Update FileCheck's documentation to mention recently added feature of

matching a variable defined on the same line.

llvm-svn: 169103
This commit is contained in:
Eli Bendersky 2012-12-01 22:03:57 +00:00
parent 8757acb3f2
commit 4ca99ba6b5
1 changed files with 16 additions and 15 deletions

View File

@ -223,9 +223,9 @@ FileCheck Variables
It is often useful to match a pattern and then verify that it occurs again It is often useful to match a pattern and then verify that it occurs again
later in the file. For codegen tests, this can be useful to allow any register, later in the file. For codegen tests, this can be useful to allow any register,
but verify that that register is used consistently later. To do this, FileCheck but verify that that register is used consistently later. To do this,
allows named variables to be defined and substituted into patterns. Here is a :program:`FileCheck` allows named variables to be defined and substituted into
simple example: patterns. Here is a simple example:
.. code-block:: llvm .. code-block:: llvm
@ -235,20 +235,21 @@ simple example:
The first check line matches a regex ``%[a-z]+`` and captures it into the The first check line matches a regex ``%[a-z]+`` and captures it into the
variable ``REGISTER``. The second line verifies that whatever is in variable ``REGISTER``. The second line verifies that whatever is in
``REGISTER`` occurs later in the file after an "``andw``". FileCheck variable ``REGISTER`` occurs later in the file after an "``andw``". :program:`FileCheck`
references are always contained in ``[[ ]]`` pairs, and their names can be variable references are always contained in ``[[ ]]`` pairs, and their names can
formed with the regex ``[a-zA-Z][a-zA-Z0-9]*``. If a colon follows the name, be formed with the regex ``[a-zA-Z][a-zA-Z0-9]*``. If a colon follows the name,
then it is a definition of the variable; otherwise, it is a use. then it is a definition of the variable; otherwise, it is a use.
FileCheck variables can be defined multiple times, and uses always get the :program:`FileCheck` variables can be defined multiple times, and uses always
latest value. Note that variables are all read at the start of a "``CHECK``" get the latest value. Variables can also be used later on the same line they
line and are all defined at the end. This means that if you have something were defined on. For example:
like "``CHECK: [[XYZ:.*]]x[[XYZ]]``", the check line will read the previous
value of the ``XYZ`` variable and define a new one after the match is .. code-block:: llvm
performed. If you need to do something like this you can probably take
advantage of the fact that FileCheck is not actually line-oriented when it ; CHECK: op [[REG:r[0-9]+]], [[REG]]
matches, this allows you to define two separate "``CHECK``" lines that match on
the same line. Can be useful if you want the operands of ``op`` to be the same register,
and don't care exactly which register it is.
FileCheck Expressions FileCheck Expressions
~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~