[llvm-dev] Can I use AArch64 Opcodes inside MachineCSE Pass

Tim Northover via llvm-dev llvm-dev at lists.llvm.org
Wed Apr 10 04:34:06 PDT 2019


On Wed, 10 Apr 2019 at 11:45, Ramakota Reddy via llvm-dev
<llvm-dev at lists.llvm.org> wrote:
> How can I use/check AArch64 Opcodes in MachineCSE pass(like: Inst->Opcode() == AArch64::ADDWrr) ?. through any object can I use AArch64 Opcodes ?

You can't use target specific opcodes directly. Instead you'd add a
virtual function (maybe to TargetInstrInfo) that queries what you
really want to know about this instruction (from what you've been
saying before, whether it's an add that can be converted into a sub,
and maybe something about the operands). You'll need a similar hook to
help you with any transformation you decide to make (perhaps to get a
corresponding subtract opcode, or perhaps to just do the
transformation entirely).

MachineCSE is a bit simplistic to provide good examples of this right
now, so it might be better to look at MachineBlockPlacement and its
use of analyzeBranch (& insert/removeBranch) to see how far this kind
of thing can go. There the target is requested to perform a detailed
analysis of how a basic block ends, and return enough information to
reconstitute the control flow at a later date if necessary.

Cheers.

Tim.


More information about the llvm-dev mailing list