Implement the getPointerRegClass method, which is required for the ptr_rc
authorChris Lattner <sabre@nondot.org>
Sat, 17 Jun 2006 00:01:04 +0000 (00:01 +0000)
committerChris Lattner <sabre@nondot.org>
Sat, 17 Jun 2006 00:01:04 +0000 (00:01 +0000)
magic to work.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28847 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/PowerPC/PPCInstrInfo.cpp
lib/Target/PowerPC/PPCInstrInfo.h
lib/Target/PowerPC/PPCTargetMachine.cpp

index d71f357990ffb06bcea1c7468d62582c471b0912..9390442b4d20e7adf3839444c6a56d5d6b29830f 100644 (file)
 
 #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,
index 25551fb6c29d957dde8968c39ea293027eaf139b..eecc1bc8be6bfe9e68d59b0359d00e0c63bdb651 100644 (file)
@@ -62,9 +62,10 @@ enum PPC970_Unit {
   
   
 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
@@ -72,7 +73,10 @@ public:
   ///
   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.
   //
index e5ee33be3f210468ed327541af854ca8b56d94e0..c174e264ce24ea12b79486662130dc2fca447ccd 100644 (file)
@@ -87,7 +87,7 @@ unsigned PPC64TargetMachine::getModuleMatchQuality(const Module &M) {
 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()) {