Commit 5fc82d98 authored by Matthias Braun's avatar Matthias Braun
Browse files

Introduce IR_LINKAGE_NO_IDENTITY

This flag can be set on entities where the actual address isn't
known/compared against other address. This also fixes a bug where we
used the mach-o csrings section for global char arrays which need
distinct addresses.
parent f8b38c80
......@@ -162,6 +162,12 @@ typedef enum ir_linkage {
* "extern inline".
*/
IR_LINKAGE_NO_CODEGEN = 1 << 5,
/**
* The entity does not need to have an address that is different from other
* entities. This is property is necessary when the entity should be merged
* with other entities with the same content.
*/
IR_LINKAGE_NO_IDENTITY = 1 << 6,
} ir_linkage;
ENUM_BITSET(ir_linkage)
......
......@@ -349,7 +349,7 @@ ir_entity *create_float_const_entity(ir_tarval *const tv)
entity = new_entity(glob, id_unique("C%u"), type);
set_entity_visibility(entity, ir_visibility_private);
add_entity_linkage(entity, IR_LINKAGE_CONSTANT);
add_entity_linkage(entity, IR_LINKAGE_CONSTANT | IR_LINKAGE_NO_IDENTITY);
ir_initializer_t *initializer = create_initializer_tarval(tv);
set_entity_initializer(entity, initializer);
......@@ -361,7 +361,7 @@ ir_entity *create_float_const_entity(ir_tarval *const tv)
void init_lconst_addr(amd64_addr_t *addr, ir_entity *entity)
{
assert(entity_has_definition(entity));
assert(get_entity_linkage(entity) == IR_LINKAGE_CONSTANT);
assert(get_entity_linkage(entity) & IR_LINKAGE_CONSTANT);
assert(get_entity_visibility(entity) == ir_visibility_private);
x86_immediate_kind_t kind = be_options.pic ? X86_IMM_PCREL : X86_IMM_ADDR;
*addr = (amd64_addr_t) {
......@@ -1531,7 +1531,7 @@ static ir_node *gen_Switch(ir_node *const node)
ir_entity *const entity
= new_entity(irp->dummy_owner, id_unique("TBL%u"), utype);
set_entity_visibility(entity, ir_visibility_private);
add_entity_linkage(entity, IR_LINKAGE_CONSTANT);
add_entity_linkage(entity, IR_LINKAGE_CONSTANT | IR_LINKAGE_NO_IDENTITY);
arch_register_req_t const **in_reqs;
amd64_op_mode_t op_mode;
......
......@@ -468,6 +468,7 @@ static be_gas_section_t determine_basic_section(const ir_entity *entity)
if (get_entity_linkage(entity) & IR_LINKAGE_CONSTANT) {
/* mach-o is the only one with a cstring section */
if (be_gas_object_file_format == OBJECT_FILE_FORMAT_MACH_O
&& (get_entity_linkage(entity) & IR_LINKAGE_NO_IDENTITY)
&& entity_is_string_const(entity, true))
return GAS_SECTION_CSTRING;
......
......@@ -45,7 +45,7 @@ static ir_entity *create_ent(ir_entity **const dst, int value, const char *name)
ir_entity *const ent = new_entity(glob, id, type);
set_entity_ld_ident(ent, id);
set_entity_visibility(ent, ir_visibility_local);
add_entity_linkage(ent, IR_LINKAGE_CONSTANT);
add_entity_linkage(ent, IR_LINKAGE_CONSTANT | IR_LINKAGE_NO_IDENTITY);
ir_graph *const cnst_irg = get_const_code_irg();
ir_node *const cnst = new_r_Const_long(cnst_irg, mode, value);
......
......@@ -320,7 +320,7 @@ static ir_entity *create_float_const_entity(ir_tarval *tv, ident *name)
res = new_entity(get_glob_type(), name, tp);
set_entity_ld_ident(res, get_entity_ident(res));
set_entity_visibility(res, ir_visibility_private);
add_entity_linkage(res, IR_LINKAGE_CONSTANT);
add_entity_linkage(res, IR_LINKAGE_CONSTANT | IR_LINKAGE_NO_IDENTITY);
ir_initializer_t *const initializer = create_initializer_tarval(tv);
set_entity_initializer(res, initializer);
......@@ -583,7 +583,7 @@ ir_entity *ia32_gen_fp_known_const(ia32_known_const_t const kct)
set_entity_ld_ident(ent, name);
set_entity_visibility(ent, ir_visibility_private);
add_entity_linkage(ent, IR_LINKAGE_CONSTANT);
add_entity_linkage(ent, IR_LINKAGE_CONSTANT|IR_LINKAGE_NO_IDENTITY);
ir_initializer_t *initializer = create_initializer_compound(2);
set_initializer_compound_value(initializer, 0,
......@@ -2943,7 +2943,7 @@ static ir_node *gen_Switch(ir_node *node)
ir_entity *const entity
= new_entity(irp->dummy_owner, id_unique("TBL%u"), utype);
set_entity_visibility(entity, ir_visibility_private);
add_entity_linkage(entity, IR_LINKAGE_CONSTANT);
add_entity_linkage(entity, IR_LINKAGE_CONSTANT | IR_LINKAGE_NO_IDENTITY);
ir_graph *irg = get_irn_irg(node);
const ir_switch_table *table = get_Switch_table(node);
......@@ -3354,7 +3354,7 @@ static ir_entity *ia32_create_const_array(ir_node *c0, ir_node *c1,
set_entity_ld_ident(ent, get_entity_ident(ent));
set_entity_visibility(ent, ir_visibility_private);
add_entity_linkage(ent, IR_LINKAGE_CONSTANT);
add_entity_linkage(ent, IR_LINKAGE_CONSTANT | IR_LINKAGE_NO_IDENTITY);
ir_initializer_t *initializer = create_initializer_compound(2);
......
......@@ -1181,7 +1181,7 @@ static ir_entity *create_float_const_entity(ir_tarval *const tv)
ir_type *glob = get_glob_type();
entity = new_entity(glob, id_unique("C%u"), type);
set_entity_visibility(entity, ir_visibility_private);
add_entity_linkage(entity, IR_LINKAGE_CONSTANT);
add_entity_linkage(entity, IR_LINKAGE_CONSTANT | IR_LINKAGE_NO_IDENTITY);
ir_initializer_t *initializer = create_initializer_tarval(tv);
set_entity_initializer(entity, initializer);
......@@ -1257,7 +1257,7 @@ static ir_node *gen_Switch(ir_node *node)
ir_entity *const entity
= new_entity(irp->dummy_owner, id_unique("TBL%u"), utype);
set_entity_visibility(entity, ir_visibility_private);
add_entity_linkage(entity, IR_LINKAGE_CONSTANT);
add_entity_linkage(entity, IR_LINKAGE_CONSTANT | IR_LINKAGE_NO_IDENTITY);
/* construct base address */
ir_node *table_address = make_address(dbgi, new_block, entity, 0);
......
......@@ -171,7 +171,7 @@ struct ir_entity {
ir_type *owner; /**< The compound type (e.g. class type) this
entity belongs to. */
ENUMBF(ir_entity_kind) entity_kind:3; /**< entity kind */
ENUMBF(ir_linkage) linkage:6; /**< Linkage type */
ENUMBF(ir_linkage) linkage:7; /**< Linkage type */
ENUMBF(ir_volatility) volatility:1; /**< Volatility of entity content.*/
ENUMBF(ir_align) aligned:1; /**< Alignment of entity content. */
ENUMBF(ir_entity_usage) usage:4; /**< Usage type of entity */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment