More DragonEgg verbiage.
[oota-llvm.git] / docs / TestingGuide.html
index 743ad10cf642a916dce377c54783e293890df527..43c414d4c974ef877cabcca5e699fbb5a42fe9ec 100644 (file)
@@ -2,44 +2,45 @@
                       "http://www.w3.org/TR/html4/strict.dtd">
 <html>
 <head>
-  <title>LLVM Test Suite Guide</title>
+  <title>LLVM Testing Infrastructure Guide</title>
   <link rel="stylesheet" href="llvm.css" type="text/css">
 </head>
 <body>
       
 <div class="doc_title">
-  LLVM Test Suite Guide
+  LLVM Testing Infrastructure Guide
 </div>
 
 <ol>
   <li><a href="#overview">Overview</a></li>
-  <li><a href="#Requirements">Requirements</a></li>
-  <li><a href="#org">LLVM Test Suite Organization</a>
+  <li><a href="#requirements">Requirements</a></li>
+  <li><a href="#org">LLVM testing infrastructure organization</a>
     <ul>
-      <li><a href="#codefragments">Code Fragments</a></li>
-      <li><a href="#wholeprograms">Whole Programs</a></li>
+      <li><a href="#dejagnu">DejaGNU tests</a></li>
+      <li><a href="#testsuite">Test suite</a></li>
     </ul>
   </li>
-  <li><a href="#quick">Quick Start</a>
+  <li><a href="#quick">Quick start</a>
     <ul>
       <li><a href="#quickdejagnu">DejaGNU tests</a></li>
-      <li><a href="#quickllvmtest">llvm-test tests</a></li>
+      <li><a href="#quicktestsuite">Test suite</a></li>
    </ul>
   </li>
-  <li><a href="#dgstructure">DejaGNU Structure</a>
+  <li><a href="#dgstructure">DejaGNU structure</a>
     <ul>
-      <li><a href="#customdg">Writing new DejaGNU tests</a></li>
+      <li><a href="#dgcustom">Writing new DejaGNU tests</a></li>
+      <li><a href="#FileCheck">The FileCheck utility</a></li>
       <li><a href="#dgvars">Variables and substitutions</a></li>
       <li><a href="#dgfeatures">Other features</a></li>
    </ul>
   </li>
-  <li><a href="#llvmteststructure"><tt>llvm-test</tt> Structure</a></li>
-  <li><a href="#runllvmtest">Running the LLVM Tests</a>
+  <li><a href="#testsuitestructure">Test suite structure</a></li>
+  <li><a href="#testsuiterun">Running the test suite</a>
     <ul>
-      <li><a href="#externaltests">Configuring external tests</a></li>
-      <li><a href="#llvmtesttests">Running different tests</a></li>
-      <li><a href="#llvmtestoutput">Generating test output</a></li>
-      <li><a href="#customtest">Writing custom tests for llvm-test</a></li>
+      <li><a href="#testsuiteexternal">Configuring External Tests</a></li>
+      <li><a href="#testsuitetests">Running different tests</a></li>
+      <li><a href="#testsuiteoutput">Generating test output</a></li>
+      <li><a href="#testsuitecustom">Writing custom tests for llvm-test</a></li>
    </ul>
   </li>
   <li><a href="#nightly">Running the nightly tester</a></li>
 
 <div class="doc_text">
 
-<p>This document is the reference manual for the LLVM test suite.  It documents
-the structure of the LLVM test suite, the tools needed to use it, and how to add
-and run tests.</p>
+<p>This document is the reference manual for the LLVM testing infrastructure. It documents
+the structure of the LLVM testing infrastructure, the tools needed to use it,
+and how to add and run tests.</p>
 
 </div>
 
 <!--=========================================================================-->
-<div class="doc_section"><a name="Requirements">Requirements</a></div>
+<div class="doc_section"><a name="requirements">Requirements</a></div>
 <!--=========================================================================-->
 
 <div class="doc_text">
 
-<p>In order to use the LLVM test suite, you will need all of the software
+<p>In order to use the LLVM testing infrastructure, you will need all of the software
 required to build LLVM, plus the following:</p>
 
 <dl>
@@ -78,69 +79,42 @@ required to build LLVM, plus the following:</p>
 <dd>Expect is required by DejaGNU.</dd>
 <dt><a href="http://www.tcl.tk/software/tcltk/">tcl</a></dt>
 <dd>Tcl is required by DejaGNU. </dd>
