cleanup besched header
[libfirm] / ir / ir / irop_t.h
1 /*
2  * Copyright (C) 1995-2008 University of Karlsruhe.  All right reserved.
3  *
4  * This file is part of libFirm.
5  *
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.
10  *
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.
14  *
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
17  * PURPOSE.
18  */
19
20 /**
21  * @file
22  * @brief    Representation of opcode of intermediate operation -- private header.
23  * @author   Christian Schaefer, Goetz Lindenmaier, Michael Beck
24  * @version  $Id$
25  */
26 #ifndef FIRM_IR_IROP_T_H
27 #define FIRM_IR_IROP_T_H
28
29 #include "irop.h"
30 #include "irtypes.h"
31 #include "tv.h"
32
33 /**
34  * Frees a newly created ir operation.
35  */
36 void free_ir_op(ir_op *code);
37
38 /** Initialize the irop module. */
39 void init_op(void);
40
41 /** Free memory used by irop module. */
42 void finish_op(void);
43
44 /**
45  * Copies simply all attributes stored in the old node to the new node.
46  * Assumes both have the same opcode and sufficient size.
47  *
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
50  */
51 void default_copy_attr(ir_graph *irg, const ir_node *old_node,
52                        ir_node *new_node);
53
54 /**
55  * Returns the attribute size of nodes of this opcode.
56  * @note Use not encouraged, internal feature.
57  */
58 static inline size_t get_op_attr_size (const ir_op *op) {
59         return op->attr_size;
60 }
61
62 /**
63  * Returns non-zero if op is a control flow opcode,
64  * like Start, End, Jmp, Cond, Return, Raise or Bad.
65  */
66 static inline int is_op_cfopcode(const ir_op *op) {
67         return op->flags & irop_flag_cfopcode;
68 }
69
70 /** Returns non-zero if operation is commutative */
71 static inline int is_op_commutative(const ir_op *op) {
72         return op->flags & irop_flag_commutative;
73 }
74
75 /** Returns non-zero if operation is fragile */
76 static inline int is_op_fragile(const ir_op *op) {
77         return op->flags & irop_flag_fragile;
78 }
79
80 /** Returns non-zero if operation is forking control flow */
81 static inline int is_op_forking(const ir_op *op) {
82         return op->flags & irop_flag_forking;
83 }
84
85 /** Returns non-zero if operation is a high-level op */
86 static inline int is_op_highlevel(const ir_op *op) {
87         return op->flags & irop_flag_highlevel;
88 }
89
90 /** Returns non-zero if operation is a const-like op */
91 static inline int is_op_constlike(const ir_op *op) {
92         return op->flags & irop_flag_constlike;
93 }
94
95 static inline int is_op_uses_memory(const ir_op *op) {
96         return op->flags & irop_flag_uses_memory;
97 }
98
99 /** Returns non-zero if operation must always be optimized */
100 static inline int is_op_always_opt(const ir_op *op) {
101         return op->flags & irop_flag_always_opt;
102 }
103
104 /** Returns non-zero if operation is a keep-like op */
105 static inline int is_op_keep(const ir_op *op) {
106         return op->flags & irop_flag_keep;
107 }
108
109 /** Returns non-zero if operation must always be placed in the start block. */
110 static inline int is_op_start_block_placed(const ir_op *op) {
111         return op->flags & irop_flag_start_block;
112 }
113
114 /** Returns non-zero if operation is a machine operation */
115 static inline int is_op_machine(const ir_op *op) {
116         return op->flags & irop_flag_machine;
117 }
118
119 /** Returns non-zero if operation is a machine operand */
120 static inline int is_op_machine_operand(const ir_op *op) {
121         return op->flags & irop_flag_machine_op;
122 }
123
124 /** Returns non-zero if operation is CSE neutral */
125 static inline int is_op_cse_neutral(const ir_op *op) {
126         return op->flags & irop_flag_cse_neutral;
127 }
128
129 /** Returns non-zero if operation is a machine user op number n */
130 static inline int is_op_machine_user(const ir_op *op, unsigned n) {
131   return op->flags & (irop_flag_user << n);
132 }
133
134 static inline unsigned _get_op_code(const ir_op *op) {
135   return op->code;
136 }
137
138 static inline ident *_get_op_ident(const ir_op *op){
139   return op->name;
140 }
141
142 static inline op_pin_state _get_op_pinned(const ir_op *op) {
143   return op->pin_state;
144 }
145
146 static inline void _set_generic_function_ptr(ir_op *op, op_func func) {
147   op->ops.generic = func;
148 }
149
150 static inline op_func _get_generic_function_ptr(const ir_op *op) {
151   return op->ops.generic;
152 }
153
154 static inline const ir_op_ops *_get_op_ops(const ir_op *op) {
155   return &op->ops;
156 }
157
158 static inline void _set_op_tag(ir_op *op, unsigned tag) {
159         op->tag = tag;
160 }
161
162 static inline unsigned _get_op_tag(const ir_op *op) {
163         return op->tag;
164 }
165
166 static inline void _set_op_attr(ir_op *op, void *attr) {
167         op->attr = attr;
168 }
169
170 static inline void *_get_op_attr(const ir_op *op) {
171         return op->attr;
172 }
173
174 #define get_op_code(op)         _get_op_code(op)
175 #define get_op_ident(op)        _get_op_ident(op)
176 #define get_op_pinned(op)       _get_op_pinned(op)
177 #define get_op_ops(op)          _get_op_ops(op)
178 #define set_op_tag(op, tag)     _set_op_tag((op), (tag))
179 #define get_op_tag(op)          _get_op_tag(op)
180 #define set_op_attr(op, attr)   _set_op_attr((op), (attr))
181 #define get_op_attr(op)         _get_op_attr(op)
182
183 #endif