[llvm-commits] [llvm] r60666 - in /llvm/trunk: include/llvm/CompilerDriver/Tools.td tools/llvmc/plugins/Clang/Clang.td

Mikhail Glushenkov foldr at codedgers.com
Sun Dec 7 08:46:23 PST 2008


Author: foldr
Date: Sun Dec  7 10:46:23 2008
New Revision: 60666

URL: http://llvm.org/viewvc/llvm-project?rev=60666&view=rev
Log:
Plugin updates: support more options.

Modified:
    llvm/trunk/include/llvm/CompilerDriver/Tools.td
    llvm/trunk/tools/llvmc/plugins/Clang/Clang.td

Modified: llvm/trunk/include/llvm/CompilerDriver/Tools.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CompilerDriver/Tools.td?rev=60666&r1=60665&r2=60666&view=diff

==============================================================================
--- llvm/trunk/include/llvm/CompilerDriver/Tools.td (original)
+++ llvm/trunk/include/llvm/CompilerDriver/Tools.td Sun Dec  7 10:46:23 2008
@@ -24,6 +24,8 @@
     (help "Stop after compilation, do not assemble")),
  (switch_option "c",
     (help "Compile and assemble, but do not link")),
+ (switch_option "pthread",
+    (help "Enable threads")),
  (parameter_option "linker",
     (help "Choose linker (possible values: gcc, g++)")),
  (parameter_list_option "include",
@@ -57,10 +59,11 @@
  (actions
      (case
          (switch_on "emit-llvm"), (stop_compilation),
-         (switch_on "E"), (stop_compilation),
+         (switch_on "E"), [(stop_compilation), (output_suffix "i")],
+         (switch_on "S"), (stop_compilation),
          (switch_on "fsyntax-only"), (stop_compilation),
          (not_empty "include"), (forward "include"),
-         (not_empty "I"), (forward "include"))),
+         (not_empty "I"), (forward "I"))),
  (sink)
 ]>;
 
@@ -83,15 +86,6 @@
  (cmd_line "llvm-as $INFILE -o $OUTFILE")
 ]>;
 
-def llc : Tool<
-[(in_language "llvm-bitcode"),
- (out_language "assembler"),
- (output_suffix "s"),
- (actions (case
-          (switch_on "S"), (stop_compilation))),
- (cmd_line "llc -f $INFILE -o $OUTFILE")
-]>;
-
 def llvm_gcc_assembler : Tool<
 [(in_language "assembler"),
  (out_language "object-code"),
@@ -102,6 +96,14 @@
           (not_empty "Wa,"), (unpack_values "Wa,")))
 ]>;
 
+def llc : Tool<
+[(in_language "llvm-bitcode"),
+ (out_language "assembler"),
+ (output_suffix "s"),
+ (cmd_line "llc -relocation-model=pic -f $INFILE -o $OUTFILE"),
+ (actions (case (switch_on "S"), (stop_compilation)))
+]>;
+
 // Base class for linkers
 class llvm_gcc_based_linker <string cmd_prefix> : Tool<
 [(in_language "object-code"),
@@ -110,6 +112,7 @@
  (cmd_line !strconcat(cmd_prefix, " $INFILE -o $OUTFILE")),
  (join),
  (actions (case
+          (switch_on "pthread"), (append_cmd "-lpthread"),
           (not_empty "L"), (forward "L"),
           (not_empty "l"), (forward "l"),
           (not_empty "Wl,"), (unpack_values "Wl,")))
@@ -125,9 +128,12 @@
 def LanguageMap : LanguageMap<
     [LangToSuffixes<"c++", ["cc", "cp", "cxx", "cpp", "CPP", "c++", "C"]>,
      LangToSuffixes<"c", ["c"]>,
+     LangToSuffixes<"c-cpp-output", ["i"]>,
+     LangToSuffixes<"objective-c-cpp-output", ["mi"]>,
      LangToSuffixes<"objective-c++", ["mm"]>,
      LangToSuffixes<"objective-c", ["m"]>,
      LangToSuffixes<"assembler", ["s"]>,
+     LangToSuffixes<"assembler-with-cpp", ["S"]>,
      LangToSuffixes<"llvm-assembler", ["ll"]>,
      LangToSuffixes<"llvm-bitcode", ["bc"]>,
      LangToSuffixes<"object-code", ["o"]>,

Modified: llvm/trunk/tools/llvmc/plugins/Clang/Clang.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc/plugins/Clang/Clang.td?rev=60666&r1=60665&r2=60666&view=diff

==============================================================================
--- llvm/trunk/tools/llvmc/plugins/Clang/Clang.td (original)
+++ llvm/trunk/tools/llvmc/plugins/Clang/Clang.td Sun Dec  7 10:46:23 2008
@@ -6,14 +6,24 @@
 
 include "llvm/CompilerDriver/Common.td"
 
+def Priority : PluginPriority<1>;
+
 def Options : OptionList<[
-(extern_switch "E",
-    (help "Stop after the preprocessing stage, do not run the compiler")),
-(extern_list "L", (help "Specify a library search path")),
+(extern_switch "E"),
+(extern_switch "c"),
+(extern_switch "fsyntax-only"),
+(extern_switch "emit-llvm"),
+(extern_switch "pthread"),
+(extern_list "I"),
+(extern_list "include"),
+(extern_list "L"),
+(extern_list "l"),
+(extern_list "Wa,"),
+(extern_list "Wl,"),
 (switch_option "clang", (help "Use Clang instead of llvm-gcc"))
 ]>;
 
-class clang_based<string language, string cmd> : Tool<
+class clang_based<string language, string cmd, string ext_E> : Tool<
 [(in_language language),
  (out_language "llvm-bitcode"),
  (output_suffix "bc"),
@@ -24,38 +34,58 @@
                 !strconcat(cmd, " -E $INFILE -o $OUTFILE"),
                 (default),
                 !strconcat(cmd, " -E $INFILE")),
+          (switch_on "c"),
+          !strconcat(cmd, " -fsyntax-only $INFILE"),
           (default),
           !strconcat(cmd, " -emit-llvm-bc $INFILE -o $OUTFILE"))),
  (actions (case (switch_on "E"),
-                [(stop_compilation), (output_suffix "i")])),
+                [(stop_compilation), (output_suffix ext_E)],
+                (switch_on "c"), (stop_compilation),
+                (switch_on "fsyntax-only"), (stop_compilation),
+                (switch_on "emit-llvm"), (stop_compilation),
+                (not_empty "include"), (forward "include"),
+                (not_empty "I"), (forward "I"))),
  (sink)
 ]>;
 
