diff options
author | Misha Brukman <brukman+llvm@gmail.com> | 2004-08-11 23:44:55 +0000 |
---|---|---|
committer | Misha Brukman <brukman+llvm@gmail.com> | 2004-08-11 23:44:55 +0000 |
commit | dceb4576075546962ac816a05267afbc606234a6 (patch) | |
tree | e10939cb7813b91021e86a7d1b7a3c18015868ee /lib | |
parent | ca9309f22e626db9019de371cf7b61a7e35d08e2 (diff) |
* Set the is64bit boolean flag in PowerPCRegisterInfo
* Doubles are 8 bytes in 64-bit PowerPC, and use the general register class
* Use double-word loads and stores for restoring from/saving to stack
* Do not allocate R2 if compiling for AIX
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@15670 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Target/PowerPC/PPCRegisterInfo.td | 6 | ||||
-rw-r--r-- | lib/Target/PowerPC/PowerPCRegisterInfo.cpp | 36 | ||||
-rw-r--r-- | lib/Target/PowerPC/PowerPCRegisterInfo.h | 6 |
3 files changed, 30 insertions, 18 deletions
diff --git a/lib/Target/PowerPC/PPCRegisterInfo.td b/lib/Target/PowerPC/PPCRegisterInfo.td index 34ebfac610..c103dd6f37 100644 --- a/lib/Target/PowerPC/PPCRegisterInfo.td +++ b/lib/Target/PowerPC/PPCRegisterInfo.td @@ -77,13 +77,13 @@ def TBU : SPR<5>; // then nonvolatiles in reverse order since stmw/lmw save from rN to r31 def GPRC : RegisterClass<i32, 4, - [R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, + [R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, R31, R30, R29, R28, R27, R26, R25, R24, R23, R22, R21, R20, R19, R18, R17, - R16, R15, R14, R13, R0, R1, LR]> + R16, R15, R14, R13, R0, R2, R1, LR]> { let Methods = [{ iterator allocation_order_end(MachineFunction &MF) const { - return end()-3; + return end() - (AIX ? 4 : 3); } }]; } diff --git a/lib/Target/PowerPC/PowerPCRegisterInfo.cpp b/lib/Target/PowerPC/PowerPCRegisterInfo.cpp index 62f553eb04..ee2aabc3cd 100644 --- a/lib/Target/PowerPC/PowerPCRegisterInfo.cpp +++ b/lib/Target/PowerPC/PowerPCRegisterInfo.cpp @@ -30,9 +30,14 @@ #include <iostream> using namespace llvm; -PowerPCRegisterInfo::PowerPCRegisterInfo() - : PowerPCGenRegisterInfo(PPC::ADJCALLSTACKDOWN, - PPC::ADJCALLSTACKUP) {} +namespace llvm { + // Switch toggling compilation for AIX + extern cl::opt<bool> AIX; +} + +PowerPCRegisterInfo::PowerPCRegisterInfo(bool is64b) + : PowerPCGenRegisterInfo(PPC::ADJCALLSTACKDOWN, PPC::ADJCALLSTACKUP), + is64bit(is64b) {} static unsigned getIdx(const TargetRegisterClass *RC) { if (RC == PowerPC::GPRCRegisterClass) { @@ -41,12 +46,13 @@ static unsigned getIdx(const TargetRegisterClass *RC) { case 1: return 0; case 2: return 1; case 4: return 2; + case 8: return 3; } } else if (RC == PowerPC::FPRCRegisterClass) { switch (RC->getSize()) { default: assert(0 && "Invalid data size!"); - case 4: return 3; - case 8: return 4; + case 4: return 4; + case 8: return 5; } } std::cerr << "Invalid register class to getIdx()!\n"; @@ -59,7 +65,7 @@ PowerPCRegisterInfo::storeRegToStackSlot(MachineBasicBlock &MBB, unsigned SrcReg, int FrameIdx, const TargetRegisterClass *RC) const { static const unsigned Opcode[] = { - PPC::STB, PPC::STH, PPC::STW, PPC::STFS, PPC::STFD + PPC::STB, PPC::STH, PPC::STW, PPC::STD, PPC::STFS, PPC::STFD }; unsigned OC = Opcode[getIdx(RC)]; if (SrcReg == PPC::LR) { @@ -78,7 +84,7 @@ PowerPCRegisterInfo::loadRegFromStackSlot(MachineBasicBlock &MBB, unsigned DestReg, int FrameIdx, const TargetRegisterClass *RC) const { static const unsigned Opcode[] = { - PPC::LBZ, PPC::LHZ, PPC::LWZ, PPC::LFS, PPC::LFD + PPC::LBZ, PPC::LHZ, PPC::LWZ, PPC::LD, PPC::LFS, PPC::LFD }; unsigned OC = Opcode[getIdx(RC)]; if (DestReg == PPC::LR) { @@ -221,17 +227,19 @@ void PowerPCRegisterInfo::emitPrologue(MachineFunction &MF) const { // adjust stack pointer: r1 -= numbytes if (NumBytes <= 32768) { - MI = BuildMI(PPC::STWU, 3).addReg(PPC::R1).addSImm(-NumBytes) + unsigned StoreOpcode = is64bit ? PPC::STDU : PPC::STWU; + MI = BuildMI(StoreOpcode, 3).addReg(PPC::R1).addSImm(-NumBytes) .addReg(PPC::R1); MBB.insert(MBBI, MI); } else { int NegNumbytes = -NumBytes; + unsigned StoreOpcode = is64bit ? PPC::STDUX : PPC::STWUX; MI = BuildMI(PPC::LIS, 1, PPC::R0).addSImm(NegNumbytes >> 16); MBB.insert(MBBI, MI); MI = BuildMI(PPC::ORI, 2, PPC::R0).addReg(PPC::R0) .addImm(NegNumbytes & 0xFFFF); MBB.insert(MBBI, MI); - MI = BuildMI(PPC::STWUX, 3).addReg(PPC::R1).addReg(PPC::R1) + MI = BuildMI(StoreOpcode, 3).addReg(PPC::R1).addReg(PPC::R1) .addReg(PPC::R0); MBB.insert(MBBI, MI); } @@ -249,7 +257,8 @@ void PowerPCRegisterInfo::emitEpilogue(MachineFunction &MF, unsigned NumBytes = MFI->getStackSize(); if (NumBytes != 0) { - MI = BuildMI(PPC::LWZ, 2, PPC::R1).addSImm(0).addReg(PPC::R1); + unsigned Opcode = is64bit ? PPC::LD : PPC::LWZ; + MI = BuildMI(Opcode, 2, PPC::R1).addSImm(0).addReg(PPC::R1); MBB.insert(MBBI, MI); } } @@ -259,9 +268,10 @@ void PowerPCRegisterInfo::emitEpilogue(MachineFunction &MF, const TargetRegisterClass* PowerPCRegisterInfo::getRegClassForType(const Type* Ty) const { switch (Ty->getTypeID()) { - case Type::LongTyID: - case Type::ULongTyID: assert(0 && "Long values can't fit in registers!"); default: assert(0 && "Invalid type to getClass!"); + case Type::LongTyID: + case Type::ULongTyID: + if (!is64bit) assert(0 && "Long values can't fit in registers!"); case Type::BoolTyID: case Type::SByteTyID: case Type::UByteTyID: @@ -270,7 +280,7 @@ PowerPCRegisterInfo::getRegClassForType(const Type* Ty) const { case Type::IntTyID: case Type::UIntTyID: case Type::PointerTyID: return &GPRCInstance; - + case Type::FloatTyID: case Type::DoubleTyID: return &FPRCInstance; } diff --git a/lib/Target/PowerPC/PowerPCRegisterInfo.h b/lib/Target/PowerPC/PowerPCRegisterInfo.h index fd4b33e92e..478693dc7c 100644 --- a/lib/Target/PowerPC/PowerPCRegisterInfo.h +++ b/lib/Target/PowerPC/PowerPCRegisterInfo.h @@ -21,8 +21,10 @@ namespace llvm { class Type; -struct PowerPCRegisterInfo : public PowerPCGenRegisterInfo { - PowerPCRegisterInfo(); +class PowerPCRegisterInfo : public PowerPCGenRegisterInfo { + bool is64bit; +public: + PowerPCRegisterInfo(bool is64b); const TargetRegisterClass* getRegClassForType(const Type* Ty) const; /// Code Generation virtual methods... |