From: Shenghou Ma Date: Thu, 7 Aug 2014 16:02:36 +0000 (-0400) Subject: [dev.power64] liblink: move span and asmout related function from obj9.c to asm9.c X-Git-Tag: go1.5beta1~2684^2~25^2~98 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=2358603f0c0e1279a0ee2d207d9733b9ea9f520e;p=gostls13.git [dev.power64] liblink: move span and asmout related function from obj9.c to asm9.c To reduce delta for the upcoming liblink CL. Just code movement, no semantic changes. LGTM=rsc R=rsc, iant CC=golang-codereviews https://golang.org/cl/124830043 --- diff --git a/src/liblink/asm9.c b/src/liblink/asm9.c index ea510df795..27ccb0a237 100644 --- a/src/liblink/asm9.c +++ b/src/liblink/asm9.c @@ -402,6 +402,843 @@ Optab optab[] = { AXXX, C_NONE, C_NONE, C_NONE, C_NONE, 0, 4, 0 }, }; +#include "l.h" + +void +span(void) +{ + Prog *p, *q; + Sym *setext; + Optab *o; + int m, bflag; + vlong c, otxt; + + if(debug['v']) + Bprint(&bso, "%5.2f span\n", cputime()); + Bflush(&bso); + + bflag = 0; + c = INITTEXT; + otxt = c; + for(p = firstp; p != P; p = p->link) { + p->pc = c; + o = oplook(p); + m = o->size; + if(m == 0) { + if(p->as == ATEXT) { + curtext = p; + autosize = p->to.offset + 8; + if(p->from3.type == D_CONST) { + if(p->from3.offset & 3) + diag("illegal origin\n%P", p); + if(c > p->from3.offset) + diag("passed origin (#%llux)\n%P", c, p); + else + c = p->from3.offset; + p->pc = c; + } + if(p->from.sym != S) + p->from.sym->value = c; + /* need passes to resolve branches? */ + if(c-otxt >= (1L<<15)) + bflag = c; + otxt = c; + continue; + } + if(p->as != ANOP) + diag("zero-width instruction\n%P", p); + continue; + } + c += m; + } + + /* + * if any procedure is large enough to + * generate a large SBRA branch, then + * generate extra passes putting branches + * around jmps to fix. this is rare. + */ + while(bflag) { + if(debug['v']) + Bprint(&bso, "%5.2f span1\n", cputime()); + bflag = 0; + c = INITTEXT; + for(p = firstp; p != P; p = p->link) { + p->pc = c; + o = oplook(p); + if((o->type == 16 || o->type == 17) && p->cond) { + otxt = p->cond->pc - c; + if(otxt < -(1L<<16)+10 || otxt >= (1L<<15)-10) { + q = prg(); + q->link = p->link; + p->link = q; + q->as = ABR; + q->to.type = D_BRANCH; + q->cond = p->cond; + p->cond = q; + q = prg(); + q->link = p->link; + p->link = q; + q->as = ABR; + q->to.type = D_BRANCH; + q->cond = q->link->link; + addnop(p->link); + addnop(p); + bflag = 1; + } + } + m = o->size; + if(m == 0) { + if(p->as == ATEXT) { + curtext = p; + autosize = p->to.offset + 8; + if(p->from.sym != S) + p->from.sym->value = c; + continue; + } + if(p->as != ANOP) + diag("zero-width instruction\n%P", p); + continue; + } + c += m; + } + } + + c = rnd(c, 8); + + setext = lookup("etext", 0); + if(setext != S) { + setext->value = c; + textsize = c - INITTEXT; + } + if(INITRND) + INITDAT = rnd(c, INITRND); + if(debug['v']) + Bprint(&bso, "tsize = %llux\n", textsize); + Bflush(&bso); +} + +void +xdefine(char *p, int t, vlong v) +{ + Sym *s; + + s = lookup(p, 0); + if(s->type == 0 || s->type == SXREF) { + s->type = t; + s->value = v; + } +} + +int +isint32(vlong v) +{ + long l; + + l = v; + return (vlong)l == v; +} + +int +isuint32(uvlong v) +{ + ulong l; + + l = v; + return (uvlong)l == v; +} + +int +aclass(Adr *a) +{ + Sym *s; + int t; + + switch(a->type) { + case D_NONE: + return C_NONE; + + case D_REG: + return C_REG; + + case D_FREG: + return C_FREG; + + case D_CREG: + return C_CREG; + + case D_SPR: + if(a->offset == D_LR) + return C_LR; + if(a->offset == D_XER) + return C_XER; + if(a->offset == D_CTR) + return C_CTR; + return C_SPR; + + case D_DCR: + return C_SPR; + + case D_FPSCR: + return C_FPSCR; + + case D_MSR: + return C_MSR; + + case D_OREG: + switch(a->name) { + case D_EXTERN: + case D_STATIC: + if(a->sym == S) + break; + t = a->sym->type; + if(t == 0 || t == SXREF) { + diag("undefined external: %s in %s", + a->sym->name, TNAME); + a->sym->type = SDATA; + } + if(dlm){ + instoffset = a->sym->value + a->offset; + switch(a->sym->type){ + case STEXT: + case SLEAF: + case SCONST: + case SUNDEF: + break; + default: + instoffset += INITDAT; + } + return C_ADDR; + } + instoffset = a->sym->value + a->offset - BIG; + if(instoffset >= -BIG && instoffset < BIG) + return C_SEXT; + return C_LEXT; + case D_AUTO: + instoffset = autosize + a->offset; + if(instoffset >= -BIG && instoffset < BIG) + return C_SAUTO; + return C_LAUTO; + case D_PARAM: + instoffset = autosize + a->offset + 8L; + if(instoffset >= -BIG && instoffset < BIG) + return C_SAUTO; + return C_LAUTO; + case D_NONE: + instoffset = a->offset; + if(instoffset == 0) + return C_ZOREG; + if(instoffset >= -BIG && instoffset < BIG) + return C_SOREG; + return C_LOREG; + } + return C_GOK; + + case D_OPT: + instoffset = a->offset & 31L; + if(a->name == D_NONE) + return C_SCON; + return C_GOK; + + case D_CONST: + switch(a->name) { + + case D_NONE: + instoffset = a->offset; + consize: + if(instoffset >= 0) { + if(instoffset == 0) + return C_ZCON; + if(instoffset <= 0x7fff) + return C_SCON; + if(instoffset <= 0xffff) + return C_ANDCON; + if((instoffset & 0xffff) == 0 && isuint32(instoffset)) /* && (instoffset & (1<<31)) == 0) */ + return C_UCON; + if(isint32(instoffset) || isuint32(instoffset)) + return C_LCON; + return C_DCON; + } + if(instoffset >= -0x8000) + return C_ADDCON; + if((instoffset & 0xffff) == 0 && isint32(instoffset)) + return C_UCON; + if(isint32(instoffset)) + return C_LCON; + return C_DCON; + + case D_EXTERN: + case D_STATIC: + s = a->sym; + if(s == S) + break; + t = s->type; + if(t == 0 || t == SXREF) { + diag("undefined external: %s in %s", + s->name, TNAME); + s->type = SDATA; + } + if(s->type == STEXT || s->type == SLEAF || s->type == SUNDEF) { + instoffset = s->value + a->offset; + return C_LCON; + } + if(s->type == SCONST) { + instoffset = s->value + a->offset; + if(dlm) + return C_LCON; + goto consize; + } + if(!dlm){ + instoffset = s->value + a->offset - BIG; + if(instoffset >= -BIG && instoffset < BIG && instoffset != 0) + return C_SECON; + } + instoffset = s->value + a->offset + INITDAT; + if(dlm) + return C_LCON; + /* not sure why this barfs */ + return C_LCON; + /* + if(instoffset == 0) + return C_ZCON; + if(instoffset >= -0x8000 && instoffset <= 0xffff) + return C_SCON; + if((instoffset & 0xffff) == 0) + return C_UCON; + return C_LCON; + */ + + case D_AUTO: + instoffset = autosize + a->offset; + if(instoffset >= -BIG && instoffset < BIG) + return C_SACON; + return C_LACON; + + case D_PARAM: + instoffset = autosize + a->offset + 8L; + if(instoffset >= -BIG && instoffset < BIG) + return C_SACON; + return C_LACON; + } + return C_GOK; + + case D_BRANCH: + return C_SBRA; + } + return C_GOK; +} + +Optab* +oplook(Prog *p) +{ + int a1, a2, a3, a4, r; + char *c1, *c3, *c4; + Optab *o, *e; + + a1 = p->optab; + if(a1) + return optab+(a1-1); + a1 = p->from.class; + if(a1 == 0) { + a1 = aclass(&p->from) + 1; + p->from.class = a1; + } + a1--; + a3 = p->from3.class; + if(a3 == 0) { + a3 = aclass(&p->from3) + 1; + p->from3.class = a3; + } + a3--; + a4 = p->to.class; + if(a4 == 0) { + a4 = aclass(&p->to) + 1; + p->to.class = a4; + } + a4--; + a2 = C_NONE; + if(p->reg != NREG) + a2 = C_REG; + r = p->as; + o = oprange[r].start; + if(o == 0) + o = oprange[r].stop; /* just generate an error */ + e = oprange[r].stop; + c1 = xcmp[a1]; + c3 = xcmp[a3]; + c4 = xcmp[a4]; + for(; oa2 == a2) + if(c1[o->a1]) + if(c3[o->a3]) + if(c4[o->a4]) { + p->optab = (o-optab)+1; + return o; + } + diag("illegal combination %A %R %R %R %R", + p->as, a1, a2, a3, a4); + if(1||!debug['a']) + prasm(p); + if(o == 0) + errorexit(); + return o; +} + +int +cmp(int a, int b) +{ + + if(a == b) + return 1; + switch(a) { + case C_LCON: + if(b == C_ZCON || b == C_SCON || b == C_UCON || b == C_ADDCON || b == C_ANDCON) + return 1; + break; + case C_ADDCON: + if(b == C_ZCON || b == C_SCON) + return 1; + break; + case C_ANDCON: + if(b == C_ZCON || b == C_SCON) + return 1; + break; + case C_SPR: + if(b == C_LR || b == C_XER || b == C_CTR) + return 1; + break; + case C_UCON: + if(b == C_ZCON) + return 1; + break; + case C_SCON: + if(b == C_ZCON) + return 1; + break; + case C_LACON: + if(b == C_SACON) + return 1; + break; + case C_LBRA: + if(b == C_SBRA) + return 1; + break; + case C_LEXT: + if(b == C_SEXT) + return 1; + break; + case C_LAUTO: + if(b == C_SAUTO) + return 1; + break; + case C_REG: + if(b == C_ZCON) + return r0iszero; + break; + case C_LOREG: + if(b == C_ZOREG || b == C_SOREG) + return 1; + break; + case C_SOREG: + if(b == C_ZOREG) + return 1; + break; + + case C_ANY: + return 1; + } + return 0; +} + +int +ocmp(void *a1, void *a2) +{ + Optab *p1, *p2; + int n; + + p1 = a1; + p2 = a2; + n = p1->as - p2->as; + if(n) + return n; + n = p1->a1 - p2->a1; + if(n) + return n; + n = p1->a2 - p2->a2; + if(n) + return n; + n = p1->a3 - p2->a3; + if(n) + return n; + n = p1->a4 - p2->a4; + if(n) + return n; + return 0; +} + +void +buildop(void) +{ + int i, n, r; + + for(i=0; i subf Rd,ra,rb */ + oprange[ASUB] = oprange[r]; + oprange[ASUBCC] = oprange[r]; + oprange[ASUBV] = oprange[r]; + oprange[ASUBVCC] = oprange[r]; + oprange[ASUBCCC] = oprange[r]; + oprange[ASUBCV] = oprange[r]; + oprange[ASUBCVCC] = oprange[r]; + oprange[ASUBE] = oprange[r]; + oprange[ASUBECC] = oprange[r]; + oprange[ASUBEV] = oprange[r]; + oprange[ASUBEVCC] = oprange[r]; + break; + case ASYNC: + oprange[AISYNC] = oprange[r]; + oprange[APTESYNC] = oprange[r]; + oprange[ATLBSYNC] = oprange[r]; + break; + case ARLWMI: + oprange[ARLWMICC] = oprange[r]; + oprange[ARLWNM] = oprange[r]; + oprange[ARLWNMCC] = oprange[r]; + break; + case ARLDMI: + oprange[ARLDMICC] = oprange[r]; + break; + case ARLDC: + oprange[ARLDCCC] = oprange[r]; + break; + case ARLDCL: + oprange[ARLDCR] = oprange[r]; + oprange[ARLDCLCC] = oprange[r]; + oprange[ARLDCRCC] = oprange[r]; + break; + case AFMOVD: + oprange[AFMOVDCC] = oprange[r]; + oprange[AFMOVDU] = oprange[r]; + oprange[AFMOVS] = oprange[r]; + oprange[AFMOVSU] = oprange[r]; + break; + case AECIWX: + oprange[ALWAR] = oprange[r]; + break; + case ASYSCALL: /* just the op; flow of control */ + oprange[ARFI] = oprange[r]; + oprange[ARFCI] = oprange[r]; + oprange[ARFID] = oprange[r]; + oprange[AHRFID] = oprange[r]; + break; + case AMOVHBR: + oprange[AMOVWBR] = oprange[r]; + break; + case ASLBMFEE: + oprange[ASLBMFEV] = oprange[r]; + break; + case ATW: + oprange[ATD] = oprange[r]; + break; + case ATLBIE: + oprange[ASLBIE] = oprange[r]; + oprange[ATLBIEL] = oprange[r]; + break; + case AEIEIO: + oprange[ASLBIA] = oprange[r]; + break; + case ACMP: + oprange[ACMPW] = oprange[r]; + break; + case ACMPU: + oprange[ACMPWU] = oprange[r]; + break; + case AADD: + case AANDCC: /* and. Rb,Rs,Ra; andi. $uimm,Rs,Ra; andis. $uimm,Rs,Ra */ + case ALSW: + case AMOVW: /* load/store/move word with sign extension; special 32-bit move; move 32-bit literals */ + case AMOVWZ: /* load/store/move word with zero extension; move 32-bit literals */ + case AMOVD: /* load/store/move 64-bit values, including 32-bit literals with/without sign-extension */ + case AMOVB: /* macro: move byte with sign extension */ + case AMOVBU: /* macro: move byte with sign extension & update */ + case AMOVFL: + case AMULLW: /* op $s[,r2],r3; op r1[,r2],r3; no cc/v */ + case ASUBC: /* op r1,$s,r3; op r1[,r2],r3 */ + case ASTSW: + case ASLBMTE: + case AWORD: + case ADWORD: + case ANOP: + case ATEXT: + break; + } + } +} + #include "l.h" #define OPVCC(o,xo,oe,rc) (((o)<<26)|((xo)<<1)|((oe)<<10)|((rc)&1)) @@ -1403,6 +2240,21 @@ asmout(Prog *p, Optab *o, int aflag) return 0; } +vlong +vregoff(Adr *a) +{ + + instoffset = 0; + aclass(a); + return instoffset; +} + +long +regoff(Adr *a) +{ + return vregoff(a); +} + long oprrr(int a) { diff --git a/src/liblink/obj9.c b/src/liblink/obj9.c index cf073ec36c..0e869fb53f 100644 --- a/src/liblink/obj9.c +++ b/src/liblink/obj9.c @@ -1220,858 +1220,6 @@ export(void) free(esyms); } -#include "l.h" - -void -span(void) -{ - Prog *p, *q; - Sym *setext; - Optab *o; - int m, bflag; - vlong c, otxt; - - if(debug['v']) - Bprint(&bso, "%5.2f span\n", cputime()); - Bflush(&bso); - - bflag = 0; - c = INITTEXT; - otxt = c; - for(p = firstp; p != P; p = p->link) { - p->pc = c; - o = oplook(p); - m = o->size; - if(m == 0) { - if(p->as == ATEXT) { - curtext = p; - autosize = p->to.offset + 8; - if(p->from3.type == D_CONST) { - if(p->from3.offset & 3) - diag("illegal origin\n%P", p); - if(c > p->from3.offset) - diag("passed origin (#%llux)\n%P", c, p); - else - c = p->from3.offset; - p->pc = c; - } - if(p->from.sym != S) - p->from.sym->value = c; - /* need passes to resolve branches? */ - if(c-otxt >= (1L<<15)) - bflag = c; - otxt = c; - continue; - } - if(p->as != ANOP) - diag("zero-width instruction\n%P", p); - continue; - } - c += m; - } - - /* - * if any procedure is large enough to - * generate a large SBRA branch, then - * generate extra passes putting branches - * around jmps to fix. this is rare. - */ - while(bflag) { - if(debug['v']) - Bprint(&bso, "%5.2f span1\n", cputime()); - bflag = 0; - c = INITTEXT; - for(p = firstp; p != P; p = p->link) { - p->pc = c; - o = oplook(p); - if((o->type == 16 || o->type == 17) && p->cond) { - otxt = p->cond->pc - c; - if(otxt < -(1L<<16)+10 || otxt >= (1L<<15)-10) { - q = prg(); - q->link = p->link; - p->link = q; - q->as = ABR; - q->to.type = D_BRANCH; - q->cond = p->cond; - p->cond = q; - q = prg(); - q->link = p->link; - p->link = q; - q->as = ABR; - q->to.type = D_BRANCH; - q->cond = q->link->link; - addnop(p->link); - addnop(p); - bflag = 1; - } - } - m = o->size; - if(m == 0) { - if(p->as == ATEXT) { - curtext = p; - autosize = p->to.offset + 8; - if(p->from.sym != S) - p->from.sym->value = c; - continue; - } - if(p->as != ANOP) - diag("zero-width instruction\n%P", p); - continue; - } - c += m; - } - } - - c = rnd(c, 8); - - setext = lookup("etext", 0); - if(setext != S) { - setext->value = c; - textsize = c - INITTEXT; - } - if(INITRND) - INITDAT = rnd(c, INITRND); - if(debug['v']) - Bprint(&bso, "tsize = %llux\n", textsize); - Bflush(&bso); -} - -void -xdefine(char *p, int t, vlong v) -{ - Sym *s; - - s = lookup(p, 0); - if(s->type == 0 || s->type == SXREF) { - s->type = t; - s->value = v; - } -} - -vlong -vregoff(Adr *a) -{ - - instoffset = 0; - aclass(a); - return instoffset; -} - -long -regoff(Adr *a) -{ - return vregoff(a); -} - -int -isint32(vlong v) -{ - long l; - - l = v; - return (vlong)l == v; -} - -int -isuint32(uvlong v) -{ - ulong l; - - l = v; - return (uvlong)l == v; -} - -int -aclass(Adr *a) -{ - Sym *s; - int t; - - switch(a->type) { - case D_NONE: - return C_NONE; - - case D_REG: - return C_REG; - - case D_FREG: - return C_FREG; - - case D_CREG: - return C_CREG; - - case D_SPR: - if(a->offset == D_LR) - return C_LR; - if(a->offset == D_XER) - return C_XER; - if(a->offset == D_CTR) - return C_CTR; - return C_SPR; - - case D_DCR: - return C_SPR; - - case D_FPSCR: - return C_FPSCR; - - case D_MSR: - return C_MSR; - - case D_OREG: - switch(a->name) { - case D_EXTERN: - case D_STATIC: - if(a->sym == S) - break; - t = a->sym->type; - if(t == 0 || t == SXREF) { - diag("undefined external: %s in %s", - a->sym->name, TNAME); - a->sym->type = SDATA; - } - if(dlm){ - instoffset = a->sym->value + a->offset; - switch(a->sym->type){ - case STEXT: - case SLEAF: - case SCONST: - case SUNDEF: - break; - default: - instoffset += INITDAT; - } - return C_ADDR; - } - instoffset = a->sym->value + a->offset - BIG; - if(instoffset >= -BIG && instoffset < BIG) - return C_SEXT; - return C_LEXT; - case D_AUTO: - instoffset = autosize + a->offset; - if(instoffset >= -BIG && instoffset < BIG) - return C_SAUTO; - return C_LAUTO; - case D_PARAM: - instoffset = autosize + a->offset + 8L; - if(instoffset >= -BIG && instoffset < BIG) - return C_SAUTO; - return C_LAUTO; - case D_NONE: - instoffset = a->offset; - if(instoffset == 0) - return C_ZOREG; - if(instoffset >= -BIG && instoffset < BIG) - return C_SOREG; - return C_LOREG; - } - return C_GOK; - - case D_OPT: - instoffset = a->offset & 31L; - if(a->name == D_NONE) - return C_SCON; - return C_GOK; - - case D_CONST: - switch(a->name) { - - case D_NONE: - instoffset = a->offset; - consize: - if(instoffset >= 0) { - if(instoffset == 0) - return C_ZCON; - if(instoffset <= 0x7fff) - return C_SCON; - if(instoffset <= 0xffff) - return C_ANDCON; - if((instoffset & 0xffff) == 0 && isuint32(instoffset)) /* && (instoffset & (1<<31)) == 0) */ - return C_UCON; - if(isint32(instoffset) || isuint32(instoffset)) - return C_LCON; - return C_DCON; - } - if(instoffset >= -0x8000) - return C_ADDCON; - if((instoffset & 0xffff) == 0 && isint32(instoffset)) - return C_UCON; - if(isint32(instoffset)) - return C_LCON; - return C_DCON; - - case D_EXTERN: - case D_STATIC: - s = a->sym; - if(s == S) - break; - t = s->type; - if(t == 0 || t == SXREF) { - diag("undefined external: %s in %s", - s->name, TNAME); - s->type = SDATA; - } - if(s->type == STEXT || s->type == SLEAF || s->type == SUNDEF) { - instoffset = s->value + a->offset; - return C_LCON; - } - if(s->type == SCONST) { - instoffset = s->value + a->offset; - if(dlm) - return C_LCON; - goto consize; - } - if(!dlm){ - instoffset = s->value + a->offset - BIG; - if(instoffset >= -BIG && instoffset < BIG && instoffset != 0) - return C_SECON; - } - instoffset = s->value + a->offset + INITDAT; - if(dlm) - return C_LCON; - /* not sure why this barfs */ - return C_LCON; - /* - if(instoffset == 0) - return C_ZCON; - if(instoffset >= -0x8000 && instoffset <= 0xffff) - return C_SCON; - if((instoffset & 0xffff) == 0) - return C_UCON; - return C_LCON; - */ - - case D_AUTO: - instoffset = autosize + a->offset; - if(instoffset >= -BIG && instoffset < BIG) - return C_SACON; - return C_LACON; - - case D_PARAM: - instoffset = autosize + a->offset + 8L; - if(instoffset >= -BIG && instoffset < BIG) - return C_SACON; - return C_LACON; - } - return C_GOK; - - case D_BRANCH: - return C_SBRA; - } - return C_GOK; -} - -Optab* -oplook(Prog *p) -{ - int a1, a2, a3, a4, r; - char *c1, *c3, *c4; - Optab *o, *e; - - a1 = p->optab; - if(a1) - return optab+(a1-1); - a1 = p->from.class; - if(a1 == 0) { - a1 = aclass(&p->from) + 1; - p->from.class = a1; - } - a1--; - a3 = p->from3.class; - if(a3 == 0) { - a3 = aclass(&p->from3) + 1; - p->from3.class = a3; - } - a3--; - a4 = p->to.class; - if(a4 == 0) { - a4 = aclass(&p->to) + 1; - p->to.class = a4; - } - a4--; - a2 = C_NONE; - if(p->reg != NREG) - a2 = C_REG; - r = p->as; - o = oprange[r].start; - if(o == 0) - o = oprange[r].stop; /* just generate an error */ - e = oprange[r].stop; - c1 = xcmp[a1]; - c3 = xcmp[a3]; - c4 = xcmp[a4]; - for(; oa2 == a2) - if(c1[o->a1]) - if(c3[o->a3]) - if(c4[o->a4]) { - p->optab = (o-optab)+1; - return o; - } - diag("illegal combination %A %R %R %R %R", - p->as, a1, a2, a3, a4); - if(1||!debug['a']) - prasm(p); - if(o == 0) - errorexit(); - return o; -} - -int -cmp(int a, int b) -{ - - if(a == b) - return 1; - switch(a) { - case C_LCON: - if(b == C_ZCON || b == C_SCON || b == C_UCON || b == C_ADDCON || b == C_ANDCON) - return 1; - break; - case C_ADDCON: - if(b == C_ZCON || b == C_SCON) - return 1; - break; - case C_ANDCON: - if(b == C_ZCON || b == C_SCON) - return 1; - break; - case C_SPR: - if(b == C_LR || b == C_XER || b == C_CTR) - return 1; - break; - case C_UCON: - if(b == C_ZCON) - return 1; - break; - case C_SCON: - if(b == C_ZCON) - return 1; - break; - case C_LACON: - if(b == C_SACON) - return 1; - break; - case C_LBRA: - if(b == C_SBRA) - return 1; - break; - case C_LEXT: - if(b == C_SEXT) - return 1; - break; - case C_LAUTO: - if(b == C_SAUTO) - return 1; - break; - case C_REG: - if(b == C_ZCON) - return r0iszero; - break; - case C_LOREG: - if(b == C_ZOREG || b == C_SOREG) - return 1; - break; - case C_SOREG: - if(b == C_ZOREG) - return 1; - break; - - case C_ANY: - return 1; - } - return 0; -} - -int -ocmp(void *a1, void *a2) -{ - Optab *p1, *p2; - int n; - - p1 = a1; - p2 = a2; - n = p1->as - p2->as; - if(n) - return n; - n = p1->a1 - p2->a1; - if(n) - return n; - n = p1->a2 - p2->a2; - if(n) - return n; - n = p1->a3 - p2->a3; - if(n) - return n; - n = p1->a4 - p2->a4; - if(n) - return n; - return 0; -} - -void -buildop(void) -{ - int i, n, r; - - for(i=0; i subf Rd,ra,rb */ - oprange[ASUB] = oprange[r]; - oprange[ASUBCC] = oprange[r]; - oprange[ASUBV] = oprange[r]; - oprange[ASUBVCC] = oprange[r]; - oprange[ASUBCCC] = oprange[r]; - oprange[ASUBCV] = oprange[r]; - oprange[ASUBCVCC] = oprange[r]; - oprange[ASUBE] = oprange[r]; - oprange[ASUBECC] = oprange[r]; - oprange[ASUBEV] = oprange[r]; - oprange[ASUBEVCC] = oprange[r]; - break; - case ASYNC: - oprange[AISYNC] = oprange[r]; - oprange[APTESYNC] = oprange[r]; - oprange[ATLBSYNC] = oprange[r]; - break; - case ARLWMI: - oprange[ARLWMICC] = oprange[r]; - oprange[ARLWNM] = oprange[r]; - oprange[ARLWNMCC] = oprange[r]; - break; - case ARLDMI: - oprange[ARLDMICC] = oprange[r]; - break; - case ARLDC: - oprange[ARLDCCC] = oprange[r]; - break; - case ARLDCL: - oprange[ARLDCR] = oprange[r]; - oprange[ARLDCLCC] = oprange[r]; - oprange[ARLDCRCC] = oprange[r]; - break; - case AFMOVD: - oprange[AFMOVDCC] = oprange[r]; - oprange[AFMOVDU] = oprange[r]; - oprange[AFMOVS] = oprange[r]; - oprange[AFMOVSU] = oprange[r]; - break; - case AECIWX: - oprange[ALWAR] = oprange[r]; - break; - case ASYSCALL: /* just the op; flow of control */ - oprange[ARFI] = oprange[r]; - oprange[ARFCI] = oprange[r]; - oprange[ARFID] = oprange[r]; - oprange[AHRFID] = oprange[r]; - break; - case AMOVHBR: - oprange[AMOVWBR] = oprange[r]; - break; - case ASLBMFEE: - oprange[ASLBMFEV] = oprange[r]; - break; - case ATW: - oprange[ATD] = oprange[r]; - break; - case ATLBIE: - oprange[ASLBIE] = oprange[r]; - oprange[ATLBIEL] = oprange[r]; - break; - case AEIEIO: - oprange[ASLBIA] = oprange[r]; - break; - case ACMP: - oprange[ACMPW] = oprange[r]; - break; - case ACMPU: - oprange[ACMPWU] = oprange[r]; - break; - case AADD: - case AANDCC: /* and. Rb,Rs,Ra; andi. $uimm,Rs,Ra; andis. $uimm,Rs,Ra */ - case ALSW: - case AMOVW: /* load/store/move word with sign extension; special 32-bit move; move 32-bit literals */ - case AMOVWZ: /* load/store/move word with zero extension; move 32-bit literals */ - case AMOVD: /* load/store/move 64-bit values, including 32-bit literals with/without sign-extension */ - case AMOVB: /* macro: move byte with sign extension */ - case AMOVBU: /* macro: move byte with sign extension & update */ - case AMOVFL: - case AMULLW: /* op $s[,r2],r3; op r1[,r2],r3; no cc/v */ - case ASUBC: /* op r1,$s,r3; op r1[,r2],r3 */ - case ASTSW: - case ASLBMTE: - case AWORD: - case ADWORD: - case ANOP: - case ATEXT: - break; - } - } -} - enum{ ABSD = 0, ABSU = 1,