Commit 4b33cfa7 authored by Matthias Braun's avatar Matthias Braun
Browse files

ia32: Use x86_imm32_t in ia32_immediate_attr_t

parent 5d8baec2
......@@ -207,7 +207,8 @@ static void emit_ia32_immediate(bool const prefix, bool const no_pic_adjust, ir_
static void emit_ia32_immediate_attr(bool const prefix, ir_node const *const node)
{
ia32_immediate_attr_t const *const attr = get_ia32_immediate_attr_const(node);
emit_ia32_immediate(prefix, attr->no_pic_adjust, attr->entity, attr->offset);
emit_ia32_immediate(prefix, attr->no_pic_adjust, attr->imm.entity,
attr->imm.offset);
}
static void ia32_emit_mode_suffix_mode(const ir_mode *mode)
......@@ -563,7 +564,7 @@ emit_I:
if (mod & EMIT_SHIFT_COMMA) {
const ia32_immediate_attr_t *attr
= get_ia32_immediate_attr_const(imm);
if (attr->entity == NULL && attr->offset == 1)
if (attr->imm.entity == NULL && attr->imm.offset == 1)
break;
}
emit_ia32_immediate_attr(!(mod & EMIT_ALTERNATE_AM), imm);
......@@ -1717,7 +1718,7 @@ static void bemit_modrm8(reg_modifier_t high_part, const arch_register_t *reg)
static bool ia32_is_8bit_imm(ia32_immediate_attr_t const *const imm)
{
return !imm->entity && ia32_is_8bit_val(imm->offset);
return !imm->imm.entity && ia32_is_8bit_val(imm->imm.offset);
}
/**
......@@ -1842,15 +1843,16 @@ static void bemit_0f_unop_reg(ir_node const *const node, unsigned char const cod
static void bemit_imm32(ir_node const *const node, bool const relative)
{
const ia32_immediate_attr_t *attr = get_ia32_immediate_attr_const(node);
bemit_entity(attr->entity, attr->offset, relative);
bemit_entity(attr->imm.entity, attr->imm.offset, relative);
}
static void bemit_imm(ia32_immediate_attr_t const *const attr, unsigned const size)
static void bemit_imm(ia32_immediate_attr_t const *const attr,
unsigned const size)
{
switch (size) {
case 8: bemit8(attr->offset); break;
case 16: bemit16(attr->offset); break;
case 32: bemit_entity(attr->entity, attr->offset, false); break;
case 8: bemit8(attr->imm.offset); break;
case 16: bemit16(attr->imm.offset); break;
case 32: bemit_entity(attr->imm.entity, attr->imm.offset, false); break;
}
}
......@@ -2058,7 +2060,7 @@ static void bemit_##op(const ir_node *node) \
arch_register_t const *const out = arch_get_irn_register_out(node, pn_ia32_res); \
ir_node *const count = get_irn_n(node, 1); \
if (is_ia32_Immediate(count)) { \
int offset = get_ia32_immediate_attr_const(count)->offset; \
int32_t offset = get_ia32_immediate_attr_const(count)->imm.offset; \
if (offset == 1) { \
bemit8(0xD1); \
bemit_modru(out, ext); \
......@@ -2081,7 +2083,7 @@ static void bemit_##op##mem(const ir_node *node) \
bemit8(0x66); \
count = get_irn_n(node, 1); \
if (is_ia32_Immediate(count)) { \
int offset = get_ia32_immediate_attr_const(count)->offset; \
int32_t offset = get_ia32_immediate_attr_const(count)->imm.offset; \
if (offset == 1) { \
bemit8(size == 8 ? 0xD0 : 0xD1); \
bemit_mod_am(ext, node); \
......@@ -2111,7 +2113,7 @@ static void bemit_shld(const ir_node *node)
if (is_ia32_Immediate(count)) {
bemit8(0xA4);
bemit_modrr(out, in);
bemit8(get_ia32_immediate_attr_const(count)->offset);
bemit8(get_ia32_immediate_attr_const(count)->imm.offset);
} else {
bemit8(0xA5);
bemit_modrr(out, in);
......@@ -2127,7 +2129,7 @@ static void bemit_shrd(const ir_node *node)
if (is_ia32_Immediate(count)) {
bemit8(0xAC);
bemit_modrr(out, in);
bemit8(get_ia32_immediate_attr_const(count)->offset);
bemit8(get_ia32_immediate_attr_const(count)->imm.offset);
} else {
bemit8(0xAD);
bemit_modrr(out, in);
......@@ -2213,7 +2215,7 @@ static void bemit_bt(ir_node const *const node)
assert(ia32_is_8bit_imm(attr));
bemit8(0xBA);
bemit_modru(lreg, 4);
bemit8(attr->offset);
bemit8(attr->imm.offset);
} else {
bemit8(0xA3);
bemit_modrr(lreg, arch_get_irn_register(right));
......
......@@ -194,7 +194,7 @@ static void ia32_transform_ShlD_to_ShrD_imm(ir_node *const irn)
ir_node *const lcount = get_irn_n(irn, n_ia32_ShlD_count);
ia32_immediate_attr_t const *const attr = get_ia32_immediate_attr_const(lcount);
ir_graph *const irg = get_irn_irg(irn);
ir_node *const count = ia32_create_Immediate(irg, 32 - attr->offset);
ir_node *const count = ia32_create_Immediate(irg, 32 - attr->imm.offset);
dbg_info *const dbgi = get_irn_dbg_info(irn);
ir_node *const block = get_nodes_block(irn);
ir_node *const res = new_bd_ia32_ShrD_imm(dbgi, block, in1, in0, count);
......
......@@ -136,14 +136,16 @@ static void ia32_dump_node(FILE *F, const ir_node *n, dump_reason_t reason)
= get_ia32_immediate_attr_const(n);
fputc(' ', F);
if (attr->entity) {
fputs(get_entity_name(attr->entity), F);
ir_entity *entity = attr->imm.entity;
if (entity) {
fputs(get_entity_name(entity), F);
}
if (attr->offset != 0 || attr->entity == NULL) {
if (attr->offset > 0 && attr->entity != NULL) {
int32_t offset = attr->imm.offset;
if (offset != 0 || entity == NULL) {
if (offset > 0 && entity != NULL) {
fputc('+', F);
}
fprintf(F, "%"PRId32, attr->offset);
fprintf(F, "%"PRId32, offset);
if (attr->no_pic_adjust) {
fputs("(no_pic_adjust)", F);
}
......@@ -778,9 +780,9 @@ static void init_ia32_immediate_attributes(ir_node *res, ir_entity *entity,
#ifndef NDEBUG
attr->attr.attr_type |= IA32_ATTR_ia32_immediate_attr_t;
#endif
attr->entity = entity;
attr->imm.entity = entity;
attr->imm.offset = offset;
attr->no_pic_adjust = no_pic_adjust;
attr->offset = offset;
}
static void init_ia32_call_attributes(ir_node* res, unsigned pop,
......@@ -909,7 +911,7 @@ static unsigned ia32_hash_Immediate(const ir_node *irn)
{
const ia32_immediate_attr_t *a = get_ia32_immediate_attr_const(irn);
return hash_ptr(a->entity) + (unsigned)a->offset;
return hash_ptr(a->imm.entity) + (unsigned)a->imm.offset;
}
/** Compare node attributes for Immediates. */
......@@ -917,9 +919,8 @@ static int ia32_immediate_attrs_equal(const ir_node *a, const ir_node *b)
{
const ia32_immediate_attr_t *attr_a = get_ia32_immediate_attr_const(a);
const ia32_immediate_attr_t *attr_b = get_ia32_immediate_attr_const(b);
return attr_a->entity == attr_b->entity
&& attr_a->no_pic_adjust == attr_b->no_pic_adjust
&& attr_a->offset == attr_b->offset;
return x86_imm32_equal(&attr_a->imm, &attr_b->imm)
&& attr_a->no_pic_adjust == attr_b->no_pic_adjust;
}
/** Compare node attributes for x87 nodes. */
......
......@@ -168,8 +168,7 @@ struct ia32_copyb_attr_t {
typedef struct ia32_immediate_attr_t ia32_immediate_attr_t;
struct ia32_immediate_attr_t {
ia32_attr_t attr; /**< generic attribute */
ir_entity *entity; /**< An entity if any. */
int32_t offset; /**< An offset if any. */
x86_imm32_t imm;
unsigned no_pic_adjust : 1; /**< constant can be relative to EIP */
};
......
......@@ -103,9 +103,9 @@ check_shift_amount:
return produces_no_flag;
const ia32_immediate_attr_t *imm_attr = get_ia32_immediate_attr_const(count);
if (imm_attr->entity != NULL)
if (imm_attr->imm.entity != NULL)
return produces_no_flag;
if ((imm_attr->offset & 0x1f) == 0)
if ((imm_attr->imm.offset & 0x1f) == 0)
return produces_no_flag;
break;
......@@ -133,7 +133,7 @@ static void peephole_ia32_Cmp(ir_node *const node)
return;
ia32_immediate_attr_t const *const imm = get_ia32_immediate_attr_const(right);
if (imm->entity != NULL || imm->offset != 0)
if (imm->imm.entity != NULL || imm->imm.offset != 0)
return;
dbg_info *const dbgi = get_irn_dbg_info(node);
......@@ -276,7 +276,7 @@ static void peephole_ia32_Test(ir_node *node)
ia32_immediate_attr_t const *const imm = get_ia32_immediate_attr_const(right);
/* A test with an entity is rather strange, but better safe than sorry */
if (imm->entity != NULL)
if (imm->imm.entity != NULL)
return;
/*
......@@ -284,7 +284,7 @@ static void peephole_ia32_Test(ir_node *node)
* testl(128, 128) -> SF=0
* testb(128, 128) -> SF=1
*/
unsigned offset = imm->offset;
unsigned offset = imm->imm.offset;
if (get_ia32_op_type(node) == ia32_AddrModeS) {
ia32_attr_t *const attr = get_ia32_attr(node);
ir_graph *const irg = get_irn_irg(node);
......@@ -714,7 +714,7 @@ static void peephole_ia32_Const(ir_node *node)
const ia32_immediate_attr_t *attr = get_ia32_immediate_attr_const(node);
/* try to transform a mov 0, reg to xor reg reg */
if (attr->offset != 0 || attr->entity != NULL)
if (attr->imm.offset != 0 || attr->imm.entity != NULL)
return;
if (ia32_cg_config.use_mov_0)
return;
......
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