1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2025-01-31 12:41:49 +01:00

[globalisel][tablegen] Multi-insn emission requires that BuildMIAction 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.

llvm-svn: 316463
This commit is contained in:
Daniel Sanders 2017-10-24 17:08:43 +00:00
parent cf7778b801
commit 9174afd27b

View File

@ -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
@ -1776,7 +1776,7 @@ private:
public:
BuildMIAction(unsigned InsnID, const CodeGenInstruction *I,
const InstructionMatcher &Matched)
const InstructionMatcher *Matched)
: InsnID(InsnID), I(I), Matched(Matched) {}
template <class Kind, class... Args>
@ -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) {
@ -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);