<div dir="ltr"><div>Hi Thomas,</div><div><br></div><div>In general, I think this is a good proposal. However, I don't think that using ">" or "<" to specify base (at least alone) is a good idea, as it might clash with future ideas to do comparisons etc. I also think it would be nice to have the syntax consistent between definition and use. My first thought on a reasonable alternative was to use commas to separate the two parts, so something like:</div><div><br></div><div>[[# VAR, 16:]] to capture a hexadecimal number (where the spaces are optional). [[# VAR, 16]] to use a variable, converted to a hexadecimal string. In both cases, the base component is optional, and defaults to decimal.<br></div><div><br></div><div>This led me to thing that it might be better to use something similar to printf style for the latter half, so to capture a hexadecimal number with a leading "0x" would be:
"0x[[# VAR, %x:]]" and to use it would be
"0x[[# VAR, %x]]". Indeed, that would allow straightforward conversions between formats, so say you defined it by capturing a decimal integer and using it to match a hexadecimal in upper case, with leading 0x and 8 digits following the 0x:</div><div><br></div><div>CHECK: [[# VAR, %d:]] # Defines</div><div>CHECK:
0x[[# VAR + 1, %8X]] # Uses</div><div><br></div><div>Of course, if we go down that route, it would probably make more sense to reverse the two sides (e.g. to become "[[# %d, VAR:]]" to capture a decimal and "[[# %8X, VAR + 1]]" to use it).<br></div><div><br></div><div>Regards,</div><div><br></div><div>James<br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On 12 July 2018 at 15:34, Thomas Preudhomme via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi all,<br>
<br>
I've written a patch to extend FileCheck to support matching<br>
arithmetic expressions involving variable [1] (eg. to match REG+1<br>
where REG is a variable with a numeric value). It was suggested to me<br>
in the review to introduce the concept of numeric variable and to<br>
allow for specifying the base the value are written in.<br>
<br>
[1] <a href="https://reviews.llvm.org/D49084" rel="noreferrer" target="_blank">https://reviews.llvm.org/<wbr>D49084</a><br>
<br>
I think the syntax should satisfy the below requirements:<br>
<br>
* based off the [[]] construct since anything else might overload an<br>
existing valid syntax (eg. $$ is supposed to match literally now)<br>
* consistent with syntax for expressions using @LINE<br>
* consistent with using ':' to define regular variable<br>
* allows to specify base of the number a numeric variable is being set to<br>
* allows to specify base of the result of the numeric expression<br>
<br>
I've come up with the following syntax for which I'd like feedback:<br>
<br>
Numeric variable definition: [[#X<base:]] (eg. [[#ADDR<16:]]) where X<br>
is the numeric variable being defined and <base is optional in which<br>
case base defaults to 10<br>
Numeric variable use: [[#X>base]] (eg. [[#ADDR]]>2) where <base is<br>
optional in which case base defaults 10<br>
Numeric expression: [[exp>base]] (eg. [[#ADDR+2>16]] where expression<br>
must contain at least one numeric variable<br>
<br>
<br>
I'm not a big fan of the > for the output base being inside the<br>
expression but [[exp]]>base would match >base literally.<br>
<br>
Any suggestions / opinions?<br>
<br>
Best regards,<br>
<br>
Thomas<br>
______________________________<wbr>_________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-dev</a><br>
</blockquote></div><br></div>