Commit e5d0d8f5 authored by Christoph Mallon's avatar Christoph Mallon Committed by Matthias Braun
Browse files

Factorise code to transform binary ops on AMD64.

parent 843f526a
......@@ -94,51 +94,21 @@ static ir_node *gen_SymConst(ir_node *node)
return new_node;
}
/**
* Transforms an Add node.
*
* @return The transformed AMD64 node.
*/
static ir_node *gen_Add(ir_node *node) {
ir_node *block = be_transform_node(get_nodes_block(node));
ir_node *op1 = get_Add_left(node);
ir_node *op2 = get_Add_right(node);
dbg_info *dbgi = get_irn_dbg_info(node);
ir_node *new_op1 = be_transform_node(op1);
ir_node *new_op2 = be_transform_node(op2);
ir_node *res = new_bd_amd64_Add(dbgi, block, new_op1, new_op2);
return res;
}
/**
* Transforms an Sub node.
*
* @return The transformed AMD64 node.
*/
static ir_node *gen_Sub(ir_node *node) {
ir_node *block = be_transform_node(get_nodes_block(node));
ir_node *op1 = get_Sub_left(node);
ir_node *op2 = get_Sub_right(node);
dbg_info *dbgi = get_irn_dbg_info(node);
ir_node *new_op1 = be_transform_node(op1);
ir_node *new_op2 = be_transform_node(op2);
ir_node *res = new_bd_amd64_Sub(dbgi, block, new_op1, new_op2);
return res;
static ir_node *gen_binop(ir_node *const node, ir_node *(*const new_node)(dbg_info*, ir_node*, ir_node*, ir_node*))
{
dbg_info *const dbgi = get_irn_dbg_info(node);
ir_node *const block = be_transform_node(get_nodes_block(node));
ir_node *const op1 = get_binop_left(node);
ir_node *const new_op1 = be_transform_node(op1);
ir_node *const op2 = get_binop_right(node);
ir_node *const new_op2 = be_transform_node(op2);
return new_node(dbgi, block, new_op1, new_op2);
}
static ir_node *gen_Mul(ir_node *node) {
ir_node *block = be_transform_node(get_nodes_block(node));
ir_node *op1 = get_Mul_left(node);
ir_node *op2 = get_Mul_right(node);
dbg_info *dbgi = get_irn_dbg_info(node);
ir_node *new_op1 = be_transform_node(op1);
ir_node *new_op2 = be_transform_node(op2);
ir_node *res = new_bd_amd64_IMul(dbgi, block, new_op1, new_op2);
return res;
}
static ir_node *gen_Add (ir_node *const node) { return gen_binop(node, &new_bd_amd64_Add); }
static ir_node *gen_Mul (ir_node *const node) { return gen_binop(node, &new_bd_amd64_IMul); }
static ir_node *gen_Sub (ir_node *const node) { return gen_binop(node, &new_bd_amd64_Sub); }
static ir_node *gen_Minus(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