cgen.c 28 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396
  1. #include "gc.h"
  2. void
  3. cgen(Node *n, int result, Node *nn)
  4. {
  5. Node *l, *r, nod;
  6. int lg, rg, xg, yg, g, o;
  7. long v;
  8. Prog *p1;
  9. if(n == Z || n->type == T)
  10. return;
  11. if(typesuv[n->type->etype]) {
  12. sugen(n, result, nn, n->type->width);
  13. return;
  14. }
  15. if(debug['g']) {
  16. if(result == D_TREE)
  17. prtree(nn, "result");
  18. else
  19. print("result = %R\n", result);
  20. prtree(n, "cgen");
  21. }
  22. l = n->left;
  23. r = n->right;
  24. o = n->op;
  25. if(n->addable >= INDEXED) {
  26. if(result == D_NONE) {
  27. if(nn == Z)
  28. switch(o) {
  29. default:
  30. nullwarn(Z, Z);
  31. break;
  32. case OINDEX:
  33. nullwarn(l, r);
  34. break;
  35. }
  36. return;
  37. }
  38. gmove(n->type, nn->type, D_TREE, n, result, nn);
  39. return;
  40. }
  41. v = 0; /* set */
  42. switch(o) {
  43. default:
  44. diag(n, "unknown op in cgen: %O", o);
  45. break;
  46. case OAS:
  47. if(l->op == OBIT)
  48. goto bitas;
  49. /*
  50. * recursive use of result
  51. */
  52. if(result == D_NONE)
  53. if(l->addable > INDEXED)
  54. if(l->complex < FNX) {
  55. cgen(r, D_TREE, l);
  56. break;
  57. }
  58. /*
  59. * function calls on both sides
  60. */
  61. if(l->complex >= FNX && r->complex >= FNX) {
  62. cgen(r, D_TOS, r);
  63. v = argoff;
  64. lg = regaddr(result);
  65. lcgen(l, lg, Z);
  66. lg |= I_INDIR;
  67. adjsp(v - argoff);
  68. gmove(r->type, l->type, D_TOS, r, lg, l);
  69. if(result != D_NONE)
  70. gmove(l->type, nn->type, lg, l, result, nn);
  71. regfree(lg);
  72. break;
  73. }
  74. rg = D_TREE;
  75. lg = D_TREE;
  76. if(r->complex >= l->complex) {
  77. /*
  78. * right side before left
  79. */
  80. if(result != D_NONE) {
  81. rg = regalloc(n->type, result);
  82. cgen(r, rg, n);
  83. } else
  84. if(r->complex >= FNX || r->addable < INDEXED) {
  85. rg = regalloc(r->type, result);
  86. cgen(r, rg, r);
  87. }
  88. if(l->addable < INDEXED) {
  89. lg = regaddr(lg);
  90. lcgen(l, lg, Z);
  91. lg |= I_INDIR;
  92. }
  93. } else {
  94. /*
  95. * left before right
  96. */
  97. if(l->complex >= FNX || l->addable < INDEXED) {
  98. lg = regaddr(lg);
  99. lcgen(l, lg, Z);
  100. lg |= I_INDIR;
  101. }
  102. if(result != D_NONE) {
  103. rg = regalloc(n->type, result);
  104. cgen(r, rg, n);
  105. } else
  106. if(r->addable < INDEXED) {
  107. rg = regalloc(r->type, result);
  108. cgen(r, rg, r);
  109. }
  110. }
  111. if(result != D_NONE) {
  112. gmove(n->type, l->type, rg, r, lg, l);
  113. gmove(n->type, nn->type, rg, r, result, nn);
  114. } else
  115. gmove(r->type, l->type, rg, r, lg, l);
  116. regfree(lg);
  117. regfree(rg);
  118. break;
  119. bitas:
  120. n = l->left;
  121. rg = regalloc(tfield, result);
  122. if(l->complex >= r->complex) {
  123. lg = regaddr(D_NONE);
  124. lcgen(n, lg, Z);
  125. lg |= I_INDIR;
  126. cgen(r, rg, r);
  127. } else {
  128. cgen(r, rg, r);
  129. lg = regaddr(D_NONE);
  130. lcgen(n, lg, Z);
  131. lg |= I_INDIR;
  132. }
  133. g = regalloc(n->type, D_NONE);
  134. gmove(l->type, l->type, lg, l, g, l);
  135. bitstore(l, rg, lg, g, result, nn);
  136. break;
  137. case OBIT:
  138. if(result == D_NONE) {
  139. nullwarn(l, Z);
  140. break;
  141. }
  142. g = bitload(n, D_NONE, D_NONE, result, nn);
  143. gopcode(OAS, nn->type, g, n, result, nn);
  144. regfree(g);
  145. break;
  146. case ODOT:
  147. sugen(l, D_TREE, nodrat, l->type->width);
  148. if(result != D_NONE) {
  149. warn(n, "non-interruptable temporary");
  150. nod = *nodrat;
  151. if(!r || r->op != OCONST) {
  152. diag(n, "DOT and no offset");
  153. break;
  154. }
  155. nod.xoffset += r->vconst;
  156. nod.type = n->type;
  157. cgen(&nod, result, nn);
  158. }
  159. break;
  160. case OASLDIV:
  161. case OASLMOD:
  162. case OASDIV:
  163. case OASMOD:
  164. if(l->op == OBIT)
  165. goto asbitop;
  166. if(typefd[n->type->etype])
  167. goto asbinop;
  168. rg = D_TREE;
  169. if(l->complex >= FNX || r->complex >= FNX) {
  170. rg = D_TOS;
  171. cgen(r, rg, r);
  172. v = argoff;
  173. } else
  174. if(r->addable < INDEXED) {
  175. rg = regalloc(n->type, D_NONE);
  176. cgen(r, rg, r);
  177. }
  178. lg = D_TREE;
  179. if(!simplv(l)) {
  180. lg = regaddr(D_NONE);
  181. lcgen(l, lg, Z); /* destroys register optimization */
  182. lg |= I_INDIR;
  183. }
  184. g = regpair(result);
  185. gmove(l->type, n->type, lg, l, g, n);
  186. if(rg == D_TOS)
  187. adjsp(v - argoff);
  188. gopcode(o, n->type, rg, r, g, n);
  189. if(o == OASLMOD || o == OASMOD)
  190. gmove(n->type, l->type, g+1, n, lg, l);
  191. else
  192. gmove(n->type, l->type, g, n, lg, l);
  193. if(result != D_NONE)
  194. if(o == OASLMOD || o == OASMOD)
  195. gmove(n->type, nn->type, g+1, n, result, nn);
  196. else
  197. gmove(n->type, nn->type, g, n, result, nn);
  198. regfree(g);
  199. regfree(g+1);
  200. regfree(lg);
  201. regfree(rg);
  202. break;
  203. case OASXOR:
  204. case OASAND:
  205. case OASOR:
  206. if(l->op == OBIT)
  207. goto asbitop;
  208. if(l->complex >= FNX ||
  209. l->addable < INDEXED ||
  210. result != D_NONE ||
  211. typefd[n->type->etype])
  212. goto asbinop;
  213. rg = D_TREE;
  214. if(r->op != OCONST) {
  215. rg = regalloc(n->type, D_NONE);
  216. cgen(r, rg, r);
  217. }
  218. gopcode(o, l->type, rg, r, D_TREE, l);
  219. regfree(rg);
  220. break;
  221. case OASADD:
  222. case OASSUB:
  223. if(l->op == OBIT ||
  224. l->complex >= FNX ||
  225. l->addable < INDEXED ||
  226. result != D_NONE ||
  227. typefd[n->type->etype])
  228. goto asbinop;
  229. v = vconst(r);
  230. if(v > 0 && v <= 8) {
  231. gopcode(o, n->type, D_TREE, r, D_TREE, l);
  232. break;
  233. }
  234. rg = regalloc(n->type, D_NONE);
  235. cgen(r, rg, r);
  236. gopcode(o, n->type, rg, r, D_TREE, l);
  237. regfree(rg);
  238. break;
  239. case OASLSHR:
  240. case OASASHR:
  241. case OASASHL:
  242. if(l->op == OBIT ||
  243. l->complex >= FNX ||
  244. l->addable < INDEXED ||
  245. result != D_NONE ||
  246. typefd[n->type->etype])
  247. goto asbinop;
  248. rg = D_TREE;
  249. v = vconst(r);
  250. if(v <= 0 || v > 8) {
  251. rg = regalloc(n->type, D_NONE);
  252. cgen(r, rg, r);
  253. }
  254. lg = regalloc(n->type, D_NONE);
  255. cgen(l, lg, l);
  256. gopcode(o, n->type, rg, r, lg, l);
  257. gmove(n->type, n->type, lg, l, D_TREE, l);
  258. regfree(lg);
  259. regfree(rg);
  260. break;
  261. case OASLMUL:
  262. case OASMUL:
  263. asbinop:
  264. if(l->op == OBIT)
  265. goto asbitop;
  266. rg = D_TREE;
  267. if(l->complex >= FNX || r->complex >= FNX) {
  268. rg = D_TOS;
  269. cgen(r, rg, r);
  270. v = argoff;
  271. } else
  272. if(r->addable < INDEXED) {
  273. rg = regalloc(n->type, D_NONE);
  274. cgen(r, rg, r);
  275. } else {
  276. if(o == OASLSHR || o == OASASHR || o == OASASHL) {
  277. v = vconst(r);
  278. if(v <= 0 || v > 8) {
  279. rg = regalloc(n->type, D_NONE);
  280. cgen(r, rg, r);
  281. }
  282. }
  283. }
  284. lg = D_TREE;
  285. if(!simplv(l)) {
  286. lg = regaddr(D_NONE);
  287. lcgen(l, lg, Z); /* destroys register optimization */
  288. lg |= I_INDIR;
  289. }
  290. g = regalloc(n->type, result);
  291. gmove(l->type, n->type, lg, l, g, n);
  292. if(rg == D_TOS)
  293. adjsp(v - argoff);
  294. if(o == OASXOR)
  295. if(rg == D_TREE) {
  296. rg = regalloc(n->type, D_NONE);
  297. cgen(r, rg, r);
  298. }
  299. if(o == OASXOR || o == OASLSHR || o == OASASHR || o == OASASHL)
  300. if(rg == D_TOS) {
  301. rg = regalloc(n->type, D_NONE);
  302. gmove(n->type, n->type, D_TOS, n, rg, n);
  303. }
  304. gopcode(o, n->type, rg, r, g, n);
  305. gmove(n->type, l->type, g, n, lg, l);
  306. if(result != D_NONE)
  307. gmove(n->type, nn->type, g, n, result, nn);
  308. regfree(g);
  309. regfree(lg);
  310. regfree(rg);
  311. break;
  312. asbitop:
  313. rg = regaddr(D_NONE);
  314. lg = regalloc(tfield, D_NONE);
  315. if(l->complex >= r->complex) {
  316. g = bitload(l, lg, rg, result, nn);
  317. xg = regalloc(r->type, D_NONE);
  318. cgen(r, xg, nn);
  319. } else {
  320. xg = regalloc(r->type, D_NONE);
  321. cgen(r, xg, nn);
  322. g = bitload(l, lg, rg, result, nn);
  323. }
  324. if(!typefd[n->type->etype]) {
  325. if(o == OASLDIV || o == OASDIV) {
  326. yg = regpair(result);
  327. gmove(tfield, n->type, g, l, yg, n);
  328. gopcode(o, n->type, xg, r, yg, n);
  329. gmove(n->type, tfield, yg, n, g, l);
  330. regfree(yg);
  331. regfree(yg+1);
  332. regfree(xg);
  333. bitstore(l, g, rg, lg, D_NONE, nn);
  334. break;
  335. }
  336. if(o == OASLMOD || o == OASMOD) {
  337. yg = regpair(result);
  338. gmove(tfield, n->type, g, l, yg, n);
  339. gopcode(o, n->type, xg, r, yg, n);
  340. gmove(n->type, tfield, yg+1, n, g, l);
  341. regfree(yg);
  342. regfree(yg+1);
  343. regfree(xg);
  344. bitstore(l, g, rg, lg, D_NONE, nn);
  345. break;
  346. }
  347. }
  348. yg = regalloc(n->type, result);
  349. gmove(tfield, n->type, g, l, yg, n);
  350. gopcode(o, n->type, xg, r, yg, n);
  351. gmove(n->type, tfield, yg, n, g, l);
  352. regfree(yg);
  353. regfree(xg);
  354. bitstore(l, g, rg, lg, D_NONE, nn);
  355. break;
  356. case OCAST:
  357. if(result == D_NONE) {
  358. nullwarn(l, Z);
  359. break;
  360. }
  361. lg = result;
  362. if(l->complex >= FNX)
  363. lg = regret(l->type);
  364. lg = eval(l, lg);
  365. if(nocast(l->type, n->type)) {
  366. gmove(n->type, nn->type, lg, l, result, nn);
  367. regfree(lg);
  368. break;
  369. }
  370. if(nocast(n->type, nn->type)) {
  371. gmove(l->type, n->type, lg, l, result, nn);
  372. regfree(lg);
  373. break;
  374. }
  375. rg = regalloc(n->type, result);
  376. gmove(l->type, n->type, lg, l, rg, n);
  377. gmove(n->type, nn->type, rg, n, result, nn);
  378. regfree(rg);
  379. regfree(lg);
  380. break;
  381. case OCOND:
  382. doinc(l, PRE);
  383. boolgen(l, 1, D_NONE, Z, l);
  384. p1 = p;
  385. inargs++;
  386. doinc(r->left, PRE);
  387. cgen(r->left, result, nn);
  388. doinc(r->left, POST);
  389. gbranch(OGOTO);
  390. patch(p1, pc);
  391. p1 = p;
  392. doinc(r->right, PRE);
  393. cgen(r->right, result, nn);
  394. doinc(r->right, POST);
  395. patch(p1, pc);
  396. inargs--;
  397. break;
  398. case OIND:
  399. if(result == D_NONE) {
  400. nullwarn(l, Z);
  401. break;
  402. }
  403. lg = nodalloc(types[TIND], result, &nod);
  404. nod.lineno = n->lineno;
  405. if(l->op == OADD) {
  406. if(l->left->op == OCONST) {
  407. nod.xoffset += l->left->vconst;
  408. l = l->right;
  409. } else
  410. if(l->right->op == OCONST) {
  411. nod.xoffset += l->right->vconst;
  412. l = l->left;
  413. }
  414. }
  415. cgen(l, lg, l);
  416. gmove(n->type, nn->type, D_TREE, &nod, result, nn);
  417. regfree(lg);
  418. break;
  419. case OFUNC:
  420. v = argoff;
  421. inargs++;
  422. gargs(r);
  423. lg = D_TREE;
  424. if(l->addable < INDEXED) {
  425. lg = regaddr(result);
  426. lcgen(l, lg, Z);
  427. lg |= I_INDIR;
  428. }
  429. inargs--;
  430. doinc(r, POST);
  431. doinc(l, POST);
  432. gopcode(OFUNC, types[TCHAR], D_NONE, Z, lg, l);
  433. regfree(lg);
  434. if(inargs)
  435. adjsp(v - argoff);
  436. if(result != D_NONE) {
  437. lg = regret(n->type);
  438. gmove(n->type, nn->type, lg, n, result, nn);
  439. }
  440. break;
  441. case OLDIV:
  442. case OLMOD:
  443. case ODIV:
  444. case OMOD:
  445. if(result == D_NONE) {
  446. nullwarn(l, r);
  447. break;
  448. }
  449. if(typefd[n->type->etype])
  450. goto binop;
  451. if(r->addable >= INDEXED && r->complex < FNX) {
  452. lg = regpair(result);
  453. cgen(l, lg, l);
  454. rg = D_TREE;
  455. } else {
  456. cgen(r, D_TOS, r);
  457. v = argoff;
  458. lg = regpair(result);
  459. cgen(l, lg, l);
  460. adjsp(v - argoff);
  461. rg = D_TOS;
  462. }
  463. gopcode(o, n->type, rg, r, lg, l);
  464. if(o == OMOD || o == OLMOD)
  465. gmove(l->type, nn->type, lg+1, l, result, nn);
  466. else
  467. gmove(l->type, nn->type, lg, l, result, nn);
  468. regfree(lg);
  469. regfree(lg+1);
  470. break;
  471. case OMUL:
  472. case OLMUL:
  473. if(l->op == OCONST)
  474. if(mulcon(r, l, result, nn))
  475. break;
  476. if(r->op == OCONST)
  477. if(mulcon(l, r, result, nn))
  478. break;
  479. if(debug['M'])
  480. print("%L multiply\n", n->lineno);
  481. goto binop;
  482. case OAND:
  483. if(r->op == OCONST)
  484. if(typeil[n->type->etype])
  485. if(l->op == OCAST) {
  486. if(typec[l->left->type->etype])
  487. if(!(r->vconst & ~0xff)) {
  488. l = l->left;
  489. goto binop;
  490. }
  491. if(typeh[l->left->type->etype])
  492. if(!(r->vconst & ~0xffff)) {
  493. l = l->left;
  494. goto binop;
  495. }
  496. }
  497. goto binop;
  498. case OADD:
  499. if(result == D_TOS)
  500. if(r->addable >= INDEXED)
  501. if(l->op == OCONST)
  502. if(typeil[l->type->etype]) {
  503. v = l->vconst;
  504. if(v > -32768 && v < 32768) {
  505. rg = regaddr(D_NONE);
  506. gmove(r->type, r->type, D_TREE, r, rg, r);
  507. gopcode(OADDR, types[TSHORT], D_NONE, Z, rg, r);
  508. p->to.offset = v;
  509. p->to.type |= I_INDIR;
  510. regfree(rg);
  511. break;
  512. }
  513. }
  514. case OSUB:
  515. if(result == D_TOS)
  516. if(l->addable >= INDEXED)
  517. if(r->op == OCONST)
  518. if(typeil[r->type->etype]) {
  519. v = r->vconst;
  520. if(v > -32768 && v < 32768) {
  521. if(n->op == OSUB)
  522. v = -v;
  523. lg = regaddr(D_NONE);
  524. gmove(l->type, l->type, D_TREE, l, lg, l);
  525. gopcode(OADDR, types[TSHORT], D_NONE, Z, lg, l);
  526. p->to.offset = v;
  527. p->to.type |= I_INDIR;
  528. regfree(lg);
  529. break;
  530. }
  531. }
  532. goto binop;
  533. case OOR:
  534. case OXOR:
  535. binop:
  536. if(result == D_NONE) {
  537. nullwarn(l, r);
  538. break;
  539. }
  540. if(l->complex >= FNX && r->complex >= FNX) {
  541. cgen(r, D_TOS, r);
  542. v = argoff;
  543. lg = regalloc(l->type, result);
  544. cgen(l, lg, l);
  545. adjsp(v - argoff);
  546. if(o == OXOR) {
  547. rg = regalloc(r->type, D_NONE);
  548. gmove(r->type, r->type, D_TOS, r, rg, r);
  549. gopcode(o, n->type, rg, r, lg, l);
  550. regfree(rg);
  551. } else
  552. gopcode(o, n->type, D_TOS, r, lg, l);
  553. gmove(n->type, nn->type, lg, l, result, nn);
  554. regfree(lg);
  555. break;
  556. }
  557. if(l->complex >= r->complex) {
  558. if(l->op == OADDR && (o == OADD || o == OSUB))
  559. lg = regaddr(result);
  560. else
  561. lg = regalloc(l->type, result);
  562. cgen(l, lg, l);
  563. rg = eval(r, D_NONE);
  564. } else {
  565. rg = regalloc(r->type, D_NONE);
  566. cgen(r, rg, r);
  567. lg = regalloc(l->type, result);
  568. cgen(l, lg, l);
  569. }
  570. if(o == OXOR) {
  571. if(rg == D_TREE) {
  572. rg = regalloc(r->type, D_NONE);
  573. cgen(r, rg, r);
  574. }
  575. if(rg == D_TOS) {
  576. rg = regalloc(r->type, D_NONE);
  577. gmove(r->type, r->type, D_TOS, r, rg, r);
  578. }
  579. }
  580. gopcode(o, n->type, rg, r, lg, l);
  581. gmove(n->type, nn->type, lg, l, result, nn);
  582. regfree(lg);
  583. regfree(rg);
  584. break;
  585. case OASHL:
  586. if(r->op == OCONST)
  587. if(shlcon(l, r, result, nn))
  588. break;
  589. case OLSHR:
  590. case OASHR:
  591. if(result == D_NONE) {
  592. nullwarn(l, r);
  593. break;
  594. }
  595. if(l->complex >= FNX && r->complex >= FNX) {
  596. cgen(r, D_TOS, r);
  597. v = argoff;
  598. lg = regalloc(l->type, result);
  599. cgen(l, lg, l);
  600. adjsp(v - argoff);
  601. rg = regalloc(r->type, D_NONE);
  602. gopcode(OAS, r->type, D_TOS, r, rg, r);
  603. gopcode(n->op, n->type, rg, r, lg, l);
  604. gmove(n->type, nn->type, lg, l, result, nn);
  605. regfree(lg);
  606. regfree(rg);
  607. break;
  608. }
  609. if(l->complex >= r->complex) {
  610. lg = regalloc(l->type, result);
  611. cgen(l, lg, l);
  612. v = vconst(r);
  613. if(v <= 0 || v > 8) {
  614. rg = regalloc(r->type, D_NONE);
  615. cgen(r, rg, r);
  616. } else
  617. rg = eval(r, D_NONE);
  618. } else {
  619. rg = regalloc(r->type, D_NONE);
  620. cgen(r, rg, r);
  621. lg = regalloc(l->type, result);
  622. cgen(l, lg, l);
  623. }
  624. gopcode(o, n->type, rg, r, lg, l);
  625. gmove(n->type, nn->type, lg, l, result, nn);
  626. regfree(lg);
  627. regfree(rg);
  628. break;
  629. case ONEG:
  630. case OCOM:
  631. if(result == D_NONE) {
  632. nullwarn(l, Z);
  633. break;
  634. }
  635. lg = regalloc(l->type, result);
  636. cgen(l, lg, l);
  637. gopcode(o, l->type, D_NONE, Z, lg, l);
  638. gmove(n->type, nn->type, lg, l, result, nn);
  639. regfree(lg);
  640. break;
  641. case OADDR:
  642. if(result == D_NONE) {
  643. nullwarn(l, Z);
  644. break;
  645. }
  646. lcgen(l, result, nn);
  647. break;
  648. case OEQ:
  649. case ONE:
  650. case OLE:
  651. case OLT:
  652. case OGE:
  653. case OGT:
  654. case OLO:
  655. case OLS:
  656. case OHI:
  657. case OHS:
  658. if(result == D_NONE) {
  659. nullwarn(l, r);
  660. break;
  661. }
  662. boolgen(n, 1, result, nn, Z);
  663. break;
  664. case OANDAND:
  665. case OOROR:
  666. boolgen(n, 1, result, nn, Z);
  667. if(result == D_NONE)
  668. patch(p, pc);
  669. break;
  670. case OCOMMA:
  671. cgen(l, D_NONE, l);
  672. doinc(l, POST);
  673. doinc(r, PRE);
  674. cgen(r, result, nn);
  675. break;
  676. case ONOT:
  677. if(result == D_NONE) {
  678. nullwarn(l, Z);
  679. break;
  680. }
  681. boolgen(n, 1, result, nn, Z);
  682. break;
  683. case OPOSTINC:
  684. case OPOSTDEC:
  685. v = 1;
  686. if(l->type->etype == TIND)
  687. v = l->type->link->width;
  688. if(o == OPOSTDEC)
  689. v = -v;
  690. if(l->op == OBIT)
  691. goto bitinc;
  692. if(nn == Z)
  693. goto pre;
  694. lg = D_TREE;
  695. if(l->addable < INDEXED) {
  696. lg = regaddr(D_NONE);
  697. lcgen(l, lg, Z);
  698. lg |= I_INDIR;
  699. }
  700. if(result != D_NONE)
  701. gmove(l->type, nn->type, lg, l, result, nn);
  702. if(typefd[n->type->etype]) {
  703. rg = regalloc(n->type, D_NONE);
  704. gmove(l->type, l->type, lg, l, rg, l);
  705. gopcode(o, n->type, D_CONST, nodconst(1), rg, l);
  706. gmove(l->type, l->type, rg, l, lg, l);
  707. regfree(rg);
  708. } else {
  709. if(v < 0)
  710. gopcode(o, n->type, D_CONST, nodconst(-v), lg, l);
  711. else
  712. gopcode(o, n->type, D_CONST, nodconst(v), lg, l);
  713. }
  714. regfree(lg);
  715. break;
  716. case OPREINC:
  717. case OPREDEC:
  718. v = 1;
  719. if(l->type->etype == TIND)
  720. v = l->type->link->width;
  721. if(o == OPREDEC)
  722. v = -v;
  723. if(l->op == OBIT)
  724. goto bitinc;
  725. pre:
  726. lg = D_TREE;
  727. if(l->addable < INDEXED) {
  728. lg = regaddr(D_NONE);
  729. lcgen(l, lg, Z);
  730. lg |= I_INDIR;
  731. }
  732. if(typefd[n->type->etype]) {
  733. rg = regalloc(n->type, D_NONE);
  734. gmove(l->type, l->type, lg, l, rg, l);
  735. gopcode(o, n->type, D_CONST, nodconst(1), rg, l);
  736. gmove(l->type, l->type, rg, l, lg, l);
  737. regfree(rg);
  738. } else {
  739. if(v < 0)
  740. gopcode(o, n->type, D_CONST, nodconst(-v), lg, l);
  741. else
  742. gopcode(o, n->type, D_CONST, nodconst(v), lg, l);
  743. }
  744. if(result != D_NONE)
  745. gmove(l->type, nn->type, lg, l, result, nn);
  746. regfree(lg);
  747. break;
  748. bitinc:
  749. rg = regaddr(D_NONE);
  750. lg = regalloc(tfield, D_NONE);
  751. if(result != D_NONE && (o == OPOSTINC || o == OPOSTDEC)) {
  752. g = bitload(l, lg, rg, D_NONE, nn);
  753. if(nn != Z)
  754. gmove(l->type, nn->type, g, l, result, nn);
  755. if(v < 0)
  756. gopcode(o, n->type, D_CONST, nodconst(-v), g, n);
  757. else
  758. gopcode(o, n->type, D_CONST, nodconst(v), g, n);
  759. bitstore(l, g, rg, lg, D_NONE, nn);
  760. break;
  761. }
  762. g = bitload(l, lg, rg, result, nn);
  763. if(v < 0)
  764. gopcode(o, n->type, D_CONST, nodconst(-v), g, n);
  765. else
  766. gopcode(o, n->type, D_CONST, nodconst(v), g, n);
  767. if(result != D_NONE)
  768. gmove(l->type, nn->type, g, l, result, nn);
  769. bitstore(l, g, rg, lg, D_NONE, nn);
  770. break;
  771. }
  772. }
  773. void
  774. lcgen(Node *n, int result, Node *nn)
  775. {
  776. Node rn;
  777. Prog *p1;
  778. int lg;
  779. if(n == Z || n->type == T)
  780. return;
  781. if(debug['g']) {
  782. if(result == D_TREE)
  783. prtree(nn, "result");
  784. else
  785. print("result = %R\n", result);
  786. prtree(n, "lcgen");
  787. }
  788. if(nn == Z) {
  789. nn = &rn;
  790. nn->type = types[TIND];
  791. }
  792. switch(n->op) {
  793. case OCOMMA:
  794. cgen(n->left, D_NONE, n->left);
  795. doinc(n->left, POST);
  796. doinc(n->right, PRE);
  797. lcgen(n->right, result, nn);
  798. break;
  799. case OCOND:
  800. doinc(n->left, PRE);
  801. boolgen(n->left, 1, D_NONE, Z, n->left);
  802. p1 = p;
  803. inargs++;
  804. doinc(n->right->left, PRE);
  805. lcgen(n->right->left, result, nn);
  806. doinc(n->right->left, POST);
  807. gbranch(OGOTO);
  808. patch(p1, pc);
  809. p1 = p;
  810. doinc(n->right->right, PRE);
  811. lcgen(n->right->right, result, nn);
  812. doinc(n->right->right, POST);
  813. patch(p1, pc);
  814. inargs--;
  815. break;
  816. case OIND:
  817. if(n->addable >= INDEXED) {
  818. if(result >= D_A0 && result < D_A0+NREG) {
  819. gopcode(OADDR, types[TLONG], D_TREE, n, result, nn);
  820. break;
  821. }
  822. if(result == D_TOS) {
  823. gopcode(OADDR, types[TSHORT], D_NONE, nn, D_TREE, n);
  824. break;
  825. }
  826. }
  827. cgen(n->left, result, nn);
  828. break;
  829. default:
  830. if(n->addable < INDEXED) {
  831. diag(n, "unknown op in lcgen: %O", n->op);
  832. break;
  833. }
  834. if(result >= D_A0 && result < D_A0+NREG) {
  835. gopcode(OADDR, types[TLONG], D_TREE, n, result, nn);
  836. break;
  837. }
  838. if(result == D_TOS) {
  839. gopcode(OADDR, types[TSHORT], D_NONE, nn, D_TREE, n);
  840. break;
  841. }
  842. lg = regaddr(result);
  843. gopcode(OADDR, types[TLONG], D_TREE, n, lg, nn);
  844. gopcode(OAS, nn->type, lg, nn, result, nn);
  845. regfree(lg);
  846. break;
  847. }
  848. }
  849. void
  850. bcgen(Node *n, int true)
  851. {
  852. boolgen(n, true, D_NONE, Z, Z);
  853. }
  854. void
  855. boolgen(Node *n, int true, int result, Node *nn, Node *post)
  856. {
  857. Prog *p1, *p2;
  858. Node *l, *r;
  859. int lg, rg, fp, o;
  860. long v;
  861. if(debug['g']) {
  862. if(result == D_TREE)
  863. prtree(nn, "result");
  864. else
  865. print("result = %R\n", result);
  866. prtree(n, "boolgen");
  867. }
  868. l = n->left;
  869. r = n->right;
  870. switch(n->op) {
  871. default:
  872. lg = eval(n, result);
  873. if(lg >= D_A0 && lg < D_A0+NREG) {
  874. rg = regalloc(types[TLONG], D_NONE);
  875. gopcode(OAS, types[TLONG], lg, n, rg, Z);
  876. regfree(rg);
  877. } else
  878. gopcode(OTST, n->type, D_NONE, Z, lg, n);
  879. regfree(lg);
  880. o = ONE;
  881. fp = typefd[n->type->etype];
  882. goto genbool;
  883. case OCONST:
  884. fp = vconst(n);
  885. if(!true)
  886. fp = !fp;
  887. gbranch(OGOTO);
  888. if(fp) {
  889. p1 = p;
  890. gbranch(OGOTO);
  891. patch(p1, pc);
  892. }
  893. goto com;
  894. case ONOT:
  895. boolgen(l, !true, result, nn, post);
  896. break;
  897. case OCOND:
  898. doinc(l, PRE);
  899. boolgen(l, 1, D_NONE, Z, l);
  900. p1 = p;
  901. inargs++;
  902. doinc(r->left, PRE);
  903. boolgen(r->left, true, result, nn, r->left);
  904. if(result != D_NONE) {
  905. doinc(r->left, POST);
  906. gbranch(OGOTO);
  907. patch(p1, pc);
  908. p1 = p;
  909. doinc(r->right, PRE);
  910. boolgen(r->right, !true, result, nn, r->right);
  911. doinc(r->right, POST);
  912. patch(p1, pc);
  913. inargs--;
  914. break;
  915. }
  916. p2 = p;
  917. gbranch(OGOTO);
  918. patch(p1, pc);
  919. p1 = p;
  920. doinc(r->right, PRE);
  921. boolgen(r->right, !true, result, nn, r->right);
  922. patch(p2, pc);
  923. p2 = p;
  924. if(doinc(post, POST|TEST)) {
  925. lg = regalloc(types[TSHORT], D_NONE);
  926. gopcode(OAS, types[TSHORT], D_CCR, Z, lg, Z);
  927. doinc(post, POST);
  928. gopcode(OAS, types[TSHORT], lg, Z, D_CCR, Z);
  929. regfree(lg);
  930. }
  931. gbranch(OGOTO);
  932. patch(p1, pc);
  933. patch(p2, pc);
  934. inargs--;
  935. goto com;
  936. case OANDAND:
  937. if(!true)
  938. goto caseor;
  939. caseand:
  940. doinc(l, PRE);
  941. boolgen(l, true, D_NONE, Z, l);
  942. p1 = p;
  943. inargs++;
  944. doinc(r, PRE);
  945. boolgen(r, !true, D_NONE, Z, r);
  946. p2 = p;
  947. patch(p1, pc);
  948. gbranch(OGOTO);
  949. patch(p2, pc);
  950. inargs--;
  951. goto com;
  952. case OOROR:
  953. if(!true)
  954. goto caseand;
  955. caseor:
  956. doinc(l, PRE);
  957. boolgen(l, !true, D_NONE, Z, l);
  958. p1 = p;
  959. inargs++;
  960. doinc(r, PRE);
  961. boolgen(r, !true, D_NONE, Z, r);
  962. p2 = p;
  963. gbranch(OGOTO);
  964. patch(p1, pc);
  965. patch(p2, pc);
  966. inargs--;
  967. goto com;
  968. case OEQ:
  969. case ONE:
  970. if(vconst(l) == 0) {
  971. if(n->op == ONE) {
  972. boolgen(r, true, result, nn, post);
  973. break;
  974. }
  975. boolgen(r, !true, result, nn, post);
  976. break;
  977. }
  978. case OLE:
  979. case OLT:
  980. case OGE:
  981. case OGT:
  982. case OHI:
  983. case OHS:
  984. case OLO:
  985. case OLS:
  986. fp = typefd[r->type->etype];
  987. if(l->op == OCONST) {
  988. v = vconst(l);
  989. if(v == 0) { /* tst instruction */
  990. o = invrel[relindex(n->op)];
  991. rg = eval(r, result);
  992. gopcode(OTST, r->type, D_NONE, Z, rg, r);
  993. regfree(rg);
  994. goto genbool;
  995. }
  996. if(!fp) { /* cmpi and movq, saves about .5% both time and space */
  997. if(v < 128 && v >= -128 &&
  998. ewidth[r->type->etype] == SZ_LONG) {
  999. rg = eval(r, result);
  1000. lg = regalloc(l->type, D_NONE);
  1001. cgen(l, lg, l);
  1002. o = n->op;
  1003. gopcode(o, l->type, lg, l, rg, r);
  1004. regfree(lg);
  1005. regfree(rg);
  1006. goto genbool;
  1007. }
  1008. o = invrel[relindex(n->op)];
  1009. rg = eval(r, result);
  1010. gopcode(o, r->type, rg, r, D_TREE, l);
  1011. regfree(rg);
  1012. goto genbool;
  1013. }
  1014. }
  1015. lg = D_TOS;
  1016. if(r->complex < FNX)
  1017. lg = regalloc(l->type, lg);
  1018. cgen(l, lg, l);
  1019. v = argoff;
  1020. rg = eval(r, result);
  1021. if(lg == D_TOS) {
  1022. adjsp(v - argoff);
  1023. lg = regalloc(l->type, lg);
  1024. gopcode(OAS, l->type, D_TOS, l, lg, l);
  1025. }
  1026. o = n->op;
  1027. gopcode(o, l->type, lg, l, rg, r);
  1028. regfree(lg);
  1029. regfree(rg);
  1030. genbool:
  1031. if(true)
  1032. o = comrel[relindex(o)];
  1033. if(doinc(post, POST|TEST)) {
  1034. lg = regalloc(types[TSHORT], D_NONE);
  1035. gopcode(OAS, types[TSHORT], D_CCR, Z, lg, Z);
  1036. doinc(post, POST);
  1037. gopcode(OAS, types[TSHORT], lg, Z, D_CCR, Z);
  1038. regfree(lg);
  1039. }
  1040. gbranch(o);
  1041. if(fp)
  1042. fpbranch();
  1043. com:
  1044. if(result == D_NONE)
  1045. break;
  1046. p1 = p;
  1047. gopcode(OAS, nn->type, D_CONST, nodconst(1), result, nn);
  1048. gbranch(OGOTO);
  1049. p2 = p;
  1050. patch(p1, pc);
  1051. gopcode(OAS, nn->type, D_CONST, nodconst(0), result, nn);
  1052. patch(p2, pc);
  1053. break;
  1054. }
  1055. }
  1056. void
  1057. sugen(Node *n, int result, Node *nn, long w)
  1058. {
  1059. long s, v, o;
  1060. int lg, rg, ng;
  1061. Prog *p1;
  1062. Node *l, *r, nod;
  1063. Type *t;
  1064. if(n == Z || n->type == T)
  1065. return;
  1066. if(debug['g']) {
  1067. if(result == D_TREE)
  1068. prtree(nn, "result");
  1069. else
  1070. print("result = %R width = %ld\n", result, w);
  1071. prtree(n, "sugen");
  1072. }
  1073. s = argoff;
  1074. if(result == D_TREE) {
  1075. if(nn == nodrat)
  1076. if(w > nrathole)
  1077. nrathole = w;
  1078. }
  1079. if(n->addable >= INDEXED && n->op != OCONST)
  1080. goto copy;
  1081. switch(n->op) {
  1082. default:
  1083. diag(n, "unknown op in sugen: %O", n->op);
  1084. break;
  1085. case OCONST:
  1086. if(n->type && typev[n->type->etype]) {
  1087. if(result == D_NONE) {
  1088. nullwarn(n->left, Z);
  1089. break;
  1090. }
  1091. lg = regaddr(D_NONE);
  1092. if(result == D_TOS) {
  1093. adjsp(s - argoff + w);
  1094. gopcode(OADDR, types[TIND], result, nn, lg, n);
  1095. } else
  1096. if(result == D_TREE) {
  1097. lcgen(nn, lg, Z);
  1098. } else
  1099. diag(n, "unknown su result: %R", result);
  1100. gopcode(OAS, types[TLONG], D_CONST, nodconst((long)(n->vconst>>32)),
  1101. lg|I_INDINC, n);
  1102. gopcode(OAS, types[TLONG], D_CONST, nodconst((long)(n->vconst)),
  1103. lg|I_INDINC, n);
  1104. regfree(lg);
  1105. break;
  1106. }
  1107. goto copy;
  1108. case ODOT:
  1109. l = n->left;
  1110. sugen(l, D_TREE, nodrat, l->type->width);
  1111. if(result != D_NONE) {
  1112. warn(n, "non-interruptable temporary");
  1113. nod = *nodrat;
  1114. r = n->right;
  1115. if(!r || r->op != OCONST) {
  1116. diag(n, "DOT and no offset");
  1117. break;
  1118. }
  1119. nod.xoffset += r->vconst;
  1120. nod.type = n->type;
  1121. sugen(&nod, result, nn, w);
  1122. }
  1123. break;
  1124. case OIND:
  1125. if(result == D_NONE) {
  1126. nullwarn(n->left, Z);
  1127. break;
  1128. }
  1129. goto copy;
  1130. case OSTRUCT:
  1131. lg = nodalloc(types[TIND], result, &nod);
  1132. nod.lineno = n->lineno;
  1133. if(result == D_TREE)
  1134. lcgen(nn, lg, Z);
  1135. else
  1136. if(result == D_TOS) {
  1137. adjsp(s - argoff + w);
  1138. gopcode(OADDR, types[TIND], result, nn, lg, n);
  1139. } else
  1140. diag(n, "unknown su result: %R", result);
  1141. o = 0;
  1142. r = n->left;
  1143. for(t = n->type->link; t != T; t = t->down) {
  1144. l = r;
  1145. if(r->op == OLIST) {
  1146. l = r->left;
  1147. r = r->right;
  1148. }
  1149. nod.type = t;
  1150. if(l->complex < FNX) {
  1151. nod.xoffset = 0;
  1152. if(o != t->offset) {
  1153. gopcode(OADD, types[TIND], D_CONST,
  1154. nodconst(t->offset-o), lg, Z);
  1155. o = t->offset;
  1156. }
  1157. cgen(l, D_TREE, &nod);
  1158. continue;
  1159. }
  1160. nod.xoffset = t->offset - o;
  1161. gopcode(OAS, types[TIND], lg, Z, D_TOS, Z);
  1162. s = argoff;
  1163. if(typesuv[t->etype]) {
  1164. sugen(l, D_TREE, nodrat, t->width);
  1165. adjsp(s - argoff);
  1166. gopcode(OAS, types[TIND], D_TOS, Z, lg, Z);
  1167. warn(n, "non-interruptable temporary");
  1168. sugen(nodrat, D_TREE, &nod, t->width);
  1169. continue;
  1170. }
  1171. rg = regalloc(t, D_NONE);
  1172. cgen(l, rg, l);
  1173. adjsp(s - argoff);
  1174. gopcode(OAS, types[TIND], D_TOS, Z, lg, Z);
  1175. gopcode(OAS, t, rg, Z, D_TREE, &nod);
  1176. regfree(rg);
  1177. }
  1178. regfree(lg);
  1179. break;
  1180. case OAS:
  1181. if(result == D_NONE) {
  1182. sugen(n->right, D_TREE, n->left, w);
  1183. break;
  1184. }
  1185. sugen(n->right, D_TREE, nodrat, w); /* could do better */
  1186. warn(n, "non-interruptable temporary");
  1187. sugen(nodrat, D_TREE, n->left, w);
  1188. sugen(nodrat, result, nn, w);
  1189. break;
  1190. case OFUNC:
  1191. if(result == D_NONE) {
  1192. sugen(n, D_TREE, nodrat, w);
  1193. break;
  1194. }
  1195. inargs++;
  1196. /* prepare zero-th arg: address of result */
  1197. if(result == D_TOS) {
  1198. adjsp(s - argoff + w);
  1199. v = argoff;
  1200. gargs(n->right);
  1201. gopcode(OADDR, types[TSHORT], D_NONE, nn, result, nn);
  1202. p->to.type = D_STACK;
  1203. p->to.offset = argoff - v;
  1204. } else
  1205. if(result == D_TREE) {
  1206. v = argoff;
  1207. gargs(n->right);
  1208. if(nn->complex >= FNX) {
  1209. rg = regalloc(types[TIND], regret(types[TIND]));
  1210. lcgen(nn, rg, Z);
  1211. gopcode(OAS, types[TIND], rg, Z, D_TOS, Z);
  1212. regfree(rg);
  1213. } else
  1214. lcgen(nn, D_TOS, Z);
  1215. } else {
  1216. diag(n, "unknown result in FUNC sugen");
  1217. break;
  1218. }
  1219. argoff += types[TIND]->width;
  1220. l = n->left;
  1221. lg = D_TREE;
  1222. if(l->addable < INDEXED) {
  1223. lg = regaddr(result);
  1224. lcgen(l, lg, Z);
  1225. lg |= I_INDIR;
  1226. }
  1227. inargs--;
  1228. doinc(n->right, POST);
  1229. doinc(n->left, POST);
  1230. gopcode(OFUNC, types[TCHAR], D_NONE, Z, lg, l);
  1231. regfree(lg);
  1232. if(inargs)
  1233. adjsp(v - argoff);
  1234. break;
  1235. case OCOND:
  1236. doinc(n->left, PRE);
  1237. boolgen(n->left, 1, D_NONE, Z, n->left);
  1238. p1 = p;
  1239. inargs++;
  1240. doinc(n->right->left, PRE);
  1241. sugen(n->right->left, result, nn, w);
  1242. doinc(n->right->left, POST);
  1243. gbranch(OGOTO);
  1244. patch(p1, pc);
  1245. p1 = p;
  1246. doinc(n->right->right, PRE);
  1247. sugen(n->right->right, result, nn, w);
  1248. doinc(n->right->right, POST);
  1249. patch(p1, pc);
  1250. inargs--;
  1251. break;
  1252. case OCOMMA:
  1253. cgen(n->left, D_NONE, n->left);
  1254. doinc(n->left, POST);
  1255. doinc(n->right, PRE);
  1256. sugen(n->right, result, nn, w);
  1257. break;
  1258. }
  1259. return;
  1260. copy:
  1261. if(result == D_NONE)
  1262. return;
  1263. rg = regaddr(D_NONE);
  1264. lcgen(n, rg, Z);
  1265. lg = regaddr(D_NONE);
  1266. if(result == D_TOS) {
  1267. adjsp(s - argoff + w);
  1268. gopcode(OADDR, types[TIND], result, nn, lg, n);
  1269. } else
  1270. if(result == D_TREE) {
  1271. if(nn->complex >= FNX) {
  1272. gopcode(OAS, types[TIND], rg, n, D_TOS, n);
  1273. s = argoff;
  1274. lcgen(nn, lg, Z);
  1275. adjsp(s - argoff);
  1276. gopcode(OAS, types[TIND], D_TOS, n, rg, n);
  1277. } else
  1278. lcgen(nn, lg, Z);
  1279. } else
  1280. diag(n, "unknown su result: %R", result);
  1281. if(w % SZ_LONG)
  1282. diag(Z, "sucopy width not 0%%%d", SZ_LONG);
  1283. v = w / SZ_LONG;
  1284. if(v & 1) {
  1285. gopcode(OAS, types[TLONG], rg|I_INDINC, n, lg|I_INDINC, n);
  1286. v--;
  1287. }
  1288. if(v > 6) {
  1289. ng = regalloc(types[TLONG], D_NONE);
  1290. gopcode(OAS, types[TLONG], D_CONST, nodconst(v/2-1), ng, n);
  1291. v = pc;
  1292. gopcode(OAS, types[TLONG], rg|I_INDINC, n, lg|I_INDINC, n);
  1293. gopcode(OAS, types[TLONG], rg|I_INDINC, n, lg|I_INDINC, n);
  1294. gbranch(OGT);
  1295. patch(p, v);
  1296. p->from.type = ng;
  1297. p->as = ADBF;
  1298. regfree(ng);
  1299. } else
  1300. while(v > 0) {
  1301. gopcode(OAS, types[TLONG], rg|I_INDINC, n, lg|I_INDINC, n);
  1302. v--;
  1303. }
  1304. regfree(lg);
  1305. regfree(rg);
  1306. }