3 * File name: ir/ir/irop_t.h
4 * Purpose: Representation of opcode of intermediate operation -- private header.
5 * Author: Christian Schaefer
6 * Modified by: Goetz Lindenmaier
9 * Copyright: (c) 1998-2003 Universität Karlsruhe
10 * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE.
19 /** The allowed parities */
22 oparity_unary, /**< an unary operator -- considering 'numeric' arguments. */
23 oparity_binary, /**< an binary operator -- considering 'numeric' arguments.*/
24 oparity_trinary, /**< an trinary operator -- considering 'numeric' arguments.*/
25 oparity_zero, /**< no operators, as e.g. Const. */
26 oparity_variable, /**< arity not fixed by opcode, but statically
27 known. E.g., number of arguments to call. */
28 oparity_dynamic, /**< arity depends on state of firm representation.
29 Can change by optimizations...
30 We must allocate a dynamic in array for the node! */
31 oparity_any, /**< other arity */
37 irop_flag_labeled = 0x00000001, /**< if set, Output edge labels on in-edges in vcg graph */
38 irop_flag_commutative = 0x00000002, /**< operation is commutative */
39 irop_flag_cfopcode = 0x00000004, /**< is a control flow operation */
40 irop_flag_ip_cfopcode = 0x00000008, /**< operation manipulates interprocedural control flow */
41 irop_flag_fragile = 0x00000010, /**< set if the operation can change the control flow because
46 /** the type of an ir_op */
48 opcode code; /**< the unique opcode of the op */
49 ident *name; /**< the name of the op */
50 size_t attr_size; /**< Space needed in memory for private attributes */
51 op_pinned pinned; /**< How to deal with the node in cse, pre. */
52 op_arity opar; /**< arity of operator. */
53 int op_index; /**< the index of the first data operand, 0 for most cases, 1 for Div etc. */
54 unsigned flags; /**< flags describing the behavior of the ir_op, a bitmaks of irop_flags */
58 * Creates a new ir operation.
60 * @param code the opcode, one of type \c opcode
61 * @param name the printable name of this opcode
62 * @param p wheater operations of this opcode are pinned or floating
63 * @param flags a bitmask of irop_flags describing the behavior of the ir operation
64 * @param opar the parity of this ir operation
65 * @param op_index if the parity is oparity_unary, oparity_binary or oparity_trinary the index
67 * @param attr_size attribute size for this ir operation
69 * @return The genenerated ir operation.
71 ir_op * new_ir_op(opcode code, const char *name, op_pinned p,
72 unsigned flags, op_arity opar, int op_index, size_t attr_size);
75 * Frees a newly created ir operation.
77 void free_ir_op(ir_op *code);
79 /** Initialize the irop module. */
82 /** Free memory used by irop module. */
85 /** Returns the attribute size of nodes of this opcode.
86 @note Use not encouraged, internal feature. */
87 static INLINE int get_op_attr_size (const ir_op *op) {
91 /** Returns non-zero if op is one of Start, End, Jmp, Cond, Return, Raise or Bad. */
92 static INLINE int is_cfopcode(const ir_op *op) {
93 return op->flags & irop_flag_cfopcode;
96 /** Returns true if the operation manipulates interprocedural control flow:
97 CallBegin, EndReg, EndExcept */
98 static INLINE int is_ip_cfopcode(const ir_op *op) {
99 return op->flags & irop_flag_ip_cfopcode;
102 /* Returns non-zero if operation is commutative */
103 static INLINE int is_op_commutative(const ir_op *op) {
104 return op->flags & irop_flag_commutative;
107 /* Returns non-zero if operation is fragile */
108 static INLINE int is_op_fragile(const ir_op *op) {
109 return op->flags & irop_flag_fragile;
112 #endif /* _IROP_T_H_ */