From: Michael Beck Date: Mon, 27 Oct 2008 15:43:44 +0000 (+0000) Subject: - add functions for global (ir_prog) resource management X-Git-Url: http://nsz.repo.hu/git/?a=commitdiff_plain;h=64d13bb5d7e4b2c992d562840c9625afad83fa22;p=libfirm - add functions for global (ir_prog) resource management [r23235] --- diff --git a/include/libfirm/irprog.h b/include/libfirm/irprog.h index 8d5347894..3d8abcb4a 100644 --- a/include/libfirm/irprog.h +++ b/include/libfirm/irprog.h @@ -93,6 +93,16 @@ typedef struct ir_prog ir_prog; */ extern ir_prog *irp; +#ifndef NDEBUG +void irp_reserve_resources(ir_prog *irp, ir_resources_t resources); +void irp_free_resources(ir_prog *irp, ir_resources_t resources); +ir_resources_t irp_resources_reserved(const ir_prog *irp); +#else +void irp_reserve_resources(irp, resources) +void irp_free_resources(irp, resources) +ir_resources_t irp_resources_reserved(irp) 0 +#endif + /** * Returns the access points from where everything in the ir can be accessed. * diff --git a/ir/ir/irgraph.c b/ir/ir/irgraph.c index f349700a5..cfae62452 100644 --- a/ir/ir/irgraph.c +++ b/ir/ir/irgraph.c @@ -1050,20 +1050,17 @@ void *get_irg_loc_description(ir_graph *irg, int n) { } #ifndef NDEBUG -void ir_reserve_resources(ir_graph *irg, ir_resources_t resources) -{ +void ir_reserve_resources(ir_graph *irg, ir_resources_t resources) { assert((irg->reserved_resources & resources) == 0); irg->reserved_resources |= resources; } -void ir_free_resources(ir_graph *irg, ir_resources_t resources) -{ +void ir_free_resources(ir_graph *irg, ir_resources_t resources) { assert((irg->reserved_resources & resources) == resources); irg->reserved_resources &= ~resources; } -ir_resources_t ir_resources_reserved(const ir_graph *irg) -{ +ir_resources_t ir_resources_reserved(const ir_graph *irg) { return irg->reserved_resources; } #endif /* NDEBUG */ diff --git a/ir/ir/irprog.c b/ir/ir/irprog.c index 28bbd48c9..22dff63d5 100644 --- a/ir/ir/irprog.c +++ b/ir/ir/irprog.c @@ -65,7 +65,10 @@ static ir_prog *new_incomplete_ir_prog(void) res->max_irg_idx = 0; #ifdef DEBUG_libfirm - res->max_node_nr = 0; + res->max_node_nr = 0; +#endif +#ifndef NDEBUG + res->reserved_resources = 0; #endif return res; @@ -430,3 +433,19 @@ ident *get_irp_asm(int pos) { assert(pos <= 0 && pos < get_irp_n_asms()); return irp->global_asms[pos]; } + +#ifndef NDEBUG +void irp_reserve_resources(ir_prog *irp, ir_resources_t resources) { + assert((irp->reserved_resources & resources) == 0); + irp->reserved_resources |= resources; +} + +void irp_free_resources(ir_prog *irp, ir_resources_t resources) { + assert((irp->reserved_resources & resources) == resources); + irp->reserved_resources &= ~resources; +} + +ir_resources_t irp_resources_reserved(const ir_prog *irp) { + return irp->reserved_resources; +} +#endif diff --git a/ir/ir/irtypes.h b/ir/ir/irtypes.h index 4dbae00f9..eade5faf9 100644 --- a/ir/ir/irtypes.h +++ b/ir/ir/irtypes.h @@ -509,7 +509,7 @@ struct ir_graph { #endif #ifndef NDEBUG - ir_resources_t reserved_resources;/**< Bitset for tracking used resources. */ + ir_resources_t reserved_resources; /**< Bitset for tracking used local resources. */ #endif }; @@ -565,6 +565,9 @@ struct ir_prog { #ifdef DEBUG_libfirm long max_node_nr; /**< to generate unique numbers for nodes. */ #endif +#ifndef NDEBUG + ir_resources_t reserved_resources; /**< Bitset for tracking used global resources. */ +#endif }; #endif