[llvm] [SPIR-V] Implement insertion of 'Group and Subgroup Instructions' using builtin functions (PR #95176)

Michal Paszkowski via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 12 10:37:38 PDT 2024


================
@@ -1015,7 +1015,37 @@ static bool generateGroupInst(const SPIRV::IncomingCall *Call,
   const SPIRV::DemangledBuiltin *Builtin = Call->Builtin;
   const SPIRV::GroupBuiltin *GroupBuiltin =
       SPIRV::lookupGroupBuiltin(Builtin->Name);
+
   MachineRegisterInfo *MRI = MIRBuilder.getMRI();
+  if (Call->isSpirvOp()) {
+    if (GroupBuiltin->NoGroupOperation)
+      return buildOpFromWrapper(MIRBuilder, GroupBuiltin->Opcode, Call,
+                                GR->getSPIRVTypeID(Call->ReturnType));
+
+    // Group Operation is a literal
+    Register GroupOpReg = Call->Arguments[1];
+    const MachineInstr *MI = getDefInstrMaybeConstant(GroupOpReg, MRI);
+    if (!MI || MI->getOpcode() != TargetOpcode::G_CONSTANT) {
+      std::string DiagMsg = std::string(Builtin->Name) +
+                            ": expect a constant value of Group Operation";
+      report_fatal_error(DiagMsg.c_str());
----------------
michalpaszkowski wrote:

I think we should be safe using [a Twine here to concat the strings](https://llvm.org/docs/ProgrammersManual.html#id16) and create the message or I might be missing something

https://github.com/llvm/llvm-project/pull/95176


More information about the llvm-commits mailing list