Exemple #1
0
        //given a partially coloured graph and a node, attempts to integrate node
        public static List<List<string>> appendToAllocated(List<List<string>> alloc, Node n)
        {
            List<string> regs = getRegisters();
            Regex literal = new Regex(@"^[0-9]+");
            Regex str = new Regex(@"^"".+""");
            Regex memory = new Regex(@"[MEM.+]");

            if(literal.IsMatch(n.id)){
            alloc.Add(new List<string>(){n.id,"="+n.id});
            return alloc;
            }
            else if(str.IsMatch(n.id) || memory.IsMatch(n.id)){
            alloc.Add(new List<string>(){n.id, n.id});
            return alloc;
            }
            for(int i = 0; i < alloc.Count; i++){
            if(n.interferes(alloc[i][0])){
                regs.Remove(alloc[i][1]);
            }
            }
            if(regs.Count > 0){
            alloc.Add(new List<string>(){n.id,regs[0]});
            return alloc;
            }
            return null;
        }
Exemple #2
0
 public void link(Node n)
 {
     if (this.id != n.id)
     {
         if (!this.interferes(n.id))
         {
             this.interfere.Add(n);
         }
         if (!n.interferes(this.id))
         {
             n.interfere.Add(this);
         }
     }
 }
Exemple #3
0
        //given a partially coloured graph and a node, attempts to integrate node
        public static List <List <string> > appendToAllocated(List <List <string> > alloc, Node n)
        {
            List <string> regs    = getRegisters();
            Regex         literal = new Regex(@"^[0-9]+");
            Regex         str     = new Regex(@"^"".+""");
            Regex         memory  = new Regex(@"[MEM.+]");

            if (literal.IsMatch(n.id))
            {
                alloc.Add(new List <string>()
                {
                    n.id, "=" + n.id
                });
                return(alloc);
            }
            else if (str.IsMatch(n.id) || memory.IsMatch(n.id))
            {
                alloc.Add(new List <string>()
                {
                    n.id, n.id
                });
                return(alloc);
            }
            for (int i = 0; i < alloc.Count; i++)
            {
                if (n.interferes(alloc[i][0]))
                {
                    regs.Remove(alloc[i][1]);
                }
            }
            if (regs.Count > 0)
            {
                alloc.Add(new List <string>()
                {
                    n.id, regs[0]
                });
                return(alloc);
            }
            return(null);
        }
Exemple #4
0
 public void link(Node n)
 {
     if(this.id != n.id){
     if(!this.interferes(n.id)){
         this.interfere.Add(n);
     }
     if(!n.interferes(this.id)){
         n.interfere.Add(this);
     }
     }
 }