[clang] [llvm] [HLSL] Implement the `reflect` HLSL function (PR #122992)
Farzon Lotfi via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 16 21:12:32 PST 2025
================
@@ -2944,6 +2944,10 @@ bool SPIRVInstructionSelector::selectIntrinsic(Register ResVReg,
return selectExtInst(ResVReg, ResType, I, CL::fract, GL::Fract);
case Intrinsic::spv_normalize:
return selectExtInst(ResVReg, ResType, I, CL::normalize, GL::Normalize);
+ case Intrinsic::spv_reflect:
+ if (STI.isVulkanEnv()) // There is no CL equivalent of Reflect
----------------
farzonl wrote:
I don't think this if statement does what you think it does. As long as the intrinsic remains in the MIR you won't be able to proceed with codegen.
instead if you want to gracefully exit you should modify the GLSL version of `selectExtInst ` to do something like this
```cpp
if (!STI.canUseExtInstSet(SPIRV::InstructionSet::GLSL_std_450)) {
std::string DiagMsg;
raw_string_ostream OS(DiagMsg);
I.print(OS);
DiagMsg = "Intrinsic selection not supported for this instruction set: " + DiagMsg;
report_fatal_error(DiagMsg.c_str(), false);
}
//original behavior of selectExtInst
```
https://github.com/llvm/llvm-project/pull/122992
More information about the llvm-commits
mailing list