LEFT | RIGHT |
1 // Derived from Inferno utils/6c/reg.c | 1 // Derived from Inferno utils/6c/reg.c |
2 // http://code.google.com/p/inferno-os/source/browse/utils/6c/reg.c | 2 // http://code.google.com/p/inferno-os/source/browse/utils/6c/reg.c |
3 // | 3 // |
4 // Copyright © 1994-1999 Lucent Technologies Inc. All rights reserved. | 4 // Copyright © 1994-1999 Lucent Technologies Inc. All rights reserved. |
5 // Portions Copyright © 1995-1997 C H Forsyth (forsyth@terzarima.net) | 5 // Portions Copyright © 1995-1997 C H Forsyth (forsyth@terzarima.net) |
6 // Portions Copyright © 1997-1999 Vita Nuova Limited | 6 // Portions Copyright © 1997-1999 Vita Nuova Limited |
7 // Portions Copyright © 2000-2007 Vita Nuova Holdings Limited (www.vitanuov
a.com) | 7 // Portions Copyright © 2000-2007 Vita Nuova Holdings Limited (www.vitanuov
a.com) |
8 // Portions Copyright © 2004,2006 Bruce Ellis | 8 // Portions Copyright © 2004,2006 Bruce Ellis |
9 // Portions Copyright © 2005-2007 C H Forsyth (forsyth@terzarima.net) | 9 // Portions Copyright © 2005-2007 C H Forsyth (forsyth@terzarima.net) |
10 // Revisions Copyright © 2000-2007 Lucent Technologies Inc. and others | 10 // Revisions Copyright © 2000-2007 Lucent Technologies Inc. and others |
(...skipping 740 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
751 change = 0; | 751 change = 0; |
752 paint1(r, i); | 752 paint1(r, i); |
753 bit.b[i/32] &= ~(1L<<(i%32)); | 753 bit.b[i/32] &= ~(1L<<(i%32)); |
754 if(change <= 0) | 754 if(change <= 0) |
755 continue; | 755 continue; |
756 rgp->cost = change; | 756 rgp->cost = change; |
757 nregion++; | 757 nregion++; |
758 if(nregion >= NRGN) { | 758 if(nregion >= NRGN) { |
759 if(debug['R'] && debug['v']) | 759 if(debug['R'] && debug['v']) |
760 print("too many regions\n"); | 760 print("too many regions\n"); |
761 | |
762 fatal("PUNTING!!!\n"); | |
763 | |
764 goto brk; | 761 goto brk; |
765 } | 762 } |
766 rgp++; | 763 rgp++; |
767 } | 764 } |
768 } | 765 } |
769 brk: | 766 brk: |
770 qsort(region, nregion, sizeof(region[0]), rcmp); | 767 qsort(region, nregion, sizeof(region[0]), rcmp); |
771 | 768 |
772 if(debug['R'] && debug['v']) | 769 if(debug['R'] && debug['v']) |
773 dumpit("pass5", firstr); | 770 dumpit("pass5", firstr); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
810 * eliminate nops | 807 * eliminate nops |
811 * free aux structures | 808 * free aux structures |
812 */ | 809 */ |
813 for(p=firstp; p!=P; p=p->link) { | 810 for(p=firstp; p!=P; p=p->link) { |
814 while(p->link != P && p->link->as == ANOP) | 811 while(p->link != P && p->link->as == ANOP) |
815 p->link = p->link->link; | 812 p->link = p->link->link; |
816 if(p->to.type == D_BRANCH) | 813 if(p->to.type == D_BRANCH) |
817 while(p->to.u.branch != P && p->to.u.branch->as == ANOP) | 814 while(p->to.u.branch != P && p->to.u.branch->as == ANOP) |
818 p->to.u.branch = p->to.u.branch->link; | 815 p->to.u.branch = p->to.u.branch->link; |
819 } | 816 } |
820 | |
821 /* | |
822 print("compiling '%s'\n", firstp->from.sym->name);//->sym->name); | |
823 for(r = firstr; r != R; r = r->link) { | |
824 print("reg %p prog %p as %d", r, r->prog, r->prog->as); | |
825 if(r->prog->as == ACALL) { | |
826 print(" call to '%s' calahead is {%Q} calbehind is {%Q}
refahead is {%Q} refbehind is {%Q}", | |
827 r->prog->to.sym->name, r->calahead, r->calbehind,
r->refahead, r->refbehind); | |
828 } | |
829 print("\n"); | |
830 } | |
831 for(p = firstp; p != P; p = p->link) { | |
832 if(p->from.type == D_PARAM || p->from.type == D_AUTO || p->from.
type == D_EXTERN || p->from.type == D_ADDR) { | |
833 print("+++ prog %p from: %s type=%d offset=%d\n", p, p->
from.sym->name, p->from.type, p->from.offset); | |
834 } | |
835 if(p->to.type == D_PARAM || p->to.type == D_AUTO || p->to.type =
= D_EXTERN || p->to.type == D_ADDR) { | |
836 print("+++ prog %p to: %s type=%d offset=%d\n", p, p->to
.sym->name, p->to.type, p->to.offset); | |
837 } | |
838 } | |
839 */ | |
840 | 817 |
841 if(lastr != R) { | 818 if(lastr != R) { |
842 lastr->link = freer; | 819 lastr->link = freer; |
843 freer = firstr; | 820 freer = firstr; |
844 } | 821 } |
845 | 822 |
846 if(debug['R']) { | 823 if(debug['R']) { |
847 if(ostats.ncvtreg || | 824 if(ostats.ncvtreg || |
848 ostats.nspill || | 825 ostats.nspill || |
849 ostats.nreload || | 826 ostats.nreload || |
(...skipping 1025 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1875 last->link = P; | 1852 last->link = P; |
1876 } | 1853 } |
1877 ········ | 1854 ········ |
1878 if(debug['R'] && debug['v']) { | 1855 if(debug['R'] && debug['v']) { |
1879 print("\n"); | 1856 print("\n"); |
1880 for(p=firstp; p; p=p->link) | 1857 for(p=firstp; p; p=p->link) |
1881 print("%P\n", p); | 1858 print("%P\n", p); |
1882 print("\n"); | 1859 print("\n"); |
1883 } | 1860 } |
1884 } | 1861 } |
LEFT | RIGHT |