mirror of
https://github.com/RPCS3/llvm.git
synced 2024-12-04 17:58:22 +00:00
Use target-specific machine operand flags to eliminate a gross hack
from the asmprinter. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74184 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
b1fb84dee9
commit
ac5e887a6c
@ -405,25 +405,15 @@ void X86ATTAsmPrinter::print_pcrel_imm(const MachineInstr *MI, unsigned OpNo) {
|
|||||||
|
|
||||||
O << Name;
|
O << Name;
|
||||||
|
|
||||||
if (shouldPrintPLT(TM, Subtarget)) {
|
if (MO.getTargetFlags() == X86II::MO_GOT_ABSOLUTE_ADDRESS) {
|
||||||
std::string GOTName(TAI->getGlobalPrefix());
|
O << " + [.-";
|
||||||
GOTName+="_GLOBAL_OFFSET_TABLE_";
|
PrintPICBaseSymbol();
|
||||||
if (Name == GOTName) {
|
O << ']';
|
||||||
// HACK! Emit extra offset to PC during printing GOT offset to
|
|
||||||
// compensate for the size of popl instruction. The resulting code
|
|
||||||
// should look like:
|
|
||||||
// call .piclabel
|
|
||||||
// piclabel:
|
|
||||||
// popl %some_register
|
|
||||||
// addl $__GLOBAL_OFFSET_TABLE_ + [.-piclabel], %some_register
|
|
||||||
O << " + [.-";
|
|
||||||
PrintPICBaseSymbol();
|
|
||||||
O << ']';
|
|
||||||
}
|
|
||||||
|
|
||||||
O << "@PLT";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (shouldPrintPLT(TM, Subtarget))
|
||||||
|
O << "@PLT";
|
||||||
|
|
||||||
if (needCloseParen)
|
if (needCloseParen)
|
||||||
O << ')';
|
O << ')';
|
||||||
|
|
||||||
@ -633,21 +623,10 @@ void X86ATTAsmPrinter::printOperand(const MachineInstr *MI, unsigned OpNo,
|
|||||||
|
|
||||||
O << Name;
|
O << Name;
|
||||||
|
|
||||||
if (shouldPrintPLT(TM, Subtarget)) {
|
if (MO.getTargetFlags() == X86II::MO_GOT_ABSOLUTE_ADDRESS) {
|
||||||
std::string GOTName(TAI->getGlobalPrefix());
|
O << " + [.-";
|
||||||
GOTName+="_GLOBAL_OFFSET_TABLE_";
|
PrintPICBaseSymbol();
|
||||||
if (Name == GOTName) {
|
O << ']';
|
||||||
// HACK! Emit extra offset to PC during printing GOT offset to
|
|
||||||
// compensate for the size of popl instruction. The resulting code
|
|
||||||
// should look like:
|
|
||||||
// call .piclabel
|
|
||||||
// piclabel:
|
|
||||||
// popl %some_register
|
|
||||||
// addl $__GLOBAL_OFFSET_TABLE_ + [.-piclabel], %some_register
|
|
||||||
O << " + [.-";
|
|
||||||
PrintPICBaseSymbol();
|
|
||||||
O << ']';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (needCloseParen)
|
if (needCloseParen)
|
||||||
|
@ -3219,17 +3219,17 @@ unsigned X86InstrInfo::getGlobalBaseReg(MachineFunction *MF) const {
|
|||||||
const TargetInstrInfo *TII = TM.getInstrInfo();
|
const TargetInstrInfo *TII = TM.getInstrInfo();
|
||||||
// Operand of MovePCtoStack is completely ignored by asm printer. It's
|
// Operand of MovePCtoStack is completely ignored by asm printer. It's
|
||||||
// only used in JIT code emission as displacement to pc.
|
// only used in JIT code emission as displacement to pc.
|
||||||
BuildMI(FirstMBB, MBBI, DL, TII->get(X86::MOVPC32r), PC)
|
BuildMI(FirstMBB, MBBI, DL, TII->get(X86::MOVPC32r), PC).addImm(0);
|
||||||
.addImm(0);
|
|
||||||
|
|
||||||
// If we're using vanilla 'GOT' PIC style, we should use relative addressing
|
// If we're using vanilla 'GOT' PIC style, we should use relative addressing
|
||||||
// not to pc, but to _GLOBAL_ADDRESS_TABLE_ external
|
// not to pc, but to _GLOBAL_OFFSET_TABLE_ external.
|
||||||
if (TM.getRelocationModel() == Reloc::PIC_ &&
|
if (TM.getRelocationModel() == Reloc::PIC_ &&
|
||||||
TM.getSubtarget<X86Subtarget>().isPICStyleGOT()) {
|
TM.getSubtarget<X86Subtarget>().isPICStyleGOT()) {
|
||||||
GlobalBaseReg =
|
GlobalBaseReg = RegInfo.createVirtualRegister(X86::GR32RegisterClass);
|
||||||
RegInfo.createVirtualRegister(X86::GR32RegisterClass);
|
// Generate addl $__GLOBAL_OFFSET_TABLE_ + [.-piclabel], %some_register
|
||||||
BuildMI(FirstMBB, MBBI, DL, TII->get(X86::ADD32ri), GlobalBaseReg)
|
BuildMI(FirstMBB, MBBI, DL, TII->get(X86::ADD32ri), GlobalBaseReg)
|
||||||
.addReg(PC).addExternalSymbol("_GLOBAL_OFFSET_TABLE_");
|
.addReg(PC).addExternalSymbol("_GLOBAL_OFFSET_TABLE_", 0,
|
||||||
|
X86II::MO_GOT_ABSOLUTE_ADDRESS);
|
||||||
} else {
|
} else {
|
||||||
GlobalBaseReg = PC;
|
GlobalBaseReg = PC;
|
||||||
}
|
}
|
||||||
|
@ -71,7 +71,18 @@ namespace X86 {
|
|||||||
namespace X86II {
|
namespace X86II {
|
||||||
enum {
|
enum {
|
||||||
//===------------------------------------------------------------------===//
|
//===------------------------------------------------------------------===//
|
||||||
// Instruction types. These are the standard/most common forms for X86
|
// X86 Specific MachineOperand flags.
|
||||||
|
|
||||||
|
MO_NO_FLAG = 0,
|
||||||
|
|
||||||
|
/// MO_GOT_ABSOLUTE_ADDRESS - On a symbol operand, this represents a
|
||||||
|
/// relocation of:
|
||||||
|
/// $SYMBOL_LABEL + [. - PICBASELABEL]
|
||||||
|
MO_GOT_ABSOLUTE_ADDRESS = 1,
|
||||||
|
|
||||||
|
|
||||||
|
//===------------------------------------------------------------------===//
|
||||||
|
// Instruction encodings. These are the standard/most common forms for X86
|
||||||
// instructions.
|
// instructions.
|
||||||
//
|
//
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user