[llvm] Let M68kMCCodeEmitter set Scratch size. (PR #69898)

Min-Yih Hsu via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 24 12:33:42 PDT 2023


================
@@ -505,7 +506,16 @@ std::string VarLenCodeEmitterGen::getInstructionCaseForEncoding(
   if (!PostEmitter.empty())
     SS.indent(I) << "Inst = " << PostEmitter << "(MI, Inst, STI);\n";
 
-  return Case;
+  // Resize the scratch buffer if it's to small.
+  std::string ScratchResizeStr = "";
+  if (VLI.size() && !VLI.isFixedValueOnly()) {
+    raw_string_ostream RS(ScratchResizeStr);
+    std::string High = utostr(HighScratchAccess);
----------------
mshockwave wrote:

I think `raw_string_ostream` can convert unsigned values to strings. So maybe
```
<< "if (Scratch.getBitWidth() < " << High << ") "
```
would be better than calling `utostr` here.

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


More information about the llvm-commits mailing list