radeon/llvm: Use a custom inserter to lower FNEG
authorTom Stellard <thomas.stellard@amd.com>
Fri, 25 May 2012 14:59:52 +0000 (10:59 -0400)
committerTom Stellard <thomas.stellard@amd.com>
Fri, 25 May 2012 19:40:58 +0000 (15:40 -0400)
src/gallium/drivers/radeon/AMDGPUInstructions.td
src/gallium/drivers/radeon/AMDILInstructions.td
src/gallium/drivers/radeon/R600ISelLowering.cpp
src/gallium/drivers/radeon/R600Instructions.td
src/gallium/drivers/radeon/R600LowerInstructions.cpp

index 1f0d582d82bd5194266e827a4974b4ee9114b837..a004b9c5abad4905187145da2bc14ca56045b1b8 100644 (file)
@@ -74,6 +74,13 @@ class FABS <RegisterClass rc> : AMDGPUShaderInst <
   [(set rc:$dst, (fabs rc:$src0))]
 >;
 
+class FNEG <RegisterClass rc> : AMDGPUShaderInst <
+  (outs rc:$dst),
+  (ins rc:$src0),
+  "FNEG $dst, $src0",
+  [(set rc:$dst, (fneg rc:$src0))]
+>;
+
 } // End isPseudo = 1, hasCustomInserter = 1
 
 } // End isCodeGenOnly = 1
index 869c2bb6af2448e6b3d71a98db7dc03bb3287c9a..0197e9418f32ed48a4050c665b7337a7c1b05c9d 100644 (file)
@@ -50,7 +50,6 @@ def INTTOANY_i16: OneInOneOut<IL_OP_MOV, (outs GPRI16:$dst), (ins GPRI32:$src0),
 //===---------------------------------------------------------------------===//
 // Signed 32bit integer math instructions start here
 //===---------------------------------------------------------------------===//
-defm NEGATE     : UnaryOpMCi32<IL_OP_I_NEGATE, IL_inegate>;
 // get rid of the addri via the tablegen instead of custom lowered instruction
 defm EADD   : BinaryOpMCi32<IL_OP_I_ADD, adde>;
 def INTTOANY_i32: OneInOneOut<IL_OP_MOV, (outs GPRI32:$dst), (ins GPRI32:$src0),
@@ -238,10 +237,6 @@ defm NEAR : UnaryOpMCf32<IL_OP_ROUND_NEAR, fnearbyint>;
 defm RND_Z : UnaryOpMCf32<IL_OP_ROUND_ZERO, ftrunc>;
 
 // This opcode has custom swizzle pattern encoded in Swizzle Encoder
-def NEG_f32         : OneInOneOut<IL_OP_MOV, (outs GPRF32:$dst),
-  (ins GPRF32:$src0),
-    !strconcat(IL_OP_MOV.Text, " $dst, $src0"),
-    [(set GPRF32:$dst, (fneg GPRF32:$src0))]>;
 def INTTOANY_f32    : OneInOneOut<IL_OP_MOV, (outs GPRF32:$dst),
   (ins GPRI32:$src0),
     !strconcat(IL_OP_MOV.Text, " $dst, $src0"),
index 59a2bb1cb288e26665a887d1c128b6f955c27337..de60a2d0e59254062be7d99ddb325d67bf536601 100644 (file)
@@ -115,6 +115,13 @@ MachineBasicBlock * R600TargetLowering::EmitInstrWithCustomInserter(
            .addOperand(MI->getOperand(1));
     break;
 
+  case AMDIL::FNEG_R600:
+    MI->getOperand(1).addTargetFlag(MO_FLAG_NEG);
+    BuildMI(*BB, I, BB->findDebugLoc(I), TII->get(AMDIL::MOV))
+            .addOperand(MI->getOperand(0))
+            .addOperand(MI->getOperand(1));
+    break;
+
   case AMDIL::R600_LOAD_CONST:
     {
       int64_t RegIndex = MI->getOperand(1).getImm();
index 22f3fc1b7802a2fc905283ef35f33a877c6f984b..a2a509ea8bab91a35ed762dcf5f7de8b1283ffdb 100644 (file)
@@ -1070,6 +1070,7 @@ def TXD_SHADOW: AMDGPUShaderInst <
 
 def CLAMP_R600 :  CLAMP <R600_Reg32>;
 def FABS_R600 : FABS<R600_Reg32>;
+def FNEG_R600 : FNEG<R600_Reg32>;
 
 let isPseudo = 1 in {
 
index 1795b38dfb6c11636bdc7b535bbfc7b3eb6610df..3b96b195fe6c4c1b31c691fb8b8645fc83261e93 100644 (file)
@@ -224,23 +224,6 @@ bool R600LowerInstructionsPass::runOnMachineFunction(MachineFunction &MF)
         continue;
       }
 
-      case AMDIL::NEGATE_i32:
-        BuildMI(MBB, I, MBB.findDebugLoc(I), TII->get(AMDIL::SUB_INT))
-                .addOperand(MI.getOperand(0))
-                .addReg(AMDIL::ZERO)
-                .addOperand(MI.getOperand(1));
-        break;
-
-      case AMDIL::NEG_f32:
-        {
-            MI.getOperand(1).addTargetFlag(MO_FLAG_NEG);
-            BuildMI(MBB, I, MBB.findDebugLoc(I),
-                    TII->get(TII->getISAOpcode(AMDIL::MOV)))
-            .addOperand(MI.getOperand(0))
-            .addOperand(MI.getOperand(1));
-          break;
-        }
-
       case AMDIL::ULT:
         BuildMI(MBB, I, MBB.findDebugLoc(I), TII->get(AMDIL::SETGT_UINT))
                 .addOperand(MI.getOperand(0))