.\" Automatically generated by Pod::Man 2.1801 (Pod::Simple 3.05)
.\"
.\" Standard preamble:
.\" ========================================================================
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Vb \" Begin verbatim text
.ft CW
.nf
.ne \\$1
..
.de Ve \" End verbatim text
.ft R
.fi
..
.\" Set up some character translations and predefined strings. \*(-- will
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
.\" double quote, and \*(R" will give a right double quote. \*(C+ will
.\" give a nicer C++. Capital omega is used to do unbreakable dashes and
.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff,
.\" nothing in troff, for use with C<>.
.tr \(*W-
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
.ie n \{\
. ds -- \(*W-
. ds PI pi
. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
. ds L" ""
. ds R" ""
. ds C` ""
. ds C' ""
'br\}
.el\{\
. ds -- \|\(em\|
. ds PI \(*p
. ds L" ``
. ds R" ''
'br\}
.\"
.\" Escape single quotes in literal strings from groff's Unicode transform.
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.\"
.\" If the F register is turned on, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
.\" entries marked with X<> in POD. Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
.ie \nF \{\
. de IX
. tm Index:\\$1\t\\n%\t"\\$2"
..
. nr % 0
. rr F
.\}
.el \{\
. de IX
..
.\}
.\"
.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
.\" Fear. Run. Save yourself. No user-serviceable parts.
. \" fudge factors for nroff and troff
.if n \{\
. ds #H 0
. ds #V .8m
. ds #F .3m
. ds #[ \f1
. ds #] \fP
.\}
.if t \{\
. ds #H ((1u-(\\\\n(.fu%2u))*.13m)
. ds #V .6m
. ds #F 0
. ds #[ \&
. ds #] \&
.\}
. \" simple accents for nroff and troff
.if n \{\
. ds ' \&
. ds ` \&
. ds ^ \&
. ds , \&
. ds ~ ~
. ds /
.\}
.if t \{\
. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
.\}
. \" troff and (daisy-wheel) nroff accents
.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
.ds ae a\h'-(\w'a'u*4/10)'e
.ds Ae A\h'-(\w'A'u*4/10)'E
. \" corrections for vroff
.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
. \" for low resolution devices (crt and lpr)
.if \n(.H>23 .if \n(.V>19 \
\{\
. ds : e
. ds 8 ss
. ds o a
. ds d- d\h'-1'\(ga
. ds D- D\h'-1'\(hy
. ds th \o'bp'
. ds Th \o'LP'
. ds ae ae
. ds Ae AE
.\}
.rm #[ #] #H #V #F C
.\" ========================================================================
.\"
.IX Title "FILECHECK 1"
.TH FILECHECK 1 "2010-05-06" "CVS" "LLVM Command Guide"
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l
.nh
.SH "NAME"
FileCheck \- Flexible pattern matching file verifier
.SH "SYNOPSIS"
.IX Header "SYNOPSIS"
\&\fBFileCheck\fR \fImatch-filename\fR [\fI\-\-check\-prefix=XXX\fR] [\fI\-\-strict\-whitespace\fR]
.SH "DESCRIPTION"
.IX Header "DESCRIPTION"
\&\fBFileCheck\fR reads two files (one from standard input, and one specified on the
command line) and uses one to verify the other. This behavior is particularly
useful for the testsuite, which wants to verify that the output of some tool
(e.g. llc) contains the expected information (for example, a movsd from esp or
whatever is interesting). This is similar to using grep, but it is optimized
for matching multiple different inputs in one file in a specific order.
.PP
The \fImatch-filename\fR file specifies the file that contains the patterns to
match. The file to verify is always read from standard input.
.SH "OPTIONS"
.IX Header "OPTIONS"
.IP "\fB\-help\fR" 4
.IX Item "-help"
Print a summary of command line options.
.IP "\fB\-\-check\-prefix\fR \fIprefix\fR" 4
.IX Item "--check-prefix prefix"
FileCheck searches the contents of \fImatch-filename\fR for patterns to match. By
default, these patterns are prefixed with \*(L"\s-1CHECK:\s0\*(R". If you'd like to use a
different prefix (e.g. because the same input file is checking multiple
different tool or options), the \fB\-\-check\-prefix\fR argument allows you to specify
a specific prefix to match.
.IP "\fB\-\-strict\-whitespace\fR" 4
.IX Item "--strict-whitespace"
By default, FileCheck canonicalizes input horizontal whitespace (spaces and
tabs) which causes it to ignore these differences (a space will match a tab).
The \-\-strict\-whitespace argument disables this behavior.
.IP "\fB\-version\fR" 4
.IX Item "-version"
Show the version number of this program.
.SH "EXIT STATUS"
.IX Header "EXIT STATUS"
If \fBFileCheck\fR verifies that the file matches the expected contents, it exits
with 0. Otherwise, if not, or if an error occurs, it will exit with a non-zero
value.
.SH "TUTORIAL"
.IX Header "TUTORIAL"
FileCheck is typically used from \s-1LLVM\s0 regression tests, being invoked on the \s-1RUN\s0
line of the test. A simple example of using FileCheck from a \s-1RUN\s0 line looks
like this:
.PP
.Vb 1
\& ; RUN: llvm\-as < %s | llc \-march=x86\-64 | FileCheck %s
.Ve
.PP
This syntax says to pipe the current file (\*(L"%s\*(R") into llvm-as, pipe that into
llc, then pipe the output of llc into FileCheck. This means that FileCheck will
be verifying its standard input (the llc output) against the filename argument
specified (the original .ll file specified by \*(L"%s\*(R"). To see how this works,
lets look at the rest of the .ll file (after the \s-1RUN\s0 line):
.PP
.Vb 7
\& define void @sub1(i32* %p, i32 %v) {
\& entry:
\& ; CHECK: sub1:
\& ; CHECK: subl
\& %0 = tail call i32 @llvm.atomic.load.sub.i32.p0i32(i32* %p, i32 %v)
\& ret void
\& }
\&
\& define void @inc4(i64* %p) {
\& entry:
\& ; CHECK: inc4:
\& ; CHECK: incq
\& %0 = tail call i64 @llvm.atomic.load.add.i64.p0i64(i64* %p, i64 1)
\& ret void
\& }
.Ve
.PP
Here you can see some \*(L"\s-1CHECK:\s0\*(R" lines specified in comments. Now you can see
how the file is piped into llvm-as, then llc, and the machine code output is
what we are verifying. FileCheck checks the machine code output to verify that
it matches what the \*(L"\s-1CHECK:\s0\*(R" lines specify.
.PP
The syntax of the \s-1CHECK:\s0 lines is very simple: they are fixed strings that
must occur in order. FileCheck defaults to ignoring horizontal whitespace
differences (e.g. a space is allowed to match a tab) but otherwise, the contents
of the \s-1CHECK:\s0 line is required to match some thing in the test file exactly.
.PP
One nice thing about FileCheck (compared to grep) is that it allows merging
test cases together into logical groups. For example, because the test above
is checking for the \*(L"sub1:\*(R" and \*(L"inc4:\*(R" labels, it will not match unless there
is a \*(L"subl\*(R" in between those labels. If it existed somewhere else in the file,
that would not count: \*(L"grep subl\*(R" matches if subl exists anywhere in the
file.
.SS "The FileCheck \-check\-prefix option"
.IX Subsection "The FileCheck -check-prefix option"
The FileCheck \-check\-prefix option allows multiple test configurations to be
driven from one .ll file. This is useful in many circumstances, for example,
testing different architectural variants with llc. Here's a simple example:
.PP
.Vb 4
\& ; RUN: llvm\-as < %s | llc \-mtriple=i686\-apple\-darwin9 \-mattr=sse41 \e
\& ; RUN: | FileCheck %s \-check\-prefix=X32
\& ; RUN: llvm\-as < %s | llc \-mtriple=x86_64\-apple\-darwin9 \-mattr=sse41 \e
\& ; RUN: | FileCheck %s \-check\-prefix=X64
\&
\& define <4 x i32> @pinsrd_1(i32 %s, <4 x i32> %tmp) nounwind {
\& %tmp1 = insertelement <4 x i32>; %tmp, i32 %s, i32 1
\& ret <4 x i32> %tmp1
\& ; X32: pinsrd_1:
\& ; X32: pinsrd $1, 4(%esp), %xmm0
\&
\& ; X64: pinsrd_1:
\& ; X64: pinsrd $1, %edi, %xmm0
\& }
.Ve
.PP
In this case, we're testing that we get the expected code generation with
both 32\-bit and 64\-bit code generation.
.ie n .SS "The ""CHECK-NEXT:"" directive"
.el .SS "The ``CHECK-NEXT:'' directive"
.IX Subsection "The CHECK-NEXT: directive"
Sometimes you want to match lines and would like to verify that matches
happen on exactly consequtive lines with no other lines in between them. In
this case, you can use \s-1CHECK:\s0 and CHECK-NEXT: directives to specify this. If
you specified a custom check prefix, just use \*(L"<\s-1PREFIX\s0>\-NEXT:\*(R". For
example, something like this works as you'd expect:
.PP
.Vb 8
\& define void @t2(<2 x double>* %r, <2 x double>* %A, double %B) {
\& %tmp3 = load <2 x double>* %A, align 16
\& %tmp7 = insertelement <2 x double> undef, double %B, i32 0
\& %tmp9 = shufflevector <2 x double> %tmp3,
\& <2 x double> %tmp7,
\& <2 x i32> < i32 0, i32 2 >
\& store <2 x double> %tmp9, <2 x double>* %r, align 16
\& ret void
\&
\& ; CHECK: t2:
\& ; CHECK: movl 8(%esp), %eax
\& ; CHECK\-NEXT: movapd (%eax), %xmm0
\& ; CHECK\-NEXT: movhpd 12(%esp), %xmm0
\& ; CHECK\-NEXT: movl 4(%esp), %eax
\& ; CHECK\-NEXT: movapd %xmm0, (%eax)
\& ; CHECK\-NEXT: ret
\& }
.Ve
.PP
CHECK-NEXT: directives reject the input unless there is exactly one newline
between it an the previous directive. A CHECK-NEXT cannot be the first
directive in a file.
.ie n .SS "The ""CHECK-NOT:"" directive"
.el .SS "The ``CHECK-NOT:'' directive"
.IX Subsection "The CHECK-NOT: directive"
The CHECK-NOT: directive is used to verify that a string doesn't occur
between two matches (or the first match and the beginning of the file). For
example, to verify that a load is removed by a transformation, a test like this
can be used:
.PP
.Vb 2
\& define i8 @coerce_offset0(i32 %V, i32* %P) {
\& store i32 %V, i32* %P
\&
\& %P2 = bitcast i32* %P to i8*
\& %P3 = getelementptr i8* %P2, i32 2
\&
\& %A = load i8* %P3
\& ret i8 %A
\& ; CHECK: @coerce_offset0
\& ; CHECK\-NOT: load
\& ; CHECK: ret i8
\& }
.Ve
.SS "FileCheck Pattern Matching Syntax"
.IX Subsection "FileCheck Pattern Matching Syntax"
The \s-1CHECK:\s0 and CHECK-NOT: directives both take a pattern to match. For most
uses of FileCheck, fixed string matching is perfectly sufficient. For some
things, a more flexible form of matching is desired. To support this, FileCheck
allows you to specify regular expressions in matching strings, surrounded by
double braces: \fB{{yourregex}}\fR. Because we want to use fixed string
matching for a majority of what we do, FileCheck has been designed to support
mixing and matching fixed string matching with regular expressions. This allows
you to write things like this:
.PP
.Vb 1
\& ; CHECK: movhpd {{[0\-9]+}}(%esp), {{%xmm[0\-7]}}
.Ve
.PP
In this case, any offset from the \s-1ESP\s0 register will be allowed, and any xmm
register will be allowed.
.PP
Because regular expressions are enclosed with double braces, they are
visually distinct, and you don't need to use escape characters within the double
braces like you would in C. In the rare case that you want to match double
braces explicitly from the input, you can use something ugly like
\&\fB{{[{][{]}}\fR as your pattern.
.SS "FileCheck Variables"
.IX Subsection "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:
.PP
.Vb 3
\& ; CHECK: test5:
\& ; CHECK: notw [[REGISTER:%[a\-z]+]]
\& ; CHECK: andw {{.*}}[[REGISTER]]
.Ve
.PP
The first check line matches a regex (%[a\-z]+) and captures it into
the variables \*(L"\s-1REGISTER\s0\*(R". The second line verifies that whatever is in \s-1REGISTER\s0
occurs later in the file after an \*(L"andw\*(R". FileCheck variable references are
always contained in [[ ]] pairs, are named, and their names can be
formed with the regex \*(L"[a\-zA\-Z_][a\-zA\-Z0\-9_]*\*(R". If a colon follows the
name, then it is a definition of the variable, if not, it is a use.
.PP
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 \*(L"\s-1CHECK\s0\*(R" line
and are all defined at the end. This means that if you have something like
\&\*(L"\s-1CHECK:\s0 [[\s-1XYZ:\s0.*]]x[[\s-1XYZ\s0]]\*(R" that the check line will read the previous
value of the \s-1XYZ\s0 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 \s-1CHECK\s0 lines that match on the same line.
.SH "AUTHORS"
.IX Header "AUTHORS"
Maintained by The \s-1LLVM\s0 Team ().