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

TEMPLATE: Add support for addresses

parent 362addbc
......@@ -36,6 +36,12 @@ static void TEMPLATE_emit_immediate(const ir_node *node)
be_emit_irprintf("%T", attr->value);
}
static void TEMPLATE_emit_entity(const ir_node *node)
{
const TEMPLATE_attr_t *attr = get_TEMPLATE_attr_const(node);
be_emit_irprintf("%s", get_entity_ld_name(attr->entity));
}
static void emit_register(const arch_register_t *reg)
{
be_emit_string(reg->name);
......@@ -97,6 +103,10 @@ void TEMPLATE_emitf(const ir_node *node, const char *format, ...)
break;
}
case 'E':
TEMPLATE_emit_entity(node);
break;
case 'I':
TEMPLATE_emit_immediate(node);
break;
......
......@@ -94,11 +94,18 @@ static void set_TEMPLATE_value(ir_node *node, ir_tarval *value)
attr->value = value;
}
static void set_TEMPLATE_entity(ir_node *node, ir_entity *entity)
{
TEMPLATE_attr_t *attr = get_TEMPLATE_attr(node);
attr->entity = entity;
}
static int TEMPLATE_attrs_equal(const ir_node *a, const ir_node *b)
{
const TEMPLATE_attr_t *attr_a = get_TEMPLATE_attr_const(a);
const TEMPLATE_attr_t *attr_b = get_TEMPLATE_attr_const(b);
return attr_a->value == attr_b->value;
return attr_a->value == attr_b->value
&& attr_a->entity == attr_b->entity;
}
static void TEMPLATE_copy_attr(ir_graph *irg, const ir_node *old_node,
......
......@@ -17,6 +17,7 @@ typedef struct TEMPLATE_attr_t TEMPLATE_attr_t;
struct TEMPLATE_attr_t
{
ir_tarval *value;
ir_entity *entity;
};
#endif
......@@ -182,6 +182,16 @@ Const => {
mode => $mode_gp,
},
Address => {
op_flags => [ "constlike" ],
irn_flags => [ "rematerializable" ],
attr => "ir_entity *entity",
custominit => "set_TEMPLATE_entity(res, entity);",
reg_req => { out => [ "gp" ] },
emit => '%D0 = address of %E',
mode => $mode_gp,
},
# Control Flow
Jmp => {
......
......@@ -165,6 +165,15 @@ static ir_node *gen_Const(ir_node *node)
return new_bd_TEMPLATE_Const(dbgi, new_block, value);
}
static ir_node *gen_Address(ir_node *node)
{
ir_node *block = get_nodes_block(node);
ir_node *new_block = be_transform_node(block);
dbg_info *dbgi = get_irn_dbg_info(node);
ir_entity *entity = get_Address_entity(node);
return new_bd_TEMPLATE_Address(dbgi, new_block, entity);
}
static ir_node *gen_Load(ir_node *node)
{
ir_node *block = get_nodes_block(node);
......@@ -298,25 +307,26 @@ static void TEMPLATE_register_transformers(void)
{
be_start_transform_setup();
be_set_transform_function(op_Add, gen_Add);
be_set_transform_function(op_And, gen_And);
be_set_transform_function(op_Const, gen_Const);
be_set_transform_function(op_Div, gen_Div);
be_set_transform_function(op_Eor, gen_Eor);
be_set_transform_function(op_Jmp, gen_Jmp);
be_set_transform_function(op_Load, gen_Load);
be_set_transform_function(op_Minus, gen_Minus);
be_set_transform_function(op_Mul, gen_Mul);
be_set_transform_function(op_Not, gen_Not);
be_set_transform_function(op_Or, gen_Or);
be_set_transform_function(op_Phi, gen_Phi);
be_set_transform_function(op_Return, gen_Return);
be_set_transform_function(op_Shl, gen_Shl);
be_set_transform_function(op_Shr, gen_Shr);
be_set_transform_function(op_Start, gen_Start);
be_set_transform_function(op_Store, gen_Store);
be_set_transform_function(op_Sub, gen_Sub);
be_set_transform_proj_function(op_Start, gen_Proj_Start);
be_set_transform_function(op_Add, gen_Add);
be_set_transform_function(op_Address, gen_Address);
be_set_transform_function(op_And, gen_And);
be_set_transform_function(op_Const, gen_Const);
be_set_transform_function(op_Div, gen_Div);
be_set_transform_function(op_Eor, gen_Eor);
be_set_transform_function(op_Jmp, gen_Jmp);
be_set_transform_function(op_Load, gen_Load);
be_set_transform_function(op_Minus, gen_Minus);
be_set_transform_function(op_Mul, gen_Mul);
be_set_transform_function(op_Not, gen_Not);
be_set_transform_function(op_Or, gen_Or);
be_set_transform_function(op_Phi, gen_Phi);
be_set_transform_function(op_Return, gen_Return);
be_set_transform_function(op_Shl, gen_Shl);
be_set_transform_function(op_Shr, gen_Shr);
be_set_transform_function(op_Start, gen_Start);
be_set_transform_function(op_Store, gen_Store);
be_set_transform_function(op_Sub, gen_Sub);
be_set_transform_proj_function(op_Proj, gen_Proj_Proj);
}
......
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