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

added constraints to ASM nodes

[r14215]
parent e68b365a
......@@ -837,21 +837,20 @@ new_bd_Pin(dbg_info *db, ir_node *block, ir_node *node) {
} /* new_bd_Pin */
static ir_node *
new_bd_ASM(dbg_info *db, ir_node *block, ir_node *store, int arity, ir_node *inputs[], ident *asm_text) {
ir_node *res, **in;
new_bd_ASM(dbg_info *db, ir_node *block, int arity, ir_node *in[], ir_asm_constraint *inputs,
int n_outs, ir_asm_constraint *outputs, ident *asm_text) {
ir_node *res;
ir_graph *irg = current_ir_graph;
int i;
NEW_ARR_A(ir_node *, in, arity + 1);
in[0] = store;
for (i = 0; i < arity; ++i)
in[i + 1] = inputs[i];
res = new_ir_node(db, irg, block, op_ASM, mode_T, arity + 1, in);
res = new_ir_node(db, irg, block, op_ASM, mode_T, arity, in);
res->attr.assem.pin_state = op_pin_state_pinned;
res->attr.assem.inputs = NEW_ARR_D(ir_asm_constraint, irg->obst, arity);
res->attr.assem.outputs = NEW_ARR_D(ir_asm_constraint, irg->obst, n_outs);
res->attr.assem.asm_text = asm_text;
memcpy(res->attr.assem.inputs, inputs, sizeof(inputs[0]) * arity);
memcpy(res->attr.assem.outputs, outputs, sizeof(outputs[0]) * n_outs);
res = optimize_node(res);
IRN_VRFY_IRG(res, irg);
return res;
......@@ -1439,13 +1438,14 @@ ir_node *new_rd_Pin(dbg_info *db, ir_graph *irg, ir_node *block, ir_node *node)
return res;
} /* new_rd_Pin */
ir_node *new_rd_ASM(dbg_info *db, ir_graph *irg, ir_node *block, ir_node *store,
int arity, ir_node *inputs[], ident *asm_text) {
ir_node *new_rd_ASM(dbg_info *db, ir_graph *irg, ir_node *block,
int arity, ir_node *in[], ir_asm_constraint *inputs,
int n_outs, ir_asm_constraint *outputs, ident *asm_text) {
ir_node *res;
ir_graph *rem = current_ir_graph;
current_ir_graph = irg;
res = new_bd_ASM(db, block, store, arity, inputs, asm_text);
res = new_bd_ASM(db, block, arity, in, inputs, n_outs, outputs, asm_text);
current_ir_graph = rem;
return res;
......@@ -1685,9 +1685,10 @@ ir_node *new_r_Bound(ir_graph *irg, ir_node *block,
ir_node *new_r_Pin(ir_graph *irg, ir_node *block, ir_node *node) {
return new_rd_Pin(NULL, irg, block, node);
}
ir_node *new_r_ASM(ir_graph *irg, ir_node *block, ir_node *store,
int arity, ir_node *inputs[], ident *asm_text) {
return new_rd_ASM(NULL, irg, block, store, arity, inputs, asm_text);
ir_node *new_r_ASM(ir_graph *irg, ir_node *block,
int arity, ir_node *in[], ir_asm_constraint *inputs,
int n_outs, ir_asm_constraint *outputs, ident *asm_text) {
return new_rd_ASM(NULL, irg, block, arity, in, inputs, n_outs, outputs, asm_text);
}
/** ********************/
......@@ -2924,8 +2925,9 @@ new_d_Pin(dbg_info *db, ir_node *node) {
} /* new_d_Pin */
ir_node *
new_d_ASM(dbg_info *db, ir_node *store, int arity, ir_node *inputs[], ident *asm_text) {
return new_bd_ASM(db, current_ir_graph->current_block, store, arity, inputs, asm_text);
new_d_ASM(dbg_info *db, int arity, ir_node *in[], ir_asm_constraint *inputs,
int n_outs, ir_asm_constraint *outputs, ident *asm_text) {
return new_bd_ASM(db, current_ir_graph->current_block, arity, in, inputs, n_outs, outputs, asm_text);
} /* new_d_ASM */
/* ********************************************************************* */
......@@ -3342,6 +3344,7 @@ ir_node *new_Bound(ir_node *store, ir_node *idx, ir_node *lower, ir_node *upper)
ir_node *new_Pin(ir_node *node) {
return new_d_Pin(NULL, node);
}
ir_node *new_ASM(ir_node *store, int arity, ir_node *inputs[], ident *asm_text) {
return new_d_ASM(NULL, store, arity, inputs, asm_text);
ir_node *new_ASM(int arity, ir_node *in[], ir_asm_constraint *inputs,
int n_outs, ir_asm_constraint *outputs, ident *asm_text) {
return new_d_ASM(NULL, arity, in, inputs, n_outs, outputs, asm_text);
}
......@@ -1996,13 +1996,16 @@ ir_node *new_rd_Pin(dbg_info *db, ir_graph *irg, ir_node *block, ir_node *node);
* @param *db A pointer for debug information.
* @param *irg The ir graph the node belong to.
* @param *block The block the node belong to.
* @param *store The memory input for the node
* @param arity The number of data inputs to the node.
* @param *inputs The array of length arity of data inputs.
* @param *in The array of length arity of data inputs.
* @param *inputs The array of length arity of input constraints.
* @param n_outs The number of data outputs to the node.
* @param *outputs The array of length n_outs of output constraints.
* @param *asm_text The assembler text.
*/
ir_node *new_rd_ASM(dbg_info *db, ir_graph *irg, ir_node *block, ir_node *store,
int arity, ir_node *inputs[], ident *asm_text);
ir_node *new_rd_ASM(dbg_info *db, ir_graph *irg, ir_node *block,
int arity, ir_node *in[], ir_asm_constraint *inputs,
int n_outs, ir_asm_constraint *outputs, ident *asm_text);
/*-------------------------------------------------------------------------*/
/* The raw interface without debug support */
......@@ -2783,13 +2786,16 @@ ir_node *new_r_Pin(ir_graph *irg, ir_node *block, ir_node *node);
*
* @param *irg The ir graph the node belong to.
* @param *block The block the node belong to.
* @param *store The memory input for the node
* @param arity The number of data inputs to the node.
* @param *inputs The array of length arity of data inputs.
* @param *in The array of length arity of data inputs.
* @param *inputs The array of length arity of input constraints.
* @param n_outs The number of data outputs to the node.
* @param *outputs The array of length n_outs of output constraints.
* @param *asm_text The assembler text.
*/
ir_node *new_r_ASM(ir_graph *irg, ir_node *block, ir_node *store,
int arity, ir_node *inputs[], ident *asm_text);
ir_node *new_r_ASM(ir_graph *irg, ir_node *block,
int arity, ir_node *in[], ir_asm_constraint *inputs,
int n_outs, ir_asm_constraint *outputs, ident *asm_text);
/*-----------------------------------------------------------------------*/
/* The block oriented interface */
......@@ -3559,12 +3565,15 @@ ir_node *new_d_Pin(dbg_info *db, ir_node *node);
/** Constructor for an ASM pseudo node.
*
* @param *db A pointer for debug information.
* @param *store The memory input for the node
* @param arity The number of data inputs to the node.
* @param *in The array of length arity of data inputs.
* @param *inputs The array of length arity of input constraints.
* @param n_outs The number of data outputs to the node.
* @param *outputs The array of length n_outs of output constraints.
* @param *asm_text The assembler text.
*/
ir_node *new_d_ASM(dbg_info *db, ir_node *store,
int arity, ir_node *inputs[], ident *asm_text);
ir_node *new_d_ASM(dbg_info *db, int arity, ir_node *in[], ir_asm_constraint *inputs,
int n_outs, ir_asm_constraint *outputs, ident *asm_text);
/*-----------------------------------------------------------------------*/
/* The block oriented interface without debug support */
......@@ -4276,12 +4285,15 @@ ir_node *new_Pin (ir_node *node);
/** Constructor for an ASM pseudo node.
*
* @param *store The memory input for the node
* @param arity The number of data inputs to the node.
* @param *inputs The array of length arity of data inputs.
* @param *in The array of length arity of data inputs.
* @param *inputs The array of length arity of input constraints.
* @param n_outs The number of data outputs to the node.
* @param *outputs The array of length n_outs of output constraints.
* @param *asm_text The assembler text.
*/
ir_node *new_ASM(ir_node *store, int arity, ir_node *inputs[], ident *asm_text);
ir_node *new_ASM(int arity, ir_node *in[], ir_asm_constraint *inputs,
int n_outs, ir_asm_constraint *outputs, ident *asm_text);
/*---------------------------------------------------------------------*/
/* The comfortable interface. */
......
......@@ -2342,6 +2342,17 @@ const char *get_ASM_text(const ir_node *node) {
return get_id_str(node->attr.assem.asm_text);
}
/* Return the input constraints for an ASM node. This is a flexible array. */
const ir_asm_constraint *get_ASM_input_constraints(const ir_node *node) {
assert(node->op == op_ASM);
return node->attr.assem.inputs;
}
/** Return the output constraints for an ASM node. This is a flexible array. */
const ir_asm_constraint *get_ASM_output_constraints(const ir_node *node) {
assert(node->op == op_ASM);
return node->attr.assem.outputs;
}
/* returns the graph of a node */
ir_graph *
......
......@@ -1153,9 +1153,21 @@ void set_Bound_upper(ir_node *bound, ir_node *upper);
ir_node *get_Pin_op(const ir_node *pin);
void set_Pin_op(ir_node *pin, ir_node *node);
/** A input/output constraint attribute */
typedef struct {
unsigned pos; /**< The inputs/output position for this constraint. */
ident *constraint; /**< The constraint for this input/output. */
} ir_asm_constraint;
/** Return the assembler text of an ASM pseudo node. */
const char *get_ASM_text(const ir_node *node);
/** Return the input constraints for an ASM node. This is a flexible array. */
const ir_asm_constraint *get_ASM_input_constraints(const ir_node *node);
/** Return the output constraints for an ASM node. This is a flexible array. */
const ir_asm_constraint *get_ASM_output_constraints(const ir_node *node);
/*
*
* NAME Auxiliary routines
......
......@@ -207,9 +207,10 @@ typedef struct {
/** Inline Assembler support attribute. */
typedef struct {
op_pin_state pin_state; /**< the pin state for operations that might generate a exception */
ident *asm_text; /**< The inline assembler text. */
void *be_data; /**< backend can add data here. */
op_pin_state pin_state; /**< the pin state for operations that might generate a exception */
ident *asm_text; /**< The inline assembler text. */
ir_asm_constraint *inputs; /**< Input constraints. */
ir_asm_constraint *outputs; /**< Output constraints. */
} asm_attr;
/** Some IR-nodes just have one attribute, these are stored here,
......
......@@ -177,6 +177,18 @@ filter_copy_attr(const ir_node *old_node, ir_node *new_node) {
new_node->attr.filter.backedge = new_backedge_arr(irg->obst, get_irn_arity(new_node));
}
/**
* Copies all ASM attributes stored in old node to the new node
*/
static void
ASM_copy_attr(const ir_node *old_node, ir_node *new_node) {
ir_graph *irg = current_ir_graph;
default_copy_attr(old_node, new_node);
new_node->attr.assem.inputs = DUP_ARR_D(ir_asm_constraint, irg->obst, old_node->attr.assem.inputs);
new_node->attr.assem.outputs = DUP_ARR_D(ir_asm_constraint, irg->obst, old_node->attr.assem.outputs);
}
/**
* Sets the default copy_attr operation for an ir_ops
*
......@@ -195,6 +207,8 @@ static ir_op_ops *firm_set_default_copy_attr(ir_opcode code, ir_op_ops *ops) {
ops->copy_attr = phi_copy_attr;
else if (code == iro_Filter)
ops->copy_attr = filter_copy_attr;
else if (code == iro_ASM)
ops->copy_attr = ASM_copy_attr;
else {
/* not allowed to be NULL */
if (! ops->copy_attr)
......
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