[clang] [llvm] [HLSL] Implement the f16tof32() intrinsic (PR #165860)
Tim Corringham via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 4 08:00:06 PST 2025
================
@@ -3780,6 +3751,89 @@ bool SPIRVInstructionSelector::selectResourceNonUniformIndex(
return true;
}
+bool SPIRVInstructionSelector::selectF16ToF32(Register ResVReg,
+ const SPIRVType *ResType,
+ MachineInstr &I) const {
+ assert(I.getNumOperands() == 3);
+ assert(I.getOperand(0).isReg());
+ assert(I.getOperand(2).isReg());
+ Register SrcReg = I.getOperand(2).getReg();
+ const SPIRVType *SrcRegType = GR.getSPIRVTypeForVReg(SrcReg);
+ LLT SrcType = MRI->getType(SrcReg);
+ SPIRVType *SrcEltType = GR.getScalarOrVectorComponentType(SrcRegType);
+ SPIRVType *ResEltType = GR.getScalarOrVectorComponentType(ResType);
+ const TargetRegisterClass *SrcRegClass = GR.getRegClass(SrcEltType);
+ const TargetRegisterClass *ResRegClass = GR.getRegClass(ResEltType);
+ MachineIRBuilder MIRBuilder(I);
+ const SPIRVType *Vec2ResType =
+ GR.getOrCreateSPIRVVectorType(ResEltType, 2, MIRBuilder, false);
+ const TargetRegisterClass *Vec2RegClass = GR.getRegClass(Vec2ResType);
+
+ bool Result = true;
----------------
tcorringham wrote:
As you have probably noticed, I have made changes along the lines of farzonl's comment - moving the expansion of the vector spv_legacyf16tof32 to Clang Codegen and using a spv_unpackhalf2x16 instead.
This simplifies the spirv codegen significantly. I have included a comment along the lines of your suggestion in the clang codegen.
https://github.com/llvm/llvm-project/pull/165860
More information about the llvm-commits
mailing list