1//===- Clang.td - LLVMC toolchain descriptions -------------*- tablegen -*-===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9// 10// This file contains compilation graph description used by llvmc. 11// 12//===----------------------------------------------------------------------===// 13 14 15def Options : OptionList<[ 16(switch_option "clang", (help "Use Clang instead of llvm-gcc")) 17]>; 18 19class clang_based<string language, string cmd, string ext_E> : Tool< 20[(in_language language), 21 (out_language "llvm-bitcode"), 22 (output_suffix "bc"), 23 (command cmd), 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"), 34 (stop_compilation), 35 (not_empty "include"), (forward "include"), 36 (not_empty "I"), (forward "I"))), 37 (sink) 38]>; 39 40def clang_c : clang_based<"c", "clang -x c", "i">; 41def clang_cpp : clang_based<"c++", "clang -x c++", "i">; 42def clang_objective_c : clang_based<"objective-c", 43 "clang -x objective-c", "mi">; 44def clang_objective_cpp : clang_based<"objective-c++", 45 "clang -x objective-c++", "mi">; 46 47def as : Tool< 48[(in_language "assembler"), 49 (out_language "object-code"), 50 (output_suffix "o"), 51 (command "as"), 52 (actions (case (not_empty "Wa,"), (forward_value "Wa,"), 53 (switch_on "c"), (stop_compilation))) 54]>; 55 56// Default linker 57def llvm_ld : Tool< 58[(in_language "object-code"), 59 (out_language "executable"), 60 (output_suffix "out"), 61 (command "llvm-ld -native -disable-internalize"), 62 (actions (case 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,"))), 67 (join) 68]>; 69 70// Compilation graph 71 72def 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") 87]>; 88