-E should print to stdout.
[oota-llvm.git] / tools / llvmc2 / examples / Clang.td
1 // A (first stab at a) replacement for the Clang's ccc script.
2 // To compile, use this command:
3 //    make TOOLNAME=ccc GRAPH=examples/Clang.td
4
5 include "Common.td"
6
7 def clang : Tool<
8 [(in_language ["c", "c++", "objective-c"]),
9  (out_language "llvm-bitcode"),
10  (output_suffix "bc"),
11  // TOFIX: We should be able to test the language of the input file
12  (cmd_line (case (switch_on "E"), "clang -E $INFILE",
13                  (default), "clang -emit-llvm-bc $INFILE -o $OUTFILE")),
14  (switch_option "E", (stop_compilation), (output_suffix "i"),
15    (help "Stop after the preprocessing stage, do not run the compiler")),
16  (sink)
17 ]>;
18
19 // Default linker
20 def llvm_ld : Tool<
21 [(in_language "llvm-bitcode"),
22  (out_language "executable"),
23  (output_suffix "out"),
24  (cmd_line "llvm-ld -native -disable-internalize $INFILE -o $OUTFILE"),
25  (prefix_list_option "L", (forward), (help "Specify a library search path")),
26  (join)
27 ]>;
28
29 // Language map
30
31 def LanguageMap : LanguageMap<
32     [LangToSuffixes<"c++", ["cc", "cp", "cxx", "cpp", "CPP", "c++", "C"]>,
33      LangToSuffixes<"c", ["c"]>,
34      LangToSuffixes<"objective-c", ["m"]>,
35      LangToSuffixes<"c-cpp-output", ["i"]>,
36      LangToSuffixes<"objective-c-cpp-output", ["mi"]>
37      ]>;
38
39 // Compilation graph
40
41 def CompilationGraph : CompilationGraph<[
42     Edge<root, clang>,
43     Edge<clang, llvm_ld>
44     ]>;
45