// 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);
}
}];
}
#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) {
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";
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) {
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) {
// 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);
}
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);
}
}
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:
case Type::IntTyID:
case Type::UIntTyID:
case Type::PointerTyID: return &GPRCInstance;
-
+
case Type::FloatTyID:
case Type::DoubleTyID: return &FPRCInstance;
}