[llvm-branch-commits] [llvm-branch] r166327 - in /llvm/branches/R600: lib/Target/AMDGPU/R600ISelLowering.cpp lib/Target/AMDGPU/R600InstrInfo.cpp lib/Target/AMDGPU/R600InstrInfo.h lib/Target/AMDGPU/R600Instructions.td test/CodeGen/R600/fabs.ll test/CodeGen/R600/fcmp.ll test/CodeGen/R600/fsub.ll

Tom Stellard thomas.stellard at amd.com
Fri Oct 19 14:10:06 PDT 2012


Author: tstellar
Date: Fri Oct 19 16:10:06 2012
New Revision: 166327

URL: http://llvm.org/viewvc/llvm-project?rev=166327&view=rev
Log:
R600: Use native operands for the MOV Instruction

Modified:
    llvm/branches/R600/lib/Target/AMDGPU/R600ISelLowering.cpp
    llvm/branches/R600/lib/Target/AMDGPU/R600InstrInfo.cpp
    llvm/branches/R600/lib/Target/AMDGPU/R600InstrInfo.h
    llvm/branches/R600/lib/Target/AMDGPU/R600Instructions.td
    llvm/branches/R600/test/CodeGen/R600/fabs.ll
    llvm/branches/R600/test/CodeGen/R600/fcmp.ll
    llvm/branches/R600/test/CodeGen/R600/fsub.ll

Modified: llvm/branches/R600/lib/Target/AMDGPU/R600ISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/R600/lib/Target/AMDGPU/R600ISelLowering.cpp?rev=166327&r1=166326&r2=166327&view=diff
==============================================================================
--- llvm/branches/R600/lib/Target/AMDGPU/R600ISelLowering.cpp (original)
+++ llvm/branches/R600/lib/Target/AMDGPU/R600ISelLowering.cpp Fri Oct 19 16:10:06 2012
@@ -81,36 +81,30 @@
   case AMDGPU::SHADER_TYPE: break;
   case AMDGPU::CLAMP_R600:
     {
-      MachineInstr *NewMI =
-        BuildMI(*BB, I, BB->findDebugLoc(I), TII->get(AMDGPU::MOV))
-               .addOperand(MI->getOperand(0))
-               .addOperand(MI->getOperand(1))
-               .addImm(0) // Flags
-               .addReg(AMDGPU::PRED_SEL_OFF);
+      MachineInstr *NewMI = TII->buildDefaultInstruction(*BB, I,
+                                                    AMDGPU::MOV,
+                                                    MI->getOperand(0).getReg(),
+                                                    MI->getOperand(1).getReg());
       TII->addFlag(NewMI, 0, MO_FLAG_CLAMP);
       break;
     }
   case AMDGPU::FABS_R600:
     {
-      MachineInstr *NewMI =
-        BuildMI(*BB, I, BB->findDebugLoc(I), TII->get(AMDGPU::MOV))
-               .addOperand(MI->getOperand(0))
-               .addOperand(MI->getOperand(1))
-               .addImm(0) // Flags
-               .addReg(AMDGPU::PRED_SEL_OFF);
-      TII->addFlag(NewMI, 1, MO_FLAG_ABS);
+      MachineInstr *NewMI = TII->buildDefaultInstruction(*BB, I,
+                                                    AMDGPU::MOV,
+                                                    MI->getOperand(0).getReg(),
+                                                    MI->getOperand(1).getReg());
+      TII->addFlag(NewMI, 0, MO_FLAG_ABS);
       break;
     }
 
   case AMDGPU::FNEG_R600:
     {
-      MachineInstr *NewMI =
-        BuildMI(*BB, I, BB->findDebugLoc(I), TII->get(AMDGPU::MOV))
-                .addOperand(MI->getOperand(0))
-                .addOperand(MI->getOperand(1))
-                .addImm(0) // Flags
-                .addReg(AMDGPU::PRED_SEL_OFF);
-      TII->addFlag(NewMI, 1, MO_FLAG_NEG);
+      MachineInstr *NewMI = TII->buildDefaultInstruction(*BB, I,
+                                                    AMDGPU::MOV,
+                                                    MI->getOperand(0).getReg(),
+                                                    MI->getOperand(1).getReg());
+      TII->addFlag(NewMI, 0, MO_FLAG_NEG);
     break;
     }
 

