Index: gcc/config/ia64/ia64.c
===================================================================
--- gcc/config/ia64/ia64.c      (revision 182245)
+++ gcc/config/ia64/ia64.c      (working copy)
@@ -309,6 +309,7 @@
 static bool ia64_scalar_mode_supported_p (enum machine_mode mode);
 static bool ia64_vector_mode_supported_p (enum machine_mode mode);
 static bool ia64_legitimate_constant_p (enum machine_mode, rtx);
+static bool ia64_legitimate_address_p (enum machine_mode, rtx, bool);
 static bool ia64_cannot_force_const_mem (enum machine_mode, rtx);
 static const char *ia64_mangle_type (const_tree);
 static const char *ia64_invalid_conversion (const_tree, const_tree);
@@ -583,6 +584,8 @@
 
 #undef TARGET_LEGITIMATE_CONSTANT_P
 #define TARGET_LEGITIMATE_CONSTANT_P ia64_legitimate_constant_p
+#undef TARGET_LEGITIMATE_ADDRESS_P
+#define TARGET_LEGITIMATE_ADDRESS_P ia64_legitimate_address_p
 
 #undef TARGET_CANNOT_FORCE_CONST_MEM
 #define TARGET_CANNOT_FORCE_CONST_MEM ia64_cannot_force_const_mem
@@ -937,6 +940,68 @@
   return tls_kind;
 }
 
+/* Returns true if REG (assumed to be a `reg' RTX) is valid for use
+   as a base register.  */
+
+static inline bool
+ia64_reg_ok_for_base_p (const_rtx reg, bool strict)
+{
+  if (strict
+      && REGNO_OK_FOR_BASE_P (REGNO (reg)))
+    return true;
+  else if (!strict
+          && (GENERAL_REGNO_P (REGNO (reg))
+              || !HARD_REGISTER_P (reg)))
+    return true;
+  else
+    return false;
+}
+
+static bool
+ia64_legitimate_address_reg (const_rtx reg, bool strict)
+{
+  if ((REG_P (reg) && ia64_reg_ok_for_base_p (reg, strict))
+      || (GET_CODE (reg) == SUBREG && REG_P (XEXP (reg, 0))
+         && ia64_reg_ok_for_base_p (XEXP (reg, 0), strict)))
+    return true;
+
+  return false;
+}
+
+static bool
+ia64_legitimate_address_disp (const_rtx reg, const_rtx disp, bool strict)
+{
+  if (GET_CODE (disp) == PLUS
+      && rtx_equal_p (reg, XEXP (disp, 0))
+      && (ia64_legitimate_address_reg (XEXP (disp, 1), strict)
+         || (CONST_INT_P (XEXP (disp, 1))
+             && IN_RANGE (INTVAL (XEXP (disp, 1)), -256, 255))))
+    return true;
+
+  return false;
+}
+
+/* Implement TARGET_LEGITIMATE_ADDRESS_P.  */
+
+static bool
+ia64_legitimate_address_p (enum machine_mode mode ATTRIBUTE_UNUSED,
+                          rtx x, bool strict)
+{
+  if (ia64_legitimate_address_reg (x, strict))
+    return true;
+  else if ((GET_CODE (x) == POST_INC || GET_CODE (x) == POST_DEC)
+          && ia64_legitimate_address_reg (XEXP (x, 0), strict)
+          && XEXP (x, 0) != arg_pointer_rtx) 
+    return true;
+  else if (GET_CODE (x) == POST_MODIFY
+          && ia64_legitimate_address_reg (XEXP (x, 0), strict)
+          && XEXP (x, 0) != arg_pointer_rtx
+          && ia64_legitimate_address_disp (XEXP (x, 0), XEXP (x, 1), strict))
+    return true;
+  else
+    return false;
+}
+
 /* Return true if X is a constant that is valid for some immediate
    field in an instruction.  */
 
Index: gcc/config/ia64/ia64.h
===================================================================
--- gcc/config/ia64/ia64.h      (revision 182245)
+++ gcc/config/ia64/ia64.h      (working copy)
@@ -1154,52 +1154,6 @@
 
 #define MAX_REGS_PER_ADDRESS 2
 
-/* 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 LEGITIMATE_ADDRESS_REG(X)                                      \
-  ((GET_CODE (X) == REG && REG_OK_FOR_BASE_P (X))                      \
-   || (GET_CODE (X) == SUBREG && GET_CODE (XEXP (X, 0)) == REG         \
-       && REG_OK_FOR_BASE_P (XEXP (X, 0))))
-
-#define LEGITIMATE_ADDRESS_DISP(R, X)                                  \
-  (GET_CODE (X) == PLUS                                                        \
-   && rtx_equal_p (R, XEXP (X, 0))                                     \
-   && (LEGITIMATE_ADDRESS_REG (XEXP (X, 1))                            \
-       || (GET_CODE (XEXP (X, 1)) == CONST_INT                         \
-          && INTVAL (XEXP (X, 1)) >= -256                              \
-          && INTVAL (XEXP (X, 1)) < 256)))
-
-#define GO_IF_LEGITIMATE_ADDRESS(MODE, X, LABEL)                       \
-do {                                                                   \
-  if (LEGITIMATE_ADDRESS_REG (X))                                      \
-    goto LABEL;                                                                \
-  else if ((GET_CODE (X) == POST_INC || GET_CODE (X) == POST_DEC)      \
-          && LEGITIMATE_ADDRESS_REG (XEXP (X, 0))                      \
-          && XEXP (X, 0) != arg_pointer_rtx)                           \
-    goto LABEL;                                                                \
-  else if (GET_CODE (X) == POST_MODIFY                                 \
-          && LEGITIMATE_ADDRESS_REG (XEXP (X, 0))                      \
-          && XEXP (X, 0) != arg_pointer_rtx                            \
-          && LEGITIMATE_ADDRESS_DISP (XEXP (X, 0), XEXP (X, 1)))       \
-    goto LABEL;                                                                \
-} while (0)
-
-/* A C expression that is nonzero if X (assumed to be a `reg' RTX) is valid for
-   use as a base register.  */
-
-#ifdef REG_OK_STRICT
-#define REG_OK_FOR_BASE_P(X) REGNO_OK_FOR_BASE_P (REGNO (X))
-#else
-#define REG_OK_FOR_BASE_P(X) \
-  (GENERAL_REGNO_P (REGNO (X)) || (REGNO (X) >= FIRST_PSEUDO_REGISTER))
-#endif
-
-/* A C expression that is nonzero if X (assumed to be a `reg' RTX) is valid for
-   use as an index register.  This is needed for POST_MODIFY.  */
-
-#define REG_OK_FOR_INDEX_P(X) REG_OK_FOR_BASE_P (X)
 
 /* Condition Code Status */
 
