X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fir%2Firop.c;h=ac34f4b6e9243b187b76ff031c8d647a6bf7f200;hb=8399216d8aebc713bbda04b6e3e250a1d52b20bf;hp=69f8a84bc4047cc7953b804f37406aa670c4cbcc;hpb=814def24d66ee2a525987001946d6c9a6717505c;p=libfirm diff --git a/ir/ir/irop.c b/ir/ir/irop.c index 69f8a84bc..ac34f4b6e 100644 --- a/ir/ir/irop.c +++ b/ir/ir/irop.c @@ -11,16 +11,18 @@ */ #ifdef HAVE_CONFIG_H -# include +# include "config.h" #endif +#ifdef HAVE_STRING_H # include +#endif # include "irop_t.h" # include "irnode_t.h" # include "firmstat.h" -# include "iropt.h" /* for firm_set_default_operations */ +# include "iropt_t.h" /* for firm_set_default_operations */ # include "xmalloc.h" @@ -86,7 +88,47 @@ ir_op *op_EndReg; ir_op *get_op_EndReg (void) { return op_EndReg; } ir_op *op_EndExcept; ir_op *get_op_EndExcept (void) { return op_EndExcept; } ir_op *op_NoMem; ir_op *get_op_NoMem (void) { return op_NoMem; } +ir_op *op_Mux; ir_op *get_op_Mux (void) { return op_Mux; } + + +/* + * Copies all attributes stored in the old node to the new node. + * Assumes both have the same opcode and sufficient size. + */ +void default_copy_attr(const ir_node *old_node, ir_node *new_node) { + unsigned size = firm_add_node_size; + + assert(get_irn_op(old_node) == get_irn_op(new_node)); + memcpy(&new_node->attr, &old_node->attr, get_op_attr_size(get_irn_op(old_node))); + + if (size > 0) { + /* copy additional node data */ + memcpy(get_irn_data(new_node, void, size), get_irn_data(old_node, void, size), size); + } +} + +/** + * Copies all attributes stored in the old node to the new node. + * Assumes both have the same opcode and sufficient size. + */ +static void +call_copy_attr(const ir_node *old_node, ir_node *new_node) { + default_copy_attr(old_node, new_node); + remove_Call_callee_arr(new_node); +} + +/** + * Sets the copy_attr operation for an ir_op + */ +static ir_op *firm_set_default_copy_attr(ir_op *op) { + if (op->code == iro_Call) + op->copy_attr = call_copy_attr; + else + op->copy_attr = default_copy_attr; + + return op; +} ir_op * new_ir_op(opcode code, const char *name, op_pin_state p, unsigned flags, op_arity opar, int op_index, size_t attr_size) @@ -105,6 +147,8 @@ new_ir_op(opcode code, const char *name, op_pin_state p, unsigned flags, op_arit res->op_index = op_index; firm_set_default_operations(res); + firm_set_default_copy_attr(res); + stat_new_ir_op(res); return res; } @@ -183,6 +227,7 @@ init_op(void) op_EndExcept = new_ir_op(iro_EndExcept, "EndExcept", op_pin_state_pinned, X|I, oparity_any, -1, sizeof(end_attr)); op_NoMem = new_ir_op(iro_NoMem, "NoMem", op_pin_state_pinned, 0, oparity_zero, -1, 0); + op_Mux = new_ir_op(iro_Mux, "Mux", op_pin_state_floats, 0, oparity_trinary, -1, 0); #undef Y #undef F @@ -254,6 +299,7 @@ void finish_op(void) { free_ir_op (op_EndExcept); op_EndExcept = NULL; free_ir_op (op_NoMem ); op_NoMem = NULL; + free_ir_op (op_Mux ); op_Mux = NULL; } /* Returns the string for the opcode. */ @@ -265,10 +311,22 @@ opcode (get_op_code)(const ir_op *op){ return __get_op_code(op); } -ident *(get_op_ident)(ir_op *op){ +ident *(get_op_ident)(const ir_op *op){ return __get_op_ident(op); } +const char *get_op_pin_state_name(op_pin_state s) { + switch(s) { +#define XXX(s) case s: return #s + XXX(op_pin_state_floats); + XXX(op_pin_state_pinned); + XXX(op_pin_state_exc_pinned); + XXX(op_pin_state_mem_pinned); +#undef XXX + } + return ""; +} + op_pin_state (get_op_pinned)(const ir_op *op){ return __get_op_pinned(op); }