8295979: [IR Framework] Improve IR matching warning

Reviewed-by: thartmann, kvn
This commit is contained in:
Emanuel Peter 2023-02-20 08:40:11 +00:00
parent 743a85db06
commit 5c0f50bc01

View File

@ -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
@ -74,7 +74,7 @@ public class IREncodingPrinter {
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) {
@ -96,35 +96,36 @@ public class IREncodingPrinter {
}
}
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.