[llvm] [GlobalISel][TableGen] Add GIReplaceRegWithConstant/FConstant builtins (PR #222298)

Tim Gymnich via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 9 07:15:43 PDT 2026


================
@@ -873,8 +873,20 @@ bool BuiltinPattern::checkSemantics(ArrayRef<SMLoc> Loc) {
   if (!InstructionPattern::checkSemantics(Loc))
     return false;
 
-  // For now all builtins just take names, no immediates.
+  // All builtins just take names, except for the second operand of
+  // GIReplaceRegWithConstant/GIReplaceRegWithFConstant, which is a literal.
   for (const auto &[Idx, Op] : enumerate(operands())) {
+    if ((I.Kind == BI_ReplaceRegWithConstant ||
+         I.Kind == BI_ReplaceRegWithFConstant) &&
+        Idx == 1) {
+      if (!Op.hasImmValue() || Op.isNamedOperand()) {
+        PrintError(Loc, "expected operand " + std::to_string(Idx) + " of '" +
----------------
tgymnich wrote:

```suggestion
        PrintError(Loc, "expected operand " + Twine(Idx) + " of '" +
```

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


More information about the llvm-commits mailing list