Tell ARMJITInfo if codegen relocation is PIC. It changes how function stubs are generated.

llvm-svn: 58896
This commit is contained in:
Evan Cheng 2008-11-08 07:38:22 +00:00
parent 1b889b16da
commit 98161f5f34
3 changed files with 13 additions and 8 deletions

View File

@ -167,7 +167,7 @@ bool ARMCodeEmitter::runOnMachineFunction(MachineFunction &MF) {
MCPEs = &MF.getConstantPool()->getConstants(); MCPEs = &MF.getConstantPool()->getConstants();
MJTEs = &MF.getJumpTableInfo()->getJumpTables(); MJTEs = &MF.getJumpTableInfo()->getJumpTables();
IsPIC = TM.getRelocationModel() == Reloc::PIC_; IsPIC = TM.getRelocationModel() == Reloc::PIC_;
JTI->Initialize(MF); JTI->Initialize(MF, IsPIC);
do { do {
DOUT << "JITTing function '" << MF.getFunction()->getName() << "'\n"; DOUT << "JITTing function '" << MF.getFunction()->getName() << "'\n";

View File

@ -26,8 +26,6 @@ namespace llvm {
class ARMTargetMachine; class ARMTargetMachine;
class ARMJITInfo : public TargetJITInfo { class ARMJITInfo : public TargetJITInfo {
ARMTargetMachine &TM;
// ConstPoolId2AddrMap - A map from constant pool ids to the corresponding // ConstPoolId2AddrMap - A map from constant pool ids to the corresponding
// CONSTPOOL_ENTRY addresses. // CONSTPOOL_ENTRY addresses.
SmallVector<intptr_t, 16> ConstPoolId2AddrMap; SmallVector<intptr_t, 16> ConstPoolId2AddrMap;
@ -39,8 +37,12 @@ namespace llvm {
// PCLabelMap - A map from PC labels to addresses. // PCLabelMap - A map from PC labels to addresses.
DenseMap<unsigned, intptr_t> PCLabelMap; DenseMap<unsigned, intptr_t> PCLabelMap;
// IsPIC - True if the relocation model is PIC. This is used to determine
// how to codegen function stubs.
bool IsPIC;
public: public:
explicit ARMJITInfo(ARMTargetMachine &tm) : TM(tm) { useGOT = false; } explicit ARMJITInfo() : IsPIC(false) { useGOT = false; }
/// replaceMachineCodeForFunction - Make it so that calling the function /// replaceMachineCodeForFunction - Make it so that calling the function
/// whose machine code is at OLD turns into a call to NEW, perhaps by /// whose machine code is at OLD turns into a call to NEW, perhaps by
@ -89,12 +91,15 @@ namespace llvm {
#endif #endif
} }
/// Initialize - Initialize internal stage. Get the list of constant pool /// Initialize - Initialize internal stage for the function being JITted.
/// Resize constant pool ids to CONSTPOOL_ENTRY addresses map. /// Resize constant pool ids to CONSTPOOL_ENTRY addresses map; resize
void Initialize(const MachineFunction &MF) { /// jump table ids to jump table bases map; remember if codegen relocation
/// model is PIC.
void Initialize(const MachineFunction &MF, bool isPIC) {
const ARMFunctionInfo *AFI = MF.getInfo<ARMFunctionInfo>(); const ARMFunctionInfo *AFI = MF.getInfo<ARMFunctionInfo>();
ConstPoolId2AddrMap.resize(AFI->getNumConstPoolEntries()); ConstPoolId2AddrMap.resize(AFI->getNumConstPoolEntries());
JumpTableId2AddrMap.resize(AFI->getNumJumpTables()); JumpTableId2AddrMap.resize(AFI->getNumJumpTables());
IsPIC = isPIC;
} }
/// getConstantPoolEntryAddr - The ARM target puts all constant /// getConstantPoolEntryAddr - The ARM target puts all constant

View File

@ -84,7 +84,7 @@ ARMTargetMachine::ARMTargetMachine(const Module &M, const std::string &FS,
std::string("e-p:32:32-f64:64:64-i64:64:64"))), std::string("e-p:32:32-f64:64:64-i64:64:64"))),
InstrInfo(Subtarget), InstrInfo(Subtarget),
FrameInfo(Subtarget), FrameInfo(Subtarget),
JITInfo(*this), JITInfo(),
TLInfo(*this) { TLInfo(*this) {
DefRelocModel = getRelocationModel(); DefRelocModel = getRelocationModel();
} }