[PATCH] D75014: [InstrEmitter, SystemZ] Copy Access registers with the correct register class.

Jonas Paulsson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Feb 22 15:45:58 PST 2020


jonpa created this revision.
jonpa added reviewers: uweigand, hliao, kparzysz.
Herald added a subscriber: hiraditya.
Herald added a project: LLVM.

On SystemZ there are a set of "access registers" that can be copied in and out of 32-bit GPRs with special instructions. These instructions can only perform the copy using low 32-bit parts of the 64-bit GPRs. As reported and discussed at https://bugs.llvm.org/show_bug.cgi?id=44254, this is currently broken due to the fact that the default register class for 32-bit integers is GRX32, which also contains the high 32-bit part registers.

I have tried to find a simple way to constrain the register class of such copies (also at -O0), but this turned out to not be quite simple. Just selecting a pseudo instruction with a custom inserter does not seem to work since CopyToReg/CopyFromReg have special handlings in InstrEmitter.

I then tried in SystemZDAGToDAG.cpp to select a CopyToReg to (CopyToReg COPY_TO_REGCLASS), which worked fine. But I could not get the same results with CopyFromReg. (COPY_TO_REGCLASS CopyFromReg) only resulted in a later COPY into GR32, but the COPY from the Access register was still first made to GRX32.

One alternative might be to let InstrEmitter deduce the needed register class for a CopyFromReg if there is only one user which is a COPY_TO_REGCLASS. I thought this seemed a bit messy, so I instead tried adding a new TargetRegisterInfo hook that is used in InstrEmitter when emitting CopyToReg/CopyFromReg nodes.

Does this make sense, or is there a better way?


https://reviews.llvm.org/D75014

Files:
  llvm/include/llvm/CodeGen/TargetRegisterInfo.h
  llvm/lib/CodeGen/SelectionDAG/InstrEmitter.cpp
  llvm/lib/Target/SystemZ/SystemZRegisterInfo.cpp
  llvm/lib/Target/SystemZ/SystemZRegisterInfo.h
  llvm/test/CodeGen/SystemZ/tls-08.ll
  llvm/test/CodeGen/SystemZ/tls-09.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D75014.246089.patch
Type: text/x-patch
Size: 5281 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200222/d66643cb/attachment.bin>


More information about the llvm-commits mailing list