mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-31 12:30:06 +00:00
pull the rip-relative addressing mode case up early.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96031 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
9cc48eb897
commit
1e35d0e923
@ -176,9 +176,17 @@ void X86MCCodeEmitter::EmitMemModRMByte(const MCInst &MI, unsigned Op,
|
|||||||
const MCOperand &Scale = MI.getOperand(Op+1);
|
const MCOperand &Scale = MI.getOperand(Op+1);
|
||||||
const MCOperand &IndexReg = MI.getOperand(Op+2);
|
const MCOperand &IndexReg = MI.getOperand(Op+2);
|
||||||
unsigned BaseReg = Base.getReg();
|
unsigned BaseReg = Base.getReg();
|
||||||
unsigned BaseRegNo = -1U;
|
|
||||||
if (BaseReg != 0 && BaseReg != X86::RIP)
|
// Handle %rip relative addressing.
|
||||||
BaseRegNo = GetX86RegNum(Base);
|
if (BaseReg == X86::RIP) { // [disp32+RIP] in X86-64 mode
|
||||||
|
assert(IndexReg.getReg() == 0 && Is64BitMode &&
|
||||||
|
"Invalid rip-relative address");
|
||||||
|
EmitByte(ModRMByte(0, RegOpcodeField, 5), CurByte, OS);
|
||||||
|
EmitImmediate(Disp, 4, FK_Data_4, CurByte, OS, Fixups);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned BaseRegNo = BaseReg ? GetX86RegNum(Base) : -1U;
|
||||||
|
|
||||||
// Determine whether a SIB byte is needed.
|
// Determine whether a SIB byte is needed.
|
||||||
// If no BaseReg, issue a RIP relative instruction only if the MCE can
|
// If no BaseReg, issue a RIP relative instruction only if the MCE can
|
||||||
@ -195,8 +203,7 @@ void X86MCCodeEmitter::EmitMemModRMByte(const MCInst &MI, unsigned Op,
|
|||||||
// byte to emit an addr that is just 'disp32' (the non-RIP relative form).
|
// byte to emit an addr that is just 'disp32' (the non-RIP relative form).
|
||||||
(!Is64BitMode || BaseReg != 0)) {
|
(!Is64BitMode || BaseReg != 0)) {
|
||||||
|
|
||||||
if (BaseReg == 0 || // [disp32] in X86-32 mode
|
if (BaseReg == 0) { // [disp32] in X86-32 mode
|
||||||
BaseReg == X86::RIP) { // [disp32+RIP] in X86-64 mode
|
|
||||||
EmitByte(ModRMByte(0, RegOpcodeField, 5), CurByte, OS);
|
EmitByte(ModRMByte(0, RegOpcodeField, 5), CurByte, OS);
|
||||||
EmitImmediate(Disp, 4, FK_Data_4, CurByte, OS, Fixups);
|
EmitImmediate(Disp, 4, FK_Data_4, CurByte, OS, Fixups);
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user