more genrecog tweeks

Richard Henderson rth@cygnus.com
Thu Oct 14 18:56:00 GMT 1999


... and a bug fix for yesterday's print_rtx change.

I'm introducing `pmode_register_operand' because it seems a fairly
common thing to want to match a register based on a variable Pmode. 
No sense having 5 ports wind up defining the same thing.


r~

        * recog.c (pmode_register_operand): New.
        * recog.h: Declare it.
        * genrecog.c (pred_codes): Likewise.
        (special_mode_pred_table): Likewise.
        (validate_pattern): Don't warn no mode for address_operand.

        * print-rtl.c (print_rtx) [LABEL_REF]: Only do full subexpression
        if the operand is not insn-like.

Index: genrecog.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/genrecog.c,v
retrieving revision 1.65
diff -c -p -d -r1.65 genrecog.c
*** genrecog.c	1999/10/14 11:01:59	1.65
--- genrecog.c	1999/10/15 01:47:28
*************** static struct pred_table
*** 197,202 ****
--- 197,203 ----
    {"address_operand", {CONST_INT, CONST_DOUBLE, CONST, SYMBOL_REF,
  		       LABEL_REF, SUBREG, REG, MEM, PLUS, MINUS, MULT}},
    {"register_operand", {SUBREG, REG}},
+   {"pmode_register_operand", {SUBREG, REG}},
    {"scratch_operand", {SCRATCH, REG}},
    {"immediate_operand", {CONST_INT, CONST_DOUBLE, CONST, SYMBOL_REF,
  			 LABEL_REF}},
*************** static const char * special_mode_pred_ta
*** 220,230 ****
  #ifdef SPECIAL_MODE_PREDICATES
    SPECIAL_MODE_PREDICATES
  #endif
!   NULL
  };
  
  #define NUM_SPECIAL_MODE_PREDS \
!   (sizeof (special_mode_pred_table) / sizeof (const char *) - 1)
  
  static struct decision *new_decision
    PROTO((const char *, struct decision_head *));
--- 221,231 ----
  #ifdef SPECIAL_MODE_PREDICATES
    SPECIAL_MODE_PREDICATES
  #endif
!   "pmode_register_operand"
  };
  
  #define NUM_SPECIAL_MODE_PREDS \
!   (sizeof (special_mode_pred_table) / sizeof (special_mode_pred_table[0]))
  
  static struct decision *new_decision
    PROTO((const char *, struct decision_head *));
*************** validate_pattern (pattern, insn, set_des
*** 516,530 ****
  	/* A modeless MATCH_OPERAND can be handy when we can
  	   check for multiple modes in the c_test.  In most other cases,
  	   it is a mistake.  Only DEFINE_INSN is eligible, since SPLIT
! 	   and PEEP2 can FAIL within the output pattern.  */
  
  	if (GET_MODE (pattern) == VOIDmode
  	    && code == MATCH_OPERAND
! 	    && pred_name[0] != '\0'
  	    && allows_non_const
  	    && ! special_mode_pred
! 	    && strstr (c_test, "operands") == NULL
! 	    && GET_CODE (insn) == DEFINE_INSN)
  	  {
  	    message_with_line (pattern_lineno,
  			       "warning: operand %d missing mode?",
--- 517,534 ----
  	/* A modeless MATCH_OPERAND can be handy when we can
  	   check for multiple modes in the c_test.  In most other cases,
  	   it is a mistake.  Only DEFINE_INSN is eligible, since SPLIT
! 	   and PEEP2 can FAIL within the output pattern.  Exclude 
! 	   address_operand, since its mode is related to the mode of
! 	   the memory not the operand.  */
  
  	if (GET_MODE (pattern) == VOIDmode
  	    && code == MATCH_OPERAND
! 	    && GET_CODE (insn) == DEFINE_INSN
  	    && allows_non_const
  	    && ! special_mode_pred
! 	    && pred_name[0] != '\0'
! 	    && strcmp (pred_name, "address_operand") != 0
! 	    && strstr (c_test, "operands") == NULL)
  	  {
  	    message_with_line (pattern_lineno,
  			       "warning: operand %d missing mode?",
Index: print-rtl.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/print-rtl.c,v
retrieving revision 1.37
diff -c -p -d -r1.37 print-rtl.c
*** print-rtl.c	1999/10/14 03:43:48	1.37
--- print-rtl.c	1999/10/15 01:47:28
*************** print_rtx (in_rtx)
*** 299,314 ****
        case 'u':
  	if (XEXP (in_rtx, i) != NULL)
  	  {
! 	    if (GET_CODE (XEXP (in_rtx, i)) != CODE_LABEL)
  	      goto do_e;
  
  	    if (flag_dump_unnumbered)
  	      fputc ('#', outfile);
  	    else
! 	      fprintf (outfile, " %d", INSN_UID (XEXP (in_rtx, i)));
  	  }
  	else
! 	  fputs (" 0", outfile);
  	sawclose = 0;
  	break;
  
--- 299,319 ----
        case 'u':
  	if (XEXP (in_rtx, i) != NULL)
  	  {
! 	    rtx sub = XEXP (in_rtx, i);
! 	    enum rtx_code subc = GET_CODE (sub);
! 
! 	    if (subc != CODE_LABEL
! 		&& subc != NOTE
! 		&& GET_RTX_CLASS (subc) != 'i')
  	      goto do_e;
  
  	    if (flag_dump_unnumbered)
  	      fputc ('#', outfile);
  	    else
! 	      fprintf (outfile, " %d", INSN_UID (sub));
  	  }
  	else
! 	  fputs (" (nil)", outfile);
  	sawclose = 0;
  	break;
  
Index: recog.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/recog.c,v
retrieving revision 1.45
diff -c -p -d -r1.45 recog.c
*** recog.c	1999/10/09 19:47:18	1.45
--- recog.c	1999/10/15 01:47:28
*************** register_operand (op, mode)
*** 1027,1032 ****
--- 1027,1042 ----
  	      || REGNO_REG_CLASS (REGNO (op)) != NO_REGS));
  }
  
+ /* Return 1 for a register in Pmode; ignore the tested mode.  */
+ 
+ int
+ pmode_register_operand (op, mode)
+      rtx op;
+      enum machine_mode mode ATTRIBUTE_UNUSED;
+ {
+   return register_operand (op, Pmode);
+ }
+ 
  /* Return 1 if OP should match a MATCH_SCRATCH, i.e., if it is a SCRATCH
     or a hard register.  */
  
Index: recog.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/recog.h,v
retrieving revision 1.24
diff -c -p -d -r1.24 recog.h
*** recog.h	1999/10/01 10:00:25	1.24
--- recog.h	1999/10/15 01:47:28
*************** extern rtx *find_single_use		PROTO((rtx,
*** 91,96 ****
--- 91,97 ----
  extern int general_operand		PROTO((rtx, enum machine_mode));
  extern int address_operand		PROTO((rtx, enum machine_mode));
  extern int register_operand		PROTO((rtx, enum machine_mode));
+ extern int pmode_register_operand	PROTO((rtx, enum machine_mode));
  extern int scratch_operand		PROTO((rtx, enum machine_mode));
  extern int immediate_operand		PROTO((rtx, enum machine_mode));
  extern int const_int_operand		PROTO((rtx, enum machine_mode));


More information about the Gcc-patches mailing list