irop_t.h 4.36 KB
Newer Older
Christian Würdig's avatar
Christian Würdig committed
1
/*
Michael Beck's avatar
Michael Beck committed
2
 * Copyright (C) 1995-2008 University of Karlsruhe.  All right reserved.
Christian Würdig's avatar
Christian Würdig committed
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
 *
 * This file is part of libFirm.
 *
 * This file may be distributed and/or modified under the terms of the
 * GNU General Public License version 2 as published by the Free Software
 * Foundation and appearing in the file LICENSE.GPL included in the
 * packaging of this file.
 *
 * Licensees holding valid libFirm Professional Edition licenses may use
 * this file in accordance with the libFirm Commercial License.
 * Agreement provided with the Software.
 *
 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE.
 */

Matthias Braun's avatar
Matthias Braun committed
20
21
22
/**
 * @file
 * @brief    Representation of opcode of intermediate operation -- private header.
Michael Beck's avatar
Michael Beck committed
23
 * @author   Christian Schaefer, Goetz Lindenmaier, Michael Beck
24
 */
Matthias Braun's avatar
Matthias Braun committed
25
26
#ifndef FIRM_IR_IROP_T_H
#define FIRM_IR_IROP_T_H
Götz Lindenmaier's avatar
Götz Lindenmaier committed
27

Michael Beck's avatar
Michael Beck committed
28
#include "irop.h"
Matthias Braun's avatar
Matthias Braun committed
29
30
31

#include <stdbool.h>

32
#include "irtypes.h"
Michael Beck's avatar
Michael Beck committed
33
#include "tv.h"
Götz Lindenmaier's avatar
Götz Lindenmaier committed
34

35
36
37
38
39
40
41
42
43
#define get_op_code(op)         get_op_code_(op)
#define get_op_ident(op)        get_op_ident_(op)
#define get_op_pinned(op)       get_op_pinned_(op)
#define get_op_ops(op)          get_op_ops_(op)
#define set_op_tag(op, tag)     set_op_tag_((op), (tag))
#define get_op_tag(op)          get_op_tag_(op)
#define set_op_attr(op, attr)   set_op_attr_((op), (attr))
#define get_op_attr(op)         get_op_attr_(op)

44
45
46
#define set_generic_function_ptr(op, func) set_generic_function_ptr_((op), (op_func)(func))
#define get_generic_function_ptr(type, op) ((type*)get_generic_function_ptr_((op)))

47
48
49
50
/**
 * Frees a newly created ir operation.
 */
void free_ir_op(ir_op *code);
Götz Lindenmaier's avatar
Götz Lindenmaier committed
51

Michael Beck's avatar
Michael Beck committed
52
/** Initialize the irop module. */
Matthias Braun's avatar
Matthias Braun committed
53
void firm_init_op(void);
Götz Lindenmaier's avatar
Götz Lindenmaier committed
54

Matthias Braun's avatar
Matthias Braun committed
55
56
/** frees memory allocated by irop module */
void firm_finish_op(void);
57

58
59
60
61
/**
 * Returns the attribute size of nodes of this opcode.
 * @note Use not encouraged, internal feature.
 */
Matthias Braun's avatar
Matthias Braun committed
62
63
static inline size_t get_op_attr_size (const ir_op *op)
{
Michael Beck's avatar
Michael Beck committed
64
	return op->attr_size;
65
66
}

67
68
69
70
/**
 * Returns non-zero if op is a control flow opcode,
 * like Start, End, Jmp, Cond, Return, Raise or Bad.
 */
Matthias Braun's avatar
Matthias Braun committed
71
72
static inline bool is_op_cfopcode(const ir_op *op)
{
Michael Beck's avatar
Michael Beck committed
73
	return op->flags & irop_flag_cfopcode;
74
75
}

76
77
78
79
80
static inline bool is_op_unknown_jump(const ir_op *op)
{
	return op->flags & irop_flag_unknown_jump;
}

81
/** Returns non-zero if operation is commutative */
Matthias Braun's avatar
Matthias Braun committed
82
83
static inline bool is_op_commutative(const ir_op *op)
{
Michael Beck's avatar
Michael Beck committed
84
	return op->flags & irop_flag_commutative;
85
86
}

87
/** Returns non-zero if operation is fragile */
Matthias Braun's avatar
Matthias Braun committed
88
89
static inline bool is_op_fragile(const ir_op *op)
{
Michael Beck's avatar
Michael Beck committed
90
	return op->flags & irop_flag_fragile;
91
92
}

