[tablegen] Handle common load/store predicates inside tablegen. NFC.
authorDaniel Sanders <daniel_l_sanders@apple.com>
Sun, 15 Oct 2017 02:06:44 +0000 (02:06 +0000)
committerDaniel Sanders <daniel_l_sanders@apple.com>
Sun, 15 Oct 2017 02:06:44 +0000 (02:06 +0000)
commit3f267bf769f169f26dd98d05246cbe75b632f4be
tree2e07fae3f38e998db8f26597f21856913cb75bdb
parent1826842865f1a7db9417819dca1151705464b7f7
[tablegen] Handle common load/store predicates inside tablegen. NFC.

Summary:
GlobalISel and SelectionDAG require different code for the common
load/store predicates due to differences in the representation.
For example:
   SelectionDAG: (load<signext,i8>:i32 GPR32:$addr) // The <> denote properties of the SDNode that are not printed in the DAG
   GlobalISel: (G_SEXT:s32 (G_LOAD:s8 GPR32:$addr))
Even without that, differences in the IR (SDNode vs MachineInstr) require
differences in the C++ predicate.

This patch moves the implementation of the common load/store predicates
into tablegen so that it can handle these differences.

It's NFC for SelectionDAG since it emits equivalent code and it's NFC for
GlobalISel since the rules involving the relevant predicates are still
rejected by the importer.

Depends on D36618

Reviewers: ab, qcolombet, t.p.northover, rovka, aditya_nandakumar

Subscribers: llvm-commits, igorb

Differential Revision: https://reviews.llvm.org/D37443

Includes a partial revert of r315826 since this patch makes it necessary for
getPredCode() to return a std::string and getImmCode() should have the same
interface as getPredCode().

llvm-svn: 315841
llvm/include/llvm/Target/TargetSelectionDAG.td
llvm/utils/TableGen/CodeGenDAGPatterns.cpp
llvm/utils/TableGen/CodeGenDAGPatterns.h
llvm/utils/TableGen/GlobalISelEmitter.cpp