aboutsummaryrefslogtreecommitdiff
path: root/llvm/docs/CommandGuide/FileCheck.rst
diff options
context:
space:
mode:
authorThomas Preud'homme <thomasp@graphcore.ai>2019-05-14 11:58:30 +0000
committerThomas Preud'homme <thomasp@graphcore.ai>2019-05-14 11:58:30 +0000
commit7b4ecdd3c2c64b0656f4a45a74fd2decf7606d0c (patch)
treee1809bf80568482321f3436be2c1174c2bc6bd1d /llvm/docs/CommandGuide/FileCheck.rst
parent2747ee2c83e4ba0c159f98498bdf98b3773ffa53 (diff)
downloadllvm-7b4ecdd3c2c64b0656f4a45a74fd2decf7606d0c.zip
llvm-7b4ecdd3c2c64b0656f4a45a74fd2decf7606d0c.tar.gz
llvm-7b4ecdd3c2c64b0656f4a45a74fd2decf7606d0c.tar.bz2
Reinstate "FileCheck [5/12]: Introduce regular numeric variables"
This reinstates r360578 (git e47362c1ec1ea31b626336cc05822035601c3e57), reverted in r360653 (git 004393681c25e34e921adccc69ae6378090dee54), with a fix for the list added in FileCheck.rst to build without error. 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: 360665
Diffstat (limited to 'llvm/docs/CommandGuide/FileCheck.rst')
-rw-r--r--llvm/docs/CommandGuide/FileCheck.rst60
1 files changed, 53 insertions, 7 deletions
diff --git a/llvm/docs/CommandGuide/FileCheck.rst b/llvm/docs/CommandGuide/FileCheck.rst
index 778f6bb..55c7f31 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: