예제 #1
0
 static void CalculateForOutputBlocks <V>(TransferFunctionStorage <ISet <V> > result, Region r, Region s, List <int> outputBlocks, Graph graph)
 {
     foreach (BasicBlock bb in outputBlocks.Select(i => graph.getBlockById(i)))
     {
         LeafRegion b = new LeafRegion(bb);
         TransferFunctionStorage <ISet <V> > clone = result.Clone();
         result[r, RegionDirection.Out, b] = input => clone[s, RegionDirection.Out, b](clone[r, RegionDirection.In, s](input));
     }
 }
예제 #2
0
        static TransferFunctionStorage <ISet <V> > ApplyAscendingPart <V>(Graph graph, List <Region> regions, SetIterativeAlgorithmParameters <V> param)
        {
            TransferFunctionStorage <ISet <V> > result = new TransferFunctionStorage <ISet <V> >();

            foreach (Region r in regions)
            {
                LeafRegion leaf = r as LeafRegion;
                TransferFunctionStorage <ISet <V> > clone = result.Clone();
                if (leaf != null)
                {
                    //////
                    for (int i = graph.Count(); i < regions.Count; ++i)
                    {
                        result[regions[i], RegionDirection.Out, leaf] = input => param.TransferFunction(input, leaf.Block);
                    }
                    /////
                    result[leaf, RegionDirection.In, leaf]  = Identity;
                    result[leaf, RegionDirection.Out, leaf] = input => param.TransferFunction(input, leaf.Block);
                }
                BodyRegion body = r as BodyRegion;
                if (body != null)
                {
                    foreach (Region s in body.Regions)
                    {
                        LeafRegion header = s as LeafRegion;
                        if (header != null)
                        {
                            result[body, RegionDirection.In, s] = Identity;
                        }
                        else
                        {
                            result[body, RegionDirection.In, s] = input => GatherFunctionsResults(input, clone, body, s.Header.InputBlocks, graph, param);
                        }
                        CalculateForOutputBlocks(result, body, s, s.OutputBlocks, graph);
                    }
                }
                LoopRegion loop = r as LoopRegion;
                if (loop != null)
                {
                    result[loop, RegionDirection.In, loop.Body] = input => SetFactory.GetSet <V>(input.Union(GatherFunctionsResults(input, clone, loop.Body, loop.Header.InputBlocks, graph, param)));
                    CalculateForOutputBlocks(result, loop, loop.Body, loop.OutputBlocks, graph);
                }
            }
            return(result);
        }