[Mlir-commits] [mlir] [mlir][utils] Update generate-test-checks.py (PR #136721)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Tue Apr 22 09:00:05 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-mlir
Author: Andrzej WarzyĆski (banach-space)
<details>
<summary>Changes</summary>
Following #<!-- -->128083, all `CHECK-SAME` lines generated by
generate-test-checks.py use a strict regex:
```mlir
// CHECK-SAME: %[[A:[0-9]+|[a-zA-Z$._-][a-zA-Z0-9$._-]*]] = arith.constant 0 : index
```
However, in most cases this strict form is unnecessary and can obscure
readability. In such cases, the following would be sufficient:
```mlir
// CHECK-SAME: %[[A:.*]] = arith.constant 0 : index
```
This patch adds a command-line flag to make the strict mode optional. To
enable strict regex matching, use:
```bash
generate-test-checks.py --strict_name_re=true file.mlir
```
---
Full diff: https://github.com/llvm/llvm-project/pull/136721.diff
1 Files Affected:
- (modified) mlir/utils/generate-test-checks.py (+7-1)
``````````diff
diff --git a/mlir/utils/generate-test-checks.py b/mlir/utils/generate-test-checks.py
index 394ef7e0f7da0..5e13e61865df3 100755
--- a/mlir/utils/generate-test-checks.py
+++ b/mlir/utils/generate-test-checks.py
@@ -295,6 +295,12 @@ def main():
help="Names to be used in FileCheck regular expression to represent "
"attributes in the order they are defined. Separate names with commas,"
"commas, and leave empty entries for default names (e.g.: 'MAP0,,,MAP1')")
+ parser.add_argument(
+ "--strict_name_re",
+ type=bool,
+ default=False,
+ help="Set to true to use stricter regex for CHECK-SAME directives. "
+ "Use when Greedy matching causes issues with the generic '.*'")
args = parser.parse_args()
@@ -406,7 +412,7 @@ def main():
# Process the rest of the line.
output_line += process_line(
- [argument], variable_namer, strict_name_re=True
+ [argument], variable_namer, args.strict_name_re
)
# Append the output line.
``````````
</details>
https://github.com/llvm/llvm-project/pull/136721
More information about the Mlir-commits
mailing list