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

Amy Kwan via llvm-commits llvm-commits at lists.llvm.org
Sun Nov 10 20:50:26 PST 2024


amy-kwan wrote:

> There is already a `PPCTargetXCOFFStreamer::emitMachine()` method. Why can't this be used to emit the directive? It feels like the code is duplicating existing functionality.
> 
> E.g. the code in `AsmPrinter::doInitialization()` to emit the directive could move to `PPCAsmPrinter::emitStartOfAsmFile()`, because it is XCOFF+PowerPC specific. Then you have access to the `PPCTargetStreamer` to call `emitMachine()`. This avoids adding more XCOFF-specific functions to the global classes.

Unless I am missing something, I do not see why I cannot use the `emitMachine()` that already exists in `PPCTargetXCOFFStreamer`. I have updated the patch to leverage this, so thanks for the suggestion @redstar!

The only obvious difference I can see is that the `.machine` pseudo-op is no longer emitted directly after the `.file` pseudo-op in my implementation of changing it to use PPCTargetXCOFFStreamer, but unless I am reading the documentation (such as https://www.ibm.com/docs/en/aix/7.3?topic=ops-machine-pseudo-op) incorrectly, I believe this OK.

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


More information about the llvm-commits mailing list