A small refactoring (extract method) + some comment fixes.
[oota-llvm.git] / tools / llvmc2 / Common.td
1 //===- Tools.td - Common definitions for LLVMCC  -----------*- 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 common definitions used in llvmcc tool description files.
11 //
12 //===----------------------------------------------------------------------===//
13
14 class Tool<list<dag> l> {
15       list<dag> properties = l;
16 }
17
18 // Special Tool instance - the root node of the compilation graph.
19
20 def root : Tool<[]>;
21
22 // Possible Tool properties
23
24 def in_language;
25 def out_language;
26 def output_suffix;
27 def cmd_line;
28 def join;
29 def sink;
30
31 // Possible option types
32
33 def switch_option;
34 def parameter_option;
35 def parameter_list_option;
36 def prefix_option;
37 def prefix_list_option;
38
39 // Possible option properties
40
41 def append_cmd;
42 def forward;
43 def stop_compilation;
44 def unpack_values;
45 def help;
46 def required;
47
48 // Possible edge properties
49
50 // 'Atomic' properties.
51 def switch_on;
52 def parameter_equals;
53 def element_in_list;
54 def if_input_languages_contain;
55
56 // Edge property combinators.
57 def weight;
58 def and;
59 def or;
60
61 // Map from suffixes to language names
62
63 class LangToSuffixes<string str, list<string> lst> {
64       string lang = str;
65       list<string> suffixes = lst;
66 }
67
68 class LanguageMap<list<LangToSuffixes> lst> {
69       list<LangToSuffixes> map = lst;
70 }
71
72 // Compilation graph
73
74 class EdgeBase<Tool t1, Tool t2, list<dag> lst> {
75       Tool a = t1;
76       Tool b = t2;
77       list<dag> props = lst;
78 }
79
80 class Edge<Tool t1, Tool t2> : EdgeBase<t1, t2, []>;
81
82 // Edge and SimpleEdge are synonyms.
83 class SimpleEdge<Tool t1, Tool t2> : EdgeBase<t1, t2, []>;
84
85 // Optionally enabled edge.
86 class OptionalEdge<Tool t1, Tool t2, list<dag> lst> : EdgeBase<t1, t2, lst>;
87
88 class CompilationGraph<list<EdgeBase> lst> {
89       list<EdgeBase> edges = lst;
90 }