bearch: Disallow passing Projs to get_irn_ops().
[libfirm] / ir / ir / irop_t.h
1 /*
2  * This file is part of libFirm.
3  * Copyright (C) 2012 University of Karlsruhe.
4  */
5
6 /**
7  * @file
8  * @brief    Representation of opcode of intermediate operation -- private header.
9  * @author   Christian Schaefer, Goetz Lindenmaier, Michael Beck
10  */
11 #ifndef FIRM_IR_IROP_T_H
12 #define FIRM_IR_IROP_T_H
13
14 #include "irop.h"
15
16 #include <stdbool.h>
17
18 #include "irtypes.h"
19 #include "tv.h"
20
21 #define get_op_code(op)         get_op_code_(op)
22 #define get_op_ident(op)        get_op_ident_(op)
23 #define get_op_pinned(op)       get_op_pinned_(op)
24 #define get_op_ops(op)          get_op_ops_(op)
25 #define set_op_tag(op, tag)     set_op_tag_((op), (tag))
26 #define get_op_tag(op)          get_op_tag_(op)
27 #define set_op_attr(op, attr)   set_op_attr_((op), (attr))
28 #define get_op_attr(op)         get_op_attr_(op)
29
30 #define set_generic_function_ptr(op, func) set_generic_function_ptr_((op), (op_func)(func))
31 #define get_generic_function_ptr(type, op) ((type*)get_generic_function_ptr_((op)))
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 firm_init_op(void);
40
41 /** frees memory allocated by irop module */
42 void firm_finish_op(void);
43
44 /**
45  * Returns the attribute size of nodes of this opcode.
46  * @note Use not encouraged, internal feature.
47  */
48 static inline size_t get_op_attr_size (const ir_op *op)
49 {
50         return op->attr_size;
51 }
52
53 /**
54  * Returns non-zero if op is a control flow opcode,
55  * like Start, End, Jmp, Cond, Return, Raise or Bad.
56  */
57 static inline bool is_op_cfopcode(const ir_op *op)
58 {
59         return op->flags & irop_flag_cfopcode;
60 }
61
62 static inline bool is_op_unknown_jump(const ir_op *op)
63 {
64         return op->flags & irop_flag_unknown_jump;
65 }
66
67 /** Returns non-zero if operation is commutative */
68 static inline bool is_op_commutative(const ir_op *op)
69 {
70         return op->flags & irop_flag_commutative;
71 }
72
73 /** Returns non-zero if operation is fragile */
74 static inline bool is_op_fragile(const ir_op *op)
75 {
76         return op->flags & irop_flag_fragile;
77 }
78
79 /** Returns non-zero if operation is forking control flow */
80 static inline bool is_op_forking(const ir_op *op)
81 {
82         return op->flags & irop_flag_forking;
83 }
84
85 /** Returns non-zero if operation is a high-level op */
86 static inline bool is_op_highlevel(const ir_op *op)
87 {
88         return op->flags & irop_flag_highlevel;
89 }
90
91 /** Returns non-zero if operation is a const-like op */
92 static inline bool is_op_constlike(const ir_op *op)
93 {
94         return op->flags & irop_flag_constlike;
95 }
96
97 static inline bool is_op_uses_memory(const ir_op *op)
98 {
99         return op->flags & irop_flag_uses_memory;
100 }
101
102 /** Returns non-zero if operation is a keep-like op */
103 static inline bool is_op_keep(const ir_op *op)
104 {
105         return op->flags & irop_flag_keep;
106 }
107
108 /** Returns non-zero if operation must always be placed in the start block. */
109 static inline bool is_op_start_block_placed(const ir_op *op)
110 {
111         return op->flags & irop_flag_start_block;
112 }
113
114 /** Returns non-zero if operation is CSE neutral */
115 static inline bool is_op_cse_neutral(const ir_op *op)
116 {
117         return op->flags & irop_flag_cse_neutral;
118 }
119
120 static inline unsigned get_op_code_(const ir_op *op)
121 {
122         return op->code;
123 }
124
125 static inline ident *get_op_ident_(const ir_op *op)
126 {
127         return op->name;
128 }
129
130 static inline op_pin_state get_op_pinned_(const ir_op *op)
131 {
132         return op->pin_state;
133 }
134
135 static inline void set_generic_function_ptr_(ir_op *op, op_func func)
136 {
137         op->ops.generic = func;
138 }
139
140 static inline op_func get_generic_function_ptr_(const ir_op *op)
141 {
142         return op->ops.generic;
143 }
144
145 static inline ir_op_ops const *get_op_ops_(ir_op const *const op)
146 {
147         return &op->ops;
148 }
149
150 static inline void set_op_tag_(ir_op *op, unsigned tag)
151 {
152         op->tag = tag;
153 }
154
155 static inline unsigned get_op_tag_(const ir_op *op)
156 {
157         return op->tag;
158 }
159
160 static inline void set_op_attr_(ir_op *op, void *attr)
161 {
162         op->attr = attr;
163 }
164
165 static inline void *get_op_attr_(const ir_op *op)
166 {
167         return op->attr;
168 }
169
170 #endif