Commit f5798785 by Uros Bizjak

i386.c (memory_address_length): Assert that non-null base or index RTXes are registers.

	* config/i386/i386.c (memory_address_length): Assert that non-null
	base or index RTXes are registers.  Do not check for REG RTXes.
	Determine addr32 prefix from original base and index RTXes.
	Simplify code.

From-SVN: r192690
parent 43b1bad6
2012-10-22 Uros Bizjak <ubizjak@gmail.com>
* config/i386/i386.c (memory_address_length): Assert that non-null
base or index RTXes are registers. Do not check for REG RTXes.
Determine addr32 prefix from original base and index RTXes.
Simplify code.
2012-10-22 Richard Biener <rguenther@suse.de> 2012-10-22 Richard Biener <rguenther@suse.de>
PR tree-optimization/55011 PR tree-optimization/55011
...@@ -30,8 +37,7 @@ ...@@ -30,8 +37,7 @@
2012-10-22 Sameera Deshpande <sameera.deshpande@arm.com> 2012-10-22 Sameera Deshpande <sameera.deshpande@arm.com>
Greta Yorsh <Greta.Yorsh@arm.com> Greta Yorsh <Greta.Yorsh@arm.com>
* config/arm/arm-protos.h (offset_ok_for_ldrd_strd): New * config/arm/arm-protos.h (offset_ok_for_ldrd_strd): New declaration.
declaration.
(operands_ok_ldrd_strd): Likewise. (operands_ok_ldrd_strd): Likewise.
* config/arm/arm.c (offset_ok_for_ldrd_strd): New function. * config/arm/arm.c (offset_ok_for_ldrd_strd): New function.
(operands_ok_ldrd_strd): Likewise. (operands_ok_ldrd_strd): Likewise.
...@@ -23764,7 +23764,7 @@ memory_address_length (rtx addr, bool lea) ...@@ -23764,7 +23764,7 @@ memory_address_length (rtx addr, bool lea)
{ {
struct ix86_address parts; struct ix86_address parts;
rtx base, index, disp; rtx base, index, disp;
int len = 0; int len;
int ok; int ok;
if (GET_CODE (addr) == PRE_DEC if (GET_CODE (addr) == PRE_DEC
...@@ -23776,15 +23776,26 @@ memory_address_length (rtx addr, bool lea) ...@@ -23776,15 +23776,26 @@ memory_address_length (rtx addr, bool lea)
ok = ix86_decompose_address (addr, &parts); ok = ix86_decompose_address (addr, &parts);
gcc_assert (ok); gcc_assert (ok);
if (parts.base && GET_CODE (parts.base) == SUBREG) len = (parts.seg == SEG_DEFAULT) ? 0 : 1;
parts.base = SUBREG_REG (parts.base);
if (parts.index && GET_CODE (parts.index) == SUBREG) /* If this is not LEA instruction, add the length of addr32 prefix. */
parts.index = SUBREG_REG (parts.index); if (TARGET_64BIT && !lea
&& ((parts.base && GET_MODE (parts.base) == SImode)
|| (parts.index && GET_MODE (parts.index) == SImode)))
len++;
base = parts.base; base = parts.base;
index = parts.index; index = parts.index;
disp = parts.disp; disp = parts.disp;
if (base && GET_CODE (base) == SUBREG)
base = SUBREG_REG (base);
if (index && GET_CODE (index) == SUBREG)
index = SUBREG_REG (index);
gcc_assert (base == NULL_RTX || REG_P (base));
gcc_assert (index == NULL_RTX || REG_P (index));
/* Rule of thumb: /* Rule of thumb:
- esp as the base always wants an index, - esp as the base always wants an index,
- ebp as the base always wants a displacement, - ebp as the base always wants a displacement,
...@@ -23797,14 +23808,13 @@ memory_address_length (rtx addr, bool lea) ...@@ -23797,14 +23808,13 @@ memory_address_length (rtx addr, bool lea)
/* esp (for its index) and ebp (for its displacement) need /* esp (for its index) and ebp (for its displacement) need
the two-byte modrm form. Similarly for r12 and r13 in 64-bit the two-byte modrm form. Similarly for r12 and r13 in 64-bit
code. */ code. */
if (REG_P (base) if (base == arg_pointer_rtx
&& (base == arg_pointer_rtx
|| base == frame_pointer_rtx || base == frame_pointer_rtx
|| REGNO (base) == SP_REG || REGNO (base) == SP_REG
|| REGNO (base) == BP_REG || REGNO (base) == BP_REG
|| REGNO (base) == R12_REG || REGNO (base) == R12_REG
|| REGNO (base) == R13_REG)) || REGNO (base) == R13_REG)
len = 1; len++;
} }
/* Direct Addressing. In 64-bit mode mod 00 r/m 5 /* Direct Addressing. In 64-bit mode mod 00 r/m 5
...@@ -23814,7 +23824,7 @@ memory_address_length (rtx addr, bool lea) ...@@ -23814,7 +23824,7 @@ memory_address_length (rtx addr, bool lea)
by UNSPEC. */ by UNSPEC. */
else if (disp && !base && !index) else if (disp && !base && !index)
{ {
len = 4; len += 4;
if (TARGET_64BIT) if (TARGET_64BIT)
{ {
rtx symbol = disp; rtx symbol = disp;
...@@ -23832,7 +23842,7 @@ memory_address_length (rtx addr, bool lea) ...@@ -23832,7 +23842,7 @@ memory_address_length (rtx addr, bool lea)
|| (XINT (symbol, 1) != UNSPEC_GOTPCREL || (XINT (symbol, 1) != UNSPEC_GOTPCREL
&& XINT (symbol, 1) != UNSPEC_PCREL && XINT (symbol, 1) != UNSPEC_PCREL
&& XINT (symbol, 1) != UNSPEC_GOTNTPOFF))) && XINT (symbol, 1) != UNSPEC_GOTNTPOFF)))
len += 1; len++;
} }
} }
else else
...@@ -23841,41 +23851,23 @@ memory_address_length (rtx addr, bool lea) ...@@ -23841,41 +23851,23 @@ memory_address_length (rtx addr, bool lea)
if (disp) if (disp)
{ {
if (base && satisfies_constraint_K (disp)) if (base && satisfies_constraint_K (disp))
len = 1; len += 1;
else else
len = 4; len += 4;
} }
/* ebp always wants a displacement. Similarly r13. */ /* ebp always wants a displacement. Similarly r13. */
else if (base && REG_P (base) else if (base && (REGNO (base) == BP_REG || REGNO (base) == R13_REG))
&& (REGNO (base) == BP_REG || REGNO (base) == R13_REG)) len++;
len = 1;
/* An index requires the two-byte modrm form.... */ /* An index requires the two-byte modrm form.... */
if (index if (index
/* ...like esp (or r12), which always wants an index. */ /* ...like esp (or r12), which always wants an index. */
|| base == arg_pointer_rtx || base == arg_pointer_rtx
|| base == frame_pointer_rtx || base == frame_pointer_rtx
|| (base && REG_P (base) || (base && (REGNO (base) == SP_REG || REGNO (base) == R12_REG)))
&& (REGNO (base) == SP_REG || REGNO (base) == R12_REG))) len++;
len += 1;
}
switch (parts.seg)
{
case SEG_FS:
case SEG_GS:
len += 1;
break;
default:
break;
} }
/* If this is not LEA instruction, add the length of addr32 prefix. */
if (TARGET_64BIT && !lea
&& ((base && GET_MODE (base) == SImode)
|| (index && GET_MODE (index) == SImode)))
len += 1;
return len; return len;
} }
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