# include "type.h"
# include "tpop_t.h"
+# include "array.h"
+
/**
* @file type_t.h
* This file contains the datatypes hidden in type.h.
ident *name;
type_state state; /**< Represents the types state: layout undefined or
fixed. */
- int size; /**< Size of an entity of this type. This is determined
+ int size; /**< Size of an entity of this type. This is determined
when fixing the layout of this class. Size must be
- given in bytes. */
+ given in bits. */
ir_mode *mode; /**< The mode for atomic types */
unsigned long visit; /**< visited counter for walks of the type information */
void *link; /**< holds temporary data - like in irnode_t.h */
struct dbg_info* dbi; /**< A pointer to information for debug support. */
+ /* ------------- fields for analyses ---------------*/
+ ir_node **allocations; /**< array of all Alloc nodes with this type
+ @@@ Should not be in here, hash table! */
+
#ifdef DEBUG_libfirm
int nr; /**< a unique node number for each node to make output
readable. */
}
static INLINE int
-__get_type_size(type *tp) {
+__get_type_size_bits(type *tp) {
assert(tp && tp->kind == k_type);
return tp->size;
}
+static INLINE int
+__get_type_size_bytes(type *tp) {
+ int size = __get_type_size_bits(tp);
+ if (size < 0)
+ return -1;
+ if ((size & 7) != 0) {
+ assert(0 && "cannot take byte size of this type");
+ return -1;
+ }
+ return size >> 3;
+}
+
static INLINE type_state
__get_type_state(type *tp) {
assert(tp && tp->kind == k_type);
return (clss->type_op == type_class);
}
+static INLINE int
+__get_class_n_members (type *clss) {
+ assert(clss && (clss->type_op == type_class));
+ return (ARR_LEN (clss->attr.ca.members));
+}
+
+static INLINE entity *
+__get_class_member (type *clss, int pos) {
+ assert(clss && (clss->type_op == type_class));
+ assert(pos >= 0 && pos < get_class_n_members(clss));
+ return clss->attr.ca.members[pos];
+}
+
static INLINE int
__is_struct_type(type *strct) {
assert(strct);
#define type_not_visited(tp) __type_not_visited(tp)
#define is_type(thing) __is_type(thing)
#define is_class_type(clss) __is_class_type(clss)
+#define get_class_n_members(clss) __get_class_n_members(clss)
+#define get_class_member(clss, pos) __get_class_member(clss, pos)
#define is_struct_type(strct) __is_struct_type(strct)
#define is_method_type(method) __is_method_type(method)
#define is_union_type(uni) __is_union_type(uni)