aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMisha Brukman <brukman+llvm@gmail.com>2004-08-12 02:53:01 +0000
committerMisha Brukman <brukman+llvm@gmail.com>2004-08-12 02:53:01 +0000
commitcc6b01b1e68cd87807f94a8c51088be9ff096e71 (patch)
tree089118d8b30a3b218c9f25170f938ebe68d0001a
parent8e63dcebcc3256a9bf656c21f163b478b82e00a6 (diff)
downloadexternal_llvm-cc6b01b1e68cd87807f94a8c51088be9ff096e71.zip
external_llvm-cc6b01b1e68cd87807f94a8c51088be9ff096e71.tar.gz
external_llvm-cc6b01b1e68cd87807f94a8c51088be9ff096e71.tar.bz2
* Pointers are 8 bytes, hence cLong type on 64-bit PPC
* Fix loading of GlobalValues git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@15678 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Target/PowerPC/PPC64ISelSimple.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/lib/Target/PowerPC/PPC64ISelSimple.cpp b/lib/Target/PowerPC/PPC64ISelSimple.cpp
index 9695c7d..129b038 100644
--- a/lib/Target/PowerPC/PPC64ISelSimple.cpp
+++ b/lib/Target/PowerPC/PPC64ISelSimple.cpp
@@ -52,14 +52,14 @@ static inline TypeClass getClass(const Type *Ty) {
case Type::ShortTyID:
case Type::UShortTyID: return cShort; // Short operands are class #1
case Type::IntTyID:
- case Type::UIntTyID:
- case Type::PointerTyID: return cInt; // Ints and pointers are class #2
+ case Type::UIntTyID: return cInt; // Ints are class #2
case Type::FloatTyID: return cFP32; // Single float is #3
case Type::DoubleTyID: return cFP64; // Double Point is #4
+ case Type::PointerTyID:
case Type::LongTyID:
- case Type::ULongTyID: return cLong; // Longs are class #5
+ case Type::ULongTyID: return cLong; // Longs and pointers are class #5
default:
assert(0 && "Invalid type to getClass!");
return cByte; // not reached
@@ -606,9 +606,11 @@ void ISel::copyConstantToRegister(MachineBasicBlock *MBB,
// Copy zero (null pointer) to the register.
BuildMI(*MBB, IP, PPC::LI, 1, R).addSImm(0);
} else if (GlobalValue *GV = dyn_cast<GlobalValue>(C)) {
- unsigned TmpReg = makeAnotherReg(GV->getType());
- BuildMI(*MBB, IP, PPC::LD, 2, TmpReg).addGlobalAddress(GV).addReg(PPC::R2);
- BuildMI(*MBB, IP, PPC::LWA, 2, R).addSImm(0).addReg(TmpReg);
+ static unsigned OpcodeTable[] = {
+ PPC::LBZ, PPC::LHZ, PPC::LWZ, PPC::LFS, PPC::LFD, PPC::LD
+ };
+ unsigned Opcode = OpcodeTable[getClassB(GV->getType())];
+ BuildMI(*MBB, IP, Opcode, 2, R).addGlobalAddress(GV).addReg(PPC::R2);
} else {
std::cerr << "Offending constant: " << *C << "\n";
assert(0 && "Type not handled yet!");