Commit 60a4728c authored by Manuel Mohr's avatar Manuel Mohr
Browse files

sparc: Remember call type attribute in sparc_Call node.

parent da6c0d72
......@@ -216,6 +216,18 @@ const sparc_asm_attr_t *get_sparc_asm_attr_const(const ir_node *node)
return (const sparc_asm_attr_t*)get_irn_generic_attr_const(node);
}
sparc_call_attr_t *get_sparc_call_attr(ir_node *node)
{
assert(is_sparc_Call(node));
return (sparc_call_attr_t*)get_irn_generic_attr(node);
}
const sparc_call_attr_t *get_sparc_call_attr_const(const ir_node *node)
{
assert(is_sparc_Call(node));
return (const sparc_call_attr_t*)get_irn_generic_attr_const(node);
}
/**
* Initializes the nodes attributes.
*/
......@@ -280,6 +292,12 @@ static void init_sparc_asm_attributes(ir_node *node, ident *text,
attr->operands = operands;
}
static void init_sparc_call_attributes(ir_node *node, ir_type *call_type)
{
sparc_call_attr_t *attr = get_sparc_call_attr(node);
attr->call_type = call_type;
}
/**
* copies sparc attributes of node
*/
......@@ -370,5 +388,15 @@ static int cmp_attr_sparc_asm(const ir_node *a, const ir_node *b)
return attr_a->text != attr_b->text;
}
static int cmp_attr_sparc_call(const ir_node *a, const ir_node *b)
{
if (cmp_attr_sparc(a, b))
return 1;
const sparc_call_attr_t *attr_a = get_sparc_call_attr_const(a);
const sparc_call_attr_t *attr_b = get_sparc_call_attr_const(b);
return attr_a->call_type != attr_b->call_type;
}
/* Include the generated constructor functions */
#include "gen_sparc_new_nodes.c.inl"
......@@ -39,6 +39,9 @@ const sparc_fp_conv_attr_t *get_sparc_fp_conv_attr_const(const ir_node *node);
sparc_asm_attr_t *get_sparc_asm_attr(ir_node *node);
const sparc_asm_attr_t *get_sparc_asm_attr_const(const ir_node *node);
sparc_call_attr_t *get_sparc_call_attr(ir_node *node);
const sparc_call_attr_t *get_sparc_call_attr_const(const ir_node *node);
/* Include the generated headers */
#include "gen_sparc_new_nodes.h"
......
......@@ -11,6 +11,7 @@
#ifndef FIRM_BE_SPARC_SPARC_NODES_ATTR_H
#define FIRM_BE_SPARC_SPARC_NODES_ATTR_H
#include "firm_types.h"
#include "bearch.h"
#include <stdint.h>
......@@ -33,6 +34,15 @@ enum sparc_arch_irn_flags_t {
sparc_arch_irn_flag_has_delay_slot = arch_irn_flags_backend << 3,
};
/**
* attribute for Call instruction
*/
typedef struct sparc_call_attr_t sparc_call_attr_t;
struct sparc_call_attr_t {
sparc_attr_t base;
ir_type *call_type; /**< The call type, copied from the original Call node. */
};
/**
* attribute for FP immediate instruction
*/
......
......@@ -116,11 +116,14 @@ $default_copy_attr = "sparc_copy_attr";
"\tinit_sparc_fp_conv_attributes(res, src_mode, dest_mode);\n",
sparc_asm_attr_t => "\tinit_sparc_attributes(res, irn_flags_, in_reqs, n_res);\n".
"\tinit_sparc_asm_attributes(res, text, operands);",
sparc_call_attr_t => "\tinit_sparc_attributes(res, irn_flags_, in_reqs, n_res);\n".
"\tinit_sparc_call_attributes(res, call_type);",
);
%compare_attr = (
sparc_attr_t => "cmp_attr_sparc",
sparc_asm_attr_t => "cmp_attr_sparc_asm",
sparc_call_attr_t => "cmp_attr_sparc_call",
sparc_fp_attr_t => "cmp_attr_sparc_fp",
sparc_fp_conv_attr_t => "cmp_attr_sparc_fp_conv",
sparc_jmp_cond_attr_t => "cmp_attr_sparc_jmp_cond",
......@@ -540,16 +543,17 @@ Call => {
state => "exc_pinned",
arity => "variable",
out_arity => "variable",
attr_type => "sparc_call_attr_t",
constructors => {
imm => {
attr => "ir_entity *entity, int32_t offset, bool aggregate_return",
custominit => "\tsparc_set_attr_imm(res, entity, offset);".
attr => "ir_type *call_type, ir_entity *entity, int32_t offset, bool aggregate_return",
custominit => "\tsparc_set_attr_imm(res, entity, offset);\n".
"\tif (aggregate_return) arch_add_irn_flags(res, (arch_irn_flags_t)sparc_arch_irn_flag_aggregate_return);",
arity => "variable",
out_arity => "variable",
},
reg => {
attr => "bool aggregate_return",
attr => "ir_type *call_type, bool aggregate_return",
arity => "variable",
out_arity => "variable",
custominit => "\tif (aggregate_return) arch_add_irn_flags(res, (arch_irn_flags_t)sparc_arch_irn_flag_aggregate_return);",
......
......@@ -2152,10 +2152,10 @@ static ir_node *gen_Call(ir_node *node)
ir_node *res;
if (entity != NULL) {
res = new_bd_sparc_Call_imm(dbgi, new_block, in_arity, in, out_arity,
entity, 0, aggregate_return);
type, entity, 0, aggregate_return);
} else {
res = new_bd_sparc_Call_reg(dbgi, new_block, in_arity, in, out_arity,
aggregate_return);
type, aggregate_return);
}
arch_set_irn_register_reqs_in(res, in_req);
......
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