Example #1
0
        private void doLiveoutSets(ProgramBlock<SparcInstruction> start)
        {
            bool changed = false;
            do
            {
                changed = false;

                foreach (var f in start.Functions)
                {
                    if (coloringDone.Contains(f.Name))
                        continue;

                    f.VisitBlocks(b =>
                    {
                        var gset = genSets[b];
                        var kset = killSets[b];
                        var lset = liveoutSets[b];
                        var newLset = new BitArray(numRegs);

                        if (!b.IsReturn)
                        {
                            foreach (var suc in b.Nexts)
                            {
                                var sucKset = killSets[suc as BasicBlock<SparcInstruction>];
                                var sucGset = genSets[suc as BasicBlock<SparcInstruction>];
                                var sucLset = liveoutSets[suc as BasicBlock<SparcInstruction>];
                                var sucSet = new BitArray(numRegs);

                                //do lset - kset
                                sucSet.Or(sucLset).Xor(sucKset).And(sucLset);

                                //do gen union with the above
                                sucSet.Or(sucGset);

                                //union with new lset
                                newLset.Or(sucSet);
                            }
                        }

                        var countingSet = new BitArray(lset);
                        countingSet.Xor(newLset);
                        var countArr = new int[countingSet.IntArraySize()];
                        countingSet.CopyTo(countArr, 0);

                        for (int i = 0; i < countArr.Length; i++)
                        {
                            changed |= countArr[i] != 0;
                        }

                        if (changed)
                        {
                            liveoutSets[b] = newLset;
                        }
                    }, false);
                }
            }
            while (changed);
        }