]> granicus.if.org Git - llvm/commit
[globalisel][tablegen] Revise API for ComplexPattern operands to improve flexibility.
authorDaniel Sanders <daniel_l_sanders@apple.com>
Sat, 22 Apr 2017 15:11:04 +0000 (15:11 +0000)
committerDaniel Sanders <daniel_l_sanders@apple.com>
Sat, 22 Apr 2017 15:11:04 +0000 (15:11 +0000)
commitcc3830e7daac18b9a98cbb59dfdb869398b24d9f
treef52781fbcbb947b1fe8ee94bdcf0d5fd40dc98a7
parentcaed319d5118abcf410fa9b8bdd47b236938da83
[globalisel][tablegen] Revise API for ComplexPattern operands to improve flexibility.

Summary:
Some targets need to be able to do more complex rendering than just adding an
operand or two to an instruction. For example, it may need to insert an
instruction to extract a subreg first, or it may need to perform an operation
on the operand.

In SelectionDAG, targets would create SDNode's to achieve the desired effect
during the complex pattern predicate. This worked because SelectionDAG had a
form of garbage collection that would take care of SDNode's that were created
but not used due to a later predicate rejecting a match. This doesn't translate
well to GlobalISel and the churn was wasteful.

The API changes in this patch enable GlobalISel to accomplish the same thing
without the waste. The API is now:
InstructionSelector::OptionalComplexRendererFn selectArithImmed(MachineOperand &Root) const;
where Root is the root of the match. The return value can be omitted to
indicate that the predicate failed to match, or a function with the signature
ComplexRendererFn can be returned. For example:
return OptionalComplexRendererFn(
       [=](MachineInstrBuilder &MIB) { MIB.addImm(Immed).addImm(ShVal); });
adds two immediate operands to the rendered instruction. Immed and ShVal are
captured from the predicate function.

As an added bonus, this also reduces the amount of information we need to
provide to GIComplexOperandMatcher.

Depends on D31418

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

Reviewed By: ab

Subscribers: dberris, kristof.beyls, igorb, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301079 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/CodeGen/GlobalISel/InstructionSelector.h
include/llvm/CodeGen/MachineOperand.h
include/llvm/Target/GlobalISel/Target.td
lib/CodeGen/MIRPrinter.cpp
lib/CodeGen/MachineInstr.cpp
lib/Target/AArch64/AArch64InstrFormats.td
lib/Target/AArch64/AArch64InstructionSelector.cpp
lib/Target/ARM/ARMExpandPseudoInsts.cpp
test/TableGen/GlobalISelEmitter.td
utils/TableGen/GlobalISelEmitter.cpp