Skip to content

Commit

Permalink
8295979: [IR Framework] Improve IR matching warning
Browse files Browse the repository at this point in the history
Reviewed-by: thartmann, kvn
  • Loading branch information
eme64 committed Feb 20, 2023
1 parent 743a85d commit 5c0f50b
Showing 1 changed file with 13 additions and 12 deletions.
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -74,7 +74,7 @@ public void emitRuleEncoding(Method m, boolean skipped) {
for (IR irAnno : irAnnos) {
ruleIndex = i + 1;
try {
if (shouldApplyIrRule(irAnno, m.getName())) {
if (shouldApplyIrRule(irAnno, m.getName(), ruleIndex, irAnnos.length)) {
validRules.add(ruleIndex);
}
} catch (TestFormatException e) {
Expand All @@ -96,35 +96,36 @@ public void emitRuleEncoding(Method m, boolean skipped) {
}
}

private void printDisableReason(String method, String reason) {
TestFrameworkSocket.write("Disabling IR matching for " + method + ": " + reason + ".",
private void printDisableReason(String method, String reason, String[] apply, int ruleIndex, int ruleMax) {
TestFrameworkSocket.write("Disabling IR matching for rule " + ruleIndex + " of " + ruleMax + " in " +
method + ": " + reason + ": " + String.join(", ", apply),
"[IREncodingPrinter]", true);
}

private boolean shouldApplyIrRule(IR irAnno, String m) {
private boolean shouldApplyIrRule(IR irAnno, String m, int ruleIndex, int ruleMax) {
checkIRAnnotations(irAnno);
if (isIRNodeUnsupported(irAnno)) {
return false;
} else if (irAnno.applyIf().length != 0 && !hasAllRequiredFlags(irAnno.applyIf(), "applyIf")) {
printDisableReason(m, "Flag constraint not met");
printDisableReason(m, "Flag constraint not met (applyIf)", irAnno.applyIf(), ruleIndex, ruleMax);
return false;
} else if (irAnno.applyIfNot().length != 0 && !hasNoRequiredFlags(irAnno.applyIfNot(), "applyIfNot")) {
printDisableReason(m, "Flag constraint not met");
printDisableReason(m, "Flag constraint not met (applyIfNot)", irAnno.applyIfNot(), ruleIndex, ruleMax);
return false;
} else if (irAnno.applyIfAnd().length != 0 && !hasAllRequiredFlags(irAnno.applyIfAnd(), "applyIfAnd")) {
printDisableReason(m, "All flag constraints not met");
printDisableReason(m, "Not all flag constraints are met (applyIfAnd)", irAnno.applyIfAnd(), ruleIndex, ruleMax);
return false;
} else if (irAnno.applyIfOr().length != 0 && hasNoRequiredFlags(irAnno.applyIfOr(), "applyIfOr")) {
printDisableReason(m, "None of the flag constraints met");
printDisableReason(m, "None of the flag constraints met (applyIfOr)", irAnno.applyIfOr(), ruleIndex, ruleMax);
return false;
} else if (irAnno.applyIfCPUFeature().length != 0 && !hasAllRequiredCPUFeature(irAnno.applyIfCPUFeature())) {
printDisableReason(m, "Feature constraint not met");
printDisableReason(m, "Feature constraint not met (applyIfCPUFeature)", irAnno.applyIfCPUFeature(), ruleIndex, ruleMax);
return false;
} else if (irAnno.applyIfCPUFeatureAnd().length != 0 && !hasAllRequiredCPUFeature(irAnno.applyIfCPUFeatureAnd())) {
printDisableReason(m, "All feature constraints not met");
printDisableReason(m, "Not all feature constraints are met (applyIfCPUFeatureAnd)", irAnno.applyIfCPUFeatureAnd(), ruleIndex, ruleMax);
return false;
} else if (irAnno.applyIfCPUFeatureOr().length != 0 && !hasAnyRequiredCPUFeature(irAnno.applyIfCPUFeatureOr())) {
printDisableReason(m, "None of the feature constraints met");
printDisableReason(m, "None of the feature constraints met (applyIfCPUFeatureOr)", irAnno.applyIfCPUFeatureOr(), ruleIndex, ruleMax);
return false;
} else {
// All preconditions satisfied: apply rule.
Expand Down

1 comment on commit 5c0f50b

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.