[llvm-commits] [llvm] r56829 - in /llvm/trunk/lib/Target/X86: X86FastISel.cpp X86InstrBuilder.h
Dan Gohman
gohman at apple.com
Mon Sep 29 18:21:32 PDT 2008
Author: djg
Date: Mon Sep 29 20:21:32 2008
New Revision: 56829
URL: http://llvm.org/viewvc/llvm-project?rev=56829&view=rev
Log:
Fix X86FastISel's output for x86-32 PIC constant pool addresses.
Modified:
llvm/trunk/lib/Target/X86/X86FastISel.cpp
llvm/trunk/lib/Target/X86/X86InstrBuilder.h
Modified: llvm/trunk/lib/Target/X86/X86FastISel.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86FastISel.cpp?rev=56829&r1=56828&r2=56829&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86FastISel.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86FastISel.cpp Mon Sep 29 20:21:32 2008
@@ -1217,9 +1217,18 @@
Align = Log2_64(Align);
}
+ // x86-32 PIC requires a PIC base register for constant pools.
+ unsigned PICBase = 0;
+ if (TM.getRelocationModel() == Reloc::PIC_ &&
+ !Subtarget->is64Bit())
+ PICBase = getInstrInfo()->getGlobalBaseReg(&MF);
+
+ // Create the load from the constant pool.
unsigned MCPOffset = MCP.getConstantPoolIndex(C, Align);
unsigned ResultReg = createResultReg(RC);
- addConstantPoolReference(BuildMI(MBB, TII.get(Opc), ResultReg), MCPOffset);
+ addConstantPoolReference(BuildMI(MBB, TII.get(Opc), ResultReg), MCPOffset,
+ PICBase);
+
return ResultReg;
}
Modified: llvm/trunk/lib/Target/X86/X86InstrBuilder.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrBuilder.h?rev=56829&r1=56828&r2=56829&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86InstrBuilder.h (original)
+++ llvm/trunk/lib/Target/X86/X86InstrBuilder.h Mon Sep 29 20:21:32 2008
@@ -114,13 +114,15 @@
/// addConstantPoolReference - This function is used to add a reference to the
/// base of a constant value spilled to the per-function constant pool. The
-/// reference has base register ConstantPoolIndex offset which is retained until
-/// either machine code emission or assembly output. This allows an optional
-/// offset to be added as well.
+/// reference uses the abstract ConstantPoolIndex which is retained until
+/// either machine code emission or assembly output. In PIC mode on x86-32,
+/// the GlobalBaseReg parameter can be used to make this a
+/// GlobalBaseReg-relative reference.
///
inline const MachineInstrBuilder &
-addConstantPoolReference(const MachineInstrBuilder &MIB, unsigned CPI) {
- return MIB.addReg(0).addImm(1).addReg(0).addConstantPoolIndex(CPI);
+addConstantPoolReference(const MachineInstrBuilder &MIB, unsigned CPI,
+ unsigned GlobalBaseReg = 0) {
+ return MIB.addReg(GlobalBaseReg).addImm(1).addReg(0).addConstantPoolIndex(CPI);
}
} // End llvm namespace
More information about the llvm-commits
mailing list