Ejemplo n.º 1
0
        public InterferenceCopyGraphPair GetInterferenceCopyGraphs(
            IReadOnlyList <CodeBlock> instructions)
        {
            var cfg               = GetInstructionCFG(instructions);
            var reverseCFG        = GraphReverser.ReverseGraph(cfg);
            var liveness          = GetLivenessSets(reverseCFG);
            var interferenceGraph = CreateInterferenceGraph(reverseCFG, liveness);
            var copyGraph         = CreateCopyGraph(reverseCFG);

            return(new InterferenceCopyGraphPair(interferenceGraph, copyGraph));
        }
Ejemplo n.º 2
0
        public void SimpleTest()
        {
            var graph = new Dictionary <int, IReadOnlyCollection <int> >()
            {
                [0] = new HashSet <int>()
                {
                    1, 2
                },
                [1] = new HashSet <int>()
                {
                },
                [2] = new HashSet <int>()
                {
                    1
                },
            };

            var expectedReverse = new Dictionary <int, IReadOnlyCollection <int> >()
            {
                [0] = new HashSet <int>()
                {
                },
                [1] = new HashSet <int>()
                {
                    0, 2
                },
                [2] = new HashSet <int>()
                {
                    0
                },
            };

            var result = GraphReverser.ReverseGraph(graph);

            MappingEquivalence.AssertAreEquivalentCollection(expectedReverse, result);
        }