OSDN Git Service

radeon/llvm: Add isMov() to AMDILInstrInfo
authorTom Stellard <thomas.stellard@amd.com>
Sat, 2 Jun 2012 13:51:04 +0000 (09:51 -0400)
committerTom Stellard <thomas.stellard@amd.com>
Wed, 6 Jun 2012 17:46:04 +0000 (13:46 -0400)
This enables the CFGStructurizer to work without the AMDIL::MOV*
instructions.

src/gallium/drivers/radeon/AMDILCFGStructurizer.cpp
src/gallium/drivers/radeon/AMDILInstrInfo.h
src/gallium/drivers/radeon/R600InstrInfo.cpp
src/gallium/drivers/radeon/R600InstrInfo.h
src/gallium/drivers/radeon/SIInstrInfo.cpp
src/gallium/drivers/radeon/SIInstrInfo.h

index 26559a0..ba7d246 100644 (file)
@@ -2862,16 +2862,6 @@ struct CFGStructTraits<AMDILCFGStructurizer>
     return true;
   }
 
-  static bool isPhimove(MachineInstr *instr) {
-    switch (instr->getOpcode()) {
-      ExpandCaseToAllTypes(AMDIL::MOVE);
-      break;
-    default:
-      return false;
-    }
-    return true;
-  }
-
   static DebugLoc getLastDebugLocInBB(MachineBasicBlock *blk) {
     //get DebugLoc from the first MachineBasicBlock instruction with debug info
     DebugLoc DL;
@@ -2899,6 +2889,9 @@ struct CFGStructTraits<AMDILCFGStructurizer>
   // instruction.  Such move instruction "belong to" the loop backward-edge.
   //
   static MachineInstr *getLoopendBlockBranchInstr(MachineBasicBlock *blk) {
+    const AMDILInstrInfo * TII = static_cast<const AMDILInstrInfo *>(
+                                  blk->getParent()->getTarget().getInstrInfo());
+
     for (MachineBasicBlock::reverse_iterator iter = blk->rbegin(),
          iterEnd = blk->rend(); iter != iterEnd; ++iter) {
       // FIXME: Simplify
@@ -2906,7 +2899,7 @@ struct CFGStructTraits<AMDILCFGStructurizer>
       if (instr) {
         if (isCondBranch(instr) || isUncondBranch(instr)) {
           return instr;
-        } else if (!isPhimove(instr)) {
+        } else if (!TII->isMov(instr->getOpcode())) {
           break;
         }
       }
index 211c881..7ea8834 100644 (file)
@@ -152,6 +152,8 @@ public:
                                         int64_t Imm) const = 0;
 
   virtual unsigned getIEQOpcode() const = 0;
+
+  virtual bool isMov(unsigned Opcode) const = 0;
 };
 
 }
index 05c291f..363c814 100644 (file)
@@ -116,3 +116,14 @@ unsigned R600InstrInfo::getIEQOpcode() const
 {
   return AMDIL::SETE_INT;
 }
+
+bool R600InstrInfo::isMov(unsigned Opcode) const
+{
+  switch(Opcode) {
+  default: return false;
+  case AMDIL::MOV:
+  case AMDIL::MOV_IMM_F32:
+  case AMDIL::MOV_IMM_I32:
+    return true;
+  }
+}
index 2b5e5c4..2db10ad 100644 (file)
@@ -51,6 +51,7 @@ namespace llvm {
                                         int64_t Imm) const;
 
   virtual unsigned getIEQOpcode() const;
+  virtual bool isMov(unsigned Opcode) const;
 };
 
 } // End llvm namespace
index 4c7a920..058c772 100644 (file)
@@ -115,3 +115,18 @@ MachineInstr * SIInstrInfo::getMovImmInstr(MachineFunction *MF, unsigned DstReg,
   return MI;
 
 }
+
+bool SIInstrInfo::isMov(unsigned Opcode) const
+{
+  switch(Opcode) {
+  default: return false;
+  case AMDIL::S_MOV_B32:
+  case AMDIL::S_MOV_B64:
+  case AMDIL::V_MOV_B32_e32:
+  case AMDIL::V_MOV_B32_e64:
+  case AMDIL::V_MOV_IMM_F32:
+  case AMDIL::V_MOV_IMM_I32:
+  case AMDIL::S_MOV_IMM_I32:
+    return true;
+  }
+}
index 996dcee..6cfbaf4 100644 (file)
@@ -55,6 +55,7 @@ public:
                                         int64_t Imm) const;
 
   virtual unsigned getIEQOpcode() const { assert(!"Implement"); return 0;}
+  virtual bool isMov(unsigned Opcode) const;
 
   };