Commit 6f319bb1 authored by Matthias Braun's avatar Matthias Braun
Browse files

Get rid of tpop flags (we already have type flags)

parent 4790cf11
......@@ -23,13 +23,12 @@ const tp_op *type_primitive; const tp_op *get_tpop_primitive(void) { return type
const tp_op *tpop_code; const tp_op *get_tpop_code_type(void) { return tpop_code; }
const tp_op *tpop_unknown; const tp_op *get_tpop_unknown (void) { return tpop_unknown; }
const tp_op *new_tpop(tp_opcode code, ident *name, unsigned flags,
size_t attr_size, const tp_op_ops *ops)
const tp_op *new_tpop(tp_opcode code, ident *name, size_t attr_size,
const tp_op_ops *ops)
{
tp_op *res = XMALLOC(tp_op);
res->code = code;
res->name = name;
res->flags = flags;
res->attr_size = attr_size;
res->ops = *ops;
return res;
......@@ -64,15 +63,15 @@ static const tp_op_ops
void init_tpop(void)
{
type_class = new_tpop(tpo_class, NEW_IDENT("class"), TP_OP_FLAG_COMPOUND, sizeof(cls_attr), &class_ops);
type_struct = new_tpop(tpo_struct, NEW_IDENT("struct"), TP_OP_FLAG_COMPOUND, sizeof(compound_attr), &struct_ops);
type_method = new_tpop(tpo_method, NEW_IDENT("method"), 0, sizeof(mtd_attr), &method_ops);
type_union = new_tpop(tpo_union, NEW_IDENT("union"), TP_OP_FLAG_COMPOUND, sizeof(compound_attr), &union_ops);
type_array = new_tpop(tpo_array, NEW_IDENT("array"), 0, sizeof(arr_attr), &null_ops);
type_pointer = new_tpop(tpo_pointer, NEW_IDENT("pointer"), 0, sizeof(ptr_attr), &null_ops);
type_primitive = new_tpop(tpo_primitive, NEW_IDENT("primitive"), 0, 0, &null_ops);
tpop_code = new_tpop(tpo_code, NEW_IDENT("code"), 0, 0, &null_ops);
tpop_unknown = new_tpop(tpo_unknown, NEW_IDENT("Unknown"), 0, 0, &null_ops);
type_class = new_tpop(tpo_class, NEW_IDENT("class"), sizeof(cls_attr), &class_ops);
type_struct = new_tpop(tpo_struct, NEW_IDENT("struct"), sizeof(compound_attr), &struct_ops);
type_method = new_tpop(tpo_method, NEW_IDENT("method"), sizeof(mtd_attr), &method_ops);
type_union = new_tpop(tpo_union, NEW_IDENT("union"), sizeof(compound_attr), &union_ops);
type_array = new_tpop(tpo_array, NEW_IDENT("array"), sizeof(arr_attr), &null_ops);
type_pointer = new_tpop(tpo_pointer, NEW_IDENT("pointer"), sizeof(ptr_attr), &null_ops);
type_primitive = new_tpop(tpo_primitive, NEW_IDENT("primitive"), 0, &null_ops);
tpop_code = new_tpop(tpo_code, NEW_IDENT("code"), 0, &null_ops);
tpop_unknown = new_tpop(tpo_unknown, NEW_IDENT("Unknown"), 0, &null_ops);
}
void finish_tpop(void)
......
......@@ -27,17 +27,11 @@ typedef struct tp_op_ops {
void (*free_attrs)(ir_type *type);
} tp_op_ops;
/** possible flags for a type opcode */
enum tp_op_flags_t {
TP_OP_FLAG_COMPOUND = 1 /**< is a compound type */
};
/** The type opcode. */
struct tp_op {
tp_opcode code; /**< The tpop code. */
ident *name; /**< The name of the type opcode. */
size_t attr_size; /**< The attribute size for a type of this opcode. */
unsigned flags; /**< Flags for this opcode. */
tp_op_ops ops; /**< tp_op operations. */
};
......@@ -50,14 +44,13 @@ struct tp_op {
*
* @param code the enum for this type opcode.
* @param name an ident for the name of the type opcode.
* @param flags additional flags
* @param attr_size the size of the attributes necessary for a type with
* this opcode
* @param ops the tp_op operations for this type
* @return A new type opcode.
*/
tp_op const *new_tpop(tp_opcode code, ident *name, unsigned flags,
size_t attr_size, tp_op_ops const *ops);
tp_op const *new_tpop(tp_opcode code, ident *name, size_t attr_size,
tp_op_ops const *ops);
/**
* Free a tpop data structure.
......
......@@ -312,6 +312,7 @@ void (set_type_dbg_info)(ir_type *tp, type_dbg_info *db)
static void compound_init(ir_type *const type, ident *const name)
{
type->flags |= tf_compound;
type->name = name;
type->attr.ca.members = NEW_ARR_F(ir_entity*, 0);
}
......@@ -935,7 +936,7 @@ int is_compound_variable_size(const ir_type *tp)
int is_compound_type(const ir_type *tp)
{
assert(tp->kind == k_type);
return tp->type_op->flags & TP_OP_FLAG_COMPOUND;
return (tp->flags & tf_compound) != 0;
}
ident *get_compound_ident(const ir_type *tp)
......
......@@ -99,16 +99,17 @@ typedef union {
/** Additional type flags. */
typedef enum type_flags {
tf_none = 0, /**< No flags. */
tf_lowered_type = 1U << 0, /**< Set if this is a lowered type. */
tf_layout_fixed = 1U << 1, /**< Set if the layout of a type is fixed */
tf_frame_type = 1U << 2, /**< Set if this is a frame type. */
tf_segment = 1U << 3, /**< type represents a linker segment */
tf_global_type = 1U << 4, /**< Set only for the global type */
tf_tls_type = 1U << 5, /**< Set only for the tls type */
tf_info = 1U << 6, /**< infos (for example constructor, destructor pointers) */
tf_variable_size = 1U << 7, /**< compound or array type may have variable size last element */
tf_lowered_dw = 1U << 8, /**< hack to identify lowered doubleword params */
tf_compound = 1U << 0, /**< Set if type is a compound type. */
tf_lowered_type = 1U << 1, /**< Set if this is a lowered type. */
tf_layout_fixed = 1U << 2, /**< Set if the layout of a type is fixed */
tf_frame_type = 1U << 3, /**< Set if this is a frame type. */
tf_segment = 1U << 4, /**< type represents a linker segment */
tf_global_type = 1U << 5, /**< Set only for the global type */
tf_tls_type = 1U << 6, /**< Set only for the tls type */
tf_info = 1U << 7, /**< infos (for example constructor, destructor pointers) */
tf_variable_size = 1U << 8, /**< compound or array type may have variable size last element */
tf_lowered_dw = 1U << 9, /**< hack to identify lowered doubleword params */
} type_flags;
ENUM_BITSET(type_flags)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment