[llvm] Add diagnostic help for inline asm operand constraint 'H' (PR #88248)

Jessica Clarke via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 10 11:16:03 PDT 2024


================
@@ -422,13 +425,34 @@ void SparcAsmPrinter::printMemOperand(const MachineInstr *MI, int opNum,
   printOperand(MI, opNum+1, O);
 }
 
+void SparcAsmPrinter::diagnoseAsmOperandError(LLVMContext &C,
+                                              const AsmOperandErrorCode EC,
+                                              const char *AsmStr,
+                                              uint64_t Loc) {
+  AsmPrinter::diagnoseAsmOperandError(C, EC, AsmStr, Loc);
+  std::string msg;
+  raw_string_ostream Msg(msg);
+  switch (EC) {
+  default:
+    break;
+  case AsmOperandErrorCode::CONSTRAINT_H_ERROR:
+    Msg << "Hi part of pair should point to an even-numbered register";
+    Msg << "\n (note that in some cases it might be necessary to manually "
+           "bind the input/output registers instead of relying on "
+           "automatic allocation)";
+    break;
+  }
+  C.emitError(Msg.str());
+}
 /// PrintAsmOperand - Print out an operand for an inline asm expression.
----------------
jrtc27 wrote:

```suggestion

/// PrintAsmOperand - Print out an operand for an inline asm expression.
```

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


More information about the llvm-commits mailing list