From b9f26da5dd6c404e0a6eabcb60fb3c61ac0ee173 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Wed, 24 Nov 2004 01:56:12 +0000 Subject: [PATCH] Get constant pools working. This fixes even more programs, allowing us to pass 24/42 in UnitTests (up from 20). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@18196 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/PowerPC/PPCCodeEmitter.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/Target/PowerPC/PPCCodeEmitter.cpp b/lib/Target/PowerPC/PPCCodeEmitter.cpp index 8d21557b90a..14dbcff2dbf 100644 --- a/lib/Target/PowerPC/PPCCodeEmitter.cpp +++ b/lib/Target/PowerPC/PPCCodeEmitter.cpp @@ -199,6 +199,7 @@ int PPC32CodeEmitter::getMachineOpValue(MachineInstr &MI, MachineOperand &MO) { } else { assert(0 && "Unknown instruction for relocation!"); } + assert(MovePCtoLROffset && "MovePCtoLR not seen yet?"); MCE.addRelocation(MachineRelocation(MCE.getCurrentPCOffset(), Reloc, MO.getGlobal(), -((intptr_t)MovePCtoLROffset+4))); @@ -208,27 +209,26 @@ int PPC32CodeEmitter::getMachineOpValue(MachineInstr &MI, MachineOperand &MO) { BBRefs.push_back(std::make_pair(BB, CurrPC)); } else if (MO.isConstantPoolIndex()) { unsigned index = MO.getConstantPoolIndex(); - rv = MCE.getConstantPoolEntryAddress(index); - } else { - std::cerr << "ERROR: Unknown type of MachineOperand: " << MO << "\n"; - abort(); - } - - // Special treatment for global symbols: constants and vars - if ((MO.isConstantPoolIndex() || MO.isGlobalAddress()) && - MI.getOpcode() != PPC::CALLpcrel) { - unsigned Opcode = MI.getOpcode(); assert(MovePCtoLROffset && "MovePCtoLR not seen yet?"); + rv = MCE.getConstantPoolEntryAddress(index) - (intptr_t)MovePCtoLROffset-4; + unsigned Opcode = MI.getOpcode(); if (Opcode == PPC::LOADHiAddr) { // LoadHiAddr wants hi16(addr - &MovePCtoLR) + if ((short)rv < 0) rv += 1 << 16; rv >>= 16; } else if (Opcode == PPC::LWZ || Opcode == PPC::LA || Opcode == PPC::LFS || Opcode == PPC::LFD) { // These load opcodes want lo16(addr - &MovePCtoLR) rv &= 0xffff; + } else { + assert(0 && "Unknown constant pool using instruction!"); } + } else { + std::cerr << "ERROR: Unknown type of MachineOperand: " << MO << "\n"; + abort(); } + return rv; } -- 2.34.1