2 * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
4 * This file is part of libFirm.
6 * This file may be distributed and/or modified under the terms of the
7 * GNU General Public License version 2 as published by the Free Software
8 * Foundation and appearing in the file LICENSE.GPL included in the
9 * packaging of this file.
11 * Licensees holding valid libFirm Professional Edition licenses may use
12 * this file in accordance with the libFirm Commercial License.
13 * Agreement provided with the Software.
15 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
16 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * @brief Representation of opcode of intermediate operation -- private header.
23 * @author Christian Schaefer, Goetz Lindenmaier
26 #ifndef FIRM_IR_IROP_T_H
27 #define FIRM_IR_IROP_T_H
29 #include "firm_config.h"
35 /** The type of an ir_op. */
37 ir_opcode code; /**< The unique opcode of the op. */
38 ident *name; /**< The name of the op. */
39 size_t attr_size; /**< Space needed in memory for private attributes. */
40 op_pin_state op_pin_state_pinned; /**< How to deal with the node in CSE, PRE. */
41 op_arity opar; /**< The arity of operator. */
42 int op_index; /**< The index of the first data operand, 0 for most cases, 1 for Div etc. */
43 unsigned flags; /**< Flags describing the behavior of the ir_op, a bitmasks of irop_flags. */
44 void *tag; /**< Some custom pointer the op's creator can attach stuff to. */
46 ir_op_ops ops; /**< The operations of the this op. */
50 * Frees a newly created ir operation.
52 void free_ir_op(ir_op *code);
54 /** Initialize the irop module. */
57 /** Free memory used by irop module. */
61 * Copies simply all attributes stored in the old node to the new node.
62 * Assumes both have the same opcode and sufficient size.
64 * @param old_node the old node from which the attributes are read
65 * @param new_node the new node to which the attributes are written
67 void default_copy_attr(const ir_node *old_node, ir_node *new_node);
70 * Returns the attribute size of nodes of this opcode.
71 * @note Use not encouraged, internal feature.
73 static INLINE size_t get_op_attr_size (const ir_op *op) {
78 * Returns non-zero if op is a control flow opcode,
79 * like Start, End, Jmp, Cond, Return, Raise or Bad.
81 static INLINE int is_cfopcode(const ir_op *op) {
82 return op->flags & irop_flag_cfopcode;
86 * Returns non-zero if the operation manipulates interprocedural control flow:
87 * CallBegin, EndReg, EndExcept
89 static INLINE int is_ip_cfopcode(const ir_op *op) {
90 return op->flags & irop_flag_ip_cfopcode;
93 /** Returns non-zero if operation is commutative */
94 static INLINE int is_op_commutative(const ir_op *op) {
95 return op->flags & irop_flag_commutative;
98 /** Returns non-zero if operation is fragile */
99 static INLINE int is_op_fragile(const ir_op *op) {
100 return op->flags & irop_flag_fragile;
103 /** Returns non-zero if operation is forking control flow */
104 static INLINE int is_op_forking(const ir_op *op) {
105 return op->flags & irop_flag_forking;
108 /** Returns non-zero if operation is a high-level op */
109 static INLINE int is_op_highlevel(const ir_op *op) {
110 return op->flags & irop_flag_highlevel;
113 /** Returns non-zero if operation is a const-like op */
114 static INLINE int is_op_constlike(const ir_op *op) {
115 return op->flags & irop_flag_constlike;
118 /** Returns non-zero if operation must always be optimized */
119 static INLINE int is_op_always_opt(const ir_op *op) {
120 return op->flags & irop_flag_always_opt;
123 /** Returns non-zero if operation is a keep-like op */
124 static INLINE int is_op_keep(const ir_op *op) {
125 return op->flags & irop_flag_keep;
128 /** Returns non-zero if operation must always be placed in the start block. */
129 static INLINE int is_op_start_block_placed(const ir_op *op) {
130 return op->flags & irop_flag_start_block;
133 /** Returns non-zero if operation is a machine operation */
134 static INLINE int is_op_machine(const ir_op *op) {
135 return op->flags & irop_flag_machine;
138 /** Returns non-zero if operation is a machine operand */
139 static INLINE int is_op_machine_operand(const ir_op *op) {
140 return op->flags & irop_flag_machine_op;
143 /** Returns non-zero if operation is a machine user op number n */
144 static INLINE int is_op_machine_user(const ir_op *op, unsigned n) {
145 return op->flags & (irop_flag_user << n);
148 static INLINE ir_opcode _get_op_code(const ir_op *op) {
152 static INLINE ident *_get_op_ident(const ir_op *op){
156 static INLINE op_pin_state _get_op_pinned(const ir_op *op) {
157 return op->op_pin_state_pinned;
160 static INLINE void _set_generic_function_ptr(ir_op *op, op_func func) {
161 op->ops.generic = func;
164 static INLINE op_func _get_generic_function_ptr(const ir_op *op) {
165 return op->ops.generic;
168 static INLINE const ir_op_ops *_get_op_ops(const ir_op *op) {
172 static INLINE void _set_op_tag(ir_op *op, void *tag) {
176 static INLINE void *_get_op_tag(ir_op *op) {
180 #define get_op_code(op) _get_op_code(op)
181 #define get_op_ident(op) _get_op_ident(op)
182 #define get_op_pinned(op) _get_op_pinned(op)
183 #define get_op_ops(op) _get_op_ops(op)
184 #define set_op_tag(op, tag) _set_op_tag((op), (tag))
185 #define get_op_tag(op) _get_op_tag(op)