X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;ds=sidebyside;f=scripts%2Fir_spec.py;h=fd4ed3267827cb8823156318c5e09ae97c6fd093;hb=1b8b9508dc269d5dfe53061b0dc04aac41f61106;hp=d0707820cdb65ad4f0415b77577fcb5f12853e1e;hpb=279822e9e2a4f26deaf67b5fe8423b27837a75d7;p=libfirm diff --git a/scripts/ir_spec.py b/scripts/ir_spec.py index d0707820c..fd4ed3267 100755 --- a/scripts/ir_spec.py +++ b/scripts/ir_spec.py @@ -1,57 +1,120 @@ 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 = "type", + type = "ir_type*" + ), + dict( + name = "where", + type = "ir_where_alloc" ) ], + pinned = "exception", + pinned_init = "pinned", + 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", + arity = "variable", + 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); @@ -72,22 +135,57 @@ Block = dict( public void markBlockVisited() { binding.mark_Block_block_visited(ptr); - }''', + } + + public boolean isBad() { + return binding.is_Bad(ptr) != 0; + } + ''', ), -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" ], + pinned = "exception", + pinned_init = "pinned", + d_post = ''' + #if PRECISE_EXC_CONTEXT + firm_alloc_frag_arr(res, op_Bound, &res->attr.bound.exc.frag_arr); + #endif + ''' +), + + +Break = dict( + mode = "mode_X" +), + +Builtin = dict( + ins = [ "mem" ], + arity = "variable", + outs = [ "M_regular", "X_regular", "X_except", "T_result", "M_except", "P_value_res_base" ], + attrs = [ dict( - type = "ir_entity*", - name = "entity" + type = "ir_builtin_kind", + name = "kind" + ), + dict( + type = "ir_type*", + name = "type" ) ], -), + pinned = "memory", + pinned_init = "pinned", + init = ''' + assert((get_unknown_type() == type) || is_Method_type(type)); + ''' -# SymConst + # TODO: No firm_alloc_frag_arr?? +), Call = dict( ins = [ "mem", "ptr" ], @@ -98,72 +196,234 @@ Call = dict( type = "ir_type*", name = "type" ) - ] + ], + pinned = "memory", + pinned_init = "pinned", + 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 + ''' ), -binop = dict( - abstract = True, - ins = [ "left", "right" ] +Carry = dict( + is_a = "binop" ), -Add = 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));" ), -Carry = dict( - is_a = "binop" +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" +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" + ) + ] ), -Borrow = dict( - is_a = "binop" +Confirm = dict( + ins = [ "value", "bound" ], + mode = "get_irn_mode(irn_value)", + attrs = [ + dict( + name = "cmp", + type = "pn_Cmp" + ), + ], ), -Mul = dict( - is_a = "binop" +Const = dict( + mode = "", + knownBlock = True, + attrs_name = "con", + attrs = [ + dict( + type = "tarval*", + name = "tarval", + ) + ], ), -Mulh = dict( - is_a = "binop" +Conv = dict( + is_a = "unop", + attrs = [ + dict( + name = "strict", + type = "int", + init = "0", + special = dict( + prefix = "strict", + init = "1" + ) + ) + ] ), -Abs = dict( - is_a = "unop" +CopyB = dict( + ins = [ "mem", "dst", "src" ], + outs = [ "M", "X_regular", "X_except" ], + attrs = [ + dict( + name = "type", + type = "ir_type*" + ) + ], + pinned = "memory", + pinned_init = "pinned", + d_post = ''' + #if PRECISE_EXC_CONTEXT + firm_alloc_frag_arr(res, op_CopyB, &res->attr.copyb.exc.frag_arr); + #endif + ''' ), -And = dict( - is_a = "binop" +Div = dict( + ins = [ "mem", "left", "right" ], + outs = [ "M", "X_regular", "X_except", "res" ], + attrs_name = "divmod", + attrs = [ + dict( + type = "ir_mode*", + name = "resmode" + ), + dict( + name = "no_remainder", + type = "int", + init = "0", + special = dict( + suffix = "RL", + init = "1" + ) + ) + ], + pinned = "exception", + d_post = ''' + #if PRECISE_EXC_CONTEXT + firm_alloc_frag_arr(res, op_Div, &res->attr.except.frag_arr); + #endif + ''' +), + +DivMod = dict( + ins = [ "mem", "left", "right" ], + outs = [ "M", "X_regular", "X_except", "res_div", "res_mod" ], + attrs_name = "divmod", + attrs = [ + dict( + type = "ir_mode*", + name = "resmode" + ), + ], + pinned = "exception", + d_post = ''' + #if PRECISE_EXC_CONTEXT + firm_alloc_frag_arr(res, op_DivMod, &res->attr.except.frag_arr); + #endif + ''' ), -Or = dict( - is_a = "binop" +End = dict( + mode = "mode_X", + op_flags = "cfopcode", + pinned = "yes", + arity = "dynamic", + noconstr = True, + optimize = False ), Eor = dict( is_a = "binop" ), -Not = dict( - is_a = "unop" +Filter = dict( + ins = [ "pred" ], + attrs = [ + dict( + name = "proj", + type = "long" + ) + ] + + # TODO: Broken asserts in original: + # assert(get_Proj_pred(res)); + # assert(get_nodes_block(get_Proj_pred(res))); ), -Shl = dict( - is_a = "binop" +Free = dict( + ins = [ "mem", "ptr", "size" ], + mode = "mode_M", + attrs = [ + dict( + name = "type", + type = "ir_type*" + ), + dict( + name = "where", + type = "ir_where_alloc" + ) + ] ), -Shr = dict( - is_a = "binop" +Id = dict( + ins = [ "pred" ] ), -Shrs = dict( - is_a = "binop" +IJmp = dict( + mode = "mode_X", + op_flags = "cfopcode", + pinned = "yes", + ins = [ "target" ], ), -Rotl = dict( - is_a = "binop" +InstOf = dict( + ins = [ "store", "obj" ], + outs = [ "M", "X_regular", "X_except", "res", "M_except" ], + attrs = [ + dict( + name = "type", + type = "ir_type*" + ) + ], + pinned = "memory", + pinned_init = "floats", +), + +Jmp = dict( + mode = "mode_X", + op_flags = "cfopcode", + pinned = "yes", + ins = [], ), Load = dict( @@ -178,31 +438,49 @@ 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", "left", "right" ], + outs = [ "M", "X_regular", "X_except", "res" ], + attrs_name = "divmod", + attrs = [ dict( - type = "cons_flags", - name = "flags", + type = "ir_mode*", + name = "resmode" ), ], + pinned = "exception", + 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( @@ -210,14 +488,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, + pinned = "yes", + arity = "variable", ), Pin = dict( ins = [ "op" ], - mode = "get_irn_mode(op);" + mode = "get_irn_mode(irn_op)" ), Proj = dict( @@ -225,109 +512,123 @@ 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", "left", "right" ], + outs = [ "M", "X_regular", "X_except", "res" ], + attrs_name = "divmod", + attrs = [ dict( - type = "ir_entity*", - name = "entity" - ) - ] + type = "ir_mode*", + name = "resmode" + ), + ], + pinned = "exception", + 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" ], - block = "get_nodes_block(value)", - 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" - ), - ], -), - -Return = dict( - ins = [ "mem" ], - arity = "variable", - mode = "mode_X" + type = "ir_entity*", + name = "entity" + ) + ] ), -unop = dict( - abstract = True, - ins = [ "op" ] +Shl = dict( + is_a = "binop" ), -Minus = dict( - is_a = "unop" +Shr = dict( + is_a = "binop" ), -Mux = dict( - ins = [ "sel", "false", "true" ] +Shrs = dict( + is_a = "binop" ), -Cond = dict( - ins = [ "selector" ], - outs = [ "false", "true" ], +Start = dict( + mode = "mode_T", + op_flags = "cfopcode", + pinned = "yes", + noconstr = True, + optimize = False ), -Cmp = dict( - is_a = "binop", - outs = [ "False", "Eq", "Lt", "Le", "Gt", "Ge", "Lg", "Leg", "Uo", "Ue", "Ul", "Ule", "Ug", "Uge", "Ne", "True" ], +Store = dict( + ins = [ "mem", "ptr", "value" ], + outs = [ "M", "X_regular", "X_except" ], + constructor_args = [ + dict( + type = "ir_cons_flags", + name = "flags", + ), + ], + d_post = ''' +#if PRECISE_EXC_CONTEXT + firm_alloc_frag_arr(res, op_Store, &res->attr.store.exc.frag_arr); +#endif + ''' ), -Conv = dict( - is_a = "unop" +Sub = dict( + is_a = "binop" ), -Alloc = dict( - ins = [ "mem", "size" ], - outs = [ "M", "X_regular", "X_except", "res" ], - attrs = [ - dict( - name = "type", - type = "ir_type*" - ), +SymConst = dict( + mode = "mode_P", + knownBlock = True, + noconstr = True, + attrs = [ dict( - name = "where", - type = "ir_where_alloc" + type = "ir_entity*", + name = "entity" ) - ] + ], ), -Free = dict( - ins = [ "mem", "ptr", "size" ], - mode = "mode_M", - attrs = [ - dict( - name = "type", - type = "ir_type*" - ), - dict( - name = "where", - type = "ir_where_alloc" - ) - ] +Sync = dict( + mode = "mode_M", + optimize = False, + arity = "dynamic" +), + +Tuple = dict( + arity = "variable", + mode = "mode_T", +), + +Unknown = dict( + knownBlock = True, + block = "get_irg_start_block(irg)", + nodbginfo = True ), )