-
-<dt><a href="http://www.netlib.org/f2c">F2C</a></dt>
-<dd>For now, LLVM does not have a Fortran front-end, but using F2C, we can run
-Fortran benchmarks.  F2C support must be enabled via <tt>configure</tt> if not
-installed in a standard place.  F2C requires three items: the <tt>f2c</tt>
-executable, <tt>f2c.h</tt> to compile the generated code, and <tt>libf2c.a</tt>
-to link generated code.  By default, given an F2C directory <tt>$DIR</tt>, the
-configure script will search <tt>$DIR/bin</tt> for <tt>f2c</tt>,
-<tt>$DIR/include</tt> for <tt>f2c.h</tt>, and <tt>$DIR/lib</tt> for
-<tt>libf2c.a</tt>.  The default <tt>$DIR</tt> values are: <tt>/usr</tt>,
-<tt>/usr/local</tt>, <tt>/sw</tt>, and <tt>/opt</tt>.  If you installed F2C in a
-different location, you must tell <tt>configure</tt>:
-
-<ul>
-<li><tt>./configure --with-f2c=$DIR</tt><br>
-This will specify a new <tt>$DIR</tt> for the above-described search
-process.  This will only work if the binary, header, and library are in their
-respective subdirectories of <tt>$DIR</tt>.</li>
-
-<li><tt>./configure --with-f2c-bin=/binary/path --with-f2c-inc=/include/path
---with-f2c-lib=/lib/path</tt><br>
-This allows you to specify the F2C components separately.  Note: if you choose
-this route, you MUST specify all three components, and you need to only specify
-<em>directories</em> where the files are located; do NOT include the
-filenames themselves on the <tt>configure</tt> line.</li>
-</ul></dd>
 </dl>
 
-<p>Darwin (Mac OS X) developers can simplify the installation of Expect and tcl
-by using fink.  <tt>fink install expect</tt> will install both. Alternatively,
-Darwinports users can use <tt>sudo port install expect</tt> to install Expect
-and tcl.</p>
-
 </div>
 
 <!--=========================================================================-->
-<div class="doc_section"><a name="org">LLVM Test Suite Organization</a></div>
+<div class="doc_section"><a name="org">LLVM testing infrastructure organization</a></div>
 <!--=========================================================================-->
 
 <div class="doc_text">
 
-<p>The LLVM test suite contains two major categories of tests: code
-fragments and whole programs. Code fragments are in the <tt>llvm</tt> module
-under the <tt>llvm/test</tt> directory. The whole programs
-test suite is in the <tt>llvm-test</tt> module under the main directory.</p>
+<p>The LLVM testing infrastructure contains two major categories of tests: code
+fragments and whole programs. Code fragments are referred to as the "DejaGNU
+tests" and are in the <tt>llvm</tt> module in subversion under the
+<tt>llvm/test</tt> directory. The whole programs tests are referred to as the
+"Test suite" and are in the <tt>test-suite</tt> module in subversion.
+</p>
 
 </div>
 
 <!-- _______________________________________________________________________ -->
-<div class="doc_subsection"><a name="codefragments">Code Fragments (a.k.a.
-DejaGNU tests)</a></div>
+<div class="doc_subsection"><a name="dejagnu">DejaGNU tests</a></div>
 <!-- _______________________________________________________________________ -->
 
 <div class="doc_text">
 
-<p>Code fragments are small pieces of code that test a specific feature of LLVM
-or trigger a specific bug in LLVM.  They are usually written in LLVM assembly
-language, but can be written in other languages if the test targets a particular
-language front end. These tests are driven by the DejaGNU testing framework,
-which is hidden behind a few simple makefiles.</p>
+<p>Code fragments are small pieces of code that test a specific
+feature of LLVM or trigger a specific bug in LLVM.  They are usually
+written in LLVM assembly language, but can be written in other
+languages if the test targets a particular language front end (and the
+appropriate <tt>--with-llvmgcc</tt> options were used
+at <tt>configure</tt> time of the <tt>llvm</tt> module). These tests
+are driven by the DejaGNU testing framework, which is hidden behind a
+few simple makefiles.</p>
 
-<p>These code fragments are not complete programs. The code generated from them is
-never executed to determine correct behavior.</p> 
+<p>These code fragments are not complete programs. The code generated
+from them is never executed to determine correct behavior.</p>
 
 <p>These code fragment tests are located in the <tt>llvm/test</tt>
 directory.</p>
@@ -154,13 +128,12 @@ application or benchmark.</p>
 </div>
 
 <!-- _______________________________________________________________________ -->
-<div class="doc_subsection"><a name="wholeprograms">Whole Programs (a.k.a.
-<tt>llvm-test</tt> tests)</a></div>
+<div class="doc_subsection"><a name="testsuite">Test suite</a></div>
 <!-- _______________________________________________________________________ -->
 
 <div class="doc_text">
 
-<p>The <tt>llvm-test</tt> suite contains whole programs, which are pieces of
+<p>The test suite contains whole programs, which are pieces of
 code which can be compiled and linked into a stand-alone program that can be
 executed.  These programs are generally written in high level languages such as
 C or C++, but sometimes they are written straight in LLVM assembly.</p>
