1 //===- Tools.td - Tools description for the LLVMCC --------*- tablegen -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file contains descriptions of the various build tools run by llvmcc.
12 //===----------------------------------------------------------------------===//
14 // TOTHINK: Open issue: should we use DAG lists in Tool specifications
15 // or change to something like
17 // def LLVMGccC : < Tool<
19 // PrefixListOption<"Wl", [UnpackValues, PropertyName<Arg>, ...]>
22 // DAG lists look more aesthetically pleasing to me.
24 def llvm_gcc_c : Tool<
26 (out_language "llvm-bitcode"),
30 "llvm-g++ -E -x c $INFILE",
32 "llvm-g++ -c -x c $INFILE -o $OUTFILE -emit-llvm")),
33 (switch_option "E", (stop_compilation),
34 (help "Stop after the preprocessing stage, do not run the compiler")),
38 def llvm_gcc_cpp : Tool<
40 (out_language "llvm-bitcode"),
44 // TOFIX: this does not play well with -o
45 "llvm-g++ -E -x c++ $INFILE",
47 "llvm-g++ -c -x c++ $INFILE -o $OUTFILE -emit-llvm")),
48 (switch_option "E", (stop_compilation)),
53 [(in_language "llvm-bitcode"),
54 (out_language "llvm-bitcode"),
55 (switch_option "opt", (help "Enable opt")),
57 (cmd_line "opt $INFILE -o $OUTFILE")
61 [(in_language "llvm-assembler"),
62 (out_language "llvm-bitcode"),
64 (cmd_line "llvm-as $INFILE -o $OUTFILE")
68 [(in_language "llvm-bitcode"),
69 (out_language "assembler"),
71 (switch_option "S", (stop_compilation),
72 (help "Stop after compilation, do not assemble")),
73 (cmd_line "llc -f $INFILE -o $OUTFILE")
76 def llvm_gcc_assembler : Tool<
77 [(in_language "assembler"),
78 (out_language "object-code"),
80 (cmd_line "llvm-gcc -c -x assembler $INFILE -o $OUTFILE"),
81 (switch_option "c", (stop_compilation),
82 (help "Compile and assemble, but do not link")),
83 (prefix_list_option "Wa,", (unpack_values), (help "pass options to assembler"))
87 def llvm_gcc_linker : Tool<
88 [(in_language "object-code"),
89 (out_language "executable"),
90 (output_suffix "out"),
91 (cmd_line "llvm-gcc $INFILE -o $OUTFILE"),
93 (prefix_list_option "L", (forward), (help "add a directory to link path")),
94 (prefix_list_option "l", (forward), (help "search a library when linking")),
95 (prefix_list_option "Wl,", (unpack_values), (help "pass options to linker"))
98 // Alternative linker for C++
99 def llvm_gcc_cpp_linker : Tool<
100 [(in_language "object-code"),
101 (out_language "executable"),
102 (output_suffix "out"),
103 (cmd_line "llvm-g++ $INFILE -o $OUTFILE"),
105 (parameter_option "linker",
106 (help "Choose linker (possible values: gcc, g++)")),
107 (prefix_list_option "L", (forward)),
108 (prefix_list_option "l", (forward)),
109 (prefix_list_option "Wl,", (unpack_values))
114 def LanguageMap : LanguageMap<
115 [LangToSuffixes<"c++", ["cc", "cp", "cxx", "cpp", "CPP", "c++", "C"]>,
116 LangToSuffixes<"c", ["c"]>,
117 LangToSuffixes<"assembler", ["s"]>,
118 LangToSuffixes<"llvm-assembler", ["ll"]>,
119 LangToSuffixes<"llvm-bitcode", ["bc"]>,
120 LangToSuffixes<"object-code", ["o"]>,
121 LangToSuffixes<"executable", ["out"]>