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

Amy Kwan via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 5 12:07:38 PST 2024


================
@@ -3046,6 +3047,30 @@ void PPCAIXAsmPrinter::emitEndOfAsmFile(Module &M) {
 bool PPCAIXAsmPrinter::doInitialization(Module &M) {
   const bool Result = PPCAsmPrinter::doInitialization(M);
 
+  // Emit the .machine directive on AIX.
+  const Triple &Target = TM.getTargetTriple();
+  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;
----------------
amy-kwan wrote:

I think `llvm/test/CodeGen/PowerPC/aix-cpu-version.ll` is supposed to cover this. Or am I misunderstanding your comment?

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


More information about the llvm-commits mailing list