From bd1dd01279617ceb729eb6464e87310627d39f8c Mon Sep 17 00:00:00 2001 From: Christian Helmer Date: Thu, 19 Jul 2012 18:56:38 +0200 Subject: [PATCH] Added link field for arbitrary data to ir_valueset elements. --- ir/ir/valueset.c | 14 ++++++++++++++ ir/ir/valueset.h | 21 ++++++++++++++++++++- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/ir/ir/valueset.c b/ir/ir/valueset.c index 9dd242d98..c6c2e072a 100644 --- a/ir/ir/valueset.c +++ b/ir/ir/valueset.c @@ -147,6 +147,20 @@ void *ir_valueset_lookup(const ir_valueset_t *valueset, const ir_node *value) return NULL; } +void ir_valueset_set_link(const ir_valueset_t *valueset, const ir_node *value, void *link) +{ + ir_valueset_entry_t *entry = ir_valueset_find_(valueset, value); + assert(entry); + entry->link = link; +} + +void *ir_valueset_get_link(const ir_valueset_t *valueset, const ir_node *value) +{ + ir_valueset_entry_t *entry = ir_valueset_find_(valueset, value); + assert(entry); + return entry->link; +} + void ir_valueset_iterator_init(ir_valueset_iterator_t *iterator, const ir_valueset_t *valueset) { diff --git a/ir/ir/valueset.h b/ir/ir/valueset.h index 8a52d9ff1..084b47a24 100644 --- a/ir/ir/valueset.h +++ b/ir/ir/valueset.h @@ -32,6 +32,7 @@ typedef struct ir_valueset_entry_t { ir_node *value; /**< the represented value */ ir_node *expr; /**< the leader expression for the value in the current set */ + void *link; /**< additional attached information */ list_head list; /**< link field for the list iterator */ } ir_valueset_entry_t; @@ -107,6 +108,24 @@ static inline void ir_valueset_del(ir_valueset_t *valueset) { */ int ir_valueset_insert(ir_valueset_t *valueset, ir_node *value, ir_node *expr); +/** + * Sets link of the element associated with specified value. + * + * @param valueset Pointer to the value set. + * @param value Value of the element. + * @param link Link to be set in element. + */ +void ir_valueset_set_link(const ir_valueset_t *valueset, const ir_node *value, void *link); + +/** + * Get the link of the element associated with specified value. + * + * @param valueset Pointer to the value set. + * @param value Value of the element. + * @returns Link of the element associated to the value. + */ +void *ir_valueset_get_link(const ir_valueset_t *valueset, const ir_node *value); + /** * Inserts a (value, expression) pair into a valueset if the value is not already * known, else replace the expression for the given value. @@ -133,7 +152,7 @@ void *ir_valueset_lookup(const ir_valueset_t *valueset, const ir_node *value); * the value. * * @param valueset Pointer to the value set - * @param value value to remove from the values et + * @param value value to remove from the values set */ void ir_valueset_remove(ir_valueset_t *valueset, const ir_node *value); -- 2.20.1