Commit dbde310d by Geoffrey Keating Committed by Geoffrey Keating

i386.c (ix86_delegitimize_address): Handle Darwin addresses with offsets; reorganize.

	* config/i386/i386.c (ix86_delegitimize_address): Handle Darwin
	addresses with offsets; reorganize.

From-SVN: r111826
parent fb638355
2006-03-07 Geoffrey Keating <geoffk@apple.com> 2006-03-07 Geoffrey Keating <geoffk@apple.com>
* config/i386/i386.c (ix86_delegitimize_address): Handle Darwin
addresses with offsets; reorganize.
* dwarf2out.c (DWARF2_FRAME_REG_OUT): Move up in file. * dwarf2out.c (DWARF2_FRAME_REG_OUT): Move up in file.
(expand_builtin_dwarf_sp_column): Call DWARF2_FRAME_REG_OUT. (expand_builtin_dwarf_sp_column): Call DWARF2_FRAME_REG_OUT.
(expand_builtin_init_dwarf_reg_sizes): Likewise. (expand_builtin_init_dwarf_reg_sizes): Likewise.
......
...@@ -7083,12 +7083,24 @@ i386_output_dwarf_dtprel (FILE *file, int size, rtx x) ...@@ -7083,12 +7083,24 @@ i386_output_dwarf_dtprel (FILE *file, int size, rtx x)
/* In the name of slightly smaller debug output, and to cater to /* In the name of slightly smaller debug output, and to cater to
general assembler lossage, recognize PIC+GOTOFF and turn it back general assembler lossage, recognize PIC+GOTOFF and turn it back
into a direct symbol reference. */ into a direct symbol reference.
On Darwin, this is necessary to avoid a crash, because Darwin
has a different PIC label for each routine but the DWARF debugging
information is not associated with any particular routine, so it's
necessary to remove references to the PIC label from RTL stored by
the DWARF output code. */
static rtx static rtx
ix86_delegitimize_address (rtx orig_x) ix86_delegitimize_address (rtx orig_x)
{ {
rtx x = orig_x, y; rtx x = orig_x;
/* reg_addend is NULL or a multiple of some register. */
rtx reg_addend = NULL_RTX;
/* const_addend is NULL or a const_int. */
rtx const_addend = NULL_RTX;
/* This is the result, or NULL. */
rtx result = NULL_RTX;
if (GET_CODE (x) == MEM) if (GET_CODE (x) == MEM)
x = XEXP (x, 0); x = XEXP (x, 0);
...@@ -7110,59 +7122,52 @@ ix86_delegitimize_address (rtx orig_x) ...@@ -7110,59 +7122,52 @@ ix86_delegitimize_address (rtx orig_x)
if (GET_CODE (XEXP (x, 0)) == REG if (GET_CODE (XEXP (x, 0)) == REG
&& REGNO (XEXP (x, 0)) == PIC_OFFSET_TABLE_REGNUM) && REGNO (XEXP (x, 0)) == PIC_OFFSET_TABLE_REGNUM)
/* %ebx + GOT/GOTOFF */ /* %ebx + GOT/GOTOFF */
y = NULL; ;
else if (GET_CODE (XEXP (x, 0)) == PLUS) else if (GET_CODE (XEXP (x, 0)) == PLUS)
{ {
/* %ebx + %reg * scale + GOT/GOTOFF */ /* %ebx + %reg * scale + GOT/GOTOFF */
y = XEXP (x, 0); reg_addend = XEXP (x, 0);
if (GET_CODE (XEXP (y, 0)) == REG if (GET_CODE (XEXP (reg_addend, 0)) == REG
&& REGNO (XEXP (y, 0)) == PIC_OFFSET_TABLE_REGNUM) && REGNO (XEXP (reg_addend, 0)) == PIC_OFFSET_TABLE_REGNUM)
y = XEXP (y, 1); reg_addend = XEXP (reg_addend, 1);
else if (GET_CODE (XEXP (y, 1)) == REG else if (GET_CODE (XEXP (reg_addend, 1)) == REG
&& REGNO (XEXP (y, 1)) == PIC_OFFSET_TABLE_REGNUM) && REGNO (XEXP (reg_addend, 1)) == PIC_OFFSET_TABLE_REGNUM)
y = XEXP (y, 0); reg_addend = XEXP (reg_addend, 0);
else else
return orig_x; return orig_x;
if (GET_CODE (y) != REG if (GET_CODE (reg_addend) != REG
&& GET_CODE (y) != MULT && GET_CODE (reg_addend) != MULT
&& GET_CODE (y) != ASHIFT) && GET_CODE (reg_addend) != ASHIFT)
return orig_x; return orig_x;
} }
else else
return orig_x; return orig_x;
x = XEXP (XEXP (x, 1), 0); x = XEXP (XEXP (x, 1), 0);
if (GET_CODE (x) == UNSPEC
&& ((XINT (x, 1) == UNSPEC_GOT && GET_CODE (orig_x) == MEM)
|| (XINT (x, 1) == UNSPEC_GOTOFF && GET_CODE (orig_x) != MEM)))
{
if (y)
return gen_rtx_PLUS (Pmode, y, XVECEXP (x, 0, 0));
return XVECEXP (x, 0, 0);
}
if (GET_CODE (x) == PLUS if (GET_CODE (x) == PLUS
&& GET_CODE (XEXP (x, 0)) == UNSPEC && GET_CODE (XEXP (x, 1)) == CONST_INT)
&& GET_CODE (XEXP (x, 1)) == CONST_INT
&& ((XINT (XEXP (x, 0), 1) == UNSPEC_GOT && GET_CODE (orig_x) == MEM)
|| (XINT (XEXP (x, 0), 1) == UNSPEC_GOTOFF
&& GET_CODE (orig_x) != MEM)))
{ {
x = gen_rtx_PLUS (VOIDmode, XVECEXP (XEXP (x, 0), 0, 0), XEXP (x, 1)); const_addend = XEXP (x, 1);
if (y) x = XEXP (x, 0);
return gen_rtx_PLUS (Pmode, y, x);
return x;
} }
if (GET_CODE (x) == UNSPEC
&& ((XINT (x, 1) == UNSPEC_GOT && GET_CODE (orig_x) == MEM)
|| (XINT (x, 1) == UNSPEC_GOTOFF && GET_CODE (orig_x) != MEM)))
result = XVECEXP (x, 0, 0);
if (TARGET_MACHO && darwin_local_data_pic (x) if (TARGET_MACHO && darwin_local_data_pic (x)
&& GET_CODE (orig_x) != MEM) && GET_CODE (orig_x) != MEM)
{ result = XEXP (x, 0);
x = XEXP (x, 0);
if (y) if (! result)
return gen_rtx_PLUS (Pmode, y, x);
return x;
}
return orig_x; return orig_x;
if (const_addend)
result = gen_rtx_PLUS (Pmode, result, const_addend);
if (reg_addend)
result = gen_rtx_PLUS (Pmode, reg_addend, result);
return result;
} }
static void static void
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment