X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fir%2Firphase_t.h;h=a9ccd6af5825a934e9280df5b42ce3ffed5c42a0;hb=8eea5eff43cbc4cc012f87645e738566e8a7d48f;hp=0eca0039c655a3915856fffe67e708cd218aa944;hpb=9984b962ccf1f9964d10ef305d7dc08aaa684479;p=libfirm diff --git a/ir/ir/irphase_t.h b/ir/ir/irphase_t.h index 0eca0039c..a9ccd6af5 100644 --- a/ir/ir/irphase_t.h +++ b/ir/ir/irphase_t.h @@ -120,6 +120,15 @@ 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 just here for performance reasons. */ @@ -145,12 +154,27 @@ static INLINE void _private_phase_enlarge(phase_t *phase, unsigned max_idx) */ #define _private_phase_assure_capacity(ph, max_idx) ((max_idx) >= (ph)->n_data_ptr ? (_private_phase_enlarge((ph), (max_idx)), 1) : 1) -static INLINE void *_phase_get_irn_data(phase_t *ph, const ir_node *irn) +static INLINE void *_phase_get_irn_data(const phase_t *ph, const ir_node *irn) { unsigned idx = get_irn_idx(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);