[llvm] [PowerPC][AIX] Emit PowerPC version for XCOFF (PR #95510)

Chen Zheng via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 5 03:17:20 PDT 2024


================
@@ -514,9 +514,28 @@ bool AsmPrinter::doInitialization(Module &M) {
     }
   }
 
-  // On AIX, emit bytes for llvm.commandline metadata after .file so that the
-  // C_INFO symbol is preserved if any csect is kept by the linker.
   if (TM.getTargetTriple().isOSBinFormatXCOFF()) {
+    // Emit .machine directive on AIX.
+    XCOFF::CFileCpuId TargetCpuId = XCOFF::TCPU_INVALID;
+    // Walk through the "target-cpu" attribute of functions and use the newest
+    // level as the CPU of the module.
+    for (auto &F : M) {
+      XCOFF::CFileCpuId FunCpuId =
+          XCOFF::getCpuID(TM.getSubtargetImpl(F)->getCPU());
+      if (FunCpuId > TargetCpuId)
+        TargetCpuId = FunCpuId;
+    }
+    // If there is no "target-cpu" attr in functions, take the "-mcpu" value.
+    if (!TargetCpuId) {
+      if (!TM.getTargetCPU().empty())
+        TargetCpuId = XCOFF::getCpuID(TM.getTargetCPU());
+      else
+        TargetCpuId = XCOFF::TCPU_ANY;
----------------
chenzheng1030 wrote:

Maybe `TCPU_COM` is a better default CPU type

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


More information about the llvm-commits mailing list