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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
|
//===- Tools.td - Tools description for LLVMC2 -------------*- tablegen -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file contains descriptions of the various build tools run by llvmc2.
//
//===----------------------------------------------------------------------===//
def llvm_gcc_c : Tool<
[(in_language "c"),
(out_language "llvm-bitcode"),
(output_suffix "bc"),
(cmd_line (case
(switch_on "E"),
(case (not_empty "o"),
"llvm-gcc -E -x c++ $INFILE -o $OUTFILE",
(default),
"llvm-gcc -E -x c++ $INFILE"),
(default),
"llvm-gcc -c -x c $INFILE -o $OUTFILE -emit-llvm")),
(switch_option "E", (stop_compilation),
(help "Stop after the preprocessing stage, do not run the compiler")),
(sink)
]>;
def llvm_gcc_cpp : Tool<
[(in_language "c++"),
(out_language "llvm-bitcode"),
(output_suffix "bc"),
(cmd_line (case
(switch_on "E"),
(case (not_empty "o"),
"llvm-g++ -E -x c++ $INFILE -o $OUTFILE",
(default),
"llvm-g++ -E -x c++ $INFILE"),
(default),
"llvm-g++ -c -x c++ $INFILE -o $OUTFILE -emit-llvm")),
(switch_option "E", (stop_compilation)),
(sink)
]>;
def llvm_gcc_m : Tool<
[(in_language "objective-c"),
(out_language "llvm-bitcode"),
(output_suffix "bc"),
(cmd_line (case
(switch_on "E"),
(case (not_empty "o"),
"llvm-gcc -E -x objective-c $INFILE -o $OUTFILE",
(default),
"llvm-gcc -E -x objective-c $INFILE"),
(default),
"llvm-gcc -c -x objective-c $INFILE -o $OUTFILE -emit-llvm")),
(switch_option "E", (stop_compilation)),
(sink)
]>;
def llvm_gcc_mxx : Tool<
[(in_language "objective-c++"),
(out_language "llvm-bitcode"),
(output_suffix "bc"),
(cmd_line (case
(switch_on "E"),
(case (not_empty "o"),
"llvm-gcc -E -x objective-c++ $INFILE -o $OUTFILE",
(default),
"llvm-gcc -E -x objective-c++ $INFILE"),
(default),
"llvm-gcc -c -x objective-c++ $INFILE -o $OUTFILE -emit-llvm")),
(switch_option "E", (stop_compilation)),
(sink)
]>;
def opt : Tool<
[(in_language "llvm-bitcode"),
(out_language "llvm-bitcode"),
(switch_option "opt", (help "Enable opt")),
(output_suffix "bc"),
(cmd_line "opt -f $INFILE -o $OUTFILE")
]>;
def llvm_as : Tool<
[(in_language "llvm-assembler"),
(out_language "llvm-bitcode"),
(output_suffix "bc"),
(cmd_line "llvm-as $INFILE -o $OUTFILE")
]>;
def llc : Tool<
[(in_language "llvm-bitcode"),
(out_language "assembler"),
(output_suffix "s"),
(switch_option "S", (stop_compilation),
(help "Stop after compilation, do not assemble")),
(cmd_line "llc -f $INFILE -o $OUTFILE")
]>;
def llvm_gcc_assembler : Tool<
[(in_language "assembler"),
(out_language "object-code"),
(output_suffix "o"),
(cmd_line "llvm-gcc -c -x assembler $INFILE -o $OUTFILE"),
(switch_option "c", (stop_compilation),
(help "Compile and assemble, but do not link")),
(prefix_list_option "Wa,", (unpack_values), (help "Pass options to assembler"))
]>;
// Default linker
def llvm_gcc_linker : Tool<
[(in_language "object-code"),
(out_language "executable"),
(output_suffix "out"),
(cmd_line "llvm-gcc $INFILE -o $OUTFILE"),
(join),
(prefix_list_option "L", (forward), (help "Add a directory to link path")),
(prefix_list_option "l", (forward), (help "Search a library when linking")),
(prefix_list_option "Wl,", (unpack_values), (help "Pass options to linker"))
]>;
// Alternative linker for C++
def llvm_gcc_cpp_linker : Tool<
[(in_language "object-code"),
(out_language "executable"),
(output_suffix "out"),
(cmd_line "llvm-g++ $INFILE -o $OUTFILE"),
(join),
(parameter_option "linker",
(help "Choose linker (possible values: gcc, g++)")),
(prefix_list_option "L", (forward)),
(prefix_list_option "l", (forward)),
(prefix_list_option "Wl,", (unpack_values))
]>;
// Language map
def LanguageMap : LanguageMap<
[LangToSuffixes<"c++", ["cc", "cp", "cxx", "cpp", "CPP", "c++", "C"]>,
LangToSuffixes<"c", ["c"]>,
LangToSuffixes<"objective-c++", ["mm"]>,
LangToSuffixes<"objective-c", ["m"]>,
LangToSuffixes<"assembler", ["s"]>,
LangToSuffixes<"llvm-assembler", ["ll"]>,
LangToSuffixes<"llvm-bitcode", ["bc"]>,
LangToSuffixes<"object-code", ["o"]>,
LangToSuffixes<"executable", ["out"]>
]>;
|