if(lv) {
switch(n->op) {
case OEQ:
a = nodeqv;
goto setbool;
case ONE:
a = nodnev;
goto setbool;
case OLE:
a = nodlev;
goto setbool;
case OLT:
a = nodltv;
goto setbool;
case OGE:
a = nodgev;
goto setbool;
case OGT:
a = nodgtv;
goto setbool;
case OHI:
a = nodhiv;
goto setbool;
case OHS:
a = nodhsv;
goto setbool;
case OLO:
a = nodlov;
goto setbool;
case OLS:
a = nodlsv;
goto setbool;
case OANDAND:
case OOROR:
if(machcap(n))
return 1;
if(rv) {
if(machcap(n))
return 1;
switch(n->op) {
case OANDAND:
case OOROR:
r = new(OFUNC, nodtestv, r);
n->right = r;
r->complex = FNX;
r->op = OFUNC;
r->type = types[TLONG];
return 1;
case OCOND:
return 1;
}
}
if(typev[n->type->etype]) {
if(machcap(n))
return 1;
switch(n->op) {
default:
diag(n, "unknown vlong %O", n->op);
case OFUNC:
n->complex = FNX;
case ORETURN:
case OAS:
case OIND:
case OLIST:
case OCOMMA:
return 1;
case OADD:
a = nodaddv;
goto setbop;
case OSUB:
a = nodsubv;
goto setbop;
case OMUL:
case OLMUL:
a = nodmulv;
goto setbop;
case ODIV:
a = noddivv;
goto setbop;
case OLDIV:
a = noddivvu;
goto setbop;
case OMOD:
a = nodmodv;
goto setbop;
case OLMOD:
a = nodmodvu;
goto setbop;
case OASHL:
a = nodlshv;
goto setbop;
case OASHR:
a = nodrshav;
goto setbop;
case OLSHR:
a = nodrshlv;
goto setbop;
case OAND:
a = nodandv;
goto setbop;
case OOR:
a = nodorv;
goto setbop;
case OXOR:
a = nodxorv;
goto setbop;
case OPOSTINC:
a = nodvpp;
goto setvinc;
case OPOSTDEC:
a = nodvmm;
goto setvinc;
case OPREINC:
a = nodppv;
goto setvinc;
case OPREDEC:
a = nodmmv;
goto setvinc;
case ONEG:
a = nodnegv;
goto setfnx;
case OCOM:
a = nodcomv;
goto setfnx;
case OCAST:
switch(l->type->etype) {
case TCHAR:
a = nodsc2v;
goto setfnxl;
case TUCHAR:
a = noduc2v;
goto setfnxl;
case TSHORT:
a = nodsh2v;
goto setfnxl;
case TUSHORT:
a = noduh2v;
goto setfnxl;
case TINT:
a = nodsi2v;
goto setfnx;
case TUINT:
a = nodui2v;
goto setfnx;
case TLONG:
a = nodsl2v;
goto setfnx;
case TULONG:
a = nodul2v;
goto setfnx;
case TFLOAT:
a = nodf2v;
goto setfnx;
case TDOUBLE:
a = nodd2v;
goto setfnx;
case TIND:
a = nodp2v;
goto setfnx;
}
diag(n, "unknown %T->vlong cast", l->type);
return 1;
case OASADD:
a = nodaddv;
goto setasop;
case OASSUB:
a = nodsubv;
goto setasop;
case OASMUL:
case OASLMUL:
a = nodmulv;
goto setasop;
case OASDIV:
a = noddivv;
goto setasop;
case OASLDIV:
a = noddivvu;
goto setasop;
case OASMOD:
a = nodmodv;
goto setasop;
case OASLMOD:
a = nodmodvu;
goto setasop;
case OASASHL:
a = nodlshv;
goto setasop;
case OASASHR:
a = nodrshav;
goto setasop;
case OASLSHR:
a = nodrshlv;
goto setasop;
case OASAND:
a = nodandv;
goto setasop;
case OASOR:
a = nodorv;
goto setasop;
case OASXOR:
a = nodxorv;
goto setasop;
}
}
if(n->op == OCAST) {
if(l->type && typev[l->type->etype]) {
if(machcap(n))
return 1;
switch(n->type->etype) {
case TDOUBLE:
if(l->type->etype == TUVLONG)
a = noduv2d;
else
a = nodv2d;
goto setfnx;
case TFLOAT:
if(l->type->etype == TUVLONG)
a = noduv2f;
else
a = nodv2f;
goto setfnx;
case TLONG:
a = nodv2sl;
goto setfnx;
case TULONG:
a = nodv2ul;
goto setfnx;
case TINT:
a = nodv2si;
goto setfnx;
case TUINT:
a = nodv2ui;
goto setfnx;
case TSHORT:
a = nodv2sh;
goto setfnx;
case TUSHORT:
a = nodv2uh;
goto setfnx;
case TCHAR:
a = nodv2sc;
goto setfnx;
case TUCHAR:
a = nodv2uc;
goto setfnx;
case TIND: // small pun here
a = nodv2ul;
goto setfnx;
}
diag(n, "unknown vlong->%T cast", n->type);
return 1;
}
}
if(l->type->etype == TUVLONG)
a = noduv2d;
else
a = nodv2d;
t = new(OADDR, a, 0);
t->type = typ(TIND, a->type);
r = new(OLIST, t, r);
t = new(OADDR, l, 0);
t->type = typ(TIND, l->type);
t->complex = l->complex;
r = new(OLIST, t, r);
switch(n->op){
default: diag(n, "mixed vlong/double %O not implemented", n->op);
case OASADD: a = nodaddd; break;
case OASSUB: a = nodsubd; break;
case OASMUL: a = nodmuld; break;
case OASDIV: a = noddivd; break;
}
/*
* more machine depend stuff.
* this is common for 8,16,32,64 bit machines.
* this is common for ieee machines.
*/
double
convvtof(vlong v)
{
double d;
d = v; /* BOTCH */
return d;
}
vlong
convftov(double d)
{
vlong v;
v = d; /* BOTCH */
return v;
}
double
convftox(double d, int et)
{
if(!typefd[et])
diag(Z, "bad type in castftox %s", tnames[et]);
return d;
}
vlong
convvtox(vlong c, int et)
{
int n;
n = 8 * ewidth[et];
c &= MASK(n);
if(!typeu[et])
if(c & SIGN(n))
c |= ~MASK(n);
return c;
}