Skip to content

Commit

Permalink
[globalisel][tablegen] Multi-insn emission requires that BuildMIActio…
Browse files Browse the repository at this point in the history
…n support not being linked to an InstructionMatcher. NFC

When multi-instruction emission is supported, it will no longer be guaranteed
that every BuildMIAction has a corresponding matched instruction. BuildMIAction
should support not having one to cover the case where a rule produces more
instructions than it matched.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@316463 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
dsandersllvm committed Oct 24, 2017
1 parent 03644f2 commit 8e1e4b9
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions utils/TableGen/GlobalISelEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1753,18 +1753,18 @@ class BuildMIAction : public MatchAction {
private:
unsigned InsnID;
const CodeGenInstruction *I;
const InstructionMatcher &Matched;
const InstructionMatcher *Matched;
std::vector<std::unique_ptr<OperandRenderer>> OperandRenderers;

/// True if the instruction can be built solely by mutating the opcode.
bool canMutate(RuleMatcher &Rule) const {
if (OperandRenderers.size() != Matched.getNumOperands())
if (OperandRenderers.size() != Matched->getNumOperands())
return false;

for (const auto &Renderer : enumerate(OperandRenderers)) {
if (const auto *Copy = dyn_cast<CopyRenderer>(&*Renderer.value())) {
const OperandMatcher &OM = Rule.getOperandMatcher(Copy->getSymbolicName());
if (&Matched != &OM.getInstructionMatcher() ||
if ((Matched != nullptr && Matched != &OM.getInstructionMatcher()) ||
OM.getOperandIndex() != Renderer.index())
return false;
} else
Expand All @@ -1776,7 +1776,7 @@ class BuildMIAction : public MatchAction {

public:
BuildMIAction(unsigned InsnID, const CodeGenInstruction *I,
const InstructionMatcher &Matched)
const InstructionMatcher *Matched)
: InsnID(InsnID), I(I), Matched(Matched) {}

template <class Kind, class... Args>
Expand Down Expand Up @@ -2651,7 +2651,7 @@ Expected<BuildMIAction &> GlobalISelEmitter::createAndImportInstructionRenderer(
IsExtractSubReg = true;
}

auto &DstMIBuilder = M.addAction<BuildMIAction>(0, DstI, InsnMatcher);
auto &DstMIBuilder = M.addAction<BuildMIAction>(0, DstI, &InsnMatcher);

// Render the explicit defs.
for (unsigned I = 0; I < DstI->Operands.NumDefs; ++I) {
Expand Down Expand Up @@ -2802,7 +2802,7 @@ Expected<RuleMatcher> GlobalISelEmitter::runOnPattern(const PatternToMatch &P) {
M.defineOperand(OM0.getSymbolicName(), OM0);
OM0.addPredicate<RegisterBankOperandMatcher>(RC);

auto &DstMIBuilder = M.addAction<BuildMIAction>(0, &DstI, InsnMatcher);
auto &DstMIBuilder = M.addAction<BuildMIAction>(0, &DstI, &InsnMatcher);
DstMIBuilder.addRenderer<CopyRenderer>(0, DstIOperand.Name);
DstMIBuilder.addRenderer<CopyRenderer>(0, Dst->getName());
M.addAction<ConstrainOperandToRegClassAction>(0, 0, RC);
Expand Down

0 comments on commit 8e1e4b9

Please sign in to comment.