@@ -175,27 +148,26 @@ a way of benchmarking LLVM performance, both in terms of the efficiency of the
 programs generated as well as the speed with which LLVM compiles, optimizes, and
 generates code.</p>
 
-<p>All "whole program" tests are located in the <tt>test-suite</tt> Subversion
-module.</p> 
+<p>The test-suite is located in the <tt>test-suite</tt> Subversion module.</p> 
 
 </div>
 
 <!--=========================================================================-->
-<div class="doc_section"><a name="quick">Quick Start</a></div>
+<div class="doc_section"><a name="quick">Quick start</a></div>
 <!--=========================================================================-->
 
 <div class="doc_text">
 
-  <p>The tests are located in two separate Subversion modules. The code fragment
+  <p>The tests are located in two separate Subversion modules. The
   DejaGNU tests are in the main "llvm" module under the directory 
   <tt>llvm/test</tt> (so you get these tests for free with the main llvm tree).
-  The more comprehensive <tt>llvm-test</tt> suite that includes whole 
-programs in C and C++ is in the <tt>test-suite</tt> module. This module should 
-be checked out to the <tt>llvm/projects</tt> directory as llvm-test (don't use
-another name, for then the test suite will be run every time you run
-<tt>make</tt> in the main <tt>llvm</tt> directory).
+  The more comprehensive test suite that includes whole 
+programs in C and C++ is in the <tt>test-suite</tt> module. This module should
+be checked out to the <tt>llvm/projects</tt> directory (don't use another name
+then the default "test-suite", for then the test suite will be run every time
+you run <tt>make</tt> in the main <tt>llvm</tt> directory).
 When you <tt>configure</tt> the <tt>llvm</tt> module, 
-the <tt>llvm-test</tt> directory will be automatically configured. 
+the <tt>test-suite</tt> directory will be automatically configured. 
 Alternatively, you can configure the <tt>test-suite</tt> module manually.</p>
 
 <!-- _______________________________________________________________________ -->
@@ -218,8 +190,8 @@ Alternatively, you can configure the <tt>test-suite</tt> module manually.</p>
 </pre>
 </div>
 
-<p>To run only a subdirectory of tests in llvm/test using DejaGNU (ie.
-Regression/Transforms), just set the TESTSUITE variable to the path of the
+<p>To run only a subdirectory of tests in <tt>llvm/test</tt> using DejaGNU (ie.
+Transforms), just set the TESTSUITE variable to the path of the
 subdirectory (relative to <tt>llvm/test</tt>):</p>
 
 <div class="doc_code">
@@ -232,8 +204,8 @@ subdirectory (relative to <tt>llvm/test</tt>):</p>
 must have run the complete testsuite before you can specify a
 subdirectory.</b></p>
 
-<p>To run only a single test, set TESTONE to its path (relative to
-<tt>llvm/test</tt>) and make the check-one target:</p>
+<p>To run only a single test, set <tt>TESTONE</tt> to its path (relative to
+<tt>llvm/test</tt>) and make the <tt>check-one</tt> target:</p>
 
 <div class="doc_code">
 <pre>
@@ -241,8 +213,17 @@ subdirectory.</b></p>
 </pre>
 </div>
 
+<p>To run the tests with Valgrind (Memcheck by default), just append
+<tt>VG=1</tt> to the commands above, e.g.:</p>
+
+<div class="doc_code">
+<pre>
+% gmake check VG=1
+</pre>
+</div>
+
 <!-- _______________________________________________________________________ -->
-<div class="doc_subsection"><a name="quickllvmtest"><tt>llvm-test</tt> tests</a></div>
+<div class="doc_subsection"><a name="quicktestsuite">Test suite</a></div>
 <!-- _______________________________________________________________________ -->
 
 <p>To run the comprehensive test suite (tests that compile and execute whole 
@@ -251,20 +232,28 @@ programs), first checkout and setup the <tt>test-suite</tt> module:</p>
 <div class="doc_code">
 <pre>
 % cd llvm/projects
-% svn co http://llvm.org/svn/llvm-project/test-suite/trunk llvm-test
+% svn co http://llvm.org/svn/llvm-project/test-suite/trunk test-suite
 % cd ..
 % ./configure --with-llvmgccdir=$LLVM_GCC_DIR
 </pre>
-<p>where <tt>$LLVM_GCC_DIR</tt> is the directory where you <em>installed</em>
-llvm-gcc, not it's src or obj dir.</p>
 </div>
 
