mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-04-02 19:30:34 +02:00
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 <michel.daenzer@amd.com>
This commit is contained in:
parent
841c1b5f54
commit
dfd3d61abf
8 changed files with 32 additions and 1 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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 */
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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 =
|
||||
|
|
|
|||
|
|
@ -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. */
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
{ }
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ class SIMachineFunctionInfo : public MachineFunctionInfo {
|
|||
public:
|
||||
SIMachineFunctionInfo(const MachineFunction &MF);
|
||||
unsigned spi_ps_input_addr;
|
||||
unsigned ShaderType;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue