rev: release-0.15 scopes/doc/ir-ref._rst -rw-r--r-- 6.1 KiB View raw Log this file
e53de6d7cb89 — Leonard Ritter * win32 build fix 1 year, 5 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
IR Language Reference
=====================

This chapter will provide reference information for Scopes IR in a future release.

Built-in Types
--------------

.. ir-type:: void
.. ir-type:: i1
.. ir-type:: i8
.. ir-type:: i16
.. ir-type:: i32
.. ir-type:: i64
.. ir-type:: float
.. ir-type:: double
.. ir-type:: rawstring
.. ir-type:: opaque

Type Constructors
-----------------

.. ir-special:: (function return-type (? param-type ...) (? _:...))

.. ir-special:: (pointer type)

.. ir-special:: (array type count)

.. ir-special:: (vector type count)

.. ir-special:: (struct name (? _:packed) (? type ...))

.. ir-special:: (typeof value)

.. ir-special:: (getelementtype type (? index ...))

Definitions
-----------

.. ir-special:: (defvalue value)

.. ir-special:: (deftype value)

.. ir-special:: (defstruct name (? _:packed) (? type ...))

.. ir-special:: (define name ((? param ...)) type (? expression ...))

.. ir-special:: (declare symbol-string type)

Aggregate Constructors
----------------------

.. ir-special:: (structof (| (? "" (? _:packed)) type) (? const-value ...))

.. ir-special:: (arrayof type (? const-value ...))

.. ir-special:: (vectorof const-value (? ...))

Constant Values
---------------

.. ir-special:: (int type integer-value)

    Constructs an integer constant of ``type``.

    A naked integer is shorthand for ``(int i32 <number>)``.

.. ir-special:: (real type real-value)

    Constructs a real constant of ``type``.

.. ir-special:: (null type)

    Constructs a zero initializer for ``type``.

.. ir-special:: (alignof type)

.. ir-special:: (sizeof type)

.. ir-special:: (lengthof type)

.. ir-macro:: (&str string)

    Constructs a global string constant and returns it as ``rawstring``.

Flow Control
------------

.. ir-special:: (block name)

.. ir-special:: (set-block block-expr)

.. ir-special:: (call callee (? argument-value ...))

.. ir-special:: (ret (? return-value))

.. ir-special:: (br label-value)

.. ir-special:: (cond-br value then-label-value else-label-value)

.. ir-special:: (phi type (? (value label-value) ...))

.. ir-special:: (incoming phi-value (? (value label-value) ...))

.. ir-macro:: (? condition-expr then-expr else-expr)

.. ir-macro:: (and? a-expr b-expr)

.. ir-macro:: (or? a-expr b-expr)

.. ir-macro:: (if (condition-expr expression ...) ... (? (_:else expression ...)))

.. ir-macro:: (loop var-name init-expr condition-expr iterate-expr expression ...)

.. ir-macro:: (assert condition-expr (? exception-expr))

Unary Operators
---------------

.. ir-macro:: (not pointer-expr)

Binary Operators
----------------

.. ir-special:: (add lhs rhs)

.. ir-special:: (add-nsw lhs rhs)

.. ir-special:: (add-nuw lhs rhs)

.. ir-special:: (fadd lhs rhs)

.. ir-special:: (sub lhs rhs)

.. ir-special:: (sub-nsw lhs rhs)

.. ir-special:: (sub-nuw lhs rhs)

.. ir-special:: (fsub lhs rhs)

.. ir-special:: (mul lhs rhs)

.. ir-special:: (mul-nsw lhs rhs)

.. ir-special:: (mul-nuw lhs rhs)

.. ir-special:: (fmul lhs rhs)

.. ir-special:: (udiv lhs rhs)

.. ir-special:: (sdiv lhs rhs)

.. ir-special:: (exact-sdiv lhs rhs)

.. ir-special:: (urem lhs rhs)

.. ir-special:: (srem lhs rhs)

.. ir-special:: (frem lhs rhs)

.. ir-special:: (shl lhs rhs)

.. ir-special:: (lshr lhs rhs)

.. ir-special:: (ashr lhs rhs)

.. ir-special:: (and lhs rhs)

.. ir-special:: (or lhs rhs)

.. ir-special:: (xor lhs rhs)

Comparators
-----------

.. ir-special:: (icmp op lhs rhs)

.. ir-special:: (fcmp op lhs rhs)

.. ir-special:: (select condition-expr then-value else-value)

.. ir-macro:: (null? pointer-expr)

Composition
-----------

.. ir-special:: (getelementptr value (? index-value ...))

.. ir-special:: (extractelement value index)

.. ir-special:: (insertelement value element index)

.. ir-special:: (shufflevector value1 value2 mask)

.. ir-special:: (extractvalue value index)

.. ir-special:: (insertvalue value element index)

Memory
------

.. ir-special:: (align value bytes)

.. ir-special:: (load from-value)

.. ir-special:: (store from-value to-value)

.. ir-special:: (alloca type (? count-value))

.. ir-special:: (va_arg va_list-value type)

Global Values
-------------

.. ir-special:: (constant global-value)

.. ir-special:: (global name constant-value)

Casting
-------

.. ir-special:: (trunc value type)

.. ir-special:: (zext value type)

.. ir-special:: (sext value type)

.. ir-special:: (fptrunc value type)

.. ir-special:: (fpext value type)

.. ir-special:: (fptoui value type)

.. ir-special:: (fptosi value type)

.. ir-special:: (uitofp value type)

.. ir-special:: (sitofp value type)

.. ir-special:: (ptrtoint value type)

.. ir-special:: (intotptr value type)

.. ir-special:: (bitcast value type)

.. ir-special:: (addrspacecast value type)

Debugging
---------

.. ir-special:: (dump-module)

.. ir-special:: (dump value)

.. ir-special:: (dumptype type)

Metaprogramming
---------------

.. ir-special:: (include filename-string)

    Includes expressions from another source file into the module currently being
    defined. ``filename-string`` is the path to the source file to be included,
    relative to the path of the expression's anchor.

.. ir-special:: (execute function-value)

    Executes a function in the module as it is being defined. The function must
    match the signature ``(function void [Environment])``. If the environment
    parameter is defined, then the currently active translation environment
    will be passed.

.. ir-macro:: (run expression ...)

.. ir-special:: (module name (| _:IR language) (? expression ...))

    Declares a new LLVM module with a new empty namespace. ``language`` must be
    a name with which a preprocessor has been registered, or ``IR`` for the
    default.

.. ir-special:: (quote type element)

    Adds the symbolic expression ``element`` as global constant pointer to the
    module currently being defined and returns its value handle. This allows
    programs to create and process properly anchored expressions.

.. ir-special:: (splice (? expression ...))

.. ir-macro:: (print (? value ...))

.. ir-macro:: (handle pointer-value)

.. ir-macro:: (table (? (key value) ...))

.. ir-special:: (error message-string expression)

.. ir-special:: (nop)

    Ponders the futility of existence.