@@ -619,14 +619,14 @@ struct MatchableInfo {
619
619
620
620
// / shouldBeMatchedBefore - Compare two matchables for ordering.
621
621
bool shouldBeMatchedBefore (const MatchableInfo &RHS,
622
- const CodeGenTarget &Target ) const {
622
+ bool PreferSmallerInstructions ) const {
623
623
// The primary comparator is the instruction mnemonic.
624
624
if (int Cmp = Mnemonic.compare_insensitive (RHS.Mnemonic ))
625
625
return Cmp == -1 ;
626
626
627
627
// (Optionally) Order by the resultant instuctions size.
628
628
// eg. for ARM thumb instructions smaller encodings should be preferred.
629
- if (getPreferSmallerInstructions (Target) && ResInstSize != RHS.ResInstSize )
629
+ if (PreferSmallerInstructions && ResInstSize != RHS.ResInstSize )
630
630
return ResInstSize < RHS.ResInstSize ;
631
631
632
632
if (AsmOperands.size () != RHS.AsmOperands .size ())
@@ -668,7 +668,7 @@ struct MatchableInfo {
668
668
// / ambiguously match the same set of operands as \p RHS (without being a
669
669
// / strictly superior match).
670
670
bool couldMatchAmbiguouslyWith (const MatchableInfo &RHS,
671
- const CodeGenTarget &Target ) const {
671
+ bool PreferSmallerInstructions ) const {
672
672
// The primary comparator is the instruction mnemonic.
673
673
if (Mnemonic != RHS.Mnemonic )
674
674
return false ;
@@ -678,7 +678,7 @@ struct MatchableInfo {
678
678
return false ;
679
679
680
680
// The size of instruction is unambiguous.
681
- if (getPreferSmallerInstructions (Target) && ResInstSize != RHS.ResInstSize )
681
+ if (PreferSmallerInstructions && ResInstSize != RHS.ResInstSize )
682
682
return false ;
683
683
684
684
// The number of operands is unambiguous.
@@ -3241,21 +3241,23 @@ void AsmMatcherEmitter::run(raw_ostream &OS) {
3241
3241
AsmMatcherInfo Info (AsmParser, Target, Records);
3242
3242
Info.buildInfo ();
3243
3243
3244
+ bool PreferSmallerInstructions = getPreferSmallerInstructions (Target);
3244
3245
// Sort the instruction table using the partial order on classes. We use
3245
3246
// stable_sort to ensure that ambiguous instructions are still
3246
3247
// deterministically ordered.
3247
- llvm::stable_sort (Info.Matchables ,
3248
- [&Target](const std::unique_ptr<MatchableInfo> &a,
3249
- const std::unique_ptr<MatchableInfo> &b) {
3250
- return a->shouldBeMatchedBefore (*b, Target);
3251
- });
3248
+ llvm::stable_sort (
3249
+ Info.Matchables ,
3250
+ [PreferSmallerInstructions](const std::unique_ptr<MatchableInfo> &A,
3251
+ const std::unique_ptr<MatchableInfo> &B) {
3252
+ return A->shouldBeMatchedBefore (*B, PreferSmallerInstructions);
3253
+ });
3252
3254
3253
3255
#ifdef EXPENSIVE_CHECKS
3254
3256
// Verify that the table is sorted and operator < works transitively.
3255
3257
for (auto I = Info.Matchables .begin (), E = Info.Matchables .end (); I != E;
3256
3258
++I) {
3257
3259
for (auto J = I; J != E; ++J) {
3258
- assert (!(*J)->shouldBeMatchedBefore (**I, Target ));
3260
+ assert (!(*J)->shouldBeMatchedBefore (**I, PreferSmallerInstructions ));
3259
3261
}
3260
3262
}
3261
3263
#endif
@@ -3274,7 +3276,7 @@ void AsmMatcherEmitter::run(raw_ostream &OS) {
3274
3276
const MatchableInfo &A = **I;
3275
3277
const MatchableInfo &B = **J;
3276
3278
3277
- if (A.couldMatchAmbiguouslyWith (B, Target )) {
3279
+ if (A.couldMatchAmbiguouslyWith (B, PreferSmallerInstructions )) {
3278
3280
errs () << " warning: ambiguous matchables:\n " ;
3279
3281
A.dump ();
3280
3282
errs () << " \n is incomparable with:\n " ;
0 commit comments