Commit 1838facc authored by Michael Beck's avatar Michael Beck
Browse files

renamed all type 'type' to new ir_type

intrinsic method property added

[r7210]
parent 61adb504
......@@ -74,8 +74,8 @@
/** TYPE **/
/*-----------------------------------------------------------------*/
type *firm_none_type; type *get_none_type(void) { return firm_none_type; }
type *firm_unknown_type; type *get_unknown_type(void) { return firm_unknown_type; }
ir_type *firm_none_type; ir_type *get_none_type(void) { return firm_none_type; }
ir_type *firm_unknown_type; ir_type *get_unknown_type(void) { return firm_unknown_type; }
#ifdef DEBUG_libfirm
......@@ -124,15 +124,15 @@ void (inc_master_type_visited)(void) { _inc_master_type_visited();
/*
* Creates a new type representation.
*/
type *
ir_type *
new_type(tp_op *type_op, ir_mode *mode, ident *name, dbg_info *db) {
type *res;
ir_type *res;
int node_size;
assert(type_op != type_id);
assert(!id_contains_char(name, ' ') && "type name should not contain spaces");
node_size = offsetof(type, attr) + type_op->attr_size;
node_size = offsetof(ir_type, attr) + type_op->attr_size;
res = xmalloc(node_size);
memset(res, 0, node_size);
......@@ -157,7 +157,7 @@ new_type(tp_op *type_op, ir_mode *mode, ident *name, dbg_info *db) {
return res;
}
void free_type(type *tp) {
void free_type(ir_type *tp) {
const tp_op *op = get_type_tpop(tp);
if ((get_type_tpop(tp) == tpop_none) || (get_type_tpop(tp) == tpop_unknown))
......@@ -166,7 +166,7 @@ void free_type(type *tp) {
remove_irp_type(tp);
/* Free the attributes of the type. */
free_type_attrs(tp);
/* Free entities automatically allocated with the type */
/* Free entities automatically allocated with the ir_type */
if (op->ops.free_auto_entities)
op->ops.free_auto_entities(tp);
/* And now the type itself... */
......@@ -174,14 +174,14 @@ void free_type(type *tp) {
free(tp);
}
void free_type_entities(type *tp) {
void free_type_entities(ir_type *tp) {
const tp_op *tpop = get_type_tpop(tp);
if (tpop->ops.free_entities)
tpop->ops.free_entities(tp);
}
void free_type_attrs(type *tp) {
void free_type_attrs(ir_type *tp) {
const tp_op *tpop = get_type_tpop(tp);
if (tpop->ops.free_attrs)
......@@ -189,36 +189,36 @@ void free_type_attrs(type *tp) {
}
/* set/get the link field */
void *(get_type_link)(const type *tp) {
void *(get_type_link)(const ir_type *tp) {
return _get_type_link(tp);
}
void (set_type_link)(type *tp, void *l) {
void (set_type_link)(ir_type *tp, void *l) {
_set_type_link(tp, l);
}
const tp_op *(get_type_tpop)(const type *tp) {
const tp_op *(get_type_tpop)(const ir_type *tp) {
return _get_type_tpop(tp);
}
ident *(get_type_tpop_nameid)(const type *tp) {
ident *(get_type_tpop_nameid)(const ir_type *tp) {
return _get_type_tpop_nameid(tp);
}
const char* get_type_tpop_name(const type *tp) {
const char* get_type_tpop_name(const ir_type *tp) {
assert(tp && tp->kind == k_type);
return get_id_str(tp->type_op->name);
}
tp_opcode (get_type_tpop_code)(const type *tp) {
tp_opcode (get_type_tpop_code)(const ir_type *tp) {
return _get_type_tpop_code(tp);
}
ir_mode *(get_type_mode)(const type *tp) {
ir_mode *(get_type_mode)(const ir_type *tp) {
return _get_type_mode(tp);
}
void set_type_mode(type *tp, ir_mode *mode) {
void set_type_mode(ir_type *tp, ir_mode *mode) {
const tp_op *tpop = get_type_tpop(tp);
if (tpop->ops.set_type_mode)
......@@ -227,16 +227,16 @@ void set_type_mode(type *tp, ir_mode *mode) {
assert(0 && "setting a mode is NOT allowed for this type");
}
ident *(get_type_ident)(const type *tp) {
ident *(get_type_ident)(const ir_type *tp) {
return _get_type_ident(tp);
}
void (set_type_ident)(type *tp, ident* id) {
void (set_type_ident)(ir_type *tp, ident* id) {
_set_type_ident(tp, id);
}
/* Outputs a unique number for this node */
long get_type_nr(const type *tp) {
long get_type_nr(const ir_type *tp) {
assert(tp);
#ifdef DEBUG_libfirm
return tp->nr;
......@@ -245,21 +245,21 @@ long get_type_nr(const type *tp) {
#endif
}
const char* get_type_name(const type *tp) {
const char* get_type_name(const ir_type *tp) {
assert(tp && tp->kind == k_type);
return (get_id_str(tp->name));
}
int (get_type_size_bytes)(const type *tp) {
int (get_type_size_bytes)(const ir_type *tp) {
return _get_type_size_bytes(tp);
}
int (get_type_size_bits)(const type *tp) {
int (get_type_size_bits)(const ir_type *tp) {
return _get_type_size_bits(tp);
}
visibility get_type_visibility (const type *tp) {
visibility get_type_visibility (const ir_type *tp) {
#if 0
visibility res = visibility_local;
if (is_compound_type(tp)) {
......@@ -283,7 +283,7 @@ visibility get_type_visibility (const type *tp) {
return tp->visibility;
}
void set_type_visibility (type *tp, visibility v) {
void set_type_visibility (ir_type *tp, visibility v) {
assert(is_type(tp));
#if 0
/* check for correctness */
......@@ -310,7 +310,7 @@ void set_type_visibility (type *tp, visibility v) {
}
void
set_type_size_bits(type *tp, int size) {
set_type_size_bits(ir_type *tp, int size) {
const tp_op *tpop = get_type_tpop(tp);
if (tpop->ops.set_type_size)
......@@ -320,17 +320,17 @@ set_type_size_bits(type *tp, int size) {
}
void
set_type_size_bytes(type *tp, int size) {
set_type_size_bytes(ir_type *tp, int size) {
set_type_size_bits(tp, 8*size);
}
int get_type_alignment_bytes(type *tp) {
int get_type_alignment_bytes(ir_type *tp) {
int align = get_type_alignment_bits(tp);
return align < 0 ? align : (align + 7) >> 3;
}
int get_type_alignment_bits(type *tp) {
int get_type_alignment_bits(ir_type *tp) {
int align = 8;
if (tp->align > 0)
......@@ -346,7 +346,7 @@ int get_type_alignment_bits(type *tp) {
align = 0;
for (i = 0; i < n; ++i) {
type *t = get_entity_type(get_compound_member(tp, i));
ir_type *t = get_entity_type(get_compound_member(tp, i));
int a = get_type_alignment_bits(t);
if (a > align)
......@@ -363,7 +363,7 @@ int get_type_alignment_bits(type *tp) {
}
void
set_type_alignment_bits(type *tp, int align) {
set_type_alignment_bits(ir_type *tp, int align) {
assert(tp && tp->kind == k_type);
/* Methods don't have an alignment. */
if (tp->type_op != type_method) {
......@@ -372,7 +372,7 @@ set_type_alignment_bits(type *tp, int align) {
}
void
set_type_alignment_bytes(type *tp, int align) {
set_type_alignment_bytes(ir_type *tp, int align) {
set_type_alignment_bits(tp, 8*align);
}
......@@ -388,12 +388,12 @@ const char *get_type_state_name(type_state s) {
}
type_state (get_type_state)(const type *tp) {
type_state (get_type_state)(const ir_type *tp) {
return _get_type_state(tp);
}
void
set_type_state(type *tp, type_state state) {
set_type_state(ir_type *tp, type_state state) {
assert(tp && tp->kind == k_type);
if ((tp->type_op == type_pointer) || (tp->type_op == type_primitive) ||
......@@ -448,24 +448,24 @@ set_type_state(type *tp, type_state state) {
tp->state = state;
}
unsigned long (get_type_visited)(const type *tp) {
unsigned long (get_type_visited)(const ir_type *tp) {
return _get_type_visited(tp);
}
void (set_type_visited)(type *tp, unsigned long num) {
void (set_type_visited)(ir_type *tp, unsigned long num) {
_set_type_visited(tp, num);
}
/* Sets visited field in type to type_visited. */
void (mark_type_visited)(type *tp) {
void (mark_type_visited)(ir_type *tp) {
_mark_type_visited(tp);
}
int (type_visited)(const type *tp) {
int (type_visited)(const ir_type *tp) {
return _type_visited(tp);
}
int (type_not_visited)(const type *tp) {
int (type_not_visited)(const ir_type *tp) {
return _type_not_visited(tp);
}
......@@ -474,9 +474,9 @@ int (is_type)(const void *thing) {
}
/* Checks whether two types are structural equal.*/
int equal_type(type *typ1, type *typ2) {
int equal_type(ir_type *typ1, ir_type *typ2) {
entity **m;
type **t;
ir_type **t;
int i, j;
if (typ1 == typ2) return 1;
......@@ -518,9 +518,9 @@ int equal_type(type *typ1, type *typ2) {
memset(t, 0, sizeof(entity *) * get_class_n_supertypes(typ1));
/* First sort the supertypes of typ2 */
for (i = 0; i < get_class_n_supertypes(typ1); i++) {
type *t1 = get_class_supertype(typ1, i);
ir_type *t1 = get_class_supertype(typ1, i);
for (j = 0; j < get_class_n_supertypes(typ2); j++) {
type *t2 = get_class_supertype(typ2, j);
ir_type *t2 = get_class_supertype(typ2, j);
if (get_type_ident(t2) == get_type_ident(t1))
t[i] = t2;
}
......@@ -625,7 +625,7 @@ int equal_type(type *typ1, type *typ2) {
}
/* Checks whether two types are structural comparable. */
int smaller_type (type *st, type *lt) {
int smaller_type (ir_type *st, ir_type *lt) {
entity **m;
int i, j;
......@@ -708,7 +708,7 @@ int smaller_type (type *st, type *lt) {
}
} break;
case tpo_array: {
type *set, *let; /* small/large elt. type */
ir_type *set, *let; /* small/large elt. ir_type */
if (get_array_n_dimensions(st) != get_array_n_dimensions(lt))
return 0;
set = get_array_element_type(st);
......@@ -755,33 +755,33 @@ int smaller_type (type *st, type *lt) {
/* TYPE_CLASS */
/*-----------------------------------------------------------------*/
/* create a new class type */
type *new_d_type_class (ident *name, dbg_info *db) {
type *res;
/* create a new class ir_type */
ir_type *new_d_type_class (ident *name, dbg_info *db) {
ir_type *res;
res = new_type(type_class, NULL, name, db);
res->attr.ca.members = NEW_ARR_F (entity *, 0);
res->attr.ca.subtypes = NEW_ARR_F (type *, 0);
res->attr.ca.supertypes = NEW_ARR_F (type *, 0);
res->attr.ca.subtypes = NEW_ARR_F (ir_type *, 0);
res->attr.ca.supertypes = NEW_ARR_F (ir_type *, 0);
res->attr.ca.peculiarity = peculiarity_existent;
res->attr.ca.dfn = 0;
hook_new_type(res);
return res;
}
type *new_type_class (ident *name) {
ir_type *new_type_class (ident *name) {
return new_d_type_class (name, NULL);
}
void free_class_entities(type *clss) {
void free_class_entities(ir_type *clss) {
int i;
assert(clss && (clss->type_op == type_class));
for (i = get_class_n_members(clss) - 1; i >= 0; --i)
free_entity(get_class_member(clss, i));
}
void free_class_attrs(type *clss) {
void free_class_attrs(ir_type *clss) {
assert(clss && (clss->type_op == type_class));
DEL_ARR_F(clss->attr.ca.members);
DEL_ARR_F(clss->attr.ca.subtypes);
......@@ -789,17 +789,17 @@ void free_class_attrs(type *clss) {
}
/* manipulate private fields of class type */
void add_class_member (type *clss, entity *member) {
void add_class_member (ir_type *clss, entity *member) {
assert(clss && (clss->type_op == type_class));
assert(clss != get_entity_type(member) && "recursive type");
ARR_APP1 (entity *, clss->attr.ca.members, member);
}
int (get_class_n_members) (const type *clss) {
int (get_class_n_members) (const ir_type *clss) {
return _get_class_n_members(clss);
}
int get_class_member_index(type *clss, entity *mem) {
int get_class_member_index(ir_type *clss, entity *mem) {
int i;
assert(clss && (clss->type_op == type_class));
for (i = 0; i < get_class_n_members(clss); i++)
......@@ -808,11 +808,11 @@ int get_class_member_index(type *clss, entity *mem) {
return -1;
}
entity *(get_class_member) (const type *clss, int pos) {
entity *(get_class_member) (const ir_type *clss, int pos) {
return _get_class_member(clss, pos);
}
entity *get_class_member_by_name(type *clss, ident *name) {
entity *get_class_member_by_name(ir_type *clss, ident *name) {
int i, n_mem;
assert(clss && (clss->type_op == type_class));
n_mem = get_class_n_members(clss);
......@@ -823,12 +823,12 @@ entity *get_class_member_by_name(type *clss, ident *name) {
return NULL;
}
void set_class_member (type *clss, entity *member, int pos) {
void set_class_member (ir_type *clss, entity *member, int pos) {
assert(clss && (clss->type_op == type_class));
assert(pos >= 0 && pos < get_class_n_members(clss));
clss->attr.ca.members[pos] = member;
}
void set_class_members (type *clss, entity **members, int arity) {
void set_class_members (ir_type *clss, entity **members, int arity) {
int i;
assert(clss && (clss->type_op == type_class));
DEL_ARR_F(clss->attr.ca.members);
......@@ -838,7 +838,7 @@ void set_class_members (type *clss, entity **members, int arity) {
ARR_APP1 (entity *, clss->attr.ca.members, members[i]);
}
}
void remove_class_member(type *clss, entity *member) {
void remove_class_member(ir_type *clss, entity *member) {
int i;
assert(clss && (clss->type_op == type_class));
for (i = 0; i < (ARR_LEN (clss->attr.ca.members)); i++) {
......@@ -851,26 +851,26 @@ void remove_class_member(type *clss, entity *member) {
}
}
void add_class_subtype (type *clss, type *subtype) {
void add_class_subtype (ir_type *clss, ir_type *subtype) {
int i;
assert(clss && (clss->type_op == type_class));
ARR_APP1 (type *, clss->attr.ca.subtypes, subtype);
ARR_APP1 (ir_type *, clss->attr.ca.subtypes, subtype);
for (i = 0; i < get_class_n_supertypes(subtype); i++)
if (get_class_supertype(subtype, i) == clss)
/* Class already registered */
return;
ARR_APP1 (type *, subtype->attr.ca.supertypes, clss);
ARR_APP1 (ir_type *, subtype->attr.ca.supertypes, clss);
}
int get_class_n_subtypes (const type *clss) {
int get_class_n_subtypes (const ir_type *clss) {
assert(clss && (clss->type_op == type_class));
return (ARR_LEN (clss->attr.ca.subtypes));
}
type *get_class_subtype (type *clss, int pos) {
ir_type *get_class_subtype (ir_type *clss, int pos) {
assert(clss && (clss->type_op == type_class));
assert(pos >= 0 && pos < get_class_n_subtypes(clss));
return clss->attr.ca.subtypes[pos] = skip_tid(clss->attr.ca.subtypes[pos]);
}
int get_class_subtype_index(type *clss, const type *subclass) {
int get_class_subtype_index(ir_type *clss, const ir_type *subclass) {
int i, n_subtypes = get_class_n_subtypes(clss);
assert(is_Class_type(subclass));
for (i = 0; i < n_subtypes; ++i) {
......@@ -878,12 +878,12 @@ int get_class_subtype_index(type *clss, const type *subclass) {
}
return -1;
}
void set_class_subtype (type *clss, type *subtype, int pos) {
void set_class_subtype (ir_type *clss, ir_type *subtype, int pos) {
assert(clss && (clss->type_op == type_class));
assert(pos >= 0 && pos < get_class_n_subtypes(clss));
clss->attr.ca.subtypes[pos] = subtype;
}
void remove_class_subtype(type *clss, type *subtype) {
void remove_class_subtype(ir_type *clss, ir_type *subtype) {
int i;
assert(clss && (clss->type_op == type_class));
for (i = 0; i < (ARR_LEN (clss->attr.ca.subtypes)); i++)
......@@ -895,22 +895,22 @@ void remove_class_subtype(type *clss, type *subtype) {
}
}
void add_class_supertype (type *clss, type *supertype) {
void add_class_supertype (ir_type *clss, ir_type *supertype) {
int i;
assert(clss && (clss->type_op == type_class));
assert(supertype && (supertype -> type_op == type_class));
ARR_APP1 (type *, clss->attr.ca.supertypes, supertype);
ARR_APP1 (ir_type *, clss->attr.ca.supertypes, supertype);
for (i = get_class_n_subtypes(supertype) - 1; i >= 0; --i)
if (get_class_subtype(supertype, i) == clss)
/* Class already registered */
return;
ARR_APP1 (type *, supertype->attr.ca.subtypes, clss);
ARR_APP1 (ir_type *, supertype->attr.ca.subtypes, clss);
}
int get_class_n_supertypes (const type *clss) {
int get_class_n_supertypes (const ir_type *clss) {
assert(clss && (clss->type_op == type_class));
return (ARR_LEN (clss->attr.ca.supertypes));
}
int get_class_supertype_index(type *clss, type *super_clss) {
int get_class_supertype_index(ir_type *clss, ir_type *super_clss) {
int i, n_supertypes = get_class_n_supertypes(clss);
assert(super_clss && (super_clss->type_op == type_class));
for (i = 0; i < n_supertypes; i++)
......@@ -918,17 +918,17 @@ int get_class_supertype_index(type *clss, type *super_clss) {
return i;
return -1;
}
type *get_class_supertype (type *clss, int pos) {
ir_type *get_class_supertype (ir_type *clss, int pos) {
assert(clss && (clss->type_op == type_class));
assert(pos >= 0 && pos < get_class_n_supertypes(clss));
return clss->attr.ca.supertypes[pos] = skip_tid(clss->attr.ca.supertypes[pos]);
}
void set_class_supertype (type *clss, type *supertype, int pos) {
void set_class_supertype (ir_type *clss, ir_type *supertype, int pos) {
assert(clss && (clss->type_op == type_class));
assert(pos >= 0 && pos < get_class_n_supertypes(clss));
clss->attr.ca.supertypes[pos] = supertype;
}
void remove_class_supertype(type *clss, type *supertype) {
void remove_class_supertype(ir_type *clss, ir_type *supertype) {
int i;
assert(clss && (clss->type_op == type_class));
for (i = 0; i < (ARR_LEN (clss->attr.ca.supertypes)); i++)
......@@ -951,40 +951,40 @@ const char *get_peculiarity_string(peculiarity p) {
return "invalid peculiarity";
}
peculiarity get_class_peculiarity (const type *clss) {
peculiarity get_class_peculiarity (const ir_type *clss) {
assert(clss && (clss->type_op == type_class));
return clss->attr.ca.peculiarity;
}
void set_class_peculiarity (type *clss, peculiarity pec) {
void set_class_peculiarity (ir_type *clss, peculiarity pec) {
assert(clss && (clss->type_op == type_class));
assert(pec != peculiarity_inherited); /* There is no inheritance of types in libFirm. */
clss->attr.ca.peculiarity = pec;
}
void set_class_dfn (type *clss, int dfn)
void set_class_dfn (ir_type *clss, int dfn)
{
clss->attr.ca.dfn = dfn;
}
int get_class_dfn (const type *clss)
int get_class_dfn (const ir_type *clss)
{
return (clss->attr.ca.dfn);
}
/* typecheck */
int (is_Class_type)(const type *clss) {
int (is_Class_type)(const ir_type *clss) {
return _is_class_type(clss);
}
void set_class_mode(type *tp, ir_mode *mode) {
void set_class_mode(ir_type *tp, ir_mode *mode) {
/* for classes and structs we allow to set a mode if the layout is fixed AND the size matches */
assert(get_type_state(tp) == layout_fixed &&
tp->size == get_mode_size_bits(mode) && "mode don't match class layout");
tp->mode = mode;
}
void set_class_size_bits(type *tp, int size) {
void set_class_size_bits(ir_type *tp, int size) {
/* argh: we must allow to set negative values as "invalid size" */
tp->size = (size >= 0) ? (size + 7) & ~7 : size;
assert(tp->size == size && "setting a bit size is NOT allowed for this type");
......@@ -995,36 +995,36 @@ void set_class_size_bits(type *tp, int size) {
/*----------------------------------------------------------------**/
/* create a new type struct */
type *new_d_type_struct(ident *name, dbg_info *db) {
type *res = new_type(type_struct, NULL, name, db);
ir_type *new_d_type_struct(ident *name, dbg_info *db) {
ir_type *res = new_type(type_struct, NULL, name, db);
res->attr.sa.members = NEW_ARR_F(entity *, 0);
hook_new_type(res);
return res;
}
type *new_type_struct (ident *name) {
ir_type *new_type_struct (ident *name) {
return new_d_type_struct (name, NULL);
}
void free_struct_entities (type *strct) {
void free_struct_entities (ir_type *strct) {
int i;
assert(strct && (strct->type_op == type_struct));
for (i = get_struct_n_members(strct)-1; i >= 0; --i)
free_entity(get_struct_member(strct, i));
}
void free_struct_attrs (type *strct) {
void free_struct_attrs (ir_type *strct) {
assert(strct && (strct->type_op == type_struct));
DEL_ARR_F(strct->attr.sa.members);
}
/* manipulate private fields of struct */
int get_struct_n_members (const type *strct) {
int get_struct_n_members (const ir_type *strct) {
assert(strct && (strct->type_op == type_struct));
return (ARR_LEN (strct->attr.sa.members));
}
void add_struct_member (type *strct, entity *member) {
void add_struct_member (ir_type *strct, entity *member) {
assert(strct && (strct->type_op == type_struct));
assert(get_type_tpop(get_entity_type(member)) != type_method);
/* @@@ lowerfirm geht nicht durch */
......@@ -1032,13 +1032,13 @@ void add_struct_member (type *strct, entity *member) {
ARR_APP1 (entity *, strct->attr.sa.members, member);
}
entity *get_struct_member (const type *strct, int pos) {
entity *get_struct_member (const ir_type *strct, int pos) {
assert(strct && (strct->type_op == type_struct));
assert(pos >= 0 && pos < get_struct_n_members(strct));
return strct->attr.sa.members[pos];
}
int get_struct_member_index(type *strct, entity *mem) {
int get_struct_member_index(ir_type *strct, entity *mem) {
int i;
assert(strct && (strct->type_op == type_struct));
for (i = 0; i < get_struct_n_members(strct); i++)
......@@ -1047,13 +1047,13 @@ int get_struct_member_index(type *strct, entity *mem) {
return -1;
}
void set_struct_member (type *strct, int pos, entity *member) {
void set_struct_member (ir_type *strct, int pos, entity *member) {
assert(strct && (strct->type_op == type_struct));
assert(pos >= 0 && pos < get_struct_n_members(strct));
assert(get_entity_type(member)->type_op != type_method);/* @@@ lowerfirm !!*/
strct->attr.sa.members[pos] = member;
}
void remove_struct_member(type *strct, entity *member) {
void remove_struct_member(ir_type *strct, entity *member) {
int i;
assert(strct && (strct->type_op == type_struct));
for (i = 0; i < (ARR_LEN (strct->attr.sa.members)); i++)
......@@ -1066,18 +1066,18 @@ void remove_struct_member(type *strct, entity *member) {
}
/* typecheck */