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 class llvm_gcc_based <string cmd_prefix, string in_lang> : Tool<
15 [(in_language in_lang),
16 (out_language "llvm-bitcode"),
20 (case (not_empty "o"),
21 !strconcat(cmd_prefix, " -E $INFILE -o $OUTFILE"),
23 !strconcat(cmd_prefix, " -E $INFILE")),
24 (switch_on "fsyntax-only"),
25 !strconcat(cmd_prefix, " -fsyntax-only $INFILE"),
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")),
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++">;
47 [(in_language "llvm-bitcode"),
48 (out_language "llvm-bitcode"),
49 (switch_option "opt", (help "Enable opt")),
51 (cmd_line "opt -f $INFILE -o $OUTFILE")
55 [(in_language "llvm-assembler"),
56 (out_language "llvm-bitcode"),
58 (cmd_line "llvm-as $INFILE -o $OUTFILE")
62 [(in_language "llvm-bitcode"),
63 (out_language "assembler"),
65 (switch_option "S", (stop_compilation),
66 (help "Stop after compilation, do not assemble")),
67 (cmd_line "llc -f $INFILE -o $OUTFILE")
70 def llvm_gcc_assembler : Tool<
71 [(in_language "assembler"),
72 (out_language "object-code"),
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"))
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"),
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"))
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"),
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))
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"]>