@@ -568,11 +568,11 @@ void PatternEmitter::emitOpMatch(DagNode tree, StringRef opName, int depth) {
568
568
return formatv (" castedOp{0}" , depth);
569
569
};
570
570
571
- // The order of generating static matcher follows the topological order so
572
- // that for every dependent DagNode already have their static matcher
573
- // generated if needed. The reason we check if `getMatcherName(tree).empty()`
574
- // is when we are generating the static matcher for a DagNode itself. In this
575
- // case, we need to emit the function body rather than a function call.
571
+ // Static matchers are generated in topological order so that all dependent
572
+ // DagNodes have their static matcher generated beforehand if needed. We check
573
+ // if `getMatcherName(tree).empty()` for when we are generating the static
574
+ // matcher for a DagNode itself. In this case, we need to emit the function
575
+ // body rather than a function call.
576
576
if (staticMatcherHelper.useStaticMatcher (tree) &&
577
577
!staticMatcherHelper.getMatcherName (tree).empty ()) {
578
578
emitStaticMatchCall (tree, opName);
@@ -658,7 +658,7 @@ void PatternEmitter::emitOpMatch(DagNode tree, StringRef opName, int depth) {
658
658
if (isa<NamedTypeConstraint *>(opArg)) {
659
659
auto operandName =
660
660
formatv (" {0}.getODSOperands({1})" , castedName, nextOperand);
661
- emitOperandMatch (tree, castedName, operandName.str (), opArgIdx ,
661
+ emitOperandMatch (tree, castedName, operandName.str (), nextOperand ,
662
662
/* operandMatcher=*/ tree.getArgAsLeaf (i),
663
663
/* argName=*/ tree.getArgName (i), opArgIdx,
664
664
/* variadicSubIndex=*/ std::nullopt);
@@ -680,7 +680,7 @@ void PatternEmitter::emitOperandMatch(DagNode tree, StringRef opName,
680
680
int argIndex,
681
681
std::optional<int > variadicSubIndex) {
682
682
Operator &op = tree.getDialectOp (opMap);
683
- auto * operand = cast<NamedTypeConstraint *>( op.getArg (operandIndex) );
683
+ NamedTypeConstraint operand = op.getOperand (operandIndex);
684
684
685
685
// If a constraint is specified, we need to generate C++ statements to
686
686
// check the constraint.
@@ -693,8 +693,8 @@ void PatternEmitter::emitOperandMatch(DagNode tree, StringRef opName,
693
693
// Only need to verify if the matcher's type is different from the one
694
694
// of op definition.
695
695
Constraint constraint = operandMatcher.getAsConstraint ();
696
- if (operand-> constraint != constraint) {
697
- if (operand-> isVariableLength ()) {
696
+ if (operand. constraint != constraint) {
697
+ if (operand. isVariableLength ()) {
698
698
auto error = formatv (
699
699
" further constrain op {0}'s variadic operand #{1} unsupported now" ,
700
700
op.getOperationName (), argIndex);
@@ -706,7 +706,7 @@ void PatternEmitter::emitOperandMatch(DagNode tree, StringRef opName,
706
706
verifier, opName, self.str (),
707
707
formatv (
708
708
" \" operand {0} of op '{1}' failed to satisfy constraint: '{2}'\" " ,
709
- operand - op. operand_begin () , op.getOperationName (),
709
+ operandIndex , op.getOperationName (),
710
710
escapeString (constraint.getSummary ()))
711
711
.str ());
712
712
}
@@ -715,7 +715,7 @@ void PatternEmitter::emitOperandMatch(DagNode tree, StringRef opName,
715
715
// Capture the value
716
716
// `$_` is a special symbol to ignore op argument matching.
717
717
if (!argName.empty () && argName != " _" ) {
718
- auto res = symbolInfoMap.findBoundSymbol (argName, tree, op, operandIndex ,
718
+ auto res = symbolInfoMap.findBoundSymbol (argName, tree, op, argIndex ,
719
719
variadicSubIndex);
720
720
if (res == symbolInfoMap.end ())
721
721
PrintFatalError (loc, formatv (" symbol not found: {0}" , argName));
@@ -821,7 +821,7 @@ void PatternEmitter::emitVariadicOperandMatch(DagNode tree,
821
821
StringRef variadicTreeName = variadicArgTree.getSymbol ();
822
822
if (!variadicTreeName.empty ()) {
823
823
auto res =
824
- symbolInfoMap.findBoundSymbol (variadicTreeName, tree, op, operandIndex ,
824
+ symbolInfoMap.findBoundSymbol (variadicTreeName, tree, op, argIndex ,
825
825
/* variadicSubIndex=*/ std::nullopt);
826
826
if (res == symbolInfoMap.end ())
827
827
PrintFatalError (loc, formatv (" symbol not found: {0}" , variadicTreeName));
0 commit comments