From 8e0743d545ddaf0f7d01f0f3ff3ebb1fd97063fe Mon Sep 17 00:00:00 2001 From: Sebastian Hack Date: Thu, 2 Dec 2004 15:50:57 +0000 Subject: [PATCH] Constified a little bit. [r4539] --- ir/ir/irnode.c | 10 +++++----- ir/ir/irnode.h | 19 ++++++++++++++----- ir/ir/irnode_t.h | 7 ++++--- 3 files changed, 23 insertions(+), 13 deletions(-) diff --git a/ir/ir/irnode.c b/ir/ir/irnode.c index 78cd9c0a6..d13d3140b 100644 --- a/ir/ir/irnode.c +++ b/ir/ir/irnode.c @@ -238,19 +238,19 @@ set_irn_in (ir_node *node, int arity, ir_node **in) { } ir_node * -(get_irn_intra_n)(ir_node *node, int n) { +(get_irn_intra_n)(const ir_node *node, int n) { return __get_irn_intra_n (node, n); } ir_node * -(get_irn_inter_n)(ir_node *node, int n) { +(get_irn_inter_n)(const ir_node *node, int n) { return __get_irn_inter_n (node, n); } -ir_node *(*__get_irn_n)(ir_node *node, int n) = __get_irn_intra_n; +ir_node *(*__get_irn_n)(const ir_node *node, int n) = __get_irn_intra_n; ir_node * -(get_irn_n)(ir_node *node, int n) { +(get_irn_n)(const ir_node *node, int n) { return __get_irn_n(node, n); } @@ -527,7 +527,7 @@ get_irn_except_attr (ir_node *node) /* this works for all except Block */ ir_node * -get_nodes_block (ir_node *node) { +get_nodes_block (const ir_node *node) { assert (!(node->op == op_Block)); return get_irn_n(node, -1); } diff --git a/ir/ir/irnode.h b/ir/ir/irnode.h index 0696e6642..04ee9d6e8 100644 --- a/ir/ir/irnode.h +++ b/ir/ir/irnode.h @@ -133,9 +133,9 @@ void set_irn_in (ir_node *node, int arity, * Get the n-th predecessor of a node. * This function removes Id predecessors. */ -ir_node *get_irn_n (ir_node *node, int n); -ir_node *get_irn_intra_n (ir_node *node, int n); -ir_node *get_irn_inter_n (ir_node *node, int n); +ir_node *get_irn_n (const ir_node *node, int n); +ir_node *get_irn_intra_n (const ir_node *node, int n); +ir_node *get_irn_inter_n (const ir_node *node, int n); /** Replace the n-th predecessor of a node with a new one. */ void set_irn_n (ir_node *node, int n, ir_node *in); @@ -223,7 +223,7 @@ new_ir_node (dbg_info *db, * To express the difference to access routines that work for all * nodes we use infix "nodes" and do not name this function * get_irn_block. */ -ir_node *get_nodes_block (ir_node *node); +ir_node *get_nodes_block (const ir_node *node); /** Sets the Block of a node. */ void set_nodes_block (ir_node *node, ir_node *block); @@ -904,7 +904,16 @@ int is_forking_op(const ir_node *node); * @return A pointer of type @p type. */ #define get_irn_data(node,type,off) \ - (assert(off > 0 && "Invalid node data offset"), (type *) ((char *) (node) - (off))) + (assert(off > 0 && "Invalid node data offset"), (type *) ((char *) (node) - (off))) + +/** + * Get the pointer to the node some custom data belongs to. + * @param data The pointer to the custom data. + * @param off The number as returned by register_additional_node_data(). + * @return A pointer to the ir node the custom data belongs to. + */ +#define get_irn_data_base(data,off) \ + (assert(off > 0 && "Invalid node data offset"), (ir_node *) ((char *) (data) + (off))) /** * Request additional data to be allocated with an ir node. diff --git a/ir/ir/irnode_t.h b/ir/ir/irnode_t.h index cf7f4f592..57e35e26e 100644 --- a/ir/ir/irnode_t.h +++ b/ir/ir/irnode_t.h @@ -41,6 +41,7 @@ #include "entity_t.h" #include "type_t.h" + /** ir node attributes **/ /** Block attributes */ @@ -339,7 +340,7 @@ extern int (*__get_irn_arity)(const ir_node *node); * Intern version for libFirm. */ static INLINE ir_node * -__get_irn_intra_n (ir_node *node, int n) { +__get_irn_intra_n (const ir_node *node, int n) { assert(node); assert(-1 <= n && n < __get_irn_intra_arity(node)); return (node->in[n + 1] = skip_Id(node->in[n + 1])); @@ -349,7 +350,7 @@ __get_irn_intra_n (ir_node *node, int n) { * Intern version for libFirm. */ static INLINE ir_node* -__get_irn_inter_n (ir_node *node, int n) { +__get_irn_inter_n (const ir_node *node, int n) { assert(node); assert(-1 <= n && n < __get_irn_inter_arity(node)); /* handle Filter and Block specially */ @@ -371,7 +372,7 @@ __get_irn_inter_n (ir_node *node, int n) { * If it is a block, the entry -1 is NULL. * Intern version for libFirm. */ -extern ir_node *(*__get_irn_n)(ir_node *node, int n); +extern ir_node *(*__get_irn_n)(const ir_node *node, int n); /** * Gets the mode of a node. -- 2.20.1