Mikhail Glushenkov | 2d3327f | 2008-05-30 06:20:54 +0000 | [diff] [blame] | 1 | //===- Common.td - Common definitions for LLVMCC ----------*- tablegen -*-===// |
Anton Korobeynikov | e9ffb5b | 2008-03-23 08:57:20 +0000 | [diff] [blame] | 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 | |
Mikhail Glushenkov | 7adcf1e | 2008-05-09 08:27:26 +0000 | [diff] [blame] | 18 | // Special Tool instance - the root node of the compilation graph. |
Mikhail Glushenkov | 2cfd223 | 2008-05-06 16:35:25 +0000 | [diff] [blame] | 19 | |
| 20 | def root : Tool<[]>; |
| 21 | |
Anton Korobeynikov | e9ffb5b | 2008-03-23 08:57:20 +0000 | [diff] [blame] | 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 | |
Mikhail Glushenkov | b623c32 | 2008-05-30 06:22:52 +0000 | [diff] [blame] | 33 | def alias_option; |
Anton Korobeynikov | e9ffb5b | 2008-03-23 08:57:20 +0000 | [diff] [blame] | 34 | def switch_option; |
| 35 | def parameter_option; |
| 36 | def parameter_list_option; |
| 37 | def prefix_option; |
| 38 | def prefix_list_option; |
| 39 | |
| 40 | // Possible option properties |
| 41 | |
| 42 | def append_cmd; |
| 43 | def forward; |
| 44 | def stop_compilation; |
| 45 | def unpack_values; |
| 46 | def help; |
| 47 | def required; |
| 48 | |
Mikhail Glushenkov | b623c32 | 2008-05-30 06:22:52 +0000 | [diff] [blame] | 49 | // Empty DAG marker. |
Mikhail Glushenkov | dedba64 | 2008-05-30 06:08:50 +0000 | [diff] [blame] | 50 | def empty; |
Mikhail Glushenkov | 46d4e97 | 2008-05-06 16:36:06 +0000 | [diff] [blame] | 51 | |
Mikhail Glushenkov | dedba64 | 2008-05-30 06:08:50 +0000 | [diff] [blame] | 52 | // The 'case' construct. |
| 53 | def case; |
| 54 | |
| 55 | // Primitive tests. |
Mikhail Glushenkov | 46d4e97 | 2008-05-06 16:36:06 +0000 | [diff] [blame] | 56 | def switch_on; |
| 57 | def parameter_equals; |
| 58 | def element_in_list; |
Mikhail Glushenkov | dedba64 | 2008-05-30 06:08:50 +0000 | [diff] [blame] | 59 | def input_languages_contain; |
Mikhail Glushenkov | 242d0e6 | 2008-05-30 06:19:52 +0000 | [diff] [blame] | 60 | def not_empty; |
| 61 | // TOTHINK: remove? |
Mikhail Glushenkov | 35576b0 | 2008-05-30 06:10:19 +0000 | [diff] [blame] | 62 | def default; |
Mikhail Glushenkov | d622888 | 2008-05-06 18:15:12 +0000 | [diff] [blame] | 63 | |
Mikhail Glushenkov | dedba64 | 2008-05-30 06:08:50 +0000 | [diff] [blame] | 64 | // Boolean operators. |
Mikhail Glushenkov | 3f6743e | 2008-05-06 17:22:47 +0000 | [diff] [blame] | 65 | def and; |
Mikhail Glushenkov | d622888 | 2008-05-06 18:15:12 +0000 | [diff] [blame] | 66 | def or; |
Mikhail Glushenkov | 46d4e97 | 2008-05-06 16:36:06 +0000 | [diff] [blame] | 67 | |
Mikhail Glushenkov | dedba64 | 2008-05-30 06:08:50 +0000 | [diff] [blame] | 68 | // Increase/decrease the edge weight. |
| 69 | def inc_weight; |
| 70 | def dec_weight; |
| 71 | |
Mikhail Glushenkov | d638e85 | 2008-05-30 06:26:08 +0000 | [diff] [blame] | 72 | // Option list - used to specify aliases and sometimes help strings. |
| 73 | class OptionList<list<dag> l> { |
| 74 | list<dag> options = l; |
| 75 | } |
| 76 | |
Anton Korobeynikov | e9ffb5b | 2008-03-23 08:57:20 +0000 | [diff] [blame] | 77 | // Map from suffixes to language names |
| 78 | |
| 79 | class LangToSuffixes<string str, list<string> lst> { |
| 80 | string lang = str; |
| 81 | list<string> suffixes = lst; |
| 82 | } |
| 83 | |
| 84 | class LanguageMap<list<LangToSuffixes> lst> { |
| 85 | list<LangToSuffixes> map = lst; |
| 86 | } |
| 87 | |
Mikhail Glushenkov | 2cfd223 | 2008-05-06 16:35:25 +0000 | [diff] [blame] | 88 | // Compilation graph |
Anton Korobeynikov | e9ffb5b | 2008-03-23 08:57:20 +0000 | [diff] [blame] | 89 | |
Mikhail Glushenkov | dedba64 | 2008-05-30 06:08:50 +0000 | [diff] [blame] | 90 | class EdgeBase<Tool t1, Tool t2, dag d> { |
Mikhail Glushenkov | 2cfd223 | 2008-05-06 16:35:25 +0000 | [diff] [blame] | 91 | Tool a = t1; |
| 92 | Tool b = t2; |
Mikhail Glushenkov | dedba64 | 2008-05-30 06:08:50 +0000 | [diff] [blame] | 93 | dag weight = d; |
Anton Korobeynikov | e9ffb5b | 2008-03-23 08:57:20 +0000 | [diff] [blame] | 94 | } |
| 95 | |
Mikhail Glushenkov | dedba64 | 2008-05-30 06:08:50 +0000 | [diff] [blame] | 96 | class Edge<Tool t1, Tool t2> : EdgeBase<t1, t2, (empty)>; |
Mikhail Glushenkov | 46d4e97 | 2008-05-06 16:36:06 +0000 | [diff] [blame] | 97 | |
Mikhail Glushenkov | dfcad6c | 2008-05-06 18:18:20 +0000 | [diff] [blame] | 98 | // Edge and SimpleEdge are synonyms. |
Mikhail Glushenkov | dedba64 | 2008-05-30 06:08:50 +0000 | [diff] [blame] | 99 | class SimpleEdge<Tool t1, Tool t2> : EdgeBase<t1, t2, (empty)>; |
Mikhail Glushenkov | 46d4e97 | 2008-05-06 16:36:06 +0000 | [diff] [blame] | 100 | |
| 101 | // Optionally enabled edge. |
Mikhail Glushenkov | dedba64 | 2008-05-30 06:08:50 +0000 | [diff] [blame] | 102 | class OptionalEdge<Tool t1, Tool t2, dag props> : EdgeBase<t1, t2, props>; |
Mikhail Glushenkov | 46d4e97 | 2008-05-06 16:36:06 +0000 | [diff] [blame] | 103 | |
| 104 | class CompilationGraph<list<EdgeBase> lst> { |
| 105 | list<EdgeBase> edges = lst; |
Anton Korobeynikov | e9ffb5b | 2008-03-23 08:57:20 +0000 | [diff] [blame] | 106 | } |