more fixes (sorry for the breakages...)
[libfirm] / scripts / ir_spec.py
index 365855e..77444d2 100755 (executable)
@@ -5,35 +5,36 @@ nodes = dict(
 #
 unop = dict(
        abstract = True,
-       ins      = [ "op" ]
+       ins      = [ "op" ],
+       op_index = 0,
+       pinned   = "no",
 ),
 
 binop = dict(
        abstract = True,
-       ins      = [ "left", "right" ]
+       ins      = [ "left", "right" ],
+       op_index = 0,
+       pinned   = "no",
 ),
 
 #
 # Real node types
 #
 Abs = dict(
-       is_a     = "unop"
+       is_a     = "unop",
+       flags    = "none",
 ),
 
 Add = dict(
-       is_a     = "binop"
+       is_a     = "binop",
+       flags    = "commutative",
 ),
 
 Alloc = dict(
        ins   = [ "mem", "size" ],
        outs  = [ "M", "X_regular", "X_except", "res" ],
+       flags = "fragile, uses_memory",
        attrs = [
-               dict(
-                       name = "state",
-                       type = "op_pin_state",
-                       initname = ".exc.pin_state",
-                       init = "op_pin_state_pinned"
-               ),
                dict(
                        name = "type",
                        type = "ir_type*"
@@ -43,6 +44,8 @@ Alloc = dict(
                        type = "ir_where_alloc"
                )
        ],
+       pinned      = "yes",
+       attr_struct = "alloc_attr",
        d_post = '''
        #if PRECISE_EXC_CONTEXT
        firm_alloc_frag_arr(res, op_Alloc, &res->attr.alloc.exc.frag_arr);
@@ -51,31 +54,73 @@ Alloc = dict(
 ),
 
 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
+       mode        = "mode_ANY",
+       arity       = "variable",
+       flags       = "dump_noblock",
+       pinned      = "yes",
+       knownBlock  = True,
+       singleton   = True,
 ),
 
 And = dict(
-       is_a     = "binop"
+       is_a     = "binop",
+       flags    = "commutative",
+),
+
+ASM = dict(
+       mode          = "mode_T",
+       arity         = "variable",
+       flags         = "keep, uses_memory",
+       attr_struct   = "asm_attr",
+       pinned        = "memory",
+       pinned_init   = "op_pin_state_pinned",
+       attrs = [
+               dict(
+                       name = "input_constraints",
+                       type = "ir_asm_constraint*",
+               ),
+               dict(
+                       name = "n_output_constraints",
+                       type = "int",
+               ),
+               dict(
+                       name = "output_constraints",
+                       type = "ir_asm_constraint*",
+               ),
+               dict(
+                       name = "n_clobbers",
+                       type = "int",
+               ),
+               dict(
+                       name = "clobbers",
+                       type = "ident**",
+               ),
+               dict(
+                       name = "text",
+                       type = "ident*",
+               ),
+       ],
+       java_noconstr = True,
 ),
 
 Bad = dict(
        mode       = "mode_Bad",
+       flags      = "cfopcode, fragile, start_block, dump_noblock",
+       pinned     = "yes",
        knownBlock = True,
+       singleton  = True,
 ),
 
 Block = dict(
-       mode       = "mode_BB",
-       knownBlock = True,
-       block      = "NULL",
-       noconstr   = True,
-       optimize   = False,
-       arity      = "variable",
+       mode        = "mode_BB",
+       knownBlock  = True,
+       block       = "NULL",
+       pinned      = "yes",
+       optimize    = False,
+       arity       = "variable",
+       flags       = "labeled",
+       attr_struct = "block_attr",
+       java_noconstr = True,
 
        init = '''
        /* macroblock header */
@@ -142,24 +187,26 @@ Block = dict(
 
        public void markBlockVisited() {
                binding.mark_Block_block_visited(ptr);
-       }''',
+       }
+
+       public boolean isBad() {
+               return binding.is_Bad(ptr) != 0;
+       }
+       ''',
 ),
 
 Borrow = dict(
-       is_a     = "binop"
+       is_a     = "binop",
+       flags    = "none",
 ),
 
 Bound = dict(
-       ins   = [ "mem", "index", "lower", "upper" ],
-       outs  = [ "M", "X_regular", "X_except", "res" ],
-       attrs = [
-               dict(
-                       name = "state",
-                       type = "op_pin_state",
-                       initname = ".exc.pin_state",
-                       init = "op_pin_state_pinned"
-               )
-       ],
+       ins    = [ "mem", "index", "lower", "upper" ],
+       outs   = [ "M", "X_regular", "X_except", "res" ],
+       flags  = "fragile, highlevel",
+       pinned = "exception",
+       pinned_init = "op_pin_state_pinned",
+       attr_struct = "bound_attr",
        d_post = '''
        #if PRECISE_EXC_CONTEXT
        firm_alloc_frag_arr(res, op_Bound, &res->attr.bound.exc.frag_arr);
@@ -167,22 +214,18 @@ Bound = dict(
        '''
 ),
 
-
 Break = dict(
-       mode = "mode_X"
+       mode   = "mode_X",
+       flags  = "cfopcode",
+       pinned = "yes",
 ),
 
 Builtin = dict(
        ins      = [ "mem" ],
        arity    = "variable",
        outs     = [ "M_regular", "X_regular", "X_except", "T_result", "M_except", "P_value_res_base" ],
+       flags    = "uses_memory",
        attrs    = [
-               dict(
-                       name = "state",
-                       type = "op_pin_state",
-                       initname = ".exc.pin_state",
-                       init = "op_pin_state_pinned"
-               ),
                dict(
                        type = "ir_builtin_kind",
                        name = "kind"
@@ -192,7 +235,10 @@ Builtin = dict(
                        name = "type"
                )
        ],
-       init = '''
+       pinned      = "memory",
+       pinned_init = "op_pin_state_pinned",
+       attr_struct = "builtin_attr",
+       init   = '''
        assert((get_unknown_type() == type) || is_Method_type(type));
        '''
 
@@ -203,18 +249,16 @@ Call = dict(
        ins      = [ "mem", "ptr" ],
        arity    = "variable",
        outs     = [ "M_regular", "X_regular", "X_except", "T_result", "M_except", "P_value_res_base" ],
+       flags    = "fragile, uses_memory",
        attrs    = [
-               dict(
-                       name = "state",
-                       type = "op_pin_state",
-                       initname = ".exc.pin_state",
-                       init = "op_pin_state_pinned"
-               ),
                dict(
                        type = "ir_type*",
                        name = "type"
                )
        ],
+       attr_struct = "call_attr",
+       pinned      = "memory",
+       pinned_init = "op_pin_state_pinned",
        init = '''
        assert((get_unknown_type() == type) || is_Method_type(type));
        ''',
@@ -225,30 +269,50 @@ Call = dict(
        '''
 ),
 
+CallBegin = dict(
+       ins   = [ "ptr" ],
+       outs  = [ "" ], # TODO
+       flags         = "cfopcode, ip_cfopcode",
+       pinned        = "yes",
+       # TODO: attribute with call...
+       attr_struct   = "callbegin_attr",
+       java_noconstr = True,
+       init = '''
+       res->attr.callbegin.call = call;
+       ''',
+),
+
 Carry = dict(
-       is_a     = "binop"
+       is_a     = "binop",
+       flags    = "commutative",
 ),
 
 Cast = dict(
        ins      = [ "op" ],
        mode     = "get_irn_mode(irn_op)",
+       flags    = "highlevel",
+       pinned   = "no",
        attrs    = [
                dict(
                        type = "ir_type*",
                        name = "type"
                )
        ],
+       attr_struct = "cast_attr",
        init     = "assert(is_atomic_type(type));"
 ),
 
 Cmp = dict(
        is_a     = "binop",
        outs     = [ "False", "Eq", "Lt", "Le", "Gt", "Ge", "Lg", "Leg", "Uo", "Ue", "Ul", "Ule", "Ug", "Uge", "Ne", "True" ],
+       flags    = "none",
 ),
 
 Cond = dict(
        ins      = [ "selector" ],
        outs     = [ "false", "true" ],
+       flags    = "cfopcode, forking",
+       pinned   = "yes",
        attrs    = [
                dict(
                        name = "kind",
@@ -265,23 +329,29 @@ Cond = dict(
                        type = "cond_jmp_predicate",
                        init = "COND_JMP_PRED_NONE"
                )
-       ]
+       ],
+       attr_struct = "cond_attr"
 ),
 
 Confirm = dict(
        ins      = [ "value", "bound" ],
        mode     = "get_irn_mode(irn_value)",
+       flags    = "highlevel",
+       pinned   = "yes",
        attrs    = [
                dict(
                        name = "cmp",
                        type = "pn_Cmp"
                ),
        ],
+       attr_struct = "confirm_attr",
 ),
 
 Const = dict(
        mode       = "",
+       flags      = "constlike, start_block",
        knownBlock = True,
+       pinned     = "no",
        attrs_name = "con",
        attrs      = [
                dict(
@@ -289,10 +359,12 @@ Const = dict(
                        name = "tarval",
                )
        ],
+       attr_struct = "const_attr",
 ),
 
 Conv = dict(
        is_a     = "unop",
+       flags    = "none",
        attrs = [
                dict(
                        name = "strict",
@@ -303,24 +375,23 @@ Conv = dict(
                                init = "1"
                        )
                )
-       ]
+       ],
+       attr_struct = "conv_attr",
 ),
 
 CopyB = dict(
        ins   = [ "mem", "dst", "src" ],
        outs  = [ "M", "X_regular", "X_except" ],
+       flags = "fragile, highlevel, uses_memory",
        attrs = [
-               dict(
-                       name = "state",
-                       type = "op_pin_state",
-                       initname = ".exc.pin_state",
-                       init = "op_pin_state_pinned"
-               ),
                dict(
                        name = "type",
                        type = "ir_type*"
                )
        ],
+       attr_struct = "copyb_attr",
+       pinned      = "memory",
+       pinned_init = "op_pin_state_pinned",
        d_post = '''
        #if PRECISE_EXC_CONTEXT
        firm_alloc_frag_arr(res, op_CopyB, &res->attr.copyb.exc.frag_arr);
@@ -329,19 +400,15 @@ CopyB = dict(
 ),
 
 Div = dict(
-       ins   = [ "mem", "dividend", "divisor" ],
+       ins   = [ "mem", "left", "right" ],
        outs  = [ "M", "X_regular", "X_except", "res" ],
+       flags = "fragile, uses_memory",
        attrs_name = "divmod",
        attrs = [
                dict(
                        type = "ir_mode*",
                        name = "resmode"
                ),
-               dict(
-                       name = "state",
-                       type = "op_pin_state",
-                       initname = ".exc.pin_state"
-               ),
                dict(
                        name = "no_remainder",
                        type = "int",
@@ -352,6 +419,9 @@ Div = dict(
                        )
                )
        ],
+       attr_struct = "divmod_attr",
+       pinned      = "exception",
+       op_index    = 1,
        d_post = '''
        #if PRECISE_EXC_CONTEXT
        firm_alloc_frag_arr(res, op_Div, &res->attr.except.frag_arr);
@@ -360,20 +430,19 @@ Div = dict(
 ),
 
 DivMod = dict(
-       ins   = [ "mem", "dividend", "divisor" ],
+       ins   = [ "mem", "left", "right" ],
        outs  = [ "M", "X_regular", "X_except", "res_div", "res_mod" ],
+       flags = "fragile, uses_memory",
        attrs_name = "divmod",
        attrs = [
                dict(
                        type = "ir_mode*",
                        name = "resmode"
                ),
-               dict(
-                       name = "state",
-                       type = "op_pin_state",
-                       initname = ".exc.pin_state"
-               )
        ],
+       attr_struct = "divmod_attr",
+       pinned      = "exception",
+       op_index    = 1,
        d_post = '''
        #if PRECISE_EXC_CONTEXT
        firm_alloc_frag_arr(res, op_DivMod, &res->attr.except.frag_arr);
@@ -381,27 +450,55 @@ DivMod = dict(
        '''
 ),
 
+Dummy = dict(
+       ins   = [],
+       flags = "cfopcode, fragile, start_block, constlike, dump_noblock",
+       knownBlock = True,
+       pinned     = "yes",
+       block      = "get_irg_start_block(irg)",
+),
+
 End = dict(
        mode       = "mode_X",
-       op_flags   = "cfopcode",
-       state      = "pinned",
+       pinned     = "yes",
        arity      = "dynamic",
-       noconstr   = True,
-       optimize   = False
+       flags      = "cfopcode",
+       singleton  = True,
+),
+
+EndExcept = dict(
+       mode      = "mode_X",
+       pinned    = "yes",
+       arity     = "dynamic",
+       flags     = "cfopcode, ip_cfopcode",
+       singleton = True
+),
+
+EndReg = dict(
+       mode      = "mode_X",
+       pinned    = "yes",
+       arity     = "dynamic",
+       flags     = "cfopcode, ip_cfopcode",
+       singleton = True
 ),
 
 Eor = dict(
-       is_a     = "binop"
+       is_a     = "binop",
+       flags    = "commutative",
 ),
 
 Filter = dict(
        ins   = [ "pred" ],
+       flags = "none",
        attrs = [
                dict(
                        name = "proj",
                        type = "long"
                )
-       ]
+       ],
+       pinned      = "yes",
+       attr_struct = "filter_attr",
+       java_noconstr = True
 
        # TODO: Broken asserts in original:
        # assert(get_Proj_pred(res));
@@ -409,9 +506,11 @@ Filter = dict(
 ),
 
 Free = dict(
-       ins   = [ "mem", "ptr", "size" ],
-       mode  = "mode_M",
-       attrs = [
+       ins    = [ "mem", "ptr", "size" ],
+       mode   = "mode_M",
+       flags  = "uses_memory",
+       pinned = "yes",
+       attrs  = [
                dict(
                        name = "type",
                        type = "ir_type*"
@@ -420,49 +519,51 @@ Free = dict(
                        name = "where",
                        type = "ir_where_alloc"
                )
-       ]
+       ],
+       attr_struct = "free_attr",
 ),
 
 Id = dict(
-       ins = [ "pred" ]
+       ins    = [ "pred" ],
+       pinned = "no",
+       flags  = "none",
 ),
 
 IJmp = dict(
        mode     = "mode_X",
-       op_flags = "cfopcode",
-       state    = "pinned",
+       pinned   = "yes",
        ins      = [ "target" ],
+       flags    = "cfopcode, forking, keep",
 ),
 
 InstOf = dict(
-       ins   = [ "store", "objptr" ],
+       ins   = [ "store", "obj" ],
        outs  = [ "M", "X_regular", "X_except", "res", "M_except" ],
+       flags = "highlevel",
        attrs = [
-               dict(
-                       name = "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???
+       ],
+       attr_struct = "io_attr",
+       pinned      = "memory",
+       pinned_init = "op_pin_state_floats",
 ),
 
 Jmp = dict(
        mode     = "mode_X",
-       op_flags = "cfopcode",
-       state    = "pinned",
+       pinned   = "yes",
        ins      = [],
+       flags    = "cfopcode",
 ),
 
 Load = dict(
        ins      = [ "mem", "ptr" ],
        outs     = [ "M", "X_regular", "X_except", "res" ],
+       flags    = "fragile, uses_memory",
+       pinned   = "exception",
+       pinned_init = "flags & cons_floats ? op_pin_state_floats : op_pin_state_pinned",
        attrs    = [
                dict(
                        type = "ir_mode*",
@@ -470,6 +571,7 @@ Load = dict(
                        java_name = "load_mode"
                ),
        ],
+       attr_struct = "load_attr",
        constructor_args = [
                dict(
                        type = "ir_cons_flags",
@@ -484,24 +586,24 @@ Load = dict(
 ),
 
 Minus = dict(
-       is_a     = "unop"
+       is_a     = "unop",
+       flags    = "none",
 ),
 
 Mod = dict(
-       ins   = [ "mem", "dividend", "divisor" ],
+       ins   = [ "mem", "left", "right" ],
        outs  = [ "M", "X_regular", "X_except", "res" ],
+       flags = "fragile, uses_memory",
        attrs_name = "divmod",
        attrs = [
                dict(
                        type = "ir_mode*",
                        name = "resmode"
                ),
-               dict(
-                       name = "state",
-                       type = "op_pin_state",
-                       initname = ".exc.pin_state"
-               )
        ],
+       attr_struct = "divmod_attr",
+       pinned      = "exception",
+       op_index    = 1,
        d_post = '''
        #if PRECISE_EXC_CONTEXT
        firm_alloc_frag_arr(res, op_Mod, &res->attr.except.frag_arr);
@@ -510,67 +612,84 @@ Mod = dict(
 ),
 
 Mul = dict(
-       is_a     = "binop"
+       is_a     = "binop",
+       flags    = "commutative",
 ),
 
 Mulh = dict(
-       is_a     = "binop"
+       is_a     = "binop",
+       flags    = "commutative",
 ),
 
 Mux = dict(
-       ins      = [ "sel", "false", "true" ]
+       ins    = [ "sel", "false", "true" ],
+       flags  = "none",
+       pinned = "no",
 ),
 
 NoMem = dict(
        mode       = "mode_M",
+       flags      = "dump_noblock, dump_noinput",
+       pinned     = "yes",
        knownBlock = True,
+       singleton  = True,
 ),
 
 Not = dict(
-       is_a     = "unop"
+       is_a     = "unop",
+       flags    = "none",
 ),
 
 Or = dict(
-       is_a     = "binop"
+       is_a     = "binop",
+       flags    = "commutative",
 ),
 
 Phi = dict(
-       noconstr = True,
-       state    = "pinned",
-       arity    = "variable",
+       pinned      = "yes",
+       arity       = "variable",
+       flags       = "none",
+       attr_struct = "phi_attr",
+       custom_is   = True,
+       java_noconstr = True,
 ),
 
 Pin = dict(
        ins      = [ "op" ],
-       mode     = "get_irn_mode(irn_op)"
+       mode     = "get_irn_mode(irn_op)",
+       flags    = "highlevel",
+       pinned   = "yes",
 ),
 
 Proj = dict(
        ins      = [ "pred" ],
+       flags    = "none",
+       pinned   = "no",
        attrs    = [
                dict(
                        type = "long",
                        name = "proj",
                        initname = ""
                )
-       ]
+       ],
+       attr_struct = "long",
+       custom_is   = True,
 ),
 
 Quot = dict(
-       ins   = [ "mem", "dividend", "divisor" ],
+       ins   = [ "mem", "left", "right" ],
        outs  = [ "M", "X_regular", "X_except", "res" ],
+       flags = "fragile, uses_memory",
        attrs_name = "divmod",
        attrs = [
                dict(
                        type = "ir_mode*",
                        name = "resmode"
                ),
-               dict(
-                       name = "state",
-                       type = "op_pin_state",
-                       initname = ".exc.pin_state"
-               )
        ],
+       attr_struct = "divmod_attr",
+       pinned      = "exception",
+       op_index    = 1,
        d_post = '''
        #if PRECISE_EXC_CONTEXT
        firm_alloc_frag_arr(res, op_Quot, &res->attr.except.frag_arr);
@@ -579,55 +698,69 @@ Quot = dict(
 ),
 
 Raise = dict(
-       ins   = [ "mem", "exo_ptr" ],
-       outs  = [ "M", "X" ]
+       ins    = [ "mem", "exo_ptr" ],
+       outs   = [ "M", "X" ],
+       flags  = "highlevel, cfopcode",
+       pinned = "yes",
 ),
 
 Return = dict(
        ins      = [ "mem" ],
        arity    = "variable",
-       mode     = "mode_X"
+       mode     = "mode_X",
+       flags    = "cfopcode",
+       pinned   = "yes",
 ),
 
 Rotl = dict(
-       is_a     = "binop"
+       is_a     = "binop",
+       flags    = "none",
 ),
 
 Sel = dict(
        ins    = [ "mem", "ptr" ],
        arity  = "variable",
+       flags  = "none",
        mode   = "is_Method_type(get_entity_type(entity)) ? mode_P_code : mode_P_data",
-       attrs    = [
+       pinned = "no",
+       attrs  = [
                dict(
                        type = "ir_entity*",
                        name = "entity"
                )
-       ]
+       ],
+       attr_struct = "sel_attr",
 ),
 
 Shl = dict(
-       is_a     = "binop"
+       is_a     = "binop",
+       flags    = "none",
 ),
 
 Shr = dict(
-       is_a     = "binop"
+       is_a     = "binop",
+       flags    = "none",
 ),
 
 Shrs = dict(
-       is_a     = "binop"
+       is_a     = "binop",
+       flags    = "none",
 ),
 
 Start = dict(
        mode       = "mode_T",
-       op_flags   = "cfopcode",
-       state      = "pinned",
-       noconstr   = True,
-       optimize   = False
+       pinned     = "yes",
+       flags      = "cfopcode",
+       singleton  = True,
 ),
 
 Store = dict(
        ins      = [ "mem", "ptr", "value" ],
        outs     = [ "M", "X_regular", "X_except" ],
+       flags    = "fragile, uses_memory",
+       pinned   = "exception",
+       attr_struct = "store_attr",
+       pinned_init = "flags & cons_floats ? op_pin_state_floats : op_pin_state_pinned",
        constructor_args = [
                dict(
                        type = "ir_cons_flags",
@@ -642,35 +775,45 @@ Store = dict(
 ),
 
 Sub = dict(
-       is_a     = "binop"
+       is_a     = "binop",
+       flags    = "none",
 ),
 
 SymConst = dict(
        mode       = "mode_P",
+       flags      = "constlike, start_block",
        knownBlock = True,
-       noconstr   = True,
+       pinned     = "no",
        attrs      = [
                dict(
                        type = "ir_entity*",
                        name = "entity"
                )
        ],
+       attr_struct = "symconst_attr",
+       java_noconstr = True,
 ),
 
 Sync = dict(
        mode     = "mode_M",
+       flags    = "none",
+       pinned   = "no",
        optimize = False,
        arity    = "dynamic"
 ),
 
 Tuple = dict(
-       arity    = "variable",
-       mode     = "mode_T",
+       arity  = "variable",
+       mode   = "mode_T",
+       pinned = "no",
+       flags  = "labeled",
+       java_noconstr = True
 ),
 
 Unknown = dict(
        knownBlock = True,
+       pinned     = "yes",
        block      = "get_irg_start_block(irg)",
-       nodbginfo  = True
+       flags      = "cfopcode, fragile, start_block, constlike, dump_noblock",
 ),
 )