-/*
- * (C) 2001 by Universitaet Karlsruhe
- */
-
/**
*
- * @file type.h
+ * @file type.h
*
- * Datastructure to hold type information.
+ * Project: libFIRM <br>
+ * File name: ir/tr/type.h <br>
+ * Purpose: Representation of types. <br>
+ * Author: Goetz Lindenmaier <br>
+ * Modified by: <br>
+ * Created: <br>
+ * Copyright: (c) 2001-2003 Universität Karlsruhe <br>
+ * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE. <br>
+ * CVS-ID: $Id$
*
- * @author Goetz Lindenmaier
+ *
+ * Datastructure to hold type information.
*
* This module supplies a datastructure to represent all types
* known in the compiled program. This includes types specified
* in the program as well as types defined by the language. In the
* view of the intermediate representation there is no difference
- * between these types.
+ * between these types. Finally it specifies some auxiliary types.
*
* There exist several kinds of types, arranged by the structure of
* the type. A type is described by a set of attributes. Some of
* on the level of the programming language, modes at the level of
* the target processor.
*
- * @see tpop.h
+ * @see tpop.h
*/
-/* $Id$ */
-
# ifndef _TYPE_H_
# define _TYPE_H_
+# include <stdbool.h>
+
# include "tpop.h"
# include "firm_common.h"
# include "ident.h"
# include "irmode.h"
-# include <stdbool.h>
# include "dbginfo.h"
# include "type_or_entity.h"
/** Frees the memory used by the type. Does not free the entities
- belonging to the type, except for the array element entity. */
+ belonging to the type, except for the array element entity.
+ Does not free if tp is "none" or "unknown". */
void free_type(type *tp);
tp_op* get_type_tpop(type *tp);
layout_fixed /**< The layout is fixed, all component/member entities
have an offset assigned. Size of the type is known.
Arrays can be accessed by explicit address
- computation. Default for pointer, primitive ane method
+ computation. Default for pointer, primitive and method
types. */
} type_state;
/** Sets the mode of a type.
*
- * Only has an effect on primitive and enumeration types.
+ * Only has an effect on primitive, enumeration and pointer types.
*/
void set_type_mode(type *tp, ir_mode* m);
/** 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. */
- inherited, /**< Describes explicitly that other entities are
- inherited to the owner of this entity.
- Overwrites must refer to at least one other
- entity. If this is a method entity there exists
- no irg for this entity, only for one of the
- overwritten ones. */
- existent /**< The entity/type (can) exist. */
+ peculiarity_description, /**< Represents only a description. The entity/type is never
+ allocated, no code/data exists for this entity/type. */
+ peculiarity_inherited, /**< Describes explicitly that other entities are
+ inherited to the owner of this entity.
+ Overwrites must refer to at least one other
+ entity. If this is a method entity there exists
+ no irg for this entity, only for one of the
+ overwritten ones.
+ Only for entity. */
+ peculiarity_existent /**< The entity/type (can) exist. */
} peculiarity;
+char *get_peculiarity_string(peculiarity p);
/* The peculiarity of the class. The enumeration peculiarity is defined
in entity.h */
/* Returns an entity that represents the copied value result. Only necessary
for compounds passed by value. This information is constructed only on demand. */
entity *get_method_value_res_ent(type *method, int pos);
+/*
+ */
+type *get_method_value_res_type(type *method);
/**
* this enum flags the variadicity of methods (methods with a
* non_variadic.
*/
typedef enum variadicity {
- non_variadic, /**< non variadic */
- variadic /**< variadic */
+ variadicity_non_variadic, /**< non variadic */
+ variadicity_variadic /**< variadic */
} variadicity;
+/** Returns the null-terminated name of this variadicity. */
+const char *get_variadicity_name(variadicity vari);
+
/** Returns the variadicity of a method. */
variadicity get_method_variadicity(type *method);
/** Creates a new type pointer with mode mode_p. */
#define new_type_pointer(N, P) new_type_pointer_mode(N, P, mode_P)
-//type *new_type_pointer (ident *name, type *points_to);
+/* type *new_type_pointer (ident *name, type *points_to); */
/** Creates a new type pointer with given pointer mode. */
type *new_type_pointer_mode (ident *name, type *points_to, ir_mode *ptr_mode);
/** Returns true if a type is a pointer type. */
bool is_pointer_type (type *pointer);
+/** Returns the first pointer type that has as points_to tp.
+ * Not efficient: O(#types).
+ * If not found returns unknown_type. */
+type *find_pointer_type_to_type (type *tp);
+
/**
* @page primitive_type Representation of a primitive type
*
bool is_primitive_type (type *primitive);
+/**
+ * @page none_type
+ *
+ * This type is an auxiliary type dedicated to support type analyses.
+ *
+ * The none type represents that there is no type. The type can be used to
+ * initialize fields of type* that actually can not contain a type or that
+ * are initialized for an analysis. There exists exactly one type none.
+ * This type is not on the type list in ir_prog. It is
+ * allocated when initializing the type module.
+ *
+ * The following values are set:
+ * mode: mode_BAD
+ * name: "type_none"
+ * state: layout_fixed
+ * size: 0
+ */
+/* A variable that contains the only none type. */
+extern type *none_type;
+/* Returns the none type */
+type *get_none_type(void);
+
+/**
+ * @page unknown_type
+ *
+ * This type is an auxiliary type dedicated to support type analyses.
+ *
+ * The unknown type represents that there could be a type, but it is not
+ * known. This type can be used to initialize fields before an analysis (not known
+ * yet) or to represent the top of a lattice (could not be determined). There exists
+ * exactly one type unknown. This type is not on the type list in ir_prog. It is
+ * allocated when initializing the type module.
+ *
+ * The following values are set:
+ * mode: mode_ANY
+ * name: "type_unknown"
+ * state: layout_fixed
+ * size: 0
+ */
+/* A variable that contains the only unknown type. */
+extern type *unknown_type;
+/* Returns the none type */
+type *get_unknown_type(void);
+
+
/**
* Checks whether a type is atomic.
* @param tp - any type
int is_compound_type(type *tp);
-/** Outputs a unique number for this type if libfirm is compiled for
- debugging, (configure with --enable-debug) else returns 0. */
+/**
+ * Outputs a unique number for this type if libfirm is compiled for
+ * debugging, (configure with --enable-debug) else returns the address
+ * of the type cast to long.
+ */
INLINE long get_type_nr(type *tp);
# endif /* _TYPE_H_ */