[llvm] [NVPTX] Cleanup/Refactoring in NVPTX AsmPrinter and RegisterInfo (NFC) (PR #126800)

Artem Belevich via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 11 16:51:20 PST 2025


================
@@ -839,16 +827,14 @@ void NVPTXAsmPrinter::emitGlobalAlias(const Module &M, const GlobalAlias &GA) {
 
 void NVPTXAsmPrinter::emitHeader(Module &M, raw_ostream &O,
                                  const NVPTXSubtarget &STI) {
-  O << "//\n";
-  O << "// Generated by LLVM NVPTX Back-End\n";
-  O << "//\n";
-  O << "\n";
+  const unsigned PTXVersion = STI.getPTXVersion();
 
-  unsigned PTXVersion = STI.getPTXVersion();
-  O << ".version " << (PTXVersion / 10) << "." << (PTXVersion % 10) << "\n";
-
-  O << ".target ";
-  O << STI.getTargetName();
+  O << "//\n"
+       "// Generated by LLVM NVPTX Back-End\n"
+       "//\n"
+       "\n"
+    << ".version " << (PTXVersion / 10) << "." << (PTXVersion % 10) << "\n"
----------------
Artem-B wrote:

We could probably make use of Format.h to simplify printing further:
https://github.com/llvm/llvm-project/blob/934c97dd16ae8048ae009d97be7d80db4e1dee66/llvm/include/llvm/Support/Format.h#L9-L18

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


More information about the llvm-commits mailing list