From eec96958cd53ebb61bebfd3af416ace380df6f6c Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sun, 27 Sep 2009 07:56:52 +0000 Subject: 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 --- docs/TestingGuide.html | 41 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) (limited to 'docs/TestingGuide.html') diff --git a/docs/TestingGuide.html b/docs/TestingGuide.html index bc19ab4..8e1041e 100644 --- a/docs/TestingGuide.html +++ b/docs/TestingGuide.html @@ -626,7 +626,7 @@ define i8 @coerce_offset0(i32 %V, i32* %P) {
FileCheck Pattern Matting Syntax
+name="FileCheck-Matching">FileCheck Pattern Matching Syntax
@@ -656,7 +656,46 @@ braces explicitly from the input, you can use something ugly like
+ +
FileCheck Variables
+ +
+

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:

+ +
+
+; CHECK: test5:
+; CHECK:    notw	[[REG:%[a-z]+]]
+; CHECK:    andw	{{.*}}[[REG]]
+
+
+ +

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.

+ +

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 +"CHECK: [[XYZ:.*]]x[[XYZ]]" 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. +

+ + + +
Variables and -- cgit v1.1