summaryrefslogtreecommitdiffstats
path: root/tools/llvmc/example/mcc16/plugins
diff options
context:
space:
mode:
authored <ed@FreeBSD.org>2009-07-04 13:58:26 +0000
committered <ed@FreeBSD.org>2009-07-04 13:58:26 +0000
commit72621d11de5b873f1695f391eb95f0b336c3d2d4 (patch)
tree84360c8989c912127a383af37c4b1aa5767bd16e /tools/llvmc/example/mcc16/plugins
parentcf5cd875b51255602afaed29deb636b66b295671 (diff)
downloadFreeBSD-src-72621d11de5b873f1695f391eb95f0b336c3d2d4.zip
FreeBSD-src-72621d11de5b873f1695f391eb95f0b336c3d2d4.tar.gz
Import LLVM 74788.
Diffstat (limited to 'tools/llvmc/example/mcc16/plugins')
-rw-r--r--tools/llvmc/example/mcc16/plugins/PIC16Base/PIC16Base.td29
-rw-r--r--tools/llvmc/example/mcc16/plugins/PIC16Base/PluginMain.cpp60
2 files changed, 77 insertions, 12 deletions
diff --git a/tools/llvmc/example/mcc16/plugins/PIC16Base/PIC16Base.td b/tools/llvmc/example/mcc16/plugins/PIC16Base/PIC16Base.td
index 0b8a22b..de85fa9 100644
--- a/tools/llvmc/example/mcc16/plugins/PIC16Base/PIC16Base.td
+++ b/tools/llvmc/example/mcc16/plugins/PIC16Base/PIC16Base.td
@@ -10,9 +10,11 @@ include "llvm/CompilerDriver/Common.td"
def OptionList : OptionList<[
(switch_option "g",
- (help "Disable optimizations")),
+ (help "Enable Debugging")),
(switch_option "S",
(help "Stop after compilation, do not assemble")),
+ (switch_option "c",
+ (help "Stop after assemble, do not link")),
(parameter_option "I",
(help "Add a directory to include path")),
(parameter_option "pre-RA-sched",
@@ -33,7 +35,7 @@ def clang_cc : Tool<[
(in_language "c"),
(out_language "llvm-bitcode"),
(output_suffix "bc"),
- (cmd_line "clang-cc $INFILE -o $OUTFILE"),
+ (cmd_line "$CALL(GetBinDir)clang-cc -I $CALL(GetStdHeadersDir) -triple=pic16- -emit-llvm-bc $INFILE -o $OUTFILE"),
(actions (case
(not_empty "I"), (forward "I"))),
(sink)
@@ -43,7 +45,7 @@ def llvm_ld : Tool<[
(in_language "llvm-bitcode"),
(out_language "llvm-bitcode"),
(output_suffix "bc"),
- (cmd_line "llvm-ld $INFILE -o $OUTFILE"),
+ (cmd_line "$CALL(GetBinDir)llvm-ld -link-as-library $INFILE -o $OUTFILE"),
(actions (case
(switch_on "g"), (append_cmd "-disable-opt"),
(not_empty "Wo,"), (unpack_values "Wo,")))
@@ -53,7 +55,7 @@ def llvm_ld_lto : Tool<[
(in_language "llvm-bitcode"),
(out_language "llvm-bitcode"),
(output_suffix "bc"),
- (cmd_line "llvm-ld $INFILE -o $OUTFILE"),
+ (cmd_line "$CALL(GetBinDir)llvm-ld -link-as-library $INFILE -o $OUTFILE"),
(actions (case
(switch_on "g"), (append_cmd "-disable-opt"),
(not_empty "Wo,"), (unpack_values "Wo,"))),
@@ -64,27 +66,28 @@ def llc : Tool<[
(in_language "llvm-bitcode"),
(out_language "assembler"),
(output_suffix "s"),
- (cmd_line "llc -f $INFILE -o $OUTFILE"),
+ (cmd_line "$CALL(GetBinDir)llc -march=pic16 -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")))
]>;
-def native_as : Tool<[
+def gpasm : Tool<[
(in_language "assembler"),
(out_language "object-code"),
(output_suffix "o"),
- (cmd_line "native-as $INFILE -o $OUTFILE"),
+ (cmd_line "$CALL(GetBinDir)gpasm -r decimal -p p16F1937 -I $CALL(GetStdAsmHeadersDir) -C -c $INFILE -o $OUTFILE"),
(actions (case
+ (switch_on "c"), (stop_compilation),
(not_empty "Wa,"), (unpack_values "Wa,")))
]>;
-def native_ld : Tool<[
+def mplink : Tool<[
(in_language "object-code"),
(out_language "executable"),
(output_suffix "out"),
- (cmd_line "native-ld $INFILE -o $OUTFILE"),
+ (cmd_line "$CALL(GetBinDir)mplink.exe /k $CALL(GetStdLinkerScriptsDir) /l $CALL(GetStdLibsDir) 16f1937.lkr intrinsics.lib std.lib $INFILE -o $OUTFILE"),
(actions (case
(not_empty "Wl,"), (unpack_values "Wl,"))),
(join)
@@ -109,8 +112,10 @@ def CompilationGraph : CompilationGraph<[
Edge<"root", "clang_cc">,
Edge<"clang_cc", "llvm_ld_lto">,
Edge<"llvm_ld_lto", "llc">,
- OptionalEdge<"clang_cc", "llvm_ld", (case (switch_on "S"), (inc_weight))>,
+ OptionalEdge<"clang_cc", "llvm_ld", (case
+ (switch_on "S"), (inc_weight),
+ (switch_on "c"), (inc_weight))>,
Edge<"llvm_ld", "llc">,
- Edge<"llc", "native_as">,
- Edge<"native_as", "native_ld">
+ Edge<"llc", "gpasm">,
+ Edge<"gpasm", "mplink">
]>;
diff --git a/tools/llvmc/example/mcc16/plugins/PIC16Base/PluginMain.cpp b/tools/llvmc/example/mcc16/plugins/PIC16Base/PluginMain.cpp
index add8acb..21a25b3 100644
--- a/tools/llvmc/example/mcc16/plugins/PIC16Base/PluginMain.cpp
+++ b/tools/llvmc/example/mcc16/plugins/PIC16Base/PluginMain.cpp
@@ -1 +1,61 @@
#include "AutoGenerated.inc"
+
+#include "llvm/System/Path.h"
+#include "llvm/Support/raw_ostream.h"
+
+using namespace llvm;
+
+namespace llvmc {
+ extern char *ProgramName;
+}
+
+// Returns the platform specific directory separator via #ifdefs.
+static std::string GetDirSeparator(void) {
+ return "/";
+}
+
+namespace hooks {
+// Get the dir where c16 executables reside.
+std::string GetBinDir (void) {
+ // Construct a Path object from the program name.
+ void *P = (void*) (intptr_t) GetBinDir;
+ sys::Path ProgramFullPath
+ = sys::Path::GetMainExecutable(llvmc::ProgramName, P);
+
+ // Get the dir name for the program. It's last component should be 'bin'.
+ std::string BinDir = ProgramFullPath.getDirname();
+
+ // llvm::errs() << "BinDir: " << BinDir << '\n';
+ return BinDir + GetDirSeparator();
+}
+
+// Get the Top-level Installation dir for c16.
+std::string GetInstallDir (void) {
+ sys::Path BinDirPath = sys::Path(GetBinDir());
+
+ // Go one more level up to get the install dir.
+ std::string InstallDir = BinDirPath.getDirname();
+
+ return InstallDir + GetDirSeparator();
+}
+
+// Get the dir where the c16 header files reside.
+std::string GetStdHeadersDir (void) {
+ return GetInstallDir() + "include";
+}
+
+// Get the dir where the assembler header files reside.
+std::string GetStdAsmHeadersDir (void) {
+ return GetInstallDir() + "inc";
+}
+
+// Get the dir where the linker scripts reside.
+std::string GetStdLinkerScriptsDir (void) {
+ return GetInstallDir() + "lkr";
+}
+
+// Get the dir where startup code, intrinsics and lib reside.
+std::string GetStdLibsDir (void) {
+ return GetInstallDir() + "lib";
+}
+}
OpenPOWER on IntegriCloud