-def clang_c : clang_based<"c", "clang -x c">;
-def clang_cpp : clang_based<"c++", "clang -x c++">;
-def clang_objective_c : clang_based<"objective-c", "clang -x objective-c">;
+def clang_c : clang_based<"c", "clang -x c", "i">;
+def clang_cpp : clang_based<"c++", "clang -x c++", "i">;
+def clang_objective_c : clang_based<"objective-c",
+    "clang -x objective-c", "mi">;
 def clang_objective_cpp : clang_based<"objective-c++",
-    "clang -x objective-c++">;
+    "clang -x objective-c++", "mi">;
+
+def as : Tool<
+[(in_language "assembler"),
+ (out_language "object-code"),
+ (output_suffix "o"),
+ (cmd_line "as $INFILE -o $OUTFILE"),
+ (actions (case (not_empty "Wa,"), (unpack_values "Wa,")))
+]>;
 
 // Default linker
 def llvm_ld : Tool<
-[(in_language "llvm-bitcode"),
+[(in_language "object-code"),
  (out_language "executable"),
  (output_suffix "out"),
  (cmd_line "llvm-ld -native -disable-internalize $INFILE -o $OUTFILE"),
- (actions (case (not_empty "L"), (forward "L"))),
+ (actions (case
+          (switch_on "pthread"), (append_cmd "-lpthread"),
+          (not_empty "L"), (forward "L"),
+          (not_empty "l"), (forward "l"),
+          (not_empty "Wl,"), (unpack_values "Wl,"))),
  (join)
 ]>;
 
 // Language map
 
-def LanguageMap : LanguageMap<
-    [LangToSuffixes<"c++", ["cc", "cp", "cxx", "cpp", "CPP", "c++", "C"]>,
-     LangToSuffixes<"c", ["c"]>,
-     LangToSuffixes<"objective-c", ["m"]>,
-     LangToSuffixes<"c-cpp-output", ["i"]>,
-     LangToSuffixes<"objective-c-cpp-output", ["mi"]>
-     ]>;
+def LanguageMap : LanguageMap<[
+    LangToSuffixes<"c++", ["cc", "cp", "cxx", "cpp", "CPP", "c++", "C"]>,
+    LangToSuffixes<"c", ["c"]>,
+    LangToSuffixes<"objective-c", ["m"]>,
+    LangToSuffixes<"c-cpp-output", ["i"]>,
+    LangToSuffixes<"objective-c-cpp-output", ["mi"]>
+]>;
 
 // Compilation graph
 
@@ -66,7 +96,12 @@
                          (case (switch_on "clang"), (inc_weight))>,
     OptionalEdge<"root", "clang_objective_c",
                          (case (switch_on "clang"), (inc_weight))>,
-    Edge<"clang_c", "llvm_ld">,
-    Edge<"clang_cpp", "llvm_ld">,
-    Edge<"clang_objective_c", "llvm_ld">
-    ]>;
+    OptionalEdge<"root", "clang_objective_cpp",
+                         (case (switch_on "clang"), (inc_weight))>,
+    Edge<"clang_c", "llc">,
+    Edge<"clang_cpp", "llc">,
+    Edge<"clang_objective_c", "llc">,
+    Edge<"clang_objective_cpp", "llc">,
+    OptionalEdge<"llc", "as", (case (switch_on "clang"), (inc_weight))>,
+    Edge<"as", "llvm_ld">
+]>;





More information about the llvm-commits mailing list