diff options
author | Chris Lattner <sabre@nondot.org> | 2004-11-24 22:30:08 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2004-11-24 22:30:08 +0000 |
commit | 5efb75daed48edfeb03ba62f3f0afe81b86f5d7f (patch) | |
tree | 7c99314e1f98ec1f73650c060d51ed9cf85133fd /lib/Target/PowerPC/PPCCodeEmitter.cpp | |
parent | 53e4aa57c6bdc9bc99d7d8843e1b2b693a16fbfa (diff) | |
download | external_llvm-5efb75daed48edfeb03ba62f3f0afe81b86f5d7f.zip external_llvm-5efb75daed48edfeb03ba62f3f0afe81b86f5d7f.tar.gz external_llvm-5efb75daed48edfeb03ba62f3f0afe81b86f5d7f.tar.bz2 |
* Rename existing relocations to be more specific
* Add relocations for refernces to non-lazy darwin stubs and implement
them correctly.
With this change, we can correctly references external globals, and now
all but two UnitTests and all but 1 Regression/C tests pass.
More importantly, bugpoint-jit will start giving us useful testcases,
instead of always telling us that references to external globals don't
work :)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@18222 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/PowerPC/PPCCodeEmitter.cpp')
-rw-r--r-- | lib/Target/PowerPC/PPCCodeEmitter.cpp | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/lib/Target/PowerPC/PPCCodeEmitter.cpp b/lib/Target/PowerPC/PPCCodeEmitter.cpp index 2b0c0cf..7336181 100644 --- a/lib/Target/PowerPC/PPCCodeEmitter.cpp +++ b/lib/Target/PowerPC/PPCCodeEmitter.cpp @@ -189,21 +189,36 @@ int PPC32CodeEmitter::getMachineOpValue(MachineInstr &MI, MachineOperand &MO) { } else if (MO.isImmediate()) { rv = MO.getImmedValue(); } else if (MO.isGlobalAddress()) { + GlobalValue *GV = MO.getGlobal(); unsigned Reloc = 0; int Offset = 0; if (MI.getOpcode() == PPC::CALLpcrel) Reloc = PPC::reloc_pcrel_bx; - else if (MI.getOpcode() == PPC::LOADHiAddr) { + else { assert(MovePCtoLROffset && "MovePCtoLR not seen yet?"); - Reloc = PPC::reloc_absolute_loadhi; Offset = -((intptr_t)MovePCtoLROffset+4); - } else if (MI.getOpcode() == PPC::LA || MI.getOpcode() == PPC::LWZ || - MI.getOpcode() == PPC::LFS || MI.getOpcode() == PPC::LFD) { - assert(MovePCtoLROffset && "MovePCtoLR not seen yet?"); - Reloc = PPC::reloc_absolute_la; - Offset = -((intptr_t)MovePCtoLROffset+4); - } else { - assert(0 && "Unknown instruction for relocation!"); + + if (MI.getOpcode() == PPC::LOADHiAddr) { + if (GV->hasWeakLinkage() || GV->isExternal() || isa<Function>(GV)) + 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() || isa<Function>(GV)) + && "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() || isa<Function>(GV))&& + "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)); |