Commit c361c2a3 authored by Christoph Mallon's avatar Christoph Mallon
Browse files

template: Merge Address into Const.

Now the template backend has a node, which can represent an adress with an offset.
parent 332b22a4
...@@ -21,14 +21,16 @@ ...@@ -21,14 +21,16 @@
static void TEMPLATE_emit_immediate(const ir_node *node) static void TEMPLATE_emit_immediate(const ir_node *node)
{ {
const TEMPLATE_attr_t *attr = get_TEMPLATE_attr_const(node); TEMPLATE_attr_t const *const attr = get_TEMPLATE_attr_const(node);
be_emit_irprintf("%T", attr->value); ir_entity *const ent = attr->entity;
} ir_tarval *const val = attr->value;
if (ent) {
static void TEMPLATE_emit_entity(const ir_node *node) be_emit_irprintf("&%s", get_entity_ld_name(ent));
{ if (val)
const TEMPLATE_attr_t *attr = get_TEMPLATE_attr_const(node); be_emit_char('+');
be_emit_irprintf("%s", get_entity_ld_name(attr->entity)); }
if (val)
be_emit_irprintf("%T", val);
} }
static void emit_register(const arch_register_t *reg) static void emit_register(const arch_register_t *reg)
...@@ -92,10 +94,6 @@ void TEMPLATE_emitf(const ir_node *node, const char *format, ...) ...@@ -92,10 +94,6 @@ void TEMPLATE_emitf(const ir_node *node, const char *format, ...)
break; break;
} }
case 'E':
TEMPLATE_emit_entity(node);
break;
case 'I': case 'I':
TEMPLATE_emit_immediate(node); TEMPLATE_emit_immediate(node);
break; break;
......
...@@ -68,16 +68,11 @@ TEMPLATE_attr_t *get_TEMPLATE_attr(ir_node *node) ...@@ -68,16 +68,11 @@ TEMPLATE_attr_t *get_TEMPLATE_attr(ir_node *node)
return (TEMPLATE_attr_t *)get_irn_generic_attr(node); return (TEMPLATE_attr_t *)get_irn_generic_attr(node);
} }
static void set_TEMPLATE_value(ir_node *node, ir_tarval *value) static void set_TEMPLATE_value(ir_node *const node, ir_entity *const entity, ir_tarval *const value)
{
TEMPLATE_attr_t *attr = get_TEMPLATE_attr(node);
attr->value = value;
}
static void set_TEMPLATE_entity(ir_node *node, ir_entity *entity)
{ {
TEMPLATE_attr_t *attr = get_TEMPLATE_attr(node); TEMPLATE_attr_t *attr = get_TEMPLATE_attr(node);
attr->entity = entity; attr->entity = entity;
attr->value = value;
} }
static int TEMPLATE_attrs_equal(const ir_node *a, const ir_node *b) static int TEMPLATE_attrs_equal(const ir_node *a, const ir_node *b)
......
...@@ -166,18 +166,11 @@ Not => { ...@@ -166,18 +166,11 @@ Not => {
Const => { Const => {
template => $constop, template => $constop,
attr => "ir_tarval *value", attr => "ir_entity *entity, ir_tarval *value",
custominit => "set_TEMPLATE_value(res, value);", custominit => "set_TEMPLATE_value(res, entity, value);",
emit => '%D0 = const %I', emit => '%D0 = const %I',
}, },
Address => {
template => $constop,
attr => "ir_entity *entity",
custominit => "set_TEMPLATE_entity(res, entity);",
emit => '%D0 = address of %E',
},
# Control Flow # Control Flow
Jmp => { Jmp => {
......
...@@ -43,6 +43,13 @@ static inline bool mode_needs_gp_reg(ir_mode *mode) ...@@ -43,6 +43,13 @@ static inline bool mode_needs_gp_reg(ir_mode *mode)
return get_mode_arithmetic(mode) == irma_twos_complement; return get_mode_arithmetic(mode) == irma_twos_complement;
} }
static ir_node *transform_const(ir_node *const node, ir_entity *const entity, ir_tarval *const value)
{
ir_node *const block = be_transform_nodes_block(node);
dbg_info *const dbgi = get_irn_dbg_info(node);
return new_bd_TEMPLATE_Const(dbgi, block, entity, value);
}
static ir_node *transform_binop(ir_node *node, new_binop_func new_func) static ir_node *transform_binop(ir_node *node, new_binop_func new_func)
{ {
ir_node *new_block = be_transform_nodes_block(node); ir_node *new_block = be_transform_nodes_block(node);
...@@ -155,18 +162,14 @@ static ir_node *gen_Not(ir_node *node) ...@@ -155,18 +162,14 @@ static ir_node *gen_Not(ir_node *node)
static ir_node *gen_Const(ir_node *node) static ir_node *gen_Const(ir_node *node)
{ {
ir_node *new_block = be_transform_nodes_block(node); ir_tarval *const value = get_Const_tarval(node);
dbg_info *dbgi = get_irn_dbg_info(node); return transform_const(node, NULL, value);
ir_tarval *value = get_Const_tarval(node);
return new_bd_TEMPLATE_Const(dbgi, new_block, value);
} }
static ir_node *gen_Address(ir_node *node) static ir_node *gen_Address(ir_node *node)
{ {
ir_node *new_block = be_transform_nodes_block(node); ir_entity *const entity = get_Address_entity(node);
dbg_info *dbgi = get_irn_dbg_info(node); return transform_const(node, entity, NULL);
ir_entity *entity = get_Address_entity(node);
return new_bd_TEMPLATE_Address(dbgi, new_block, entity);
} }
static ir_node *gen_Load(ir_node *node) static ir_node *gen_Load(ir_node *node)
......
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