extern const tp_op *type_primitive;
const tp_op *get_tpop_primitive(void);
-/**
- * This type opcode is an auxiliary opcode dedicated to support transformations
- * of the type structure.
- *
- * If a type is changed to another type with another
- * opcode the new type will be allocated with new memory. All nodes refering
- * to the old type need to be changed to refer to the new one. This is simplified
- * by turning the old type into an id type that merely forwards to the new type
- * that now replaces the old one.
- * type_ids should never be visible out of the type module. All access routines
- * should automatically check for type_id and eventually follow the forward in
- * type_id. Two types are exchanged by a call to exchange_types.
- * If a type_id is visible externally report this as bug. If it is assured that
- * this never happens this extern variable can be moved to tpop_t.h.
- * This struct is dynamically allocated but constant for the lifetime
- * of the library.
- */
-extern const tp_op *type_id;
-const tp_op *get_tpop_id(void);
-
/**
* The code type is used to mark pieces of code (basic blocks)
*/
#define TR_VRFY() tr_vrfy()
#endif
-/** Replaces one type by the other.
- *
- * Old type is replaced by new_type. All references to old_type
- * now point to new_type. The memory for the old type is destroyed,
- * but still used. Therefore it is not freed.
- * All referenced to this memory will be lost after a certain while.
- * An exception is the list of types in irp (irprog.h).
- * In the future there might be a routine to recover the memory, but
- * this will be at considerable runtime cost.
- *
- * @param old_type - The old type that shall be replaced by the new type.
- * @param new_type - The new type that will replace old_type.
- *
- */
-void exchange_types(ir_type *old_type, ir_type *new_type);
-
-/** Skip id types until a useful type is reached.
- *
- * @param tp - A type of arbitrary kind.
- *
- * @return
- * tp if it is not an id type.
- * If tp is an id type returns the real type it stands for.
- */
-ir_type *skip_tid(ir_type *tp);
-
/**
* @page type representation of types
*
* the target processor.
*/
-#include "typerep.h"
-
/** Frees all entities associated with a type.
* Does not free the array entity.
* Warning: ensure these entities are not referenced anywhere else.
* - the same element type
* - they are enumeration types and have the same enumerator names
* - they are pointer types and have the identical points_to type
- * (i.e., the same C-struct to represent the type, type_id is skipped.
+ * (i.e., the same C-struct to represent the type.
* This is to avoid endless recursions; with pointer types cyclic
* type graphs are possible.)
*/
*/
ir_type *mature_type_free_entities(ir_type *tp);
-/**
- * The interface type for the type identify module;
- */
-struct type_identify_if_t {
- compare_types_func_t *cmp; /**< The function that should be used to compare two types.
- If NULL, compare_strict() will be used. */
- hash_types_func_t *hash; /**< The function that should be used to calculate a hash
- value of a type. If NULL, hash_name() will be used. */
-};
-
-/**
- * Initialise the type identifier module.
- *
- * @param ti_if The interface functions for this module.
- *
- * If the parameter ti_if is NULL, the default functions compare_strict() and
- * firm_hash_name() will be used.
- */
-void init_type_identify(type_identify_if_t *ti_if);
-
/** A data type to treat types and entities as the same. */
typedef union {
ir_type *typ; /**< points to a type */
*/
void types_calc_finalization(void);
-/**
- * Checks if a type already exists in the program and returns the existing
- * type.
- * @param type The type to check
- * @param free_from_obst free type from type obst (only legal if nothing
- * else was allocated since the type allocation)
- */
-ir_type *identify_type(ir_type *type, int free_from_obst);
-
#endif
firm_init_type(def_params.builtin_dbg, def_params.cc_mask);
/* initialize the entity module */
firm_init_entity();
- /* allocate a hash table. */
- init_type_identify(def_params.ti_if);
/* class cast optimization */
firm_init_class_casts_opt();
/* memory disambiguation */
static inline ir_type *
_get_irg_frame_type(ir_graph *irg) {
- assert(irg && irg->frame_type);
- return irg->frame_type = skip_tid(irg->frame_type);
+ assert(irg->frame_type);
+ return irg->frame_type;
}
static inline void
call_attr *get_irn_call_attr(ir_node *node) {
assert(is_Call(node));
- node->attr.call.type = skip_tid(node->attr.call.type);
return &node->attr.call;
}
ir_type *
get_Const_type(ir_node *node) {
assert(is_Const(node));
- node->attr.con.tp = skip_tid(node->attr.con.tp);
return node->attr.con.tp;
}
ir_node *irn = (ir_node *)node;
assert(is_SymConst(node) &&
(SYMCONST_HAS_TYPE(get_SymConst_kind(node))));
- return irn->attr.symc.sym.type_p = skip_tid(irn->attr.symc.sym.type_p);
+ return irn->attr.symc.sym.type_p;
}
void
ir_type *
get_SymConst_value_type(ir_node *node) {
assert(is_SymConst(node));
- if (node->attr.symc.tp) node->attr.symc.tp = skip_tid(node->attr.symc.tp);
return node->attr.symc.tp;
}
ir_type *
get_Call_type(ir_node *node) {
assert(is_Call(node));
- return node->attr.call.type = skip_tid(node->attr.call.type);
+ return node->attr.call.type;
}
void
ir_type *
get_Builtin_type(ir_node *node) {
assert(is_Builtin(node));
- return node->attr.builtin.type = skip_tid(node->attr.builtin.type);
+ return node->attr.builtin.type;
}
void
ir_type *
get_Cast_type(ir_node *node) {
assert(is_Cast(node));
- node->attr.cast.type = skip_tid(node->attr.cast.type);
return node->attr.cast.type;
}
ir_type *
get_Alloc_type(ir_node *node) {
assert(is_Alloc(node));
- return node->attr.alloc.type = skip_tid(node->attr.alloc.type);
+ return node->attr.alloc.type;
}
void
ir_type *
get_Free_type(ir_node *node) {
assert(is_Free(node));
- return node->attr.free.type = skip_tid(node->attr.free.type);
+ return node->attr.free.type;
}
void
ir_type *get_CopyB_type(ir_node *node) {
assert(is_CopyB(node));
- return node->attr.copyb.type = skip_tid(node->attr.copyb.type);
+ return node->attr.copyb.type;
}
void set_CopyB_type(ir_node *node, ir_type *data_type) {
ir_type *
get_InstOf_type(ir_node *node) {
assert(node->op == op_InstOf);
- return node->attr.instof.type = skip_tid(node->attr.instof.type);
+ return node->attr.instof.type;
}
void
#include "array.h"
/** Adds mode to the list of modes in irp. */
-void add_irp_mode(ir_mode *mode);
+void add_irp_mode(ir_mode *mode);
/* inline functions */
static inline ir_type *
ir_type *type;
assert(segment < IR_SEGMENT_COUNT);
- type = skip_tid(irp->segment_types[segment]);
+ type = irp->segment_types[segment];
irp->segment_types[segment] = type;
return type;
}
static inline int
_get_irp_n_irgs(void) {
- assert (irp && irp->graphs);
+ assert(irp && irp->graphs);
if (get_visit_pseudo_irgs()) return get_irp_n_allirgs();
return ARR_LEN(irp->graphs);
}
static inline int
_get_irp_n_types(void) {
- assert (irp && irp->types);
+ assert(irp && irp->types);
return ARR_LEN(irp->types);
}
static inline ir_type *
_get_irp_type(int pos) {
- assert (irp && irp->types);
+ assert(irp->types);
/* Don't set the skip_tid result so that no double entries are generated. */
- return skip_tid(irp->types[pos]);
+ return irp->types[pos];
}
static inline int
_get_irp_n_modes(void) {
- assert (irp && irp->modes);
+ assert(irp->modes);
return ARR_LEN(irp->modes);
}
static inline ir_mode *
_get_irp_mode(int pos) {
- assert (irp && irp->modes);
+ assert(irp && irp->modes);
return irp->modes[pos];
}
static inline int
_get_irp_n_opcodes(void) {
- assert (irp && irp->opcodes);
+ assert(irp && irp->opcodes);
return ARR_LEN(irp->opcodes);
}
static inline ir_op *
_get_irp_opcode(int pos) {
- assert (irp && irp->opcodes);
+ assert(irp && irp->opcodes);
return irp->opcodes[pos];
}
static inline ir_type *
_get_entity_owner(ir_entity *ent) {
assert(ent && ent->kind == k_entity);
- return ent->owner = skip_tid(ent->owner);
+ return ent->owner;
}
static inline ident *
static inline ir_type *
_get_entity_type(ir_entity *ent) {
assert(ent && ent->kind == k_entity);
- return ent->type = skip_tid(ent->type);
+ return ent->type;
}
static inline void
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(ir_type, attr) + type_op->attr_size;
{
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]);
+ return clss->attr.ca.subtypes[pos];
}
int get_class_subtype_index(ir_type *clss, const ir_type *subclass)
{
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]);
+ return clss->attr.ca.supertypes[pos];
}
void set_class_supertype(ir_type *clss, ir_type *supertype, int pos)
assert(pos >= 0 && pos < get_method_n_params(method));
res = method->attr.ma.params[pos].tp;
assert(res != NULL && "empty method param type");
- return method->attr.ma.params[pos].tp = skip_tid(res);
+ return res;
}
void set_method_param_type(ir_type *method, int pos, ir_type *tp)
assert(pos >= 0 && pos < get_method_n_ress(method));
res = method->attr.ma.res_type[pos].tp;
assert(res != NULL && "empty method return type");
- return method->attr.ma.res_type[pos].tp = skip_tid(res);
+ return res;
}
void set_method_res_type(ir_type *method, int pos, ir_type *tp)
ir_type *get_array_element_type(ir_type *array)
{
assert(array && (array->type_op == type_array));
- return array->attr.aa.element_type = skip_tid(array->attr.aa.element_type);
+ return array->attr.aa.element_type;
}
void set_array_element_entity(ir_type *array, ir_entity *ent)
ir_type *get_pointer_points_to_type(ir_type *pointer)
{
assert(pointer && (pointer->type_op == type_pointer));
- return pointer->attr.pa.points_to = skip_tid(pointer->attr.pa.points_to);
+ return pointer->attr.pa.points_to;
}
int (is_Pointer_type)(const ir_type *pointer)
+++ /dev/null
-/*
- * Copyright (C) 1995-2008 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file type_identify.c
- * @brief Representation of types.
- * @author Goetz Lindenmaier
- * @version $Id$
- */
-#include "config.h"
-
-#include "typerep.h"
-
-#include <stdlib.h>
-#include <stddef.h>
-#include <string.h>
-
-#include "type_t.h"
-#include "tpop_t.h"
-#include "irprog_t.h"
-#include "array.h"
-#include "irprog_t.h"
-#include "pset.h"
-#include "irtools.h"
-
-/* The hash set for types. */
-static pset *type_table = NULL;
-
-/* hash and compare types */
-static hash_types_func_t *hash_types_func;
-static compare_types_func_t *compare_types_func;
-
-int compare_names (const void *tp1, const void *tp2) {
- ir_type *t1 = (ir_type *) tp1;
- ir_type *t2 = (ir_type *) tp2;
-
- return (t1 != t2 &&
- (t1->type_op != t2->type_op ||
- t1->name != t2->name ) );
-}
-
-/* stuff for comparing two types. */
-int compare_strict(const void *tp1, const void *tp2) {
- const ir_type *t1 = tp1;
- const ir_type *t2 = tp2;
- return t1 != t2;
-}
-
-/* stuff to compute a hash value for a type. */
-int firm_hash_name(ir_type *tp) {
- unsigned h = (unsigned)PTR_TO_INT(tp->type_op);
- h = 9*h + (unsigned)PTR_TO_INT(tp->name);
- return h;
-}
-
-/* The function that hashes a type. */
-ir_type *mature_type(ir_type *tp) {
- ir_type *o;
-
- assert(type_table);
-
- o = pset_insert (type_table, tp, hash_types_func(tp) );
- if (!o || o == tp) return tp;
- exchange_types(tp, o);
-
- return o;
-}
-
-
-/* The function that hashes a type. */
-ir_type *mature_type_free(ir_type *tp) {
- ir_type *o;
-
- assert(type_table);
-
- o = pset_insert (type_table, tp, hash_types_func(tp) );
- if (!o || o == tp) return tp;
-
- free_type_entities(tp);
- free_type(tp);
-
- return o;
-}
-
-/* The function that hashes a type. */
-ir_type *mature_type_free_entities(ir_type *tp) {
- ir_type *o;
-
- assert(type_table);
-
- o = pset_insert (type_table, tp, hash_types_func(tp) );
- if (!o || o == tp) return tp;
-
- free_type_entities(tp);
- exchange_types(tp, o);
-
- return o;
-}
-
-/* initialize this module */
-void init_type_identify(type_identify_if_t *ti_if) {
- compare_types_func = ti_if && ti_if->cmp ? ti_if->cmp : compare_strict;
- hash_types_func = ti_if && ti_if->hash ? ti_if->hash : firm_hash_name;
-
- type_table = new_pset (compare_types_func, 8);
-}
+++ /dev/null
-/*
- * Copyright (C) 1995-2008 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file typegmod.c
- * @brief Functionality to modify the type graph.
- * @author Goetz Lindenmaier, Michael Beck
- * @version $Id$
- */
-#include "config.h"
-
-#include "type_t.h"
-#include "tpop_t.h"
-#include "irmode.h"
-
-void exchange_types(ir_type *old_type, ir_type *new_type) {
- unsigned flags = old_type->flags & ~(tf_lowered_type | tf_layout_fixed);
- /* Deallocate datastructures not directly contained in the
- old type. We must do this now as it is the latest point
- where we know the original kind of type.
- */
- free_type_attrs(old_type);
-
- /* @@@@
- Things to deal with:
- * After exchange_types the type has two entries in the list of
- all types in irp. So far this is fine for the walker.
- Maybe it's better to remove the id entry and shrink the list.
- Does this conflict with the walker? Might a type be left out
- during the walk?
- * Deallocation: if the Id is removed from the list it will eventually
- disappear in a memory leak. When is impossible to determine so we
- need to hold it in a separate list for deallocation.
- */
-
- /* Exchange the types */
- old_type->type_op = type_id;
- old_type->assoc_type = new_type;
- /* ensure that the frame, value param, global and tls flags
- are set right if these types are exchanged */
- new_type->flags |= flags;
-}
-
-ir_type *skip_tid(ir_type *tp) {
- /* @@@ implement the self cycle killing trick of skip_id(ir_node *) */
- while (tp->type_op == type_id)
- tp = tp->assoc_type;
- return tp;
-}
return;
break;
case k_type:
- tp = skip_tid(tore.typ);
if (type_visited(tp))
return;
break;
if (entity_visited(tore.ent)) return;
break;
case k_type:
- if (type_id == get_type_tpop(tore.typ)) {
- cont.typ = skip_tid(tore.typ);
- type_walk_s2s_2(cont, pre, post, env);
- return;
- }
if (type_visited(tore.typ)) return;
break;
default:
/* execute pre method */
if (pre)
pre(tore, env);
- tp = skip_tid(tp);
n = get_class_n_subtypes(tp);
for (i = 0; i < n; ++i) {
return;
break;
case k_type:
- if (type_id == get_type_tpop(tore.typ)) {
- cont.typ = skip_tid(tore.typ);
- type_walk_super_2(cont, pre, post, env);
- return;
- }
if (type_visited(tore.typ))
return;
break;
/* execute pre method */
if (pre)
pre(tore, env);
- tp = skip_tid(tp);
n = get_class_n_supertypes(tp);
for (i = 0; i < n; ++i) {
if (pre)
pre(tp, env);
- tp = skip_tid(tp);
n = get_class_n_subtypes(tp);
for (i = 0; i < n; ++i) {
class_walk_s2s_2(get_class_subtype(tp, i), pre, post, env);