Skip to content

Commit a873ae7

Browse files
GleasonKvar-const
authored andcommitted
[mlir] Add support for broader range of input files in generate-test-checks.py (llvm#134327)
A few additions: - Lines with `{{`: These can show up if serializing non-MLIR info into string attrs `my.attr = {{proto}, {...}}`. String escape the opening `{{`, given that check lines are generated this has no effect on `{{.*}}` etc in generated lines. - File split line: Normally these are skipped because of their indent level, but if using `--starts_from_scope=0` to generate checks for the `module {...} {` line, and since MLIR opt tools emit file split lines by default, some `CHECK: // -----` lines were emit. - (edit removed this, fixed by llvm#134364) AttrAliases: I'm not sure if I'm missing something for the attribute parser to work correctly, but I was getting many `#[[?]]` for all dialect attrs. Only use the attr aliasing if there's a match.
1 parent 3a018f2 commit a873ae7

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

mlir/utils/generate-test-checks.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,9 +236,13 @@ def process_attribute_references(line, attribute_namer):
236236
# Pre-process a line of input to remove any character sequences that will be
237237
# problematic with FileCheck.
238238
def preprocess_line(line):
239+
# Replace any `{{` with escaped replacements. `{{` corresponds to regex
240+
# checks in FileCheck.
241+
output_line = line.replace("{{", "{{\\{\\{}}")
242+
239243
# Replace any double brackets, '[[' with escaped replacements. '[['
240244
# corresponds to variable names in FileCheck.
241-
output_line = line.replace("[[", "{{\\[\\[}}")
245+
output_line = output_line.replace("[[", "{{\\[\\[}}")
242246

243247
# Replace any single brackets that are followed by an SSA identifier, the
244248
# identifier will be replace by a variable; Creating the same situation as
@@ -327,6 +331,11 @@ def main():
327331
if not input_line:
328332
continue
329333

334+
# When using `--starts_from_scope=0` to capture module lines, the file
335+
# split needs to be skipped, otherwise a `CHECK: // -----` is inserted.
336+
if input_line.startswith("// -----"):
337+
continue
338+
330339
# Check if this is an attribute definition and process it
331340
process_attribute_definition(input_line, attribute_namer, output)
332341

0 commit comments

Comments
 (0)