[llvm] [PowerPC][AIX] Emit PowerPC version for XCOFF (PR #95510)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 25 23:21:42 PDT 2024
================
@@ -514,9 +514,27 @@ 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.
+ StringRef TargetCPU;
+ // Walk through the target-cpu attribute of functions and use the newest
+ // level as the CPU of the module.
+ for (auto &F : M) {
+ StringRef FunCPU = TM.getSubtargetImpl(F)->getCPU();
+ if (XCOFF::getCpuID(FunCPU) > XCOFF::getCpuID(TargetCPU))
+ TargetCPU = FunCPU;
+ }
+ // If there is no "target-cpu" attr in functions, take the "-mcpu" value.
+ if (TargetCPU.empty()) {
+ if (!TM.getTargetCPU().empty())
+ TargetCPU = TM.getTargetCPU();
+ else
+ TargetCPU = "any";
+ }
+ OutStreamer->emitMachineDirective(TargetCPU);
----------------
EsmeYi wrote:
Thanks. The valid values for the assembler are not exactly the same as those in XCOFF, so I thought it would be appropriate to support an intersection of them.
https://github.com/llvm/llvm-project/pull/95510
More information about the llvm-commits
mailing list