OSDN Git Service

[tablegen][globalisel] Capture instructions into locals and related infrastructure...
authorDaniel Sanders <daniel_l_sanders@apple.com>
Mon, 20 Mar 2017 15:20:42 +0000 (15:20 +0000)
committerDaniel Sanders <daniel_l_sanders@apple.com>
Mon, 20 Mar 2017 15:20:42 +0000 (15:20 +0000)
commit1111ea1a18939df766e18439e84ac2c6155318a1
tree43a6fa964dcb2409a3ca69919082b2f249ee4846
parent194f24401fe31d741f582e527fd26ad70d899075
[tablegen][globalisel] Capture instructions into locals and related infrastructure for multiple instructions matches.

Summary:
Prepare the way for nested instruction matching support by having actions
like CopyRenderer look up operands in the RuleMatcher rather than a
specific InstructionMatcher. This allows actions to reference any operand
from any matched instruction.

It works by checking the 'shape' of the match and capturing
each matched instruction to a local variable. If the shape is wrong
(not enough operands, leaf nodes where non-leafs are expected, etc.), then
the rule exits early without checking the predicates. Once we've captured
the instructions, we then test the predicates as before (except using the
local variables). If the match is successful, then we render the new
instruction as before using the local variables.

It's not noticable in this patch but by the time we support multiple
instruction matching, this patch will also cause a significant improvement
to readability of the emitted code since
MRI.getVRegDef(I->getOperand(0).getReg()) will simply be MI1 after
emitCxxCaptureStmts().

This isn't quite NFC because I've also fixed a bug that I'm surprised we
haven't encountered yet. It now checks there are at least the expected
number of operands before accessing them with getOperand().

Depends on D30531

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

Reviewed By: rovka

Subscribers: dberris, kristof.beyls, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@298257 91177308-0d34-0410-b5e6-96231b3b80d8
test/TableGen/GlobalISelEmitter.td
utils/TableGen/GlobalISelEmitter.cpp