(clrstrsi): Correct check for constant size.
authorRichard Kenner <kenner@gcc.gnu.org>
Sat, 14 Sep 1996 21:01:32 +0000 (17:01 -0400)
committerRichard Kenner <kenner@gcc.gnu.org>
Sat, 14 Sep 1996 21:01:32 +0000 (17:01 -0400)
(allocate_stack{,_worker}): New patterns.

From-SVN: r12708

gcc/config/i386/i386.md

index 33c9ac691d9fb0ed7838c46d7bd80c7d359a2b97..a1480fbe60472576fd54610eaf73fd9901537925 100644 (file)
@@ -58,6 +58,8 @@
 ;;    operand 0 is the argument for `sin'.
 ;; 2  This is a `cos' operation.  The mode of the UNSPEC is MODE_FLOAT.
 ;;    operand 0 is the argument for `cos'.
+;; 3  This is part of a `stack probe' operation.  The mode of the UNSPEC is 
+;;    always SImode.  operand 0 is the size of the stack allocation.
 \f
 ;; This shadows the processor_type enumeration, so changes must be made
 ;; to i386.h at the same time.
 {
   rtx addr0, addr1;
 
-  if (GET_CODE (operands[2]) != CONST_INT)
+  if (GET_CODE (operands[1]) != CONST_INT)
     FAIL;
 
   addr0 = copy_to_mode_reg (Pmode, XEXP (operands[0], 0));
   "(TARGET_USE_Q_REG && optimize > 1)"
   "* return output_strlen_unroll (operands);"
 )
+
+(define_insn "allocate_stack_worker"
+  [(unspec:SI [(match_operand:SI 0 "register_operand" "a")] 3)
+   (set (reg:SI 7) (minus:SI (reg:SI 7) (match_dup 0)))
+   (clobber (match_dup 0))]
+  "TARGET_STACK_PROBE"
+  "* return AS1(call,__alloca);")
+
+(define_expand "allocate_stack"
+  [(set (reg:SI 7)
+       (minus:SI (reg:SI 7) (match_operand:SI 0 "general_operand" "")))]
+  "TARGET_STACK_PROBE"
+  "
+{
+#ifdef CHECK_STACK_LIMIT
+  if (GET_CODE (operands[0]) == CONST_INT
+      && INTVAL (operands[0]) < CHECK_STACK_LIMIT)
+    emit_insn (gen_subsi3 (stack_pointer_rtx, stack_pointer_rtx,
+                          operands[0]));
+  else 
+#endif
+    emit_insn (gen_allocate_stack_worker (copy_to_mode_reg (SImode,
+                                                           operands[0])));
+
+  DONE;
+}")