[clang] [llvm] [HLSL] Adding HLSL `clip` function. (PR #114588)
Finn Plummer via cfe-commits
cfe-commits at lists.llvm.org
Thu Nov 7 12:23:52 PST 2024
================
@@ -2120,6 +2123,32 @@ bool SPIRVInstructionSelector::selectSplatVector(Register ResVReg,
return MIB.constrainAllUses(TII, TRI, RBI);
}
+bool SPIRVInstructionSelector::selectClip(Register ResVReg,
+ const SPIRVType *ResType,
+ MachineInstr &I) const {
+
+ unsigned Opcode;
+
+ if (STI.isAtLeastSPIRVVer(VersionTuple(1, 6))) {
+ if (!STI.canUseExtension(
+ SPIRV::Extension::SPV_EXT_demote_to_helper_invocation))
+ report_fatal_error(
+ "llvm.spv.clip intrinsic: this instruction requires the following "
+ "SPIR-V extension: SPV_EXT_demote_to_helper_invocation",
+ false);
----------------
inbelic wrote:
```suggestion
if (STI.isAtLeastSPIRVVer(VersionTuple(1, 6)) ||
STI.canUseExtension(SPIRV::Extension::SPV_EXT_demote_to_helper_invocation))) {
```
My understanding is that the extension is used to specify the capability is available when we don't have a spirv version that enables it by default. So we can use it if the minimum version is allowed or the extension is enabled.
https://github.com/llvm/llvm-project/pull/114588
More information about the cfe-commits
mailing list