1
0
mirror of https://github.com/golang/go synced 2024-11-26 17:07:09 -07:00

byte multiply

R=r
OCL=18807
CL=18807
This commit is contained in:
Ken Thompson 2008-11-07 14:20:32 -08:00
parent 434c6052d8
commit dc78c64f23
3 changed files with 34 additions and 1 deletions

View File

@ -122,7 +122,10 @@ cgen(Node *n, Node *res)
case OADD:
case OMUL:
a = optoas(n->op, nl->type);
goto sbop;
if(a != AIMULB)
goto sbop;
cgen_bmul(n->op, nl, nr, res);
break;
// asymmetric binary
case OSUB:

View File

@ -1095,6 +1095,35 @@ ret:
;
}
void
cgen_bmul(int op, Node *nl, Node *nr, Node *res)
{
Node n1, n2;
Type *t;
int a;
t = types[TUINT16];
if(issigned[nl->type->etype])
t = types[TINT16];
if(nl->ullman >= nr->ullman) {
regalloc(&n1, t, nl);
cgen(nl, &n1);
regalloc(&n2, t, nr);
cgen(nr, &n2);
} else {
regalloc(&n2, t, nr);
cgen(nr, &n2);
regalloc(&n1, t, nl);
cgen(nl, &n1);
}
a = optoas(op, t);
gins(a, &n2, &n1);
gmove(&n1, res);
regfree(&n1);
regfree(&n2);
}
void
checklabels(void)
{

View File

@ -138,6 +138,7 @@ void cgen_callinter(Node*, Node*, int);
void cgen_proc(Node*);
void cgen_callret(Node*, Node*);
void cgen_div(int, Node*, Node*, Node*);
void cgen_bmul(int, Node*, Node*, Node*);
void cgen_shift(int, Node*, Node*, Node*);
void genpanic(void);
int needconvert(Type*, Type*);