-/****h* libfirm/type
+/****h* libfirm/type6 2002/03/19 13:08:33
*
* NAME
* file type.h - datastructure to hold type information.
* tpop.h
*****
*/
+
+/* $Id$ */
+
# ifndef _TYPE_H_
# define _TYPE_H_
# include "irmode.h"
# include "bool.h"
+
#ifndef _ENTITY_TYPEDEF_
#define _ENTITY_TYPEDEF_
/* to resolve recursion between entity.h and type.h */
* occupy size bytes in memory. In several cases this is
* determined when fixing the layout of this type (class,
* struct, union, array, enumeration).
+ * state The state of the type. The state represents whether the
+ * layout of the type is undefined or fixed (values: layout_undefined
+ * or layout_fixed). Compound types can have an undefined
+ * layout. The layout of the basic types primitive and pointer
+ * is always layout_fixed. If the layout of
+ * compound types is fixed all entities must have an offset
+ * and the size of the type must be set.
+ * A fixed layout for enumeration types means that each enumeration
+ * is associated with an implementation value.
* visit A counter for walks of the type information.
+ * link A void* to associate some additional inforamtion with the type.
*
* These fields can only be accessed via access functions.
*
*/
typedef struct type type;
+# include "type_or_entity.h"
+
void* get_type_link(type *tp);
void set_type_link(type *tp, void *l);
tp_op* get_type_tpop(type *tp);
const char* get_type_tpop_name(type *tp);
tp_opcode get_type_tpop_code(type *tp);
+/* Returns NULL for all non atomic types. */
ir_mode* get_type_mode(type *tp);
+/* Only has an effect on primitive and enumeration types */
void set_type_mode(type *tp, ir_mode* m);
ident* get_type_ident(type *tp);
const char* get_type_name(type *tp);
int get_type_size(type *tp);
-/* For primitives and pointer types the size is always fixed.
- This call is legal but has no effect. */
+/* For primitives, enumerationsm, pointer and method types the size
+ is always fixed. This call is legal but has no effect. */
void set_type_size(type *tp, int size);
typedef enum {
} type_state;
type_state get_type_state(type *tp);
-/* For primitives and pointer types the layout is always fixed.
+/* For primitives, pointer and method types the layout is always fixed.
This call is legal but has no effect. */
void set_type_state(type *tp, type_state state);
*
* These are dynamic lists that can be grown with an "add_" function,
* but not shrinked.
+ *
+ * peculiarity The peculiarity of this class. If the class is of peculiarity
+ * "description" it only is a description of requirememts to a class,
+ * as, e.g., a Java interface. The class will never be allocated.
+ * Values: description, existent. Default: existent.
+ *
* SOURCE
*/
/* create a new class type */
/* Overwrites the member at position pos, 0 <= pos < n_member with
the passed entity. */
void set_class_member (type *clss, entity *member, int pos);
+/* Replaces complete member list in class type by the list passed. Copies the
+ list passed. This function is necessary to reduce the number of members.
+ members is an array of entities, num the size of this array. Sets all
+ owners of the members passed to clss. */
+void set_class_members (type *clss, entity **members, int arity);
/* Finds member in the list of members and overwrites it with NULL
@@@ Doesn't work properly. */
void remove_class_member(type *clss, entity *member);
@@@ Doesn't work properly. */
void remove_class_supertype(type *clss, type *supertype);
+/* This enumeration flags the peculiarity of entities and types. */
+typedef enum peculiarity {
+ description, /* Represents only a description. The entity/type is never
+ allocated, no code/data exists for this entity/type. */
+ existent /* The entity/type (can) exist. */
+} peculiarity;
+
+/* The peculiarity of the class. The enumeration peculiarity is defined
+ in entity.h */
+inline peculiarity get_class_peculiarity (type *clss);
+inline void set_class_peculiarity (type *clss, peculiarity pec);
+
/* typecheck */
bool is_class_type(type *clss);
/*****/
* Representation of an array type.
* NOTE
* The array type represents rectangular multi dimensional arrays.
+ * The constants representing the bounds must be allocated to
+ * get_const_code_irg() by setting current_ir_graph accordingly.
* ATTRIBUTES
* n_dimensions Number of array dimensions.
* *lower_bound Lower bounds of dimensions. Usually all 0.
* SOURCE
*/
/* create a new type array --
- Set dimension sizes after call to constructor with set_* routines.
- Entity for array elements is built automatically. */
+ Sets n_dimension to dimension and all dimension entries to NULL.
+ Initializes order to the order of the dimensions.
+ Entity for array elements is built automatically.
+ Set dimension sizes after call to constructor with set_* routines. */
type *new_type_array (ident *name, int n_dimensions,
type *element_type);
/* manipulate private fields of array type */
int get_array_n_dimensions (type *array);
+/* Allocates Const nodes of mode_I for the array dimensions */
+void set_array_bounds_int (type *array, int dimension, int lower_bound,
+ int upper_bound);
void set_array_bounds (type *array, int dimension, ir_node *lower_bound,
ir_node *upper_bound);
void set_array_lower_bound (type *array, int dimension, ir_node *lower_bound);
+void set_array_lower_bound_int (type *array, int dimension, int lower_bound);
void set_array_upper_bound (type *array, int dimension, ir_node *upper_bound);
ir_node * get_array_lower_bound (type *array, int dimension);
ir_node * get_array_upper_bound (type *array, int dimension);
+void set_array_order (type *array, int dimension, int order);
+int get_array_order (type *array, int dimension);
+
void set_array_element_type (type *array, type *type);
type *get_array_element_type (type *array);
bool is_primitive_type (type *primitive);
/*****/
+
+
+/****f* type/is_atomic_type
+ *
+ * NAME
+ * is_atomic_type - Checks whether a type is atomic.
+ * SYNOPSIS
+ * int is_atomic_type(type *tp);
+ * INPUTS
+ * tp - any type
+ * RESULT
+ * true if type is primitive, pointer or enumeration
+ ***
+ */
+int is_atomic_type(type *tp);
+
+/****f* type/is_compound_type
+ *
+ * NAME
+ * is_compound_type - Checks whether a type is compound.
+ * SYNOPSIS
+ * int is_compound_type(type *tp)
+ * INPUTS
+ * tp - any type
+ * RESULT
+ * true if the type is class, structure, union or array type.
+ ***
+ */
+int is_compound_type(type *tp);
+
# endif /* _TYPE_H_ */