2009-06-07 07:08:01 +00:00
|
|
|
//===- PIC16Base.td - PIC16 toolchain driver ---------------*- tablegen -*-===//
|
|
|
|
//
|
|
|
|
// A basic driver for the PIC16 toolchain.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
include "llvm/CompilerDriver/Common.td"
|
|
|
|
|
|
|
|
// Options
|
|
|
|
|
|
|
|
def OptionList : OptionList<[
|
|
|
|
(switch_option "g",
|
2009-07-01 16:10:29 +00:00
|
|
|
(help "Enable Debugging")),
|
2009-10-21 10:38:59 +00:00
|
|
|
(switch_option "E",
|
|
|
|
(help "Stop after preprocessing, do not compile")),
|
2009-06-07 07:08:01 +00:00
|
|
|
(switch_option "S",
|
|
|
|
(help "Stop after compilation, do not assemble")),
|
2009-10-21 10:38:59 +00:00
|
|
|
(switch_option "bc",
|
|
|
|
(help "Stop after b-code generation, do not compile")),
|
2009-07-02 17:35:38 +00:00
|
|
|
(switch_option "c",
|
|
|
|
(help "Stop after assemble, do not link")),
|
2009-12-19 13:13:29 +00:00
|
|
|
(prefix_option "p",
|
|
|
|
(help "Specify part name")),
|
2009-10-21 10:38:59 +00:00
|
|
|
(prefix_list_option "I",
|
2009-06-07 07:08:01 +00:00
|
|
|
(help "Add a directory to include path")),
|
2009-10-21 10:38:59 +00:00
|
|
|
(prefix_list_option "L",
|
|
|
|
(help "Add a directory to library path")),
|
|
|
|
(prefix_list_option "K",
|
|
|
|
(help "Add a directory to linker script search path")),
|
|
|
|
(parameter_option "l",
|
|
|
|
(help "Specify a library to link")),
|
|
|
|
(parameter_option "k",
|
|
|
|
(help "Specify a linker script")),
|
|
|
|
(parameter_option "m",
|
|
|
|
(help "Generate linker map file with the given name")),
|
|
|
|
(prefix_list_option "D",
|
|
|
|
(help "Define a macro")),
|
2009-12-19 13:13:29 +00:00
|
|
|
(switch_option "X",
|
|
|
|
(help "Do not invoke mp2hex to create an output hex file.")),
|
2009-10-21 10:38:59 +00:00
|
|
|
(switch_option "O0",
|
|
|
|
(help "Do not optimize")),
|
2009-12-19 13:13:29 +00:00
|
|
|
(switch_option "O1",
|
|
|
|
(help "Optimization Level 1.")),
|
|
|
|
(switch_option "O2",
|
|
|
|
(help "Optimization Level 2.")),
|
|
|
|
(switch_option "O3",
|
|
|
|
(help "Optimization Level 3.")),
|
|
|
|
(switch_option "Od",
|
|
|
|
(help "Perform Debug-safe Optimizations only.")),
|
2010-02-08 05:56:37 +00:00
|
|
|
(switch_option "w",
|
|
|
|
(help "Disable all warnings.")),
|
|
|
|
// (switch_option "O1",
|
|
|
|
// (help "Optimization level 1")),
|
|
|
|
// (switch_option "O2",
|
|
|
|
// (help "Optimization level 2. (Default)")),
|
|
|
|
// (parameter_option "pre-RA-sched",
|
|
|
|
// (help "Example of an option that is passed to llc")),
|
2009-12-19 13:13:29 +00:00
|
|
|
(parameter_option "regalloc",
|
2010-02-18 14:37:52 +00:00
|
|
|
(help "Register allocator to use (possible values: simple, linearscan, pbqp, local; default=linearscan)")),
|
2010-02-08 05:56:37 +00:00
|
|
|
(prefix_list_option "Wa,", (comma_separated),
|
2009-12-19 13:13:29 +00:00
|
|
|
(help "Pass options to assembler (Run 'gpasm -help' for assembler options)")),
|
2010-02-08 05:56:37 +00:00
|
|
|
(prefix_list_option "Wl,", (comma_separated),
|
2009-12-19 13:13:29 +00:00
|
|
|
(help "Pass options to linker (Run 'mplink -help' for linker options)"))
|
2010-02-08 05:56:37 +00:00
|
|
|
// (prefix_list_option "Wllc,",
|
|
|
|
// (help "Pass options to llc")),
|
|
|
|
// (prefix_list_option "Wo,",
|
|
|
|
// (help "Pass options to llvm-ld"))
|
2009-06-07 07:08:01 +00:00
|
|
|
]>;
|
|
|
|
|
|
|
|
// Tools
|
2009-10-21 10:38:59 +00:00
|
|
|
class clang_based<string language, string cmd, string ext_E> : Tool<
|
|
|
|
[(in_language language),
|
2009-06-07 07:08:01 +00:00
|
|
|
(out_language "llvm-bitcode"),
|
|
|
|
(output_suffix "bc"),
|
2010-02-23 09:59:30 +00:00
|
|
|
(command cmd),
|
|
|
|
(actions (case
|
|
|
|
(and (multiple_input_files),
|
|
|
|
(or (switch_on "S"), (switch_on "c"))),
|
|
|
|
(error "cannot specify -o with -c or -S with multiple files"),
|
|
|
|
(switch_on "E"), [(forward "E"),
|
|
|
|
(stop_compilation), (output_suffix ext_E)],
|
|
|
|
(and (switch_on "E"), (empty "o")), (no_out_file),
|
2009-10-21 10:38:59 +00:00
|
|
|
(switch_on "bc"),[(stop_compilation), (output_suffix "bc")],
|
|
|
|
(switch_on "g"), (append_cmd "-g"),
|
2010-02-08 05:56:37 +00:00
|
|
|
(switch_on "w"), (append_cmd "-w"),
|
2009-12-19 13:13:29 +00:00
|
|
|
(switch_on "O1"), (append_cmd ""),
|
|
|
|
(switch_on "O2"), (append_cmd ""),
|
|
|
|
(switch_on "O3"), (append_cmd ""),
|
|
|
|
(switch_on "Od"), (append_cmd ""),
|
2009-10-21 10:38:59 +00:00
|
|
|
(not_empty "D"), (forward "D"),
|
2009-12-19 13:13:29 +00:00
|
|
|
(not_empty "I"), (forward "I"),
|
|
|
|
(switch_on "O0"), (append_cmd "-O0"),
|
|
|
|
(default), (append_cmd "-O1")))
|
2010-02-08 05:56:37 +00:00
|
|
|
// (sink)
|
2009-06-07 07:08:01 +00:00
|
|
|
]>;
|
|
|
|
|
2010-02-08 05:56:37 +00:00
|
|
|
def clang_cc : clang_based<"c", "$CALL(GetBinDir)clang -cc1 -I $CALL(GetStdHeadersDir) -D $CALL(GetLowerCasePartDefine) -D $CALL(GetUpperCasePartDefine) -triple=pic16- -emit-llvm-bc ", "i">;
|
|
|
|
|
|
|
|
//def clang_cc : Tool<[
|
|
|
|
// (in_language "c"),
|
|
|
|
// (out_language "llvm-bitcode"),
|
|
|
|
// (output_suffix "bc"),
|
|
|
|
// (cmd_line "$CALL(GetBinDir)clang-cc -I $CALL(GetStdHeadersDir) -triple=pic16- -emit-llvm-bc "),
|
|
|
|
// (cmd_line kkkkk
|
|
|
|
// (actions (case
|
|
|
|
// (switch_on "g"), (append_cmd "g"),
|
|
|
|
// (not_empty "I"), (forward "I"))),
|
|
|
|
// (sink)
|
|
|
|
//]>;
|
2009-10-21 10:38:59 +00:00
|
|
|
|
|
|
|
|
|
|
|
// pre-link-and-lto step.
|
2009-06-07 07:08:01 +00:00
|
|
|
def llvm_ld : Tool<[
|
|
|
|
(in_language "llvm-bitcode"),
|
|
|
|
(out_language "llvm-bitcode"),
|
|
|
|
(output_suffix "bc"),
|
2010-02-23 09:59:30 +00:00
|
|
|
(command "$CALL(GetBinDir)llvm-ld -L $CALL(GetStdLibsDir) -disable-gvn -disable-licm-promotion -disable-mem2reg -l std"),
|
|
|
|
(out_file_option "-b"),
|
2009-06-07 07:08:01 +00:00
|
|
|
(actions (case
|
2009-12-19 13:13:29 +00:00
|
|
|
(switch_on "O0"), (append_cmd "-disable-opt"),
|
|
|
|
(switch_on "O1"), (append_cmd "-disable-opt"),
|
|
|
|
// Whenever O3 is not specified on the command line, default i.e. disable-inlining will always be added.
|
2010-02-23 09:59:30 +00:00
|
|
|
(switch_on "O2"), (append_cmd ""),
|
2009-12-19 13:13:29 +00:00
|
|
|
(switch_on "O3"), (append_cmd ""),
|
|
|
|
(default), (append_cmd "-disable-inlining"))),
|
2009-10-21 10:38:59 +00:00
|
|
|
(join)
|
2009-06-07 07:08:01 +00:00
|
|
|
]>;
|
|
|
|
|
2009-10-21 10:38:59 +00:00
|
|
|
// optimize single file
|
|
|
|
def llvm_ld_optimizer : Tool<[
|
2009-06-07 07:08:01 +00:00
|
|
|
(in_language "llvm-bitcode"),
|
|
|
|
(out_language "llvm-bitcode"),
|
|
|
|
(output_suffix "bc"),
|
2010-02-08 05:56:37 +00:00
|
|
|
// FIXME: we are still not disabling licm-promotion.
|
|
|
|
// -disable-licm-promotion and building stdn library causes c16-71 to fail.
|
2010-02-23 09:59:30 +00:00
|
|
|
(command "$CALL(GetBinDir)llvm-ld -disable-gvn -disable-mem2reg"),
|
|
|
|
(out_file_option "-b"),
|
2009-06-07 07:08:01 +00:00
|
|
|
(actions (case
|
2010-02-08 05:56:37 +00:00
|
|
|
(switch_on "O0"), (append_cmd "-disable-opt"),
|
|
|
|
(switch_on "O1"), (append_cmd "-disable-opt"),
|
|
|
|
// Whenever O3 is not specified on the command line, default i.e. disable-inlining will always be added.
|
2010-02-23 09:59:30 +00:00
|
|
|
(switch_on "O2"), (append_cmd ""),
|
2010-02-08 05:56:37 +00:00
|
|
|
(switch_on "O3"), (append_cmd ""),
|
|
|
|
(default), (append_cmd "-disable-inlining")))
|
2009-10-21 10:38:59 +00:00
|
|
|
]>;
|
|
|
|
|
|
|
|
// optimizer step.
|
|
|
|
def pic16passes : Tool<[
|
|
|
|
(in_language "llvm-bitcode"),
|
|
|
|
(out_language "llvm-bitcode"),
|
|
|
|
(output_suffix "obc"),
|
2010-02-23 09:59:30 +00:00
|
|
|
(command "$CALL(GetBinDir)opt -pic16cg -pic16overlay -f"),
|
2009-10-21 10:38:59 +00:00
|
|
|
(actions (case
|
|
|
|
(switch_on "O0"), (append_cmd "-disable-opt")))
|
2009-06-07 07:08:01 +00:00
|
|
|
]>;
|
|
|
|
|
|
|
|
def llc : Tool<[
|
|
|
|
(in_language "llvm-bitcode"),
|
|
|
|
(out_language "assembler"),
|
|
|
|
(output_suffix "s"),
|
2010-02-23 09:59:30 +00:00
|
|
|
(command "$CALL(GetBinDir)llc -march=pic16 -disable-jump-tables -pre-RA-sched=list-burr -f"),
|
2009-06-07 07:08:01 +00:00
|
|
|
(actions (case
|
2009-12-19 13:13:29 +00:00
|
|
|
(switch_on "S"), (stop_compilation),
|
2010-02-08 05:56:37 +00:00
|
|
|
// (not_empty "Wllc,"), (unpack_values "Wllc,"),
|
|
|
|
// (not_empty "pre-RA-sched"), (forward "pre-RA-sched")))
|
2009-12-19 13:13:29 +00:00
|
|
|
(not_empty "regalloc"), (forward "regalloc"),
|
2010-02-08 05:56:37 +00:00
|
|
|
(empty "regalloc"), (append_cmd "-regalloc=linearscan")))
|
2009-06-07 07:08:01 +00:00
|
|
|
]>;
|
|
|
|
|
2009-07-01 16:10:29 +00:00
|
|
|
def gpasm : Tool<[
|
2009-06-07 07:08:01 +00:00
|
|
|
(in_language "assembler"),
|
|
|
|
(out_language "object-code"),
|
|
|
|
(output_suffix "o"),
|
2010-02-23 09:59:30 +00:00
|
|
|
(command "$CALL(GetBinDir)gpasm -z -r decimal -I $CALL(GetStdAsmHeadersDir) -C -c -w 2"),
|
2009-06-07 07:08:01 +00:00
|
|
|
(actions (case
|
2009-07-02 17:35:38 +00:00
|
|
|
(switch_on "c"), (stop_compilation),
|
2009-10-21 10:38:59 +00:00
|
|
|
(switch_on "g"), (append_cmd "-g"),
|
2009-12-19 13:13:29 +00:00
|
|
|
(not_empty "p"), (forward "p"),
|
|
|
|
(empty "p"), (append_cmd "-p 16f1xxx"),
|
2009-12-07 18:25:54 +00:00
|
|
|
(not_empty "Wa,"), (forward_value "Wa,")))
|
2009-06-07 07:08:01 +00:00
|
|
|
]>;
|
|
|
|
|
2009-07-01 16:10:29 +00:00
|
|
|
def mplink : Tool<[
|
2009-06-07 07:08:01 +00:00
|
|
|
(in_language "object-code"),
|
|
|
|
(out_language "executable"),
|
2009-10-21 10:38:59 +00:00
|
|
|
(output_suffix "cof"),
|
2010-02-23 09:59:30 +00:00
|
|
|
(command "$CALL(GetBinDir)mplink -e -k $CALL(GetStdLinkerScriptsDir) -l $CALL(GetStdLibsDir) intrinsics.lib stdn.lib"),
|
2009-06-07 07:08:01 +00:00
|
|
|
(actions (case
|
2009-12-07 18:25:54 +00:00
|
|
|
(not_empty "Wl,"), (forward_value "Wl,"),
|
2009-12-19 13:13:29 +00:00
|
|
|
(switch_on "X"), (append_cmd "-x"),
|
2009-10-21 10:38:59 +00:00
|
|
|
(not_empty "L"), (forward_as "L", "-l"),
|
|
|
|
(not_empty "K"), (forward_as "K", "-k"),
|
|
|
|
(not_empty "m"), (forward "m"),
|
2009-12-19 13:13:29 +00:00
|
|
|
(not_empty "p"), [(forward "p"), (append_cmd "-c")],
|
|
|
|
(empty "p"), (append_cmd "-p 16f1xxx -c"),
|
2010-02-08 05:56:37 +00:00
|
|
|
// (not_empty "l"), [(unpack_values "l"),(append_cmd ".lib")])),
|
|
|
|
(not_empty "k"), (forward "k"),
|
|
|
|
(not_empty "l"), (forward "l"))),
|
2009-06-07 07:08:01 +00:00
|
|
|
(join)
|
|
|
|
]>;
|
|
|
|
|
|
|
|
// Language map
|
|
|
|
|
|
|
|
def LanguageMap : LanguageMap<[
|
|
|
|
LangToSuffixes<"c", ["c"]>,
|
|
|
|
LangToSuffixes<"c-cpp-output", ["i"]>,
|
|
|
|
LangToSuffixes<"assembler", ["s"]>,
|
|
|
|
LangToSuffixes<"assembler-with-cpp", ["S"]>,
|
|
|
|
LangToSuffixes<"llvm-assembler", ["ll"]>,
|
|
|
|
LangToSuffixes<"llvm-bitcode", ["bc"]>,
|
|
|
|
LangToSuffixes<"object-code", ["o"]>,
|
2009-10-21 10:38:59 +00:00
|
|
|
LangToSuffixes<"executable", ["cof"]>
|
2009-06-07 07:08:01 +00:00
|
|
|
]>;
|
|
|
|
|
|
|
|
// Compilation graph
|
|
|
|
|
|
|
|
def CompilationGraph : CompilationGraph<[
|
|
|
|
Edge<"root", "clang_cc">,
|
2009-10-21 10:38:59 +00:00
|
|
|
Edge<"root", "llvm_ld">,
|
2010-02-23 09:59:30 +00:00
|
|
|
OptionalEdge<"root", "llvm_ld_optimizer", (case
|
2009-10-21 10:38:59 +00:00
|
|
|
(switch_on "S"), (inc_weight),
|
|
|
|
(switch_on "c"), (inc_weight))>,
|
|
|
|
Edge<"root", "gpasm">,
|
|
|
|
Edge<"root", "mplink">,
|
|
|
|
Edge<"clang_cc", "llvm_ld">,
|
2010-02-23 09:59:30 +00:00
|
|
|
OptionalEdge<"clang_cc", "llvm_ld_optimizer", (case
|
2009-07-02 17:35:38 +00:00
|
|
|
(switch_on "S"), (inc_weight),
|
|
|
|
(switch_on "c"), (inc_weight))>,
|
2009-10-21 10:38:59 +00:00
|
|
|
Edge<"llvm_ld", "pic16passes">,
|
|
|
|
Edge<"llvm_ld_optimizer", "pic16passes">,
|
|
|
|
Edge<"pic16passes", "llc">,
|
2009-07-01 16:10:29 +00:00
|
|
|
Edge<"llc", "gpasm">,
|
|
|
|
Edge<"gpasm", "mplink">
|
2009-06-07 07:08:01 +00:00
|
|
|
]>;
|