[llvm] [PowerPC][AIX] Emit PowerPC version for XCOFF (PR #95510)
Chen Zheng via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 26 02:06:54 PDT 2024
================
@@ -500,9 +500,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_COM;
----------------
chenzheng1030 wrote:
if there is no -mcpu option either, maybe we should get the default CPU by calling to `getNormalizedPPCTargetCPU()` instead of setting it to `XCOFF::TCPU_COM`?
https://github.com/llvm/llvm-project/pull/95510
More information about the llvm-commits
mailing list