Commit d594010a authored by Matthias Braun's avatar Matthias Braun
Browse files

ia32: Use x86_imm32_t in x86_address_t

parent bb65f2b2
......@@ -613,7 +613,7 @@ static void perform_address_matching(ir_node *ptr, int *arity,
addr->base_input = base_input;
in[base_input] = be_transform_node(maddr.base);
} else {
ir_entity *entity = maddr.entity;
ir_entity *entity = maddr.imm.entity;
if (entity != NULL
&& need_relative_addressing(entity) != REFERENCE_DIRECT) {
addr->base_input = RIP_INPUT;
......@@ -629,16 +629,16 @@ static void perform_address_matching(ir_node *ptr, int *arity,
addr->index_input = NO_INPUT;
}
if (maddr.frame_entity != NULL) {
assert(maddr.entity == NULL);
assert(maddr.imm.entity == NULL);
addr->immediate.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.entity;
addr->immediate.entity = maddr.imm.entity;
}
addr->immediate.offset = maddr.offset;
addr->immediate.offset = maddr.imm.offset;
addr->log_scale = maddr.scale;
}
......
......@@ -800,7 +800,7 @@ static void build_address(ia32_address_mode_t *am, ir_node *node,
addr->base = get_global_base(irg);
addr->index = noreg_GP;
addr->mem = nomem;
addr->entity = entity;
addr->imm.entity = entity;
addr->tls_segment = false;
addr->use_frame = false;
am->ls_mode = get_type_mode(get_entity_type(entity));
......@@ -828,8 +828,8 @@ static void build_address(ia32_address_mode_t *am, ir_node *node,
static void set_address(ir_node *node, const x86_address_t *addr)
{
set_ia32_am_scale(node, addr->scale);
set_ia32_am_ent(node, addr->entity);
set_ia32_am_offs_int(node, addr->offset);
set_ia32_am_ent(node, addr->imm.entity);
set_ia32_am_offs_int(node, addr->imm.offset);
set_ia32_am_tls_segment(node, addr->tls_segment);
set_ia32_frame_ent(node, addr->frame_entity);
if (addr->use_frame)
......@@ -1362,7 +1362,7 @@ static ir_node *create_lea_from_address(dbg_info *dbgi, ir_node *block,
* around... */
if (addr->tls_segment) {
ir_node *tls_base = new_bd_ia32_LdTls(NULL, block);
assert(addr->entity != NULL);
assert(addr->imm.entity != NULL);
if (base == noreg_GP)
base = tls_base;
else
......@@ -1382,7 +1382,7 @@ static ir_node *create_lea_from_address(dbg_info *dbgi, ir_node *block,
*/
static bool am_has_immediates(const x86_address_t *addr)
{
return addr->offset != 0 || addr->entity != NULL
return addr->imm.offset != 0 || addr->imm.entity != NULL
|| addr->frame_entity || addr->use_frame;
}
......@@ -1527,7 +1527,8 @@ static ir_node *gen_Add(ir_node *node)
/* a constant? */
if (addr.base == NULL && addr.index == NULL) {
new_node = new_bd_ia32_Const(dbgi, new_block, addr.entity, 0, addr.offset);
new_node = new_bd_ia32_Const(dbgi, new_block, addr.imm.entity, 0,
addr.imm.offset);
SET_IA32_ORIG_NODE(new_node, node);
return new_node;
}
......@@ -2729,7 +2730,7 @@ static ir_node *gen_float_const_Store(ir_node *node, ir_node *cns)
size -= delta;
ofs += delta;
addr.offset += delta;
addr.imm.offset += delta;
} while (size != 0);
if (i > 1) {
......@@ -3534,7 +3535,9 @@ static ir_node *gen_Mux(ir_node *node)
}
ia32_address_mode_t am;
am.addr.entity = ia32_create_const_array(mux_false, mux_true, &new_mode);
am.addr.imm.entity
= ia32_create_const_array(mux_false, mux_true, &new_mode);
am.addr.imm.offset = 0;
unsigned scale;
if (new_mode == ia32_mode_float32) {
......@@ -3554,7 +3557,6 @@ static ir_node *gen_Mux(ir_node *node)
am.addr.base = get_global_base(irg);
am.addr.index = new_node;
am.addr.mem = nomem;
am.addr.offset = 0;
am.addr.scale = scale;
am.addr.use_frame = 0;
am.addr.tls_segment = false;
......@@ -3884,7 +3886,7 @@ static ir_node *gen_x87_gp_to_fp(ir_node *node)
addr->index, addr->mem);
ir_node *new_node = new_r_Proj(fild, mode_fp, pn_ia32_fild_res);
set_am_attributes(fild, &am);
if (addr->use_frame && addr->entity == NULL
if (addr->use_frame && addr->imm.entity == NULL
&& get_mode_arithmetic(am.ls_mode) != irma_twos_complement)
force_int_stackent(fild, am.ls_mode);
......@@ -4519,9 +4521,9 @@ static ir_node *gen_ia32_l_LLtoFloat(ir_node *node)
am.addr.base = get_global_base(irg);
am.addr.index = new_bd_ia32_Shr(dbgi, block, new_val_high, count);
am.addr.mem = nomem;
am.addr.offset = 0;
am.addr.imm.entity = ia32_gen_fp_known_const(ia32_ULLBIAS);
am.addr.imm.offset = 0;
am.addr.scale = 2;
am.addr.entity = ia32_gen_fp_known_const(ia32_ULLBIAS);
am.addr.tls_segment = false;
am.addr.use_frame = 0;
am.addr.frame_entity = NULL;
......@@ -4949,10 +4951,10 @@ static ir_node *gen_Call(ir_node *node)
} else {
/* Value transmitted on callframe. */
x86_address_t const store_addr = {
.base = callframe,
.index = noreg_GP,
.mem = nomem,
.offset = param->offset,
.base = callframe,
.index = noreg_GP,
.mem = nomem,
.imm.offset = param->offset,
};
ir_node *const store = create_store(dbgi, block, value, &store_addr);
set_irn_pinned(store, op_pin_state_floats);
......
......@@ -54,10 +54,10 @@ static bool eat_imm(x86_address_t *const addr, ir_node const *const node)
case iro_Address:
/* The first Address of a DAG can be folded into an immediate. */
if (addr->entity)
if (addr->imm.entity)
return false;
addr->entity = get_Address_entity(node);
if (is_tls_entity(addr->entity))
addr->imm.entity = get_Address_entity(node);
if (is_tls_entity(addr->imm.entity))
addr->tls_segment = true;
return true;
......@@ -66,7 +66,7 @@ static bool eat_imm(x86_address_t *const addr, ir_node const *const node)
ir_tarval *const tv = get_Const_tarval(node);
if (!tarval_possible(tv))
return false;
addr->offset += get_tarval_long(tv);
addr->imm.offset += get_tarval_long(tv);
return true;
}
......
......@@ -15,19 +15,19 @@
#include <stdbool.h>
#include <stdint.h>
#include "irtypes.h"
#include "x86_imm.h"
/**
* The address mode data: Used to construct (memory) address modes.
*/
typedef struct x86_address_t {
ir_node *base; /**< value for base register (if any) */
ir_node *index; /**< value for index register (if any). */
ir_node *mem; /**< value for memory input (if any). */
int32_t offset; /**< An integer offset. */
ir_node *base; /**< value for base register (if any) */
ir_node *index; /**< value for index register (if any). */
ir_node *mem; /**< value for memory input (if any). */
x86_imm32_t imm;
unsigned scale : 8; /**< An integer scale. {0,1,2,3} */
bool use_frame : 1; /**< Set, if the frame is accessed */
bool tls_segment : 1; /**< Set if AM is relative to TLS */
ir_entity *entity; /**< The accessed entity if any. */
ir_entity *frame_entity; /**< The accessed frame entity if any. */
} x86_address_t;
......
Supports Markdown
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