[llvm-dev] Is there a way to correlate operation to machine instruction?

Ryan Taylor via llvm-dev llvm-dev at lists.llvm.org
Wed Apr 12 10:25:55 PDT 2017

For example, given a multiclass for ADD 32 bit that might produce something

ADD32_REG_REG_REG (operands are all registers for a 32 bit add)
ADD32_REG_IMM_REG (srcA is a register, srcB is an immediate and dst is a
ADD32_REG_IMM_MEM (srcA is a register, srcB is an immediate and dst is a
memory address)

What I'd like to do is replace an operand, for example, change srcA from a
REG to a MEM in ADD32_REG_REG_REG (so it would be ADD32_MEM_REG_REG).

Currently, I'm simply building a new machine instruction via BuildMI with
the appropriate operands and then removing the old machine instruction.

My problem comes in trying to correlate the operation given the old
instruction to the new instruction. How can I tell the old instruction was
an ADD32?

The problem I'm trying to solve is the DAG is CSE'd, which is generating
extra move instructions (memory into register) when the memory is used more
than once, this is unnecessary for us. Would it be possible to change the
DAG right before Instruction Selection (this would be much easier than
doing it in the backend but when I've tried in the past, CSE is performed

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170412/8b7d0235/attachment.html>

More information about the llvm-dev mailing list