diff options
author | Thomas Preud'homme <thomasp@graphcore.ai> | 2019-07-23 22:41:38 +0000 |
---|---|---|
committer | Thomas Preud'homme <thomasp@graphcore.ai> | 2019-07-23 22:41:38 +0000 |
commit | 1b05977538d9487aa845ee2f3bec8b89c63c4f29 (patch) | |
tree | a07940c8253e44d48e5a95de8c113a77d3311a55 /llvm/docs/CommandGuide/FileCheck.rst | |
parent | f8552e67e91177911351f3ffa8028d44ec1e8b66 (diff) | |
download | llvm-1b05977538d9487aa845ee2f3bec8b89c63c4f29.zip llvm-1b05977538d9487aa845ee2f3bec8b89c63c4f29.tar.gz llvm-1b05977538d9487aa845ee2f3bec8b89c63c4f29.tar.bz2 |
FileCheck [8/12]: Define numeric var from expr
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch lift the restriction for a
numeric expression to either be a variable definition or a numeric
expression to try to match.
This commit allows a numeric variable to be set to the result of the
evaluation of a numeric expression after it has been matched
successfully. When it happens, the variable is allowed to be used on
the same line since its value is known at match time.
It also makes use of this possibility to reuse the parsing code to
parse a command-line definition by crafting a mirror string of the
-D option with the equal sign replaced by a colon sign, e.g. for option
'-D#NUMVAL=10' it creates the string
'-D#NUMVAL=10 (parsed as [[#NUMVAL:10]])' where the numeric expression
is parsed to define NUMVAL. This result in a few tests needing updating
for the location diagnostics on top of the tests for the new feature.
It also enables empty numeric expression which match any number without
defining a variable. This is done here rather than in commit #5 of the
patch series because it requires to dissociate automatic regex insertion
in RegExStr from variable definition which would make commit #5 even
bigger than it already is.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60388
llvm-svn: 366860
Diffstat (limited to 'llvm/docs/CommandGuide/FileCheck.rst')
-rw-r--r-- | llvm/docs/CommandGuide/FileCheck.rst | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/llvm/docs/CommandGuide/FileCheck.rst b/llvm/docs/CommandGuide/FileCheck.rst index 0aa2d89..c5521e4 100644 --- a/llvm/docs/CommandGuide/FileCheck.rst +++ b/llvm/docs/CommandGuide/FileCheck.rst @@ -107,12 +107,12 @@ and from the command line. Sets a filecheck pattern variable ``VAR`` with value ``VALUE`` that can be used in ``CHECK:`` lines. -.. option:: -D#<NUMVAR>=<VALUE EXPRESSION> +.. option:: -D#<NUMVAR>=<NUMERIC EXPRESSION> Sets a filecheck numeric variable ``NUMVAR`` to the result of evaluating - ``<VALUE EXPRESSION>`` that can be used in ``CHECK:`` lines. See section - ``FileCheck Numeric Variables and Expressions`` for details on the format - and meaning of ``<VALUE EXPRESSION>``. + ``<NUMERIC EXPRESSION>`` that can be used in ``CHECK:`` lines. See section + ``FileCheck Numeric Variables and Expressions`` for details on supported + numeric expressions. .. option:: -version @@ -625,11 +625,27 @@ but would not match the text: due to ``7`` being unequal to ``5 + 1``. +The syntax also supports an empty expression, equivalent to writing {{[0-9]+}}, +for cases where the input must contain a numeric value but the value itself +does not matter: + +.. code-block:: gas + + ; CHECK-NOT: mov r0, r[[#]] + +to check that a value is synthesized rather than moved around. + +A numeric variable can also be defined to the result of a numeric expression, +in which case the numeric expression is checked and if verified the variable is +assigned to the value. The unified syntax for both defining numeric variables +and checking a numeric expression is thus ``[[#<NUMVAR>: <expr>]]`` with each +element as described previously. + The ``--enable-var-scope`` option has the same effect on numeric variables as on string variables. Important note: In its current implementation, an expression cannot use a -numeric variable defined on the same line. +numeric variable with a non-empty expression defined on the same line. FileCheck Pseudo Numeric Variables ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |