e701b476494d4ded6740ed9845edd50d40ea4bb0
[oota-llvm.git] / include / llvm / CompilerDriver / Tools.td
1 //===- Tools.td - Tools description for LLVMC2 -------------*- tablegen -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file contains descriptions of the various build tools run by llvmc2.
11 //
12 //===----------------------------------------------------------------------===//
13
14 class llvm_gcc_based <string cmd_prefix, string in_lang> : Tool<
15 [(in_language in_lang),
16  (out_language "llvm-bitcode"),
17  (output_suffix "bc"),
18  (cmd_line (case
19             (switch_on "E"),
20               (case (not_empty "o"),
21                     !strconcat(cmd_prefix, " -E $INFILE -o $OUTFILE"),
22                     (default),
23                     !strconcat(cmd_prefix, " -E $INFILE")),
24             (switch_on "fsyntax-only"),
25               !strconcat(cmd_prefix, " -fsyntax-only $INFILE"),
26             (default),
27               !strconcat(cmd_prefix, " -c $INFILE -o $OUTFILE -emit-llvm"))),
28  (switch_option "emit-llvm", (stop_compilation),
29    (help "Emit LLVM intermediate files instead of native object files")),
30  (switch_option "E", (stop_compilation),
31    (help "Stop after the preprocessing stage, do not run the compiler")),
32  (switch_option "fsyntax-only", (stop_compilation),
33    (help "Stop after checking the input for syntax errors")),
34  (parameter_list_option "include", (forward),
35    (help "Include the named file prior to preprocessing")),
36  (prefix_list_option "I", (forward),
37    (help "Add a directory to include path")),
38  (sink)
39 ]>;
40
41 def llvm_gcc_c : llvm_gcc_based<"llvm-gcc -x c", "c">;
42 def llvm_gcc_cpp : llvm_gcc_based<"llvm-g++ -x c++", "c++">;
43 def llvm_gcc_m : llvm_gcc_based<"llvm-gcc -x objective-c", "objective-c">;
44 def llvm_gcc_mxx : llvm_gcc_based<"llvm-gcc -x objective-c++", "objective-c++">;
45
46 def opt : Tool<
47 [(in_language "llvm-bitcode"),
48  (out_language "llvm-bitcode"),
49  (switch_option "opt", (help "Enable opt")),
50  (output_suffix "bc"),
51  (cmd_line "opt -f $INFILE -o $OUTFILE")
52 ]>;
53
54 def llvm_as : Tool<
55 [(in_language "llvm-assembler"),
56  (out_language "llvm-bitcode"),
57  (output_suffix "bc"),
58  (cmd_line "llvm-as $INFILE -o $OUTFILE")
59 ]>;
60
61 def llc : Tool<
62 [(in_language "llvm-bitcode"),
63  (out_language "assembler"),
64  (output_suffix "s"),
65  (switch_option "S", (stop_compilation),
66                 (help "Stop after compilation, do not assemble")),
67  (cmd_line "llc -f $INFILE -o $OUTFILE")
68 ]>;
69
70 def llvm_gcc_assembler : Tool<
71 [(in_language "assembler"),
72  (out_language "object-code"),
73  (output_suffix "o"),
74  (cmd_line "llvm-gcc -c -x assembler $INFILE -o $OUTFILE"),
75  (switch_option "c", (stop_compilation),
76                 (help "Compile and assemble, but do not link")),
77  (prefix_list_option "Wa,", (unpack_values), (help "Pass options to assembler"))
78 ]>;
79
80 // Default linker
81 def llvm_gcc_linker : Tool<
82 [(in_language "object-code"),
83  (out_language "executable"),
84  (output_suffix "out"),
85  (cmd_line "llvm-gcc $INFILE -o $OUTFILE"),
86  (join),
87  (prefix_list_option "L", (forward), (help "Add a directory to link path")),
88  (prefix_list_option "l", (forward), (help "Search a library when linking")),
89  (prefix_list_option "Wl,", (unpack_values), (help "Pass options to linker"))
90 ]>;
91
92 // Alternative linker for C++
93 def llvm_gcc_cpp_linker : Tool<
94 [(in_language "object-code"),
95  (out_language "executable"),
96  (output_suffix "out"),
97  (cmd_line "llvm-g++ $INFILE -o $OUTFILE"),
98  (join),
99  (parameter_option "linker",
100                    (help "Choose linker (possible values: gcc, g++)")),
101  (prefix_list_option "L", (forward)),
102  (prefix_list_option "l", (forward)),
103  (prefix_list_option "Wl,", (unpack_values))
104 ]>;
105
106 // Language map
107
108 def LanguageMap : LanguageMap<
109     [LangToSuffixes<"c++", ["cc", "cp", "cxx", "cpp", "CPP", "c++", "C"]>,
110      LangToSuffixes<"c", ["c"]>,
111      LangToSuffixes<"objective-c++", ["mm"]>,
112      LangToSuffixes<"objective-c", ["m"]>,
113      LangToSuffixes<"assembler", ["s"]>,
114      LangToSuffixes<"llvm-assembler", ["ll"]>,
115      LangToSuffixes<"llvm-bitcode", ["bc"]>,
116      LangToSuffixes<"object-code", ["o"]>,
117      LangToSuffixes<"executable", ["out"]>
118      ]>;