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
137 * .itype: type of the input operands
146 Compare less-than-or-equal (signed).
149 Compare greater-than-or-equal (signed).
152 Compare less-than (signed).
155 Compare greater-than (signed).
158 Compare less-than (unsigned).
161 Compare greater-than (unsigned).
164 Compare less-than-or-equal (unsigned).
167 Compare greater-than-or-equal (unsigned).
169 Floating-point compares
170 -----------------------
171 They all have the same signature as the integer compares.
173 The usual 6 operations exist in two versions: 'ordered' and
174 'unordered'. These operations first check if any operand is a
175 NaN and if it is the case the ordered compares return false
176 and then unordered return true, otherwise the result of the
177 comparison, now guaranteed to be done on non-NaNs, is returned.
180 Floating-point compare ordered equal
183 Floating-point compare ordered not-equal
186 Floating-point compare ordered less-than-or-equal
189 Floating-point compare ordered greater-or-equal
192 Floating-point compare ordered less-than
195 Floating-point compare ordered greater-than
199 Floating-point compare unordered equal
202 Floating-point compare unordered not-equal
205 Floating-point compare unordered less-than-or-equal
208 Floating-point compare unordered greater-or-equal
211 Floating-point compare unordered less-than
214 Floating-point compare unordered greater-than
218 Floating-point compare ordered: return true if both operands are ordered
219 (none of the operands are a NaN) and false otherwise.
222 Floating-point compare unordered: return false if no operands is ordered
230 * .src: operand (type must be compatible with .target)
231 * .target: result of the operation
232 * .type: type of .target, must be an integral type
237 * .src: operand (type must be compatible with .target)
238 * .target: result of the operation (must be an integral type)
239 * .type: type of .target
242 Floating-point negation.
244 * .src: operand (type must be compatible with .target)
245 * .target: result of the operation (must be a floating-point type)
246 * .type: type of .target
249 Create a pseudo corresponding to the address of a symbol.
251 * .src: input symbol (must be a PSEUDO_SYM)
252 * .target: symbol's address
255 Copy (only needed after out-of-SSA).
257 * .src: operand (type must be compatible with .target)
258 * .target: result of the operation
259 * .type: type of .target
263 They all have the following signature:
265 * .orig_type: type of .src
266 * .target: result value
267 * .type: type of .target
269 Currently, a cast to a void pointer is treated like a cast to
270 an unsigned integer of the same size.
273 Cast from integer to an integer of a smaller size.
276 Cast from integer to an integer of a bigger size with sign extension.
279 Cast from integer to an integer of a bigger size with zero extension.
282 Cast from pointer-sized unsigned integer to pointer type.
285 Cast from pointer type to pointer-sized unsigned integer.
288 Cast between pointers.
291 Conversion from float type to unsigned integer.
294 Conversion from float type to signed integer.
297 Conversion from unsigned integer to float type.
300 Conversion from signed integer to float type.
303 Conversion between float types.
308 * .src1: condition, must be of integral type
309 * .src2, .src3: operands (types must be compatible with .target)
310 * .target: result of the operation
311 * .type: type of .target
316 * .src1, .src2, .src3: operands (types must be compatible with .target)
317 * .target: result of the operation (must be a floating-point type)
318 * .type: type of .target
321 Range/bounds checking (only used for an unused sparse extension).
323 * .src1: value to be checked
324 * .src2, src3: bound of the value (must be constants?)
325 * .type: type of .src[123]?
332 * .src: base address to load from
333 * .offset: address offset
334 * .target: loaded value
335 * .type: type of .target
340 * .src: base address to store to
341 * .offset: address offset
342 * .target: value to be stored
343 * .type: type of .target
348 Create a pseudo corresponding to a floating-point literal.
350 * .fvalue: the literal's value (long double)
351 * .target: the corresponding pseudo
352 * .type: type of the literal & .target
355 Create a pseudo corresponding to a string literal.
356 The value is given as an expression EXPR_STRING.
358 * .val: (expression) input expression
359 * .target: the resulting value
360 * .type: type of .target, the value
363 Create a pseudo corresponding to a label-as-value.
365 * .bb_true: the BB corresponding to the label
366 * .target: the resulting value
367 * .type: type of .target (void \*)
370 Phi-node (for SSA form).
372 * .phi_list: phi-operands (type must be compatible with .target)
374 * .type: type of .target
378 Like OP_COPY but exclusively used to give a defining instructions
379 (and thus also a type) to *all* OP_PHI operands.
381 * .phi_src: operand (type must be compatible with .target, alias .src)
382 * .target: the "result" PSEUDO_PHI
383 * .type: type of .target
384 * .phi_node: the unique phi instruction using the target pseudo
389 * .func: (pseudo_t) the function (can be a symbol or a "register",
391 * .arguments: (pseudo_list) list of the associated arguments
392 * .target: function return value (if any)
393 * .type: type of .target
394 * .fntypes: (symbol_list) list of the function's types: the first
395 entry is the full function type, the next ones are the type of
398 .. op:: OP_INLINED_CALL
399 Only used as an annotation to show that the instructions just above
400 correspond to a function that have been inlined.
402 * .func: (pseudo_t) the function (must be a symbol, alias .src))
403 * .arguments: list of pseudos that where the function's arguments
404 * .target: function return value (if any)
405 * .type: type of .target
408 Extract a "slice" from an aggregate.
410 * .base: (pseudo_t) aggregate (alias .src)
411 * .from: offset of the "slice" within the aggregate
413 * .type: type of .target
416 Inlined assembly code.
418 * .string: asm template
419 * .asm_rules: asm constraints, rules
421 Sparse tagging (line numbers, context, whatever)
422 ------------------------------------------------
424 Currently only used for lock/unlock tracking.
426 * .context_expr: unused
427 * .increment: (1 for locking, -1 for unlocking)
428 * .check: (ignore the instruction if 0)
433 Function entry point (no associated semantic).
436 Invalid operation (should never be generated).
439 No-op (should never be generated).
442 Annotation telling the pseudo will be death after the next
443 instruction (other than some other annotation, that is).