always transform integer abs, even in GRAPH_STATE_KEEP_MUX
[libfirm] / scripts / ir_spec.py
index 7f55e91..2ab4c8a 100755 (executable)
@@ -38,10 +38,10 @@ class Alloc(Op):
                ("count", "number of objects to allocate" ),
        ]
        outs  = [
-               ("M",         "memory result",                         "pn_Generic_M"),
-               ("X_regular", "control flow when no exception occurs", "pn_Generic_X_regular"),
-               ("X_except",  "control flow when exception occured",   "pn_Generic_X_except"),
-               ("res",       "pointer to newly allocated memory",     "pn_Generic_other"),
+               ("M",         "memory result"),
+               ("X_regular", "control flow when no exception occurs"),
+               ("X_except",  "control flow when exception occured"),
+               ("res",       "pointer to newly allocated memory"),
        ]
        attrs = [
                dict(
@@ -56,7 +56,8 @@ class Alloc(Op):
                )
        ]
        flags       = [ "fragile", "uses_memory" ]
-       pinned      = "yes"
+       pinned      = "exception"
+       pinned_init = "op_pin_state_pinned"
        attr_struct = "alloc_attr"
 
 class Anchor(Op):
@@ -146,12 +147,10 @@ class Bad(Op):
        they are set to Bad, and the actual removal is left to the control flow
        optimisation phase. Block, Phi, Tuple with only Bad inputs however are
        replaced by Bad right away."""
-       mode          = "mode_T"
-       flags         = [ "cfopcode", "start_block", "dump_noblock" ]
+       flags         = [ "start_block", "dump_noblock" ]
        pinned        = "yes"
        knownBlock    = True
        block         = "get_irg_start_block(irg)"
-       singleton     = True
        attr_struct   = "bad_attr"
        init = '''
        res->attr.bad.irg.irg = irg;
@@ -203,10 +202,10 @@ class Bound(Op):
                ("upper",  "upper bound (exclusive)"),
        ]
        outs  = [
-               ("M",         "memory result",                         "pn_Generic_M"),
-               ("X_regular", "control flow when no exception occurs", "pn_Generic_X_regular"),
-               ("X_except",  "control flow when exception occured",   "pn_Generic_X_except"),
-               ("res",       "the checked index",                     "pn_Generic_other"),
+               ("M",         "memory result"),
+               ("X_regular", "control flow when no exception occurs"),
+               ("X_except",  "control flow when exception occured"),
+               ("res",       "the checked index"),
        ]
        flags  = [ "fragile", "highlevel" ]
        pinned = "exception"
@@ -221,8 +220,8 @@ class Builtin(Op):
        ]
        arity    = "variable"
        outs     = [
-               ("M",        "memory result", "pn_Generic_M"),
-               ("1_result", "first result",  "pn_Generic_other"),
+               ("M",        "memory result"),
+               ("1_result", "first result"),
        ]
        flags    = [ "uses_memory" ]
        attrs    = [
@@ -255,11 +254,10 @@ class Call(Op):
        ]
        arity    = "variable"
        outs     = [
-               ("M",                "memory result",                         "pn_Generic_M"),
-               ("X_regular",        "control flow when no exception occurs", "pn_Generic_X_regular"),
-               ("X_except",         "control flow when exception occured",   "pn_Generic_X_except"),
-               ("T_result",         "tuple containing all results",          "pn_Generic_other"),
-               ("P_value_res_base", "pointer to memory register containing copied results passed by value"),
+               ("M",                "memory result"),
+               ("X_regular",        "control flow when no exception occurs"),
+               ("X_except",         "control flow when exception occured"),
+               ("T_result",         "tuple containing all results"),
        ]
        flags    = [ "fragile", "uses_memory" ]
        attrs    = [
@@ -302,7 +300,7 @@ class Cast(Unop):
        init     = "assert(is_atomic_type(type));"
 
 class Cmp(Binop):
-       """Compares its two operands and checks wether a specified
+       """Compares its two operands and checks whether a specified
           relation (like less or equal) is fulfilled."""
        flags = []
        mode  = "mode_b"
