Commit 2120cb6a authored by Michael Beck's avatar Michael Beck
Browse files

add base type for primitive types to better represent bitfields

[r15410]
parent 6f5fcad0
......@@ -2240,6 +2240,11 @@ ir_type *new_d_type_primitive(ident *name, ir_mode *mode, dbg_info* db);
/** Returns true if a type is a primitive type. */
int is_Primitive_type(const ir_type *primitive);
/** Return the base type of a primitive (bitfield) type or NULL if none. */
ir_type *get_primitive_base_type(ir_type *tp);
/** Sets the base type of a primitive (bitfield) type. */
void set_primitive_base_type(ir_type *tp, ir_type *base_tp);
/**
* @page none_type The None type
......
......@@ -180,7 +180,7 @@ void init_tpop(void) {
type_array = new_tpop(tpo_array , ID("array"), C, sizeof (arr_attr), &array_ops);
type_enumeration = new_tpop(tpo_enumeration, ID("enumeration"), 0, sizeof (enm_attr), &enum_ops);
type_pointer = new_tpop(tpo_pointer , ID("pointer"), 0, sizeof (ptr_attr), &pointer_ops);
type_primitive = new_tpop(tpo_primitive , ID("primitive"), 0, /* sizeof (pri_attr) */ 0, &null_ops);
type_primitive = new_tpop(tpo_primitive , ID("primitive"), 0, sizeof (pri_attr), &null_ops);
type_id = new_tpop(tpo_id , ID("type_id"), 0, /* sizeof (id_attr) */ 0, &null_ops);
tpop_none = new_tpop(tpo_none , ID("None"), 0, /* sizeof (non_attr) */ 0, &pseudo_ops);
tpop_unknown = new_tpop(tpo_unknown , ID("Unknown"), 0, /* sizeof (ukn_attr) */ 0, &pseudo_ops);
......
......@@ -1931,6 +1931,7 @@ ir_type *new_d_type_primitive(ident *name, ir_mode *mode, dbg_info *db) {
ir_type *res = new_type(type_primitive, mode, name, db);
res->size = get_mode_size_bits(mode);
res->flags |= tf_layout_fixed;
res->attr.ba.base_type = NULL;
hook_new_type(res);
return res;
}
......@@ -1939,7 +1940,7 @@ ir_type *new_type_primitive(ident *name, ir_mode *mode) {
return new_d_type_primitive(name, mode, NULL);
}
/* typecheck */
/* type check */
int (is_Primitive_type)(const ir_type *primitive) {
return _is_primitive_type(primitive);
}
......@@ -1953,6 +1954,17 @@ void set_primitive_mode(ir_type *tp, ir_mode *mode) {
tp->mode = mode;
}
/* Return the base type of a primitive (bitfield) type or NULL if none. */
ir_type *get_primitive_base_type(ir_type *tp) {
assert(is_Primitive_type(tp));
return tp->attr.ba.base_type;
}
/* Sets the base type of a primitive (bitfield) type. */
void set_primitive_base_type(ir_type *tp, ir_type *base_tp) {
assert(is_Primitive_type(tp));
tp->attr.ba.base_type = base_tp;
}
/*-----------------------------------------------------------------*/
/* common functionality */
......
......@@ -115,9 +115,10 @@ typedef struct {
ir_type *points_to; /**< The type of the ir_entity the pointer points to. */
} ptr_attr;
/*
typedef struct { * No private attr yet! *
} pri_attr; */
/** Primitive type attributes. */
typedef struct {
ir_type *base_type; /**< For bitfield types: The base primitive type, NULL else. */
} pri_attr;
/*
......@@ -134,6 +135,7 @@ typedef union {
arr_attr aa; /**< Attributes of an array type */
enm_attr ea; /**< Attributes of an enumeration type */
ptr_attr pa; /**< Attributes of a pointer type */
pri_attr ba; /**< Attributes of a primitive bitfield type */
} tp_attr;
/** Additional 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