* recog.c (pop_operand): New function.
authorrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 19 Jan 1999 21:55:35 +0000 (21:55 +0000)
committerrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 19 Jan 1999 21:55:35 +0000 (21:55 +0000)
        * recog.h (pop_operand): Declare it.
        * genrecog.c (preds): Define it.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@24774 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/genrecog.c
gcc/recog.c
gcc/recog.h

index 572ce6c..d32ef1b 100644 (file)
@@ -1,5 +1,9 @@
 Tue Jan 19 21:20:52 1999  Richard Henderson  <rth@cygnus.com>
 
+       * recog.c (pop_operand): New function.
+       * recog.h (pop_operand): Declare it.
+       * genrecog.c (preds): Define it.
+
        * expr.c (do_jump_for_compare): Handle conditional branch expanders
        emitting multiple jump instructions.
        * jump.c (condjump_label): New function.
index da2a0cf..bcc47f0 100644 (file)
@@ -161,6 +161,7 @@ static struct pred_table
      {"nonmemory_operand", {CONST_INT, CONST_DOUBLE, CONST, SYMBOL_REF,
                            LABEL_REF, SUBREG, REG}},
      {"push_operand", {MEM}},
+     {"pop_operand", {MEM}},
      {"memory_operand", {SUBREG, MEM}},
      {"indirect_operand", {SUBREG, MEM}},
      {"comparison_operator", {EQ, NE, LE, LT, GE, GT, LEU, LTU, GEU, GTU}},
index da80b86..6d8db93 100644 (file)
@@ -41,6 +41,14 @@ Boston, MA 02111-1307, USA.  */
 #endif
 #endif
 
+#ifndef STACK_POP_CODE
+#ifdef STACK_GROWS_DOWNWARD
+#define STACK_POP_CODE POST_INC
+#else
+#define STACK_POP_CODE POST_DEC
+#endif
+#endif
+
 static void validate_replace_rtx_1     PROTO((rtx *, rtx, rtx, rtx));
 static rtx *find_single_use_1          PROTO((rtx, rtx *));
 static rtx *find_constant_term_loc     PROTO((rtx *));
@@ -1200,6 +1208,31 @@ push_operand (op, mode)
   return XEXP (op, 0) == stack_pointer_rtx;
 }
 
+/* Return 1 if OP is a valid operand that stands for popping a
+   value of mode MODE off the stack.
+
+   The main use of this function is as a predicate in match_operand
+   expressions in the machine description.  */
+
+int
+pop_operand (op, mode)
+     rtx op;
+     enum machine_mode mode;
+{
+  if (GET_CODE (op) != MEM)
+    return 0;
+
+  if (GET_MODE (op) != mode)
+    return 0;
+
+  op = XEXP (op, 0);
+
+  if (GET_CODE (op) != STACK_POP_CODE)
+    return 0;
+
+  return XEXP (op, 0) == stack_pointer_rtx;
+}
+
 /* Return 1 if ADDR is a valid memory address for mode MODE.  */
 
 int
index d85cc0f..fc4719b 100644 (file)
@@ -98,6 +98,7 @@ extern int const_double_operand               PROTO((rtx, enum machine_mode));
 extern int nonimmediate_operand                PROTO((rtx, enum machine_mode));
 extern int nonmemory_operand           PROTO((rtx, enum machine_mode));
 extern int push_operand                        PROTO((rtx, enum machine_mode));
+extern int pop_operand                 PROTO((rtx, enum machine_mode));
 extern int memory_operand              PROTO((rtx, enum machine_mode));
 extern int indirect_operand            PROTO((rtx, enum machine_mode));
 extern int mode_independent_operand    PROTO((rtx, enum machine_mode));