Patchwork RX: mainline: Fix obvious bugs

login
register
mail settings
Submitter Nick Clifton
Date May 12, 2011, 10:33 a.m.
Message ID <m3ei448az6.fsf@redhat.com>
Download mbox | patch
Permalink /patch/95281/
State New
Headers show

Comments

Nick Clifton - May 12, 2011, 10:33 a.m.
Hi Guys,

  I am applying the patch below to fix some small, obvious problems with
  the RX backend in the mainline sources.

Cheers
  Nick

gcc/ChangeLog
2011-05-12  DJ Delorie  <dj@redhat.com>
	    Nick Clifton  <nickc@redhat.com>

	* config/rx/rx.h (HAVE_PRE_DECREMENT): Fix typo.
	* config/rx/rx.c (CC_FLAG_FP): Fix comment.
	(rx_is_legitimate_address): Add pre-decrement and post-increment
	addressing in HImode and QImode.  Fix test for out of range
	REG+INT addressing.
	(rx_legitimate_constant_p): Rename to rx_is_legitimate_constant.
	(rx_align_for_label): Test label before extracting its usage
	count.
	(rx_adjust_insn_lengths): Fix selection of insn codes.
	(TARGET_LEGITIMATE_CONSTANT_P): Use renamed function.

Patch

Index: gcc/config/rx/rx.h
===================================================================
--- gcc/config/rx/rx.h	(revision 173693)
+++ gcc/config/rx/rx.h	(working copy)
@@ -144,7 +144,7 @@ 
 
 #define TRULY_NOOP_TRUNCATION(OUTPREC, INPREC)   1
 
-#define HAVE_PRE_DECCREMENT		1
+#define HAVE_PRE_DECREMENT		1
 #define HAVE_POST_INCREMENT		1
 
 #define MOVE_RATIO(SPEED) 		((SPEED) ? 4 : 2)
Index: gcc/config/rx/rx.c
===================================================================
--- gcc/config/rx/rx.c	(revision 173693)
+++ gcc/config/rx/rx.c	(working copy)
@@ -58,7 +58,7 @@ 
 #define CC_FLAG_Z	(1 << 1)
 #define CC_FLAG_O	(1 << 2)
 #define CC_FLAG_C	(1 << 3)
-#define CC_FLAG_FP	(1 << 4)	/* fake, to differentiate CC_Fmode */
+#define CC_FLAG_FP	(1 << 4)	/* Fake, to differentiate CC_Fmode.  */
 
 static unsigned int flags_from_mode (enum machine_mode mode);
 static unsigned int flags_from_code (enum rtx_code code);
@@ -85,7 +85,9 @@ 
     /* Register Indirect.  */
     return true;
 
-  if (GET_MODE_SIZE (mode) <= 4
+  if ((GET_MODE_SIZE (mode) == 4
+       || GET_MODE_SIZE (mode) == 2
+       || GET_MODE_SIZE (mode) == 1)
       && (GET_CODE (x) == PRE_DEC || GET_CODE (x) == POST_INC))
     /* Pre-decrement Register Indirect or
        Post-increment Register Indirect.  */
@@ -125,7 +127,7 @@ 
 	      case 1: factor = 1; break;
 	      }
 
-	    if (val >= (0x10000 * factor))
+	    if (val > (65535 * factor))
 	      return false;
 	    return (val % factor) == 0;
 	  }
@@ -1349,7 +1351,7 @@ 
     insn = emit_insn (gen_addsi3 (dest, src, val));
   else
     {
-      /* Wrap VAL in an UNSPEC so that rx_legitimate_constant_p
+      /* Wrap VAL in an UNSPEC so that rx_is_legitimate_constant
 	 will not reject it.  */
       val = gen_rtx_CONST (SImode, gen_rtx_UNSPEC (SImode, gen_rtvec (1, val), UNSPEC_CONST));
       insn = emit_insn (gen_addsi3 (dest, src, val));
@@ -2448,7 +2450,7 @@ 
    operand on the RX.  X is already known to satisfy CONSTANT_P.  */
 
 bool
-rx_legitimate_constant_p (enum machine_mode mode ATTRIBUTE_UNUSED, rtx x)
+rx_is_legitimate_constant (enum machine_mode mode ATTRIBUTE_UNUSED, rtx x)
 {
   switch (GET_CODE (x))
     {
@@ -2782,7 +2784,7 @@ 
      because the delay due to the inserted NOPs would be greater than the delay
      due to the misaligned branch.  If uses_threshold is zero then the alignment
      is always useful.  */
-  if (LABEL_NUSES (lab) < uses_threshold)
+  if (LABEL_P (lab) && LABEL_NUSES (lab) < uses_threshold)
     return 0;
 
   return optimize_size ? 1 : 3;
@@ -2837,7 +2839,7 @@ 
     case CODE_FOR_smaxsi3_zero_extendhi:
     case CODE_FOR_sminsi3_zero_extendhi:
     case CODE_FOR_multsi3_zero_extendhi:
-    case CODE_FOR_comparesi3_zero_extendqi:
+    case CODE_FOR_comparesi3_zero_extendhi:
       zero = true;
       factor = 2;
       break;
@@ -2852,7 +2854,7 @@ 
     case CODE_FOR_smaxsi3_sign_extendhi:
     case CODE_FOR_sminsi3_sign_extendhi:
     case CODE_FOR_multsi3_sign_extendhi:
-    case CODE_FOR_comparesi3_zero_extendhi:
+    case CODE_FOR_comparesi3_sign_extendhi:
       zero = false;
       factor = 2;
       break;
@@ -2867,7 +2869,7 @@ 
     case CODE_FOR_smaxsi3_zero_extendqi:
     case CODE_FOR_sminsi3_zero_extendqi:
     case CODE_FOR_multsi3_zero_extendqi:
-    case CODE_FOR_comparesi3_sign_extendqi:
+    case CODE_FOR_comparesi3_zero_extendqi:
       zero = true;
       factor = 1;
       break;
@@ -2882,7 +2884,7 @@ 
     case CODE_FOR_smaxsi3_sign_extendqi:
     case CODE_FOR_sminsi3_sign_extendqi:
     case CODE_FOR_multsi3_sign_extendqi:
-    case CODE_FOR_comparesi3_sign_extendhi:
+    case CODE_FOR_comparesi3_sign_extendqi:
       zero = false;
       factor = 1;
       break;
@@ -3062,7 +3064,7 @@ 
 #define TARGET_FLAGS_REGNUM			CC_REG
 
 #undef  TARGET_LEGITIMATE_CONSTANT_P
-#define TARGET_LEGITIMATE_CONSTANT_P		rx_legitimate_constant_p
+#define TARGET_LEGITIMATE_CONSTANT_P		rx_is_legitimate_constant
 
 struct gcc_target targetm = TARGET_INITIALIZER;