Modified: llvm/branches/R600/lib/Target/AMDGPU/R600InstrInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/R600/lib/Target/AMDGPU/R600InstrInfo.cpp?rev=166327&r1=166326&r2=166327&view=diff
==============================================================================
--- llvm/branches/R600/lib/Target/AMDGPU/R600InstrInfo.cpp (original)
+++ llvm/branches/R600/lib/Target/AMDGPU/R600InstrInfo.cpp Fri Oct 19 16:10:06 2012
@@ -54,23 +54,22 @@
       && AMDGPU::R600_Reg128RegClass.contains(SrcReg)) {
     for (unsigned I = 0; I < 4; I++) {
       unsigned SubRegIndex = RI.getSubRegFromChannel(I);
-      BuildMI(MBB, MI, DL, get(AMDGPU::MOV))
-              .addReg(RI.getSubReg(DestReg, SubRegIndex), RegState::Define)
-              .addReg(RI.getSubReg(SrcReg, SubRegIndex))
-              .addImm(0) // Flag
-              .addReg(0) // PREDICATE_BIT
-              .addReg(DestReg, RegState::Define | RegState::Implicit);
+      buildDefaultInstruction(MBB, MI, AMDGPU::MOV,
+                              RI.getSubReg(DestReg, SubRegIndex),
+                              RI.getSubReg(SrcReg, SubRegIndex))
+                              .addReg(DestReg,
+                                      RegState::Define | RegState::Implicit);
     }
   } else {
 
-    /* We can't copy vec4 registers */
+    // We can't copy vec4 registers
     assert(!AMDGPU::R600_Reg128RegClass.contains(DestReg)
            && !AMDGPU::R600_Reg128RegClass.contains(SrcReg));
 
-    BuildMI(MBB, MI, DL, get(AMDGPU::MOV), DestReg)
-      .addReg(SrcReg, getKillRegState(KillSrc))
-      .addImm(0) // Flag
-      .addReg(0); // PREDICATE_BIT
+    MachineInstr *NewMI = buildDefaultInstruction(MBB, MI, AMDGPU::MOV,
+                                                  DestReg, SrcReg);
+    NewMI->getOperand(getOperandIdx(*NewMI, R600Operands::SRC0))
+                                    .setIsKill(KillSrc);
   }
 }
 
@@ -475,6 +474,28 @@
   return 2;
 }
 
+MachineInstrBuilder R600InstrInfo::buildDefaultInstruction(MachineBasicBlock &MBB,
+                                                  MachineBasicBlock::iterator I,
+                                                  unsigned Opcode,
+                                                  unsigned DstReg,
+                                                  unsigned Src0Reg) const
+{
+  return BuildMI(MBB, I, MBB.findDebugLoc(I), get(Opcode), DstReg)
+    .addImm(1)        // $write
+    .addImm(0)        // $omod
+    .addImm(0)        // $dst_rel
+    .addImm(0)        // $dst_clamp
+    .addReg(Src0Reg)  // $src0
+    .addImm(0)        // $src0_neg
+    .addImm(0)        // $src0_rel
+    .addImm(0)        // $src0_abs
+    //XXX: The r600g finalizer expects this to be 1, once we've moved the
+    //scheduling to the backend, we can change the default to 0.
+    .addImm(1)        // $last
+    .addReg(AMDGPU::PRED_SEL_OFF) // $pred_sel
+    .addImm(0);        // $literal
+}
+
 int R600InstrInfo::getOperandIdx(const MachineInstr &MI,
                                  R600Operands::Ops Op) const
 {

Modified: llvm/branches/R600/lib/Target/AMDGPU/R600InstrInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/R600/lib/Target/AMDGPU/R600InstrInfo.h?rev=166327&r1=166326&r2=166327&view=diff
==============================================================================
--- llvm/branches/R600/lib/Target/AMDGPU/R600InstrInfo.h (original)
+++ llvm/branches/R600/lib/Target/AMDGPU/R600InstrInfo.h Fri Oct 19 16:10:06 2012
@@ -110,6 +110,16 @@
   virtual int getInstrLatency(const InstrItineraryData *ItinData,
                               SDNode *Node) const { return 1;}
 
+  ///buildDefaultInstruction - This function returns a MachineInstr with
+  /// all the instruction modifiers initialized to their default values.
+  /// You can use this function to avoid manually specifying each instruction
+  /// modifier operand when building a new instruction.
+  MachineInstrBuilder buildDefaultInstruction(MachineBasicBlock &MBB,
+                                              MachineBasicBlock::iterator I,
+                                              unsigned Opcode,
+                                              unsigned DstReg,
+                                              unsigned Src0Reg) const;
+
   /// getOperandIdx - Get the index of Op in the MachineInstr.  Returns -1
   /// if the Instruction does not contain the specified Op.
   int getOperandIdx(const MachineInstr &MI, R600Operands::Ops Op) const;

Modified: llvm/branches/R600/lib/Target/AMDGPU/R600Instructions.td
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/R600/lib/Target/AMDGPU/R600Instructions.td?rev=166327&r1=166326&r2=166327&view=diff
==============================================================================
--- llvm/branches/R600/lib/Target/AMDGPU/R600Instructions.td (original)
+++ llvm/branches/R600/lib/Target/AMDGPU/R600Instructions.td Fri Oct 19 16:10:06 2012
@@ -514,19 +514,7 @@
 def RNDNE : R600_1OP_Helper <0x13, "RNDNE", frint>;
 def FLOOR : R600_1OP_Helper <0x14, "FLOOR", ffloor>;
 
-let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in {
-
-def MOV : InstR600 <0x19, (outs R600_Reg32:$dst),
-                          (ins R600_Reg32:$src0, i32imm:$flags,
-                               R600_Pred:$p),
-                          "MOV $dst, $src0", [], AnyALU> {
-  let FlagOperandIdx = 2;
-  bits<7> dst;
-  bits<9> src0;
-  let Inst{8-0}   = src0;
-  let Inst{49-39} = op_code;
-  let Inst{59-53} = dst;
-}
+def MOV : R600_1OP <0x19, "MOV", []>;
 
 class MOV_IMM <ValueType vt, Operand immType> : InstR600 <0x19,
   (outs R600_Reg32:$dst),
@@ -543,7 +531,6 @@
   let Inst{59-53} = dst;
 }
 
-} // End mayLoad = 0, mayStore = 0, hasSideEffects = 0
 def MOV_IMM_I32 : MOV_IMM<i32, i32imm>;
 def : Pat <
   (imm:$val),

