@@ -375,6 +375,10 @@ class AsmVariantInfo {
375
375
int AsmVariantNo;
376
376
};
377
377
378
+ bool getPreferSmallerInstructions (CodeGenTarget const &Target) {
379
+ return Target.getAsmParser ()->getValueAsBit (" PreferSmallerInstructions" );
380
+ }
381
+
378
382
// / MatchableInfo - Helper class for storing the necessary information for an
379
383
// / instruction or alias which is capable of being matched.
380
384
struct MatchableInfo {
@@ -620,9 +624,9 @@ struct MatchableInfo {
620
624
if (int Cmp = Mnemonic.compare_insensitive (RHS.Mnemonic ))
621
625
return Cmp == -1 ;
622
626
623
- // Sort by the resultant instuctions size, eg. for ARM instructions
624
- // we must choose the smallest matching instruction .
625
- if (Target. getPreferSmallerInstructions () && ResInstSize != RHS.ResInstSize )
627
+ // (Optionally) Order by the resultant instuctions size.
628
+ // eg. for ARM thumb instructions smaller encodings should be preferred .
629
+ if (getPreferSmallerInstructions (Target ) && ResInstSize != RHS.ResInstSize )
626
630
return ResInstSize < RHS.ResInstSize ;
627
631
628
632
if (AsmOperands.size () != RHS.AsmOperands .size ())
@@ -673,8 +677,7 @@ struct MatchableInfo {
673
677
if (AsmVariantID != RHS.AsmVariantID )
674
678
return false ;
675
679
676
- // Sort by the resultant instuctions size, eg. for ARM instructions
677
- // we must choose the smallest matching instruction.
680
+ // The size of instruction is unambiguous.
678
681
if (Target.getPreferSmallerInstructions () && ResInstSize != RHS.ResInstSize )
679
682
return false ;
680
683
@@ -3252,7 +3255,7 @@ void AsmMatcherEmitter::run(raw_ostream &OS) {
3252
3255
for (auto I = Info.Matchables .begin (), E = Info.Matchables .end (); I != E;
3253
3256
++I) {
3254
3257
for (auto J = I; J != E; ++J) {
3255
- assert (!(( *J)->shouldBeMatchedBefore (**I, Target) ));
3258
+ assert (!(*J)->shouldBeMatchedBefore (**I, Target));
3256
3259
}
3257
3260
}
3258
3261
#endif
0 commit comments