[PATCH] D22403: FileCheck Enhancement - pattern templates.

Adrian Prantl via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 21 09:22:40 PDT 2016


aprantl added a comment.

In https://reviews.llvm.org/D22403#490814, @eklepilkina wrote:

> 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.


They are also both placeholders for a pattern. Can you give an example where it is useful to tell the difference between a use of a pattern and a use of a plain old variable? Does it make the test more readable?
I'm not saying that we have to share the syntax, but adding more syntax increases the cognitive load on testcase authors and we should make sure we are doing it for the right reasons.

> > As for pattern variables, I really think this review would benefit if we could split out pattern variables into a separate review.

> 

> 

> I a bit misuderstand how can I split out pattern variables into a separate review, because this review need all these changes.


If you feel like splitting out the pattern variables into a separate review ins't feasible that's fine with me.

Could you please answer the following questions specifically?

> > 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?

> 




> 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.


In the documentation the example showed a pattern use on its own, here it appears inside of a regexp. To make sure I understand the proposal correctly :-) it might help if you could add your new syntax to the grammar I posted earlier.

thanks!
adrian


https://reviews.llvm.org/D22403





More information about the llvm-commits mailing list