-<p>Then, run the entire test suite by running make in the <tt>llvm-test</tt>
+<p>where <tt>$LLVM_GCC_DIR</tt> is the directory where
+you <em>installed</em> llvm-gcc, not it's src or obj
+dir. The <tt>--with-llvmgccdir</tt> option assumes that
+the <tt>llvm-gcc-4.2</tt> module was configured with
+<tt>--program-prefix=llvm-</tt>, and therefore that the C and C++
+compiler drivers are called <tt>llvm-gcc</tt> and <tt>llvm-g++</tt>
+respectively.  If this is not the case,
+use <tt>--with-llvmgcc</tt>/<tt>--with-llvmgxx</tt> to specify each
+executable's location.</p>
+
+<p>Then, run the entire test suite by running make in the <tt>test-suite</tt>
 directory:</p>
 
 <div class="doc_code">
 <pre>
-% cd projects/llvm-test
+% cd projects/test-suite
 % gmake
 </pre>
 </div>
@@ -274,19 +263,19 @@ let it generate a report by running:</p>
 
 <div class="doc_code">
 <pre>
-% cd projects/llvm-test
+% cd projects/test-suite
 % gmake TEST=nightly report report.html
 </pre>
 </div>
 
 <p>Any of the above commands can also be run in a subdirectory of
-<tt>projects/llvm-test</tt> to run the specified test only on the programs in
+<tt>projects/test-suite</tt> to run the specified test only on the programs in
 that subdirectory.</p>
 
 </div>
 
 <!--=========================================================================-->
-<div class="doc_section"><a name="dgstructure">DejaGNU Structure</a></div>
+<div class="doc_section"><a name="dgstructure">DejaGNU structure</a></div>
 <!--=========================================================================-->
 <div class="doc_text">
   <p>The LLVM DejaGNU tests are driven by DejaGNU together with GNU Make and are
@@ -313,7 +302,7 @@ that subdirectory.</p>
 </div>
 
 <!-- _______________________________________________________________________ -->
-<div class="doc_subsection"><a name="customdg">Writing new DejaGNU tests</a></div>
+<div class="doc_subsection"><a name="dgcustom">Writing new DejaGNU tests</a></div>
 <!-- _______________________________________________________________________ -->
 <div class="doc_text">
   <p>The DejaGNU structure is very simple, but does require some information to 
@@ -452,10 +441,265 @@ that subdirectory.</p>
 </pre>
 </div>
 
