[llvm-commits] [llvm] r74611 - in /llvm/trunk/tools/llvmc/example/mcc16/plugins/PIC16Base: PIC16Base.td PluginMain.cpp

Sanjiv Gupta sanjiv.gupta at microchip.com
Wed Jul 1 09:10:37 PDT 2009


Author: sgupta
Date: Wed Jul  1 11:10:29 2009
New Revision: 74611

URL: http://llvm.org/viewvc/llvm-project?rev=74611&view=rev
Log:
Executables will be at InstallDir/bin directory. Std header files will be at InstallDir/include, libs will be at InstallDir/lib. Define hooks for these and use them in the options for various tools.

Modified:
    llvm/trunk/tools/llvmc/example/mcc16/plugins/PIC16Base/PIC16Base.td
    llvm/trunk/tools/llvmc/example/mcc16/plugins/PIC16Base/PluginMain.cpp

Modified: llvm/trunk/tools/llvmc/example/mcc16/plugins/PIC16Base/PIC16Base.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc/example/mcc16/plugins/PIC16Base/PIC16Base.td?rev=74611&r1=74610&r2=74611&view=diff

==============================================================================
--- llvm/trunk/tools/llvmc/example/mcc16/plugins/PIC16Base/PIC16Base.td (original)
+++ llvm/trunk/tools/llvmc/example/mcc16/plugins/PIC16Base/PIC16Base.td Wed Jul  1 11:10:29 2009
@@ -10,7 +10,7 @@
 
 def OptionList : OptionList<[
  (switch_option "g",
-    (help "Disable optimizations")),
+    (help "Enable Debugging")),
  (switch_option "S",
     (help "Stop after compilation, do not assemble")),
  (parameter_option "I",
@@ -33,7 +33,7 @@
  (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 +43,7 @@
  (in_language "llvm-bitcode"),
  (out_language "llvm-bitcode"),
  (output_suffix "bc"),
- (cmd_line "llvm-ld $INFILE -o $OUTFILE"),
+ (cmd_line "llvm-ld -f -link-as-library $INFILE -o $OUTFILE"),
  (actions (case
           (switch_on "g"), (append_cmd "-disable-opt"),
           (not_empty "Wo,"), (unpack_values "Wo,")))
@@ -53,7 +53,7 @@
  (in_language "llvm-bitcode"),
  (out_language "llvm-bitcode"),
  (output_suffix "bc"),
- (cmd_line "llvm-ld $INFILE -o $OUTFILE"),
+ (cmd_line "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 +64,27 @@
  (in_language "llvm-bitcode"),
  (out_language "assembler"),
  (output_suffix "s"),
- (cmd_line "llc -f $INFILE -o $OUTFILE"),
+ (cmd_line "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 "gpasm -I $CALL(GetStdAsmHeadersDir) $INFILE -o $OUTFILE"),
  (actions (case
           (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 "mplink /k $CALL(GetStdLinkerScriptsDir) /l $CALL(GetStdLibsDir) $INFILE -o $OUTFILE"),
  (actions (case
           (not_empty "Wl,"), (unpack_values "Wl,"))),
  (join)
@@ -111,6 +111,6 @@
     Edge<"llvm_ld_lto", "llc">,
     OptionalEdge<"clang_cc", "llvm_ld", (case (switch_on "S"), (inc_weight))>,
     Edge<"llvm_ld", "llc">,
-    Edge<"llc", "native_as">,
-    Edge<"native_as", "native_ld">
+    Edge<"llc", "gpasm">,
+    Edge<"gpasm", "mplink">
 ]>;

Modified: llvm/trunk/tools/llvmc/example/mcc16/plugins/PIC16Base/PluginMain.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc/example/mcc16/plugins/PIC16Base/PluginMain.cpp?rev=74611&r1=74610&r2=74611&view=diff

==============================================================================
--- llvm/trunk/tools/llvmc/example/mcc16/plugins/PIC16Base/PluginMain.cpp (original)
+++ llvm/trunk/tools/llvmc/example/mcc16/plugins/PIC16Base/PluginMain.cpp Wed Jul  1 11:10:29 2009
@@ -1 +1,48 @@
 #include "AutoGenerated.inc"
+#include "llvm/System/Path.h"
+
+namespace llvmc {
+  extern char *ProgramName;
+}
+
+// Returns the platform specific directory separator via #ifdefs.
+static std::string GetDirSeparator(void) {
+  return "/";
+}
+
+namespace hooks {
+std::string GetBinDir (void) {
+  // Construct a Path object from the program name.  
+  llvm::sys::Path ProgramFullName(llvmc::ProgramName, 
+                                  strlen(llvmc::ProgramName));
+
+  // Get the dir name for the program. It's last component should be 'bin'.
+  std::string BinDir = ProgramFullName.getDirname();
+
+  return BinDir + GetDirSeparator();
+}
+
+std::string GetInstallDir (void) {
+  llvm::sys::Path BinDirPath = llvm::sys::Path(GetBinDir());
+
+  // Go one more level up to get the install dir.
+  std::string InstallDir  = BinDirPath.getDirname();
+  
+  return InstallDir + GetDirSeparator();
+}
+
+std::string GetStdHeadersDir (void) {
+  return GetInstallDir() + "include";
+}
+
+std::string GetStdAsmHeadersDir (void) {
+  return GetInstallDir() + "inc";
+}
+std::string GetStdLinkerScriptsDir (void) {
+  return GetInstallDir() + "lkr";
+}
+
+std::string GetStdLibsDir (void) {
+  return GetInstallDir() + "lib";
+}
+}





More information about the llvm-commits mailing list