typos fixed
[libfirm] / ir / ir / irphase_t.h
index 26f5599..3d9920e 100644 (file)
@@ -75,10 +75,45 @@ void phase_free(phase_t *phase);
 /**
  * Re-initialize the irn data for all nodes in the node => data map using the given callback.
  * @param phase The phase.
- * @note This function will pass NULL to the init function passed to phase_new().
  */
 void phase_reinit_irn_data(phase_t *phase);
 
+/**
+ * Re-initialize the irn data for all nodes in the given block.
+ * @param phase The phase.
+ * @param block The block.
+ */
+void phase_reinit_block_irn_data(phase_t *phase, ir_node *block);
+
+/**
+ * Re-initialize the irn data for the given node.
+ * @param phase The phase.
+ * @param irn   The irn.
+ */
+#define phase_reinit_single_irn_data(phase, irn) _phase_reinit_single_irn_data((phase), (irn))
+
+/**
+ * Returns the first node of the phase having some data assigned.
+ * @param phase The phase.
+ * @return The first irn having some data assigned, NULL otherwise
+ */
+ir_node *phase_get_first_node(phase_t *phase);
+
+/**
+ * Returns the next node after @p start having some data assigned.
+ * @param phase The phase.
+ * @param start The node to start from
+ * @return The next node after start having some data assigned, NULL otherwise
+ */
+ir_node *phase_get_next_node(phase_t *phase, ir_node *start);
+
+/**
+ * Convenience macro to iterate over all nodes of a phase
+ * having some data assigned.
+ */
+#define foreach_phase_irn(phase, irn) \
+       for (irn = phase_get_first_node(phase); irn; irn = phase_get_next_node(phase, irn))
+
 /**
  * Get the name of the phase.
  */
@@ -120,6 +155,31 @@ void phase_reinit_irn_data(phase_t *phase);
  */
 #define phase_get_or_set_irn_data(ph, irn) _phase_get_or_set_irn_data((ph), (irn))
 
+/**
+ * Set the data for an irn.
+ * @param ph The phase.
+ * @param irn The node.
+ * @param data The data.
+ * @return The old data or NULL if there was none.
+ */
+#define phase_set_irn_data(ph, irn, data)  _phase_set_irn_data((ph), (irn), (data))
+
+/**
+ * This is private and only here for performance reasons.
+ */
+static INLINE void _phase_reinit_single_irn_data(phase_t *phase, ir_node *irn)
+{
+       int idx;
+
+       if (! phase->data_init)
+               return;
+
+       idx = get_irn_idx(irn);
+       if (phase->data_ptr[idx])
+               phase->data_init(phase, irn, phase->data_ptr[idx]);
+}
+
+
 /**
  * This is private and just here for performance reasons.
  */
@@ -151,6 +211,21 @@ static INLINE void *_phase_get_irn_data(const phase_t *ph, const ir_node *irn)
        return idx < ph->n_data_ptr ? ph->data_ptr[idx] : NULL;
 }
 
+static INLINE void *_phase_set_irn_data(phase_t *ph, const ir_node *irn, void *data)
+{
+       unsigned idx = get_irn_idx(irn);
+       void *res;
+
+       /* Assure that there's a sufficient amount of slots. */
+       _private_phase_assure_capacity(ph, idx);
+
+       res = ph->data_ptr[idx];
+       ph->data_ptr[idx] = data;
+
+       return res;
+}
+
+
 static INLINE void *_phase_get_or_set_irn_data(phase_t *ph, ir_node *irn)
 {
        unsigned idx = get_irn_idx(irn);
@@ -172,5 +247,4 @@ static INLINE void *_phase_get_or_set_irn_data(phase_t *ph, ir_node *irn)
        return res;
 }
 
-
 #endif /* _FIRM_IR_PHASE_T_H */