1(library (yuni transformer llvm bitcode-dict)
2         (export builtin-abbid
3                 llvm-ir-blockid
4                 record-BLOCKINFO
5                 record-MODULE_BLOCK
6                 record-PARAMATTR_BLOCK
7                 record-TYPE_BLOCK
8                 record-TYPE_SYMTAB_BLOCK
9                 record-VALUE_SYMTAB_BLOCK
10                 record-METADATA_BLOCK
11                 record-CONSTANTS_BLOCK
12                 code-linkage code-visibility code-callingconv
13                 op-cast op-binary
14                 record-FUNCTION_BLOCK)
15         (import (rnrs)
16                 (yuni core))
17
18(define-syntax to-symbol
19  (syntax-rules ()
20    ((_ input (sym val) ...)
21     (case input
22       ((val) 'sym)
23       ...
24       (else input)))))
25
26(define-syntax to-value
27  (syntax-rules ()
28    ((_ input (sym val) ...)
29     (case input
30       ((sym) val)
31       ...
32       (else input)))))
33
34(define-syntax dictconverter
35  (syntax-rules ()
36    ((_ input spec ...)
37     (if (symbol? input)
38       (to-value input spec ...)
39       (to-symbol input spec ...)))))
40
41(define-syntax define-llvm-dict
42  (syntax-rules ()
43    ((_ name specs ...)
44     (define (name x) (dictconverter x specs ...)))))
45
46(define-llvm-dict builtin-abbid
47                  (END_BLOCK 0)
48                  (ENTER_SUBBLOCK 1)
49                  (DEFINE_ABBREV 2)
50                  (UNABBREV_RECORD 3))
51
52(define-llvm-dict llvm-ir-blockid
53                  (MODULE_BLOCK 8)
54                  (PARAMATTR_BLOCK 9)
55                  (TYPE_BLOCK 10)
56                  (CONSTANTS_BLOCK 11)
57                  (FUNCTION_BLOCK 12)
58                  (TYPE_SYMTAB_BLOCK 13)
59                  (VALUE_SYMTAB_BLOCK 14)
60                  (METADATA_BLOCK 15)
61                  (METADATA_ATTACHMENT 16))
62
63(define-llvm-dict record-VALUE_SYMTAB_BLOCK
64                  (ENTRY 1)
65                  (BBENTRY 2))
66
67(define-llvm-dict record-TYPE_SYMTAB_BLOCK
68                  (ENTRY 1))
69
70(define-llvm-dict record-BLOCKINFO ;; id = 0
71                  (SETBID 1)
72                  (BLOCKNAME 2)
73                  (SETRECORDNAME 3))
74
75(define-llvm-dict record-MODULE_BLOCK
76                  (VERSION 1)
77                  (TRIPLE 2)
78                  (DATALAYOUT 3)
79                  (ASM 4)
80                  (SECTIONNAME 5)
81                  (DEPLIB 6)
82                  (GLOBALVAR 7)
83                  (FUNCTION 8)
84                  (ALIAS 9)
85                  (PURGEVALS 10)
86                  (GCNAME 11))
87
88(define-llvm-dict record-PARAMATTR_BLOCK
89                  (ENTRY 1))
90
91(define-llvm-dict record-TYPE_BLOCK
92                  (NUMENTRY 1)
93                  (VOID 2)
94                  (FLOAT 3)
95                  (DOUBLE 4)
96                  (LABEL 5)
97                  (OPAQUE 6)
98                  (INTEGER 7)
99                  (POINTER 8)
100                  (FUNCTION 9)
101                  (STRUCT 10)
102                  (ARRAY 11)
103                  (VECTOR 12)
104                  (X86_FP80 13)
105                  (FP128 14)
106                  (PPC_FP128 15)
107                  (METADATA 16))
108
109(define-llvm-dict record-METADATA_BLOCK
110                  (STRING 1)
111                  (NODE 2) ;; deprecated
112                  (FN_NODE 3) ;; deprecated
113                  (NAME 4)
114                  (NAMED_NODE 5) ;; deprecated
115                  (KIND 6)
116                  (ATTACHMENT 7) ;; deprecated
117                  (NODE2 8)
118                  (FN_NODE2 9)
119                  (NAMED_NODE2 10)
120                  (ATTACHMENT2 11))
121
122(define-llvm-dict record-CONSTANTS_BLOCK
123                  (SETTYPE 1)
124                  (NULL 2)
125                  (UNDEF 3)
126                  (INTEGER 4) ;; signed VBR
127                  (WIDE_INTEGER 5) ;; signed VBR
128                  (FLOAT 6)
129                  (AGGREGATE 7)
130                  (STRING 8)
131                  (CSTRING 9)
132                  (CE_BINOP 10)
133                  (CE_CAST 11)
134                  (CE_GEP 12)
135                  (CE_SELECT 13)
136                  (CE_EXTRACTELT 14)
137                  (CE_INSERTELT 15)
138                  (CE_SHUFFLEVEC 16)
139                  (CE_CMP 17)
140                  (INLINEASM 18)
141                  (CE_SHUFVEC_EX 19)
142                  (CE_INBOUNDS_GEP 20)
143                  (BLOCKADDRESS 21))
144
145(define-llvm-dict op-cast
146                  (TRUNC 0)
147                  (ZEXT 1)
148                  (SEXT 2)
149                  (FPTOUI 3)
150                  (FPTOSI 4)
151                  (UITOFP 5)
152                  (SITOFP 6)
153                  (FPTRUNC 7)
154                  (FPEXT 8)
155                  (PTRTOINT 9)
156                  (INTTOPTR 10)
157                  (BITCAST 11))
158
159(define-llvm-dict op-binary
160                  (ADD 0)
161                  (SUB 1)
162                  (MUL 2)
163                  (UDIV 3)
164                  (SDIV 4)
165                  (UREM 5)
166                  (SREM 6)
167                  (SHL 7)
168                  (LSHR 8)
169                  (ASHR 9)
170                  (AND 10)
171                  (OR 11)
172                  (XOR 12))
173
174(define-llvm-dict code-callingconv
175                  (ccc 0)
176                  (fastcc 8)
177                  (coldcc 9)
178                  (x86_stdcallcc 64)
179                  (x86_fastcallcc 65)
180                  (arm_apcscc 66)
181                  (arm_aapcscc 67)
182                  (arm_aapcs_vfpcc 68))
183
184(define-llvm-dict code-linkage
185                  (external 0)
186                  (weak 1)
187                  (appending 2)
188                  (internal 3)
189                  (linkonce 4)
190                  (dllimport 5)
191                  (dllexport 6)
192                  (extern_weak 7)
193                  (common 8)
194                  (private 9)
195                  (weak_odr 10)
196                  (linkonce_odr 11)
197                  (available_externally 12)
198                  (linker_private 13))
199
200(define-llvm-dict code-visibility
201                  (default 0)
202                  (hidden 1)
203                  (protected 2))
204
205(define-llvm-dict record-FUNCTION_BLOCK
206                  (DECLAREBLOCKS 1)
207                  (BINOP 2)
208                  (CAST 3)
209                  (GEP 4)
210                  (SELECT 5)
211                  (EXTRACTELT 6)
212                  (INSERTELT 7)
213                  (SHUFFLEVEC 8)
214                  (CMP 9)
215                  (RET 10)
216                  (BR 11)
217                  (SWITCH 12)
218                  (INVOKE 13)
219                  (UNWIND 14)
220                  (UNREACHABLE 15)
221                  (PHI 16)
222                  (MALLOC 17)
223                  (FREE 18)
224                  (ALLOCA 19)
225                  (LOAD 20)
226                  (STORE 21) ;; deprecated
227                  (CALL 22) ;; deprecated
228                  (VAARG 23)
229                  (STORE2 24)
230                  (GETRESULT 25) ;; deprecated
231                  (EXTRACTVAL 26)
232                  (INSERTVAL 27)
233                  (CMP2 28)
234                  (VSELECT 29)
235                  (INBOUNDS_GEP 30)
236                  (INDIRECTBR 31)
237                  (DEBUG_LOC 32) ;; deprecated
238                  (DEBUG_LOC_AGAIN 33)
239                  (INST_CALL2 34)
240                  (DEBUG_LOC2 35))
241
242
243
244)
245