- removed needless cast
[libfirm] / scripts / ir_spec.py
index 4137a12..fd4ed32 100755 (executable)
@@ -36,15 +36,19 @@ Alloc = 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",
-       ins        = [ "end_block", "start_block", "end", "start",
-                      "end_reg", "end_except", "initial_exec",
-                                  "frame", "tls", "initial_mem", "args",
-                                  "bad", "no_mem" ],
+       arity      = "variable",
        knownBlock = True,
        noconstr   = True
 ),
@@ -131,13 +135,35 @@ 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"
 ),
 
+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",
@@ -151,7 +177,14 @@ Builtin = dict(
                        type = "ir_type*",
                        name = "type"
                )
-       ]
+       ],
+       pinned      = "memory",
+       pinned_init = "pinned",
+       init   = '''
+       assert((get_unknown_type() == type) || is_Method_type(type));
+       '''
+
+       # TODO: No firm_alloc_frag_arr??
 ),
 
 Call = dict(
@@ -163,7 +196,17 @@ 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
+       '''
 ),
 
 Carry = dict(
@@ -255,21 +298,25 @@ CopyB = 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
+       '''
 ),
 
 Div = dict(
-       ins   = [ "mem", "dividend", "divisor" ],
+       ins   = [ "mem", "left", "right" ],
        outs  = [ "M", "X_regular", "X_except", "res" ],
+       attrs_name = "divmod",
        attrs = [
                dict(
                        type = "ir_mode*",
                        name = "resmode"
                ),
-               dict(
-                       name = "state",
-                       type = "op_pin_state"
-               ),
                dict(
                        name = "no_remainder",
                        type = "int",
@@ -279,28 +326,37 @@ Div = dict(
                                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", "dividend", "divisor" ],
+       ins   = [ "mem", "left", "right" ],
        outs  = [ "M", "X_regular", "X_except", "res_div", "res_mod" ],
+       attrs_name = "divmod",
        attrs = [
                dict(
                        type = "ir_mode*",
                        name = "resmode"
                ),
-               dict(
-                       name = "state",
-                       type = "op_pin_state"
-               )
-       ]
+       ],
+       pinned = "exception",
+       d_post = '''
+       #if PRECISE_EXC_CONTEXT
+       firm_alloc_frag_arr(res, op_DivMod, &res->attr.except.frag_arr);
+       #endif
+       '''
 ),
 
 End = dict(
        mode       = "mode_X",
        op_flags   = "cfopcode",
-       state      = "pinned",
+       pinned     = "yes",
        arity      = "dynamic",
        noconstr   = True,
        optimize   = False
@@ -310,6 +366,20 @@ Eor = dict(
        is_a     = "binop"
 ),
 
+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)));
+),
+
 Free = dict(
        ins   = [ "mem", "ptr", "size" ],
        mode  = "mode_M",
@@ -332,14 +402,27 @@ Id = dict(
 IJmp = dict(
        mode     = "mode_X",
        op_flags = "cfopcode",
-       state    = "pinned",
+       pinned   = "yes",
        ins      = [ "target" ],
 ),
 
+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",
-       state    = "pinned",
+       pinned   = "yes",
        ins      = [],
 ),
 
@@ -371,18 +454,21 @@ Minus = dict(
 ),
 
 Mod = dict(
-       ins   = [ "mem", "dividend", "divisor" ],
+       ins   = [ "mem", "left", "right" ],
        outs  = [ "M", "X_regular", "X_except", "res" ],
+       attrs_name = "divmod",
        attrs = [
                dict(
                        type = "ir_mode*",
                        name = "resmode"
                ),
-               dict(
-                       name = "state",
-                       type = "op_pin_state"
-               )
-       ]
+       ],
+       pinned = "exception",
+       d_post = '''
+       #if PRECISE_EXC_CONTEXT
+       firm_alloc_frag_arr(res, op_Mod, &res->attr.except.frag_arr);
+       #endif
+       '''
 ),
 
 Mul = dict(
@@ -412,7 +498,7 @@ Or = dict(
 
 Phi = dict(
        noconstr = True,
-       state    = "pinned",
+       pinned   = "yes",
        arity    = "variable",
 ),
 
@@ -433,18 +519,26 @@ Proj = dict(
 ),
 
 Quot = dict(
-       ins   = [ "mem", "dividend", "divisor" ],
+       ins   = [ "mem", "left", "right" ],
        outs  = [ "M", "X_regular", "X_except", "res" ],
+       attrs_name = "divmod",
        attrs = [
                dict(
                        type = "ir_mode*",
                        name = "resmode"
                ),
-               dict(
-                       name = "state",
-                       type = "op_pin_state"
-               )
-       ]
+       ],
+       pinned = "exception",
+       d_post = '''
+       #if PRECISE_EXC_CONTEXT
+       firm_alloc_frag_arr(res, op_Quot, &res->attr.except.frag_arr);
+       #endif
+       '''
+),
+
+Raise = dict(
+       ins   = [ "mem", "exo_ptr" ],
+       outs  = [ "M", "X" ]
 ),
 
 Return = dict(
@@ -484,7 +578,7 @@ Shrs = dict(
 Start = dict(
        mode       = "mode_T",
        op_flags   = "cfopcode",
-       state      = "pinned",
+       pinned     = "yes",
        noconstr   = True,
        optimize   = False
 ),