Beispiel #1
0
def transformInputSubtree(compiler, dioa, dataflow, subtree, root):
    hyperblock = dataflow.entry.hyperblock
    predicate = dataflow.entryPredicate
    objs = root.annotation.values.flat  # HACK - what about correlation?

    assert len(objs) > 0
    obj = tuple(objs)[0]

    # HACK temporarily ignore correlated objects.
    if len(objs) > 1:
        exprNode = createLocalNode(hyperblock, getName(subtree, root),
                                   root.annotation.values)
        name = exprNode.names[0]
        dataflow.entry.addEntry(name, exprNode)
        subtree.impl = name
    else:
        assert len(objs) == 1
        if intrinsics.isIntrinsicObject(obj):
            exprNode = createLocalNode(hyperblock, getName(subtree, root),
                                       root.annotation.values)
            name = exprNode.names[0]
            dataflow.entry.addEntry(name, exprNode)
            subtree.impl = name

            # Prevent the fields of this object from being transformed
            return exprNode
        else:
            exprNode = allocateObj(dioa, dataflow, subtree, root, obj)

    lut = dataflow.entry.modifies

    # Recurse to each field of this node
    for field, child in subtree.fields.iteritems():
        # Field the field nodes for the field name
        fieldNodes = [lut[o.slots[field]] for o in objs if field in o.slots]

        fieldNode = fieldNodes[0]  # HACK

        # HACK ignore correlated fields
        #if fieldNode.annotation.values.correlated.tree(): continue

        # Create the dataflow store
        valueNode = transformInputSubtree(compiler, dioa, dataflow, child,
                                          fieldNode)

        g = makeStoreOp(dataflow, hyperblock, predicate, exprNode, field,
                        valueNode)

        for oldField in fieldNodes:
            # This op should produce a new version of the field
            newField = oldField.duplicate()
            g.addModify(newField.name, newField)

            # Reads from this field should come from the store instead
            oldField.canonical().redirect(newField)

        # TODO mask?
        setOpAnnotation(dioa, g, modify=dioa.set.leaf(fieldNodes))

    return exprNode
Beispiel #2
0
	def callback(name, slot):
		if slot.isField():
			# Kill non-intrinsic fields.
			return intrinsics.isIntrinsicSlot(slot.name)
		elif slot.isLocal():
			# Kill locals that do not contain intrinsic types.
			intrinsicObj = any([intrinsics.isIntrinsicObject(obj) for obj in slot.annotation.values.flat])
			return intrinsicObj
Beispiel #3
0
def transformInputSubtree(compiler, dioa, dataflow, subtree, root):
	hyperblock = dataflow.entry.hyperblock
	predicate  = dataflow.entryPredicate
	objs = root.annotation.values.flat # HACK - what about correlation?

	assert len(objs) > 0
	obj = tuple(objs)[0]

	# HACK temporarily ignore correlated objects.
	if len(objs) > 1:
		exprNode = createLocalNode(hyperblock, getName(subtree, root), root.annotation.values)
		name = exprNode.names[0]
		dataflow.entry.addEntry(name, exprNode)
		subtree.impl = name
	else:
		assert len(objs) == 1
		if intrinsics.isIntrinsicObject(obj):
			exprNode = createLocalNode(hyperblock, getName(subtree, root), root.annotation.values)
			name = exprNode.names[0]
			dataflow.entry.addEntry(name, exprNode)
			subtree.impl = name

			# Prevent the fields of this object from being transformed
			return exprNode
		else:
			exprNode = allocateObj(dioa, dataflow, subtree, root, obj)

	lut = dataflow.entry.modifies

	# Recurse to each field of this node
	for field, child in subtree.fields.iteritems():
		# Field the field nodes for the field name
		fieldNodes = [lut[o.slots[field]] for o in objs if field in o.slots]

		fieldNode = fieldNodes[0] # HACK

		# HACK ignore correlated fields
		#if fieldNode.annotation.values.correlated.tree(): continue

		# Create the dataflow store
		valueNode = transformInputSubtree(compiler, dioa, dataflow, child, fieldNode)

		g = makeStoreOp(dataflow, hyperblock, predicate, exprNode, field, valueNode)

		for oldField in fieldNodes:
			# This op should produce a new version of the field
			newField = oldField.duplicate()
			g.addModify(newField.name, newField)

			# Reads from this field should come from the store instead
			oldField.canonical().redirect(newField)

		# TODO mask?
		setOpAnnotation(dioa, g, modify=dioa.set.leaf(fieldNodes))

	return exprNode
Beispiel #4
0
 def callback(name, slot):
     if slot.isField():
         # Kill non-intrinsic fields.
         return intrinsics.isIntrinsicSlot(slot.name)
     elif slot.isLocal():
         # Kill locals that do not contain intrinsic types.
         intrinsicObj = any([
             intrinsics.isIntrinsicObject(obj)
             for obj in slot.annotation.values.flat
         ])
         return intrinsicObj