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 * File name: ir/tr/tpop_t.h
23 * Purpose: Opcode of types -- private header.
24 * Author: Goetz Lindenmaier
28 * Copyright: (c) 2001-2003 Universität Karlsruhe
35 #include "firm_types.h"
42 * This file contains the datatypes hidden in tpop.h.
44 * @author Goetz Lindenmaier
48 /** A function called to free attributes of a type. */
49 typedef void (*free_attrs_func)(ir_type *tp);
51 /** A function called to free owned entities of a type. */
52 typedef void (*free_entities_func)(ir_type *tp);
54 /** A function called to free all automatic allocated entities of a type. */
55 typedef void (*free_auto_entities_func)(ir_type *tp);
57 /** A function called to set the mode of a type. */
58 typedef void (*set_type_mode_func)(ir_type *tp, ir_mode *m);
60 /** A function called to set the size of a type in bits */
61 typedef void (*set_type_size_func)(ir_type *tp, int size);
63 /** A function called to get the number of compound members */
64 typedef int (*get_n_members_func)(const ir_type *tp);
66 /** A function called to get the pos'th compound member */
67 typedef ir_entity *(*get_member_func)(const ir_type *tp, int pos);
69 typedef int (*get_member_index_func)(const ir_type *tp, ir_entity *member);
71 /** A function called to insert an entity into the type */
72 typedef void (*insert_entity_func)(ir_type *tp, ir_entity *member);
77 typedef struct _tp_op_ops {
78 free_attrs_func free_attrs; /**< called to free the attributes of a type */
79 free_entities_func free_entities; /**< called to free the owned entities of a type */
80 free_auto_entities_func free_auto_entities; /**< called to free the automatic allocated entities of a type */
81 set_type_mode_func set_type_mode; /**< called to set a ir_mode of a type */
82 set_type_size_func set_type_size; /**< called to set the bit size of a type */
83 get_n_members_func get_n_members; /**< called to return the number of compound members */
84 get_member_func get_member; /**< called to get the pos'th compound member */
85 get_member_index_func get_member_index; /**< called to get the index of a compound member */
88 /** possible flags for a type opcode */
90 TP_OP_FLAG_COMPOUND = 1 /**< is a compound type */
93 /** The type opcode */
95 tp_opcode code; /**< the tpop code */
96 ident *name; /**< the name of the type opcode */
97 size_t attr_size; /**< the attribute size for a type of this opcode */
98 unsigned flags; /**< flags for this opcode */
99 tp_op_ops ops; /**< tp_op operations */
103 * Returns a new type opcode.
105 * Allocates a new tp_op struct and initializes it's fields with
106 * the passed values. This function is only to be used during
107 * initialization of the library.
109 * @param code the enum for this type opcode.
110 * @param name an ident for the name of the type opcode.
111 * @param flags additional flags
112 * @param attr_size the size of the attributes necessary for a type with
114 * @param ops the tp_op operations for this type
115 * @return A new type opcode.
117 tp_op *new_tpop (tp_opcode code, ident *name, unsigned flags, size_t attr_size,
118 const tp_op_ops *ops);
121 * Free a tpop datastructure.
123 void free_tpop(tp_op *tpop);
126 * Initialize the tpop module.
128 * Must be called during the initialization of the library. Allocates
129 * opcodes and sets the globals that are external visible as specified
131 * Allocates opcodes for classes, struct, method, union, array,
132 * enumeration, pointer and primitive and sets the according values.
134 void init_tpop (void);
137 * Finalize the tpop module.
139 * Frees all type opcodes.
141 void finish_tpop(void);
144 * Returns the size of the attribute to this kind
149 * @param op The type opcode to get the size for.
150 * @return The size of the attribute of types with this opcode.
153 int get_tpop_attr_size (const tp_op *op);
156 /* ---------------- *
158 * -----------------*/
160 static INLINE tp_opcode
161 _get_tpop_code(const tp_op *op) {
165 static INLINE ident *
166 _get_tpop_ident(const tp_op *op){
171 _get_tpop_attr_size(const tp_op *op) {
172 return op->attr_size;
175 #define get_tpop_code(op) _get_tpop_code(op)
176 #define get_tpop_ident(op) _get_tpop_ident(op)
177 #define get_tpop_attr_size(op) _get_tpop_attr_size(op)
179 #endif /* _TPOP_T_H_ */