aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Target/PowerPC/PPCCodeEmitter.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2005-04-18 00:46:10 +0000
committerChris Lattner <sabre@nondot.org>2005-04-18 00:46:10 +0000
commit477d1de9b2c77455192b6e67dd9496851f4ed8d0 (patch)
tree0c95d0e8940f51ea12eef1530884eb64264300d9 /lib/Target/PowerPC/PPCCodeEmitter.cpp
parent9acc366ae4638480e1320087afc632a2a6e5cf67 (diff)
downloadexternal_llvm-477d1de9b2c77455192b6e67dd9496851f4ed8d0.zip
external_llvm-477d1de9b2c77455192b6e67dd9496851f4ed8d0.tar.gz
external_llvm-477d1de9b2c77455192b6e67dd9496851f4ed8d0.tar.bz2
Handle ExternalSymbol operands in the PPC JIT
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21312 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/PowerPC/PPCCodeEmitter.cpp')
-rw-r--r--lib/Target/PowerPC/PPCCodeEmitter.cpp22
1 files changed, 13 insertions, 9 deletions
diff --git a/lib/Target/PowerPC/PPCCodeEmitter.cpp b/lib/Target/PowerPC/PPCCodeEmitter.cpp
index 2f9c8c2..57b92b4 100644
--- a/lib/Target/PowerPC/PPCCodeEmitter.cpp
+++ b/lib/Target/PowerPC/PPCCodeEmitter.cpp
@@ -188,8 +188,10 @@ int PPC32CodeEmitter::getMachineOpValue(MachineInstr &MI, MachineOperand &MO) {
rv = enumRegToMachineReg(MO.getReg());
} else if (MO.isImmediate()) {
rv = MO.getImmedValue();
- } else if (MO.isGlobalAddress()) {
- GlobalValue *GV = MO.getGlobal();
+ } else if (MO.isGlobalAddress() || MO.isExternalSymbol()) {
+ bool isExternal = MO.isExternalSymbol() ||
+ MO.getGlobal()->hasWeakLinkage() ||
+ MO.getGlobal()->isExternal();
unsigned Reloc = 0;
int Offset = 0;
if (MI.getOpcode() == PPC::CALLpcrel)
@@ -199,29 +201,31 @@ int PPC32CodeEmitter::getMachineOpValue(MachineInstr &MI, MachineOperand &MO) {
Offset = -((intptr_t)MovePCtoLROffset+4);
if (MI.getOpcode() == PPC::LOADHiAddr) {
- if (GV->hasWeakLinkage() || GV->isExternal())
+ if (isExternal)
Reloc = PPC::reloc_absolute_ptr_high; // Pointer to stub
else
Reloc = PPC::reloc_absolute_high; // Pointer to symbol
} else if (MI.getOpcode() == PPC::LA) {
- assert(!(GV->hasWeakLinkage() || GV->isExternal())
- && "Something in the ISEL changed\n");
+ assert(!isExternal && "Something in the ISEL changed\n");
Reloc = PPC::reloc_absolute_low;
} else if (MI.getOpcode() == PPC::LWZ) {
Reloc = PPC::reloc_absolute_ptr_low;
- assert((GV->hasWeakLinkage() || GV->isExternal()) &&
- "Something in the ISEL changed\n");
+ assert(isExternal && "Something in the ISEL changed\n");
} else {
// These don't show up for global value references AFAIK, only for
// constant pool refs: PPC::LFS, PPC::LFD
assert(0 && "Unknown instruction for relocation!");
}
}
- MCE.addRelocation(MachineRelocation(MCE.getCurrentPCOffset(),
- Reloc, MO.getGlobal(), Offset));
+ if (MO.isGlobalAddress())
+ MCE.addRelocation(MachineRelocation(MCE.getCurrentPCOffset(),
+ Reloc, MO.getGlobal(), Offset));
+ else
+ MCE.addRelocation(MachineRelocation(MCE.getCurrentPCOffset(),
+ Reloc, MO.getSymbolName(), Offset));
} else if (MO.isMachineBasicBlock()) {
unsigned* CurrPC = (unsigned*)(intptr_t)MCE.getCurrentPCValue();
BBRefs.push_back(std::make_pair(MO.getMachineBasicBlock(), CurrPC));