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

zhijian lin via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 6 06:25:03 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;
----------------
diggerlin wrote:

do we need two functions with different 
"target-cpu" value?

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


More information about the llvm-commits mailing list