Example #1
0
                # no simplification
                result = node
            self.memoization_map[node] = result
            return result


class Pass_LogicalSimplification(FunctionPass):
    """ Pass to simplify logical operation """
    pass_tag = "logical_simplification"

    def __init__(self, target):
        FunctionPass.__init__(self, "logical operation simplification pass",
                              target)
        ## memoization map for promoted optree
        self.memoization_map = {}
        self.simplifier = LogicalSimplification(target)

    def execute_on_optree(self,
                          node,
                          fct=None,
                          fct_group=None,
                          memoization_map=None):
        """ If node can be transformed returns the transformed node
            else returns None """
        return self.simplifier.simplify(node)


Log.report(LOG_PASS_INFO, "Registering logical_simplification pass")
# register pass
Pass.register(Pass_LogicalSimplification)
Example #2
0
                                    target)
        ## memoization map for promoted optree
        self.memoization_map = {}
        self.expander = VectorMaskTestExpander(target)

    def can_be_transformed(self, node, *args):
        """ Returns True if @p can be expanded from a multi-precision
            node to a list of scalar-precision fields,
            returns False otherwise """
        return self.expander.is_expandable(node)

    def transform_node(self, node, transformed_inputs, *args):
        """ If node can be transformed returns the transformed node
            else returns None """
        return self.expander.expand_node(node)

    def reconstruct_from_transformed(self, node, transformed_node):
        """return a node at the root of a transformation chain,
            compatible with untransformed nodes """
        return transformed_node

    ## standard Opt pass API
    def execute(self, optree):
        """ Implémentation of the standard optimization pass API """
        return self.transform_graph(optree)


Log.report(LOG_PASS_INFO, "Registering vector_mask_test_legalization pass")
# register pass
Pass.register(Pass_VectorMaskTestLegalization)
Example #3
0
        OptreeOptimization.__init__(self, "basic legalization pass", target)
        ## memoization map for promoted optree
        self.memoization_map = {}
        self.expander = BasicExpander(target)

    def can_be_transformed(self, node, *args):
        """ Returns True if @p can be expanded from a multi-precision
            node to a list of scalar-precision fields,
            returns False otherwise """
        return self.expander.is_expandable(node)

    def transform_node(self, node, transformed_inputs, *args):
        """ If node can be transformed returns the transformed node
            else returns None """
        return self.expander.expand_node(node)

    def reconstruct_from_transformed(self, node, transformed_node):
        """return a node at the root of a transformation chain,
            compatible with untransformed nodes """
        return transformed_node

    ## standard Opt pass API
    def execute(self, optree):
        """ Implémentation of the standard optimization pass API """
        return self.transform_graph(optree)


Log.report(LOG_PASS_INFO, "Registering basic_legalization pass")
# register pass
Pass.register(Pass_BasicLegalization)
Example #4
0
            function-group @p fct_group """
        Log.report(
            LOG_LEVEL_GEN_BB_INFO,
            "executing pass {} on fct {}".format(self.pass_tag,
                                                 fct.get_name()))
        optree = fct.get_scheme()
        assert isinstance(optree, BasicBlockList)
        bb_root = optree.get_input(0)
        bbg = BasicBlockGraph(bb_root, optree)
        phi_node_insertion(bbg)
        variable_renaming(bbg)


# registering basic-block generation pass
Log.report(LOG_PASS_INFO, "Registering generate Basic-Blocks pass")
Pass.register(Pass_GenerateBasicBlock)
# registering ssa translation pass
Log.report(LOG_PASS_INFO, "Registering ssa translation pass")
Pass.register(Pass_SSATranslate)

if __name__ == "__main__":
    bb_root = BasicBlock(tag="bb_root")
    bb_1 = BasicBlock(tag="bb_1")
    bb_2 = BasicBlock(tag="bb_2")
    bb_3 = BasicBlock(tag="bb_3")

    var_x = Variable("x", precision=None)
    var_y = Variable("y", precision=None)

    bb_root.add(ReferenceAssign(var_x, 1))
    bb_root.add(ReferenceAssign(var_y, 2))