+<p>If your system includes GNU <tt>grep</tt>, make sure
+that <tt>GREP_OPTIONS</tt> is not set in your environment. Otherwise,
+you may get invalid results (both false positives and false
+negatives).</p>
+
+</div>
+
+<!-- _______________________________________________________________________ -->
+<div class="doc_subsection"><a name="FileCheck">The FileCheck utility</a></div>
+<!-- _______________________________________________________________________ -->
+
+<div class="doc_text">
+
+<p>A powerful feature of the RUN: lines is that it allows any arbitrary commands
+   to be executed as part of the test harness.  While standard (portable) unix
+   tools like 'grep' work fine on run lines, as you see above, there are a lot
+   of caveats due to interaction with Tcl syntax, and we want to make sure the
+   run lines are portable to a wide range of systems.  Another major problem is
+   that grep is not very good at checking to verify that the output of a tools
+   contains a series of different output in a specific order.  The FileCheck
+   tool was designed to help with these problems.</p>
+
+<p>FileCheck (whose basic command line arguments are described in <a
+   href="http://llvm.org/cmds/FileCheck.html">the FileCheck man page</a> is
+   designed to read a file to check from standard input, and the set of things
+   to verify from a file specified as a command line argument.  A simple example
+   of using FileCheck from a RUN line looks like this:</p>
+   
+<div class="doc_code">
+<pre>
+; RUN: llvm-as &lt; %s | llc -march=x86-64 | <b>FileCheck %s</b>
+</pre>
+</div>
+
+<p>This syntax says to pipe the current file ("%s") 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 "%s").  To see how this works,
+lets look at the rest of the .ll file (after the RUN line):</p>
+
+<div class="doc_code">
+<pre>
+define void @sub1(i32* %p, i32 %v) {
+entry:
+; <b>CHECK: sub1:</b>
+; <b>CHECK: subl</b>
+        %0 = tail call i32 @llvm.atomic.load.sub.i32.p0i32(i32* %p, i32 %v)
+        ret void
+}
+
+define void @inc4(i64* %p) {
+entry:
+; <b>CHECK: inc4:</b>
+; <b>CHECK: incq</b>
+        %0 = tail call i64 @llvm.atomic.load.add.i64.p0i64(i64* %p, i64 1)
+        ret void
+}
+</pre>
+</div>
+
+<p>Here you can see some "CHECK:" 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 "CHECK:" lines specify.</p>
+
+<p>The syntax of the CHECK: 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 CHECK: line is required to match some thing in the test file exactly.</p>
+
+<p>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 "sub1:" and "inc4:" labels, it will not match unless there
+is a "subl" in between those labels.  If it existed somewhere else in the file,
+that would not count: "grep subl" matches if subl exists anywhere in the
+file.</p>
+
+</div>
+
+<!-- _______________________________________________________________________ -->
+<div class="doc_subsubsection"><a 
+name="FileCheck-check-prefix">The FileCheck -check-prefix option</a></div>
+
+<div class="doc_text">
+
+<p>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:</p>
+
+<div class="doc_code">
+<pre>
+; RUN: llvm-as &lt; %s | llc -mtriple=i686-apple-darwin9 -mattr=sse41 \
+; RUN:              | <b>FileCheck %s -check-prefix=X32</b>
+; RUN: llvm-as &lt; %s | llc -mtriple=x86_64-apple-darwin9 -mattr=sse41 \
+; RUN:              | <b>FileCheck %s -check-prefix=X64</b>
+
+define &lt;4 x i32&gt; @pinsrd_1(i32 %s, &lt;4 x i32&gt; %tmp) nounwind {
+        %tmp1 = insertelement &lt;4 x i32&gt; %tmp, i32 %s, i32 1
+        ret &lt;4 x i32&gt; %tmp1
+; <b>X32:</b> pinsrd_1:
+; <b>X32:</b>    pinsrd $1, 4(%esp), %xmm0
+
+; <b>X64:</b> pinsrd_1:
+; <b>X64:</b>    pinsrd $1, %edi, %xmm0
+}
+</pre>
+</div>
+
+<p>In this case, we're testing that we get the expected code generation with
+both 32-bit and 64-bit code generation.</p>
+
+</div>
+
+<!-- _______________________________________________________________________ -->
+<div class="doc_subsubsection"><a 
+name="FileCheck-CHECK-NEXT">The "CHECK-NEXT:" directive</a></div>
+
+<div class="doc_text">
+
+<p>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 CHECK: and CHECK-NEXT: directives to specify this.  If
+you specified a custom check prefix, just use "&lt;PREFIX&gt;-NEXT:".  For
+example, something like this works as you'd expect:</p>
+
+<div class="doc_code">
+<pre>
+define void @t2(&lt;2 x double&gt;* %r, &lt;2 x double&gt;* %A, double %B) {
+       %tmp3 = load &lt;2 x double&gt;* %A, align 16
+       %tmp7 = insertelement &lt;2 x double&gt; undef, double %B, i32 0
+       %tmp9 = shufflevector &lt;2 x double&gt; %tmp3,
+                              &lt;2 x double&gt; %tmp7,
+                              &lt;2 x i32&gt; &lt; i32 0, i32 2 &gt;
+       store &lt;2 x double&gt; %tmp9, &lt;2 x double&gt;* %r, align 16
+       ret void
+        
+; <b>CHECK:</b> t2:
+; <b>CHECK:</b>        movl    8(%esp), %eax
+; <b>CHECK-NEXT:</b>   movapd  (%eax), %xmm0
+; <b>CHECK-NEXT:</b>   movhpd  12(%esp), %xmm0
+; <b>CHECK-NEXT:</b>   movl    4(%esp), %eax
+; <b>CHECK-NEXT:</b>   movapd  %xmm0, (%eax)
+; <b>CHECK-NEXT:</b>   ret
+}
+</pre>
+</div>
+
+<p>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.</p>
+
 </div>
 
 <!-- _______________________________________________________________________ -->
