Commit 9eaaf697 authored by Matthias Braun's avatar Matthias Braun
Browse files

ia32: Introduce x86_addr_t and use it instead of am_imm for now

parent 08126f79
......@@ -134,7 +134,7 @@ static void ia32_set_frame_entity(ir_node *node, ir_entity *entity,
attr->am_imm = (x86_imm32_t) {
.kind = X86_IMM_FRAMEENT,
.entity = entity,
.offset = attr->am_imm.offset,
.offset = attr->addr.immediate.offset,
};
assert(get_ia32_frame_use(node) != IA32_FRAME_USE_NONE);
......@@ -478,8 +478,8 @@ ir_node *ia32_turn_back_am(ir_node *node)
set_irn_n(node, n_ia32_base, noreg);
set_irn_n(node, n_ia32_index, noreg);
ia32_attr_t *const attr = get_ia32_attr(node);
attr->am_imm = (x86_imm32_t) { .kind = X86_IMM_VALUE, .offset = 0 };
attr->frame_use = IA32_FRAME_USE_NONE;
attr->addr.immediate = (x86_imm32_t) { .kind = X86_IMM_VALUE, .offset = 0 };
attr->frame_use = IA32_FRAME_USE_NONE;
set_ia32_am_scale(node, 0);
/* rewire mem-proj */
......@@ -910,7 +910,7 @@ static void ia32_collect_frame_entity_nodes(ir_node *node, void *data)
assert(get_ia32_frame_use(node) == IA32_FRAME_USE_NONE);
return;
}
if (attr->am_imm.entity != NULL)
if (attr->addr.immediate.entity != NULL)
return;
ir_type const *type;
......
......@@ -372,16 +372,16 @@ static void ia32_emit_am(ir_node const *const node)
/* emit offset */
ia32_attr_t const *const attr = get_ia32_attr_const(node);
int32_t const offset = attr->am_imm.offset;
ir_entity const *const entity = attr->am_imm.entity;
int32_t const offset = attr->addr.immediate.offset;
ir_entity const *const entity = attr->addr.immediate.entity;
if (entity) {
assert(attr->am_imm.kind != X86_IMM_VALUE);
assert(attr->addr.immediate.kind != X86_IMM_VALUE);
const ia32_attr_t *attr = get_ia32_attr_const(node);
ia32_emit_relocation(&attr->am_imm);
ia32_emit_relocation(&attr->addr.immediate);
if (offset != 0)
be_emit_irprintf("%+"PRId32, offset);
} else if (offset != 0 || (!base && !idx)) {
assert(attr->am_imm.kind == X86_IMM_VALUE);
assert(attr->addr.immediate.kind == X86_IMM_VALUE);
/* also handle special case if nothing is set */
be_emit_irprintf("%"PRId32, offset);
}
......
......@@ -147,8 +147,8 @@ void ia32_dump_node(FILE *F, const ir_node *n, dump_reason_t reason)
ia32_dump_immediate(F, attr->imm.entity, attr->imm.offset);
} else {
ia32_attr_t const *const attr = get_ia32_attr_const(n);
int32_t const offset = attr->am_imm.offset;
ir_entity *const entity = attr->am_imm.entity;
int32_t const offset = attr->addr.immediate.offset;
ir_entity *const entity = attr->addr.immediate.entity;
if (entity || offset != 0) {
fputs(" [", F);
ia32_dump_immediate(F, entity, offset);
......@@ -206,7 +206,7 @@ void ia32_dump_node(FILE *F, const ir_node *n, dump_reason_t reason)
const ia32_attr_t *attr = get_ia32_attr_const(n);
fputs("AM immediate = ", F);
x86_dump_imm32(&attr->am_imm, F);
x86_dump_imm32(&attr->addr.immediate, F);
fputc('\n', F);
/* dump AM scale */
......@@ -249,7 +249,7 @@ void ia32_dump_node(FILE *F, const ir_node *n, dump_reason_t reason)
fprintf(F, "frame use = %s\n", get_frame_use_str(n));
if (attr->old_frame_ent != NULL) {
fprintf(F, "frame entity = ");
ir_entity *entity = attr->am_imm.entity;
ir_entity *entity = attr->addr.immediate.entity;
if (entity != NULL) {
ir_fprintf(F, "%+F", entity);
} else {
......@@ -415,31 +415,31 @@ void set_ia32_am_support(ir_node *node, ia32_am_type_t arity)
int32_t get_ia32_am_offs_int(const ir_node *node)
{
const ia32_attr_t *attr = get_ia32_attr_const(node);
return attr->am_imm.offset;
return attr->addr.immediate.offset;
}
void set_ia32_am_offs_int(ir_node *node, int32_t offset)
{
ia32_attr_t *attr = get_ia32_attr(node);
attr->am_imm.offset = offset;
attr->addr.immediate.offset = offset;
}
void add_ia32_am_offs_int(ir_node *node, int32_t offset)
{
ia32_attr_t *attr = get_ia32_attr(node);
attr->am_imm.offset += offset;
attr->addr.immediate.offset += offset;
}
ir_entity *get_ia32_am_ent(const ir_node *node)
{
const ia32_attr_t *attr = get_ia32_attr_const(node);
return attr->am_imm.entity;
return attr->addr.immediate.entity;
}
void set_ia32_am_ent(ir_node *node, ir_entity *entity)
{
ia32_attr_t *attr = get_ia32_attr(node);
attr->am_imm.entity = entity;
attr->addr.immediate.entity = entity;
}
void set_ia32_am_tls_segment(ir_node *node, bool value)
......@@ -471,8 +471,8 @@ void ia32_copy_am_attrs(ir_node *to, const ir_node *from)
{
ia32_attr_t const *const from_attr = get_ia32_attr_const(from);
ia32_attr_t *const to_attr = get_ia32_attr(to);
to_attr->am_imm = from_attr->am_imm;
to_attr->frame_use = from_attr->frame_use;
to_attr->addr.immediate = from_attr->addr.immediate;
to_attr->frame_use = from_attr->frame_use;
set_ia32_ls_mode(to, get_ia32_ls_mode(from));
set_ia32_am_scale(to, get_ia32_am_scale(from));
......@@ -718,7 +718,7 @@ static int ia32_attrs_equal_(const ia32_attr_t *a, const ia32_attr_t *b)
return a->tp == b->tp
&& a->am_scale == b->am_scale
&& x86_imm32_equal(&a->am_imm, &b->am_imm)
&& x86_imm32_equal(&a->addr.immediate, &b->addr.immediate)
&& a->ls_mode == b->ls_mode
&& a->frame_use == b->frame_use
&& a->has_except_label == b->has_except_label
......
......@@ -16,6 +16,7 @@
#include "x86_asm.h"
#include "x86_cc.h"
#include "x86_x87.h"
#include "x86_address_mode.h"
typedef enum {
ia32_Normal,
......@@ -84,6 +85,16 @@ typedef enum ia32_frame_use_t {
IA32_FRAME_USE_AUTO,
} ia32_frame_use_t;
typedef struct {
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 : 3;
ENUMBF(x86_addr_variant_t) variant : 3;
} x86_addr_t;
/**
* The generic ia32 attributes. Every node has them.
*/
......@@ -106,13 +117,13 @@ struct ia32_attr_t {
unsigned is_spill:1;
unsigned is_remat:1;
x86_imm32_t am_imm; /**< imm32 for address mode */
ir_mode *ls_mode; /**< Load/Store mode: This is the mode of the
value that is manipulated by this node. */
ir_label_t exc_label; /**< the exception label iff this instruction can throw an exception */
x86_addr_t addr; /**< address mode specification */
#ifndef NDEBUG
const char *orig_node; /**< holds the name of the original ir node */
ir_entity const *old_frame_ent; /**< frame entity referenced */
......
......@@ -333,7 +333,7 @@ static ir_entity *create_float_const_entity(ir_tarval *tv, ident *name)
static void set_am_const_entity(ir_node *node, ir_entity *entity)
{
ia32_attr_t *const attr = get_ia32_attr(node);
attr->am_imm = (x86_imm32_t) {
attr->addr.immediate = (x86_imm32_t) {
.kind = lconst_imm_kind,
.entity = entity,
};
......@@ -477,7 +477,7 @@ static ir_node *gen_Address(ir_node *node)
ir_node *tls_base = new_bd_ia32_LdTls(NULL, block);
ir_node *lea = new_bd_ia32_Lea(dbgi, block, tls_base, noreg_GP);
ia32_attr_t *const attr = get_ia32_attr(lea);
attr->am_imm = imm;
attr->addr.immediate = imm;
cnst = lea;
} else {
cnst = new_bd_ia32_Const(dbgi, block, &imm);
......@@ -882,7 +882,7 @@ static void build_address(ia32_address_mode_t *am, ir_node *node,
static void set_address(ir_node *node, const x86_address_t *addr)
{
ia32_attr_t *const attr = get_ia32_attr(node);
attr->am_imm = addr->imm;
attr->addr.immediate = addr->imm;
set_ia32_am_scale(node, addr->scale);
set_ia32_am_tls_segment(node, addr->tls_segment);
if (addr->imm.kind == X86_IMM_FRAMEENT)
......
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