Commit 11619991 authored by Michael Beck's avatar Michael Beck
Browse files

register slots are now automatically allocated together with the $ARCH_attribute

No more extra allocation needed, but must be last in the attribute structure
parent fbc27d3a
......@@ -128,7 +128,7 @@ static void dump_reg_req(FILE *F, ir_node *n, const TEMPLATE_register_req_t **re
* @param reason indicates which kind of information should be dumped
* @return 0 on success or != 0 on failure
*/
static int dump_node_TEMPLATE(ir_node *n, FILE *F, dump_reason_t reason) {
static int TEMPLATE_dump_node(ir_node *n, FILE *F, dump_reason_t reason) {
ir_mode *mode = NULL;
int bad = 0;
int i;
......
......@@ -5,19 +5,20 @@
typedef struct _TEMPLATE_register_req_t {
const arch_register_req_t req;
int same_pos; /**<< in case of "should be same" we need to remember the pos to get the irn */
int different_pos; /**<< in case of "should be different" we need to remember the pos to get the irn */
int same_pos; /**< in case of "should be same" we need to remember the pos to get the irn */
int different_pos; /**< in case of "should be different" we need to remember the pos to get the irn */
} TEMPLATE_register_req_t;
typedef struct _TEMPLATE_attr_t {
arch_irn_flags_t flags; /**<< indicating if spillable, rematerializeable ... etc. */
int n_res; /**<< number of results for this node */
arch_irn_flags_t flags; /**< indicating if spillable, rematerializeable ... etc. */
int n_res; /**< number of results for this node */
const TEMPLATE_register_req_t **in_req; /**<< register requirements for arguments */
const TEMPLATE_register_req_t **out_req; /**<< register requirements for results */
const TEMPLATE_register_req_t **in_req; /**< register requirements for arguments */
const TEMPLATE_register_req_t **out_req; /**< register requirements for results */
const arch_register_t **slots; /**<< register slots for assigned registers */
/* must be last, dynamically allocated */
const arch_register_t *slots[1]; /**< register slots for assigned registers */
} TEMPLATE_attr_t;
#endif /* _TEMPLATE_NODES_ATTR_H_ */
......@@ -131,7 +131,6 @@ static void dump_reg_req(FILE *F, ir_node *n, const arm_register_req_t **reqs, i
}
}
/**
* Dumper interface for dumping arm nodes in vcg.
* @param n the node to dump
......@@ -139,7 +138,7 @@ static void dump_reg_req(FILE *F, ir_node *n, const arm_register_req_t **reqs, i
* @param reason indicates which kind of information should be dumped
* @return 0 on success or != 0 on failure
*/
static int dump_node_arm(ir_node *n, FILE *F, dump_reason_t reason) {
static int arm_dump_node(ir_node *n, FILE *F, dump_reason_t reason) {
ir_mode *mode = NULL;
int bad = 0;
int i;
......@@ -506,13 +505,14 @@ void init_arm_attributes(ir_node *node, int flags, const arm_register_req_t ** i
attr->out_req = out_reqs;
attr->n_res = n_res;
attr->flags = flags;
attr->slots = xcalloc(n_res, sizeof(attr->slots[0]));
attr->instr_fl = (ARM_COND_AL << 3) | ARM_SHF_NONE;
attr->value = NULL;
attr->proj_num = -42;
attr->symconst_label = NULL;
attr->n_projs = 0;
attr->default_proj_num = 0;
memset(attr->slots, 0, n_res * sizeof(attr->slots[0]));
}
static int arm_comp_condJmp(arm_attr_t *attr_a, arm_attr_t *attr_b) {
......
......@@ -69,8 +69,6 @@ typedef struct _arm_attr_t {
const arm_register_req_t **in_req; /**< register requirements for arguments */
const arm_register_req_t **out_req; /**< register requirements for results */
const arch_register_t **slots; /**< register slots for assigned registers */
ir_mode *op_mode; /**< operation mode */
unsigned instr_fl; /**< condition code, shift modifier */
tarval *value; /**< immediate */
......@@ -78,6 +76,9 @@ typedef struct _arm_attr_t {
int proj_num;
int n_projs;
long default_proj_num;
/* must be last, dynamically allocated */
const arch_register_t *slots[1]; /**< register slots for assigned registers */
} arm_attr_t;
/**
......
......@@ -153,7 +153,7 @@ static void dump_reg_req(FILE *F, ir_node *n, const ia32_register_req_t **reqs,
* @param reason indicates which kind of information should be dumped
* @return 0 on success or != 0 on failure
*/
static int dump_node_ia32(ir_node *n, FILE *F, dump_reason_t reason) {
static int ia32_dump_node(ir_node *n, FILE *F, dump_reason_t reason) {
ir_mode *mode = NULL;
int bad = 0;
int i, n_res, am_flav, flags;
......@@ -1178,33 +1178,19 @@ const arch_register_t *get_ia32_out_reg(const ir_node *node, int pos) {
return attr->slots[pos];
}
/**
* Allocates num register slots for node.
*/
void alloc_ia32_reg_slots(ir_node *node, int num) {
ia32_attr_t *attr = get_ia32_attr(node);
if (num) {
attr->slots = (const arch_register_t **)NEW_ARR_D(arch_register_t*, get_irg_obstack(get_irn_irg(node)), num);
memset((void *) attr->slots, 0, sizeof(attr->slots[0]) * num);
}
else {
attr->slots = NULL;
}
attr->data.n_res = num;
}
/**
* Initializes the nodes attributes.
*/
void init_ia32_attributes(ir_node *node, arch_irn_flags_t flags, const ia32_register_req_t **in_reqs,
const ia32_register_req_t **out_reqs, int n_res)
{
ia32_attr_t *attr = get_ia32_attr(node);
set_ia32_flags(node, flags);
set_ia32_in_req_all(node, in_reqs);
set_ia32_out_req_all(node, out_reqs);
alloc_ia32_reg_slots(node, n_res);
attr->data.n_res = n_res;
memset(attr->slots, 0, n_res * sizeof(attr->slots[0]));
}
/***************************************************************************************
......@@ -1241,31 +1227,5 @@ int ia32_compare_conv_attr(ia32_attr_t *a, ia32_attr_t *b) {
return !equ;
}
/* copies the ia32 attributes */
static void ia32_copy_attr(const ir_node *old_node, ir_node *new_node) {
ia32_attr_t *attr_old = get_ia32_attr(old_node);
ia32_attr_t *attr_new = get_ia32_attr(new_node);
int n_res = get_ia32_n_res(old_node);
/* copy the attributes */
memcpy(attr_new, attr_old, sizeof(*attr_new));
/* copy the register slots */
attr_new->slots = (const arch_register_t **)NEW_ARR_D(arch_register_t*, get_irg_obstack(get_irn_irg(new_node)), n_res);
memcpy((void *)attr_new->slots, (void *)attr_old->slots, sizeof(attr_new->slots[0]) * n_res);
}
/**
* Registers the ia32_copy_attr function for all ia32 opcodes.
*/
void ia32_register_copy_attr_func(void) {
unsigned i, f = get_ia32_opcode_first(), l = get_ia32_opcode_last();
for (i = f; i < l; i++) {
ir_op *op = get_irp_opcode(i);
op->ops.copy_attr = ia32_copy_attr;
}
}
/* Include the generated constructor functions */
#include "gen_ia32_new_nodes.c.inl"
......@@ -117,8 +117,10 @@ typedef struct _ia32_attr_t {
const ia32_register_req_t **in_req; /**< register requirements for arguments */
const ia32_register_req_t **out_req; /**< register requirements for results */
const arch_register_t **slots; /**< register slots for assigned registers */
const arch_register_t *x87[3]; /**< register slots for x87 register */
/* must be last, dynamic */
const arch_register_t *slots[1]; /**< register slots for assigned registers */
} ia32_attr_t;
#endif /* _IA32_NODES_ATTR_H_ */
......@@ -128,7 +128,7 @@ static void dump_reg_req(FILE *F, ir_node *n, const mips_register_req_t **reqs,
* @param reason indicates which kind of information should be dumped
* @return 0 on success or != 0 on failure
*/
static int dump_node_mips(ir_node *n, FILE *F, dump_reason_t reason) {
static int mips_dump_node(ir_node *n, FILE *F, dump_reason_t reason) {
ir_mode *mode = NULL;
int bad = 0;
int i;
......@@ -395,12 +395,9 @@ void init_mips_attributes(ir_node *node, arch_irn_flags_t flags, const mips_regi
attr->out_req = out_reqs;
attr->n_res = n_res;
if(n_res) {
attr->slots = xcalloc(n_res, sizeof(attr->slots[0]));
} else {
attr->slots = NULL;
}
attr->in_req = in_reqs;
memset(attr->slots, 0, n_res * sizeof(attr->slots[0]));
}
/************************************************************************
......
......@@ -12,24 +12,25 @@ typedef struct _mips_register_req_t {
typedef struct _mips_attr_t {
arch_irn_flags_t flags; /**<< indicating if spillable, rematerializeable ... etc. */
int n_res; /**<< number of results for this node */
arch_irn_flags_t flags; /**< indicating if spillable, rematerializeable ... etc. */
int n_res; /**< number of results for this node */
tarval *tv; /**<< contains the immediate value (if the node has any) */
ident *symconst_id; /**<< contains the ident (for la operations) */
tarval *tv; /**< contains the immediate value (if the node has any) */
ident *symconst_id; /**< contains the ident (for la operations) */
union {
ir_mode *load_store_mode; /**<< contains the mode of a load/store */
ir_mode *original_mode; /**<< contains the original mode of the node */
ir_mode *load_store_mode; /**< contains the mode of a load/store */
ir_mode *original_mode; /**< contains the original mode of the node */
} modes;
entity *stack_entity; /**<< contains the entity on the stack for a load/store mode */
int stack_entity_offset; /**<< contains the real stack offset for the entity */
entity *stack_entity; /**< contains the entity on the stack for a load/store mode */
int stack_entity_offset; /**< contains the real stack offset for the entity */
int switch_default_pn; /**< proj number of default case in switch */
const mips_register_req_t **in_req; /**<< register requirements for arguments */
const mips_register_req_t **out_req; /**<< register requirements for results */
const mips_register_req_t **in_req; /**< register requirements for arguments */
const mips_register_req_t **out_req; /**< register requirements for results */
const arch_register_t **slots; /**<< register slots for assigned registers */
/* must be last, dynamically allocated */
const arch_register_t *slots[1]; /**< register slots for assigned registers */
} mips_attr_t;
#endif /* _mips_NODES_ATTR_H_ */
......@@ -128,7 +128,7 @@ static void dump_reg_req(FILE *F, ir_node *n, const ppc32_register_req_t **reqs,
* @param reason indicates which kind of information should be dumped
* @return 0 on success or != 0 on failure
*/
static int dump_node_ppc32(ir_node *n, FILE *F, dump_reason_t reason) {
static int ppc32_dump_node(ir_node *n, FILE *F, dump_reason_t reason) {
ir_mode *mode = NULL;
int bad = 0;
int i;
......@@ -520,15 +520,12 @@ void init_ppc32_attributes(ir_node *node, int flags,
attr->in_req = in_reqs;
attr->out_req = out_reqs;
attr->n_res = n_res;
attr->slots = NULL;
if (n_res) {
attr->slots = xcalloc(n_res, sizeof(attr->slots[0]));
}
attr->content_type = ppc32_ac_None;
attr->offset_mode = ppc32_ao_Illegal;
attr->data.empty = NULL;
memset(attr->slots, 0, n_res * sizeof(attr->slots[0]));
}
......
......@@ -38,8 +38,6 @@ typedef struct _ppc32_attr_t {
const ppc32_register_req_t **in_req; /**< register requirements for arguments */
const ppc32_register_req_t **out_req; /**< register requirements for results */
const arch_register_t **slots; /**< register slots for assigned registers */
ppc32_attr_content_type content_type;
ppc32_attr_offset_mode offset_mode;
union {
......@@ -52,6 +50,8 @@ typedef struct _ppc32_attr_t {
void* empty;
} data;
/* must be last, dynamically allocated */
const arch_register_t *slots[1]; /**< register slots for assigned registers */
} ppc32_attr_t;
#endif /* _PPC32_NODES_ATTR_H_ */
......@@ -63,6 +63,7 @@ push(@obst_enum_op, "typedef enum _$arch\_opcodes {\n");
foreach my $op (keys(%nodes)) {
my %n = %{ $nodes{"$op"} };
my $tuple = 0;
my $n_res = 0;
# determine arity from in requirements
$arity = 0;
......@@ -243,6 +244,7 @@ foreach my $op (keys(%nodes)) {
if (@out) {
$out_param = $out_req_var.", ".($#out + 1);
$n_res = $#out;
}
else {
$out_param = "NULL, 0";
......@@ -284,8 +286,9 @@ foreach my $op (keys(%nodes)) {
$n{"state"} = "floats" if (! exists($n{"state"}));
$n{"op_flags"} = "N" if (! exists($n{"op_flags"}));
push(@obst_new_irop, "\n memset(&ops, 0, sizeof(ops));\n");
push(@obst_new_irop, " ops.dump_node = dump_node_$arch;\n");
push(@obst_new_irop, " ops.dump_node = $arch\_dump_node;\n");
if ($cmp_attr_func) {
push(@obst_new_irop, " ops.node_cmp_attr = cmp_attr_$op;\n");
......@@ -293,7 +296,7 @@ foreach my $op (keys(%nodes)) {
$n_opcodes++;
$temp = " op_$op = new_ir_op(cur_opcode + iro_$op, \"$op\", op_pin_state_".$n{"state"}.", ".$n{"op_flags"};
$temp .= "|M, ".translate_arity($arity).", 0, sizeof($arch\_attr_t), &ops);\n";
$temp .= "|M, ".translate_arity($arity).", 0, sizeof($arch\_attr_t) + $n_res * sizeof(arch_register_t *), &ops);\n";
push(@obst_new_irop, $temp);
push(@obst_enum_op, " iro_$op,\n");
}
......
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