Skip to content

Commit 36d47e8

Browse files
committed
[mlir][utils] Update generate-test-checks.py
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 ```
1 parent 86a0336 commit 36d47e8

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

mlir/utils/generate-test-checks.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,12 @@ def main():
295295
help="Names to be used in FileCheck regular expression to represent "
296296
"attributes in the order they are defined. Separate names with commas,"
297297
"commas, and leave empty entries for default names (e.g.: 'MAP0,,,MAP1')")
298+
parser.add_argument(
299+
"--strict_name_re",
300+
type=bool,
301+
default=False,
302+
help="Set to true to use stricter regex for CHECK-SAME directives. "
303+
"Use when Greedy matching causes issues with the generic '.*'")
298304

299305
args = parser.parse_args()
300306

@@ -406,7 +412,7 @@ def main():
406412

407413
# Process the rest of the line.
408414
output_line += process_line(
409-
[argument], variable_namer, strict_name_re=True
415+
[argument], variable_namer, args.strict_name_re
410416
)
411417

412418
# Append the output line.

0 commit comments

Comments
 (0)