[PATCH] D22403: FileCheck Enhancement - pattern templates.

Elena Lepilkina via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 20 23:25:52 PDT 2016


eklepilkina added a comment.

In https://reviews.llvm.org/D22403#489895, @aprantl wrote:

> Is there a benefit in (or need for) distinguishing between variable uses and pattern uses, or could we piggyback the existing syntax?


There is difference between patterns and variables so we should understand where variable is, where pattern is.

> As for pattern variables, I really think this review would benefit if we could split out pattern variables into a separate review. I didn't yet understand how pattern variables are supposed to work: Is \:(variable)\=(value) supposed to be an argument to a pattern use that immediately precedes it? Or is it modifying global state similar to regular variable definition in FileCheck? If the latter is the case, why does it come after the pattern in the example? In the former case, wouldn't it be better to have syntax that looks more like passing in an argument?


I a bit misuderstand how can I split out pattern variables into a separate review, because this review need all these changes. We can't use pattern variable without patterns, so separate review will duplicate part of changes of pattern review.
Pattren variables supposed to help create one pattern when you have a lot of similar checks.
For example

CHECK-DEFINE-PATTERN reg: {{\:(RegName)0x[0-9a-fA-F]+}}

This is pattern for defining register, and name is parameter. Template is saved in such way.
Then you can use it.
// CHECK: {{\#(reg)\:(RegName)\=(REG)}}
When you write such check, FileCheck will replace it with template where variable name is changed to it's value. Variable name is some kind of named spaceholder.
The previous check-line will be equivalent to
// CHECK: {{REG0x[0-9a-fA-F]+}}
We should have difference between pattern variable and global variables because we can use global variable in pattern or as value of pattern variable.


https://reviews.llvm.org/D22403





More information about the llvm-commits mailing list