diff options
author | Richard Henderson <rth@gcc.gnu.org> | 2002-03-12 21:42:40 -0800 |
---|---|---|
committer | Richard Henderson <rth@gcc.gnu.org> | 2002-03-12 21:42:40 -0800 |
commit | 5b43fed17bf58c31f3151dd37966e7a9b85a309e (patch) | |
tree | ff7ebe9916a64b81e187d279cffac13101372cd6 /gcc/config | |
parent | 56d4fe31c5265b7f5a0aaea8d5013a7154b211e8 (diff) | |
download | gcc-5b43fed17bf58c31f3151dd37966e7a9b85a309e.zip gcc-5b43fed17bf58c31f3151dd37966e7a9b85a309e.tar.gz gcc-5b43fed17bf58c31f3151dd37966e7a9b85a309e.tar.bz2 |
re PR rtl-optimization/5878 (gcc 3.1 breaks on C code generated by the Mercury compiler)
PR 5878
* config/arc/arc.h, config/cris/cris.h, config/i386/i386.h,
config/m68k/m68k.h, config/s390/s390.h, config/sparc/sparc.h
(PIC_OFFSET_TABLE_REGNUM): Conditionalize on flag_pic.
* config/arm/arm.h config/i386/i386.h, config/m68k/m68k.h,
config/sparc/sparc.h (CONDITIONAL_REGISTER_USAGE): Set
PIC_OFFSET_TABLE_REGNUM based on INVALID_REGNUM not flag_pic.
* config/arc/arc.h (CONDITIONAL_REGISTER_USAGE): New.
* config/arm/arm.c (arm_pic_register): Init to INVALID_REGNUM.
(arm_override_options): Set arm_pic_register if TARGET_APCS_STACK
also. Don't set it if not flag_pic.
* config/i386/i386.c (ix86_save_reg): Trust PIC_OFFSET_TABLE_REGNUM
to be INVALID_REGNUM when not used.
* gcc.dg/20020312-2.c: New.
From-SVN: r50713
Diffstat (limited to 'gcc/config')
-rw-r--r-- | gcc/config/arc/arc.h | 12 | ||||
-rw-r--r-- | gcc/config/arm/arm.c | 20 | ||||
-rw-r--r-- | gcc/config/arm/arm.h | 2 | ||||
-rw-r--r-- | gcc/config/cris/cris.h | 2 | ||||
-rw-r--r-- | gcc/config/i386/i386.c | 4 | ||||
-rw-r--r-- | gcc/config/i386/i386.h | 12 | ||||
-rw-r--r-- | gcc/config/m68k/m68k.h | 72 | ||||
-rw-r--r-- | gcc/config/s390/s390.h | 2 | ||||
-rw-r--r-- | gcc/config/sparc/sparc.h | 4 |
9 files changed, 68 insertions, 62 deletions
diff --git a/gcc/config/arc/arc.h b/gcc/config/arc/arc.h index 4ba19f1..651d81e 100644 --- a/gcc/config/arc/arc.h +++ b/gcc/config/arc/arc.h @@ -355,6 +355,16 @@ if (GET_MODE_CLASS (MODE) == MODE_INT \ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, \ 27, 28, 29, 30 } +/* Macro to conditionally modify fixed_regs/call_used_regs. */ +#define CONDITIONAL_REGISTER_USAGE \ +do { \ + if (PIC_OFFSET_TABLE_REGNUM != INVALID_REGNUM) \ + { \ + fixed_regs[PIC_OFFSET_TABLE_REGNUM] = 1; \ + call_used_regs[PIC_OFFSET_TABLE_REGNUM] = 1; \ + } \ +} while (0) + /* Return number of consecutive hard regs needed starting at reg REGNO to hold something of mode MODE. This is ordinarily the length in words of a value of mode MODE @@ -1152,7 +1162,7 @@ do { \ pointer and frame pointer registers. If this macro is not defined, it is up to the machine-dependent files to allocate such a register (if necessary). */ -#define PIC_OFFSET_TABLE_REGNUM 26 +#define PIC_OFFSET_TABLE_REGNUM (flag_pic ? 26 : INVALID_REGNUM) /* Define this macro if the register defined by PIC_OFFSET_TABLE_REGNUM is clobbered by calls. Do not define this macro if PIC_OFFSET_TABLE_REGNUM diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c index 4a0e851..8e85957 100644 --- a/gcc/config/arm/arm.c +++ b/gcc/config/arm/arm.c @@ -268,7 +268,7 @@ enum machine_mode output_memory_reference_mode; /* The register number to be used for the PIC offset register. */ const char * arm_pic_register_string = NULL; -int arm_pic_register = 9; +int arm_pic_register = INVALID_REGNUM; /* Set to 1 when a return insn is output, this means that the epilogue is not needed. */ @@ -651,8 +651,8 @@ arm_override_options () /* If stack checking is disabled, we can use r10 as the PIC register, which keeps r9 available. */ - if (flag_pic && !TARGET_APCS_STACK) - arm_pic_register = 10; + if (flag_pic) + arm_pic_register = TARGET_APCS_STACK ? 9 : 10; if (TARGET_APCS_FLOAT) warning ("passing floating point arguments in fp regs not yet supported"); @@ -713,18 +713,16 @@ arm_override_options () if (arm_pic_register_string != NULL) { - int pic_register; - + int pic_register = decode_reg_name (arm_pic_register_string); + if (!flag_pic) warning ("-mpic-register= is useless without -fpic"); - pic_register = decode_reg_name (arm_pic_register_string); - /* Prevent the user from choosing an obviously stupid PIC register. */ - if (pic_register < 0 || call_used_regs[pic_register] - || pic_register == HARD_FRAME_POINTER_REGNUM - || pic_register == STACK_POINTER_REGNUM - || pic_register >= PC_REGNUM) + else if (pic_register < 0 || call_used_regs[pic_register] + || pic_register == HARD_FRAME_POINTER_REGNUM + || pic_register == STACK_POINTER_REGNUM + || pic_register >= PC_REGNUM) error ("unable to use '%s' for PIC register", arm_pic_register_string); else arm_pic_register = pic_register; diff --git a/gcc/config/arm/arm.h b/gcc/config/arm/arm.h index c180e26..240595e 100644 --- a/gcc/config/arm/arm.h +++ b/gcc/config/arm/arm.h @@ -838,7 +838,7 @@ extern const char * structure_size_string; regno <= LAST_ARM_FP_REGNUM; ++regno) \ fixed_regs[regno] = call_used_regs[regno] = 1; \ } \ - if (flag_pic) \ + if (PIC_OFFSET_TABLE_REGNUM != INVALID_REGNUM) \ { \ fixed_regs[PIC_OFFSET_TABLE_REGNUM] = 1; \ call_used_regs[PIC_OFFSET_TABLE_REGNUM] = 1; \ diff --git a/gcc/config/cris/cris.h b/gcc/config/cris/cris.h index 235777d..21065a9 100644 --- a/gcc/config/cris/cris.h +++ b/gcc/config/cris/cris.h @@ -1468,7 +1468,7 @@ call_ ## FUNC (void) \ /* Node: PIC */ -#define PIC_OFFSET_TABLE_REGNUM 0 +#define PIC_OFFSET_TABLE_REGNUM (flag_pic ? 0 : INVALID_REGNUM) #define LEGITIMATE_PIC_OPERAND_P(X) cris_legitimate_pic_operand (X) diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index 56fdf90..2d06499 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -3880,9 +3880,7 @@ ix86_save_reg (regno, maybe_eh_return) int regno; int maybe_eh_return; { - if (flag_pic - && ! TARGET_64BIT - && regno == PIC_OFFSET_TABLE_REGNUM + if (regno == PIC_OFFSET_TABLE_REGNUM && (current_function_uses_pic_offset_table || current_function_uses_const_pool || current_function_calls_eh_return)) diff --git a/gcc/config/i386/i386.h b/gcc/config/i386/i386.h index 50e8dd5..9435913 100644 --- a/gcc/config/i386/i386.h +++ b/gcc/config/i386/i386.h @@ -937,7 +937,7 @@ do { \ call_used_regs[i] = (call_used_regs[i] \ & (TARGET_64BIT ? 2 : 1)) != 0; \ } \ - if (flag_pic && PIC_OFFSET_TABLE_REGNUM != INVALID_REGNUM) \ + if (PIC_OFFSET_TABLE_REGNUM != INVALID_REGNUM) \ { \ fixed_regs[PIC_OFFSET_TABLE_REGNUM] = 1; \ call_used_regs[PIC_OFFSET_TABLE_REGNUM] = 1; \ @@ -1113,11 +1113,11 @@ do { \ #define STATIC_CHAIN_REGNUM (TARGET_64BIT ? FIRST_REX_INT_REG + 10 - 8 : 2) /* Register to hold the addressing base for position independent - code access to data items. - We don't use PIC pointer for 64bit mode. Define the regnum to - dummy value to prevent gcc from pessimizing code dealing with EBX. - */ -#define PIC_OFFSET_TABLE_REGNUM (TARGET_64BIT ? INVALID_REGNUM : 3) + code access to data items. We don't use PIC pointer for 64bit + mode. Define the regnum to dummy value to prevent gcc from + pessimizing code dealing with EBX. */ +#define PIC_OFFSET_TABLE_REGNUM \ + (TARGET_64BIT || !flag_pic ? INVALID_REGNUM : 3) /* Register in which address to store a structure value arrives in the function. On the 386, the prologue diff --git a/gcc/config/m68k/m68k.h b/gcc/config/m68k/m68k.h index 9a20494..55f5fd1 100644 --- a/gcc/config/m68k/m68k.h +++ b/gcc/config/m68k/m68k.h @@ -387,7 +387,7 @@ extern int target_flags; #endif /* This defines the register which is used to hold the offset table for PIC. */ -#define PIC_OFFSET_TABLE_REGNUM 13 +#define PIC_OFFSET_TABLE_REGNUM (flag_pic ? 13 : INVALID_REGNUM) #ifndef SUPPORT_SUN_FPA @@ -469,43 +469,43 @@ extern int target_flags; #ifdef SUPPORT_SUN_FPA -#define CONDITIONAL_REGISTER_USAGE \ -{ \ - int i; \ - HARD_REG_SET x; \ - if (! TARGET_FPA) \ - { \ - COPY_HARD_REG_SET (x, reg_class_contents[(int)FPA_REGS]); \ - for (i = 0; i < FIRST_PSEUDO_REGISTER; i++ ) \ - if (TEST_HARD_REG_BIT (x, i)) \ - fixed_regs[i] = call_used_regs[i] = 1; \ - } \ - if (! TARGET_68881) \ - { \ - COPY_HARD_REG_SET (x, reg_class_contents[(int)FP_REGS]); \ - for (i = 0; i < FIRST_PSEUDO_REGISTER; i++ ) \ - if (TEST_HARD_REG_BIT (x, i)) \ - fixed_regs[i] = call_used_regs[i] = 1; \ - } \ - if (flag_pic) \ - fixed_regs[PIC_OFFSET_TABLE_REGNUM] \ - = call_used_regs[PIC_OFFSET_TABLE_REGNUM] = 1;\ +#define CONDITIONAL_REGISTER_USAGE \ +{ \ + int i; \ + HARD_REG_SET x; \ + if (! TARGET_FPA) \ + { \ + COPY_HARD_REG_SET (x, reg_class_contents[(int)FPA_REGS]); \ + for (i = 0; i < FIRST_PSEUDO_REGISTER; i++ ) \ + if (TEST_HARD_REG_BIT (x, i)) \ + fixed_regs[i] = call_used_regs[i] = 1; \ + } \ + if (! TARGET_68881) \ + { \ + COPY_HARD_REG_SET (x, reg_class_contents[(int)FP_REGS]); \ + for (i = 0; i < FIRST_PSEUDO_REGISTER; i++ ) \ + if (TEST_HARD_REG_BIT (x, i)) \ + fixed_regs[i] = call_used_regs[i] = 1; \ + } \ + if (PIC_OFFSET_TABLE_REGNUM != INVALID_REGNUM) \ + fixed_regs[PIC_OFFSET_TABLE_REGNUM] \ + = call_used_regs[PIC_OFFSET_TABLE_REGNUM] = 1; \ } #else -#define CONDITIONAL_REGISTER_USAGE \ -{ \ - int i; \ - HARD_REG_SET x; \ - if (! TARGET_68881) \ - { \ - COPY_HARD_REG_SET (x, reg_class_contents[(int)FP_REGS]); \ - for (i = 0; i < FIRST_PSEUDO_REGISTER; i++ ) \ - if (TEST_HARD_REG_BIT (x, i)) \ - fixed_regs[i] = call_used_regs[i] = 1; \ - } \ - if (flag_pic) \ - fixed_regs[PIC_OFFSET_TABLE_REGNUM] \ - = call_used_regs[PIC_OFFSET_TABLE_REGNUM] = 1;\ +#define CONDITIONAL_REGISTER_USAGE \ +{ \ + int i; \ + HARD_REG_SET x; \ + if (! TARGET_68881) \ + { \ + COPY_HARD_REG_SET (x, reg_class_contents[(int)FP_REGS]); \ + for (i = 0; i < FIRST_PSEUDO_REGISTER; i++ ) \ + if (TEST_HARD_REG_BIT (x, i)) \ + fixed_regs[i] = call_used_regs[i] = 1; \ + } \ + if (PIC_OFFSET_TABLE_REGNUM != INVALID_REGNUM) \ + fixed_regs[PIC_OFFSET_TABLE_REGNUM] \ + = call_used_regs[PIC_OFFSET_TABLE_REGNUM] = 1; \ } #endif /* defined SUPPORT_SUN_FPA */ diff --git a/gcc/config/s390/s390.h b/gcc/config/s390/s390.h index 8ab287b..93b355c 100644 --- a/gcc/config/s390/s390.h +++ b/gcc/config/s390/s390.h @@ -249,7 +249,7 @@ if (INTEGRAL_MODE_P (MODE) && \ GPR 14: Return registers holds the return address GPR 15: Stack pointer */ -#define PIC_OFFSET_TABLE_REGNUM 12 +#define PIC_OFFSET_TABLE_REGNUM (flag_pic ? 12 : INVALID_REGNUM) #define BASE_REGISTER 13 #define RETURN_REGNUM 14 #define STACK_POINTER_REGNUM 15 diff --git a/gcc/config/sparc/sparc.h b/gcc/config/sparc/sparc.h index aeb1078..92c8ace 100644 --- a/gcc/config/sparc/sparc.h +++ b/gcc/config/sparc/sparc.h @@ -984,7 +984,7 @@ if (TARGET_ARCH64 \ #define CONDITIONAL_REGISTER_USAGE \ do \ { \ - if (flag_pic) \ + if (PIC_OFFSET_TABLE_REGNUM != INVALID_REGNUM) \ { \ fixed_regs[PIC_OFFSET_TABLE_REGNUM] = 1; \ call_used_regs[PIC_OFFSET_TABLE_REGNUM] = 1; \ @@ -1159,7 +1159,7 @@ extern int sparc_mode_class[]; /* Register which holds offset table for position-independent data references. */ -#define PIC_OFFSET_TABLE_REGNUM 23 +#define PIC_OFFSET_TABLE_REGNUM (flag_pic ? 23 : INVALID_REGNUM) /* Pick a default value we can notice from override_options: !v9: Default is on. |