aboutsummaryrefslogtreecommitdiffstats
path: root/tools/llvmc2/examples/Clang.td
blob: 45ee63891c8a58ae3a2a677c3af26102a66e9a1f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// A (first stab at a) replacement for the Clang's ccc script.
// To compile, use this command:
//    make TOOLNAME=ccc GRAPH=examples/Clang.td

include "Common.td"

// TOFIX: It should be possible to use a string list in the 'in_language'
// tool property. There should be also an 'in_language' test in the
// 'case' construct.

def clang : Tool<
[(in_language "c"),
 (out_language "llvm-bitcode"),
 (output_suffix "bc"),
 (cmd_line (case (switch_on "E"), "clang -E $INFILE -o $OUTFILE",
                 (default), "clang -emit-llvm-bc $INFILE -o $OUTFILE")),
 (switch_option "E", (stop_compilation), (output_suffix "i"),
   (help "Stop after the preprocessing stage, do not run the compiler")),
 (sink)
]>;

// Default linker
def llvm_ld : Tool<
[(in_language "llvm-bitcode"),
 (out_language "executable"),
 (output_suffix "out"),
 (cmd_line "llvm-ld -native -disable-internalize $INFILE -o $OUTFILE"),
 (prefix_list_option "L", (forward), (help "Specify a library search path")),
 (join)
]>;

// Language map

def LanguageMap : LanguageMap<
    [LangToSuffixes<"c++", ["cc", "cp", "cxx", "cpp", "CPP", "c++", "C"]>,
     LangToSuffixes<"c", ["c"]>,
     LangToSuffixes<"objective-c", ["m"]>,
     LangToSuffixes<"c-cpp-output", ["i"]>,
     LangToSuffixes<"objective-c-cpp-output", ["mi"]>
     ]>;

// Compilation graph

def CompilationGraph : CompilationGraph<[
    Edge<root, clang>,
    Edge<clang, llvm_ld>
    ]>;