@@ -420,9 +418,9 @@ class CopyB(Op):
                ("src",  "source address"),
        ]
        outs  = [
-               ("M",         "memory result",                         "pn_Generic_M"),
-               ("X_regular", "control flow when no exception occurs", "pn_Generic_X_regular"),
-               ("X_except",  "control flow when exception occured",   "pn_Generic_X_except"),
+               ("M",         "memory result"),
+               ("X_regular", "control flow when no exception occurs"),
+               ("X_except",  "control flow when exception occured"),
        ]
        flags = [ "fragile", "uses_memory" ]
        attrs = [
@@ -445,10 +443,10 @@ class Div(Op):
                ("right", "second operand"),
        ]
        outs  = [
-               ("M",         "memory result",                         "pn_Generic_M"),
-               ("X_regular", "control flow when no exception occurs", "pn_Generic_X_regular"),
-               ("X_except",  "control flow when exception occured",   "pn_Generic_X_except"),
-               ("res",       "result of computation",                 "pn_Generic_other"),
+               ("M",         "memory result"),
+               ("X_regular", "control flow when no exception occurs"),
+               ("X_except",  "control flow when exception occured"),
+               ("res",       "result of computation"),
        ]
        flags = [ "fragile", "uses_memory" ]
        attrs_name = "div"
@@ -536,19 +534,19 @@ class IJmp(Op):
        ins      = [
           ("target", "target address of the jump"),
        ]
-       flags    = [ "cfopcode", "forking", "keep" ]
+       flags    = [ "cfopcode", "forking", "keep", "unknown_jump" ]
 
 class InstOf(Op):
-       """Tests wether an object is an instance of a class-type"""
+       """Tests whether an object is an instance of a class-type"""
        ins   = [
           ("store", "memory dependency"),
           ("obj",   "pointer to object being queried")
        ]
        outs  = [
-               ("M",         "memory result",                         "pn_Generic_M"),
-               ("X_regular", "control flow when no exception occurs", "pn_Generic_X_regular"),
-               ("X_except",  "control flow when exception occured",   "pn_Generic_X_except"),
-               ("res",       "checked object pointer",                "pn_Generic_other"),
+               ("M",         "memory result"),
+               ("X_regular", "control flow when no exception occurs"),
+               ("X_except",  "control flow when exception occured"),
+               ("res",       "checked object pointer"),
        ]
        flags = [ "highlevel" ]
        attrs = [
@@ -576,10 +574,10 @@ class Load(Op):
                ("ptr",  "address to load from"),
        ]
        outs  = [
-               ("M",         "memory result",                         "pn_Generic_M"),
-               ("X_regular", "control flow when no exception occurs", "pn_Generic_X_regular"),
-               ("X_except",  "control flow when exception occured",   "pn_Generic_X_except"),
-               ("res",       "result of load operation",              "pn_Generic_other"),
+               ("M",         "memory result"),
+               ("X_regular", "control flow when no exception occurs"),
+               ("X_except",  "control flow when exception occured"),
+               ("res",       "result of load operation"),
        ]
        flags    = [ "fragile", "uses_memory" ]
        pinned   = "exception"
@@ -587,9 +585,20 @@ class Load(Op):
                dict(
                        type      = "ir_mode*",
                        name      = "mode",
-                       java_name = "load_mode",
                        comment   = "mode of the value to be loaded",
                ),
+               dict(
+                       type      = "ir_volatility",
+                       name      = "volatility",
+                       comment   = "volatile loads are a visible side-effect and may not be optimized",
+                       init      = "flags & cons_volatile ? volatility_is_volatile : volatility_non_volatile",
+               ),
+               dict(
+                       type      = "ir_align",
+                       name      = "unaligned",
+                       comment   = "pointers to unaligned loads don't need to respect the load-mode/type alignments",
+                       init      = "flags & cons_unaligned ? align_non_aligned : align_is_aligned",
+               ),
        ]
        attr_struct = "load_attr"
        constructor_args = [
@@ -600,10 +609,6 @@ class Load(Op):
                ),
        ]
        pinned_init = "flags & cons_floats ? op_pin_state_floats : op_pin_state_pinned"
-       init = '''
-       res->attr.load.volatility = flags & cons_volatile ? volatility_is_volatile : volatility_non_volatile;
-       res->attr.load.aligned = flags & cons_unaligned ? align_non_aligned : align_is_aligned;
-       '''
 
 class Minus(Unop):
        """returns the difference between its operands"""
