示例#1
0
        public RegisterAllocation()
        {
            candidateColors = new BitArray(SparcRegister.IntValueMap.Value.Max() + 1);
            virtToSparc = new SparcRegister[candidateColors.Length];

            foreach (SparcReg r in Enum.GetValues(typeof(SparcReg)))
            {
                var s = new SparcRegister(r);
                virtToSparc[s.IntVal] = s;
            }

            var canColors = new List<SparcRegister>();
            canColors.Add(new SparcRegister(SparcReg.l0));
            canColors.Add(new SparcRegister(SparcReg.l1));
            canColors.Add(new SparcRegister(SparcReg.l2));
            canColors.Add(new SparcRegister(SparcReg.l3));
            canColors.Add(new SparcRegister(SparcReg.l4));
            canColors.Add(new SparcRegister(SparcReg.l5));
            canColors.Add(new SparcRegister(SparcReg.l6));
            canColors.Add(new SparcRegister(SparcReg.l7));
            canColors.Add(new SparcRegister(SparcReg.o1));
            canColors.Add(new SparcRegister(SparcReg.o2));
            canColors.Add(new SparcRegister(SparcReg.o3));
            canColors.Add(new SparcRegister(SparcReg.o4));
            canColors.Add(new SparcRegister(SparcReg.o5));
            canColors.Add(new SparcRegister(SparcReg.g1));
            canColors.Add(new SparcRegister(SparcReg.g4));
            canColors.Add(new SparcRegister(SparcReg.g5));

            numColors = canColors.Count;

            foreach (var c in canColors)
            {
                if (c.IntVal == 0)
                    throw new Exception("no register should have an intval of 0, the register allocator depends on this");
                candidateColors[c.IntVal] = true;
            }

            //data the may be inject in setupVars()
            genSets = new Dictionary<BasicBlock<SparcInstruction>, BitArray>();
            killSets = new Dictionary<BasicBlock<SparcInstruction>, BitArray>();
            liveoutSets = new Dictionary<BasicBlock<SparcInstruction>, BitArray>();
            allDepGraphs = new Dictionary<FunctionBlock<SparcInstruction>, BitArray[]>();
            colorMapping = new Dictionary<string, SparcRegister[]>();
        }
示例#2
0
 public abstract SparcInstruction ConvertRegister(SparcRegister[] map);