Hello LLVM-Dev,
I understand that Uses and Defs are for implicit registers. Uses is defined as for using non-operand registers and Defs is defined as for modifying non-operand registers.
For example, for compare and compare with carry instructions, is my understanding correct that the instructions should be defined as described below?
Considering that the carry flag is part of the status register:
Compare – The status register is only listed in the Defs register list since it modifies the status register.
Compare with carry – The status register is listed in both Defs and Uses register lists since it refers the status register (Carry flag information) and modifies it.
With this understanding, am I correct to assume that all “with carry” instructions lists the status register in the Uses? The status register being listed in the Defs depends on whether the instruction modifies the status register or not.
Thank you in advance for your responses, they are highly appreciated.
Sincerely,
Miguel Inigo J. Manalac (1852)
I need to implement the following behavior for all instructions that
require two source operands:
%1 = add i16 %a, %b
Should match the ADD instruction which has 1 outs and 1 ins. The second
operand %b should be moved into the implicit register R14 (fixed).
For now I implemented the PseudoADD instruction which gets expanded into
a move plus the mentioned ADD instruction.
This obviously creates a low of unnecessary moves and prevents any
optimizations of the register R14 (e.g. R14 could be used as destination
register in previous operations without the need for a move).
I'd like to transform the dag:
(set GPR:$rd, (add GPR:$rs1, GPR:$rs2))
to something like:
(set R14, GPR:$rs2), (set GPR:$rd, (add GPR:$rs1))
Is it possible to specify this transformation using TableGen? If now how
could I achieve this?
Thanks.
Best Regards,
Marco Speziali
Dear Craig,Thanks for the reply. I tried to use the pattern you provided to set list<pattern> inside the ADD instruction. Unfortunately the pattern:
(set GPR:$rd, (add GPR:$rs1, R14))
Does not generate a move of $rs2 to R14. It, for some reason, produces an add with 3 register operands. Which we do not support. The only way to use 2 source registers is to move the second one to R14. For example:
add rd, rs1, rs2
Should become:
mv R14, rs2add rd, rs1
Is there a way to automate this process using TableGen?
Thanks,Marco Speziali
(set GPR:$rd, (add GPR:$rs1, R14))
On 10 Apr 2021, at 19:09, Craig Topper <craig....@gmail.com> wrote: