diff options
author | Uros Bizjak <ubizjak@gmail.com> | 2023-04-21 14:26:46 +0200 |
---|---|---|
committer | Uros Bizjak <ubizjak@gmail.com> | 2023-04-21 16:31:52 +0200 |
commit | 18c9427b66fc0df663ae30ba721ef4e590902e30 (patch) | |
tree | 6510bf263a0011ecaba6cfd46b02b7ce01278799 /gcc | |
parent | 2f4e45101dd812a6fcc1e5d96efedc60b8735432 (diff) | |
download | gcc-18c9427b66fc0df663ae30ba721ef4e590902e30.zip gcc-18c9427b66fc0df663ae30ba721ef4e590902e30.tar.gz gcc-18c9427b66fc0df663ae30ba721ef4e590902e30.tar.bz2 |
i386: Remove REG_OK_FOR_INDEX/REG_OK_FOR_BASE and their derivatives
x86 was converted to TARGET_LEGITIMATE_ADDRESS_P long ago. Remove
remnants of the conversion. Also, cleanup the remaining macros a bit
by introducing INDEX_REGNO_P macro.
No functional change.
gcc/ChangeLog:
2023-04-21 Uroš Bizjak <ubizjak@gmail.com>
* config/i386/i386.h (REG_OK_FOR_INDEX_P, REG_OK_FOR_BASE_P): Remove.
(REG_OK_FOR_INDEX_NONSTRICT_P, REG_OK_FOR_BASE_NONSTRICT_P): Ditto.
(REG_OK_FOR_INDEX_STRICT_P, REG_OK_FOR_BASE_STRICT_P): Ditto.
(FIRST_INDEX_REG, LAST_INDEX_REG): New defines.
(LEGACY_INDEX_REG_P, LEGACY_INDEX_REGNO_P): New macros.
(INDEX_REG_P, INDEX_REGNO_P): Ditto.
(REGNO_OK_FOR_INDEX_P): Use INDEX_REGNO_P predicates.
(REGNO_OK_FOR_INDEX_NONSTRICT_P): New macro.
(EG_OK_FOR_BASE_NONSTRICT_P): Ditto.
* config/i386/predicates.md (index_register_operand):
Use REGNO_OK_FOR_INDEX_P and REGNO_OK_FOR_INDEX_NONSTRICT_P macros.
* config/i386/i386.cc (ix86_legitimate_address_p): Use
REGNO_OK_FOR_BASE_P, REGNO_OK_FOR_BASE_NONSTRICT_P,
REGNO_OK_FOR_INDEX_P and REGNO_OK_FOR_INDEX_NONSTRICT_P macros.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/config/i386/i386.cc | 10 | ||||
-rw-r--r-- | gcc/config/i386/i386.h | 69 | ||||
-rw-r--r-- | gcc/config/i386/predicates.md | 5 |
3 files changed, 34 insertions, 50 deletions
diff --git a/gcc/config/i386/i386.cc b/gcc/config/i386/i386.cc index fbd33a6..a3db556 100644 --- a/gcc/config/i386/i386.cc +++ b/gcc/config/i386/i386.cc @@ -11035,8 +11035,9 @@ ix86_legitimate_address_p (machine_mode, rtx addr, bool strict) if (reg == NULL_RTX) return false; - if ((strict && ! REG_OK_FOR_BASE_STRICT_P (reg)) - || (! strict && ! REG_OK_FOR_BASE_NONSTRICT_P (reg))) + unsigned int regno = REGNO (reg); + if ((strict && !REGNO_OK_FOR_BASE_P (regno)) + || (!strict && !REGNO_OK_FOR_BASE_NONSTRICT_P (regno))) /* Base is not valid. */ return false; } @@ -11049,8 +11050,9 @@ ix86_legitimate_address_p (machine_mode, rtx addr, bool strict) if (reg == NULL_RTX) return false; - if ((strict && ! REG_OK_FOR_INDEX_STRICT_P (reg)) - || (! strict && ! REG_OK_FOR_INDEX_NONSTRICT_P (reg))) + unsigned int regno = REGNO (reg); + if ((strict && !REGNO_OK_FOR_INDEX_P (regno)) + || (!strict && !REGNO_OK_FOR_INDEX_NONSTRICT_P (regno))) /* Index is not valid. */ return false; } diff --git a/gcc/config/i386/i386.h b/gcc/config/i386/i386.h index 1da6dce..c7439f8 100644 --- a/gcc/config/i386/i386.h +++ b/gcc/config/i386/i386.h @@ -1166,6 +1166,9 @@ extern const char *host_detect_local_cpu (int argc, const char **argv); #define FIRST_INT_REG AX_REG #define LAST_INT_REG SP_REG +#define FIRST_INDEX_REG AX_REG +#define LAST_INDEX_REG BP_REG + #define FIRST_QI_REG AX_REG #define LAST_QI_REG BX_REG @@ -1404,7 +1407,11 @@ enum reg_class #define QI_REGNO_P(N) IN_RANGE ((N), FIRST_QI_REG, LAST_QI_REG) #define LEGACY_INT_REG_P(X) (REG_P (X) && LEGACY_INT_REGNO_P (REGNO (X))) -#define LEGACY_INT_REGNO_P(N) (IN_RANGE ((N), FIRST_INT_REG, LAST_INT_REG)) +#define LEGACY_INT_REGNO_P(N) IN_RANGE ((N), FIRST_INT_REG, LAST_INT_REG) + +#define LEGACY_INDEX_REG_P(X) (REG_P (X) && LEGACY_INDEX_REGNO_P (REGNO (X))) +#define LEGACY_INDEX_REGNO_P(N) \ + IN_RANGE ((N), FIRST_INDEX_REG, LAST_INDEX_REG) #define REX_INT_REG_P(X) (REG_P (X) && REX_INT_REGNO_P (REGNO (X))) #define REX_INT_REGNO_P(N) \ @@ -1414,6 +1421,10 @@ enum reg_class #define GENERAL_REGNO_P(N) \ (LEGACY_INT_REGNO_P (N) || REX_INT_REGNO_P (N)) +#define INDEX_REG_P(X) (REG_P (X) && INDEX_REGNO_P (REGNO (X))) +#define INDEX_REGNO_P(N) \ + (LEGACY_INDEX_REGNO_P (N) || REX_INT_REGNO_P (N)) + #define ANY_QI_REG_P(X) (REG_P (X) && ANY_QI_REGNO_P (REGNO (X))) #define ANY_QI_REGNO_P(N) \ (TARGET_64BIT ? GENERAL_REGNO_P (N) : QI_REGNO_P (N)) @@ -1678,56 +1689,26 @@ typedef struct ix86_args { has been allocated, which happens in reginfo.cc during register allocation. */ -#define REGNO_OK_FOR_INDEX_P(REGNO) \ - ((REGNO) < STACK_POINTER_REGNUM \ - || REX_INT_REGNO_P (REGNO) \ - || (unsigned) reg_renumber[(REGNO)] < STACK_POINTER_REGNUM \ - || REX_INT_REGNO_P ((unsigned) reg_renumber[(REGNO)])) +#define REGNO_OK_FOR_INDEX_P(REGNO) \ + (INDEX_REGNO_P (REGNO) \ + || INDEX_REGNO_P (reg_renumber[(REGNO)])) -#define REGNO_OK_FOR_BASE_P(REGNO) \ +#define REGNO_OK_FOR_BASE_P(REGNO) \ (GENERAL_REGNO_P (REGNO) \ || (REGNO) == ARG_POINTER_REGNUM \ || (REGNO) == FRAME_POINTER_REGNUM \ - || GENERAL_REGNO_P ((unsigned) reg_renumber[(REGNO)])) - -/* The macros REG_OK_FOR..._P assume that the arg is a REG rtx - and check its validity for a certain class. - We have two alternate definitions for each of them. - The usual definition accepts all pseudo regs; the other rejects - them unless they have been allocated suitable hard regs. - The symbol REG_OK_STRICT causes the latter definition to be used. - - Most source files want to accept pseudo regs in the hope that - they will get allocated to the class that the insn wants them to be in. - Source files for reload pass need to be strict. - After reload, it makes no difference, since pseudo regs have - been eliminated by then. */ - + || GENERAL_REGNO_P (reg_renumber[(REGNO)])) /* Non strict versions, pseudos are ok. */ -#define REG_OK_FOR_INDEX_NONSTRICT_P(X) \ - (REGNO (X) < STACK_POINTER_REGNUM \ - || REX_INT_REGNO_P (REGNO (X)) \ - || REGNO (X) >= FIRST_PSEUDO_REGISTER) +#define REGNO_OK_FOR_INDEX_NONSTRICT_P(REGNO) \ + (INDEX_REGNO_P (REGNO) \ + || !HARD_REGISTER_NUM_P (REGNO)) -#define REG_OK_FOR_BASE_NONSTRICT_P(X) \ - (GENERAL_REGNO_P (REGNO (X)) \ - || REGNO (X) == ARG_POINTER_REGNUM \ - || REGNO (X) == FRAME_POINTER_REGNUM \ - || REGNO (X) >= FIRST_PSEUDO_REGISTER) - -/* Strict versions, hard registers only */ -#define REG_OK_FOR_INDEX_STRICT_P(X) REGNO_OK_FOR_INDEX_P (REGNO (X)) -#define REG_OK_FOR_BASE_STRICT_P(X) REGNO_OK_FOR_BASE_P (REGNO (X)) - -#ifndef REG_OK_STRICT -#define REG_OK_FOR_INDEX_P(X) REG_OK_FOR_INDEX_NONSTRICT_P (X) -#define REG_OK_FOR_BASE_P(X) REG_OK_FOR_BASE_NONSTRICT_P (X) - -#else -#define REG_OK_FOR_INDEX_P(X) REG_OK_FOR_INDEX_STRICT_P (X) -#define REG_OK_FOR_BASE_P(X) REG_OK_FOR_BASE_STRICT_P (X) -#endif +#define REGNO_OK_FOR_BASE_NONSTRICT_P(REGNO) \ + (GENERAL_REGNO_P (REGNO) \ + || (REGNO) == ARG_POINTER_REGNUM \ + || (REGNO) == FRAME_POINTER_REGNUM \ + || !HARD_REGISTER_NUM_P (REGNO)) /* TARGET_LEGITIMATE_ADDRESS_P recognizes an RTL expression that is a valid memory address for an instruction. diff --git a/gcc/config/i386/predicates.md b/gcc/config/i386/predicates.md index e752e20..91400d7 100644 --- a/gcc/config/i386/predicates.md +++ b/gcc/config/i386/predicates.md @@ -728,10 +728,11 @@ if (SUBREG_P (op)) op = SUBREG_REG (op); + unsigned int regno = REGNO (op); if (reload_completed) - return REG_OK_FOR_INDEX_STRICT_P (op); + return REGNO_OK_FOR_INDEX_P (regno); else - return REG_OK_FOR_INDEX_NONSTRICT_P (op); + return REGNO_OK_FOR_INDEX_NONSTRICT_P (regno); }) ;; Return false if this is any eliminable register. Otherwise general_operand. |