[PATCH] D72034: [GlobalISel][RFC] Importing patterns with PtrValueType and nullptr

Petar Avramovic via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 31 04:04:24 PST 2019


Petar.Avramovic created this revision.
Petar.Avramovic added reviewers: atanasyan, petarj, dsanders, qcolombet, tstellar, arsenm, rtereshin.
Herald added subscribers: llvm-commits, jrtc27, hiraditya, arichardson, rovka, mgorny, wdng, sdardis.
Herald added a project: LLVM.

This is WIP on iseling icmp, select and branch patterns that involve pointers.

Pointers in GlobalISel have pointer type, unlike SDAG where they have integer type.
Thus GlobalISel selectImpl cannot select pointer instructions from SDAG td files since there are no patterns for pointers there.

It is already possible to write td file for GlobalIsel that will allow selection of pointer patterns.
For that reason I am adding a new td file with additional patterns for pointers, everything from SDAG td files is also included.

Introducing new ValueType, NullPtrValue. It allows to specify nullpointer integer value in td file that will be matched with:

  %0:gprb(scalar) = G_CONSTANT intvalue
  %1:gprb(p_addrspace) = G_INTTOPTR %0(scalar)

since that is how globalisel translates llvm-ir `null`. For MIPS intvalue is 0.

Added a few pointer patterns example tests for MIPS in new td file.

Similar thing could be possible for x86, this pattern for example:

  def : Pat<(X86cmp GR32:$src1, 0),
            (TEST32rr GR32:$src1, GR32:$src1)>;

also works for pointers in SDAG, but for globalisel it would require custom legalize that generates GINodeEquiv of X86cmp and new pattern with PtrValueType and NullPtrValue instead of 0.

TODO: If NullPtrValue idea works, split to smaller patches and add detailed tests for source patterns with two or more instructions.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D72034

Files:
  llvm/include/llvm/CodeGen/ValueTypes.td
  llvm/lib/Target/Mips/CMakeLists.txt
  llvm/lib/Target/Mips/MipsGISel.td
  llvm/lib/Target/Mips/MipsInstructionSelector.cpp
  llvm/test/CodeGen/Mips/GlobalISel/instruction-select/icmp.mir
  llvm/test/CodeGen/Mips/GlobalISel/instruction-select/icmp_nullptr.mir
  llvm/test/CodeGen/Mips/GlobalISel/instruction-select/select_patterns.mir
  llvm/test/CodeGen/Mips/GlobalISel/irtranslator/icmp_nullptr.ll
  llvm/test/CodeGen/Mips/GlobalISel/llvm-ir/icmp.ll
  llvm/test/CodeGen/Mips/GlobalISel/llvm-ir/icmp_nullptr.ll
  llvm/test/TableGen/Common/GlobalISelEmitterCommon.td
  llvm/test/TableGen/GlobalISelEmitter.td
  llvm/utils/TableGen/CodeGenDAGPatterns.cpp
  llvm/utils/TableGen/GlobalISelEmitter.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D72034.235702.patch
Type: text/x-patch
Size: 26712 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191231/c00b1b57/attachment.bin>


More information about the llvm-commits mailing list