mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-10-20 03:23:01 +02:00
Fix X86FastISel's output for x86-32 PIC constant pool addresses.
llvm-svn: 56829
This commit is contained in:
parent
c28f40a821
commit
b5824675e4
@ -1217,9 +1217,18 @@ unsigned X86FastISel::TargetMaterializeConstant(Constant *C) {
|
|||||||
Align = Log2_64(Align);
|
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 MCPOffset = MCP.getConstantPoolIndex(C, Align);
|
||||||
unsigned ResultReg = createResultReg(RC);
|
unsigned ResultReg = createResultReg(RC);
|
||||||
addConstantPoolReference(BuildMI(MBB, TII.get(Opc), ResultReg), MCPOffset);
|
addConstantPoolReference(BuildMI(MBB, TII.get(Opc), ResultReg), MCPOffset,
|
||||||
|
PICBase);
|
||||||
|
|
||||||
return ResultReg;
|
return ResultReg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,13 +114,15 @@ addFrameReference(const MachineInstrBuilder &MIB, int FI, int Offset = 0) {
|
|||||||
|
|
||||||
/// addConstantPoolReference - This function is used to add a reference to the
|
/// addConstantPoolReference - This function is used to add a reference to the
|
||||||
/// base of a constant value spilled to the per-function constant pool. The
|
/// base of a constant value spilled to the per-function constant pool. The
|
||||||
/// reference has base register ConstantPoolIndex offset which is retained until
|
/// reference uses the abstract ConstantPoolIndex which is retained until
|
||||||
/// either machine code emission or assembly output. This allows an optional
|
/// either machine code emission or assembly output. In PIC mode on x86-32,
|
||||||
/// offset to be added as well.
|
/// the GlobalBaseReg parameter can be used to make this a
|
||||||
|
/// GlobalBaseReg-relative reference.
|
||||||
///
|
///
|
||||||
inline const MachineInstrBuilder &
|
inline const MachineInstrBuilder &
|
||||||
addConstantPoolReference(const MachineInstrBuilder &MIB, unsigned CPI) {
|
addConstantPoolReference(const MachineInstrBuilder &MIB, unsigned CPI,
|
||||||
return MIB.addReg(0).addImm(1).addReg(0).addConstantPoolIndex(CPI);
|
unsigned GlobalBaseReg = 0) {
|
||||||
|
return MIB.addReg(GlobalBaseReg).addImm(1).addReg(0).addConstantPoolIndex(CPI);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // End llvm namespace
|
} // End llvm namespace
|
||||||
|
Loading…
Reference in New Issue
Block a user