#!/usr/bin/perl -w
# This tiny little script, which should be run from the clang
-# directory (with clang-cc in your patch), tries to take each
+# directory (with clang in your patch), tries to take each
# compilable Clang test and build a PCH file from that test, then read
# and dump the contents of the PCH file just created.
use POSIX;
@files = `ls test/*/*.$suffix`;
foreach $file (@files) {
chomp($file);
- my $code = system("clang-cc -fsyntax-only -x $language $file > /dev/null 2>&1");
+ my $code = system("clang- -fsyntax-only -x $language $file > /dev/null 2>&1");
if ($code == 0) {
print(".");
- $code = system("clang-cc -emit-pch -x $language -o $file.pch $file > /dev/null 2>&1");
+ $code = system("clang -cc1 -emit-pch -x $language -o $file.pch $file > /dev/null 2>&1");
if ($code == 0) {
- $code = system("clang-cc -include-pch $file.pch -x $language -ast-dump /dev/null > /dev/null 2>&1");
+ $code = system("clang -cc1 -include-pch $file.pch -x $language -ast-dump /dev/null > /dev/null 2>&1");
if ($code == 0) {
$passed++;
} elsif (($code & 0xFF) == SIGINT) {
</ul>
<li>Try it out (assuming you add llvm/Debug/bin to your path):</li>
<ul>
- <li><tt>clang-cc --help</tt></li>
- <li><tt>clang-cc file.c -fsyntax-only</tt> (check for correctness)</li>
- <li><tt>clang-cc file.c -ast-dump</tt> (internal debug dump of ast)</li>
- <li><tt>clang-cc file.c -ast-view</tt> (<a
- href="http://llvm.org/docs/ProgrammersManual.html#ViewGraph">set up graphviz
- and rebuild llvm first</a>)</li>
- <li><tt>clang-cc file.c -emit-llvm</tt> (print out unoptimized llvm code)</li>
- <li><tt>clang-cc file.c -emit-llvm -o - | llvm-as | opt -std-compile-opts |
- llvm-dis</tt> (print out optimized llvm code)</li>
- <li><tt>clang-cc file.c -emit-llvm -o - | llvm-as | opt -std-compile-opts | llc
- > file.s</tt> (output native machine code)</li>
+ <li><tt>clang --help</tt></li>
+ <li><tt>clang file.c -fsyntax-only</tt> (check for correctness)</li>
+ <li><tt>clang file.c -S -emit-llvm -o -</tt> (print out unoptimized llvm code)</li>
+ <li><tt>clang file.c -S -emit-llvm -o - -O3</tt></li>
+ <li><tt>clang file.c -S -O3 -o -</tt> (output native machine code)</li>
</ul>
- <p><em>Note</em>: Here <tt>clang-cc</tt> is the "low-level" frontend
- executable that is similar in purpose to <tt>cc1</tt>. Clang also has a <a
- href="#driver">high-level compiler driver</a> that acts as a drop-in
- replacement for <tt>gcc</tt>.
</ol>
<p>Note that the C front-end uses LLVM, but does not depend on llvm-gcc. If you
<li>Build Clang:</li>
<ul>
<li>Open LLVM.sln in Visual Studio.</li>
- <li>Build the "clang-cc" project for just the compiler front end.
- Alternatively, build the "clang" project for the compiler driver
- (note that the driver is currently broken on Windows),
- or the "ALL_BUILD" project to build everything, including tools.</li>
+ <li>Build the "clang" project for just the compiler driver and front end, or
+ the "ALL_BUILD" project to build everything, including tools.</li>
</ul>
<li>Try it out (assuming you added llvm/debug/bin to your path). (See the
running examples from above.)</li>
to the latest code base, use the <tt>svn update</tt> command in both the
llvm and llvm\tools\clang directories, as they are separate repositories.</p>
-<a name="driver"><h2>High-Level Compiler Driver (Drop-in Substitute for GCC)</h2></a>
+<a name="driver"><h2>Clang Compiler Driver (Drop-in Substitute for GCC)</h2></a>
-<p>While the <tt>clang-cc</tt> executable is a low-level frontend executable
-that can perform code generation, program analysis, and other actions, it is not
-designed to be a drop-in replacement for GCC's <tt>cc</tt>. For this purpose,
-use the high-level driver, aptly named <tt>clang</tt>. Here are some
-examples of how to use the high-level driver:
+<p>The <tt>clang</tt> tool is the compiler driver and front-end, which is
+designed to be a drop-in replacement for the <tt>gcc</tt> command. Here are
+some examples of how to use the high-level driver:
</p>
<pre class="code">
<h2>Examples of using Clang</h2>
-<p>The high-level driver <tt>clang</tt> is designed to understand most of GCC's
-options, and the lower-level <tt>clang-cc</tt> executable also directly takes
-many of GCC's options. You can see which options <tt>clang-cc</tt> accepts with
-'<tt>clang-cc --help</tt>'. Here are a few examples of using <tt>clang</tt> and
-<tt>clang-cc</tt>:</p>
-
<!-- Thanks to
http://shiflett.org/blog/2006/oct/formatting-and-highlighting-php-code-listings
Site suggested using pre in CSS, but doesn't work in IE, so went for the <pre>
<h3>Pretty printing from the AST:</h3>
+<p>Note, the <tt>-cc1</tt> argument indicates the the compiler front-end, and
+not the driver, should be run. The compiler front-end has several additional
+Clang specific features which are not exposed through the GCC compatible driver
+interface.</p>
+
<pre class="code">
-$ <b>clang-cc ~/t.c -ast-print</b>
+$ <b>clang -cc1 ~/t.c -ast-print</b>
typedef float V __attribute__(( vector_size(16) ));
V foo(V a, V b) {
return a + b * a;
<h3>Code generation with LLVM:</h3>
<pre class="code">
-$ <b>clang-cc ~/t.c -emit-llvm -o - | llvm-as | opt -std-compile-opts | llvm-dis</b>
+$ <b>clang ~/t.c -S -emit-llvm -o -</b>
define <4 x float> @foo(<4 x float> %a, <4 x float> %b) {
entry:
%mul = mul <4 x float> %b, %a
%add = add <4 x float> %mul, %a
ret <4 x float> %add
}
-$ <b>clang-cc ~/t.c -emit-llvm -o - | llvm-as | opt -std-compile-opts | llc -march=ppc32 -mcpu=g5</b>
-..
-_foo:
- vmaddfp v2, v3, v2, v2
- blr
-$ <b>clang-cc ~/t.c -emit-llvm -o - | llvm-as | opt -std-compile-opts | llc -march=x86 -mcpu=yonah</b>
-..
+$ <b>clang -fomit-frame-pointer -O3 -S -o - t.c</b> <i># On x86_64</i>
+...
_foo:
- mulps %xmm0, %xmm1
- addps %xmm0, %xmm1
- movaps %xmm1, %xmm0
- ret
+Leh_func_begin1:
+ mulps %xmm0, %xmm1
+ addps %xmm1, %xmm0
+ ret
+Leh_func_end1:
</pre>
</div>