[llvm-dev] RFC: FileCheck Enhancements

Elena Lepilkina via llvm-dev llvm-dev at lists.llvm.org
Tue Sep 13 07:23:46 PDT 2016


Hi,

There is including directive CHECK-INCLUDE as one of implemented enhancement. Using it you can include file with defined patterns. There is a good idea to get some such files in open source and may be adding options is simplier then choosing file for including. But including files is more flexible, in my opinion.
Now this feature has no feedback and I'll be glad to hear some opinions about it. https://reviews.llvm.org/D22500
Pattern is only first step.

Thank you for your suggestion.

Thanks, Elena. 

-----Original Message-----
From: Chris Lattner [mailto:clattner at apple.com] 
Sent: Tuesday, September 13, 2016 9:22 AM
To: Vedant Kumar <vsk at apple.com>
Cc: Elena Lepilkina <Elena.Lepilkina at synopsys.com>; llvm-dev at lists.llvm.org
Subject: Re: [llvm-dev] RFC: FileCheck Enhancements

On Sep 12, 2016, at 6:04 PM, Vedant Kumar via llvm-dev <llvm-dev at lists.llvm.org> wrote:
> That's a good example. While '{{REGEX}}' usually creates a new 
> matching group, we could introduce some new syntax to make it possible 
> to use pattern arguments inside of regexes. E.g for an argument named 
> 'x', writing 'x' in a pattern definition preserves the current 
> behavior, and writing '#x' concatenates the value of 'x' with any 
> surrounding regexes (resulting in just one matching group).
> 
> So, to match one or more things you could write:
> 
>  CHECK-DEFINE-PATTERN: one_or_more(x): #x {{+}}
>  CHECK: [[@one_or_more("1")]]
> 
> Without the '#', you'd see a syntax error because '+' isn't a valid regex.
> 
> I like this approach because it doesn't require changing the 
> definitions of REGEX or POSIX_REGEX. It'd be interesting to hear what other people think.
> 
> We should be able to hash this out in parallel to the work on D22403, 
> since the plan is to defer work on pattern arguments until basic 
> support for pattern definitions has landed.
> 
> Revised grammar (** proposal **):
> 
>  ACTION <- CHECK ':' MATCH '\n' ;
>  ACTION <- CHECK-DEFINE-PATTERN ':' IDENT PARAMLIST? ':' 
> PATTERN_ELEMENT* '\n' ;  PARAMLIST <- '(' IDENT (',' IDENT)* ')' ;  
> PATTERN_ELEMENT <- '#'? IDENT ;  PATTERN_ELEMENT <- REGEX ;  MATCH <- 
> (TEXT | REGEX | PATTERN_USE | VAR)* ;  REGEX <- '{{' POSIX_REGEX '}}' 
> ;  PATTERN_USE <- '[[' '@' IDENT ARGLIST? ']]' ;  VAR <- '[[' IDENT 
> ':' POSIX_REGEX ']]' ;  VAR <- '[[' IDENT '@' IDENT ARGLIST? ']]' ;  
> ARGLIST <- '(' ARG (',' ARG)* ')' ;  ARG <- "([^"]|\\")*” ;

This seems like a really complicated set of extensions to filecheck for marginal gain.  I’m not enthused by the idea that you’d have to actually utter this in every individual test that needs to use the feature, because that would lead to boilerplate.

Instead of doing this, has anyone considered baking “modes” into Filecheck to support the important clients (e.g. LLVM IR, MC, clang, etc)?  This would mean that a test could just add a “--mode=llvmir” flag to filecheck and get a bunch of baked in patterns, potentially with magic syntax.  Something like this would avoid having to redundantly enter "%[0-9]+” a kajillion times all over the place.

-Chris


More information about the llvm-dev mailing list