From 5d194aeb1895dc34cc9088068e1528a6a67bd696 Mon Sep 17 00:00:00 2001 From: Michael Beck Date: Mon, 31 Jul 2006 09:12:07 +0000 Subject: [PATCH] symconst_enum_const support added [r8074] --- ir/ir/ircons.c | 3 ++- ir/ir/irdump.c | 55 +++++++++++++++++++++++++++-------------------- ir/ir/irdumptxt.c | 6 +++++- ir/ir/irnode.c | 14 +++++++++++- ir/ir/irnode.h | 23 ++++++++++++++------ ir/ir/irprintf.c | 5 ++++- 6 files changed, 73 insertions(+), 33 deletions(-) diff --git a/ir/ir/ircons.c b/ir/ir/ircons.c index a96404f38..a2a935178 100644 --- a/ir/ir/ircons.c +++ b/ir/ir/ircons.c @@ -3083,7 +3083,8 @@ set_store(ir_node *store) { ir_node *load, *pload, *pred, *in[2]; - assert(get_irg_phase_state (current_ir_graph) == phase_building); + assert(get_irg_phase_state(current_ir_graph) == phase_building); + assert(get_irn_mode(store) == mode_M && "storing non-memory node"); if (get_opt_auto_create_sync()) { /* handle non-volatile Load nodes by automatically creating Sync's */ diff --git a/ir/ir/irdump.c b/ir/ir/irdump.c index af5b16e43..d11ba5dd4 100644 --- a/ir/ir/irdump.c +++ b/ir/ir/irdump.c @@ -6,7 +6,7 @@ * Modified by: Goetz Lindenmaier, Hubert Schmidt * Created: * CVS-ID: $Id$ - * Copyright: (c) 1998-2003 Universit�t Karlsruhe + * Copyright: (c) 1998-2006 Universit�t Karlsruhe * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE. */ #ifdef HAVE_CONFIG_H @@ -671,21 +671,26 @@ int dump_node_opcode(FILE *F, ir_node *n) } break; case iro_SymConst: { - if (get_SymConst_kind(n) == symconst_addr_name) { + switch (get_SymConst_kind(n)) { + case symconst_addr_name: /* don't use get_SymConst_ptr_info as it mangles the name. */ - fprintf (F, "SymC %s", get_id_str(get_SymConst_name(n))); - } else if (get_SymConst_kind(n) == symconst_addr_ent) { - assert(get_SymConst_entity(n)); - assert(is_entity(get_SymConst_entity(n))); - fprintf (F, "SymC &%s", get_entity_name(get_SymConst_entity(n))); - } else { - assert(get_kind(get_SymConst_type(n)) == k_type); - assert(get_type_ident(get_SymConst_type(n))); - fprintf (F, "SymC %s ", get_type_name_ex(get_SymConst_type(n), &bad)); - if (get_SymConst_kind(n) == symconst_type_tag) - fprintf (F, "tag"); - else - fprintf (F, "size"); + fprintf(F, "SymC %s", get_id_str(get_SymConst_name(n))); + break; + case symconst_addr_ent: + fprintf(F, "SymC &%s", get_entity_name(get_SymConst_entity(n))); + break; + case symconst_type_tag: + fprintf(F, "SymC %s tag", get_type_name_ex(get_SymConst_type(n), &bad)); + break; + case symconst_type_size: + fprintf(F, "SymC %s size", get_type_name_ex(get_SymConst_type(n), &bad)); + break; + case symconst_type_align: + fprintf(F, "SymC %s align", get_type_name_ex(get_SymConst_type(n), &bad)); + break; + case symconst_enum_const: + fprintf(F, "SymC %s enum", get_enumeration_name(get_SymConst_enum(n))); + break; } } break; @@ -1842,16 +1847,20 @@ void dump_entity_node(FILE *F, entity *ent, int color) static void dump_enum_item(FILE *F, ir_type *tp, int pos) { char buf[1024]; - ident *id = get_enumeration_nameid(tp, pos); - tarval *tv = get_enumeration_enum(tp, pos); + ir_enum_const *ec = get_enumeration_const(tp, pos); + ident *id = get_enumeration_nameid(ec); + tarval *tv = get_enumeration_value(ec); - tarval_snprintf(buf, sizeof(buf), tv); - fprintf (F, "node: {title: \""); + if (tv) + tarval_snprintf(buf, sizeof(buf), tv); + else + strncpy(buf, "", sizeof(buf)); + fprintf(F, "node: {title: \""); PRINT_ITEMID(tp, pos); fprintf(F, "\""); - fprintf (F, DEFAULT_ENUM_ITEM_ATTRIBUTE); - fprintf (F, "label: "); - fprintf (F, "\"enum item %s\" " ENUM_ITEM_NODE_ATTR, get_id_str(id)); - fprintf (F, "\n info1: \"value: %s\"}\n", buf); + fprintf(F, DEFAULT_ENUM_ITEM_ATTRIBUTE); + fprintf(F, "label: "); + fprintf(F, "\"enum item %s\" " ENUM_ITEM_NODE_ATTR, get_id_str(id)); + fprintf(F, "\n info1: \"value: %s\"}\n", buf); } /* dumps a type or entity and it's edges. */ diff --git a/ir/ir/irdumptxt.c b/ir/ir/irdumptxt.c index 5d793eeee..568739791 100644 --- a/ir/ir/irdumptxt.c +++ b/ir/ir/irdumptxt.c @@ -6,7 +6,7 @@ * Modified by: Goetz Lindenmaier, Hubert Schmidt * Created: * CVS-ID: $Id$ - * Copyright: (c) 1998-2003 Universität Karlsruhe + * Copyright: (c) 1998-2006 Universität Karlsruhe * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE. */ #ifdef HAVE_CONFIG_H @@ -302,6 +302,10 @@ int dump_irnode_to_file(FILE *F, ir_node *n) { fprintf(F, " type: "); dump_type_to_file(F, get_SymConst_type(n), dump_verbosity_onlynames); break; + case symconst_enum_const: + fprintf(F, " kind: enumeration\n"); + fprintf(F, " name: %s\n", get_enumeration_name(get_SymConst_enum(n))); + break; } fprintf(F, " type of value: %s \n", get_type_name_ex(get_SymConst_value_type(n), &bad)); } break; diff --git a/ir/ir/irnode.c b/ir/ir/irnode.c index 1e92ea1a8..f28a89b43 100644 --- a/ir/ir/irnode.c +++ b/ir/ir/irnode.c @@ -6,7 +6,7 @@ * Modified by: Goetz Lindenmaier, Michael Beck * Created: * CVS-ID: $Id$ - * Copyright: (c) 1998-2003 Universität Karlsruhe + * Copyright: (c) 1998-2006 Universität Karlsruhe * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE. */ @@ -1045,6 +1045,18 @@ void set_SymConst_entity (ir_node *node, entity *ent) { node->attr.symc.sym.entity_p = ent; } +ir_enum_const *get_SymConst_enum (ir_node *node) { + assert ( (node->op == op_SymConst) + && (get_SymConst_kind (node) == symconst_enum_const)); + return node->attr.symc.sym.enum_p; +} + +void set_SymConst_enum (ir_node *node, ir_enum_const *ec) { + assert ( (node->op == op_SymConst) + && (get_SymConst_kind(node) == symconst_enum_const)); + node->attr.symc.sym.enum_p = ec; +} + union symconst_symbol get_SymConst_symbol (ir_node *node) { assert (node->op == op_SymConst); diff --git a/ir/ir/irnode.h b/ir/ir/irnode.h index e732c1b00..4b7767f9f 100644 --- a/ir/ir/irnode.h +++ b/ir/ir/irnode.h @@ -6,7 +6,7 @@ * Modified by: Goetz Lindenmaier, Michael Beck * Created: * CVS-ID: $Id$ - * Copyright: (c) 1998-2003 Universität Karlsruhe + * Copyright: (c) 1998-2006 Universität Karlsruhe * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE. */ #ifndef _FIRM_IR_IRNODE_H_ @@ -451,9 +451,11 @@ typedef enum { symconst_addr_name, /**< The SymConst is a symbolic pointer to be filled in by the linker. The pointer is represented by a string. symconst_symbol is ident *. */ - symconst_addr_ent /**< The SymConst is a symbolic pointer to be filled in + symconst_addr_ent, /**< The SymConst is a symbolic pointer to be filled in by the linker. The pointer is represented by an entity. symconst_symbol is entity *. */ + symconst_enum_const /**< The SymConst is a enumeration constant of an + enumeration type. */ } symconst_kind; /** Returns non-zero if s symconst kind has a type attribute */ @@ -465,13 +467,18 @@ typedef enum { /** Returns non-zero if s symconst kind has an entity attribute */ #define SYMCONST_HAS_ENT(kind) ((kind) == symconst_addr_ent) +/** Returns non-zero if s symconst kind has an enum_const attribute */ +#define SYMCONST_HAS_ENUM(kind) ((kind) == symconst_enum_const) + /** SymConst attribute. * - * This union contains the symbolic information represented by the node. */ + * This union contains the symbolic information represented by the node. + */ typedef union symconst_symbol { - ir_type *type_p; - ident *ident_p; - entity *entity_p; + ir_type *type_p; + ident *ident_p; + entity *entity_p; + ir_enum_const *enum_p; } symconst_symbol; /** Get the kind of the SymConst. */ @@ -491,6 +498,10 @@ void set_SymConst_name (ir_node *node, ident *name); entity *get_SymConst_entity (ir_node *node); void set_SymConst_entity (ir_node *node, entity *ent); +/** Only to access SymConst of kind symconst_enum_const. Else assertion: */ +ir_enum_const *get_SymConst_enum (ir_node *node); +void set_SymConst_enum (ir_node *node, ir_enum_const *ec); + /** Sets both: type and ptrinfo. Needed to treat the node independent of its semantics. Does a memcpy for the memory sym points to. */ /* write 'union': firmjni then does not create a method... */ diff --git a/ir/ir/irprintf.c b/ir/ir/irprintf.c index 5ebfd1204..94663761b 100644 --- a/ir/ir/irprintf.c +++ b/ir/ir/irprintf.c @@ -5,7 +5,7 @@ * Author: Sebastian Hack * Created: 29.11.2004 * CVS-ID: $Id$ - * Copyright: (c) 1998-2004 Universität Karlsruhe + * Copyright: (c) 1998-2006 Universität Karlsruhe * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE. */ @@ -340,6 +340,9 @@ static void firm_emit(char *buf, int buflen, char conversion, case symconst_addr_ent: /* entity name */ snprintf(tv_buf, sizeof(tv_buf), "<%s>", get_entity_name(get_SymConst_entity(X))); break; + case symconst_enum_const: /* enumeration constant */ + snprintf(tv_buf, sizeof(tv_buf), "", get_enumeration_name(get_SymConst_enum(X))); + break; default: tv_buf[0] = '\0'; } -- 2.20.1