-<div class="doc_subsection"><a name="dgvars">Variables and substitutions</a></div>
+<div class="doc_subsubsection"><a 
+name="FileCheck-CHECK-NOT">The "CHECK-NOT:" directive</a></div>
+
+<div class="doc_text">
+
+<p>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:</p>
+
+<div class="doc_code">
+<pre>
+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
+; <b>CHECK:</b> @coerce_offset0
+; <b>CHECK-NOT:</b> load
+; <b>CHECK:</b> ret i8
+}
+</pre>
+</div>
+
+</div>
+
+<!-- _______________________________________________________________________ -->
+<div class="doc_subsubsection"><a 
+name="FileCheck-Matching">FileCheck Pattern Matching Syntax</a></div>
+
+<div class="doc_text">
+
+<p>The CHECK: 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: <b>{{yourregex}}</b>.  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:</p>
+
+<div class="doc_code">
+<pre>
+; CHECK: movhpd        <b>{{[0-9]+}}</b>(%esp), <b>{{%xmm[0-7]}}</b>
+</pre>
+</div>
+
+<p>In this case, any offset from the ESP register will be allowed, and any xmm
+register will be allowed.</p>
+
+<p>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
+<b>{{[{][{]}}</b> as your pattern.</p>
+
+</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>[[REGISTER:%[a-z]+]]</b>
+; CHECK:    andw       {{.*}}<b>[[REGISTER]]</b>
+</pre>
+</div>
+
+<p>The first check line matches a regex (<tt>%[a-z]+</tt>) and captures it into
+the variables "REGISTER".  The second line verifies that whatever is in REGISTER
+occurs later in the file after an "andw".  FileCheck variable references are
+always contained in <tt>[[ ]]</tt> pairs, are named, and their names can be
+formed with the regex "<tt>[a-zA-Z][a-zA-Z0-9]*</tt>".  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
+substitutions</a></div>
 <!-- _______________________________________________________________________ -->
 <div class="doc_text">
   <p>With a RUN line there are a number of substitutions that are permitted. In
@@ -509,14 +753,6 @@ that subdirectory.</p>
     <dd>The target triplet that corresponds to the current host machine (the one
     running the test cases). This should probably be called "host".<dd>
 
-    <dt><b>prcontext</b> (%prcontext)</dt>
-    <dd>Path to the prcontext tcl script that prints some context around a 
-    line that matches a pattern. This isn't strictly necessary as the test suite
-    is run with its PATH altered to include the test/Scripts directory where
-    the prcontext script is located. Note that this script is similar to 
-    <tt>grep -C</tt> but you should use the <tt>prcontext</tt> script because
-    not all platforms support <tt>grep -C</tt>.</dd>
-
     <dt><b>llvmgcc</b> (%llvmgcc)</dt>
     <dd>The full path to the <tt>llvm-gcc</tt> executable as specified in the
     configured LLVM environment</dd>
@@ -624,7 +860,7 @@ that subdirectory.</p>
 </div>
 
 <!--=========================================================================-->
-<div class="doc_section"><a name="llvmteststructure"><tt>llvm-test</tt> 
+<div class="doc_section"><a name="testsuitestructure">Test suite
 Structure</a></div>
 <!--=========================================================================-->
 
@@ -669,7 +905,7 @@ go here.</p></li>
 <p>The External directory contains Makefiles for building code that is external
 to (i.e., not distributed with) LLVM.  The most prominent members of this
 directory are the SPEC 95 and SPEC 2000 benchmark suites. The <tt>External</tt>
-directory does not contain these actual tests,but only the Makefiles that know
+directory does not contain these actual tests, but only the Makefiles that know
 how to properly compile these programs from somewhere else. The presence and
 location of these external programs is configured by the llvm-test
 <tt>configure</tt> script.</p></li>
@@ -684,7 +920,7 @@ others are features that we haven't added yet (or may never add).  In DejaGNU,
 the result for such tests will be XFAIL (eXpected FAILure).  In this way, you
 can tell the difference between an expected and unexpected failure.</p>
 
-<p>The tests in <tt>llvm-test</tt> have no such feature at this time. If the
+<p>The tests in the test suite have no such feature at this time. If the
 test passes, only warnings and other miscellaneous output will be generated.  If
 a test fails, a large &lt;program&gt; FAILED message will be displayed.  This
 will help you separate benign warnings from actual test failures.</p>
@@ -692,7 +928,7 @@ will help you separate benign warnings from actual test failures.</p>
 </div>
 
 <!--=========================================================================-->
-<div class="doc_section"><a name="runllvmtest">Running the LLVM Tests</a></div>
+<div class="doc_section"><a name="testsuiterun">Running the test suite</a></div>
 <!--=========================================================================-->
 
 <div class="doc_text">
@@ -701,85 +937,97 @@ will help you separate benign warnings from actual test failures.</p>
 <i>are not</i> executed inside of the LLVM source tree. This is because the
 test suite creates temporary files during execution.</p>
 
-<p>To run the <tt>llvm-test</tt> suite, you need to use the following steps:</p>
+<p>To run the test suite, you need to use the following steps:</p>
 
 <ol>
-  <li><tt>cd</tt> into the <tt>llvm/projects</tt> directory</li>
+  <li><tt>cd</tt> into the <tt>llvm/projects</tt> directory in your source tree.
+  </li>
 
   <li><p>Check out the <tt>test-suite</tt> module with:</p>
 
 <div class="doc_code">
 <pre>
-% svn co http://llvm.org/svn/llvm-project/test-suite/trunk llvm-test
+% svn co http://llvm.org/svn/llvm-project/test-suite/trunk test-suite
 </pre>
 </div>
-
-      <p>This will get the test suite into <tt>llvm/projects/llvm-test</tt></p>
-
-  <li><p>Configure the test suite using llvm configure. This will automatically configure llvm-test. 
-         You must do it from the top level otherwise llvm-gcc will not be set which is required to 
-        run llvm-test:</p>
+    <p>This will get the test suite into <tt>llvm/projects/test-suite</tt>.</p>
+  </li>
+  <li><p>Configure and build <tt>llvm</tt>.</p></li>
+  <li><p>Configure and build <tt>llvm-gcc</tt>.</p></li>
+  <li><p>Install <tt>llvm-gcc</tt> somewhere.</p></li>
+  <li><p><em>Re-configure</em> <tt>llvm</tt> from the top level of
+      each build tree (LLVM object directory tree) in which you want
+      to run the test suite, just as you do before building LLVM.</p>
+    <p>During the <em>re-configuration</em>, you must either: (1)
+      have <tt>llvm-gcc</tt> you just built in your path, or (2)
+      specify the directory where your just-built <tt>llvm-gcc</tt> is
+      installed using <tt>--with-llvmgccdir=$LLVM_GCC_DIR</tt>.</p>
+    <p>You must also tell the configure machinery that the test suite
+      is available so it can be configured for your build tree:</p>
 <div class="doc_code">
 <pre>
-% cd $LLVM_OBJ_ROOT ; $LLVM_SRC_ROOT/configure --with-llvmgccdir=$LLVM_GCC_DIR
+% cd $LLVM_OBJ_ROOT ; $LLVM_SRC_ROOT/configure [--with-llvmgccdir=$LLVM_GCC_DIR]
 </pre>
 </div>
-    <p>Note that that <tt>$LLVM_GCC_DIR</tt> is the directory where you
-    <em>installed</em> llvm-gcc, not its src or obj directory.</p>
+    <p>[Remember that <tt>$LLVM_GCC_DIR</tt> is the directory where you
+    <em>installed</em> llvm-gcc, not its src or obj directory.]</p>
   </li>
 
-  <li><p>Change back to the <tt>llvm/projects/llvm-test</tt> directory you created before
-  and run <tt>gmake</tt> (or just "<tt>make</tt>" on systems where GNU make is
-  the default, such as linux.</p></li>
+  <li><p>You can now run the test suite from your build tree as follows:</p>
+<div class="doc_code">
+<pre>
+% cd $LLVM_OBJ_ROOT/projects/test-suite
+% make
+</pre>
+</div>
+  </li>
 </ol>
 <p>Note that the second and third steps only need to be done once. After you
 have the suite checked out and configured, you don't need to do it again (unless
 the test code or configure script changes).</p>
 
+</div>
+
 <!-- _______________________________________________________________________ -->
 <div class="doc_subsection">
-<a name="externaltests">Configuring external tests</a></div>
+<a name="testsuiteexternal">Configuring External Tests</a></div>
 <!-- _______________________________________________________________________ -->
 
 <div class="doc_text">
-<p>Note, when configuring the <tt>llvm-test</tt> module, you might want to
-specify the following configuration options:</p>
+<p>In order to run the External tests in the <tt>test-suite</tt>
+  module, you must specify <i>--with-externals</i>.  This
+  must be done during the <em>re-configuration</em> step (see above),
+  and the <tt>llvm</tt> re-configuration must recognize the
+  previously-built <tt>llvm-gcc</tt>.  If any of these is missing or
+  neglected, the External tests won't work.</p>
 <dl>
-  <dt><i>--enable-spec2000</i>
-  <dt><i>--enable-spec2000=&lt;<tt>directory</tt>&gt;</i>
-  <dd>
-    Enable the use of SPEC2000 when testing LLVM.  This is disabled by default
-    (unless <tt>configure</tt> finds SPEC2000 installed).  By specifying
-    <tt>directory</tt>, you can tell configure where to find the SPEC2000
-    benchmarks.  If <tt>directory</tt> is left unspecified, <tt>configure</tt>
-    uses the default value
-    <tt>/home/vadve/shared/benchmarks/speccpu2000/benchspec</tt>.
-    <p>
-
-  <dt><i>--enable-spec95</i>
-  <dt><i>--enable-spec95=&lt;<tt>directory</tt>&gt;</i>
-  <dd>
-    Enable the use of SPEC95 when testing LLVM.  It is similar to the
-    <i>--enable-spec2000</i> option.
-    <p>
-
-  <dt><i>--enable-povray</i>
-  <dt><i>--enable-povray=&lt;<tt>directory</tt>&gt;</i>
-  <dd>
-    Enable the use of Povray as an external test.  Versions of Povray written
-    in C should work.  This option is similar to the <i>--enable-spec2000</i>
-    option.
+<dt><i>--with-externals</i></dt>
+<dt><i>--with-externals=&lt;<tt>directory</tt>&gt;</i></dt>
 </dl>
+  This tells LLVM where to find any external tests.  They are expected to be
+  in specifically named subdirectories of &lt;<tt>directory</tt>&gt;.
+  If <tt>directory</tt> is left unspecified,
+  <tt>configure</tt> uses the default value
+  <tt>/home/vadve/shared/benchmarks/speccpu2000/benchspec</tt>.
+  Subdirectory names known to LLVM include:
+  <dl>
+  <dt>spec95</dt>
+  <dt>speccpu2000</dt>
+  <dt>speccpu2006</dt>
+  <dt>povray31</dt>
+  </dl>
+  Others are added from time to time, and can be determined from 
+  <tt>configure</tt>.
 </div>
 
 <!-- _______________________________________________________________________ -->
 <div class="doc_subsection">
-<a name="llvmtesttests">Running different tests</a></div>
+<a name="testsuitetests">Running different tests</a></div>
 <!-- _______________________________________________________________________ -->
 <div class="doc_text">
-<p>In addition to the regular "whole program"  tests, the <tt>llvm-test</tt>
+<p>In addition to the regular "whole program" tests, the <tt>test-suite</tt>
 module also provides a mechanism for compiling the programs in different ways.
-If the variable TEST is defined on the gmake command line, the test system will
+If the variable TEST is defined on the <tt>gmake</tt> command line, the test system will
 include a Makefile named <tt>TEST.&lt;value of TEST variable&gt;.Makefile</tt>.
 This Makefile can modify build rules to yield different results.</p>
 
@@ -797,7 +1045,7 @@ LLVM.</p>
 
 <!-- _______________________________________________________________________ -->
 <div class="doc_subsection">
-<a name="llvmtestoutput">Generating test output</a></div>
+<a name="testsuiteoutput">Generating test output</a></div>
 <!-- _______________________________________________________________________ -->
 <div class="doc_text">
   <p>There are a number of ways to run the tests and generate output. The most
@@ -828,12 +1076,12 @@ LLVM.</p>
 
 <!-- _______________________________________________________________________ -->
 <div class="doc_subsection">
-<a name="customtest">Writing custom tests for llvm-test</a></div>
+<a name="testsuitecustom">Writing custom tests for the test suite</a></div>
 <!-- _______________________________________________________________________ -->
 
 <div class="doc_text">
 
-<p>Assuming you can run llvm-test, (e.g. "<tt>gmake TEST=nightly report</tt>"
+<p>Assuming you can run the test suite, (e.g. "<tt>gmake TEST=nightly report</tt>"
 should work), it is really easy to run optimizations or code generator
 components against every program in the tree, collecting statistics or running
 custom checks for correctness.  At base, this is how the nightly tester works,
@@ -846,10 +1094,10 @@ will tally counts of things you care about.</p>
 
 <p>Following this, you can set up a test and a report that collects these and
 formats them for easy viewing.  This consists of two files, an
-"<tt>llvm-test/TEST.XXX.Makefile</tt>" fragment (where XXX is the name of your
+"<tt>test-suite/TEST.XXX.Makefile</tt>" fragment (where XXX is the name of your
 test) and an "<tt>llvm-test/TEST.XXX.report</tt>" file that indicates how to
 format the output into a table.  There are many example reports of various
-levels of sophistication included with llvm-test, and the framework is very
+levels of sophistication included with the test suite, and the framework is very
 general.</p>
 
 <p>If you are interested in testing an optimization pass, check out the
@@ -857,7 +1105,7 @@ general.</p>
 
 <div class="doc_code">
 <pre>
-% cd llvm/projects/llvm-test/MultiSource/Benchmarks  # or some other level
+% cd llvm/projects/test-suite/MultiSource/Benchmarks  # or some other level
 % make TEST=libcalls report
 </pre>
 </div>
@@ -888,7 +1136,7 @@ Prolangs-C/bison/mybison              | 74    | *     |
 You can also use the "TEST=libcalls report.html" target to get the table in HTML
 form, similarly for report.csv and report.tex.</p>
 
-<p>The source for this is in llvm-test/TEST.libcalls.*.  The format is pretty
+<p>The source for this is in test-suite/TEST.libcalls.*.  The format is pretty
 simple: the Makefile indicates how to run the test (in this case, 
 "<tt>opt -simplify-libcalls -stats</tt>"), and the report contains one line for
 each column of the output.  The first value is the header for the column and the
@@ -963,9 +1211,9 @@ know. Thanks!</p>
 <hr>
 <address>
   <a href="http://jigsaw.w3.org/css-validator/check/referer"><img
-  src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!"></a>
+  src="http://jigsaw.w3.org/css-validator/images/vcss-blue" alt="Valid CSS"></a>
   <a href="http://validator.w3.org/check/referer"><img
-  src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!"></a>
+  src="http://www.w3.org/Icons/valid-html401-blue" alt="Valid HTML 4.01"></a>
 
   John T. Criswell, Reid Spencer, and Tanya Lattner<br>
   <a href="http://llvm.org">The LLVM Compiler Infrastructure</a><br>