@@ -624,10 +629,10 @@ class Mod(Op):
                ("right", "second operand"),
        ]
        outs  = [
-               ("M",         "memory result",                         "pn_Generic_M"),
-               ("X_regular", "control flow when no exception occurs", "pn_Generic_X_regular"),
-               ("X_except",  "control flow when exception occured",   "pn_Generic_X_except"),
-               ("res",       "result of computation",                 "pn_Generic_other"),
+               ("M",         "memory result"),
+               ("X_regular", "control flow when no exception occurs"),
+               ("X_except",  "control flow when exception occured"),
+               ("res",       "result of computation"),
        ]
        flags = [ "fragile", "uses_memory" ]
        attrs_name = "mod"
@@ -739,8 +744,8 @@ class Raise(Op):
                ("exo_ptr", "pointer to exception object to be thrown"),
        ]
        outs  = [
-               ("M", "memory result",                     "pn_Generic_M"),
-               ("X", "control flow to exception handler", "pn_Generic_X_regular"),
+               ("M", "memory result"),
+               ("X", "control flow to exception handler"),
        ]
        flags  = [ "highlevel", "cfopcode" ]
        pinned = "yes"
@@ -803,7 +808,6 @@ class Start(Op):
                ("X_initial_exec", "control flow"),
                ("M",              "initial memory"),
                ("P_frame_base",   "frame base pointer"),
-               ("P_tls",          "pointer to thread local storage segment"),
                ("T_args",         "function arguments")
        ]
        mode             = "mode_T"
@@ -822,14 +826,28 @@ class Store(Op):
           ("value", "value to store"),
        ]
        outs  = [
-               ("M",         "memory result",                         "pn_Generic_M"),
-               ("X_regular", "control flow when no exception occurs", "pn_Generic_X_regular"),
-               ("X_except",  "control flow when exception occured",   "pn_Generic_X_except"),
+               ("M",         "memory result"),
+               ("X_regular", "control flow when no exception occurs"),
+               ("X_except",  "control flow when exception occured"),
        ]
        flags    = [ "fragile", "uses_memory" ]
        pinned   = "exception"
        attr_struct = "store_attr"
        pinned_init = "flags & cons_floats ? op_pin_state_floats : op_pin_state_pinned"
+       attrs = [
+               dict(
+                       type      = "ir_volatility",
+                       name      = "volatility",
+                       comment   = "volatile stores are a visible side-effect and may not be optimized",
+                       init      = "flags & cons_volatile ? volatility_is_volatile : volatility_non_volatile",
+               ),
+               dict(
+                       type      = "ir_align",
+                       name      = "unaligned",
+                       comment   = "pointers to unaligned stores don't need to respect the load-mode/type alignments",
+                       init      = "flags & cons_unaligned ? align_non_aligned : align_is_aligned",
+               ),
+       ]
        constructor_args = [
                dict(
                        type    = "ir_cons_flags",
@@ -837,10 +855,6 @@ class Store(Op):
                        comment = "specifies alignment, volatility and pin state",
                ),
        ]
-       init = '''
-       res->attr.store.volatility = flags & cons_volatile ? volatility_is_volatile : volatility_non_volatile;
-       res->attr.store.aligned = flags & cons_unaligned ? align_non_aligned : align_is_aligned;
-       '''
 
 class Sub(Binop):
        """returns the difference of its operands"""
@@ -901,7 +915,7 @@ class Tuple(Op):
        following Proj nodes have not to be changed. (They are hard to find due to
        the implementation with pointers in only one direction.) The Tuple node is
        smaller than any other node, so that a node can be changed into a Tuple by
-       just changing it's opcode and giving it a new in array."""
+       just changing its opcode and giving it a new in array."""
        arity  = "variable"
        mode   = "mode_T"
        pinned = "no"
@@ -913,7 +927,7 @@ class Unknown(Op):
        knownBlock = True
        pinned     = "yes"
        block      = "get_irg_start_block(irg)"
-       flags      = [ "cfopcode", "start_block", "constlike", "dump_noblock" ]
+       flags      = [ "start_block", "constlike", "dump_noblock" ]
 
 # Prepare node list