2008-09-22 20:46:44 +00:00
|
|
|
//===- Tools.td - Tools description for LLVMC2 -------------*- tablegen -*-===//
|
2008-03-23 08:57:20 +00:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
2008-09-22 20:46:44 +00:00
|
|
|
// This file contains descriptions of the various build tools run by llvmc2.
|
2008-03-23 08:57:20 +00:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2008-12-07 16:41:11 +00:00
|
|
|
def OptList : OptionList<[
|
|
|
|
(switch_option "emit-llvm",
|
|
|
|
(help "Emit LLVM bitcode files instead of native object files")),
|
|
|
|
(switch_option "E",
|
|
|
|
(help "Stop after the preprocessing stage, do not run the compiler")),
|
|
|
|
(switch_option "fsyntax-only",
|
|
|
|
(help "Stop after checking the input for syntax errors")),
|
|
|
|
(switch_option "opt",
|
|
|
|
(help "Enable opt")),
|
|
|
|
(switch_option "S",
|
|
|
|
(help "Stop after compilation, do not assemble")),
|
|
|
|
(switch_option "c",
|
|
|
|
(help "Compile and assemble, but do not link")),
|
2008-12-07 16:46:23 +00:00
|
|
|
(switch_option "pthread",
|
|
|
|
(help "Enable threads")),
|
2008-12-07 16:41:11 +00:00
|
|
|
(parameter_option "linker",
|
|
|
|
(help "Choose linker (possible values: gcc, g++)")),
|
|
|
|
(parameter_list_option "include",
|
|
|
|
(help "Include the named file prior to preprocessing")),
|
|
|
|
(prefix_list_option "I",
|
|
|
|
(help "Add a directory to include path")),
|
|
|
|
(prefix_list_option "Wa,",
|
|
|
|
(help "Pass options to assembler")),
|
|
|
|
(prefix_list_option "L",
|
|
|
|
(help "Add a directory to link path")),
|
|
|
|
(prefix_list_option "l",
|
|
|
|
(help "Search a library when linking")),
|
|
|
|
(prefix_list_option "Wl,",
|
|
|
|
(help "Pass options to linker"))
|
|
|
|
]>;
|
|
|
|
|
2008-11-26 10:56:56 +00:00
|
|
|
class llvm_gcc_based <string cmd_prefix, string in_lang> : Tool<
|
|
|
|
[(in_language in_lang),
|
2008-05-06 16:36:06 +00:00
|
|
|
(out_language "llvm-bitcode"),
|
2008-03-23 08:57:20 +00:00
|
|
|
(output_suffix "bc"),
|
2008-05-30 06:10:19 +00:00
|
|
|
(cmd_line (case
|
|
|
|
(switch_on "E"),
|
2008-05-30 19:56:27 +00:00
|
|
|
(case (not_empty "o"),
|
2008-11-26 10:56:56 +00:00
|
|
|
!strconcat(cmd_prefix, " -E $INFILE -o $OUTFILE"),
|
2008-05-30 19:56:27 +00:00
|
|
|
(default),
|
2008-11-26 10:56:56 +00:00
|
|
|
!strconcat(cmd_prefix, " -E $INFILE")),
|
2008-11-19 02:59:00 +00:00
|
|
|
(switch_on "fsyntax-only"),
|
2008-11-26 10:56:56 +00:00
|
|
|
!strconcat(cmd_prefix, " -fsyntax-only $INFILE"),
|
2008-05-30 06:10:19 +00:00
|
|
|
(default),
|
2008-11-26 10:56:56 +00:00
|
|
|
!strconcat(cmd_prefix, " -c $INFILE -o $OUTFILE -emit-llvm"))),
|
2008-12-07 16:41:11 +00:00
|
|
|
(actions
|
|
|
|
(case
|
|
|
|
(switch_on "emit-llvm"), (stop_compilation),
|
2008-12-07 16:46:23 +00:00
|
|
|
(switch_on "E"), [(stop_compilation), (output_suffix "i")],
|
|
|
|
(switch_on "S"), (stop_compilation),
|
2008-12-07 16:41:11 +00:00
|
|
|
(switch_on "fsyntax-only"), (stop_compilation),
|
|
|
|
(not_empty "include"), (forward "include"),
|
2008-12-07 16:46:23 +00:00
|
|
|
(not_empty "I"), (forward "I"))),
|
2008-03-23 08:57:20 +00:00
|
|
|
(sink)
|
|
|
|
]>;
|
|
|
|
|
2008-11-26 10:56:56 +00:00
|
|
|
def llvm_gcc_c : llvm_gcc_based<"llvm-gcc -x c", "c">;
|
|
|
|
def llvm_gcc_cpp : llvm_gcc_based<"llvm-g++ -x c++", "c++">;
|
|
|
|
def llvm_gcc_m : llvm_gcc_based<"llvm-gcc -x objective-c", "objective-c">;
|
|
|
|
def llvm_gcc_mxx : llvm_gcc_based<"llvm-gcc -x objective-c++", "objective-c++">;
|
2008-11-08 03:25:47 +00:00
|
|
|
|
2008-03-23 08:57:20 +00:00
|
|
|
def opt : Tool<
|
|
|
|
[(in_language "llvm-bitcode"),
|
|
|
|
(out_language "llvm-bitcode"),
|
|
|
|
(output_suffix "bc"),
|
2008-05-30 19:56:27 +00:00
|
|
|
(cmd_line "opt -f $INFILE -o $OUTFILE")
|
2008-03-23 08:57:20 +00:00
|
|
|
]>;
|
|
|
|
|
|
|
|
def llvm_as : Tool<
|
|
|
|
[(in_language "llvm-assembler"),
|
|
|
|
(out_language "llvm-bitcode"),
|
|
|
|
(output_suffix "bc"),
|
|
|
|
(cmd_line "llvm-as $INFILE -o $OUTFILE")
|
|
|
|
]>;
|
|
|
|
|
|
|
|
def llvm_gcc_assembler : Tool<
|
|
|
|
[(in_language "assembler"),
|
|
|
|
(out_language "object-code"),
|
|
|
|
(output_suffix "o"),
|
2008-05-06 18:10:20 +00:00
|
|
|
(cmd_line "llvm-gcc -c -x assembler $INFILE -o $OUTFILE"),
|
2008-12-07 16:41:11 +00:00
|
|
|
(actions (case
|
|
|
|
(switch_on "c"), (stop_compilation),
|
|
|
|
(not_empty "Wa,"), (unpack_values "Wa,")))
|
2008-03-23 08:57:20 +00:00
|
|
|
]>;
|
|
|
|
|
2008-12-07 16:46:23 +00:00
|
|
|
def llc : Tool<
|
|
|
|
[(in_language "llvm-bitcode"),
|
|
|
|
(out_language "assembler"),
|
|
|
|
(output_suffix "s"),
|
|
|
|
(cmd_line "llc -relocation-model=pic -f $INFILE -o $OUTFILE"),
|
|
|
|
(actions (case (switch_on "S"), (stop_compilation)))
|
|
|
|
]>;
|
|
|
|
|
2008-12-07 16:41:11 +00:00
|
|
|
// Base class for linkers
|
|
|
|
class llvm_gcc_based_linker <string cmd_prefix> : Tool<
|
2008-03-23 08:57:20 +00:00
|
|
|
[(in_language "object-code"),
|
|
|
|
(out_language "executable"),
|
|
|
|
(output_suffix "out"),
|
2008-12-07 16:41:11 +00:00
|
|
|
(cmd_line !strconcat(cmd_prefix, " $INFILE -o $OUTFILE")),
|
2008-03-23 08:57:20 +00:00
|
|
|
(join),
|
2008-12-07 16:41:11 +00:00
|
|
|
(actions (case
|
2008-12-07 16:46:23 +00:00
|
|
|
(switch_on "pthread"), (append_cmd "-lpthread"),
|
2008-12-07 16:41:11 +00:00
|
|
|
(not_empty "L"), (forward "L"),
|
|
|
|
(not_empty "l"), (forward "l"),
|
|
|
|
(not_empty "Wl,"), (unpack_values "Wl,")))
|
2008-03-23 08:57:20 +00:00
|
|
|
]>;
|
|
|
|
|
2008-12-07 16:41:11 +00:00
|
|
|
// Default linker
|
|
|
|
def llvm_gcc_linker : llvm_gcc_based_linker<"llvm-gcc">;
|
2008-05-06 18:10:53 +00:00
|
|
|
// Alternative linker for C++
|
2008-12-07 16:41:11 +00:00
|
|
|
def llvm_gcc_cpp_linker : llvm_gcc_based_linker<"llvm-g++">;
|
2008-05-06 18:10:53 +00:00
|
|
|
|
2008-03-23 08:57:20 +00:00
|
|
|
// Language map
|
|
|
|
|
|
|
|
def LanguageMap : LanguageMap<
|
|
|
|
[LangToSuffixes<"c++", ["cc", "cp", "cxx", "cpp", "CPP", "c++", "C"]>,
|
|
|
|
LangToSuffixes<"c", ["c"]>,
|
2008-12-07 16:46:23 +00:00
|
|
|
LangToSuffixes<"c-cpp-output", ["i"]>,
|
|
|
|
LangToSuffixes<"objective-c-cpp-output", ["mi"]>,
|
2008-11-08 03:25:47 +00:00
|
|
|
LangToSuffixes<"objective-c++", ["mm"]>,
|
|
|
|
LangToSuffixes<"objective-c", ["m"]>,
|
2008-03-23 08:57:20 +00:00
|
|
|
LangToSuffixes<"assembler", ["s"]>,
|
2008-12-07 16:46:23 +00:00
|
|
|
LangToSuffixes<"assembler-with-cpp", ["S"]>,
|
2008-03-23 08:57:20 +00:00
|
|
|
LangToSuffixes<"llvm-assembler", ["ll"]>,
|
|
|
|
LangToSuffixes<"llvm-bitcode", ["bc"]>,
|
|
|
|
LangToSuffixes<"object-code", ["o"]>,
|
2008-05-06 18:10:20 +00:00
|
|
|
LangToSuffixes<"executable", ["out"]>
|
|
|
|
]>;
|