[llvm] [SPIRV] Add support for `cl_khr_extended_bit_ops` (PR #120571)
Michal Paszkowski via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 19 07:46:16 PST 2024
================
@@ -983,6 +983,38 @@ static bool buildBarrierInst(const SPIRV::IncomingCall *Call, unsigned Opcode,
return true;
}
+/// Helper function for building extended bit operations.
+static bool buildExtendedBitOpsInst(const SPIRV::IncomingCall *Call,
+ unsigned Opcode,
+ MachineIRBuilder &MIRBuilder,
+ SPIRVGlobalRegistry *GR) {
+ const SPIRV::DemangledBuiltin *Builtin = Call->Builtin;
+ const auto *ST =
+ static_cast<const SPIRVSubtarget *>(&MIRBuilder.getMF().getSubtarget());
+ if ((Opcode == SPIRV::OpBitFieldInsert ||
+ Opcode == SPIRV::OpBitFieldSExtract ||
+ Opcode == SPIRV::OpBitFieldUExtract || Opcode == SPIRV::OpBitReverse) &&
+ !ST->canUseExtension(SPIRV::Extension::SPV_KHR_bit_instructions)) {
+ std::string DiagMsg = std::string(Builtin->Name) +
+ ": the builtin requires the following SPIR-V "
+ "extension: SPV_KHR_bit_instructions";
+ report_fatal_error(DiagMsg.c_str(), false);
+ }
+
+ // Generate SPIRV instruction accordingly.
+ if (Call->isSpirvOp())
+ return buildOpFromWrapper(MIRBuilder, Opcode, Call, Register(0));
+
+ // Generate the instruction.
----------------
michalpaszkowski wrote:
I think the two comments are a bit redundant -- even though it seems we do have similar comments in other places :)
https://github.com/llvm/llvm-project/pull/120571
More information about the llvm-commits
mailing list