R600/SI: remove shader type intrinsic
authorChristian Konig <christian.koenig@amd.com>
Thu, 7 Mar 2013 09:03:46 +0000 (09:03 +0000)
committerChristian Konig <christian.koenig@amd.com>
Thu, 7 Mar 2013 09:03:46 +0000 (09:03 +0000)
Just encode the type as target specific attribute.

Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Tom Stellard <thomas.stellard@amd.com>
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@176622 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/R600/AMDGPUInstructions.td
lib/Target/R600/AMDGPUIntrinsics.td
lib/Target/R600/R600ISelLowering.cpp
lib/Target/R600/SIISelLowering.cpp
lib/Target/R600/SIMachineFunctionInfo.cpp
lib/Target/R600/SIMachineFunctionInfo.h

index 960f1084e7f83c9f767f07849eb03bf1e382abd6..a59c77527223eee64837ba1996065c7eabb1b54c 100644 (file)
@@ -132,13 +132,6 @@ class FNEG <RegisterClass rc> : AMDGPUShaderInst <
   [(set rc:$dst, (fneg rc:$src0))]
 >;
 
-def SHADER_TYPE : AMDGPUShaderInst <
-  (outs),
-  (ins i32imm:$type),
-  "SHADER_TYPE $type",
-  [(int_AMDGPU_shader_type imm:$type)]
->;
-
 } // usesCustomInserter = 1
 
 multiclass RegisterLoadStore <RegisterClass dstClass, Operand addrClass,
index 2ba2d4b90d21ec903482292a117e88b489822819..eecb25b04f7934405a0b7cba6453451114232aa9 100644 (file)
@@ -50,8 +50,6 @@ let TargetPrefix = "AMDGPU", isTarget = 1 in {
   def int_AMDGPU_umax : Intrinsic<[llvm_i32_ty], [llvm_i32_ty, llvm_i32_ty], [IntrNoMem]>;
   def int_AMDGPU_umin : Intrinsic<[llvm_i32_ty], [llvm_i32_ty, llvm_i32_ty], [IntrNoMem]>;
   def int_AMDGPU_cube : Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty], [IntrNoMem]>;
-
-  def int_AMDGPU_shader_type : Intrinsic<[], [llvm_i32_ty], []>;
 }
 
 let TargetPrefix = "TGSI", isTarget = 1 in {
index f25ced134f1f660bdd7fb2265e82cc1868d462af..e8be2b27435e43526bb8fdee4f795b01d321e78c 100644 (file)
@@ -105,7 +105,6 @@ MachineBasicBlock * R600TargetLowering::EmitInstrWithCustomInserter(
 
   switch (MI->getOpcode()) {
   default: return AMDGPUTargetLowering::EmitInstrWithCustomInserter(MI, BB);
-  case AMDGPU::SHADER_TYPE: break;
   case AMDGPU::CLAMP_R600: {
     MachineInstr *NewMI = TII->buildDefaultInstruction(*BB, I,
                                                    AMDGPU::MOV,
index 7aa103785a65164aa40eb89b028c4ddc77138f87..a9eca31f6416d188f5b5e03447945c8613372e5c 100644 (file)
@@ -83,12 +83,6 @@ MachineBasicBlock * SITargetLowering::EmitInstrWithCustomInserter(
   default:
     return AMDGPUTargetLowering::EmitInstrWithCustomInserter(MI, BB);
   case AMDGPU::BRANCH: return BB;
-  case AMDGPU::SHADER_TYPE:
-    BB->getParent()->getInfo<SIMachineFunctionInfo>()->ShaderType =
-                                        MI->getOperand(0).getImm();
-    MI->eraseFromParent();
-    break;
-
   case AMDGPU::SI_INTERP:
     LowerSI_INTERP(MI, *BB, I, MRI);
     break;
index 7e59b4274968f9ad77778fba823ca1f93e288786..e5fbf05e08083cd420df92a7f78c814d19bbb781 100644 (file)
 
 
 #include "SIMachineFunctionInfo.h"
+#include "llvm/IR/Attributes.h"
+#include "llvm/IR/Function.h"
 
 using namespace llvm;
 
+const char *SIMachineFunctionInfo::ShaderTypeAttribute = "ShaderType";
+
 SIMachineFunctionInfo::SIMachineFunctionInfo(const MachineFunction &MF)
   : MachineFunctionInfo(),
     SPIPSInputAddr(0),
-    ShaderType(0)
-  { }
+    ShaderType(0) {
+
+  AttributeSet Set = MF.getFunction()->getAttributes();
+  Attribute A = Set.getAttribute(AttributeSet::FunctionIndex,
+                                 ShaderTypeAttribute);
+
+  if (A.isStringAttribute()) {
+    StringRef Str = A.getValueAsString();
+    if (Str.getAsInteger(0, ShaderType))
+      llvm_unreachable("Can't parse shader type!");
+  }
+}
index 47271f5a1e747bae28d71e34f857e64a2120e870..e2f97a47901ae9b2a0a5515ec8b17025896e519a 100644 (file)
@@ -23,6 +23,8 @@ namespace llvm {
 /// tells the hardware which interpolation parameters to load.
 class SIMachineFunctionInfo : public MachineFunctionInfo {
 public:
+  static const char *ShaderTypeAttribute;
+
   SIMachineFunctionInfo(const MachineFunction &MF);
   unsigned SPIPSInputAddr;
   unsigned ShaderType;