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 26559a0371d2351531050f48e5d0d2c1e9edcc67..ba7d246137eb0f90c2da80e1154929b77bfd2913 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 211c881e7b9abadd59831114fe2177ab98ac11d2..7ea88348a9a77427a5018c5606543aac6980e933 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 05c291f1b8933303c5cd123a0c02371c1740cbdb..363c814886356dd6b7fd6d744531952d8dcd57a9 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 2b5e5c42995799ce9e781305ce431d0935c824e5..2db10addef44cf31afba61757030d78769380f72 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 4c7a92075c64abe1b9673f1fb90585c997fcbaaa..058c772e620a80d9a48f7a49c04d274a18241feb 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 996dceeb0752aec78b376ca89903bea5b81e5f4e..6cfbaf4623b002554193c266a6b0783956edd8d1 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;
 
   };