Example #1
0
			abstract_nodes.append(node)
		else:
			real_nodes.append(node)
			_preprocess_node(node)

	return (real_nodes, abstract_nodes)

def is_dynamic_pinned(node):
	return node.pinned == "exception"

def is_fragile(node):
	return "fragile" in node.flags

def inout_contains(l, name):
	for entry in l:
		if entry.name == name:
			return True
	return False

def collect_ops(moduledict):
	return [node for node in moduledict.values() if is_op(node) ]

def verify_spec(spec):
	if len(spec.nodes) == 0:
		sys.stderr.write("Warning: No nodes found in spec\n")
	if not hasattr(spec, "name"):
		sys.stderr.write("Warning: No name specified in node spec\n")

export(is_dynamic_pinned)
export(is_abstract)
Example #2
0
    This is needed to implement optimizations that remove a node that produced
    a tuple.  The node can be replaced by the Tuple operation so that the
    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 its opcode and giving it a new in array."""
    arity = "variable"
    input_name = "pred"
    mode = "mode_T"
    flags = []


@op
class Unknown(Node):
    """Returns an unknown (at compile- and runtime) value. It is a valid
    optimization to replace an Unknown by any other constant value.

    Be careful when optimising Unknown values, you cannot simply replace
    Unknown+x or Unknown<x with a new Unknown node if there are multiple
    users of the original unknown node!"""
    pinned = "yes"
    flags = ["start_block", "constlike", "dump_noblock"]


name = "ir"
(nodes, abstract_nodes) = prepare_nodes(globals())
export(nodes, "nodes")
export(abstract_nodes, "abstract_nodes")
export(globals(), "spec")
Example #3
0

def is_dynamic_pinned(node):
    return node.pinned == "exception"


def is_fragile(node):
    return "fragile" in node.flags


def inout_contains(l, name):
    for entry in l:
        if entry.name == name:
            return True
    return False


def collect_ops(moduledict):
    return [node for node in moduledict.values() if is_op(node)]


def verify_spec(spec):
    if len(spec.nodes) == 0:
        sys.stderr.write("Warning: No nodes found in spec\n")
    if not hasattr(spec, "name"):
        sys.stderr.write("Warning: No name specified in node spec\n")


export(is_dynamic_pinned)
export(is_abstract)
Example #4
0
from datetime import datetime
import re

def filtjoin(string, joinstring):
	args = re.split('\s*\n\s*', string)
	if args[0] == '':
		args = args[1:]
	if len(args) > 0 and args[-1] == '':
		args = args[:-1]
	return joinstring.join(args)

def arguments(string, voidwhenempty = False):
	joined = filtjoin(string, ", ")
	if joined == "" and voidwhenempty:
		return "void"
	return joined

def hasnot(plist, flag):
	return list(filter(lambda x: not hasattr(x, flag) or not getattr(x, flag), plist))

def has(plist, flag):
	return list(filter(lambda x: hasattr(x, flag) and getattr(x, flag), plist))

for f in [filtjoin, arguments, hasnot, has]:
	export_filter(f)

export(len)
export(hasattr)
export("/* Warning: Automatically generated file */", "warning")
export(datetime.now().replace(microsecond=0).isoformat(' '), "time")
Example #5
0
from oo_nodes_spec import nodes, abstract_nodes
from javabits import preprocess_node
from jinjautil import export

java_binding = "firm.bindings.binding_nodes"
java_package = "firm.oo.nodes"
export(java_package, "java_package")
export(java_binding, "java_binding")

for node in nodes + abstract_nodes:
    preprocess_node(node)
Example #6
0
    if len(args) > 0 and args[-1] == '':
        args = args[:-1]
    return joinstring.join(args)


def arguments(string, voidwhenempty=False):
    joined = filtjoin(string, ", ")
    if joined == "" and voidwhenempty:
        return "void"
    return joined


def hasnot(plist, flag):
    def prop(x):
        return not hasattr(x, flag) or not getattr(x, flag)

    return list(filter(prop, plist))


def has(plist, flag):
    return list(filter(lambda x: hasattr(x, flag) and getattr(x, flag), plist))


for f in [filtjoin, arguments, hasnot, has]:
    export_filter(f)

export(len)
export(hasattr)
export("/* Warning: Automatically generated file */", "warning")
export(datetime.now().replace(microsecond=0).isoformat(' '), "time")
Example #7
0
from oo_nodes_spec import nodes, abstract_nodes
from javabits import preprocess_node
from jinjautil import export

java_binding = "firm.bindings.binding_nodes"
java_package = "firm.oo.nodes"
export(java_package, "java_package")
export(java_binding, "java_binding")

for node in nodes+abstract_nodes:
	preprocess_node(node)