<div dir="ltr"><div>Could you emit a target specific ISD opcode where the CopyToReg is created? Then you could isel that ISD opcode however you want.</div><br clear="all"><div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature">~Craig</div></div><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Feb 22, 2020 at 3:45 PM Jonas Paulsson via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</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>
On SystemZ there are a set of "access registers" that can be copied in <br>
and out of 32-bit GPRs with special instructions. These instructions can <br>
only perform the copy using low 32-bit parts of the 64-bit GPRs. As <br>
reported and discussed at <a href="https://bugs.llvm.org/show_bug.cgi?id=44254" rel="noreferrer" target="_blank">https://bugs.llvm.org/show_bug.cgi?id=44254</a>, <br>
this is currently broken due to the fact that the default register class <br>
for 32-bit integers is GRX32, which also contains the high 32-bit part <br>
registers.<br>
<br>
I have tried to find a simple way to constrain the register class of <br>
such copies (also at -O0), but this turned out to not be quite simple. <br>
Just selecting a pseudo instruction with a custom inserter does not seem <br>
to work since CopyToReg/CopyFromReg have special handlings in InstrEmitter.<br>
<br>
I then tried in SystemZDAGToDAG.cpp to select a CopyToReg to (CopyToReg <br>
COPY_TO_REGCLASS), which worked fine. But I could not get the same <br>
results with CopyFromReg. (COPY_TO_REGCLASS CopyFromReg) only resulted <br>
in a later COPY into GR32, but the COPY from the Access register was <br>
still first made to GRX32.<br>
<br>
One alternative might be to let InstrEmitter deduce the needed register <br>
class for a CopyFromReg if there is only one user which is a <br>
COPY_TO_REGCLASS. I thought this seemed a bit messy, so I instead tried <br>
adding a new TargetRegisterInfo hook that is used in InstrEmitter when <br>
emitting CopyToReg/CopyFromReg nodes (<a href="https://reviews.llvm.org/D75014" rel="noreferrer" target="_blank">https://reviews.llvm.org/D75014</a>).<br>
<br>
Does this make sense, or is there a better way?<br>
<br>
A related question is if the target is required to be able to implement <br>
*any* move between register classes?<br>
<br>
Thanks,<br>
<br>
Jonas<br>
<br>
<br>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div>