1 //===- Clang.td - LLVMC toolchain descriptions -------------*- tablegen -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file contains compilation graph description used by llvmc.
12 //===----------------------------------------------------------------------===//
15 def Options : OptionList<[
16 (switch_option "clang", (help "Use Clang instead of llvm-gcc"))
19 class clang_based<string language, string cmd, string ext_E> : Tool<
20 [(in_language language),
21 (out_language "llvm-bitcode"),
24 (actions (case (switch_on "E"),
25 [(forward "E"), (stop_compilation), (output_suffix ext_E)],
26 (and (switch_on "E"), (empty "o")), (no_out_file),
27 (switch_on "fsyntax-only"), (stop_compilation),
28 (switch_on "S", "emit-llvm"),
29 [(append_cmd "-emit-llvm"),
30 (stop_compilation), (output_suffix "ll")],
31 (not (switch_on "S", "emit-llvm")),
32 (append_cmd "-emit-llvm-bc"),
33 (switch_on "c", "emit-llvm"),
35 (not_empty "include"), (forward "include"),
36 (not_empty "I"), (forward "I"))),
40 def clang_c : clang_based<"c", "clang -x c", "i">;
41 def clang_cpp : clang_based<"c++", "clang -x c++", "i">;
42 def clang_objective_c : clang_based<"objective-c",
43 "clang -x objective-c", "mi">;
44 def clang_objective_cpp : clang_based<"objective-c++",
45 "clang -x objective-c++", "mi">;
48 [(in_language "assembler"),
49 (out_language "object-code"),
52 (actions (case (not_empty "Wa,"), (forward_value "Wa,"),
53 (switch_on "c"), (stop_compilation)))
58 [(in_language "object-code"),
59 (out_language "executable"),
60 (output_suffix "out"),
61 (command "llvm-ld -native -disable-internalize"),
63 (switch_on "pthread"), (append_cmd "-lpthread"),
64 (not_empty "L"), (forward "L"),
65 (not_empty "l"), (forward "l"),
66 (not_empty "Wl,"), (forward_value "Wl,"))),
72 def ClangCompilationGraph : CompilationGraph<[
73 (optional_edge "root", "clang_c",
74 (case (switch_on "clang"), (inc_weight))),
75 (optional_edge "root", "clang_cpp",
76 (case (switch_on "clang"), (inc_weight))),
77 (optional_edge "root", "clang_objective_c",
78 (case (switch_on "clang"), (inc_weight))),
79 (optional_edge "root", "clang_objective_cpp",
80 (case (switch_on "clang"), (inc_weight))),
81 (edge "clang_c", "llc"),
82 (edge "clang_cpp", "llc"),
83 (edge "clang_objective_c", "llc"),
84 (edge "clang_objective_cpp", "llc"),
85 (optional_edge "llc", "as", (case (switch_on "clang"), (inc_weight))),
86 (edge "as", "llvm_ld")