X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=scripts%2Fir_spec.py;h=365855e7fce927de977929d87c184fe919c03a0e;hb=b094543ff14d2bb51b6f94afa001a5e00eed8442;hp=ec8313a54619eab9964ed50cd6d0acd94f7525ce;hpb=1833cfd9062cd48bd72d95b5e43a08b3acb4e20b;p=libfirm diff --git a/scripts/ir_spec.py b/scripts/ir_spec.py index ec8313a54..365855e7f 100755 --- a/scripts/ir_spec.py +++ b/scripts/ir_spec.py @@ -1,57 +1,127 @@ nodes = dict( -Start = dict( - mode = "mode_T", - op_flags = "cfopcode", - state = "pinned", - knownBlock = True, - noconstr = True, -), -End = dict( - mode = "mode_X", - op_flags = "cfopcode", - state = "pinned", - arity = "dynamic", - knownBlock = True, - noconstr = True, +# +# Abstract node types +# +unop = dict( + abstract = True, + ins = [ "op" ] ), -Phi = dict( - noconstr = True, - state = "pinned", - arity = "variable", +binop = dict( + abstract = True, + ins = [ "left", "right" ] ), -Jmp = dict( - mode = "mode_X", - op_flags = "cfopcode", - state = "pinned", - ins = [], +# +# Real node types +# +Abs = dict( + is_a = "unop" ), -IJmp = dict( - mode = "mode_X", - op_flags = "cfopcode", - state = "pinned", - ins = [ "target" ], +Add = dict( + is_a = "binop" ), -Const = dict( - mode = "", - knownBlock = True, - attrs = [ +Alloc = dict( + ins = [ "mem", "size" ], + outs = [ "M", "X_regular", "X_except", "res" ], + attrs = [ dict( - type = "tarval*", - name = "tarval", + name = "state", + type = "op_pin_state", + initname = ".exc.pin_state", + init = "op_pin_state_pinned" + ), + dict( + name = "type", + type = "ir_type*" + ), + dict( + name = "where", + type = "ir_where_alloc" ) ], + d_post = ''' + #if PRECISE_EXC_CONTEXT + firm_alloc_frag_arr(res, op_Alloc, &res->attr.alloc.exc.frag_arr); + #endif + ''' +), + +Anchor = dict( + mode = "mode_ANY", + ins = [ "end_block", "start_block", "end", "start", + "end_reg", "end_except", "initial_exec", + "frame", "tls", "initial_mem", "args", + "bad", "no_mem" ], + knownBlock = True, + noconstr = True +), + +And = dict( + is_a = "binop" +), + +Bad = dict( + mode = "mode_Bad", + knownBlock = True, ), Block = dict( - mode = "mode_BB", + mode = "mode_BB", knownBlock = True, + block = "NULL", noconstr = True, + optimize = False, arity = "variable", + + init = ''' + /* macroblock header */ + res->in[0] = res; + + res->attr.block.is_dead = 0; + res->attr.block.is_mb_head = 1; + res->attr.block.has_label = 0; + res->attr.block.irg = irg; + res->attr.block.backedge = new_backedge_arr(irg->obst, arity); + res->attr.block.in_cg = NULL; + res->attr.block.cg_backedge = NULL; + res->attr.block.extblk = NULL; + res->attr.block.mb_depth = 0; + res->attr.block.label = 0; + + set_Block_matured(res, 1); + set_Block_block_visited(res, 0); + ''', + + d_pre = ''' + int i; + int has_unknown = 0; + ''', + + d_post = ''' + /* Create and initialize array for Phi-node construction. */ + if (get_irg_phase_state(current_ir_graph) == phase_building) { + res->attr.block.graph_arr = NEW_ARR_D(ir_node *, current_ir_graph->obst, + current_ir_graph->n_loc); + memset(res->attr.block.graph_arr, 0, sizeof(ir_node *)*current_ir_graph->n_loc); + } + + for (i = arity - 1; i >= 0; i--) + if (is_Unknown(in[i])) { + has_unknown = 1; + break; + } + + if (!has_unknown) res = optimize_node(res); + + current_ir_graph->current_block = res; + + IRN_VRFY_IRG(res, current_ir_graph); + ''', + java_add = ''' public void addPred(Node node) { binding_cons.add_immBlock_pred(ptr, node.ptr); @@ -75,30 +145,31 @@ Block = dict( }''', ), -SymConst = dict( - mode = "mode_P", - knownBlock = True, - noconstr = True, - attrs = [ +Borrow = dict( + is_a = "binop" +), + +Bound = dict( + ins = [ "mem", "index", "lower", "upper" ], + outs = [ "M", "X_regular", "X_except", "res" ], + attrs = [ dict( - type = "ir_entity*", - name = "entity" + name = "state", + type = "op_pin_state", + initname = ".exc.pin_state", + init = "op_pin_state_pinned" ) ], + d_post = ''' + #if PRECISE_EXC_CONTEXT + firm_alloc_frag_arr(res, op_Bound, &res->attr.bound.exc.frag_arr); + #endif + ''' ), -# SymConst -Call = dict( - ins = [ "mem", "ptr" ], - arity = "variable", - outs = [ "M_regular", "X_regular", "X_except", "T_result", "M_except", "P_value_res_base" ], - attrs = [ - dict( - type = "ir_type*", - name = "type" - ) - ] +Break = dict( + mode = "mode_X" ), Builtin = dict( @@ -106,6 +177,12 @@ Builtin = dict( arity = "variable", outs = [ "M_regular", "X_regular", "X_except", "T_result", "M_except", "P_value_res_base" ], attrs = [ + dict( + name = "state", + type = "op_pin_state", + initname = ".exc.pin_state", + init = "op_pin_state_pinned" + ), dict( type = "ir_builtin_kind", name = "kind" @@ -114,92 +191,147 @@ Builtin = dict( type = "ir_type*", name = "type" ) - ] -), + ], + init = ''' + assert((get_unknown_type() == type) || is_Method_type(type)); + ''' -binop = dict( - abstract = True, - ins = [ "left", "right" ] + # TODO: No firm_alloc_frag_arr?? ), -Add = dict( - is_a = "binop" +Call = dict( + ins = [ "mem", "ptr" ], + arity = "variable", + outs = [ "M_regular", "X_regular", "X_except", "T_result", "M_except", "P_value_res_base" ], + attrs = [ + dict( + name = "state", + type = "op_pin_state", + initname = ".exc.pin_state", + init = "op_pin_state_pinned" + ), + dict( + type = "ir_type*", + name = "type" + ) + ], + init = ''' + assert((get_unknown_type() == type) || is_Method_type(type)); + ''', + d_post = ''' + #if PRECISE_EXC_CONTEXT + firm_alloc_frag_arr(res, op_Call, &res->attr.call.exc.frag_arr); + #endif + ''' ), Carry = dict( is_a = "binop" ), -Sub = dict( - is_a = "binop" -), - -Borrow = dict( - is_a = "binop" -), - -Mul = dict( - is_a = "binop" -), - -Mulh = dict( - is_a = "binop" -), - -Abs = dict( - is_a = "unop" -), - -And = dict( - is_a = "binop" -), - -Or = dict( - is_a = "binop" -), - -Eor = dict( - is_a = "binop" +Cast = dict( + ins = [ "op" ], + mode = "get_irn_mode(irn_op)", + attrs = [ + dict( + type = "ir_type*", + name = "type" + ) + ], + init = "assert(is_atomic_type(type));" ), -Not = dict( - is_a = "unop" +Cmp = dict( + is_a = "binop", + outs = [ "False", "Eq", "Lt", "Le", "Gt", "Ge", "Lg", "Leg", "Uo", "Ue", "Ul", "Ule", "Ug", "Uge", "Ne", "True" ], ), -Shl = dict( - is_a = "binop" +Cond = dict( + ins = [ "selector" ], + outs = [ "false", "true" ], + attrs = [ + dict( + name = "kind", + type = "cond_kind", + init = "dense" + ), + dict( + name = "default_proj", + type = "long", + init = "0" + ), + dict( + name = "jmp_pred", + type = "cond_jmp_predicate", + init = "COND_JMP_PRED_NONE" + ) + ] ), -Shr = dict( - is_a = "binop" +Confirm = dict( + ins = [ "value", "bound" ], + mode = "get_irn_mode(irn_value)", + attrs = [ + dict( + name = "cmp", + type = "pn_Cmp" + ), + ], ), -Shrs = dict( - is_a = "binop" +Const = dict( + mode = "", + knownBlock = True, + attrs_name = "con", + attrs = [ + dict( + type = "tarval*", + name = "tarval", + ) + ], ), -Rotl = dict( - is_a = "binop" +Conv = dict( + is_a = "unop", + attrs = [ + dict( + name = "strict", + type = "int", + init = "0", + special = dict( + prefix = "strict", + init = "1" + ) + ) + ] ), -Quot = dict( - ins = [ "mem", "dividend", "divisor" ], - outs = [ "M", "X_regular", "X_except", "res" ], +CopyB = dict( + ins = [ "mem", "dst", "src" ], + outs = [ "M", "X_regular", "X_except" ], attrs = [ dict( - type = "ir_mode*", - name = "resmode" + name = "state", + type = "op_pin_state", + initname = ".exc.pin_state", + init = "op_pin_state_pinned" ), dict( - name = "state", - type = "op_pin_state" + name = "type", + type = "ir_type*" ) - ] + ], + d_post = ''' + #if PRECISE_EXC_CONTEXT + firm_alloc_frag_arr(res, op_CopyB, &res->attr.copyb.exc.frag_arr); + #endif + ''' ), Div = dict( ins = [ "mem", "dividend", "divisor" ], outs = [ "M", "X_regular", "X_except", "res" ], + attrs_name = "divmod", attrs = [ dict( type = "ir_mode*", @@ -207,14 +339,30 @@ Div = dict( ), dict( name = "state", - type = "op_pin_state" + type = "op_pin_state", + initname = ".exc.pin_state" + ), + dict( + name = "no_remainder", + type = "int", + init = "0", + special = dict( + suffix = "RL", + init = "1" + ) ) - ] + ], + d_post = ''' + #if PRECISE_EXC_CONTEXT + firm_alloc_frag_arr(res, op_Div, &res->attr.except.frag_arr); + #endif + ''' ), DivMod = dict( ins = [ "mem", "dividend", "divisor" ], outs = [ "M", "X_regular", "X_except", "res_div", "res_mod" ], + attrs_name = "divmod", attrs = [ dict( type = "ir_mode*", @@ -222,24 +370,94 @@ DivMod = dict( ), dict( name = "state", - type = "op_pin_state" + type = "op_pin_state", + initname = ".exc.pin_state" ) - ] + ], + d_post = ''' + #if PRECISE_EXC_CONTEXT + firm_alloc_frag_arr(res, op_DivMod, &res->attr.except.frag_arr); + #endif + ''' ), -Mod = dict( - ins = [ "mem", "dividend", "divisor" ], - outs = [ "M", "X_regular", "X_except", "res" ], +End = dict( + mode = "mode_X", + op_flags = "cfopcode", + state = "pinned", + arity = "dynamic", + noconstr = True, + optimize = False +), + +Eor = dict( + is_a = "binop" +), + +Filter = dict( + ins = [ "pred" ], attrs = [ dict( - type = "ir_mode*", - name = "resmode" + name = "proj", + type = "long" + ) + ] + + # TODO: Broken asserts in original: + # assert(get_Proj_pred(res)); + # assert(get_nodes_block(get_Proj_pred(res))); +), + +Free = dict( + ins = [ "mem", "ptr", "size" ], + mode = "mode_M", + attrs = [ + dict( + name = "type", + type = "ir_type*" ), + dict( + name = "where", + type = "ir_where_alloc" + ) + ] +), + +Id = dict( + ins = [ "pred" ] +), + +IJmp = dict( + mode = "mode_X", + op_flags = "cfopcode", + state = "pinned", + ins = [ "target" ], +), + +InstOf = dict( + ins = [ "store", "objptr" ], + outs = [ "M", "X_regular", "X_except", "res", "M_except" ], + attrs = [ dict( name = "state", - type = "op_pin_state" + type = "op_pin_state", + initname = ".exc.pin_state", + init = "op_pin_state_floats" + ), + dict( + name = "type", + type = "ir_type*" ) ] + + # TODO: No firm_alloc_frag_arr??? +), + +Jmp = dict( + mode = "mode_X", + op_flags = "cfopcode", + state = "pinned", + ins = [], ), Load = dict( @@ -254,31 +472,53 @@ Load = dict( ], constructor_args = [ dict( - type = "cons_flags", + type = "ir_cons_flags", name = "flags", ), ], + d_post = ''' +#if PRECISE_EXC_CONTEXT + firm_alloc_frag_arr(res, op_Load, &res->attr.load.exc.frag_arr); +#endif + ''' ), -Store = dict( - ins = [ "mem", "ptr", "value" ], - outs = [ "M", "X_regular", "X_except" ], - constructor_args = [ +Minus = dict( + is_a = "unop" +), + +Mod = dict( + ins = [ "mem", "dividend", "divisor" ], + outs = [ "M", "X_regular", "X_except", "res" ], + attrs_name = "divmod", + attrs = [ dict( - type = "cons_flags", - name = "flags", + type = "ir_mode*", + name = "resmode" ), + dict( + name = "state", + type = "op_pin_state", + initname = ".exc.pin_state" + ) ], + d_post = ''' + #if PRECISE_EXC_CONTEXT + firm_alloc_frag_arr(res, op_Mod, &res->attr.except.frag_arr); + #endif + ''' ), -Anchor = dict( - mode = "mode_ANY", - ins = [ "end_block", "start_block", "end", "start", - "end_reg", "end_except", "initial_exec", - "frame", "tls", "initial_mem", "args", - "bad", "no_mem" ], - knownBlock = True, - noconstr = True +Mul = dict( + is_a = "binop" +), + +Mulh = dict( + is_a = "binop" +), + +Mux = dict( + ins = [ "sel", "false", "true" ] ), NoMem = dict( @@ -286,14 +526,23 @@ NoMem = dict( knownBlock = True, ), -Bad = dict( - mode = "mode_Bad", - knownBlock = True, +Not = dict( + is_a = "unop" +), + +Or = dict( + is_a = "binop" +), + +Phi = dict( + noconstr = True, + state = "pinned", + arity = "variable", ), Pin = dict( ins = [ "op" ], - mode = "get_irn_mode(op);" + mode = "get_irn_mode(irn_op)" ), Proj = dict( @@ -301,147 +550,127 @@ Proj = dict( attrs = [ dict( type = "long", - name = "proj" + name = "proj", + initname = "" ) ] ), -Sel = dict( - ins = [ "mem", "ptr" ], - arity = "variable", - mode = "mode_P", - attrs = [ +Quot = dict( + ins = [ "mem", "dividend", "divisor" ], + outs = [ "M", "X_regular", "X_except", "res" ], + attrs_name = "divmod", + attrs = [ dict( - type = "ir_entity*", - name = "entity" + type = "ir_mode*", + name = "resmode" + ), + dict( + name = "state", + type = "op_pin_state", + initname = ".exc.pin_state" ) - ] + ], + d_post = ''' + #if PRECISE_EXC_CONTEXT + firm_alloc_frag_arr(res, op_Quot, &res->attr.except.frag_arr); + #endif + ''' ), -Sync = dict( - mode = "mode_M", - arity = "dynamic" +Raise = dict( + ins = [ "mem", "exo_ptr" ], + outs = [ "M", "X" ] ), -Tuple = dict( +Return = dict( + ins = [ "mem" ], arity = "variable", - mode = "mode_T", + mode = "mode_X" ), -Unknown = dict( - knownBlock = True +Rotl = dict( + is_a = "binop" ), -Confirm = dict( - ins = [ "value", "bound" ], - mode = "get_irn_mode(value)", +Sel = dict( + ins = [ "mem", "ptr" ], + arity = "variable", + mode = "is_Method_type(get_entity_type(entity)) ? mode_P_code : mode_P_data", attrs = [ dict( - name = "cmp", - type = "pn_Cmp" - ), - ], + type = "ir_entity*", + name = "entity" + ) + ] ), -Return = dict( - ins = [ "mem" ], - arity = "variable", - mode = "mode_X" +Shl = dict( + is_a = "binop" ), -unop = dict( - abstract = True, - ins = [ "op" ] +Shr = dict( + is_a = "binop" ), -Minus = dict( - is_a = "unop" +Shrs = dict( + is_a = "binop" ), -Mux = dict( - ins = [ "sel", "false", "true" ] +Start = dict( + mode = "mode_T", + op_flags = "cfopcode", + state = "pinned", + noconstr = True, + optimize = False ), -Cond = dict( - ins = [ "selector" ], - outs = [ "false", "true" ], - attrs = [ - dict( - name = "kind", - type = "cond_kind", - init = "dense" - ), +Store = dict( + ins = [ "mem", "ptr", "value" ], + outs = [ "M", "X_regular", "X_except" ], + constructor_args = [ dict( - name = "default_proj", - type = "long", - init = "0" + type = "ir_cons_flags", + name = "flags", ), - dict( - name = "jmp_pred", - type = "cond_jmp_predicate", - init = "COND_JMP_PRED_NONE" - ) - ] + ], + d_post = ''' +#if PRECISE_EXC_CONTEXT + firm_alloc_frag_arr(res, op_Store, &res->attr.store.exc.frag_arr); +#endif + ''' ), -Cmp = dict( - is_a = "binop", - outs = [ "False", "Eq", "Lt", "Le", "Gt", "Ge", "Lg", "Leg", "Uo", "Ue", "Ul", "Ule", "Ug", "Uge", "Ne", "True" ], +Sub = dict( + is_a = "binop" ), -Conv = dict( - is_a = "unop", - attrs = [ +SymConst = dict( + mode = "mode_P", + knownBlock = True, + noconstr = True, + attrs = [ dict( - name = "strict", - type = "int", - init = "0", - special = dict( - prefix = "strict", - init = "1" - ) + type = "ir_entity*", + name = "entity" ) - ] + ], ), -Alloc = dict( - ins = [ "mem", "size" ], - outs = [ "M", "X_regular", "X_except", "res" ], - attrs = [ - dict( - name = "type", - type = "ir_type*" - ), - dict( - name = "where", - type = "ir_where_alloc" - ) - ] +Sync = dict( + mode = "mode_M", + optimize = False, + arity = "dynamic" ), -Free = dict( - ins = [ "mem", "ptr", "size" ], - mode = "mode_M", - attrs = [ - dict( - name = "type", - type = "ir_type*" - ), - dict( - name = "where", - type = "ir_where_alloc" - ) - ] +Tuple = dict( + arity = "variable", + mode = "mode_T", ), -CopyB = dict( - ins = [ "mem", "dst", "src" ], - outs = [ "M", "X_regular", "X_except" ], - attrs = [ - dict( - name = "type", - type = "ir_type*" - ) - ] +Unknown = dict( + knownBlock = True, + block = "get_irg_start_block(irg)", + nodbginfo = True ), )