X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;ds=sidebyside;f=include%2Flibfirm%2Ftrouts.h;h=2366ae8a70f7c236dc10cc0a79714c331d291009;hb=ce29d67e4cf75e435dd50b15a294a07a3b3e6309;hp=8ad827cfdfda6a43051bbfbc5a69834cc81bc50f;hpb=acbdf295cc01d5b69b1cb8ea2c7764dca1e7b8ac;p=libfirm diff --git a/include/libfirm/trouts.h b/include/libfirm/trouts.h index 8ad827cfd..2366ae8a7 100644 --- a/include/libfirm/trouts.h +++ b/include/libfirm/trouts.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 1995-2008 University of Karlsruhe. All right reserved. + * Copyright (C) 1995-2011 University of Karlsruhe. All right reserved. * * This file is part of libFirm. * @@ -22,18 +22,6 @@ * @brief Reverse edges that reference types/entities. * @author Goetz Lindenmaier * @date 29.10.2004 - * @version $Id$ - * @brief - * Trouts list all uses of types and entities. - * Each type gets a list of all Alloc nodes allocating it. - * Each entity gets two lists: - * - one containing all accesses (Load, (Call), Store), - * - and one containing all uses to get a reference (Sel, SymConst). - * - * @todo - * To list all uses of entities of a type, we also should list all - * static/automatic allocated entities in types. The Alloc nodes - * represent only the dynamic allocated entities. */ #ifndef FIRM_ANA_TROUTS_H #define FIRM_ANA_TROUTS_H @@ -41,76 +29,56 @@ #include "firm_types.h" #include "irgraph.h" -/*-----------------------------------------------------------------*/ -/* Accessing the trout datastructures. */ -/* These routines only work properly if firm is in state */ -/* trouts_consistent or trouts_inconsistent. */ -/*-----------------------------------------------------------------*/ - -/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -/* entities */ -/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -/** Number of Load/Store nodes that possibly access this entity. */ -int get_entity_n_accesses(const ir_entity *ent); -/** Load/Store node that possibly access this entity. */ -ir_node *get_entity_access(const ir_entity *ent, int pos); - -/** Number of references to an entity, in form of SymConst/Sel. - * Including references from constant entities and the like. */ -int get_entity_n_references(const ir_entity *ent); -/** References to an entity, in form of SymConst/Sel - * Including references from constants. */ -ir_node *get_entity_reference(const ir_entity *ent, int pos); - -/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -/* types */ -/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ +#include "begin.h" -/** Number of Alloc nodes that create an instance of this type. */ -int get_type_n_allocs(const ir_type *tp); -/** Alloc node that create an instance of this type. */ -ir_node *get_type_alloc(const ir_type *tp, int pos); +/** + * @ingroup ir_type + * @defgroup trouts Reverse Type Edges + * Trouts list all uses of types and entities. + * Each type gets a list of all Alloc nodes allocating it. + * Each entity gets two lists: + * - one containing all accesses (Load, (Call), Store), + * - and one containing all uses to get a reference (Sel, SymConst). + * @{ + */ -/** Number of Cast nodes that cast a pointer to this type. */ -int get_type_n_casts(const ir_type *tp); +/** Returns number of Load/Store nodes that possibly access entity @p entity. */ +FIRM_API size_t get_entity_n_accesses(const ir_entity *entity); +/** Returns Load/Store node number @p pos that possibly accesses entity @p entity. */ +FIRM_API ir_node *get_entity_access(const ir_entity *entity, size_t pos); + +/** Returns number of references to entity @p entity, in form of SymConst/Sel, + * including references from constant entities and the like. */ +FIRM_API size_t get_entity_n_references(const ir_entity *entity); +/** Returns reference number @p pos of references to an entity, in form of + * SymConst/Sel, including references from constants. */ +FIRM_API ir_node *get_entity_reference(const ir_entity *entity, size_t pos); + +/** Returns number of Alloc nodes that create an instance of type @p type. */ +FIRM_API size_t get_type_n_allocs(const ir_type *type); +/** Returns Alloc node number @p pos that create an instance of type @p type. */ +FIRM_API ir_node *get_type_alloc(const ir_type *type, size_t pos); + +/** Returns number of Cast nodes that cast a pointer to type @p type. */ +FIRM_API size_t get_type_n_casts(const ir_type *type); /** Cast node that cast a pointer to this type. */ -ir_node *get_type_cast(const ir_type *tp, int pos); -void add_type_cast(const ir_type *tp, ir_node *cast); -/** Return number of upcasts. O(\#casts). */ -int get_class_n_upcasts(const ir_type *clss); -/** Return number of downcasts. O(\#casts). */ -int get_class_n_downcasts(const ir_type *clss); - -/* Access all pointer types that point to tp. */ -int get_type_n_pointertypes_to(const ir_type *tp); -ir_type *get_type_pointertype_to(const ir_type *tp, int pos); -void add_type_pointertype_to(const ir_type *tp, ir_type *ptp); - -/* Access all array types that contain elements of type tp. - * Does not find subarrays, e.g., int[] being element of int[][] - * for multi dimensional arrays. */ -int get_type_n_arraytypes_of(const ir_type *tp); -ir_type *get_type_arraytype_of(const ir_type *tp, int pos); -void add_type_arraytype_of(const ir_type *tp, ir_type *atp); - - - -/* @@@ TODO: compute all entities that use a type. */ - -/*------------------------------------------------------------------*/ -/* Building and Removing the trout datastructure */ -/*------------------------------------------------------------------*/ - -/** The state of the tr_out datastructure. - * - * We reuse the enum of irouts. - * @see irouts.h. */ -irg_outs_state get_trouts_state(void); -/** Set the tr out state to inconsistent if it is consistent. */ -void set_trouts_inconsistent(void); - -/** Compute the outs of types and entities. +FIRM_API ir_node *get_type_cast(const ir_type *type, size_t pos); +/** Returns number of upcasts. O(\#casts). */ +FIRM_API size_t get_class_n_upcasts(const ir_type *clss); +/** Returns number of downcasts. O(\#casts). */ +FIRM_API size_t get_class_n_downcasts(const ir_type *clss); + +/** Returns number of pointertypes that point to type @p type. */ +FIRM_API size_t get_type_n_pointertypes_to(const ir_type *type); +/** Returns pointer type number @p pos that points to type @p type. */ +FIRM_API ir_type *get_type_pointertype_to(const ir_type *type, size_t pos); + +/** Returns number of array types with element type @p type. */ +FIRM_API size_t get_type_n_arraytypes_of(const ir_type *type); +/** Returns array type number @p pos with element type @p type. */ +FIRM_API ir_type *get_type_arraytype_of(const ir_type *type, size_t pos); + +/** Computes the outs of types and entities. * * Collects all reference from irnodes to types or entities in the * corresponding types/entities. Further reverses references between @@ -132,9 +100,13 @@ void set_trouts_inconsistent(void); * * Sets trout state to outs_consistent. */ -void compute_trouts(void); +FIRM_API void compute_trouts(void); + +/** Frees trout data. */ +FIRM_API void free_trouts(void); + +/** @} */ -/** Free trout data. */ -void free_trouts(void); +#include "end.h" #endif