From 411e138af2c914ce23eb132c960eaf32f26f9991 Mon Sep 17 00:00:00 2001 From: Richard Sandiford Date: Tue, 23 Sep 2008 18:29:14 +0000 Subject: [PATCH] i386.c: Include cselib.h. gcc/ * config/i386/i386.c: Include cselib.h. (ix86_pic_register_p): New function. (ix86_delegitimize_address): Use it to check for the PIC register. From-SVN: r140611 --- gcc/ChangeLog | 6 ++++++ gcc/config/i386/i386.c | 24 ++++++++++++++++++------ 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index ad8ac8d..461044b 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,11 @@ 2008-09-23 Richard Sandiford + * config/i386/i386.c: Include cselib.h. + (ix86_pic_register_p): New function. + (ix86_delegitimize_address): Use it to check for the PIC register. + +2008-09-23 Richard Sandiford + * doc/tm.texi (FIND_BASE_TERM): Expand documentation. * config/i386/i386.c (ix86_find_base_term): Don't check for SYMBOL_REF and LABEL_REF. diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index 024e433..86be390 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -53,6 +53,7 @@ along with GCC; see the file COPYING3. If not see #include "df.h" #include "tm-constrs.h" #include "params.h" +#include "cselib.h" static int x86_builtin_vectorization_cost (bool); static rtx legitimize_dllimport_symbol (rtx, bool); @@ -9966,6 +9967,20 @@ i386_output_dwarf_dtprel (FILE *file, int size, rtx x) } } +/* Return true if X is a representation of the PIC register. This copes + with calls from ix86_find_base_term, where the register might have + been replaced by a cselib value. */ + +static bool +ix86_pic_register_p (rtx x) +{ + if (GET_CODE (x) == VALUE) + return (pic_offset_table_rtx + && rtx_equal_for_cselib_p (x, pic_offset_table_rtx)); + else + return REG_P (x) && REGNO (x) == PIC_OFFSET_TABLE_REGNUM; +} + /* In the name of slightly smaller debug output, and to cater to general assembler lossage, recognize PIC+GOTOFF and turn it back into a direct symbol reference. @@ -10004,19 +10019,16 @@ ix86_delegitimize_address (rtx orig_x) || GET_CODE (XEXP (x, 1)) != CONST) return orig_x; - if (REG_P (XEXP (x, 0)) - && REGNO (XEXP (x, 0)) == PIC_OFFSET_TABLE_REGNUM) + if (ix86_pic_register_p (XEXP (x, 0))) /* %ebx + GOT/GOTOFF */ ; else if (GET_CODE (XEXP (x, 0)) == PLUS) { /* %ebx + %reg * scale + GOT/GOTOFF */ reg_addend = XEXP (x, 0); - if (REG_P (XEXP (reg_addend, 0)) - && REGNO (XEXP (reg_addend, 0)) == PIC_OFFSET_TABLE_REGNUM) + if (ix86_pic_register_p (XEXP (reg_addend, 0))) reg_addend = XEXP (reg_addend, 1); - else if (REG_P (XEXP (reg_addend, 1)) - && REGNO (XEXP (reg_addend, 1)) == PIC_OFFSET_TABLE_REGNUM) + else if (ix86_pic_register_p (XEXP (reg_addend, 1))) reg_addend = XEXP (reg_addend, 0); else return orig_x; -- 2.7.4