4 * this is machine dependent, but it is totally
5 * common on all of the 64-bit symulating machines.
8 #define FNX 100 /* botch -- redefinition */
75 char etconv[NTYPE]; /* for _vasop */
92 fvn(char *name, int type)
97 n->sym = slookup(name);
98 n->sym->sig = SIGINTERN;
99 if(fntypes[type] == 0)
100 fntypes[type] = typ(TFUNC, types[type]);
101 n->type = fntypes[type];
114 nodaddv = fvn("_addv", TVLONG);
115 nodsubv = fvn("_subv", TVLONG);
116 nodmulv = fvn("_mulv", TVLONG);
117 noddivv = fvn("_divv", TVLONG);
118 noddivvu = fvn("_divvu", TVLONG);
119 nodmodv = fvn("_modv", TVLONG);
120 nodmodvu = fvn("_modvu", TVLONG);
121 nodlshv = fvn("_lshv", TVLONG);
122 nodrshav = fvn("_rshav", TVLONG);
123 nodrshlv = fvn("_rshlv", TVLONG);
124 nodandv = fvn("_andv", TVLONG);
125 nodorv = fvn("_orv", TVLONG);
126 nodxorv = fvn("_xorv", TVLONG);
127 nodnegv = fvn("_negv", TVLONG);
128 nodcomv = fvn("_comv", TVLONG);
130 nodtestv = fvn("_testv", TLONG);
131 nodeqv = fvn("_eqv", TLONG);
132 nodnev = fvn("_nev", TLONG);
133 nodlev = fvn("_lev", TLONG);
134 nodltv = fvn("_ltv", TLONG);
135 nodgev = fvn("_gev", TLONG);
136 nodgtv = fvn("_gtv", TLONG);
137 nodhiv = fvn("_hiv", TLONG);
138 nodhsv = fvn("_hsv", TLONG);
139 nodlov = fvn("_lov", TLONG);
140 nodlsv = fvn("_lsv", TLONG);
142 nodf2v = fvn("_f2v", TVLONG);
143 nodd2v = fvn("_d2v", TVLONG);
144 nodp2v = fvn("_p2v", TVLONG);
145 nodsi2v = fvn("_si2v", TVLONG);
146 nodui2v = fvn("_ui2v", TVLONG);
147 nodsl2v = fvn("_sl2v", TVLONG);
148 nodul2v = fvn("_ul2v", TVLONG);
149 nodsh2v = fvn("_sh2v", TVLONG);
150 noduh2v = fvn("_uh2v", TVLONG);
151 nodsc2v = fvn("_sc2v", TVLONG);
152 noduc2v = fvn("_uc2v", TVLONG);
154 nodv2f = fvn("_v2f", TFLOAT);
155 nodv2d = fvn("_v2d", TDOUBLE);
156 noduv2f = fvn("_uv2f", TFLOAT);
157 noduv2d = fvn("_uv2d", TDOUBLE);
158 nodv2sl = fvn("_v2sl", TLONG);
159 nodv2ul = fvn("_v2ul", TULONG);
160 nodv2si = fvn("_v2si", TINT);
161 nodv2ui = fvn("_v2ui", TUINT);
162 nodv2sh = fvn("_v2sh", TSHORT);
163 nodv2uh = fvn("_v2ul", TUSHORT);
164 nodv2sc = fvn("_v2sc", TCHAR);
165 nodv2uc = fvn("_v2uc", TUCHAR);
167 nodvpp = fvn("_vpp", TVLONG);
168 nodppv = fvn("_ppv", TVLONG);
169 nodvmm = fvn("_vmm", TVLONG);
170 nodmmv = fvn("_mmv", TVLONG);
172 nodaddd = fvn("_vasaddd", TVLONG);
173 nodsubd = fvn("_vassubd", TVLONG);
174 nodmuld = fvn("_vasmuld", TVLONG);
175 noddivd = fvn("_vasdivd", TVLONG);
177 nodvasop = fvn("_vasop", TVLONG);
179 for(p = initetconv; p->code >= 0; p++)
180 etconv[p->code] = p->value;
196 if(l && l->type && typev[l->type->etype])
199 if(r && r->type && typev[r->type->etype])
241 r = new(OFUNC, nodtestv, r);
245 r->type = types[TLONG];
253 l = new(OFUNC, nodtestv, l);
257 l->type = types[TLONG];
269 r = new(OFUNC, nodtestv, r);
273 r->type = types[TLONG];
280 if(typev[n->type->etype]) {
285 diag(n, "unknown vlong %O", n->op);
353 switch(l->type->etype) {
388 diag(n, "unknown %T->vlong cast", l->type);
434 if(l->type && typev[l->type->etype]) {
437 switch(n->type->etype) {
439 if(l->type->etype == TUVLONG)
445 if(l->type->etype == TUVLONG)
474 case TIND: // small pun here
478 diag(n, "unknown vlong->%T cast", n->type);
487 n->right = new(OLIST, l, r);
493 l = new(OCAST, l, 0);
494 l->type = types[TLONG];
495 l->complex = l->left->complex;
506 l = new(OADDR, l, Z);
507 l->type = typ(TIND, l->left->type);
508 l->complex = l->left->complex;
509 n->right = new(OLIST, l, r);
518 n->right = new(OLIST, l, r);
521 n->type = types[TLONG];
525 while(l->op == OFUNC)
528 if(mixedasop(n->left->type, n->right->type)) {
529 if(n->right->type->etype != TDOUBLE) {
530 r = new(OCAST, r, 0);
531 r->type = types[TDOUBLE];
534 if(l->type->etype == TUVLONG)
539 t = new(OADDR, a, 0);
540 t->type = typ(TIND, a->type);
541 r = new(OLIST, t, r);
543 t = new(OADDR, l, 0);
544 t->type = typ(TIND, l->type);
545 t->complex = l->complex;
546 r = new(OLIST, t, r);
549 default: diag(n, "mixed vlong/double %O not implemented", n->op);
550 case OASADD: a = nodaddd; break;
551 case OASSUB: a = nodsubd; break;
552 case OASMUL: a = nodmuld; break;
553 case OASDIV: a = noddivd; break;
564 t = new(OCONST, 0, 0);
565 t->vconst = etconv[l->type->etype];
566 t->type = types[TLONG];
568 r = new(OLIST, t, r);
570 t = new(OADDR, a, 0);
571 t->type = typ(TIND, a->type);
572 r = new(OLIST, t, r);
574 t = new(OADDR, l, 0);
575 t->type = typ(TIND, l->type);
576 t->complex = l->complex;
577 r = new(OLIST, t, r);
594 if(typev[n->type->etype]) {
595 n1 = new(OXXX, 0, 0);
603 n->type = types[TLONG];
608 * more machine depend stuff.
609 * this is common for 8,16,32,64 bit machines.
610 * this is common for ieee machines.
632 convftox(double d, int et)
636 diag(Z, "bad type in castftox %s", tnames[et]);
641 convvtox(vlong c, int et)