Index: llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp =================================================================== --- llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp +++ llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp @@ -1115,28 +1115,6 @@ return true; } -static unsigned getDSShaderTypeValue(const MachineFunction &MF) { - switch (MF.getFunction().getCallingConv()) { - case CallingConv::AMDGPU_PS: - return 1; - case CallingConv::AMDGPU_VS: - return 2; - case CallingConv::AMDGPU_GS: - return 3; - case CallingConv::AMDGPU_HS: - case CallingConv::AMDGPU_LS: - case CallingConv::AMDGPU_ES: - report_fatal_error("ds_ordered_count unsupported for this calling conv"); - case CallingConv::AMDGPU_CS: - case CallingConv::AMDGPU_KERNEL: - case CallingConv::C: - case CallingConv::Fast: - default: - // Assume other calling conventions are various compute callable functions - return 0; - } -} - bool AMDGPUInstructionSelector::selectDSOrderedIntrinsic( MachineInstr &MI, Intrinsic::ID IntrID) const { MachineBasicBlock *MBB = MI.getParent(); @@ -1168,7 +1146,7 @@ report_fatal_error("ds_ordered_count: bad index operand"); unsigned Instruction = IntrID == Intrinsic::amdgcn_ds_ordered_add ? 0 : 1; - unsigned ShaderType = getDSShaderTypeValue(*MF); + unsigned ShaderType = SIInstrInfo::getDSShaderTypeValue(*MF); unsigned Offset0 = OrderedCountIndex << 2; unsigned Offset1 = WaveRelease | (WaveDone << 1) | (ShaderType << 2) | Index: llvm/lib/Target/AMDGPU/SIISelLowering.cpp =================================================================== --- llvm/lib/Target/AMDGPU/SIISelLowering.cpp +++ llvm/lib/Target/AMDGPU/SIISelLowering.cpp @@ -6613,28 +6613,6 @@ cast(Offset)->getSExtValue(); } -static unsigned getDSShaderTypeValue(const MachineFunction &MF) { - switch (MF.getFunction().getCallingConv()) { - case CallingConv::AMDGPU_PS: - return 1; - case CallingConv::AMDGPU_VS: - return 2; - case CallingConv::AMDGPU_GS: - return 3; - case CallingConv::AMDGPU_HS: - case CallingConv::AMDGPU_LS: - case CallingConv::AMDGPU_ES: - report_fatal_error("ds_ordered_count unsupported for this calling conv"); - case CallingConv::AMDGPU_CS: - case CallingConv::AMDGPU_KERNEL: - case CallingConv::C: - case CallingConv::Fast: - default: - // Assume other calling conventions are various compute callable functions - return 0; - } -} - SDValue SITargetLowering::LowerINTRINSIC_W_CHAIN(SDValue Op, SelectionDAG &DAG) const { unsigned IntrID = cast(Op.getOperand(1))->getZExtValue(); @@ -6672,7 +6650,8 @@ report_fatal_error("ds_ordered_count: wave_done requires wave_release"); unsigned Instruction = IntrID == Intrinsic::amdgcn_ds_ordered_add ? 0 : 1; - unsigned ShaderType = getDSShaderTypeValue(DAG.getMachineFunction()); + unsigned ShaderType = + SIInstrInfo::getDSShaderTypeValue(DAG.getMachineFunction()); unsigned Offset0 = OrderedCountIndex << 2; unsigned Offset1 = WaveRelease | (WaveDone << 1) | (ShaderType << 2) | (Instruction << 4); Index: llvm/lib/Target/AMDGPU/SIInstrInfo.h =================================================================== --- llvm/lib/Target/AMDGPU/SIInstrInfo.h +++ llvm/lib/Target/AMDGPU/SIInstrInfo.h @@ -1053,6 +1053,8 @@ unsigned getInstrLatency(const InstrItineraryData *ItinData, const MachineInstr &MI, unsigned *PredCost = nullptr) const override; + + static unsigned getDSShaderTypeValue(const MachineFunction &MF); }; /// \brief Returns true if a reg:subreg pair P has a TRC class Index: llvm/lib/Target/AMDGPU/SIInstrInfo.cpp =================================================================== --- llvm/lib/Target/AMDGPU/SIInstrInfo.cpp +++ llvm/lib/Target/AMDGPU/SIInstrInfo.cpp @@ -7215,3 +7215,25 @@ return SchedModel.computeInstrLatency(&MI); } + +unsigned SIInstrInfo::getDSShaderTypeValue(const MachineFunction &MF) { + switch (MF.getFunction().getCallingConv()) { + case CallingConv::AMDGPU_PS: + return 1; + case CallingConv::AMDGPU_VS: + return 2; + case CallingConv::AMDGPU_GS: + return 3; + case CallingConv::AMDGPU_HS: + case CallingConv::AMDGPU_LS: + case CallingConv::AMDGPU_ES: + report_fatal_error("ds_ordered_count unsupported for this calling conv"); + case CallingConv::AMDGPU_CS: + case CallingConv::AMDGPU_KERNEL: + case CallingConv::C: + case CallingConv::Fast: + default: + // Assume other calling conventions are various compute callable functions + return 0; + } +}