Fix spelling and grammar in a comment.
[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
8 // TOFIX: Add an explicit option list for aliases and things like this.
9 def Options : OptionList<[
10 (switch_option "E",
11     (help "Stop after the preprocessing stage, do not run the compiler"))
12 ]>;
13
14 class clang_base<string language, dag cmdline> : Tool<
15 [(in_language language),
16  (out_language "llvm-bitcode"),
17  (output_suffix "bc"),
18  (cmd_line cmdline),
19  (switch_option "E", (stop_compilation), (output_suffix "i")),
20  (sink)
21 ]>;
22
23 def clang_c : clang_base<"c",
24 (case
25 (switch_on "E"),
26     (case
27     (not_empty "o"),
28         "clang -E -x c $INFILE -o $OUTFILE",
29     (default),
30         "clang -E -x c $INFILE"),
31 (default),
32     "clang -emit-llvm-bc -x c $INFILE -o $OUTFILE")>;
33
34 def clang_cpp : clang_base<"c++",
35 (case
36 (switch_on "E"),
37     (case
38     (not_empty "o"),
39         "clang -E -x c++ $INFILE -o $OUTFILE",
40     (default),
41         "clang -E -x c++ $INFILE"),
42 (default),
43     "clang -emit-llvm-bc -x c++ $INFILE -o $OUTFILE")>;
44
45 def clang_objective_c : clang_base<"objective-c",
46 (case
47 (switch_on "E"),
48     (case
49     (not_empty "o"),
50         "clang -E -x objective-c $INFILE -o $OUTFILE",
51     (default),
52         "clang -E -x objective-c $INFILE"),
53 (default),
54     "clang -emit-llvm-bc -x objective-c $INFILE -o $OUTFILE")>;
55
56 // Default linker
57 def llvm_ld : Tool<
58 [(in_language "llvm-bitcode"),
59  (out_language "executable"),
60  (output_suffix "out"),
61  (cmd_line "llvm-ld -native -disable-internalize $INFILE -o $OUTFILE"),
62  (prefix_list_option "L", (forward), (help "Specify a library search path")),
63  (join)
64 ]>;
65
66 // Language map
67
68 def LanguageMap : LanguageMap<
69     [LangToSuffixes<"c++", ["cc", "cp", "cxx", "cpp", "CPP", "c++", "C"]>,
70      LangToSuffixes<"c", ["c"]>,
71      LangToSuffixes<"objective-c", ["m"]>,
72      LangToSuffixes<"c-cpp-output", ["i"]>,
73      LangToSuffixes<"objective-c-cpp-output", ["mi"]>
74      ]>;
75
76 // Compilation graph
77
78 def CompilationGraph : CompilationGraph<[
79     Edge<root, clang_c>,
80     Edge<root, clang_cpp>,
81     Edge<root, clang_objective_c>,
82     Edge<clang_c, llvm_ld>,
83     Edge<clang_cpp, llvm_ld>,
84     Edge<clang_objective_c, llvm_ld>
85     ]>;
86