[llvm-dev] Manually insert an instruction in SelectionDAG
Tim Northover via llvm-dev
llvm-dev at lists.llvm.org
Sat Aug 3 23:18:54 PDT 2019
Hi Kaarthik,
On Sat, 3 Aug 2019 at 22:57, Kaarthik Alagapan via llvm-dev
<llvm-dev at lists.llvm.org> wrote:
> Can I get some guidance on what function I should use to insert a .byte/.word in SelectionDAG so it’s printed out in assembly?
This kind of problem is often solved by selecting the original IR
instruction to a target-specific pseudo-instruction (one with
"isCodeGenOnly = 1" in TableGen) and then expanding it to the real
instruction sequence later.
In most cases that would be a special XYZExpandPseudoInsts.cpp pass
that runs very late and looks through a function replacing any
MachineInstrs with the correct sequence. But in your case .byte and
.word aren't even instructions so you probably want to do it during
conversion to MCInsts in XYZAsmPrinter.cpp (or possibly
XYZMCInstLower.cpp, different targets handle that step slightly
differently). There you can detect your special pseudo and call
EmitIntValue or something to get your directives.
Cheers.
Tim.
More information about the llvm-dev
mailing list