3 Intermediate Representation
4 ===========================
9 This document briefly describes which field of struct instruction is
10 used by which operation.
12 Some of those fields are used by almost all instructions,
13 some others are specific to only one or a few instructions.
16 * .src1, .src2, .src3: (pseudo_t) operands of binops or ternary ops.
17 * .src: (pseudo_t) operand of unary ops (alias for .src1).
18 * .target: (pseudo_t) result of unary, binary & ternary ops, is
19 sometimes used otherwise by some others instructions.
20 * .cond: (pseudo_t) input operands for condition (alias .src/.src1)
21 * .type: (symbol*) usually the type of .result, sometimes of the operands
26 Return from subroutine.
28 * .src : returned value (NULL if void)
34 * .bb_true: destination basic block
40 * .type: type of .cond, must be an integral type
41 * .bb_true, .bb_false: destination basic blocks
47 * .type: type of .cond, must be an integral type
48 * .multijmp_list: pairs of case-value - destination basic block
51 Mark code as unreachable
53 .. op:: OP_COMPUTEDGOTO
54 Computed goto / branch to register
56 * .src: address to branch to (void*)
57 * .multijmp_list: list of possible destination basic blocks
61 They all follow the same signature:
62 * .src1, .src2: operands (types must be compatible with .target)
63 * .target: result of the operation (must be an integral type)
64 * .type: type of .target
73 Integer multiplication.
76 Integer unsigned division.
79 Integer signed division.
82 Integer unsigned remainder.
85 Integer signed remainder.
88 Shift left (integer only)
91 Logical Shift right (integer only)
94 Arithmetic Shift right (integer only)
98 They all follow the same signature:
99 * .src1, .src2: operands (types must be compatible with .target)
100 * .target: result of the operation (must be a floating-point type)
101 * .type: type of .target
104 Floating-point addition.
107 Floating-point subtraction.
110 Floating-point multiplication.
113 Floating-point division.
117 They all follow the same signature:
118 * .src1, .src2: operands (types must be compatible with .target)
119 * .target: result of the operation
120 * .type: type of .target, must be an integral type
133 They all have the following signature:
134 * .src1, .src2: operands (types must be compatible)
135 * .target: result of the operation (0/1 valued integer)
136 * .type: type of .target, must be an integral type
145 Compare less-than-or-equal (signed).
148 Compare greater-than-or-equal (signed).
151 Compare less-than (signed).
154 Compare greater-than (signed).
157 Compare less-than (unsigned).
160 Compare greater-than (unsigned).
163 Compare less-than-or-equal (unsigned).
166 Compare greater-than-or-equal (unsigned).
168 Floating-point compares
169 -----------------------
170 They all have the same signature as the integer compares.
172 The usual 6 operations exist in two versions: 'ordered' and
173 'unordered'. These operations first check if any operand is a
174 NaN and if it is the case the ordered compares return false
175 and then unordered return true, otherwise the result of the
176 comparison, now guaranteed to be done on non-NaNs, is returned.
179 Floating-point compare ordered equal
182 Floating-point compare ordered not-equal
185 Floating-point compare ordered less-than-or-equal
188 Floating-point compare ordered greater-or-equal
191 Floating-point compare ordered less-than
194 Floating-point compare ordered greater-than
198 Floating-point compare unordered equal
201 Floating-point compare unordered not-equal
204 Floating-point compare unordered less-than-or-equal
207 Floating-point compare unordered greater-or-equal
210 Floating-point compare unordered less-than
213 Floating-point compare unordered greater-than
217 Floating-point compare ordered: return true if both operands are ordered
218 (none of the operands are a NaN) and false otherwise.
221 Floating-point compare unordered: return false if no operands is ordered
229 * .src: operand (type must be compatible with .target)
230 * .target: result of the operation
231 * .type: type of .target, must be an integral type
236 * .src: operand (type must be compatible with .target)
237 * .target: result of the operation (must be an integral type)
238 * .type: type of .target
241 Floating-point negation.
243 * .src: operand (type must be compatible with .target)
244 * .target: result of the operation (must be a floating-point type)
245 * .type: type of .target
248 Create a pseudo corresponding to the address of a symbol.
250 * .src: input symbol (must be a PSEUDO_SYM)
251 * .target: symbol's address
254 Copy (only needed after out-of-SSA).
256 * .src: operand (type must be compatible with .target)
257 * .target: result of the operation
258 * .type: type of .target
262 They all have the following signature:
264 * .orig_type: type of .src
265 * .target: result value
266 * .type: type of .target
268 Currently, a cast to a void pointer is treated like a cast to
269 an unsigned integer of the same size.
272 Cast from integer to an integer of a smaller size.
275 Cast from integer to an integer of a bigger size with sign extension.
278 Cast from integer to an integer of a bigger size with zero extension.
281 Cast from pointer-sized unsigned integer to pointer type.
284 Cast from pointer type to pointer-sized unsigned integer.
287 Cast between pointers.
290 Conversion from float type to unsigned integer.
293 Conversion from float type to signed integer.
296 Conversion from unsigned integer to float type.
299 Conversion from signed integer to float type.
302 Conversion between float types.
307 * .src1: condition, must be of integral type
308 * .src2, .src3: operands (types must be compatible with .target)
309 * .target: result of the operation
310 * .type: type of .target
313 Range/bounds checking (only used for an unused sparse extension).
315 * .src1: value to be checked
316 * .src2, src3: bound of the value (must be constants?)
317 * .type: type of .src[123]?
324 * .src: base address to load from
325 * .offset: address offset
326 * .target: loaded value
327 * .type: type of .target
332 * .src: base address to store to
333 * .offset: address offset
334 * .target: value to be stored
335 * .type: type of .target
340 Create a pseudo corresponding to a floating-point literal.
342 * .fvalue: the literal's value (long double)
343 * .target: the corresponding pseudo
344 * .type: type of the literal & .target
347 Create a pseudo corresponding to a string literal or a label-as-value.
348 The value is given as an expression EXPR_STRING or EXPR_LABEL.
350 * .val: (expression) input expression
351 * .target: the resulting value
352 * .type: type of .target, the value
355 Phi-node (for SSA form).
357 * .phi_list: phi-operands (type must be compatible with .target)
359 * .type: type of .target
363 Like OP_COPY but exclusively used to give a defining instructions
364 (and thus also a type) to *all* OP_PHI operands.
366 * .phi_src: operand (type must be compatible with .target, alias .src)
367 * .target: the "result" PSEUDO_PHI
368 * .type: type of .target
369 * .phi_users: list of phi instructions using the target pseudo
374 * .func: (pseudo_t) the function (can be a symbol or a "register",
376 * .arguments: (pseudo_list) list of the associated arguments
377 * .target: function return value (if any)
378 * .type: type of .target
379 * .fntypes: (symbol_list) list of the function's types: the first
380 entry is the full function type, the next ones are the type of
383 .. op:: OP_INLINED_CALL
384 Only used as an annotation to show that the instructions just above
385 correspond to a function that have been inlined.
387 * .func: (pseudo_t) the function (must be a symbol, alias .src))
388 * .arguments: list of pseudos that where the function's arguments
389 * .target: function return value (if any)
390 * .type: type of .target
393 Extract a "slice" from an aggregate.
395 * .base: (pseudo_t) aggregate (alias .src)
396 * .from, .len: offet & size of the "slice" within the aggregate
398 * .type: type of .target
401 Inlined assembly code.
403 * .string: asm template
404 * .asm_rules: asm constraints, rules
406 Sparse tagging (line numbers, context, whatever)
407 ------------------------------------------------
409 Currently only used for lock/unlock tracking.
411 * .context_expr: unused
412 * .increment: (1 for locking, -1 for unlocking)
413 * .check: (ignore the instruction if 0)
418 Function entry point (no associated semantic).
421 Invalid operation (should never be generated).
424 No-op (should never be generated).
427 Annotation telling the pseudo will be death after the next
428 instruction (other than some other annotation, that is).