#include "PPCInstrInfo.h"
#include "PPCGenInstrInfo.inc"
-#include "PPC.h"
+#include "PPCTargetMachine.h"
#include "llvm/CodeGen/MachineInstrBuilder.h"
#include <iostream>
using namespace llvm;
-PPCInstrInfo::PPCInstrInfo()
- : TargetInstrInfo(PPCInsts, sizeof(PPCInsts)/sizeof(PPCInsts[0])) {}
+PPCInstrInfo::PPCInstrInfo(PPCTargetMachine &tm)
+ : TargetInstrInfo(PPCInsts, sizeof(PPCInsts)/sizeof(PPCInsts[0])), TM(tm) {}
+
+/// getPointerRegClass - Return the register class to use to hold pointers.
+/// This is used for addressing modes.
+const TargetRegisterClass *PPCInstrInfo::getPointerRegClass() const {
+ if (TM.getSubtargetImpl()->isPPC64())
+ return &PPC::G8RCRegClass;
+ else
+ return &PPC::GPRCRegClass;
+}
+
bool PPCInstrInfo::isMoveInstr(const MachineInstr& MI,
unsigned& sourceReg,
class PPCInstrInfo : public TargetInstrInfo {
+ PPCTargetMachine &TM;
const PPCRegisterInfo RI;
public:
- PPCInstrInfo();
+ PPCInstrInfo(PPCTargetMachine &TM);
/// getRegisterInfo - TargetInstrInfo is a superset of MRegister info. As
/// such, whenever a client has an instance of instruction info, it should
///
virtual const MRegisterInfo &getRegisterInfo() const { return RI; }
- //
+ /// getPointerRegClass - Return the register class to use to hold pointers.
+ /// This is used for addressing modes.
+ virtual const TargetRegisterClass *getPointerRegClass() const;
+
// Return true if the instruction is a register to register move and
// leave the source and dest operands in the passed parameters.
//
PPCTargetMachine::PPCTargetMachine(const Module &M, const std::string &FS,
bool is64Bit)
: TargetMachine("PowerPC"), Subtarget(M, FS, is64Bit),
- DataLayout(Subtarget.getTargetDataString()),
+ DataLayout(Subtarget.getTargetDataString()), InstrInfo(*this),
FrameInfo(*this, false), JITInfo(*this), TLInfo(*this),
InstrItins(Subtarget.getInstrItineraryData()) {