Commit dc78c64f authored by Ken Thompson's avatar Ken Thompson

byte multiply

R=r
OCL=18807
CL=18807
parent 434c6052
...@@ -122,7 +122,10 @@ cgen(Node *n, Node *res) ...@@ -122,7 +122,10 @@ cgen(Node *n, Node *res)
case OADD: case OADD:
case OMUL: case OMUL:
a = optoas(n->op, nl->type); a = optoas(n->op, nl->type);
goto sbop; if(a != AIMULB)
goto sbop;
cgen_bmul(n->op, nl, nr, res);
break;
// asymmetric binary // asymmetric binary
case OSUB: case OSUB:
......
...@@ -1095,6 +1095,35 @@ ret: ...@@ -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 void
checklabels(void) checklabels(void)
{ {
......
...@@ -138,6 +138,7 @@ void cgen_callinter(Node*, Node*, int); ...@@ -138,6 +138,7 @@ void cgen_callinter(Node*, Node*, int);
void cgen_proc(Node*); void cgen_proc(Node*);
void cgen_callret(Node*, Node*); void cgen_callret(Node*, Node*);
void cgen_div(int, Node*, Node*, Node*); void cgen_div(int, Node*, Node*, Node*);
void cgen_bmul(int, Node*, Node*, Node*);
void cgen_shift(int, Node*, Node*, Node*); void cgen_shift(int, Node*, Node*, Node*);
void genpanic(void); void genpanic(void);
int needconvert(Type*, Type*); int needconvert(Type*, Type*);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment