Commit 76f731ed authored by Matthias Braun's avatar Matthias Braun
Browse files

Remove got_entry entity type

This is not really a new entity type but merely a relocation type.
Handle it with a x86_immediate_kind.
parent a924aadd
......@@ -200,21 +200,14 @@ typedef enum amd64_emit_mod_t {
} amd64_emit_mod_t;
ENUM_BITSET(amd64_emit_mod_t)
static void amd64_emit_immediate64(const amd64_imm64_t *const imm)
static void emit_relocation_no_offset(x86_immediate_kind_t const kind,
ir_entity const *const entity)
{
ir_entity *entity = imm->entity;
int64_t offset = imm->offset;
switch (imm->kind) {
be_gas_emit_entity(entity);
switch (kind) {
case X86_IMM_ADDR: return;
case X86_IMM_GOTPCREL: be_emit_cstring("@GOTPCREL"); return;
case X86_IMM_VALUE:
assert(entity == NULL);
be_emit_irprintf("0x%" PRIX64, offset);
return;
case X86_IMM_ADDR:
assert(entity != NULL);
be_gas_emit_entity(entity);
if (offset != 0)
be_emit_irprintf("%+" PRId64, offset);
return;
case X86_IMM_TLS_IE:
case X86_IMM_TLS_LE:
case X86_IMM_PICBASE_REL:
......@@ -224,30 +217,31 @@ static void amd64_emit_immediate64(const amd64_imm64_t *const imm)
panic("unexpected or invalid immediate kind");
}
static void amd64_emit_immediate32(bool const prefix, x86_imm32_t const *const imm)
static void amd64_emit_immediate64(const amd64_imm64_t *const imm)
{
if (imm->kind == X86_IMM_VALUE) {
assert(imm->entity == NULL);
be_emit_irprintf("0x%" PRIX64, imm->offset);
return;
}
emit_relocation_no_offset(imm->kind, imm->entity);
if (imm->offset != 0)
be_emit_irprintf("%+" PRId64, imm->offset);
}
static void amd64_emit_immediate32(bool const prefix,
x86_imm32_t const *const imm)
{
if (prefix)
be_emit_char('$');
ir_entity *entity = imm->entity;
int32_t offset = imm->offset;
switch (imm->kind) {
case X86_IMM_VALUE:
assert(entity == NULL);
be_emit_irprintf("%" PRId32, offset);
return;
case X86_IMM_ADDR:
assert(entity != NULL);
be_gas_emit_entity(entity);
if (offset != 0)
be_emit_irprintf("%+" PRId32, offset);
if (imm->kind == X86_IMM_VALUE) {
assert(imm->entity == NULL);
be_emit_irprintf("%" PRId32, imm->offset);
return;
case X86_IMM_TLS_IE:
case X86_IMM_TLS_LE:
case X86_IMM_PICBASE_REL:
case X86_IMM_FRAMEOFFSET:
break;
}
panic("unexpected or invalid immediate kind");
emit_relocation_no_offset(imm->kind, imm->entity);
if (imm->offset != 0)
be_emit_irprintf("%+" PRId32, imm->offset);
}
static bool is_fp_relative(const ir_entity *entity)
......
......@@ -421,11 +421,19 @@ static ir_node *gen_Address(ir_node *node)
addr.mem_input = NO_INPUT;
if (mode == REFERENCE_IP_RELATIVE) {
addr.immediate.entity = entity;
addr.immediate = (x86_imm32_t) {
/* TODO: create an ip-relative kind? (even though it looks the same
* in the assembler) */
.kind = X86_IMM_ADDR,
.entity = entity,
};
return new_bd_amd64_lea(dbgi, block, 0, NULL, INSN_MODE_64, addr);
} else {
assert(mode == REFERENCE_GOT);
addr.immediate.entity = new_got_entry_entity(entity);
addr.immediate = (x86_imm32_t) {
.kind = X86_IMM_GOTPCREL,
.entity = entity,
};
ir_node *load = new_bd_amd64_mov_gp(dbgi, block, 0, NULL, INSN_MODE_64,
AMD64_OP_ADDR, addr);
return new_r_Proj(load, mode_gp, pn_amd64_mov_gp_res);
......
......@@ -1230,11 +1230,6 @@ void be_gas_emit_entity(const ir_entity *entity)
ir_label_t label = get_entity_label(entity);
be_emit_irprintf("%s_%lu", be_gas_get_private_prefix(), label);
return;
} else if (entity->entity_kind == IR_ENTITY_GOTENTRY) {
ir_entity *referenced = entity->attr.got.referenced;
be_gas_emit_entity(referenced);
be_emit_cstring("@GOTPCREL");
return;
}
char const *const name = get_entity_ld_name(entity);
......@@ -1313,9 +1308,6 @@ static void emit_global(be_main_env_t const *const main_env,
/* Block labels are already emitted in the code. */
if (kind == IR_ENTITY_LABEL)
return;
/* GOT entries are created automatically */
if (kind == IR_ENTITY_GOTENTRY)
return;
/* we already emitted all methods with graphs in other functions like
* be_gas_emit_function_prolog(). All others don't need to be emitted. */
......
......@@ -193,6 +193,7 @@ static void ia32_emit_relocation(x86_imm32_t const *const imm)
be_emit_string(pic_base_label);
return;
case X86_IMM_FRAMEOFFSET:
case X86_IMM_GOTPCREL:
case X86_IMM_VALUE:
break;
}
......
......@@ -24,6 +24,7 @@ typedef enum x86_immediate_kind_t {
X86_IMM_TLS_IE, /**< thread local storage, initial exec */
X86_IMM_TLS_LE, /**< thread local storage, load exec */
X86_IMM_FRAMEOFFSET, /**< offset to entity on stackframe */
X86_IMM_GOTPCREL, /**< global offset table entry PIC relative (elf64) */
} x86_immediate_kind_t;
typedef struct x86_imm32_t {
......
......@@ -704,7 +704,6 @@ static void write_entity(write_env_t *env, ir_entity *ent)
fputc('\t', env->file);
switch ((ir_entity_kind)ent->entity_kind) {
case IR_ENTITY_ALIAS: write_symbol(env, "alias"); break;
case IR_ENTITY_GOTENTRY: write_symbol(env, "gotentry"); break;
case IR_ENTITY_NORMAL: write_symbol(env, "entity"); break;
case IR_ENTITY_METHOD: write_symbol(env, "method"); break;
case IR_ENTITY_LABEL: write_symbol(env, "label"); break;
......@@ -751,9 +750,6 @@ static void write_entity(write_env_t *env, ir_entity *ent)
case IR_ENTITY_ALIAS:
write_entity_ref(env, get_entity_alias(ent));
break;
case IR_ENTITY_GOTENTRY:
write_entity_ref(env, ent->attr.got.referenced);
break;
case IR_ENTITY_NORMAL: {
ir_initializer_t const *const init = get_entity_initializer(ent);
......@@ -1797,11 +1793,6 @@ static void read_entity(read_env_t *env, ir_entity_kind kind)
entity = new_alias_entity(owner, name, aliased, type);
break;
}
case IR_ENTITY_GOTENTRY: {
ir_entity *referenced = read_entity_ref(env);
entity = new_got_entry_entity(referenced);
break;
}
case IR_ENTITY_NORMAL:
entity = new_entity(owner, name, type);
if (ld_name != NULL)
......@@ -1894,9 +1885,6 @@ static void read_typegraph(read_env_t *env)
case kw_alias:
read_entity(env, IR_ENTITY_ALIAS);
break;
case kw_gotentry:
read_entity(env, IR_ENTITY_GOTENTRY);
break;
case kw_label:
read_entity(env, IR_ENTITY_LABEL);
break;
......
......@@ -100,18 +100,6 @@ ir_entity *new_label_entity(ir_label_t label)
return res;
}
ir_entity *new_got_entry_entity(ir_entity *referenced)
{
ir_type *reftype = get_entity_type(referenced);
ir_type *pointer = new_type_pointer(reftype);
ir_type *global_type = get_glob_type();
ir_entity *res = intern_new_entity(global_type, IR_ENTITY_GOTENTRY, NULL,
pointer);
res->attr.got.referenced = referenced;
hook_new_entity(res);
return res;
}
ir_entity *new_alias_entity(ir_type *owner, ident *name, ir_entity *aliased,
ir_type *type)
{
......@@ -307,7 +295,6 @@ void set_entity_type(ir_entity *ent, ir_type *type)
case IR_ENTITY_ALIAS:
case IR_ENTITY_PARAMETER:
case IR_ENTITY_UNKNOWN:
case IR_ENTITY_GOTENTRY:
case IR_ENTITY_COMPOUND_MEMBER:
break;
}
......@@ -907,7 +894,6 @@ int entity_has_definition(const ir_entity *entity)
case IR_ENTITY_PARAMETER:
case IR_ENTITY_UNKNOWN:
case IR_ENTITY_COMPOUND_MEMBER:
case IR_ENTITY_GOTENTRY:
return false;
}
panic("invalid entity kind");
......
......@@ -150,10 +150,6 @@ typedef struct alias_ent_attr {
ir_entity *aliased;
} alias_ent_attr;
typedef struct got_ent_attr {
ir_entity *referenced;
} got_ent_attr;
typedef enum ir_entity_kind {
IR_ENTITY_ALIAS,
IR_ENTITY_COMPOUND_MEMBER,
......@@ -162,7 +158,6 @@ typedef enum ir_entity_kind {
IR_ENTITY_NORMAL,
IR_ENTITY_PARAMETER,
IR_ENTITY_UNKNOWN,
IR_ENTITY_GOTENTRY,
} ir_entity_kind;
/**
......@@ -212,8 +207,6 @@ struct ir_entity {
parameter_ent_attr parameter;
/** alias attributes */
alias_ent_attr alias;
/** got entry attributes */
got_ent_attr got;
/** additional properties shared by method+alias entities */
mtp_additional_properties properties;
} attr; /**< type specific attributes */
......@@ -228,12 +221,6 @@ void ir_init_entity(ir_prog *irp);
*/
ir_entity *new_label_entity(ir_label_t label);
/**
* Create an entity representing an entry in the global offset table used for
* position independent code (PIC) code.
*/
ir_entity *new_got_entry_entity(ir_entity *reference);
void set_entity_irg(ir_entity *ent, ir_graph *irg);
/* ----------------------- inline functions ------------------------ */
......
......@@ -312,7 +312,6 @@ int check_entity(const ir_entity *entity)
break;
case IR_ENTITY_UNKNOWN:
case IR_ENTITY_GOTENTRY:
break;
}
......
......@@ -114,7 +114,6 @@ static void do_type_walk(ir_type *const tp, ir_entity *const ent,
case IR_ENTITY_PARAMETER:
case IR_ENTITY_LABEL:
case IR_ENTITY_COMPOUND_MEMBER:
case IR_ENTITY_GOTENTRY:
break;
}
} else {
......
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