[llvm-dev] about AsmMatcherEmitter rules for setting matchables precedence

via llvm-dev llvm-dev at lists.llvm.org
Mon Jan 8 12:19:41 PST 2018


In AsmMatcherEmitter.cpp, the operator “<” for comparing matchables
(MatchableInfo objects) only checks matches that require more features
as the last rule.

I would like to propose that we check for that rule earlier, in the case 
unrelated UserClasses, before we decide to set precedence based on 
UserClass name.

The motivation is that unrelated UserClasses seem to be Immediate 
Operand classes,
at least in the test cases I am looking at. We usually do not define 
Operands as subclasses of others.

When we set precedence by UserClass name we neglect the higher 
constraint imposed
by the number of required features.
And the required features are likely to affect immediate ranges.

Something like the change below: (alternatively, we can move this change 
the operator ‘<” for comparing ClassInfo).

diff --git a/utils/TableGen/AsmMatcherEmitter.cpp 
index 1a820a5..3be813e 100644
--- a/utils/TableGen/AsmMatcherEmitter.cpp
+++ b/utils/TableGen/AsmMatcherEmitter.cpp
@@ -594,6 +594,12 @@ struct MatchableInfo {
      // Compare lexicographically by operand. The matcher validates that 
      // orderings wouldn't be ambiguous using \see 
      for (unsigned i = 0, e = AsmOperands.size(); i != e; ++i) {
+      if (AsmOperands[i].Class->isUserClass() &&
+          RHS.AsmOperands[i].Class->isUserClass() &&
+        if (RequiredFeatures.size() != RHS.RequiredFeatures.size())
+          return RequiredFeatures.size() > RHS.RequiredFeatures.size();
        if (*AsmOperands[i].Class < *RHS.AsmOperands[i].Class)
          return true;
        if (*RHS.AsmOperands[i].Class < *AsmOperands[i].Class)

Do you see any problem with this change?

Is there a way to make these rules target dependent so we can
have more control on the auto-generated instruction matchables 

Thank you,

Ana Pazos
Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project.

More information about the llvm-dev mailing list