Modified: llvm/branches/R600/test/CodeGen/R600/fabs.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/R600/test/CodeGen/R600/fabs.ll?rev=166327&r1=166326&r2=166327&view=diff
==============================================================================
--- llvm/branches/R600/test/CodeGen/R600/fabs.ll (original)
+++ llvm/branches/R600/test/CodeGen/R600/fabs.ll Fri Oct 19 16:10:06 2012
@@ -1,6 +1,6 @@
 ;RUN: llc < %s -march=r600 -mcpu=redwood | FileCheck %s
 
-;CHECK: MOV T{{[0-9]+\.[XYZW], T[0-9]+\.[XYZW]}}
+;CHECK: MOV T{{[0-9]+\.[XYZW], \|T[0-9]+\.[XYZW]\|}}
 
 define void @test() {
    %r0 = call float @llvm.R600.load.input(i32 0)

Modified: llvm/branches/R600/test/CodeGen/R600/fcmp.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/R600/test/CodeGen/R600/fcmp.ll?rev=166327&r1=166326&r2=166327&view=diff
==============================================================================
--- llvm/branches/R600/test/CodeGen/R600/fcmp.ll (original)
+++ llvm/branches/R600/test/CodeGen/R600/fcmp.ll Fri Oct 19 16:10:06 2012
@@ -1,7 +1,7 @@
 ;RUN: llc < %s -march=r600 -mcpu=redwood | FileCheck %s
 
 ;CHECK: SETE T{{[0-9]+\.[XYZW], T[0-9]+\.[XYZW], T[0-9]+\.[XYZW]}}
-;CHECK: MOV T{{[0-9]+\.[XYZW], T[0-9]+\.[XYZW]}}
+;CHECK: MOV T{{[0-9]+\.[XYZW], -T[0-9]+\.[XYZW]}}
 ;CHECK: FLT_TO_INT T{{[0-9]+\.[XYZW], T[0-9]+\.[XYZW]}}
 
 define void @test(i32 addrspace(1)* %out, float addrspace(1)* %in) {

Modified: llvm/branches/R600/test/CodeGen/R600/fsub.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/R600/test/CodeGen/R600/fsub.ll?rev=166327&r1=166326&r2=166327&view=diff
==============================================================================
--- llvm/branches/R600/test/CodeGen/R600/fsub.ll (original)
+++ llvm/branches/R600/test/CodeGen/R600/fsub.ll Fri Oct 19 16:10:06 2012
@@ -1,5 +1,6 @@
 ;RUN: llc < %s -march=r600 -mcpu=redwood | FileCheck %s
 
+; CHECK: MOV T{{[0-9]+\.[XYZW], -T[0-9]+\.[XYZW]}}
 ; CHECK: ADD T{{[0-9]+\.[XYZW], T[0-9]+\.[XYZW], T[0-9]+\.[XYZW]}}
 
 define void @test() {





More information about the llvm-branch-commits mailing list