2 * Copyright (C) 1995-2008 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, Michael Beck
26 #ifndef FIRM_IR_IROP_T_H
27 #define FIRM_IR_IROP_T_H
34 * Frees a newly created ir operation.
36 void free_ir_op(ir_op *code);
38 /** Initialize the irop module. */
41 /** Free memory used by irop module. */
45 * Copies simply all attributes stored in the old node to the new node.
46 * Assumes both have the same opcode and sufficient size.
48 * @param old_node the old node from which the attributes are read
49 * @param new_node the new node to which the attributes are written
51 void default_copy_attr(const ir_node *old_node, ir_node *new_node);
54 * Returns the attribute size of nodes of this opcode.
55 * @note Use not encouraged, internal feature.
57 static inline size_t get_op_attr_size (const ir_op *op) {
62 * Returns non-zero if op is a control flow opcode,
63 * like Start, End, Jmp, Cond, Return, Raise or Bad.
65 static inline int is_op_cfopcode(const ir_op *op) {
66 return op->flags & irop_flag_cfopcode;
70 * Returns non-zero if the operation manipulates interprocedural control flow:
71 * CallBegin, EndReg, EndExcept
73 static inline int is_ip_cfopcode(const ir_op *op) {
74 return op->flags & irop_flag_ip_cfopcode;
77 /** Returns non-zero if operation is commutative */
78 static inline int is_op_commutative(const ir_op *op) {
79 return op->flags & irop_flag_commutative;
82 /** Returns non-zero if operation is fragile */
83 static inline int is_op_fragile(const ir_op *op) {
84 return op->flags & irop_flag_fragile;
87 /** Returns non-zero if operation is forking control flow */
88 static inline int is_op_forking(const ir_op *op) {
89 return op->flags & irop_flag_forking;
92 /** Returns non-zero if operation is a high-level op */
93 static inline int is_op_highlevel(const ir_op *op) {
94 return op->flags & irop_flag_highlevel;
97 /** Returns non-zero if operation is a const-like op */
98 static inline int is_op_constlike(const ir_op *op) {
99 return op->flags & irop_flag_constlike;
102 static inline int is_op_uses_memory(const ir_op *op) {
103 return op->flags & irop_flag_uses_memory;
106 /** Returns non-zero if operation must always be optimized */
107 static inline int is_op_always_opt(const ir_op *op) {
108 return op->flags & irop_flag_always_opt;
111 /** Returns non-zero if operation is a keep-like op */
112 static inline int is_op_keep(const ir_op *op) {
113 return op->flags & irop_flag_keep;
116 /** Returns non-zero if operation must always be placed in the start block. */
117 static inline int is_op_start_block_placed(const ir_op *op) {
118 return op->flags & irop_flag_start_block;
121 /** Returns non-zero if operation is a machine operation */
122 static inline int is_op_machine(const ir_op *op) {
123 return op->flags & irop_flag_machine;
126 /** Returns non-zero if operation is a machine operand */
127 static inline int is_op_machine_operand(const ir_op *op) {
128 return op->flags & irop_flag_machine_op;
131 /** Returns non-zero if operation is a machine user op number n */
132 static inline int is_op_machine_user(const ir_op *op, unsigned n) {
133 return op->flags & (irop_flag_user << n);
136 static inline unsigned _get_op_code(const ir_op *op) {
140 static inline ident *_get_op_ident(const ir_op *op){
144 static inline op_pin_state _get_op_pinned(const ir_op *op) {
145 return op->pin_state;
148 static inline void _set_generic_function_ptr(ir_op *op, op_func func) {
149 op->ops.generic = func;
152 static inline op_func _get_generic_function_ptr(const ir_op *op) {
153 return op->ops.generic;
156 static inline const ir_op_ops *_get_op_ops(const ir_op *op) {
160 static inline void _set_op_tag(ir_op *op, unsigned tag) {
164 static inline unsigned _get_op_tag(const ir_op *op) {
168 static inline void _set_op_attr(ir_op *op, void *attr) {
172 static inline void *_get_op_attr(const ir_op *op) {
176 #define get_op_code(op) _get_op_code(op)
177 #define get_op_ident(op) _get_op_ident(op)
178 #define get_op_pinned(op) _get_op_pinned(op)
179 #define get_op_ops(op) _get_op_ops(op)
180 #define set_op_tag(op, tag) _set_op_tag((op), (tag))
181 #define get_op_tag(op) _get_op_tag(op)
182 #define set_op_attr(op, attr) _set_op_attr((op), (attr))
183 #define get_op_attr(op) _get_op_attr(op)