diff options
author | Tom Stellard <[email protected]> | 2012-09-07 09:11:59 -0400 |
---|---|---|
committer | Tom Stellard <[email protected]> | 2012-09-11 14:53:47 -0400 |
commit | dfd3d61abfc8b2dc7300636ed5308f0a83953017 (patch) | |
tree | 0302ddd1955be5d0a2e9374927152199e79379ca /src/gallium | |
parent | 841c1b5f5423d7994ff0f6773639934d75bd1fca (diff) |
radeon/llvm: 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 <[email protected]>
Diffstat (limited to 'src/gallium')
-rw-r--r-- | src/gallium/drivers/radeon/AMDGPU.h | 9 | ||||
-rw-r--r-- | src/gallium/drivers/radeon/AMDGPUInstructions.td | 7 | ||||
-rw-r--r-- | src/gallium/drivers/radeon/AMDGPUIntrinsics.td | 2 | ||||
-rw-r--r-- | src/gallium/drivers/radeon/R600ISelLowering.cpp | 1 | ||||
-rw-r--r-- | src/gallium/drivers/radeon/SIAssignInterpRegs.cpp | 4 | ||||
-rw-r--r-- | src/gallium/drivers/radeon/SIISelLowering.cpp | 6 | ||||
-rw-r--r-- | src/gallium/drivers/radeon/SIMachineFunctionInfo.cpp | 3 | ||||
-rw-r--r-- | src/gallium/drivers/radeon/SIMachineFunctionInfo.h | 1 |
8 files changed, 32 insertions, 1 deletions
diff --git a/src/gallium/drivers/radeon/AMDGPU.h b/src/gallium/drivers/radeon/AMDGPU.h index ab6871c1da4..fe36545a165 100644 --- a/src/gallium/drivers/radeon/AMDGPU.h +++ b/src/gallium/drivers/radeon/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/src/gallium/drivers/radeon/AMDGPUInstructions.td b/src/gallium/drivers/radeon/AMDGPUInstructions.td index c8a7db6c772..6f47445b07c 100644 --- a/src/gallium/drivers/radeon/AMDGPUInstructions.td +++ b/src/gallium/drivers/radeon/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/src/gallium/drivers/radeon/AMDGPUIntrinsics.td b/src/gallium/drivers/radeon/AMDGPUIntrinsics.td index 89cc7e10d74..958e0bd73f7 100644 --- a/src/gallium/drivers/radeon/AMDGPUIntrinsics.td +++ b/src/gallium/drivers/radeon/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/src/gallium/drivers/radeon/R600ISelLowering.cpp b/src/gallium/drivers/radeon/R600ISelLowering.cpp index 5642ee8fff3..5a82920c377 100644 --- a/src/gallium/drivers/radeon/R600ISelLowering.cpp +++ b/src/gallium/drivers/radeon/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/src/gallium/drivers/radeon/SIAssignInterpRegs.cpp b/src/gallium/drivers/radeon/SIAssignInterpRegs.cpp index 3ee03ae74c5..447eff6f5ac 100644 --- a/src/gallium/drivers/radeon/SIAssignInterpRegs.cpp +++ b/src/gallium/drivers/radeon/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/src/gallium/drivers/radeon/SIISelLowering.cpp b/src/gallium/drivers/radeon/SIISelLowering.cpp index ebe9514a2b9..42c2e7f7ceb 100644 --- a/src/gallium/drivers/radeon/SIISelLowering.cpp +++ b/src/gallium/drivers/radeon/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/src/gallium/drivers/radeon/SIMachineFunctionInfo.cpp b/src/gallium/drivers/radeon/SIMachineFunctionInfo.cpp index 40ba76f1f86..f1a8c1f6e1b 100644 --- a/src/gallium/drivers/radeon/SIMachineFunctionInfo.cpp +++ b/src/gallium/drivers/radeon/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/src/gallium/drivers/radeon/SIMachineFunctionInfo.h b/src/gallium/drivers/radeon/SIMachineFunctionInfo.h index 46a021f3613..b60822e2e7a 100644 --- a/src/gallium/drivers/radeon/SIMachineFunctionInfo.h +++ b/src/gallium/drivers/radeon/SIMachineFunctionInfo.h @@ -28,6 +28,7 @@ class SIMachineFunctionInfo : public MachineFunctionInfo { public: SIMachineFunctionInfo(const MachineFunction &MF); unsigned spi_ps_input_addr; + unsigned ShaderType; }; |