diff options
author | Thomas Preud'homme <thomasp@graphcore.ai> | 2019-05-13 12:39:08 +0000 |
---|---|---|
committer | Thomas Preud'homme <thomasp@graphcore.ai> | 2019-05-13 12:39:08 +0000 |
commit | e47362c1ec1ea31b626336cc05822035601c3e57 (patch) | |
tree | 7c8293e53e46a012061a83c47fe8155328750ec3 /llvm/docs/CommandGuide/FileCheck.rst | |
parent | 053c6fc2b8a7d7fac11e6f7bb450046d1d5389fd (diff) | |
download | llvm-e47362c1ec1ea31b626336cc05822035601c3e57.zip llvm-e47362c1ec1ea31b626336cc05822035601c3e57.tar.gz llvm-e47362c1ec1ea31b626336cc05822035601c3e57.tar.bz2 |
FileCheck [5/12]: Introduce regular numeric variables
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch introduces regular numeric
variables which can be set on the command-line.
This commit introduces regular numeric variable that can be set on the
command-line with the -D option to a numeric value. They can then be
used in CHECK patterns in numeric expression with the same shape as
@LINE numeric expression, ie. VAR, VAR+offset or VAR-offset where offset
is an integer literal.
The commit also enable strict whitespace in the verbose.txt testcase to
check that the position or the location diagnostics. It fixes one of the
existing CHECK in the process which was not accurately testing a
location diagnostic (ie. the diagnostic was correct, not the CHECK).
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/D60385
llvm-svn: 360578
Diffstat (limited to 'llvm/docs/CommandGuide/FileCheck.rst')
-rw-r--r-- | llvm/docs/CommandGuide/FileCheck.rst | 60 |
1 files changed, 53 insertions, 7 deletions
diff --git a/llvm/docs/CommandGuide/FileCheck.rst b/llvm/docs/CommandGuide/FileCheck.rst index 778f6bb..d213c13 100644 --- a/llvm/docs/CommandGuide/FileCheck.rst +++ b/llvm/docs/CommandGuide/FileCheck.rst @@ -105,6 +105,11 @@ 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> + + Sets a filecheck numeric variable ``NUMVAR`` to ``<VALUE>`` that can be used + in ``CHECK:`` lines. + .. option:: -version Show the version number of this program. @@ -560,8 +565,51 @@ CHECK-LABEL block. Global variables are not affected by CHECK-LABEL. This makes it easier to ensure that individual tests are not affected by variables set in preceding tests. -FileCheck Numeric Expressions -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +FileCheck Numeric Variables and Expressions +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +:program:`FileCheck` also allows checking for numeric values that satisfy a +numeric expression constraint based on numeric variables. This allows +``CHECK:`` directives to verify a numeric relation between two numbers, such as +the need for consecutive registers to be used. + +The syntax to check a numeric expression constraint is +``[[#<NUMVAR><op><offset>]]`` where: + +*``<NUMVAR>`` is the name of a numeric variable defined on the command line. + +*``<op>`` is an optional numeric operation to perform on the value of +``<NUMVAR>``. Currently supported numeric operations are ``+`` and ``-``. + +*``<offset>`` is the immediate value that constitutes the second operand of +the numeric operation <op>. It must be present if ``<op>`` is present, +absent otherwise. + +For example: + +.. code-block:: llvm + + ; CHECK: add r[[#REG]], r[[#REG]], r[[#REG+1]] + +The above example would match the line: + +.. code-block:: llvm + + add r5, r5, r6 + +but would not match the line: + +.. code-block:: llvm + + add r5, r5, r7 + +due to ``7`` being unequal to ``5 + 1``. + +The ``--enable-var-scope`` option has the same effect on numeric variables as +on pattern variables. + +FileCheck Pseudo Numeric Variables +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Sometimes there's a need to verify output that contains line numbers of the match file, e.g. when testing compiler diagnostics. This introduces a certain @@ -569,11 +617,9 @@ fragility of the match file structure, as "``CHECK:``" lines contain absolute line numbers in the same file, which have to be updated whenever line numbers change due to text addition or deletion. -To support this case, FileCheck allows using ``[[#@LINE]]``, -``[[#@LINE+<offset>]]`` and ``[[#@LINE-<offset>]]`` numeric expressions in -patterns, with an arbitrary number of spaces between each element of the -expression. These expressions expand to the number of the line where a pattern -is located (with an optional integer offset). +To support this case, FileCheck understands the ``@LINE`` pseudo numeric +variable which evaluates to the line number of the CHECK pattern where it is +found. This way match patterns can be put near the relevant test lines and include relative line number references, for example: |