This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[addrmodes] More addresses.h APIs
- From: Paolo Bonzini <paolo dot bonzini at lu dot unisi dot ch>
- To: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Mon, 21 Aug 2006 10:41:26 +0200
- Subject: [addrmodes] More addresses.h APIs
This patch adds more APIs to addresses.h, and replaces uses of
ok_for_base_p_1 outside addresses.h. That function would go away once
everybody starts using the newer macros.
Committed to branch.
Paolo
2006-08-21 Paolo Bonzini <bonzini@gnu.org>
* addresses.h (regno_ok_for_base_p): Return false for pseudos whose
reg_renumber is <0.
(ok_for_base_p, regno_ok_for_base_p_nonstrict, ok_for_base_p_nonstrict,
regno_ok_for_index_p, ok_for_index_p, regno_ok_for_index_p_nonstrict,
ok_for_index_p_nonstrict): New.
* regclass.c (ok_for_index_p_nonstrict, ok_for_base_p_nonstrict): Delete.
* rtl-factoring.c (recompute_gain_for_pattern_seq): Use
regno_ok_for_base_p_nonstrict instead of ok_for_base_p_1.
Index: addresses.h
===================================================================
--- addresses.h (revision 116286)
+++ addresses.h (working copy)
@@ -75,7 +75,115 @@ regno_ok_for_base_p (unsigned regno, enu
enum rtx_code outer_code, enum rtx_code index_code)
{
if (regno >= FIRST_PSEUDO_REGISTER && reg_renumber[regno] >= 0)
- regno = reg_renumber[regno];
+ {
+ if (reg_renumber[regno] >= 0)
+ regno = reg_renumber[regno];
+ else
+ return false;
+ }
return ok_for_base_p_1 (regno, mode, outer_code, index_code);
}
+
+/* Wrapper around ok_for_base_p_1, for use after register allocation is
+ complete. Arguments as for the called function. */
+
+static inline bool
+ok_for_base_p (rtx reg, enum machine_mode mode,
+ enum rtx_code outer_code, enum rtx_code index_code)
+{
+ unsigned regno = REGNO (reg);
+ if (regno >= FIRST_PSEUDO_REGISTER && reg_renumber[regno] >= 0)
+ {
+ if (reg_renumber[regno] >= 0)
+ regno = reg_renumber[regno];
+ else
+ return false;
+ }
+
+ return ok_for_base_p_1 (regno, mode, outer_code, index_code);
+}
+
+
+/* A version of regno_ok_for_base_p for use during regclass, when all pseudos
+ should count as OK. Arguments as for regno_ok_for_base_p. */
+
+static inline bool
+regno_ok_for_base_p_nonstrict (unsigned regno, enum machine_mode mode,
+ enum rtx_code outer_code, enum rtx_code index_code)
+{
+ return regno >= FIRST_PSEUDO_REGISTER
+ || ok_for_base_p_1 (regno, mode, outer_code, index_code);
+}
+
+
+/* A version of regno_ok_for_base_p for use during regclass, when all pseudos
+ should count as OK. Arguments as for regno_ok_for_base_p. */
+
+static inline bool
+ok_for_base_p_nonstrict (rtx reg, enum machine_mode mode,
+ enum rtx_code outer_code, enum rtx_code index_code)
+{
+ unsigned regno = REGNO (reg);
+ if (regno >= FIRST_PSEUDO_REGISTER)
+ return true;
+
+ return regno >= FIRST_PSEUDO_REGISTER
+ || ok_for_base_p_1 (regno, mode, outer_code, index_code);
+}
+
+/* Wrapper around REGNO_OK_FOR_INDEX_P, for use after register allocation is
+ complete. Arguments as for REGNO_OK_FOR_INDEX_P. */
+
+static inline bool
+regno_ok_for_index_p (unsigned regno)
+{
+ if (regno >= FIRST_PSEUDO_REGISTER)
+ {
+ if (reg_renumber[regno] >= 0)
+ regno = reg_renumber[regno];
+ else
+ return false;
+ }
+
+ return REGNO_OK_FOR_INDEX_P (regno);
+}
+
+/* Wrapper around REGNO_OK_FOR_INDEX_P, for use after register allocation is
+ complete. Arguments as for REGNO_OK_FOR_INDEX_P. */
+
+static inline bool
+ok_for_index_p (rtx reg)
+{
+ unsigned regno = REGNO (reg);
+ if (regno >= FIRST_PSEUDO_REGISTER)
+ {
+ if (reg_renumber[regno] >= 0)
+ regno = reg_renumber[regno];
+ else
+ return false;
+ }
+
+ return REGNO_OK_FOR_INDEX_P (regno);
+}
+
+/* Wrapper around REGNO_OK_FOR_INDEX_P, to allow pseudo registers. */
+
+static inline bool
+regno_ok_for_index_p_nonstrict (unsigned regno)
+{
+ return regno >= FIRST_PSEUDO_REGISTER
+ || REGNO_OK_FOR_INDEX_P (regno);
+}
+
+/* Wrapper around REGNO_OK_FOR_INDEX_P, to allow pseudo registers. */
+
+static inline bool
+ok_for_index_p_nonstrict (rtx reg)
+{
+ unsigned regno = REGNO (reg);
+ return regno >= FIRST_PSEUDO_REGISTER
+ || REGNO_OK_FOR_INDEX_P (regno);
+}
+
+
Index: regclass.c
===================================================================
--- regclass.c (revision 116286)
+++ regclass.c (working copy)
@@ -860,29 +860,6 @@ static int auto_inc_dec_reg_p (rtx, enum
#endif
static void reg_scan_mark_refs (rtx, rtx, int);
-/* Wrapper around REGNO_OK_FOR_INDEX_P, to allow pseudo registers. */
-
-static inline bool
-ok_for_index_p_nonstrict (rtx reg)
-{
- unsigned regno = REGNO (reg);
- return regno >= FIRST_PSEUDO_REGISTER || REGNO_OK_FOR_INDEX_P (regno);
-}
-
-/* A version of regno_ok_for_base_p for use during regclass, when all pseudos
- should count as OK. Arguments as for regno_ok_for_base_p. */
-
-static inline bool
-ok_for_base_p_nonstrict (rtx reg, enum machine_mode mode,
- enum rtx_code outer_code, enum rtx_code index_code)
-{
- unsigned regno = REGNO (reg);
- if (regno >= FIRST_PSEUDO_REGISTER)
- return true;
-
- return ok_for_base_p_1 (regno, mode, outer_code, index_code);
-}
-
/* Return the reg_class in which pseudo reg number REGNO is best allocated.
This function is sometimes called before the info has been computed.
When that happens, just return GENERAL_REGS, which is innocuous. */
Index: rtl-factoring.c
===================================================================
--- rtl-factoring.c (revision 116286)
+++ rtl-factoring.c (working copy)
@@ -690,7 +690,7 @@ recompute_gain_for_pattern_seq (pattern_
#ifdef REGNO_OK_FOR_INDIRECT_JUMP_P
|| (!REGNO_OK_FOR_INDIRECT_JUMP_P (i, Pmode))
#else
- || (!ok_for_base_p_1 (i, Pmode, MEM, SCRATCH))
+ || (!regno_ok_for_base_p_nonstrict (i, Pmode, MEM, SCRATCH))
|| (!reg_class_subset_p (REGNO_REG_CLASS (i),
base_reg_class (VOIDmode, MEM, SCRATCH)))
#endif