Commit 0cf067f0 authored by Matthias Braun's avatar Matthias Braun
Browse files

amd64: Use x86_imm32_t

parent d594010a
......@@ -212,7 +212,7 @@ static void amd64_emit_immediate64(const amd64_imm64_t *const imm)
}
}
static void amd64_emit_immediate32(bool const prefix, amd64_imm32_t const *const imm)
static void amd64_emit_immediate32(bool const prefix, x86_imm32_t const *const imm)
{
if (prefix)
be_emit_char('$');
......@@ -662,8 +662,7 @@ static void emit_amd64_asm_operand(ir_node const *const node, char const modifie
}
case ASM_OP_IMMEDIATE: {
amd64_imm32_t const imm = { op->u.imm32.entity, op->u.imm32.offset };
amd64_emit_immediate32(true, &imm);
amd64_emit_immediate32(true, &op->u.imm32);
return;
}
}
......
......@@ -150,12 +150,6 @@ static void init_amd64_movimm_attributes(ir_node *node,
attr->immediate.offset = offset;
}
static bool imm32s_equal(const amd64_imm32_t *const imm0,
const amd64_imm32_t *const imm1)
{
return imm0->offset == imm1->offset && imm0->entity == imm1->entity;
}
static bool imm64s_equal(const amd64_imm64_t *const imm0,
const amd64_imm64_t *const imm1)
{
......@@ -165,7 +159,7 @@ static bool imm64s_equal(const amd64_imm64_t *const imm0,
static bool amd64_addrs_equal(const amd64_addr_t *const am0,
const amd64_addr_t *const am1)
{
return imm32s_equal(&am0->immediate, &am1->immediate)
return x86_imm32_equal(&am0->immediate, &am1->immediate)
&& am0->base_input == am1->base_input
&& am0->index_input == am1->index_input
&& am0->log_scale == am1->log_scale
......@@ -198,7 +192,7 @@ static int amd64_binop_addr_attrs_equal(const ir_node *a,
return false;
amd64_op_mode_t op_mode = attr_a->base.base.op_mode;
if (op_mode == AMD64_OP_REG_IMM || op_mode == AMD64_OP_ADDR_IMM) {
return imm32s_equal(&attr_a->u.immediate, &attr_b->u.immediate);
return x86_imm32_equal(&attr_a->u.immediate, &attr_b->u.immediate);
} else {
return attr_a->u.reg_input == attr_b->u.reg_input;
}
......
......@@ -66,22 +66,17 @@ enum {
RIP_INPUT = 0xFE, /* can be used as base_input for PIC code */
};
typedef struct {
ir_entity *entity;
int32_t offset;
} amd64_imm32_t;
typedef struct {
ir_entity *entity;
int64_t offset;
} amd64_imm64_t;
typedef struct {
amd64_imm32_t immediate;
uint8_t base_input;
uint8_t index_input;
uint8_t mem_input;
unsigned log_scale : 2; /* 0, 1, 2, 3 (giving scale 1, 2, 4, 8) */
x86_imm32_t immediate;
uint8_t base_input;
uint8_t index_input;
uint8_t mem_input;
unsigned log_scale : 2; /* 0, 1, 2, 3 (giving scale 1, 2, 4, 8) */
ENUMBF(amd64_segment_selector_t) segment : 4;
} amd64_addr_t;
......@@ -100,8 +95,8 @@ typedef struct {
typedef struct {
amd64_addr_attr_t base;
union {
uint8_t reg_input;
amd64_imm32_t immediate;
uint8_t reg_input;
x86_imm32_t immediate;
} u;
} amd64_binop_addr_attr_t;
......
......@@ -454,7 +454,7 @@ typedef struct amd64_args_t {
const arch_register_req_t **reqs;
} amd64_args_t;
static bool match_immediate_32(amd64_imm32_t *imm, const ir_node *op,
static bool match_immediate_32(x86_imm32_t *imm, const ir_node *op,
bool can_match_ip_relative,
bool upper32_dont_care)
{
......@@ -630,16 +630,14 @@ static void perform_address_matching(ir_node *ptr, int *arity,
}
if (maddr.frame_entity != NULL) {
assert(maddr.imm.entity == NULL);
addr->immediate.entity = maddr.frame_entity;
maddr.imm.entity = maddr.frame_entity;
/* not supported yet */
assert(!is_parameter_entity(maddr.frame_entity)
|| get_entity_parameter_number(maddr.frame_entity)
!= IR_VA_START_PARAMETER_NUMBER);
} else {
addr->immediate.entity = maddr.imm.entity;
}
addr->immediate.offset = maddr.imm.offset;
addr->log_scale = maddr.scale;
addr->immediate = maddr.imm;
addr->log_scale = maddr.scale;
}
static void match_binop(amd64_args_t *args, ir_node *block,
......
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