X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fana%2Firtypeinfo.c;h=77b871e906905d5132ef58488225e04ac9c781be;hb=555593b0aebec433b871920acc2b0a869b072055;hp=4205fe44891845f0546628ac7aa82026b5b61d58;hpb=f8cc15664f571aa7ef89d6f6bc8d5bd2b8ca7d53;p=libfirm diff --git a/ir/ana/irtypeinfo.c b/ir/ana/irtypeinfo.c index 4205fe448..77b871e90 100644 --- a/ir/ana/irtypeinfo.c +++ b/ir/ana/irtypeinfo.c @@ -45,27 +45,11 @@ #include "irnode_t.h" #include "pmap.h" -/* ------------ The map. ---------------------------------------------- */ - - static pmap *type_node_map = NULL; -/* ------------ Auxiliary type. --------------------------------------- */ - -/* This auxiliary type expresses that a field is uninitialized. The - * variable is set by init_irtypeinfo. The type is freed by - * free_irtypeinfo. - */ ir_type *initial_type = NULL; -/* ------------ Initializing this module. ----------------------------- */ - -/* Initializes the type information module. - * Generates a type "initial_type" and sets the type of all nodes to this type. - * Calling set/get_irn_type is invalid before calling init. Requires memory - * in the order of MIN(, #irnodes). - */ void init_irtypeinfo(void) { size_t i, n; @@ -101,8 +85,6 @@ void free_irtypeinfo(void) } -/* ------------ Irgraph state handling. ------------------------------- */ - void set_irg_typeinfo_state(ir_graph *irg, ir_typeinfo_state s) { assert(is_ir_graph(irg)); @@ -120,12 +102,6 @@ ir_typeinfo_state get_irg_typeinfo_state(const ir_graph *irg) } -/* Returns accumulated type information state information. - * - * Returns ir_typeinfo_consistent if the type information of all irgs is - * consistent. Returns ir_typeinfo_inconsistent if at least one irg has inconsistent - * or no type information. Returns ir_typeinfo_none if no irg contains type information. - */ ir_typeinfo_state get_irp_typeinfo_state(void) { return irp->typeinfo_state; @@ -134,7 +110,6 @@ void set_irp_typeinfo_state(ir_typeinfo_state s) { irp->typeinfo_state = s; } -/* If typeinfo is consistent, sets it to inconsistent. */ void set_irp_typeinfo_inconsistent(void) { if (irp->typeinfo_state == ir_typeinfo_consistent) @@ -142,29 +117,22 @@ void set_irp_typeinfo_inconsistent(void) } -/* ------------ Irnode type information. ------------------------------ */ - -/* These routines only work properly if the ir_graph is in state - * ir_typeinfo_consistent or ir_typeinfo_inconsistent. They - * assume current_ir_graph set properly. - */ ir_type *get_irn_typeinfo_type(const ir_node *n) { - ir_type *res = initial_type; - pmap_entry *entry; - + ir_type *res; assert(get_irg_typeinfo_state(get_irn_irg(n)) != ir_typeinfo_none); - entry = pmap_find(type_node_map, n); - if (entry != NULL) - res = (ir_type*) entry->value; + res = pmap_get(ir_type, type_node_map, n); + if (res == NULL) { + res = initial_type; + } return res; } void set_irn_typeinfo_type(ir_node *n, ir_type *tp) { - assert(get_irg_typeinfo_state(current_ir_graph) != ir_typeinfo_none); + assert(get_irg_typeinfo_state(get_irn_irg(n)) != ir_typeinfo_none); pmap_insert(type_node_map, (void *)n, (void *)tp); }