[llvm-commits] [llvm] r74184 - in /llvm/trunk/lib/Target/X86: AsmPrinter/X86ATTAsmPrinter.cpp X86InstrInfo.cpp X86InstrInfo.h
Chris Lattner
sabre at nondot.org
Thu Jun 25 10:38:37 PDT 2009
Author: lattner
Date: Thu Jun 25 12:38:33 2009
New Revision: 74184
URL: http://llvm.org/viewvc/llvm-project?rev=74184&view=rev
Log:
Use target-specific machine operand flags to eliminate a gross hack
from the asmprinter.
Modified:
llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp
llvm/trunk/lib/Target/X86/X86InstrInfo.cpp
llvm/trunk/lib/Target/X86/X86InstrInfo.h
Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp?rev=74184&r1=74183&r2=74184&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp Thu Jun 25 12:38:33 2009
@@ -405,25 +405,15 @@
O << Name;
- if (shouldPrintPLT(TM, Subtarget)) {
- std::string GOTName(TAI->getGlobalPrefix());
- GOTName+="_GLOBAL_OFFSET_TABLE_";
- if (Name == GOTName) {
- // 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 (MO.getTargetFlags() == X86II::MO_GOT_ABSOLUTE_ADDRESS) {
+ O << " + [.-";
+ PrintPICBaseSymbol();
+ O << ']';
}
+ if (shouldPrintPLT(TM, Subtarget))
+ O << "@PLT";
+
if (needCloseParen)
O << ')';
@@ -633,21 +623,10 @@
O << Name;
- if (shouldPrintPLT(TM, Subtarget)) {
- std::string GOTName(TAI->getGlobalPrefix());
- GOTName+="_GLOBAL_OFFSET_TABLE_";
- if (Name == GOTName) {
- // 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 (MO.getTargetFlags() == X86II::MO_GOT_ABSOLUTE_ADDRESS) {
+ O << " + [.-";
+ PrintPICBaseSymbol();
+ O << ']';
}
if (needCloseParen)
Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrInfo.cpp?rev=74184&r1=74183&r2=74184&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86InstrInfo.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86InstrInfo.cpp Thu Jun 25 12:38:33 2009
@@ -3219,17 +3219,17 @@
const TargetInstrInfo *TII = TM.getInstrInfo();
// Operand of MovePCtoStack is completely ignored by asm printer. It's
// only used in JIT code emission as displacement to pc.
- BuildMI(FirstMBB, MBBI, DL, TII->get(X86::MOVPC32r), PC)
- .addImm(0);
+ BuildMI(FirstMBB, MBBI, DL, TII->get(X86::MOVPC32r), PC).addImm(0);
// 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_ &&
TM.getSubtarget<X86Subtarget>().isPICStyleGOT()) {
- GlobalBaseReg =
- RegInfo.createVirtualRegister(X86::GR32RegisterClass);
+ GlobalBaseReg = RegInfo.createVirtualRegister(X86::GR32RegisterClass);
+ // Generate addl $__GLOBAL_OFFSET_TABLE_ + [.-piclabel], %some_register
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 {
GlobalBaseReg = PC;
}
Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrInfo.h?rev=74184&r1=74183&r2=74184&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86InstrInfo.h (original)
+++ llvm/trunk/lib/Target/X86/X86InstrInfo.h Thu Jun 25 12:38:33 2009
@@ -71,7 +71,18 @@
namespace X86II {
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.
//
More information about the llvm-commits
mailing list