diff options
author | Roman Divacky <rdivacky@FreeBSD.org> | 2009-10-14 17:57:32 +0000 |
---|---|---|
committer | Roman Divacky <rdivacky@FreeBSD.org> | 2009-10-14 17:57:32 +0000 |
commit | 59850d0874429601812bc13408cb1f776649027c (patch) | |
tree | b21f6de4e08b89bb7931806bab798fc2a5e3a686 /tools/llvmc/example | |
parent | 18f153bdb9db52e7089a2d5293b96c45a3124a26 (diff) |
Notes
Diffstat (limited to 'tools/llvmc/example')
-rw-r--r-- | tools/llvmc/example/Hello/Hello.cpp | 5 | ||||
-rw-r--r-- | tools/llvmc/example/mcc16/driver/Main.cpp | 27 | ||||
-rw-r--r-- | tools/llvmc/example/mcc16/plugins/PIC16Base/PIC16Base.td | 6 | ||||
-rw-r--r-- | tools/llvmc/example/mcc16/plugins/PIC16Base/PluginMain.cpp | 18 |
4 files changed, 41 insertions, 15 deletions
diff --git a/tools/llvmc/example/Hello/Hello.cpp b/tools/llvmc/example/Hello/Hello.cpp index 23a13a57c2b84..9c96bd0a416bf 100644 --- a/tools/llvmc/example/Hello/Hello.cpp +++ b/tools/llvmc/example/Hello/Hello.cpp @@ -13,13 +13,12 @@ #include "llvm/CompilerDriver/CompilationGraph.h" #include "llvm/CompilerDriver/Plugin.h" - -#include <iostream> +#include "llvm/Support/raw_ostream.h" namespace { struct MyPlugin : public llvmc::BasePlugin { void PopulateLanguageMap(llvmc::LanguageMap&) const - { std::cout << "Hello!\n"; } + { outs() << "Hello!\n"; } void PopulateCompilationGraph(llvmc::CompilationGraph&) const {} diff --git a/tools/llvmc/example/mcc16/driver/Main.cpp b/tools/llvmc/example/mcc16/driver/Main.cpp index b1f5b6798ae69..f42e17f641157 100644 --- a/tools/llvmc/example/mcc16/driver/Main.cpp +++ b/tools/llvmc/example/mcc16/driver/Main.cpp @@ -7,8 +7,31 @@ // //===----------------------------------------------------------------------===// // -// Just include CompilerDriver/Main.inc. +// Usually this file just includes CompilerDriver/Main.inc, but here we apply +// some trickery to make the built-in '-save-temps' option hidden and enable +// '--temp-dir' by default. // //===----------------------------------------------------------------------===// -#include "llvm/CompilerDriver/Main.inc" +#include "llvm/CompilerDriver/BuiltinOptions.h" +#include "llvm/CompilerDriver/ForceLinkage.h" +#include "llvm/System/Path.h" + +namespace llvmc { + int Main(int argc, char** argv); +} + +int main(int argc, char** argv) { + + // HACK + SaveTemps.setHiddenFlag(llvm::cl::Hidden); + TempDirname = "tmp-objs"; + + // Remove the temp dir if already exists. + llvm::sys::Path tempDir; + tempDir = TempDirname; + tempDir.eraseFromDisk(true); + + llvmc::ForceLinkage(); + return llvmc::Main(argc, argv); +} diff --git a/tools/llvmc/example/mcc16/plugins/PIC16Base/PIC16Base.td b/tools/llvmc/example/mcc16/plugins/PIC16Base/PIC16Base.td index de85fa9d59d4b..3d25ab612a0c6 100644 --- a/tools/llvmc/example/mcc16/plugins/PIC16Base/PIC16Base.td +++ b/tools/llvmc/example/mcc16/plugins/PIC16Base/PIC16Base.td @@ -55,7 +55,7 @@ def llvm_ld_lto : Tool<[ (in_language "llvm-bitcode"), (out_language "llvm-bitcode"), (output_suffix "bc"), - (cmd_line "$CALL(GetBinDir)llvm-ld -link-as-library $INFILE -o $OUTFILE"), + (cmd_line "$CALL(GetBinDir)llvm-ld -L $CALL(GetStdLibsDir) -l std $INFILE -b $OUTFILE"), (actions (case (switch_on "g"), (append_cmd "-disable-opt"), (not_empty "Wo,"), (unpack_values "Wo,"))), @@ -66,7 +66,7 @@ def llc : Tool<[ (in_language "llvm-bitcode"), (out_language "assembler"), (output_suffix "s"), - (cmd_line "$CALL(GetBinDir)llc -march=pic16 -f $INFILE -o $OUTFILE"), + (cmd_line "$CALL(GetBinDir)llc -march=pic16 -disable-jump-tables -f $INFILE -o $OUTFILE"), (actions (case (switch_on "S"), (stop_compilation), (not_empty "Wllc,"), (unpack_values "Wllc,"), @@ -87,7 +87,7 @@ def mplink : Tool<[ (in_language "object-code"), (out_language "executable"), (output_suffix "out"), - (cmd_line "$CALL(GetBinDir)mplink.exe /k $CALL(GetStdLinkerScriptsDir) /l $CALL(GetStdLibsDir) 16f1937.lkr intrinsics.lib std.lib $INFILE -o $OUTFILE"), + (cmd_line "$CALL(GetBinDir)mplink.exe -k $CALL(GetStdLinkerScriptsDir) -l $CALL(GetStdLibsDir) 16f1937_g.lkr intrinsics.lib devices.lib $INFILE -o $OUTFILE"), (actions (case (not_empty "Wl,"), (unpack_values "Wl,"))), (join) diff --git a/tools/llvmc/example/mcc16/plugins/PIC16Base/PluginMain.cpp b/tools/llvmc/example/mcc16/plugins/PIC16Base/PluginMain.cpp index 21a25b3f734b2..f8492ed45d8e5 100644 --- a/tools/llvmc/example/mcc16/plugins/PIC16Base/PluginMain.cpp +++ b/tools/llvmc/example/mcc16/plugins/PIC16Base/PluginMain.cpp @@ -10,13 +10,17 @@ namespace llvmc { } // Returns the platform specific directory separator via #ifdefs. -static std::string GetDirSeparator(void) { +static std::string GetDirSeparator() { +#ifdef _WIN32 + return "\\"; +#else return "/"; +#endif } namespace hooks { // Get the dir where c16 executables reside. -std::string GetBinDir (void) { +std::string GetBinDir() { // Construct a Path object from the program name. void *P = (void*) (intptr_t) GetBinDir; sys::Path ProgramFullPath @@ -30,7 +34,7 @@ std::string GetBinDir (void) { } // Get the Top-level Installation dir for c16. -std::string GetInstallDir (void) { +std::string GetInstallDir() { sys::Path BinDirPath = sys::Path(GetBinDir()); // Go one more level up to get the install dir. @@ -40,22 +44,22 @@ std::string GetInstallDir (void) { } // Get the dir where the c16 header files reside. -std::string GetStdHeadersDir (void) { +std::string GetStdHeadersDir() { return GetInstallDir() + "include"; } // Get the dir where the assembler header files reside. -std::string GetStdAsmHeadersDir (void) { +std::string GetStdAsmHeadersDir() { return GetInstallDir() + "inc"; } // Get the dir where the linker scripts reside. -std::string GetStdLinkerScriptsDir (void) { +std::string GetStdLinkerScriptsDir() { return GetInstallDir() + "lkr"; } // Get the dir where startup code, intrinsics and lib reside. -std::string GetStdLibsDir (void) { +std::string GetStdLibsDir() { return GetInstallDir() + "lib"; } } |