From: Michael Beck Date: Tue, 24 Jul 2007 15:40:46 +0000 (+0000) Subject: add symconst_label X-Git-Url: http://nsz.repo.hu/git/?a=commitdiff_plain;h=3bec567ca0e5b670abc47dbe7efd01abc97fe321;p=libfirm add symconst_label [r15312] --- diff --git a/include/libfirm/irnode.h b/include/libfirm/irnode.h index 806f56ed1..90226c6b2 100644 --- a/include/libfirm/irnode.h +++ b/include/libfirm/irnode.h @@ -385,6 +385,12 @@ void set_Block_extbb(ir_node *block, ir_extblk *extblk); ir_node *get_Block_MacroBlock(const ir_node *block); /** Returns the ir_graph this Block belongs to. */ ir_graph *get_Block_irg(const ir_node *block); +/** Returns non-zero if the block has an assigned label. */ +int has_Block_label(const ir_node *block); +/** Returns the label of a Block. */ +ir_label_t get_Block_label(const ir_node *block); +/** Sets a label to a block. */ +void set_Block_label(ir_node *block, ir_label_t label); /** Return the number of Keep alive node. */ int get_End_n_keepalives(ir_node *end); @@ -506,8 +512,9 @@ typedef enum { symconst_symbol is entity *. */ symconst_ofs_ent, /**< The SymConst is the offset of its entity in the entities owner type. */ - symconst_enum_const /**< The SymConst is a enumeration constant of an + symconst_enum_const, /**< The SymConst is a enumeration constant of an enumeration type. */ + symconst_label /**< The SymConst is a label address. */ } symconst_kind; /** Returns non-zero if s symconst kind has a type attribute */ @@ -522,15 +529,19 @@ typedef enum { /** Returns non-zero if s symconst kind has an enum_const attribute */ #define SYMCONST_HAS_ENUM(kind) ((kind) == symconst_enum_const) +/** Returns non-zero if s symconst kind has a label attribute */ +#define SYMCONST_HAS_LABEL(kind) ((kind) == symconst_label) + /** SymConst attribute. * * This union contains the symbolic information represented by the node. */ typedef union symconst_symbol { - ir_type *type_p; /**< the type of a symconst */ - ident *ident_p; /**< the ident of a symconst */ - ir_entity *entity_p; /**< the entity of a symconst */ - ir_enum_const *enum_p; /**< the enumeration constant of a symconst */ + ir_type *type_p; /**< The type of a SymConst. */ + ident *ident_p; /**< The ident of a SymConst. */ + ir_entity *entity_p; /**< The entity of a SymConst. */ + ir_enum_const *enum_p; /**< The enumeration constant of a SymConst. */ + ir_label_t label; /**< The label of a SymConst. */ } symconst_symbol; /** Get the kind of the SymConst. */ @@ -561,6 +572,11 @@ union symconst_symbol get_SymConst_symbol(const ir_node *node); void set_SymConst_symbol(ir_node *node, union symconst_symbol sym); +/** Only to access SymConst of kind symconst_label. Else assertion: */ +ir_label_t get_SymConst_label(const ir_node *node); +void set_SymConst_label(ir_node *node, ir_label_t label); + + /** Access the type of the value represented by the SymConst. * * Example: primitive type int for SymConst size. */ diff --git a/ir/ir/irdump.c b/ir/ir/irdump.c index ca4076a21..a02863ff9 100644 --- a/ir/ir/irdump.c +++ b/ir/ir/irdump.c @@ -707,6 +707,9 @@ int dump_node_opcode(FILE *F, ir_node *n) case symconst_enum_const: fprintf(F, "SymC %s enum", get_enumeration_name(get_SymConst_enum(n))); break; + case symconst_label: + fprintf(F, "SymC %lu label", get_SymConst_label(n)); + break; } } break; diff --git a/ir/ir/irdumptxt.c b/ir/ir/irdumptxt.c index f536b05d0..04da80bf6 100644 --- a/ir/ir/irdumptxt.c +++ b/ir/ir/irdumptxt.c @@ -324,6 +324,10 @@ int dump_irnode_to_file(FILE *F, ir_node *n) { fprintf(F, " kind: enumeration\n"); fprintf(F, " name: %s\n", get_enumeration_name(get_SymConst_enum(n))); break; + case symconst_label: + fprintf(F, " kind: label\n"); + fprintf(F, " label: %lu\n", get_SymConst_label(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 57c661ef2..aa16588a7 100644 --- a/ir/ir/irnode.c +++ b/ir/ir/irnode.c @@ -870,6 +870,22 @@ ir_graph *get_Block_irg(const ir_node *block) { return block->attr.block.irg; } +int has_Block_label(const ir_node *block) { + assert(is_Block(block)); + return block->attr.block.has_label; +} + +ir_label_t get_Block_label(const ir_node *block) { + assert(is_Block(block)); + return block->attr.block.label; +} + +void set_Block_label(ir_node *block, ir_label_t label) { + assert(is_Block(block)); + block->attr.block.has_label = 1; + block->attr.block.label = label; +} + int get_End_n_keepalives(ir_node *end) { assert(end->op == op_End); @@ -1168,6 +1184,16 @@ set_SymConst_symbol(ir_node *node, union symconst_symbol sym) { node->attr.symc.sym = sym; } +ir_label_t get_SymConst_label(const ir_node *node) { + assert(node->op == op_SymConst && SYMCONST_HAS_LABEL(get_SymConst_kind(node))); + return node->attr.symc.sym.label; +} + +void set_SymConst_label(ir_node *node, ir_label_t label) { + assert(node->op == op_SymConst && SYMCONST_HAS_LABEL(get_SymConst_kind(node))); + node->attr.symc.sym.label = label; +} + ir_type * get_SymConst_value_type(ir_node *node) { assert(node->op == op_SymConst);