Commit d556fd12 authored by Matthias Braun's avatar Matthias Braun
Browse files

redo pinned mode handling in spec generator

[r25887]
parent 581e5849
......@@ -2,6 +2,7 @@
import sys
from jinja2 import Environment, Template
from jinja2.filters import do_dictsort
from spec_util import is_dynamic_pinned, verify_node
import ir_spec
def format_argdecls(node, first = False, voidwhenempty = False):
......@@ -138,6 +139,10 @@ def preprocess_node(nodename, node):
node.setdefault("constructor_args", [])
node.setdefault("attrs_name", nodename.lower())
node.setdefault("block", "block")
node.setdefault("pinned", "no")
verify_node(node)
# construct node arguments
arguments = [ ]
......@@ -196,6 +201,25 @@ def preprocess_node(nodename, node):
elif not "init" in attr:
arguments.append(prepare_attr(attr))
# dynamic pin state means more constructor arguments
if is_dynamic_pinned(node):
if "pinned_init" in node:
initattrs.append(dict(
initname = ".exc.pin_state",
init = "op_pin_state_" + node["pinned_init"]
))
else:
node["constructor_args"].append(
dict(
name = "pin_state",
type = "op_pin_state"
)
)
initattrs.append(dict(
initname = ".exc.pin_state",
init = "pin_state"
))
for arg in node["constructor_args"]:
arguments.append(prepare_attr(arg))
if arg["type"] == "ir_cons_flags":
......
......@@ -2,6 +2,7 @@
import sys
from jinja2 import Environment, Template
from jinja2.filters import do_dictsort
from spec_util import is_dynamic_pinned, verify_node
import ir_spec
def format_args(arglist):
......@@ -82,54 +83,6 @@ def get_io_type(type, attrname, nodename):
exportcmd = "// BAD: %s" % type
return (importcmd, exportcmd)
""" if type == "ir_type*":
java_type = "firm.Type"
wrap_type = "Pointer"
to_wrapper = "%s.ptr"
from_wrapper = "firm.Type.createWrapper(%s)"
elif type == "ir_mode*":
java_type = "firm.Mode"
wrap_type = "Pointer"
to_wrapper = "%s.ptr"
from_wrapper = "new firm.Mode(%s)"
elif type == "tarval*":
java_type = "firm.TargetValue"
wrap_type = "Pointer"
to_wrapper = "%s.ptr"
from_wrapper = "new firm.TargetValue(%s)"
elif type == "pn_Cmp":
java_type = "int"
wrap_type = "int"
to_wrapper = "%s"
from_wrapper = "%s"
elif type == "long":
java_type = "int"
wrap_type = "com.sun.jna.NativeLong"
to_wrapper = "new com.sun.jna.NativeLong(%s)"
from_wrapper = "%s.intValue()"
elif type == "cons_flags":
java_type = "firm.bindings.binding_ircons.ir_cons_flags"
wrap_type = "int"
to_wrapper = "%s.val"
from_wrapper = "firm.bindings.binding_ircons.ir_cons_flags.getEnum(%s)"
elif type == "ir_where_alloc":
java_type = "firm.bindings.binding_ircons.ir_where_alloc"
wrap_type = "int"
to_wrapper = "%s.val"
from_wrapper = "firm.bindings.binding_ircons.ir_where_alloc.getEnum(%s)"
elif type == "ir_entity*":
java_type = "firm.Entity"
wrap_type = "Pointer"
to_wrapper = "%s.ptr"
from_wrapper = "new firm.Entity(%s)"
else:
print "UNKNOWN TYPE"
java_type = "BAD"
wrap_type = "BAD"
to_wrapper = "BAD"
from_wrapper = "BAD"
return (java_type,wrap_type,to_wrapper,from_wrapper)"""
def prepare_attr(nodename, attr):
(importcmd,exportcmd) = get_io_type(attr["type"], attr["name"], nodename)
attr["importcmd"] = importcmd
......@@ -151,6 +104,19 @@ def preprocess_node(nodename, node):
node["attrs"] = []
if "constructor_args" not in node:
node["constructor_args"] = []
if "pinned" not in node:
node["pinned"] = "no"
# dynamic pin state means, we have to im/export that
if is_dynamic_pinned(node):
newattr = dict(
name = "state",
type = "op_pin_state"
)
if "pinned_init" in node:
newattr["init"] = node["pinned_init"]
node["attrs"].append(newattr)
verify_node(node)
# construct node arguments
arguments = [ ]
......
......@@ -28,12 +28,6 @@ Alloc = dict(
ins = [ "mem", "size" ],
outs = [ "M", "X_regular", "X_except", "res" ],
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 +37,8 @@ Alloc = dict(
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);
......@@ -52,10 +48,7 @@ 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" ],
arity = "variable",
knownBlock = True,
noconstr = True
),
......@@ -150,16 +143,10 @@ Borrow = dict(
),
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" ],
pinned = "exception",
pinned_init = "pinned",
d_post = '''
#if PRECISE_EXC_CONTEXT
firm_alloc_frag_arr(res, op_Bound, &res->attr.bound.exc.frag_arr);
......@@ -177,12 +164,6 @@ 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"
......@@ -192,7 +173,9 @@ Builtin = dict(
name = "type"
)
],
init = '''
pinned = "memory",
pinned_init = "pinned",
init = '''
assert((get_unknown_type() == type) || is_Method_type(type));
'''
......@@ -204,17 +187,13 @@ Call = 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_type*",
name = "type"
)
],
pinned = "memory",
pinned_init = "pinned",
init = '''
assert((get_unknown_type() == type) || is_Method_type(type));
''',
......@@ -310,17 +289,13 @@ CopyB = dict(
ins = [ "mem", "dst", "src" ],
outs = [ "M", "X_regular", "X_except" ],
attrs = [
dict(
name = "state",
type = "op_pin_state",
initname = ".exc.pin_state",
init = "op_pin_state_pinned"
),
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);
......@@ -337,11 +312,6 @@ Div = 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 +322,7 @@ Div = dict(
)
)
],
pinned = "exception",
d_post = '''
#if PRECISE_EXC_CONTEXT
firm_alloc_frag_arr(res, op_Div, &res->attr.except.frag_arr);
......@@ -368,12 +339,8 @@ DivMod = dict(
type = "ir_mode*",
name = "resmode"
),
dict(
name = "state",
type = "op_pin_state",
initname = ".exc.pin_state"
)
],
pinned = "exception",
d_post = '''
#if PRECISE_EXC_CONTEXT
firm_alloc_frag_arr(res, op_DivMod, &res->attr.except.frag_arr);
......@@ -384,7 +351,7 @@ DivMod = dict(
End = dict(
mode = "mode_X",
op_flags = "cfopcode",
state = "pinned",
pinned = "yes",
arity = "dynamic",
noconstr = True,
optimize = False
......@@ -430,7 +397,7 @@ Id = dict(
IJmp = dict(
mode = "mode_X",
op_flags = "cfopcode",
state = "pinned",
pinned = "yes",
ins = [ "target" ],
),
......@@ -438,25 +405,19 @@ InstOf = dict(
ins = [ "store", "objptr" ],
outs = [ "M", "X_regular", "X_except", "res", "M_except" ],
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???
],
pinned = "memory",
pinned_init = "floats",
),
Jmp = dict(
mode = "mode_X",
op_flags = "cfopcode",
state = "pinned",
pinned = "yes",
ins = [],
),
......@@ -496,12 +457,8 @@ Mod = dict(
type = "ir_mode*",
name = "resmode"
),
dict(
name = "state",
type = "op_pin_state",
initname = ".exc.pin_state"
)
],
pinned = "exception",
d_post = '''
#if PRECISE_EXC_CONTEXT
firm_alloc_frag_arr(res, op_Mod, &res->attr.except.frag_arr);
......@@ -536,7 +493,7 @@ Or = dict(
Phi = dict(
noconstr = True,
state = "pinned",
pinned = "yes",
arity = "variable",
),
......@@ -565,12 +522,8 @@ Quot = dict(
type = "ir_mode*",
name = "resmode"
),
dict(
name = "state",
type = "op_pin_state",
initname = ".exc.pin_state"
)
],
pinned = "exception",
d_post = '''
#if PRECISE_EXC_CONTEXT
firm_alloc_frag_arr(res, op_Quot, &res->attr.except.frag_arr);
......@@ -620,7 +573,7 @@ Shrs = dict(
Start = dict(
mode = "mode_T",
op_flags = "cfopcode",
state = "pinned",
pinned = "yes",
noconstr = True,
optimize = False
),
......
def is_dynamic_pinned(node):
return node["pinned"] in ["memory", "exception"]
def verify_node(node):
if node["pinned"] not in ["yes", "no", "memory", "exception"]:
print "UNKNOWN PINNED MODE: %s" % node["pinned"]
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment