<div dir="ltr">Thanks a lot! <br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Oct 13, 2019 at 2:06 AM Tim Northover <<a href="mailto:t.p.northover@gmail.com">t.p.northover@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi,<br>
<br>
<br>
On Sat, 12 Oct 2019 at 10:47, 黄岚之观 via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<br>
> I have a problem during my development of a backend. There are some target instructions with multiple outputs, for example an instructionX with 2 inputs and 2 outputs:<br>
> def1, def2 = InstructionX op1, op2<br>
> The defs above must be allocated in consecutive target physical registers.<br>
> Is it possible to describe the constraints with tablegen and let the register allocator get all the things done or is regalloc hints related api designed just to solve the problem? Any suggestions?<br>
<br>
This is common enough that I think it's handled reasonably<br>
automatically in LLVM. You need to create a new register-class based<br>
on a RegisterTuple in TableGen. The example I'm most familiar with<br>
that's reasonably clean is AArch64's XSeqPairs (and others). They have<br>
the extra constraint that the first register has to be even-numbered<br>
so watch out for that if copy/pasting but otherwise are pretty<br>
straightforward.<br>
<br>
LLVM then handles the register allocation and so on if any instruction<br>
uses them as operands, but you might need custom C++ to for the MC<br>
stuff (encoding, decoding , asmprinting, asmparsing).<br>
<br>
Also, CodeGen is often tricky: these operations often only exist for<br>
types that would be illegal in almost all other cases (i128 on a<br>
64-bit machine) so C++ code is probably needed to make CodeGen use<br>
them. If not, then in principle things should be simpler (you can give<br>
your tuple RegisterClass some types), but I've never seen it in<br>
practice.<br>
<br>
Cheers.<br>
<br>
Tim.<br>
</blockquote></div>