[PATCH] D81667: [RFC, FileCheck] Add precision to format specifier

Joel E. Denny via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 11 09:26:46 PDT 2020


jdenny added inline comments.


================
Comment at: llvm/docs/CommandGuide/FileCheck.rst:732
 
-* ``%<fmtspec>`` is an optional scanf-style matching format specifier to
-  indicate what number format to match (e.g. hex number).  Currently accepted
-  format specifiers are ``%u``, ``%d``, ``%x`` and ``%X``.  If absent, the
-  format specifier defaults to ``%u``.
+* ``%<fmtspec>`` is an optional format specifier to indicate the what number
+  format to match and how many leading zeros to expect.
----------------
"`%<fmtspec>` is an optional" -> "`%<fmtspec>,` is an optional"?  That is, you must either have `%<fmtspec>` and `,` or neither, right?

"the what" -> "what"


================
Comment at: llvm/docs/CommandGuide/FileCheck.rst:733
+* ``%<fmtspec>`` is an optional format specifier to indicate the what number
+  format to match and how many leading zeros to expect.
 
----------------
"how many leading zeros" -> "how many digits" given that you can directly specify the latter (as a minimum) but not the former?


================
Comment at: llvm/docs/CommandGuide/FileCheck.rst:758
 would match ``mov r5, 0xF0F0`` and set ``REG`` to the value ``5`` and ``IMM``
 to the value ``0xF0F0``.
 
----------------
`IMM`->`ADDR`

The documentation above says 8 is the minimum, but `F0F0` has 4 digits.


================
Comment at: llvm/docs/CommandGuide/FileCheck.rst:761
 The syntax of a numeric substitution is
 ``[[#%<fmtspec>: <constraint> <expr>]]`` where:
 
----------------
Isn't `:` supposed to be `,`?  That's how the tests seem to work, and FileCheck complains when I try this syntax with `:`.


================
Comment at: llvm/docs/CommandGuide/FileCheck.rst:769
+  denoting that the value should be unsigned with no leading zeros. In case of
+  conflict between format specifiers of several numeric variable the conversion
+  specifier becomes mandatory but the precision specifier remains optional.
----------------
"variable" -> "variables,"


================
Comment at: llvm/docs/CommandGuide/FileCheck.rst:776
   ``<constraint>`` is not provided. No matching constraint must be specified
   when the ``<expr>`` is empty.
 
----------------
When `<expr>` is empty (here or in the variable definition syntax), then the precision specifier specifies the //minimum// number of digits to be matched, right?

When `<expr>` is non-empty, then the precision specifier combined with the actual value of the expression specifies an //exact// number of digits to be matched, right?  I understand that the precision is a minimum here too, but I think it's a printing/substitution minimum not a matching/capturing minimum.

My point is that this case is a bit hard to follow.  It seems to me that the numeric substitution syntax with no `<expr>` is actually more like a variable definition syntax with no variable (and thus no `:`): there's no existing value to match against, so there's nothing to "substitute".  Instead you're capturing a new value and either saving it as a variable or discarding it.  Can we document it that way?

If so, instead of calling the first syntax "The syntax to define a numeric variable", you might call it "The syntax to capture a numeric value".  It can optionally define a numeric variable.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81667/new/

https://reviews.llvm.org/D81667



More information about the llvm-commits mailing list