- add functions for global (ir_prog) resource management
authorMichael Beck <beck@ipd.info.uni-karlsruhe.de>
Mon, 27 Oct 2008 15:43:44 +0000 (15:43 +0000)
committerMichael Beck <beck@ipd.info.uni-karlsruhe.de>
Mon, 27 Oct 2008 15:43:44 +0000 (15:43 +0000)
[r23235]

include/libfirm/irprog.h
ir/ir/irgraph.c
ir/ir/irprog.c
ir/ir/irtypes.h

index 8d53478..3d8abcb 100644 (file)
@@ -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.
  *
index f349700..cfae624 100644 (file)
@@ -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 */
index 28bbd48..22dff63 100644 (file)
@@ -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
index 4dbae00..eade5fa 100644 (file)
@@ -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