11 while(*s == ' ' || *s == '\t')
13 if(*s == '-' || *s == '+') {
16 while(*s == ' ' || *s == '\t')
19 if(s[0]=='0' && s[1]){
20 if(s[1]=='x' || s[1]=='X'){
23 if(*s >= '0' && *s <= '9')
24 n = n*16 + *s++ - '0';
25 else if(*s >= 'a' && *s <= 'f')
26 n = n*16 + *s++ - 'a' + 10;
27 else if(*s >= 'A' && *s <= 'F')
28 n = n*16 + *s++ - 'A' + 10;
33 while(*s >= '0' && *s <= '7')
36 while(*s >= '0' && *s <= '9')
37 n = n*10 + *s++ - '0';
67 Bprint(&bso, "%5.2f dodata\n", cputime());
69 for(p = datap; p != P; p = p->link) {
71 if(p->as == ADYNT || p->as == AINIT)
76 diag("initialize non-data (%d): %s\n%P",
78 v = p->from.offset + p->reg;
80 diag("initialize bounds (%lld): %s\n%P",
81 (vlong)s->value, s->name, p);
86 * pull out string constants
88 for(p = datap; p != P; p = p->link) {
90 if(p->to.type == D_SCONST)
97 * assign 'small' variables to data segment
98 * (rationale is that data segment is more easily
99 * addressed through offset on REGSB)
102 for(i=0; i<NHASH; i++)
103 for(s = hash[i]; s != S; s = s->link) {
105 if(t != SDATA && t != SBSS)
109 diag("%s: no size", s->name);
117 orig = rnd(orig, 16);
127 * assign large 'data' variables to data segment
129 for(i=0; i<NHASH; i++)
130 for(s = hash[i]; s != S; s = s->link) {
139 orig = rnd(orig, 16);
152 * everything else to bss segment
154 for(i=0; i<NHASH; i++)
155 for(s = hash[i]; s != S; s = s->link) {
160 orig = rnd(orig, 16);
168 bsssize = orig-datsize;
170 xdefine("setSB", SDATA, 0L);
171 xdefine("bdata", SDATA, 0L);
172 xdefine("edata", SDATA, datsize);
173 xdefine("end", SBSS, datsize+bsssize);
174 xdefine("etext", STEXT, 0L);
182 for(i=0; i<20; i++) {
183 if(p == P || !isbranch(p->as))
194 Bprint(&bso, "%5.2f follow\n", cputime());
201 firstp = firstp->link;
222 if(!(p->mark & FOLL))
227 for(i=0,q=p; i<4; i++,q=q->link) {
235 if(isbranch(a) || isreturn(a))
237 if(q->cond == nil || (q->cond->mark&FOLL))
239 if(a != ABEQ && a != ABNE)
246 print("cant happen 1\n");
256 if(isbranch(a) || isreturn(a))
258 r->as = a == ABNE? ABEQ: ABNE;
261 if(!(r->link->mark&FOLL))
263 if(!(r->cond->mark&FOLL))
264 print("cant happen 2\n");
272 q->to.type = D_BRANCH;
273 q->to.offset = p->pc;
280 if(isbranch(a) || isreturn(a))
283 if(!iscall(a) && p->link != P) {
284 q = brchain(p->link);
286 if(q != P && (q->mark&FOLL)) {
292 q = brchain(p->cond);
315 Bprint(&bso, "%5.2f patch\n", cputime());
318 s = lookup("exit", 0);
320 for(p = firstp; p != P; p = p->link) {
324 if((iscall(a) || isbranch(a) || isreturn(a)) &&
325 p->to.type != D_BRANCH && p->to.sym != S) {
329 diag("undefined: %s\n%P", s->name, p);
334 p->to.offset = s->value;
338 diag("help: SUNDEF in AB || ARET");
343 p->to.type = D_BRANCH;
347 if(p->to.type == D_BRANCH)
349 else if(p->from.type == D_BRANCH)
353 for(q = firstp; q != P;) {
355 if(c >= q->forwd->pc) {
364 diag("branch out of range %ld\n%P", c, p);
370 for(p = firstp; p != P; p = p->link) {
373 if(p->cond != P && p->cond != UP) {
374 p->cond = brloop(p->cond);
376 if(p->to.type == D_BRANCH)
377 p->to.offset = p->cond->pc;
378 if(p->from.type == D_BRANCH)
379 p->from.offset = p->cond->pc;
390 long dwn[LOG], cnt[LOG], i;
393 for(i=0; i<LOG; i++) {
396 cnt[i] = LOG * cnt[i-1];
401 for(p = firstp; p != P; p = p->link) {
430 if(q == p || c > 5000)
444 for(i=0; i<NHASH; i++)
445 for(s = hash[i]; s != S; s = s->link)
447 diag("%s: not defined", s->name);