3 * File name: ir/tr/tpop_t.h
4 * Purpose: Opcode of types -- private header.
5 * Author: Goetz Lindenmaier
9 * Copyright: (c) 2001-2003 Universität Karlsruhe
10 * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE.
17 #include "firm_types.h"
24 * This file contains the datatypes hidden in tpop.h.
26 * @author Goetz Lindenmaier
30 /** A function called to free attributes of a type. */
31 typedef void (*free_attrs_func)(ir_type *tp);
33 /** A function called to free owned entities of a type. */
34 typedef void (*free_entities_func)(ir_type *tp);
36 /** A function called to free all automatic allocated entities of a type. */
37 typedef void (*free_auto_entities_func)(ir_type *tp);
39 /** A function called to set the mode of a type. */
40 typedef void (*set_type_mode_func)(ir_type *tp, ir_mode *m);
42 /** A function called to set the size of a type in bits */
43 typedef void (*set_type_size_func)(ir_type *tp, int size);
45 /** A function called to get the number of compound members */
46 typedef int (*get_n_members_func)(const ir_type *tp);
48 /** A function called to get the pos'th compound member */
49 typedef entity *(*get_member_func)(const ir_type *tp, int pos);
51 typedef int (*get_member_index_func)(const ir_type *tp, entity *member);
53 /** A function called to insert an entity into the type */
54 typedef void (*insert_entity_func)(ir_type *tp, entity *member);
59 typedef struct _tp_op_ops {
60 free_attrs_func free_attrs; /**< called to free the attributes of a type */
61 free_entities_func free_entities; /**< called to free the owned entities of a type */
62 free_auto_entities_func free_auto_entities; /**< called to free the automatic allocated entities of a type */
63 set_type_mode_func set_type_mode; /**< called to set a ir_mode of a type */
64 set_type_size_func set_type_size; /**< called to set the bit size of a type */
65 get_n_members_func get_n_members; /**< called to return the number of compound members */
66 get_member_func get_member; /**< called to get the pos'th compound member */
67 get_member_index_func get_member_index; /**< called to get the index of a compound member */
70 /** possible flags for a type opcode */
72 TP_OP_FLAG_COMPOUND = 1 /**< is a compound type */
75 /** The type opcode */
77 tp_opcode code; /**< the tpop code */
78 ident *name; /**< the name of the type opcode */
79 size_t attr_size; /**< the attribute size for a type of this opcode */
80 unsigned flags; /**< flags for this opcode */
81 tp_op_ops ops; /**< tp_op operations */
85 * Returns a new type opcode.
87 * Allocates a new tp_op struct and initializes it's fields with
88 * the passed values. This function is only to be used during
89 * initialization of the library.
91 * @param code the enum for this type opcode.
92 * @param name an ident for the name of the type opcode.
93 * @param flags additional flags
94 * @param attr_size the size of the attributes necessary for a type with
96 * @param ops the tp_op operations for this type
97 * @return A new type opcode.
99 tp_op *new_tpop (tp_opcode code, ident *name, unsigned flags, size_t attr_size,
100 const tp_op_ops *ops);
103 * Free a tpop datastructure.
105 void free_tpop(tp_op *tpop);
108 * Initialize the tpop module.
110 * Must be called during the initialization of the library. Allocates
111 * opcodes and sets the globals that are external visible as specified
113 * Allocates opcodes for classes, struct, method, union, array,
114 * enumeration, pointer and primitive and sets the according values.
116 void init_tpop (void);
119 * Finalize the tpop module.
121 * Frees all type opcodes.
123 void finish_tpop(void);
126 * Returns the size of the attribute to this kind
131 * @param op The type opcode to get the size for.
132 * @return The size of the attribute of types with this opcode.
135 int get_tpop_attr_size (const tp_op *op);
138 /* ---------------- *
140 * -----------------*/
142 static INLINE tp_opcode
143 _get_tpop_code(const tp_op *op) {
147 static INLINE ident *
148 _get_tpop_ident(const tp_op *op){
153 _get_tpop_attr_size(const tp_op *op) {
154 return op->attr_size;
157 #define get_tpop_code(op) _get_tpop_code(op)
158 #define get_tpop_ident(op) _get_tpop_ident(op)
159 #define get_tpop_attr_size(op) _get_tpop_attr_size(op)
161 #endif /* _TPOP_T_H_ */