summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTom Stellard <thomas.stellard@amd.com>2012-09-07 09:11:59 -0400
committerTom Stellard <thomas.stellard@amd.com>2012-09-21 16:41:34 +0000
commit6f8049970905130d046251bd0c0870197ba30865 (patch)
treef938dca7464b634fadb1030790a66b39f1766c53 /lib
parentb64730337b4e1b1acc2fa3da357320fdd5d71728 (diff)
R600: Add SHADER_TYPE instruction
This allows the program to specify the type of shader being compiled (e.g. PXEL, VERTEX, etc.) Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/Target/AMDGPU/AMDGPU.h9
-rw-r--r--lib/Target/AMDGPU/AMDGPUInstructions.td7
-rw-r--r--lib/Target/AMDGPU/AMDGPUIntrinsics.td2
-rw-r--r--lib/Target/AMDGPU/R600ISelLowering.cpp1
-rw-r--r--lib/Target/AMDGPU/SIAssignInterpRegs.cpp4
-rw-r--r--lib/Target/AMDGPU/SIISelLowering.cpp6
-rw-r--r--lib/Target/AMDGPU/SIMachineFunctionInfo.cpp3
-rw-r--r--lib/Target/AMDGPU/SIMachineFunctionInfo.h1
8 files changed, 32 insertions, 1 deletions
diff --git a/lib/Target/AMDGPU/AMDGPU.h b/lib/Target/AMDGPU/AMDGPU.h
index ab6871c1da4..fe36545a165 100644
--- a/lib/Target/AMDGPU/AMDGPU.h
+++ b/lib/Target/AMDGPU/AMDGPU.h
@@ -33,4 +33,13 @@ FunctionPass *createAMDGPUConvertToISAPass(TargetMachine &tm);
} // End namespace llvm
+namespace ShaderType {
+ enum Type {
+ PIXEL = 0,
+ VERTEX = 1,
+ GEOMETRY = 2,
+ COMPUTE = 3
+ };
+}
+
#endif // AMDGPU_H
diff --git a/lib/Target/AMDGPU/AMDGPUInstructions.td b/lib/Target/AMDGPU/AMDGPUInstructions.td
index c8a7db6c772..6f47445b07c 100644
--- a/lib/Target/AMDGPU/AMDGPUInstructions.td
+++ b/lib/Target/AMDGPU/AMDGPUInstructions.td
@@ -114,6 +114,13 @@ 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)]
+>;
+
} // End isCodeGenOnly = 1, isPseudo = 1, hasCustomInserter = 1
/* Generic helper patterns for intrinsics */
diff --git a/lib/Target/AMDGPU/AMDGPUIntrinsics.td b/lib/Target/AMDGPU/AMDGPUIntrinsics.td
index 256ff487574..feca038b221 100644
--- a/lib/Target/AMDGPU/AMDGPUIntrinsics.td
+++ b/lib/Target/AMDGPU/AMDGPUIntrinsics.td
@@ -54,6 +54,8 @@ 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 {
diff --git a/lib/Target/AMDGPU/R600ISelLowering.cpp b/lib/Target/AMDGPU/R600ISelLowering.cpp
index 4735297d494..c28bb701e12 100644
--- a/lib/Target/AMDGPU/R600ISelLowering.cpp
+++ b/lib/Target/AMDGPU/R600ISelLowering.cpp
@@ -61,6 +61,7 @@ MachineBasicBlock * R600TargetLowering::EmitInstrWithCustomInserter(
switch (MI->getOpcode()) {
default: return AMDGPUTargetLowering::EmitInstrWithCustomInserter(MI, BB);
+ case AMDGPU::SHADER_TYPE: break;
case AMDGPU::CLAMP_R600:
{
MachineInstr *NewMI =
diff --git a/lib/Target/AMDGPU/SIAssignInterpRegs.cpp b/lib/Target/AMDGPU/SIAssignInterpRegs.cpp
index 3ee03ae74c5..447eff6f5ac 100644
--- a/lib/Target/AMDGPU/SIAssignInterpRegs.cpp
+++ b/lib/Target/AMDGPU/SIAssignInterpRegs.cpp
@@ -87,6 +87,10 @@ bool SIAssignInterpRegsPass::runOnMachineFunction(MachineFunction &MF)
};
SIMachineFunctionInfo * MFI = MF.getInfo<SIMachineFunctionInfo>();
+ // This pass is only needed for pixel shaders.
+ if (MFI->ShaderType != ShaderType::PIXEL) {
+ return false;
+ }
MachineRegisterInfo &MRI = MF.getRegInfo();
/* First pass, mark the interpolation values that are used. */
diff --git a/lib/Target/AMDGPU/SIISelLowering.cpp b/lib/Target/AMDGPU/SIISelLowering.cpp
index ebe9514a2b9..42c2e7f7ceb 100644
--- a/lib/Target/AMDGPU/SIISelLowering.cpp
+++ b/lib/Target/AMDGPU/SIISelLowering.cpp
@@ -16,6 +16,7 @@
#include "AMDIL.h"
#include "AMDILIntrinsicInfo.h"
#include "SIInstrInfo.h"
+#include "SIMachineFunctionInfo.h"
#include "SIRegisterInfo.h"
#include "llvm/CodeGen/MachineInstrBuilder.h"
#include "llvm/CodeGen/MachineRegisterInfo.h"
@@ -122,6 +123,11 @@ MachineBasicBlock * SITargetLowering::EmitInstrWithCustomInserter(
.addImm(1); // NEG
MI->eraseFromParent();
break;
+ 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);
diff --git a/lib/Target/AMDGPU/SIMachineFunctionInfo.cpp b/lib/Target/AMDGPU/SIMachineFunctionInfo.cpp
index 40ba76f1f86..f1a8c1f6e1b 100644
--- a/lib/Target/AMDGPU/SIMachineFunctionInfo.cpp
+++ b/lib/Target/AMDGPU/SIMachineFunctionInfo.cpp
@@ -14,5 +14,6 @@ using namespace llvm;
SIMachineFunctionInfo::SIMachineFunctionInfo(const MachineFunction &MF)
: MachineFunctionInfo(),
- spi_ps_input_addr(0)
+ spi_ps_input_addr(0),
+ ShaderType(0)
{ }
diff --git a/lib/Target/AMDGPU/SIMachineFunctionInfo.h b/lib/Target/AMDGPU/SIMachineFunctionInfo.h
index 46a021f3613..b60822e2e7a 100644
--- a/lib/Target/AMDGPU/SIMachineFunctionInfo.h
+++ b/lib/Target/AMDGPU/SIMachineFunctionInfo.h
@@ -28,6 +28,7 @@ class SIMachineFunctionInfo : public MachineFunctionInfo {
public:
SIMachineFunctionInfo(const MachineFunction &MF);
unsigned spi_ps_input_addr;
+ unsigned ShaderType;
};