[llvm-dev] Syntax for FileCheck numeric variables and expressions

Thomas Preudhomme via llvm-dev llvm-dev at lists.llvm.org
Thu Jul 12 07:34:22 PDT 2018


Hi all,

I've written a patch to extend FileCheck to support matching
arithmetic expressions involving variable [1] (eg. to match REG+1
where REG is a variable with a numeric value). It was suggested to me
in the review to introduce the concept of numeric variable and to
allow for specifying the base the value are written in.

[1] https://reviews.llvm.org/D49084

I think the syntax should satisfy the below requirements:

* based off the [[]] construct since anything else might overload an
existing valid syntax (eg. $$ is supposed to match literally now)
* consistent with syntax for expressions using @LINE
* consistent with using ':' to define regular variable
* allows to specify base of the number a numeric variable is being set to
* allows to specify base of the result of the numeric expression

I've come up with the following syntax for which I'd like feedback:

Numeric variable definition: [[#X<base:]] (eg. [[#ADDR<16:]]) where X
is the numeric variable being defined and <base is optional in which
case base defaults to 10
Numeric variable use: [[#X>base]] (eg. [[#ADDR]]>2) where <base is
optional in which case base defaults 10
Numeric expression: [[exp>base]] (eg. [[#ADDR+2>16]] where expression
must contain at least one numeric variable


I'm not a big fan of the > for the output base being inside the
expression but [[exp]]>base would match >base literally.

Any suggestions / opinions?

Best regards,

Thomas


More information about the llvm-dev mailing list