mirror of
https://github.com/golang/go
synced 2024-10-05 16:41:21 -06:00
[dev.power64] cmd/9g: introduce ginscon2 for CMP/CMPU, use ginscon to ADD constants
LGTM=rsc R=rsc, iant CC=golang-codereviews https://golang.org/cl/125170043
This commit is contained in:
parent
9b88857f75
commit
893f28ca16
@ -690,8 +690,7 @@ agenr(Node *n, Node *a, Node *res)
|
|||||||
n1.xoffset = Array_nel;
|
n1.xoffset = Array_nel;
|
||||||
regalloc(&n4, n1.type, N);
|
regalloc(&n4, n1.type, N);
|
||||||
gmove(&n1, &n4);
|
gmove(&n1, &n4);
|
||||||
nodconst(&n2, types[TUINT64], v);
|
ginscon2(optoas(OCMP, types[TUINT64]), &n4, v);
|
||||||
gins(optoas(OCMP, types[TUINT64]), &n4, &n2);
|
|
||||||
regfree(&n4);
|
regfree(&n4);
|
||||||
p1 = gbranch(optoas(OGT, types[TUINT64]), T, +1);
|
p1 = gbranch(optoas(OGT, types[TUINT64]), T, +1);
|
||||||
ginscall(panicindex, 0);
|
ginscall(panicindex, 0);
|
||||||
@ -706,8 +705,7 @@ agenr(Node *n, Node *a, Node *res)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (v*w != 0) {
|
if (v*w != 0) {
|
||||||
nodconst(&n2, types[tptr], v*w);
|
ginscon(optoas(OADD, types[tptr]), v*w, &n3);
|
||||||
gins(optoas(OADD, types[tptr]), &n2, &n3);
|
|
||||||
}
|
}
|
||||||
*a = n3;
|
*a = n3;
|
||||||
break;
|
break;
|
||||||
|
@ -87,6 +87,7 @@ Node* nodarg(Type*, int);
|
|||||||
void nodreg(Node*, Type*, int);
|
void nodreg(Node*, Type*, int);
|
||||||
void nodindreg(Node*, Type*, int);
|
void nodindreg(Node*, Type*, int);
|
||||||
void ginscon(int, vlong, Node*);
|
void ginscon(int, vlong, Node*);
|
||||||
|
void ginscon2(int, Node*, vlong);
|
||||||
void buildtxt(void);
|
void buildtxt(void);
|
||||||
Plist* newplist(void);
|
Plist* newplist(void);
|
||||||
int isfat(Type*);
|
int isfat(Type*);
|
||||||
|
@ -562,6 +562,40 @@ ginscon(int as, vlong c, Node *n2)
|
|||||||
gins(as, &n1, n2);
|
gins(as, &n1, n2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* generate
|
||||||
|
* as n, $c (CMP/CMPU)
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
ginscon2(int as, Node *n2, vlong c)
|
||||||
|
{
|
||||||
|
Node n1, ntmp;
|
||||||
|
|
||||||
|
nodconst(&n1, types[TINT64], c);
|
||||||
|
|
||||||
|
switch(as) {
|
||||||
|
default:
|
||||||
|
fatal("ginscon2");
|
||||||
|
case ACMP:
|
||||||
|
if(-BIG <= c && c <= BIG) {
|
||||||
|
gins(as, n2, &n1);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case ACMPU:
|
||||||
|
if(0 <= c && c <= 2*BIG) {
|
||||||
|
gins(as, n2, &n1);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// MOV n1 into register first
|
||||||
|
regalloc(&ntmp, types[TINT64], N);
|
||||||
|
gins(AMOVD, &n1, &ntmp);
|
||||||
|
gins(as, n2, &ntmp);
|
||||||
|
regfree(&ntmp);
|
||||||
|
}
|
||||||
|
|
||||||
#define CASE(a,b) (((a)<<16)|((b)<<0))
|
#define CASE(a,b) (((a)<<16)|((b)<<0))
|
||||||
/*c2go int CASE(int, int); */
|
/*c2go int CASE(int, int); */
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user