diff options
author | Chris Lattner <sabre@nondot.org> | 2009-09-27 07:56:52 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-09-27 07:56:52 +0000 |
commit | eec96958cd53ebb61bebfd3af416ace380df6f6c (patch) | |
tree | ce88177bfb43ff68eacbacff55802074117a4877 /docs/TestingGuide.html | |
parent | 513869453be688d772df7364c141a981f50c6d56 (diff) |
implement and document support for filecheck variables. This
allows matching and remembering a string and then matching and
verifying that the string occurs later in the file.
Change X86/xor.ll to use this in some cases where the test was
checking for an arbitrary register allocation decision.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82891 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'docs/TestingGuide.html')
-rw-r--r-- | docs/TestingGuide.html | 41 |
1 files changed, 40 insertions, 1 deletions
diff --git a/docs/TestingGuide.html b/docs/TestingGuide.html index bc19ab4262..8e1041ec2a 100644 --- a/docs/TestingGuide.html +++ b/docs/TestingGuide.html @@ -626,7 +626,7 @@ define i8 @coerce_offset0(i32 %V, i32* %P) { <!-- _______________________________________________________________________ --> <div class="doc_subsubsection"><a -name="FileCheck-Matching">FileCheck Pattern Matting Syntax</a></div> +name="FileCheck-Matching">FileCheck Pattern Matching Syntax</a></div> <div class="doc_text"> @@ -656,7 +656,46 @@ braces explicitly from the input, you can use something ugly like </div> +<!-- _______________________________________________________________________ --> +<div class="doc_subsubsection"><a +name="FileCheck-Variables">FileCheck Variables</a></div> + +<div class="doc_text"> +<p>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, +but verify that that register is used consistently later. To do this, FileCheck +allows named variables to be defined and substituted into patterns. Here is a +simple example:</p> + +<div class="doc_code"> +<pre> +; CHECK: test5: +; CHECK: notw <b>[[REG:%[a-z]+]]</b> +; CHECK: andw {{.*}}<b>[[REG]]</b> +</pre> +</div> + +<p>The first check line matches a regex (%[a-z]+) and captures it into the +variables "REG". The second line verifies that whatever is in REG occurs later +in the file after an "andw". FileCheck variable references are always contained +in [[ ]] pairs, are named, and their names can 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, if not, it is a use.</p> + +<p>FileCheck variables can be defined multiple times, and uses always get the +latest value. Note that variables are all read at the start of a "CHECK" line +and are all defined at the end. This means that if you have something like +"<tt>CHECK: [[XYZ:.*]]x[[XYZ]]</tt>" that the check line will read the previous +value of the XYZ variable and define a new one after the match is 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 matches, this allows you to +define two separate CHECK lines that match on the same line. +</p> + + + +</div> <!-- _______________________________________________________________________ --> <div class="doc_subsection"><a name="dgvars">Variables and |