From: Christian Würdig Date: Thu, 3 Nov 2005 15:30:23 +0000 (+0000) Subject: added get symconst attr function for Imm nodes X-Git-Url: http://nsz.repo.hu/git/?a=commitdiff_plain;h=fd7b6cd5060bb7acb148bb06757ba0ad1d4c2cc2;p=libfirm added get symconst attr function for Imm nodes better symconst dump support --- diff --git a/ir/be/bearch_firm.c b/ir/be/bearch_firm.c index c10ee9cb1..548a4b549 100644 --- a/ir/be/bearch_firm.c +++ b/ir/be/bearch_firm.c @@ -40,10 +40,11 @@ static ir_op *op_imm; #define CLS_DATAB 0 static int dump_node_Imm(ir_node *n, FILE *F, dump_reason_t reason) { - ir_mode *mode; - int bad = 0; - char buf[1024]; - tarval *tv; + ir_mode *mode; + int bad = 0; + char buf[1024]; + tarval *tv; + imm_attr_t *attr; switch (reason) { case dump_node_opcode_txt: @@ -54,7 +55,7 @@ static int dump_node_Imm(ir_node *n, FILE *F, dump_reason_t reason) { fprintf(F, "%s", buf); } else { - fprintf(F, "imm_SymConst"); + fprintf(F, "immSymC"); } break; @@ -67,15 +68,11 @@ static int dump_node_Imm(ir_node *n, FILE *F, dump_reason_t reason) { break; case dump_node_nodeattr_txt: - break; - - case dump_node_info_txt: { - const char *name = NULL; - ir_node *old_sym = NULL; - imm_attr_t *attr = (imm_attr_t *)get_irn_generic_attr(n); + attr = (imm_attr_t *)get_irn_generic_attr(n); if (is_Imm(n) && attr->tp == imm_SymConst) { - old_sym = attr->data.symconst; + const char *name = NULL; + ir_node *old_sym = attr->data.symconst; switch (get_SymConst_kind(old_sym)) { case symconst_addr_name: @@ -89,11 +86,14 @@ static int dump_node_Imm(ir_node *n, FILE *F, dump_reason_t reason) { default: assert(!"Unsupported SymConst"); } + + fprintf(F, "&%s ", name); } - if (name) - fprintf(F, "imm_SymConst = %s", name); + + break; + + case dump_node_info_txt: break; - } } return bad; @@ -378,6 +378,20 @@ tarval *get_Imm_tv(ir_node *irn) { return NULL; } +/** + * Returns the SymConst from an Imm node or NULL in case of a Const + */ +ir_node *get_Imm_sc(ir_node *irn) { + assert(is_Imm(irn) && "Cannot get SymConst from non-Imm"); + imm_attr_t *attr = (imm_attr_t *)get_irn_generic_attr(irn); + if (attr->tp == imm_SymConst) { + return attr->data.symconst; + } + else + return NULL; +} + + static void prepare_walker(ir_node *irn, void *data) { opcode opc = get_irn_opcode(irn); diff --git a/ir/be/bearch_firm.h b/ir/be/bearch_firm.h index 646779b89..5ff4e9388 100644 --- a/ir/be/bearch_firm.h +++ b/ir/be/bearch_firm.h @@ -21,7 +21,8 @@ extern const arch_irn_handler_t firm_irn_handler; /* TODO UGLY*/ int is_Imm(const ir_node *irn); -tarval *get_Imm_tv(ir_node *irn); +tarval *get_Imm_tv(ir_node *irn); +ir_node *get_Imm_sc(ir_node *irn); typedef struct { enum { imm_Const, imm_SymConst } tp;