Add microblaze_legitimate_pic_operand method
authorDavid Holsgrove <david.holsgrove@xilinx.com>
Mon, 4 Mar 2013 15:31:49 +0000 (15:31 +0000)
committerMichael Eager <eager@gcc.gnu.org>
Mon, 4 Mar 2013 15:31:49 +0000 (15:31 +0000)
Prevents ICE where insn contains an invalid address

* config/microblaze/microblaze.c (microblaze_valid_pic_const): New
(microblaze_legitimate_pic_operand): Likewise
* config/microblaze/microblaze.h (LEGITIMATE_PIC_OPERAND_P): calls
new function microblaze_legitimate_pic_operand
* config/microblaze/microblaze-protos.h
(microblaze_legitimate_pic_operand): Declare.

From-SVN: r196434

gcc/ChangeLog
gcc/config/microblaze/microblaze-protos.h
gcc/config/microblaze/microblaze.c
gcc/config/microblaze/microblaze.h

index 8bca611a97b067083693d9e9144b4f18539d2afb..8a290e4a0de48d036e2ff35337704e9341a2f6a5 100644 (file)
@@ -1,3 +1,12 @@
+2013-03-04  David Holsgrove <david.holsgrove@xilinx.com>
+
+       * config/microblaze/microblaze.c (microblaze_valid_pic_const): New 
+       (microblaze_legitimate_pic_operand): Likewise
+       * config/microblaze/microblaze.h (LEGITIMATE_PIC_OPERAND_P): calls 
+       new function microblaze_legitimate_pic_operand
+       * config/microblaze/microblaze-protos.h
+       (microblaze_legitimate_pic_operand): Declare.
+
 2013-03-04  Edgar E. Iglesias <edgar.iglesias@gmail.com>
 
        *  config/microblaze/predicates.md (call_insn_simple_operand):
index 44740f3dbc3652e226c9ec41e65bb77ac22c0d2e..fe2ac09f86ac09e7b731b1aa39524a42239c9d5d 100644 (file)
@@ -49,6 +49,7 @@ extern HOST_WIDE_INT microblaze_initial_elimination_offset (int, int);
 extern void microblaze_declare_object (FILE *, const char *, const char *,
    const char *, int);
 extern void microblaze_asm_output_ident (const char *);
+extern int microblaze_legitimate_pic_operand (rtx);
 #endif  /* RTX_CODE */
 
 /* Declare functions in microblaze-c.c.  */
index 8458253253ca48eecf997a1c600766a42e704954..5286316e0ce299ef384f8081b93db26863f701a7 100644 (file)
@@ -596,6 +596,32 @@ microblaze_legitimate_address_p (enum machine_mode mode, rtx x, bool strict)
   return microblaze_classify_address (&addr, x, mode, strict);
 }
 
+int
+microblaze_valid_pic_const (rtx x)
+{
+  switch (GET_CODE (x))
+    {
+    case CONST:
+    case CONST_INT:
+    case CONST_DOUBLE:
+      return true;
+    default:
+      return false;
+    }
+}
+
+int
+microblaze_legitimate_pic_operand (rtx x)
+{
+  struct microblaze_address_info addr;
+
+  if (pic_address_needs_scratch (x))
+    return 0;
+  if (!microblaze_valid_pic_const(x))
+    return 0;
+
+  return 1;
+}
 
 /* Try machine-dependent ways of modifying an illegitimate address
    to be legitimate.  If we find one, return the new, valid address.
index 23ed16e4f6c14b04ee5b0d66d41cccc506bdd569..c726978800dc444a78a9fbafc7cd34a946b67af8 100644 (file)
@@ -541,7 +541,7 @@ typedef struct microblaze_args
 
 /* Define this, so that when PIC, reload won't try to reload invalid
    addresses which require two reload registers.  */
-#define LEGITIMATE_PIC_OPERAND_P(X)  (!pic_address_needs_scratch (X))
+#define LEGITIMATE_PIC_OPERAND_P(X)  microblaze_legitimate_pic_operand (X)
 
 #define CASE_VECTOR_MODE                       (SImode)