[PATCH] D70916: [NFC] Introduce and use DAG.getPointerAdd()

Alexander Richardson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 2 11:57:08 PST 2019


arichardson created this revision.
arichardson added reviewers: spatel, bogner.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.

This change does not change functionality but I believe it does slightly
increase readability.

Additionally, this change is required for our out-of-tree CHERI backend
(https://github.com/CTSRD-CHERI/llvm-project). We use a separate register
type to store pointers (128-bit capabilities, which are effectively
unforgeable and monotonic fat pointers). These capabilities permit a
reduced set of operations and therefore use a separate ValueType (iFATPTR).
to represent pointers implemented as capabilities.
Therefore, we can no longer use ISD::ADD for our patterns that operate on
pointers and added a DAG.getPointerAdd() function that uses a custom
ISD::PTRADD opcode.

Committing this change will significantly reduce our merge conflicts
for each upstream merge.

I noticed that this is effectively the same as getMemBasePlusOffset().
However, that function only allows unsigned arguments.
The only other difference is that the operands are in the same order as
DAG.getNode(). Should I be using getMemBasePlusOffset() instead and add
an overload that takes an SDNode and a signed offset?

To find potential opportunities to use getPointerAdd() I looked at
all ISD::ADD uses found with the regex `getNode\(ISD::ADD,.+,.+Ptr`
in lib/CodeGen/SelectionDAG. If this patch is accepted I will convert
the files in the individual backens too.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D70916

Files:
  llvm/include/llvm/CodeGen/SelectionDAG.h
  llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
  llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
  llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
  llvm/lib/CodeGen/SelectionDAG/LegalizeTypesGeneric.cpp
  llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D70916.231749.patch
Type: text/x-patch
Size: 17396 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191202/8289c3f1/attachment.bin>


More information about the llvm-commits mailing list