[clang] [llvm] [HLSL] Implement the f16tof32() intrinsic (PR #165860)
Tim Corringham via cfe-commits
cfe-commits at lists.llvm.org
Fri Oct 31 08:34:14 PDT 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:
I don't have a particular reason to do it this way - it just seemed the most obvious way (it is the first SPIRV code I've touched, so I only have a superficial understanding of the SPIRV codegen).
If you can outline a better way I'll be happy to amend the code - I don't immediately see how 16 bit types help, unless UnpackHalf2x16 isn't used.
https://github.com/llvm/llvm-project/pull/165860
More information about the cfe-commits
mailing list