93
/** Returns non-zero if operation is forking control flow */
Matthias Braun's avatar
Matthias Braun committed
94
95
static inline bool is_op_forking(const ir_op *op)
{
Michael Beck's avatar
Michael Beck committed
96
	return op->flags & irop_flag_forking;
Michael Beck's avatar
Michael Beck committed
97
98
}

99
/** Returns non-zero if operation is a high-level op */
Matthias Braun's avatar
Matthias Braun committed
100
101
static inline bool is_op_highlevel(const ir_op *op)
{
Michael Beck's avatar
Michael Beck committed
102
	return op->flags & irop_flag_highlevel;
Michael Beck's avatar
Michael Beck committed
103
104
}

105
/** Returns non-zero if operation is a const-like op */
Matthias Braun's avatar
Matthias Braun committed
106
107
static inline bool is_op_constlike(const ir_op *op)
{
Michael Beck's avatar
Michael Beck committed
108
	return op->flags & irop_flag_constlike;
109
110
}

Matthias Braun's avatar
Matthias Braun committed
111
112
static inline bool is_op_uses_memory(const ir_op *op)
{
113
	return op->flags & irop_flag_uses_memory;
114
115
}

Michael Beck's avatar
Michael Beck committed
116
/** Returns non-zero if operation is a keep-like op */
Matthias Braun's avatar
Matthias Braun committed
117
118
static inline bool is_op_keep(const ir_op *op)
{
Michael Beck's avatar
Michael Beck committed
119
	return op->flags & irop_flag_keep;
Michael Beck's avatar
Michael Beck committed
120
121
}

122
/** Returns non-zero if operation must always be placed in the start block. */
Matthias Braun's avatar
Matthias Braun committed
123
124
static inline bool is_op_start_block_placed(const ir_op *op)
{
Michael Beck's avatar
Michael Beck committed
125
	return op->flags & irop_flag_start_block;
126
127
}

128
/** Returns non-zero if operation is CSE neutral */
Matthias Braun's avatar
Matthias Braun committed
129
130
static inline bool is_op_cse_neutral(const ir_op *op)
{
131
132
133
	return op->flags & irop_flag_cse_neutral;
}

134
static inline unsigned get_op_code_(const ir_op *op)
Matthias Braun's avatar
Matthias Braun committed
135
136
{
	return op->code;
Michael Beck's avatar
Michael Beck committed
137
138
}

139
static inline ident *get_op_ident_(const ir_op *op)
Matthias Braun's avatar
Matthias Braun committed
140
141
{
	return op->name;
Michael Beck's avatar
Michael Beck committed
142
143
}

144
static inline op_pin_state get_op_pinned_(const ir_op *op)
Matthias Braun's avatar
Matthias Braun committed
145
146
{
	return op->pin_state;
Michael Beck's avatar
Michael Beck committed
147
148
}

149
static inline void set_generic_function_ptr_(ir_op *op, op_func func)
Matthias Braun's avatar
Matthias Braun committed
150
151
{
	op->ops.generic = func;
152
153
}

154
static inline op_func get_generic_function_ptr_(const ir_op *op)
Matthias Braun's avatar
Matthias Braun committed
155
156
{
	return op->ops.generic;
157
}
Michael Beck's avatar
Michael Beck committed
158

159
static inline ir_op_ops *get_op_ops_(ir_op *op)
Matthias Braun's avatar
Matthias Braun committed
160
161
{
	return &op->ops;
Michael Beck's avatar
Michael Beck committed
162
163
}

164
static inline void set_op_tag_(ir_op *op, unsigned tag)
Matthias Braun's avatar
Matthias Braun committed
165
{
Sebastian Hack's avatar
Sebastian Hack committed
166
167
168
	op->tag = tag;
}

169
static inline unsigned get_op_tag_(const ir_op *op)
Matthias Braun's avatar
Matthias Braun committed
170
{
Sebastian Hack's avatar
Sebastian Hack committed
171
172
173
	return op->tag;
}

174
static inline void set_op_attr_(ir_op *op, void *attr)
Matthias Braun's avatar
Matthias Braun committed
175
{
176
177
178
	op->attr = attr;
}

179
static inline void *get_op_attr_(const ir_op *op)
Matthias Braun's avatar
Matthias Braun committed
180
{
181
182
183
	return op->attr;
}

Matthias Braun's avatar
Matthias Braun committed
184
#endif