This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[patch] h8300: Turn a few macros into functions.
- From: Kazu Hirata <kazu at cs dot umass dot edu>
- To: gcc-patches at gcc dot gnu dot org
- Date: Sat, 24 Jan 2004 01:49:54 -0500 (EST)
- Subject: [patch] h8300: Turn a few macros into functions.
Hi,
Attached is a patch to turn a few macros into functions.
Built h8300-hms. Committed.
Kazu Hirata
2004-01-24 Kazu Hirata <kazu@cs.umass.edu>
* config/h8300/h8300-protos.h: Provide prototypes for
h8300_legitimate_constant_p and h8300_legitimate_address_p.
* config/h8300/h8300.c (h8300_legitimate_constant_p): New.
(h8300_rtx_ok_for_base_p): Likewise.
(h8300_legitimate_address_p): Likewise.
* config/h8300/h8300.h (LEGITIMATE_CONSTANT_P): Use
h8300_legitimate_constant_p.
(RTX_OK_FOR_BASE_P): Remove.
(GO_IF_LEGITIMATE_ADDRESS): Use h8300_legitimate_address_p.
Index: h8300-protos.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/h8300/h8300-protos.h,v
retrieving revision 1.67
diff -u -r1.67 h8300-protos.h
--- h8300-protos.h 21 Jan 2004 20:19:23 -0000 1.67
+++ h8300-protos.h 24 Jan 2004 06:33:10 -0000
@@ -81,6 +81,9 @@
extern int same_cmp_preceding_p (rtx);
extern int same_cmp_following_p (rtx);
+extern int h8300_legitimate_constant_p (rtx);
+extern int h8300_legitimate_address_p (rtx, int);
+
/* Used in builtins.c */
extern rtx h8300_return_addr_rtx (int, rtx);
#endif /* RTX_CODE */
Index: h8300.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/h8300/h8300.c,v
retrieving revision 1.263
diff -u -r1.263 h8300.c
--- h8300.c 21 Jan 2004 20:19:23 -0000 1.263
+++ h8300.c 24 Jan 2004 06:33:12 -0000
@@ -4552,6 +4552,51 @@
return 1;
}
+
+/* Return nonzero if X is a legitimate constant. */
+
+int
+h8300_legitimate_constant_p (rtx x ATTRIBUTE_UNUSED)
+{
+ return 1;
+}
+
+/* Return nonzero if X is a REG or SUBREG suitable as a base register. */
+
+static int
+h8300_rtx_ok_for_base_p (rtx x, int strict)
+{
+ /* Strip off SUBREG if any. */
+ if (GET_CODE (x) == SUBREG)
+ x = SUBREG_REG (x);
+
+ return (REG_P (x)
+ && (strict
+ ? REG_OK_FOR_BASE_STRICT_P (x)
+ : REG_OK_FOR_BASE_NONSTRICT_P (x)));
+}
+
+/* Return nozero if X is a legitimate address. On the H8/300, a
+ legitimate address has the form REG, REG+CONSTANT_ADDRESS or
+ CONSTANT_ADDRESS. */
+
+int
+h8300_legitimate_address_p (rtx x, int strict)
+{
+ /* The register indirect addresses like @er0 is always valid. */
+ if (h8300_rtx_ok_for_base_p (x, strict))
+ return 1;
+
+ if (CONSTANT_ADDRESS_P (x))
+ return 1;
+
+ if (GET_CODE (x) == PLUS
+ && CONSTANT_ADDRESS_P (XEXP (x, 1))
+ && h8300_rtx_ok_for_base_p (XEXP (x, 0), strict))
+ return 1;
+
+ return 0;
+}
/* Perform target dependent optabs initialization. */
static void
Index: h8300.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/h8300/h8300.h,v
retrieving revision 1.166
diff -u -r1.166 h8300.h
--- h8300.h 24 Jan 2004 05:32:06 -0000 1.166
+++ h8300.h 24 Jan 2004 06:33:13 -0000
@@ -796,7 +796,7 @@
/* Nonzero if the constant value X is a legitimate general operand.
It is given that X satisfies CONSTANT_P or is a CONST_DOUBLE. */
-#define LEGITIMATE_CONSTANT_P(X) (1)
+#define LEGITIMATE_CONSTANT_P(X) (h8300_legitimate_constant_p (X))
/* The macros REG_OK_FOR..._P assume that the arg is a REG rtx
and check its validity for a certain class.
@@ -879,31 +879,23 @@
(C) == 'U' ? OK_FOR_U (OP) : \
0)
-/* GO_IF_LEGITIMATE_ADDRESS recognizes an RTL expression
- that is a valid memory address for an instruction.
- The MODE argument is the machine mode for the MEM expression
- that wants to use this address.
-
- The other macros defined here are used only in GO_IF_LEGITIMATE_ADDRESS,
- except for CONSTANT_ADDRESS_P which is actually
- machine-independent.
-
- On the H8/300, a legitimate address has the form
- REG, REG+CONSTANT_ADDRESS or CONSTANT_ADDRESS. */
-
-/* Accept either REG or SUBREG where a register is valid. */
-
-#define RTX_OK_FOR_BASE_P(X) \
- ((REG_P (X) && REG_OK_FOR_BASE_P (X)) \
- || (GET_CODE (X) == SUBREG && REG_P (SUBREG_REG (X)) \
- && REG_OK_FOR_BASE_P (SUBREG_REG (X))))
-
-#define GO_IF_LEGITIMATE_ADDRESS(MODE, X, ADDR) \
- if (RTX_OK_FOR_BASE_P (X)) goto ADDR; \
- if (CONSTANT_ADDRESS_P (X)) goto ADDR; \
- if (GET_CODE (X) == PLUS \
- && CONSTANT_ADDRESS_P (XEXP (X, 1)) \
- && RTX_OK_FOR_BASE_P (XEXP (X, 0))) goto ADDR;
+#ifndef REG_OK_STRICT
+#define GO_IF_LEGITIMATE_ADDRESS(MODE, X, ADDR) \
+ do \
+ { \
+ if (h8300_legitimate_address_p ((X), 0)) \
+ goto ADDR; \
+ } \
+ while (0)
+#else
+#define GO_IF_LEGITIMATE_ADDRESS(MODE, X, ADDR) \
+ do \
+ { \
+ if (h8300_legitimate_address_p ((X), 1)) \
+ goto ADDR; \
+ } \
+ while (0)
+#endif
/* Try machine-dependent ways of modifying an illegitimate address
to be legitimate. If we find one, return the new, valid address.