diff options
author | Sanjiv Gupta <sanjiv.gupta@microchip.com> | 2010-02-08 05:56:37 +0000 |
---|---|---|
committer | Sanjiv Gupta <sanjiv.gupta@microchip.com> | 2010-02-08 05:56:37 +0000 |
commit | 90f4c914b8391ed8e54ac952d441313376acbb9a (patch) | |
tree | 1ce4c6dbad793b6c12790c2c7b2f73b77687a537 /tools | |
parent | 337c6a8edd6acd6560f8f09f1372d7eca6d8f262 (diff) |
Add uppercase and lowercase part defines in driver.
Use a temp dir with a unique name in the current dir itself.
Use forward_value instead of unpack_values.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95530 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools')
-rw-r--r-- | tools/llvmc/example/mcc16/driver/Main.cpp | 12 | ||||
-rw-r--r-- | tools/llvmc/example/mcc16/plugins/PIC16Base/PIC16Base.td | 69 | ||||
-rw-r--r-- | tools/llvmc/example/mcc16/plugins/PIC16Base/PluginMain.cpp | 39 |
3 files changed, 98 insertions, 22 deletions
diff --git a/tools/llvmc/example/mcc16/driver/Main.cpp b/tools/llvmc/example/mcc16/driver/Main.cpp index 5d50f9d4a3..43d6c048f9 100644 --- a/tools/llvmc/example/mcc16/driver/Main.cpp +++ b/tools/llvmc/example/mcc16/driver/Main.cpp @@ -37,10 +37,16 @@ int main(int argc, char** argv) { DryRun.setHiddenFlag(llvm::cl::Hidden); llvm::cl::SetVersionPrinter(PIC16VersionPrinter); - - TempDirname = "tmp-objs"; - // Remove the temp dir if already exists. + // Ask for a standard temp dir, but just cache its basename., and delete it. + llvm::sys::Path tempDir; + tempDir = llvm::sys::Path::GetTemporaryDirectory(); + TempDirname = tempDir.getBasename(); + tempDir.eraseFromDisk(true); + + // We are creating a temp dir in current dir, with the cached name. + // But before that remove if one already exists with that name.. + llvm::sys::Path tempDir; tempDir = TempDirname; tempDir.eraseFromDisk(true); diff --git a/tools/llvmc/example/mcc16/plugins/PIC16Base/PIC16Base.td b/tools/llvmc/example/mcc16/plugins/PIC16Base/PIC16Base.td index 717e95e92a..f13b9f8214 100644 --- a/tools/llvmc/example/mcc16/plugins/PIC16Base/PIC16Base.td +++ b/tools/llvmc/example/mcc16/plugins/PIC16Base/PIC16Base.td @@ -47,15 +47,24 @@ def OptionList : OptionList<[ (help "Optimization Level 3.")), (switch_option "Od", (help "Perform Debug-safe Optimizations only.")), - (switch_option "r", - (help "Use resource file for part info"), - (really_hidden)), + (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")), (parameter_option "regalloc", - (help "Register allocator to use.(possible values: simple, linearscan, pbqp, local. default = pbqp)")), - (prefix_list_option "Wa,", + (help "Register allocator to use.(possible values: simple, linearscan, pbqp, local. default = linearscan)")), + (prefix_list_option "Wa,", (comma_separated), (help "Pass options to assembler (Run 'gpasm -help' for assembler options)")), - (prefix_list_option "Wl,", + (prefix_list_option "Wl,", (comma_separated), (help "Pass options to linker (Run 'mplink -help' for linker options)")) +// (prefix_list_option "Wllc,", +// (help "Pass options to llc")), +// (prefix_list_option "Wo,", +// (help "Pass options to llvm-ld")) ]>; // Tools @@ -75,6 +84,7 @@ class clang_based<string language, string cmd, string ext_E> : Tool< (switch_on "E"), [(stop_compilation), (output_suffix ext_E)], (switch_on "bc"),[(stop_compilation), (output_suffix "bc")], (switch_on "g"), (append_cmd "-g"), + (switch_on "w"), (append_cmd "-w"), (switch_on "O1"), (append_cmd ""), (switch_on "O2"), (append_cmd ""), (switch_on "O3"), (append_cmd ""), @@ -83,9 +93,22 @@ class clang_based<string language, string cmd, string ext_E> : Tool< (not_empty "I"), (forward "I"), (switch_on "O0"), (append_cmd "-O0"), (default), (append_cmd "-O1"))) +// (sink) ]>; -def clang_cc : clang_based<"c", "$CALL(GetBinDir)clang -cc1 -I $CALL(GetStdHeadersDir) -triple=pic16- -emit-llvm-bc ", "i">; +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) +//]>; // pre-link-and-lto step. @@ -93,12 +116,12 @@ def llvm_ld : Tool<[ (in_language "llvm-bitcode"), (out_language "llvm-bitcode"), (output_suffix "bc"), - (cmd_line "$CALL(GetBinDir)llvm-ld -L $CALL(GetStdLibsDir) -instcombine -disable-licm-promotion $INFILE -b $OUTFILE -l std"), + (cmd_line "$CALL(GetBinDir)llvm-ld -L $CALL(GetStdLibsDir) -disable-gvn -disable-licm-promotion -disable-mem2reg $INFILE -b $OUTFILE -l std"), (actions (case (switch_on "O0"), (append_cmd "-disable-opt"), (switch_on "O1"), (append_cmd "-disable-opt"), - (switch_on "O2"), (append_cmd ""), // Whenever O3 is not specified on the command line, default i.e. disable-inlining will always be added. + (switch_on "O2"), (append_cmd ""), (switch_on "O3"), (append_cmd ""), (default), (append_cmd "-disable-inlining"))), (join) @@ -109,9 +132,16 @@ def llvm_ld_optimizer : Tool<[ (in_language "llvm-bitcode"), (out_language "llvm-bitcode"), (output_suffix "bc"), - (cmd_line "$CALL(GetBinDir)llvm-ld -instcombine -disable-inlining $INFILE -b $OUTFILE"), +// FIXME: we are still not disabling licm-promotion. +// -disable-licm-promotion and building stdn library causes c16-71 to fail. + (cmd_line "$CALL(GetBinDir)llvm-ld -disable-gvn -disable-mem2reg $INFILE -b $OUTFILE"), (actions (case - (switch_on "O0"), (append_cmd "-disable-opt"))) + (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. + (switch_on "O2"), (append_cmd ""), + (switch_on "O3"), (append_cmd ""), + (default), (append_cmd "-disable-inlining"))) ]>; // optimizer step. @@ -119,7 +149,7 @@ def pic16passes : Tool<[ (in_language "llvm-bitcode"), (out_language "llvm-bitcode"), (output_suffix "obc"), - (cmd_line "$CALL(GetBinDir)opt -pic16overlay $INFILE -f -o $OUTFILE"), + (cmd_line "$CALL(GetBinDir)opt -pic16cg -pic16overlay $INFILE -f -o $OUTFILE"), (actions (case (switch_on "O0"), (append_cmd "-disable-opt"))) ]>; @@ -131,19 +161,20 @@ def llc : Tool<[ (cmd_line "$CALL(GetBinDir)llc -march=pic16 -disable-jump-tables -pre-RA-sched=list-burr -f $INFILE -o $OUTFILE"), (actions (case (switch_on "S"), (stop_compilation), +// (not_empty "Wllc,"), (unpack_values "Wllc,"), +// (not_empty "pre-RA-sched"), (forward "pre-RA-sched"))) (not_empty "regalloc"), (forward "regalloc"), - (empty "regalloc"), (append_cmd "-regalloc=pbqp"))) + (empty "regalloc"), (append_cmd "-regalloc=linearscan"))) ]>; def gpasm : Tool<[ (in_language "assembler"), (out_language "object-code"), (output_suffix "o"), - (cmd_line "$CALL(GetBinDir)gpasm -r decimal -I $CALL(GetStdAsmHeadersDir) -C -c -w 2 $INFILE -o $OUTFILE"), + (cmd_line "$CALL(GetBinDir)gpasm -z -r decimal -I $CALL(GetStdAsmHeadersDir) -C -c -w 2 $INFILE -o $OUTFILE"), (actions (case (switch_on "c"), (stop_compilation), (switch_on "g"), (append_cmd "-g"), - (switch_on "r"), (append_cmd "-z"), (not_empty "p"), (forward "p"), (empty "p"), (append_cmd "-p 16f1xxx"), (not_empty "Wa,"), (forward_value "Wa,"))) @@ -153,18 +184,18 @@ def mplink : Tool<[ (in_language "object-code"), (out_language "executable"), (output_suffix "cof"), - (cmd_line "$CALL(GetBinDir)mplink -k $CALL(GetStdLinkerScriptsDir) -l $CALL(GetStdLibsDir) intrinsics.lib stdn.lib $INFILE -o $OUTFILE"), + (cmd_line "$CALL(GetBinDir)mplink -e -k $CALL(GetStdLinkerScriptsDir) -l $CALL(GetStdLibsDir) intrinsics.lib stdn.lib $INFILE -o $OUTFILE"), (actions (case (not_empty "Wl,"), (forward_value "Wl,"), - (switch_on "r"), (append_cmd "-e"), (switch_on "X"), (append_cmd "-x"), (not_empty "L"), (forward_as "L", "-l"), (not_empty "K"), (forward_as "K", "-k"), (not_empty "m"), (forward "m"), (not_empty "p"), [(forward "p"), (append_cmd "-c")], (empty "p"), (append_cmd "-p 16f1xxx -c"), - (not_empty "k"), (forward_value "k"), - (not_empty "l"), (forward_value "l"))), +// (not_empty "l"), [(unpack_values "l"),(append_cmd ".lib")])), + (not_empty "k"), (forward "k"), + (not_empty "l"), (forward "l"))), (join) ]>; diff --git a/tools/llvmc/example/mcc16/plugins/PIC16Base/PluginMain.cpp b/tools/llvmc/example/mcc16/plugins/PIC16Base/PluginMain.cpp index a6d2ff6b1a..9b2f9fc544 100644 --- a/tools/llvmc/example/mcc16/plugins/PIC16Base/PluginMain.cpp +++ b/tools/llvmc/example/mcc16/plugins/PIC16Base/PluginMain.cpp @@ -9,6 +9,8 @@ namespace llvmc { extern char *ProgramName; } + + // Returns the platform specific directory separator via #ifdefs. // FIXME: This currently work on linux and windows only. It does not // work on other unices. @@ -21,6 +23,43 @@ static std::string GetDirSeparator() { } namespace hooks { +// Get preprocessor define for the part. +// It is __partname format in lower case. +std::string +GetLowerCasePartDefine(void) { + std::string Partname; + if (AutoGeneratedParameter_p.empty()) { + Partname = "16f1xxx"; + } else { + Partname = AutoGeneratedParameter_p; + } + + std::string LowerCase; + for (unsigned i = 0; i <= Partname.size(); i++) { + LowerCase.push_back(std::tolower(Partname[i])); + } + + return "__" + LowerCase; +} + +std::string +GetUpperCasePartDefine(void) { + std::string Partname; + if (AutoGeneratedParameter_p.empty()) { + Partname = "16f1xxx"; + } else { + Partname = AutoGeneratedParameter_p; + } + + std::string UpperCase; + for (unsigned i = 0; i <= Partname.size(); i++) { + UpperCase.push_back(std::toupper(Partname[i])); + } + + return "__" + UpperCase; +} + + // Get the dir where c16 executables reside. std::string GetBinDir() { // Construct a Path object from the program name. |