From 136719e8b6d00cc17b1c7837d1587f14b3abc31d Mon Sep 17 00:00:00 2001 From: Michael Beck Date: Wed, 2 Apr 2008 13:51:39 +0000 Subject: [PATCH] add is_Global() and get_Global_ent() [r19064] --- include/libfirm/irnode.h | 6 ++++++ ir/ir/irnode.c | 19 +++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/include/libfirm/irnode.h b/include/libfirm/irnode.h index 41468b3d8..6349de0ff 100644 --- a/include/libfirm/irnode.h +++ b/include/libfirm/irnode.h @@ -1413,6 +1413,12 @@ cond_jmp_predicate get_Cond_jmp_pred(const ir_node *cond); /** Sets a new conditional jump prediction. */ void set_Cond_jmp_pred(ir_node *cond, cond_jmp_predicate pred); +/** Checks whether a node represents a global address. */ +int is_Global(const ir_node *node); + +/* Returns the entity of a global address. */ +ir_entity *get_Global_ent(const ir_node *node); + /** * Access custom node data. * The data must have been registered with diff --git a/ir/ir/irnode.c b/ir/ir/irnode.c index f969269d4..b3ebc104b 100644 --- a/ir/ir/irnode.c +++ b/ir/ir/irnode.c @@ -3084,7 +3084,26 @@ dbg_info *(get_irn_dbg_info)(const ir_node *n) { return _get_irn_dbg_info(n); } +/* checks whether a node represents a global address */ +int is_Global(const ir_node *node) { + ir_node *ptr; + if (is_SymConst_addr_ent(node)) + return 1; + if (! is_Sel(node)) + return 0; + + ptr = get_Sel_ptr(node); + return is_globals_pointer(ptr) != NULL; +} + +/* returns the entity of a global address */ +ir_entity *get_Global_ent(const ir_node *node) { + if (is_SymConst(node)) + return get_SymConst_entity(node); + else + return get_Sel_entity(node); +} #ifdef DEBUG_libfirm void dump_irn(const ir_node *n) { -- 2.20.1