1 //===- Tools.td - Tools description for LLVMC2 -------------*- 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 llvmc2.
12 //===----------------------------------------------------------------------===//
14 def OptList : OptionList<[
15 (switch_option "emit-llvm",
16 (help "Emit LLVM bitcode files instead of native object files")),
18 (help "Stop after the preprocessing stage, do not run the compiler")),
19 (switch_option "fsyntax-only",
20 (help "Stop after checking the input for syntax errors")),
24 (help "Stop after compilation, do not assemble")),
26 (help "Compile and assemble, but do not link")),
27 (parameter_option "linker",
28 (help "Choose linker (possible values: gcc, g++)")),
29 (parameter_list_option "include",
30 (help "Include the named file prior to preprocessing")),
31 (prefix_list_option "I",
32 (help "Add a directory to include path")),
33 (prefix_list_option "Wa,",
34 (help "Pass options to assembler")),
35 (prefix_list_option "L",
36 (help "Add a directory to link path")),
37 (prefix_list_option "l",
38 (help "Search a library when linking")),
39 (prefix_list_option "Wl,",
40 (help "Pass options to linker"))
43 class llvm_gcc_based <string cmd_prefix, string in_lang> : Tool<
44 [(in_language in_lang),
45 (out_language "llvm-bitcode"),
49 (case (not_empty "o"),
50 !strconcat(cmd_prefix, " -E $INFILE -o $OUTFILE"),
52 !strconcat(cmd_prefix, " -E $INFILE")),
53 (switch_on "fsyntax-only"),
54 !strconcat(cmd_prefix, " -fsyntax-only $INFILE"),
56 !strconcat(cmd_prefix, " -c $INFILE -o $OUTFILE -emit-llvm"))),
59 (switch_on "emit-llvm"), (stop_compilation),
60 (switch_on "E"), (stop_compilation),
61 (switch_on "fsyntax-only"), (stop_compilation),
62 (not_empty "include"), (forward "include"),
63 (not_empty "I"), (forward "include"))),
67 def llvm_gcc_c : llvm_gcc_based<"llvm-gcc -x c", "c">;
68 def llvm_gcc_cpp : llvm_gcc_based<"llvm-g++ -x c++", "c++">;
69 def llvm_gcc_m : llvm_gcc_based<"llvm-gcc -x objective-c", "objective-c">;
70 def llvm_gcc_mxx : llvm_gcc_based<"llvm-gcc -x objective-c++", "objective-c++">;
73 [(in_language "llvm-bitcode"),
74 (out_language "llvm-bitcode"),
76 (cmd_line "opt -f $INFILE -o $OUTFILE")
80 [(in_language "llvm-assembler"),
81 (out_language "llvm-bitcode"),
83 (cmd_line "llvm-as $INFILE -o $OUTFILE")
87 [(in_language "llvm-bitcode"),
88 (out_language "assembler"),
91 (switch_on "S"), (stop_compilation))),
92 (cmd_line "llc -f $INFILE -o $OUTFILE")
95 def llvm_gcc_assembler : Tool<
96 [(in_language "assembler"),
97 (out_language "object-code"),
99 (cmd_line "llvm-gcc -c -x assembler $INFILE -o $OUTFILE"),
101 (switch_on "c"), (stop_compilation),
102 (not_empty "Wa,"), (unpack_values "Wa,")))
105 // Base class for linkers
106 class llvm_gcc_based_linker <string cmd_prefix> : Tool<
107 [(in_language "object-code"),
108 (out_language "executable"),
109 (output_suffix "out"),
110 (cmd_line !strconcat(cmd_prefix, " $INFILE -o $OUTFILE")),
113 (not_empty "L"), (forward "L"),
114 (not_empty "l"), (forward "l"),
115 (not_empty "Wl,"), (unpack_values "Wl,")))
119 def llvm_gcc_linker : llvm_gcc_based_linker<"llvm-gcc">;
120 // Alternative linker for C++
121 def llvm_gcc_cpp_linker : llvm_gcc_based_linker<"llvm-g++">;
125 def LanguageMap : LanguageMap<
126 [LangToSuffixes<"c++", ["cc", "cp", "cxx", "cpp", "CPP", "c++", "C"]>,
127 LangToSuffixes<"c", ["c"]>,
128 LangToSuffixes<"objective-c++", ["mm"]>,
129 LangToSuffixes<"objective-c", ["m"]>,
130 LangToSuffixes<"assembler", ["s"]>,
131 LangToSuffixes<"llvm-assembler", ["ll"]>,
132 LangToSuffixes<"llvm-bitcode", ["bc"]>,
133 LangToSuffixes<"object-code", ["o"]>,
134 LangToSuffixes<"executable", ["out"]>