[MOXIE] Hookize GO_IF_LEGITIMATE_ADDRESS
authorAnatoly Sokolov <aesok@post.ru>
Tue, 7 Jul 2015 19:46:14 +0000 (22:46 +0300)
committerAnatoly Sokolov <aesok@gcc.gnu.org>
Tue, 7 Jul 2015 19:46:14 +0000 (22:46 +0300)
From-SVN: r225524

gcc/ChangeLog
gcc/config/moxie/moxie.c
gcc/config/moxie/moxie.h

index 28022d7..0650557 100644 (file)
@@ -1,3 +1,10 @@
+2015-07-07  Anatoly Sokolov  <aesok@post.ru>
+
+       * config/moxie/moxie.h (GO_IF_LEGITIMATE_ADDRESS): Remove macros.
+       * config/moxie/moxie.c (moxie_reg_ok_for_base_p,
+         moxie_legitimate_address_p): New functions.
+         (TARGET_ADDR_SPACE_LEGITIMATE_ADDRESS_P): Define.
+
 2015-07-07  Tom de Vries  <tom@codesourcery.com>
 
        PR tree-optimization/66642
index e791829..7a80f77 100644 (file)
@@ -595,6 +595,45 @@ moxie_offset_address_p (rtx x)
   return 0;
 }
 
+/* Helper function for `moxie_legitimate_address_p'.  */
+
+static bool
+moxie_reg_ok_for_base_p (const_rtx reg, bool strict_p)
+{
+  int regno = REGNO (reg);
+
+  if (strict_p)
+    return HARD_REGNO_OK_FOR_BASE_P (regno)
+          || HARD_REGNO_OK_FOR_BASE_P (reg_renumber[regno]);
+  else    
+    return !HARD_REGISTER_NUM_P (regno)
+          || HARD_REGNO_OK_FOR_BASE_P (regno);
+}
+
+/* Worker function for TARGET_LEGITIMATE_ADDRESS_P.  */
+
+static bool
+moxie_legitimate_address_p (machine_mode mode ATTRIBUTE_UNUSED,
+                           rtx x, bool strict_p,
+                           addr_space_t as)
+{
+  gcc_assert (ADDR_SPACE_GENERIC_P (as));
+
+  if (GET_CODE(x) == PLUS
+      && REG_P (XEXP (x, 0))
+      && moxie_reg_ok_for_base_p (XEXP (x, 0), strict_p)
+      && CONST_INT_P (XEXP (x, 1))
+      && IN_RANGE (INTVAL (XEXP (x, 1)), -32768, 32767))
+    return true;
+  if (REG_P (x) && moxie_reg_ok_for_base_p (x, strict_p))
+    return true;
+  if (GET_CODE (x) == SYMBOL_REF
+      || GET_CODE (x) == LABEL_REF
+      || GET_CODE (x) == CONST)
+    return true;
+  return false;
+}
+
 /* The Global `targetm' Variable.  */
 
 /* Initialize the GCC target structure.  */
@@ -615,6 +654,8 @@ moxie_offset_address_p (rtx x)
 #undef  TARGET_FUNCTION_ARG_ADVANCE
 #define TARGET_FUNCTION_ARG_ADVANCE    moxie_function_arg_advance
 
+#undef  TARGET_ADDR_SPACE_LEGITIMATE_ADDRESS_P
+#define TARGET_ADDR_SPACE_LEGITIMATE_ADDRESS_P moxie_legitimate_address_p
 
 #undef  TARGET_SETUP_INCOMING_VARARGS
 #define TARGET_SETUP_INCOMING_VARARGS  moxie_setup_incoming_varargs
index d20d214..d8ab936 100644 (file)
@@ -451,30 +451,6 @@ enum reg_class
    elements of a jump-table should have.  */
 #define CASE_VECTOR_MODE SImode
 
-/* A C compound statement with a conditional `goto LABEL;' executed
-   if X (an RTX) is a legitimate memory address on the target machine
-   for a memory operand of mode MODE.  */
-#define GO_IF_LEGITIMATE_ADDRESS(MODE,X,LABEL)         \
-  do {                                                  \
-    if (GET_CODE(X) == PLUS)                           \
-      {                                                        \
-       rtx op1,op2;                                    \
-       op1 = XEXP(X,0);                                \
-       op2 = XEXP(X,1);                                \
-       if (GET_CODE(op1) == REG                        \
-           && GET_CODE(op2) == CONST_INT               \
-           && IN_RANGE (INTVAL (op2), -32768, 32767)   \
-           && REGNO_OK_FOR_BASE_P(REGNO(op1)))         \
-         goto LABEL;                                   \
-      }                                                        \
-    if (REG_P (X) && REGNO_OK_FOR_BASE_P (REGNO (X)))  \
-      goto LABEL;                                      \
-    if (GET_CODE (X) == SYMBOL_REF                     \
-       || GET_CODE (X) == LABEL_REF                    \
-       || GET_CODE (X) == CONST)                       \
-      goto LABEL;                                      \
-  } while (0)
-
 /* Run-time Target Specification */
 
 #define TARGET_CPU_CPP_BUILTINS() \