1 /* lfr ret should little endian */
3 #define const13(x) ((x) > -4096 && (x) < 4096)
7 define(`RETH_LD',`reg_o1')
8 define(`RETL_LD',`reg_o0')
9 define(`RETH_ST',`reg_i1')
10 define(`RETL_ST',`reg_i0')
11 define(`LIN_NO',`%g6')
12 define(`FIL_NAM',`%g7')
14 define(`BP_OFFSET',`'WINDOWSIZE)
15 define(`'`EM_BSIZE',EM_BSIZE)
23 define(Comment0,; `'`)' ; `'`/* */'" ! $1" ; code_combiner`'`(' )
24 define(Comment, ; `'`)' ; `'`/* */'" ! $1 $2" ; code_combiner`'`(' )
25 define(Comment2,; `'`)' ; `'`/* */'" ! $1 $2 $3" ; code_combiner`'`(' )
28 define(MAX_INT, 0x7fffffff)
34 #undef FAST_LIN_LNI_FIL
44 if (type_of_tos() == T_cst)
55 "set EILLINS, $reg_o0";
68 /******************************************************************************/
70 /* Group 1 : Load instructions */
72 /******************************************************************************/
74 /* %fp : frame pointer
76 * RETH_XX: High part of return value
77 * RETL_XX: Low part of return value
92 if (S1 = find_local($1, NULL)) {
96 soft_alloc_reg(reg_lb);
106 Comment2( loe.. , $1, $2 );
108 #ifdef FAST_LIN_LNI_FIL
109 if ((int*)($1) == (int*)"hol0")
115 arg_error("loe.. hol0+", $2);
122 #ifdef FAST_LIN_LNI_FIL
134 if (S1 = find_local($1, NULL)) {
139 soft_alloc_reg(reg_lb);
157 soft_alloc_reg(reg_lb);
162 Comment2( lae.. , $1, $2 );
169 soft_alloc_reg(reg_lb);
173 soft_alloc_reg(reg_lb);
189 sprint(n_str, "%d", $1);
192 "1: ld [$b + EM_BSIZE], $c";
214 arg_error( "loi", $1).
226 const_str_t size_str;
229 if (type_of_tos() == T_cst && top_const() <= MAX_UNROLL) {
230 size = pop_const(size_str);
233 case 1: LD = "ldub"; break;
234 case 2: LD = "lduh"; break;
235 case 4: LD = "ld"; break;
236 default: arg_error("C_los", size);
239 if (type_of_tos() & T_reg2)
253 } else if (size <= MAX_UNROLL) { /* SUB-OPTIMAL */
255 for (i = 0; i < size; i += 4) {
257 if (type_of_tos() & T_reg2)
270 if (n[0] == '-' || isdigit(n[0]))
287 arg_error ("loi", size);
290 a = alloc_reg(); /* count */
292 b = pop_reg(); /* addr */
295 "sub $reg_sp, $a, $reg_sp" /* HACK */
299 "st $c, [$reg_sp+$a]" /* delay */
306 arg_error("C_los", $1).
317 if (S1 = find_local($1, &S2)) {
322 soft_alloc_reg(reg_lb);
332 Comment2( lde.. , $1, $2 );
349 /******************************************************************************/
351 /* Group 2 : Store instructions */
353 /******************************************************************************/
360 if ((S1 = find_local($1, NULL))) {
363 soft_alloc_reg(reg_lb);
372 Comment2( ste.. , $1, $2 );
385 if (S1 = find_local($1, NULL)) {
390 soft_alloc_reg(reg_lb);
415 arg_error( "sti", $1).
428 const_str_t size_str;
433 if (type_of_tos() == T_cst && top_const() <= MAX_UNROLL) {
435 size = pop_const(size_str);
439 case 1: ST = "stb"; break;
440 case 2: ST = "sth"; break;
441 case 4: ST = "st"; break;
442 default: arg_error("C_sti", size);
445 if (type_of_tos() & T_reg2)
449 if (type_of_tos() == T_float) {
469 } else if (size <= MAX_UNROLL) {
470 for (i = 0; i < size; i+=4) {
472 if (type_of_tos() & T_reg2)
476 if (type_of_tos() == T_float)
490 else if (n[0] == '-' || isdigit(n[0]))
506 arg_error ("sti", size);
509 force_alloc_output();
510 d = pop_reg(); /* size */
511 a = pop_reg(); /* address */
517 "andcc $d, 3, %g0"; /* delay slot */
519 "ld [$reg_sp], $b"; /* delay slot */
522 "ld [$reg_sp], $b"; /* delay slot */
526 "ld [$reg_sp], $b"; /* delay slot */
527 "3: set EILLINS, %o0";
533 "inc STACK_CLICK, $reg_sp";
535 "stb $b, [$a]"; /* delay slot */
537 "inc STACK_CLICK, $reg_sp";
539 "sth $b, [$a]"; /* delay slot */
541 "inc STACK_CLICK, $reg_sp";
543 "st $b, [$a]"; /* delay slot */
549 "ld [$reg_sp+$b], $c";
551 "st $c, [$a+$b]"; /* delay slot */
552 "add $reg_sp, $d, $reg_sp" /* HACK */
562 arg_error( "sts", $1).
572 S1 = find_local($1, NULL);
574 pop_double_reg_as(S1);
576 soft_alloc_reg(reg_lb);
585 Comment2( sde.. , $1, $2 );
598 /******************************************************************************/
600 /* Group 3 : Integer arithmetic */
602 /******************************************************************************/
608 if ((type_of_tos()) == T_cst) {
622 arg_error( "adi", $1).
629 if ((type_of_tos()) == T_cst) {
648 arg_error( "sbi", $1).
666 if (type_of_tos() == T_cst) {
671 for (n0 = 0; !(n & 1); n>>=1)
673 for (n1 = 0; n & 1; n>>=1)
678 sprint(n_str, "%d", n0);
679 "sll $orig, $n_str, $a";
685 soft_alloc_reg(orig);
696 sprint(n_str, "%d", n1);
697 "sll $orig, $n_str, $a";
716 force_alloc_output();
722 forced_alloc_reg(reg_o0);
727 arg_error( "mli", $1).
738 const_str_t n_exp_str;
742 if (type_of_tos() == T_cst &&
743 power_of_2(top_const(), &n_exp))
745 sprint (n_exp_str, "%d", n_exp);
749 "sra $a, $n_exp_str, $b";
756 force_alloc_output();
757 pop_reg_as(reg_o1); /* denominator */
758 pop_reg_as(reg_o0); /* numerator */
766 forced_alloc_reg(reg_o0);
771 arg_error( "dvi", $1).
779 force_alloc_output();
780 pop_reg_as(reg_o1); /* denominator */
781 pop_reg_as(reg_o0); /* numerator */
789 forced_alloc_reg(reg_o1);
793 arg_error( "rmi", $1).
811 arg_error( "ngi", $1).
824 if ((type_of_tos() == T_cst) &&
825 (const13(top_const()))) {
841 arg_error( "sli", $1).
854 if ((type_of_tos() == T_cst) &&
855 (const13(top_const()))) {
871 arg_error( "sri", $1).
875 /******************************************************************************/
877 /* Group 4 : Unsigned arithmetic */
879 /******************************************************************************/
899 force_alloc_output();
905 forced_alloc_reg(reg_o0);
910 arg_error( "mlu", $1).
921 const_str_t n_exp_str;
924 if (type_of_tos() == T_cst &&
925 uns_power_of_2(top_const(), &n_exp))
927 sprint (n_exp_str, "%d", n_exp);
931 "srl $a, $n_exp_str, $b";
937 force_alloc_output();
938 pop_reg_as(reg_o1); /* denominator */
939 pop_reg_as(reg_o0); /* numerator */
943 forced_alloc_reg(reg_o0);
948 arg_error( "dvu", $1).
956 force_alloc_output();
962 forced_alloc_reg(reg_o1);
966 arg_error( "rmu", $1).
985 if ((type_of_tos() == T_cst) &&
986 (const13(top_const()))) {
1002 arg_error( "sru", $1).
1006 /******************************************************************************/
1008 /* Group 5 : Floating point arithmetic */
1010 /******************************************************************************/
1026 Comment0( adf_narg);
1027 if (type_of_tos() == T_cst)
1035 "fadds $f2, $f1, $f3";
1040 else if (n == EM_DSIZE)
1042 f1= pop_double(NULL);
1043 f2= pop_double(NULL);
1044 f3= alloc_double(NULL);
1045 "faddd $f1, $f2, $f3";
1046 free_double_reg(f1);
1047 free_double_reg(f2);
1048 push_double_reg(f3);
1051 arg_error ("unimp adf", n);
1054 not_implemented ("adf_narg");
1071 Comment0( sbf_narg);
1072 if (type_of_tos() == T_cst)
1080 "fsubs $f2, $f1, $f3";
1085 else if (n == EM_DSIZE)
1087 f1= pop_double(NULL);
1088 f2= pop_double(NULL);
1089 f3= alloc_double(NULL);
1090 "fsubd $f2, $f1, $f3";
1091 free_double_reg(f1);
1092 free_double_reg(f2);
1093 push_double_reg(f3);
1096 arg_error ("unimp sbf", n);
1099 not_implemented ("sbf_narg");
1116 Comment0( mlf_narg);
1117 if (type_of_tos() == T_cst)
1125 "fmuls $f2, $f1, $f3";
1130 else if (n == EM_DSIZE)
1132 f1= pop_double(NULL);
1133 f2= pop_double(NULL);
1134 f3= alloc_double(NULL);
1135 "fmuld $f2, $f1, $f3";
1136 free_double_reg(f1);
1137 free_double_reg(f2);
1138 push_double_reg(f3);
1141 arg_error ("unimp mlf", n);
1144 not_implemented ("mlf_narg");
1161 Comment0( dvf_narg);
1162 if (type_of_tos() == T_cst)
1170 "fdivs $f2, $f1, $f3";
1175 else if (n == EM_DSIZE)
1177 f1= pop_double(NULL);
1178 f2= pop_double(NULL);
1179 f3= alloc_double(NULL);
1180 "fdivd $f2, $f1, $f3";
1181 free_double_reg(f1);
1182 free_double_reg(f2);
1183 push_double_reg(f3);
1186 arg_error ("unimp dvf", n);
1189 not_implemented ("dvf_narg");
1205 Comment0( ngf_narg);
1206 if (type_of_tos() == T_cst)
1209 if (n == EM_WSIZE || n == EM_DSIZE)
1218 arg_error ("unimp ngf", n);
1221 not_implemented ("ngf_narg");
1237 Comment0( fif_narg );
1238 if (type_of_tos() == T_cst)
1244 "! unimplemented fif 4";
1245 "st %g0, [%g0]"; /* unimp */
1254 arg_error ("fif", n);
1260 force_alloc_output();
1271 "! unimplemented fif 4";
1275 "set EILLINS, $reg_o0";
1306 Comment0( fef_narg );
1307 if (type_of_tos() == T_cst)
1313 "! unimplemented fef 4";
1314 "st %g0, [%g0]"; /* unimp */
1323 arg_error ("fef", n);
1329 force_alloc_output();
1340 "! unimplemented fef 4";
1344 "set EILLINS, $reg_o0";
1360 /******************************************************************************/
1362 /* Group 6 : Pointer arithmetic */
1364 /******************************************************************************/
1367 Comment( adp , $1 );
1372 Comment( ads , $1 );
1373 if ((type_of_tos()) == T_cst) {
1376 n = pop_const(NULL);
1387 arg_error( "ads", $1).
1393 Comment( sbs , $1 );
1395 if ((type_of_tos()) == T_cst) {
1398 n = pop_const(NULL);
1414 arg_error( "sbs", $1).
1418 /******************************************************************************/
1420 /* Group 7 : Increment/decrement/zero */
1422 /******************************************************************************/
1429 Comment( inl , $1 );
1433 if (S1 = find_local($1, NULL)) {
1437 soft_alloc_reg(reg_lb);
1442 soft_alloc_reg(reg_lb);
1456 Comment2( ine.. , $1, $2 );
1461 sprint(evalue, "%d", $2);
1462 "sethi %hi($ename+$evalue), $a";
1463 "ld [$a+%lo($ename+$evalue)], $b";
1465 "st $b, [$a+%lo($ename+$evalue)]"
1476 Comment( del , $1 );
1480 if (S1 = find_local($1, NULL)) {
1484 soft_alloc_reg(reg_lb);
1489 soft_alloc_reg(reg_lb);
1503 Comment2( dee.. , $1, $2 );
1508 sprint(evalue, "%d", $2);
1509 "sethi %hi($ename+$evalue), $a";
1510 "ld [$a+%lo($ename+$evalue)], $b";
1512 "st $b, [$a+%lo($ename+$evalue)]"
1518 Comment( zrl , $1 );
1522 if (S1 = find_local($1, NULL)) {
1527 soft_alloc_reg(reg_lb);
1540 Comment2( zre.. , $1, $2 );
1544 sprint(evalue, "%d", $2);
1545 "sethi %hi($ename+$evalue), $a";
1546 "st %g0, [$a+%lo($ename+$evalue)]"
1551 Comment( zrf , $1 );
1556 Comment0( zrf_narg );
1571 Comment0( zer_narg);
1573 if (type_of_tos() == T_cst && top_const() <= 8)
1575 n= pop_const(n_str);
1584 arg_error ("zer", n);
1591 "sub $reg_sp, $a, $reg_sp";
1593 "deccc 4, $a"; /* hack */
1594 "st %g0, [$reg_sp+$a]";
1601 /******************************************************************************/
1603 /* Group 8 : Convert */
1605 /******************************************************************************/
1607 /* cii, ciu, cuu, cui are assumed to be called with legal arguments only */
1611 reg_t a; /* target obj size */
1612 reg_t b; /* src obj size */
1613 int n1; /* target obj size */
1614 int n2; /* src obj size */
1621 if (type_of_tos() != T_cst)
1629 n1= pop_const(n1_str);
1630 if (type_of_tos() != T_cst)
1637 n2= pop_const(NULL);
1644 arg_error ("unimp cii", n1);
1646 arg_error ("unimp cii", n2);
1647 if (n2 < EM_WSIZE) {
1668 "nop"; /* delay slot */
1671 "nop"; /* delay slot */
1674 "ldsb [$reg_sp+3], $a"; /* delay slot */
1676 "ldsh [$reg_sp+2], $a";
1700 reg_t a; /* target (int) size */
1701 reg_t b; /* src (float) size */
1706 int n1; /* target (int) size */
1707 int n2; /* src (float) size */
1713 if (type_of_tos() != T_cst)
1720 n1= pop_const (n1_str);
1721 if (type_of_tos() != T_cst)
1728 n2= pop_const(NULL);
1734 arg_error ("unimp cfi", n1);
1743 else if (n2 == EM_DSIZE)
1745 s1= pop_double(NULL);
1748 free_double_reg(s1);
1752 arg_error ("unimp cfi", n2);
1759 force_alloc_output();
1770 "ld [$reg_sp], %f0";
1771 "ld [$reg_sp+STACK_CLICK], %f1";
1774 "inc 2*STACK_CLICK, $reg_sp"; /* delay slot */
1776 "ld [$reg_sp+2*STACK_CLICK], %f0";
1779 "inc STACK_CLICK, $reg_sp"; /* delay slot */
1781 "set E_EM_CFI, %o0";
1794 reg_t a; /* target (int) size */
1795 reg_t b; /* src (float) size */
1796 int n1; /* target (int) size */
1797 int n2; /* src (float) size */
1803 if (type_of_tos() != T_cst)
1810 n1= pop_const (n1_str);
1811 if (type_of_tos() != T_cst)
1818 n2= pop_const(NULL);
1824 arg_error ("unimp cfu", n1);
1825 force_alloc_output();
1832 else if (n2 == EM_DSIZE)
1838 arg_error ("unimp cfu", n2);
1839 soft_alloc_reg(reg_o0);
1846 force_alloc_output();
1865 "set E_EM_CFU, %o0";
1871 soft_alloc_reg(reg_o0);
1879 reg_t a; /* target (int) size */
1880 reg_t b; /* src (float) size */
1881 int n1; /* target (int) size */
1882 int n2; /* src (float) size */
1888 if (type_of_tos() != T_cst)
1895 n1= pop_const (n1_str);
1896 if (type_of_tos() != T_cst)
1903 n2= pop_const(NULL);
1912 a= pop_double(NULL);
1917 } else if (n2 != EM_WSIZE)
1918 arg_error ("unimp cff", n2);
1920 else if (n1 == EM_DSIZE)
1925 b= alloc_double(NULL);
1929 } else if (n2 != EM_DSIZE)
1930 arg_error ("unimp cff", n2);
1933 arg_error ("unimp cff", n1);
1939 force_alloc_output();
1942 "nop"; /* delay slot */
1950 "set E_EM_CFF, %o0";
1957 "ld [$reg_sp], %f0";
1959 "dec STACK_CLICK, $reg_sp";
1960 "st %f2, [$reg_sp]";
1961 "st %f3, [$reg_sp+STACK_CLICK]";
1968 "ld [$reg_sp], %f0";
1969 "ld [$reg_sp+STACK_CLICK], %f1";
1971 "inc STACK_CLICK, $reg_sp";
1972 "st %f2, [$reg_sp]";
1982 reg_t a; /* target (float) size */
1983 reg_t b; /* src (int) size */
1984 int n1; /* target (float) size */
1985 int n2; /* src (int) size */
1993 if (type_of_tos() != T_cst)
2000 n1= pop_const (n1_str);
2001 if (type_of_tos() != T_cst)
2008 n2= pop_const(NULL);
2014 arg_error ("unimp cif", n2);
2026 else if (n1 == EM_DSIZE)
2029 f1= alloc_double(NULL);
2032 push_double_reg(f1);
2035 arg_error ("unimp cif", n1);
2041 force_alloc_output();
2044 "nop"; /* delay slot */
2047 "nop"; /* delay slot */
2049 "set E_EM_CUF, %o0";
2055 "nop"; /* delay slot */
2056 "ld [$reg_sp], %f0";
2059 "st %f1, [$reg_sp]"; /* delay slot */
2061 "dec STACK_CLICK, $reg_sp";
2064 "nop"; /* delay slot */
2065 "ld [$reg_sp+STACK_CLICK], %f0";
2067 "st %f2, [$reg_sp]";
2069 "st %f3, [$reg_sp+STACK_CLICK]"; /* delay slot */
2080 reg_t a; /* target (float) size */
2081 reg_t b; /* src (int) size */
2087 int n1; /* target (float) size */
2088 int n2; /* src (int) size */
2094 if (type_of_tos() != T_cst)
2101 n1= pop_const (n1_str);
2102 if (type_of_tos() != T_cst)
2109 n2= pop_const(NULL);
2115 arg_error ("unimp cuf", n2);
2124 "sethi %hi(Fs0), $a";
2125 "ld [$a+%lo(Fs0)], $fs1";
2126 "fcmpes $fs2, $fs1";
2130 "sethi %hi(Fs80000000), $a";
2131 "ld [$a+%lo(Fs80000000)], $fs1";
2132 "fadds $fs1, $fs2, $fs2";
2138 else if (n1 == EM_DSIZE)
2141 fd1= alloc_double(NULL);
2142 fd2= alloc_double(NULL);
2145 "sethi %hi(Fd0), $a";
2146 "ldd [$a+%lo(Fd0)], $fd1";
2147 "fcmped $fd2, $fd1";
2151 "sethi %hi(Fd80000000), $a";
2152 "ldd [$a+%lo(Fd80000000)], $fd1";
2153 "faddd $fd1, $fd2, $fd2";
2156 free_double_reg(fd1);
2157 push_double_reg(fd2);
2161 arg_error ("unimp cuf", n1);
2171 "nop"; /* delay slot */
2174 "nop"; /* delay slot */
2176 "set E_EM_CUF, %o0";
2183 "nop"; /* delay slot */
2187 "nop"; /* delay slot */
2188 "ld [$reg_sp], %f0";
2191 "st %f1, [$reg_sp]"; /* delay slot */
2196 "ld [$reg_sp], %f0";
2198 "ld [$reg_sp], %f1";
2201 "fadds %f2, %f3, %f0";
2203 "st %f0, [$reg_sp]"; /* delay slot */
2205 "dec STACK_CLICK, $reg_sp";
2208 "nop"; /* delay slot */
2209 "ld [$reg_sp+STACK_CLICK], $c";
2212 "nop"; /* delay slot */
2213 "ld [$reg_sp+STACK_CLICK], %f0";
2215 "st %f2, [$reg_sp]";
2217 "st %f3, [$reg_sp+STACK_CLICK]"; /* delay slot */
2221 "st $a, [$reg_sp+STACK_CLICK]";
2222 "ld [$reg_sp+STACK_CLICK], %f0";
2223 "st $b, [$reg_sp+STACK_CLICK]";
2224 "ld [$reg_sp+STACK_CLICK], %f1";
2227 "fadds %f2, %f4, %f0";
2228 "st %f0, [$reg_sp]";
2230 "st %f1, [$reg_sp+STACK_CLICK]"; /* delay slot */
2236 not_implemented ("cuf");
2240 /******************************************************************************/
2242 /* Group 9 : Logical */
2244 /******************************************************************************/
2259 const_str_t a_cst_str;
2260 const_str_t b_cst_str;
2261 const_str_t c_cst_str;
2262 const_str_t d_cst_str;
2266 Comment0( and_narg );
2267 if (type_of_tos() == T_cst)
2269 n= pop_const(n_str);
2272 if (type_of_tos() == T_cst && const13(top_const()))
2275 pop_const (a_cst_str);
2279 if (type_of_tos() == T_cst && const13(top_const()))
2282 pop_const (b_cst_str);
2289 "mov $a_cst_str, $a";
2296 "and $a, $b_cst_str, $c";
2298 "and $b, $a_cst_str, $c";
2303 else if (n == EM_DSIZE)
2305 if (type_of_tos() == T_cst && const13(top_const()))
2308 pop_const (a_cst_str);
2312 if (type_of_tos() == T_cst && const13(top_const()))
2315 pop_const (b_cst_str);
2319 if (type_of_tos() == T_cst && const13(top_const()))
2322 pop_const (c_cst_str);
2326 if (type_of_tos() == T_cst && const13(top_const()))
2329 pop_const (d_cst_str);
2336 "mov $b_cst_str, $b";
2343 "and $b, $d_cst_str, $e";
2345 "and $d, $b_cst_str, $e";
2352 "mov $a_cst_str, $a";
2359 "and $a, $c_cst_str, $e";
2361 "and $c, $a_cst_str, $e";
2366 else if (!(n % EM_WSIZE))
2377 "add $reg_sp, $a, $b";
2381 "ld [$reg_sp+$c], $d";
2385 "st $f, [$b+$c]"; /* delay slot */
2386 "add $reg_sp, $a, $reg_sp";
2395 arg_error ("unimp and", n);
2407 "add $reg_sp, $a, $b";
2411 "ld [$reg_sp+$c], $d";
2415 "st $f, [$b+$c]"; /* delay slot */
2416 "add $reg_sp, $a, $reg_sp";
2440 const_str_t a_cst_str;
2441 const_str_t b_cst_str;
2442 const_str_t c_cst_str;
2443 const_str_t d_cst_str;
2447 Comment0( ior_narg );
2448 if (type_of_tos() == T_cst)
2450 n= pop_const(n_str);
2453 if (type_of_tos() == T_cst && const13(top_const()))
2456 pop_const (a_cst_str);
2460 if (type_of_tos() == T_cst && const13(top_const()))
2463 pop_const (b_cst_str);
2470 "mov $a_cst_str, $a";
2477 "or $a, $b_cst_str, $c";
2479 "or $b, $a_cst_str, $c";
2484 else if (n == EM_DSIZE)
2486 if (type_of_tos() == T_cst && const13(top_const()))
2489 pop_const (a_cst_str);
2493 if (type_of_tos() == T_cst && const13(top_const()))
2496 pop_const (b_cst_str);
2500 if (type_of_tos() == T_cst && const13(top_const()))
2503 pop_const (c_cst_str);
2507 if (type_of_tos() == T_cst && const13(top_const()))
2510 pop_const (d_cst_str);
2517 "mov $b_cst_str, $b";
2524 "or $b, $d_cst_str, $e";
2526 "or $d, $b_cst_str, $e";
2533 "mov $a_cst_str, $a";
2540 "or $a, $c_cst_str, $e";
2542 "or $c, $a_cst_str, $e";
2547 else if (!(n % EM_WSIZE))
2558 "add $reg_sp, $a, $b";
2562 "ld [$reg_sp+$c], $d";
2566 "st $f, [$b+$c]"; /* delay slot */
2567 "add $reg_sp, $a, $reg_sp";
2576 arg_error ("unimp ior", n);
2588 "add $reg_sp, $a, $b";
2592 "ld [$reg_sp+$c], $d";
2596 "st $f, [$b+$c]"; /* delay slot */
2597 "add $reg_sp, $a, $reg_sp";
2622 const_str_t a_cst_str;
2623 const_str_t b_cst_str;
2624 const_str_t c_cst_str;
2625 const_str_t d_cst_str;
2629 Comment0( xor_narg );
2630 if (type_of_tos() == T_cst)
2632 n= pop_const(n_str);
2635 if (type_of_tos() == T_cst && const13(top_const()))
2638 pop_const (a_cst_str);
2642 if (type_of_tos() == T_cst && const13(top_const()))
2645 pop_const (b_cst_str);
2652 "mov $a_cst_str, $a";
2659 "xor $a, $b_cst_str, $c";
2661 "xor $b, $a_cst_str, $c";
2666 else if (n == EM_DSIZE)
2668 if (type_of_tos() == T_cst && const13(top_const()))
2671 pop_const (a_cst_str);
2675 if (type_of_tos() == T_cst && const13(top_const()))
2678 pop_const (b_cst_str);
2682 if (type_of_tos() == T_cst && const13(top_const()))
2685 pop_const (c_cst_str);
2689 if (type_of_tos() == T_cst && const13(top_const()))
2692 pop_const (d_cst_str);
2699 "mov $b_cst_str, $b";
2706 "xor $b, $d_cst_str, $e";
2708 "xor $d, $b_cst_str, $e";
2715 "mov $a_cst_str, $a";
2722 "xor $a, $c_cst_str, $e";
2724 "xor $c, $a_cst_str, $e";
2729 else if (!(n % EM_WSIZE))
2740 "add $reg_sp, $a, $b";
2744 "ld [$reg_sp+$c], $d";
2748 "st $f, [$b+$c]"; /* delay slot */
2749 "add $reg_sp, $a, $reg_sp";
2758 arg_error ("unimp xor", n);
2770 "add $reg_sp, $a, $b";
2774 "ld [$reg_sp+$c], $d";
2778 "st $f, [$b+$c]"; /* delay slot */
2779 "add $reg_sp, $a, $reg_sp";
2806 Comment0( com_narg );
2807 if (type_of_tos() == T_cst && top_const() <= MAX_UNROLL)
2831 else if (n>0 && !(n % 4))
2836 for (i= 0; i< n; i += 4)
2838 sprint(i_str, "%d", i);
2839 "ld [$reg_sp+$i_str], $a";
2841 "st $b, [$reg_sp+$i_str]";
2847 arg_error ("com", n);
2858 "ld [$reg_sp+$a], $b";
2861 "st $c, [$reg_sp+$a]";
2880 if (type_of_tos() == T_cst)
2884 arg_error("rol 4:", n);
2893 sprint(n_str, "%d", n);
2894 "sll $a, $n_str, $b";
2895 sprint(n_str, "%d", 32-n);
2896 "srl $a, $n_str, $c";
2923 arg_error( "rol", $1).
2939 if (type_of_tos() == T_cst)
2943 arg_error("ror 4:", n);
2952 sprint(n_str, "%d", n);
2953 "srl $a, $n_str, $b";
2954 sprint(n_str, "%d", 32-n);
2955 "sll $a, $n_str, $c";
2982 arg_error( "ror", $1).
2986 /******************************************************************************/
2988 /* Group 10 : Sets */
2990 /******************************************************************************/
3009 if (type_of_tos() == T_cst && const13(top_const()))
3011 n= pop_const(n_str);
3014 if (type_of_tos() == T_cst)
3016 i= pop_const (i_str);
3023 "srl $a, $i_str, $b";
3041 else if (n == 2*EM_WSIZE)
3043 if (type_of_tos() == T_cst)
3045 i= pop_const (i_str);
3063 "srl $a, $i_str, $b";
3081 "ld [$reg_sp+$d], $b";
3082 "inc $n_str, $reg_sp";
3091 else if (n % EM_WSIZE)
3092 arg_error ("inn", n);
3104 "ld [$reg_sp+$d], $b";
3105 "inc $n_str, $reg_sp";
3115 not_implemented ("inn_narg");
3118 C_set ==> Comment( set, $1);
3131 Comment0( set_narg );
3133 if (type_of_tos() == T_cst) {
3134 n = pop_const(n_str);
3135 if (n == EM_WSIZE) {
3150 sprint(n_str, "%d", n);
3152 "sub $reg_sp, $a, $reg_sp";
3156 "st %g0, [$reg_sp+$a]"; /* HACK delay */
3162 "st $d, [$reg_sp+$c]";
3175 "sub $reg_sp, $a, $reg_sp";
3179 "st %g0, [$reg_sp+$a]"; /* HACK delay */
3185 "st $d, [$reg_sp+$c]";
3194 /******************************************************************************/
3196 /* Group 11 : Array */
3198 /******************************************************************************/
3203 force_alloc_output();
3212 arg_error ("arg error lar", $1).
3218 Comment( sar , $1 );
3219 force_alloc_output();
3228 arg_error ("arg error sar", $1).
3235 force_alloc_output();
3242 soft_alloc_reg(reg_o0);
3246 arg_error ("arg error aar", $1).
3250 /******************************************************************************/
3252 /* Group 12 : Compare */
3254 /******************************************************************************/
3266 if (type_of_tos() == T_cst && const13(top_const()))
3273 "mov 0, $b"; /* delay slot */
3275 "mov 1, $b"; /* delay slot */
3286 if (type_of_tos() == T_cst)
3297 "mov 0, $c"; /* delay slot */
3299 "mov -1, $c"; /* delay slot */
3309 arg_error ("unimp cmi", $1).
3326 Comment0( cmu_narg );
3327 if (type_of_tos() == T_cst)
3331 arg_error ("unimp cmu", n);
3334 if (type_of_tos() == T_cst &&
3335 const13(top_const()))
3342 "mov 0, $b"; /* delay slot */
3344 "mov 1, $b"; /* delay slot */
3355 if (type_of_tos() == T_cst &&
3356 const13(top_const()))
3367 "mov 0, $c"; /* delay slot */
3369 "mov -1, $c"; /* delay slot */
3380 not_implemented ("cmu_narg");
3399 Comment0( cms_narg );
3400 if (type_of_tos() == T_cst && top_const() <= EM_WSIZE)
3402 n= pop_const(n_str);
3407 if (type_of_tos() == T_cst &&
3408 const13(top_const()))
3429 else if (n % EM_WSIZE)
3430 arg_error ("unimp cms", n);
3440 "add $reg_sp, $a, $b";
3447 "mov 1, $b"; /* delay slot */
3450 "dec 4, $b"; /* delay slot */
3453 "add $reg_sp, $a, $reg_sp";
3454 "add $reg_sp, $a, $reg_sp";
3477 " mov 1, $b"; /* delay slot */
3494 "mov 1, $b"; /* delay slot */
3511 " mov 1, $b"; /* delay slot */
3528 " mov 1, $b"; /* delay slot */
3545 " mov 1, $b"; /* delay slot */
3546 " set 0, $b"; /* sup optimal */
3562 " mov 1, $b"; /* delay slot */
3580 Comment0( cmf_narg);
3581 if (type_of_tos() == T_cst)
3601 else if (n == EM_DSIZE)
3603 a= pop_double(NULL);
3604 b= pop_double(NULL);
3619 arg_error ("cmf", n);
3622 not_implemented ("cmf_narg");
3625 /******************************************************************************/
3627 /* Group 13 : Branch */
3629 /******************************************************************************/
3632 Comment( bra , $1 );
3639 "nop"; /* delay slot */
3643 Comment( bge , $1 );
3651 if (type_of_tos() == T_cst &&
3652 const13(top_const()))
3663 "nop" /* delay slot */
3669 Comment( bne , $1 );
3677 if (type_of_tos() == T_cst &&
3678 const13(top_const()))
3689 "nop" /* delay slot */
3695 Comment( beq , $1 );
3703 if (type_of_tos() == T_cst &&
3704 const13(top_const()))
3715 "nop" /* delay slot */
3721 Comment( ble , $1 );
3729 if (type_of_tos() == T_cst &&
3730 const13(top_const()))
3741 "nop" /* delay slot */
3747 Comment( blt , $1 );
3755 if (type_of_tos() == T_cst &&
3756 const13(top_const()))
3767 "nop" /* delay slot */
3773 Comment( bgt , $1 );
3781 if (type_of_tos() == T_cst &&
3782 const13(top_const()))
3793 "nop" /* delay slot */
3799 Comment( zlt , $1 );
3808 "nop"; /* delay slot */
3814 Comment( zle , $1 );
3823 "nop"; /* delay slot */
3829 Comment( zeq , $1 );
3838 "nop"; /* delay slot */
3844 Comment( zne , $1 );
3853 "nop"; /* delay slot */
3859 Comment( zge , $1 );
3868 "nop"; /* delay slot */
3874 Comment( zgt , $1 );
3883 "nop"; /* delay slot */
3887 /******************************************************************************/
3889 /* Group 14 : Procedure call instructions */
3891 /******************************************************************************/
3901 "nop"; /* delay slot */
3906 Comment( cal , $1 );
3911 "nop"; /* delay slot */
3917 Comment( lfr , $1 );
3918 forced_alloc_reg(RETL_LD);
3923 Comment( lfr , $1 );
3924 forced_alloc_reg(RETL_LD);
3925 forced_alloc_reg(RETH_LD);
3930 arg_error( "lfr", $1).
3935 Comment( ret , $1 );
3938 free_all_reg_vars();
3941 "add %sp, $reg_gap, %sp";
3943 alloc_all_reg_vars();
3947 Comment( ret , $1 );
3948 soft_alloc_reg(RETL_ST);
3949 pop_reg_as(RETL_ST);
3953 free_all_reg_vars();
3956 "add %sp, $reg_gap, %sp";
3958 alloc_all_reg_vars();
3962 Comment( ret , $1 );
3963 soft_alloc_reg(RETL_ST);
3964 soft_alloc_reg(RETH_ST);
3965 pop_reg_as(RETL_ST);
3966 pop_reg_as(RETH_ST);
3971 free_all_reg_vars();
3974 "add %sp, $reg_gap, %sp";
3976 alloc_all_reg_vars();
3979 arg_error( "ret", $1).
3981 /******************************************************************************/
3983 /* Group 15 : Miscellaneous instructions */
3985 /******************************************************************************/
3988 Comment( asp , $1 );
4000 if (type_of_tos() == T_cst)
4002 n= pop_const(n_str);
4004 arg_error ("asp", n);
4012 "inc $n_str, $reg_sp";
4017 "add $reg_sp, $a, $reg_sp";
4026 "add $reg_sp, $a, $reg_sp";
4031 arg_error( "ass", $1).
4057 Comment( bls , $1 );
4058 if (type_of_tos() == T_cst)
4060 n= pop_const(n_str);
4062 arg_error ("blm", n);
4063 else if (n <= MAX_UNROLL)
4066 for (i=0; i<n; i += EM_WSIZE)
4068 if (type_of_tos() & T_reg2) /* dest */
4069 a= pop_reg_reg (&ao_reg);
4073 a= pop_reg_c13(ac_str);
4075 if (type_of_tos() & T_reg2) /* src */
4076 b= pop_reg_reg (&bo_reg);
4080 b= pop_reg_c13(bc_str);
4083 "ld [$b+$bo_reg], $c";
4085 "ld [$b+$bc_str], $c";
4087 "st $c, [$a+$ao_reg]";
4089 "st $c, [$a+$ac_str]";
4093 inc_tos_reg(bo_reg);
4095 else if (bc_str[0] == '-' ||
4099 inc_tos(atoi(bc_str));
4103 "add $b, $bc_str, $c";
4112 inc_tos_reg(ao_reg);
4114 else if (ac_str[0] == '-' ||
4118 inc_tos(atoi(ac_str));
4122 "add $a, $ac_str, $c";
4134 a= pop_reg(); /* dest */
4135 b= pop_reg(); /* src */
4157 c= alloc_reg(); /* size */
4159 a= pop_reg(); /* dest */
4160 b= pop_reg(); /* src */
4181 arg_error( "bls", $1).
4187 Comment( csa , $1 );
4189 force_alloc_output();
4194 "set csa, $reg_tmp";
4199 arg_error( "csa", $1).
4205 Comment( csb , $1 );
4207 force_alloc_output();
4212 "set csb, $reg_tmp";
4217 arg_error( "csb", $1).
4228 a= pop_reg(); /* some LB */
4231 "ta 3"; /* flush register windows */
4233 "andn $b, 7, $c"; /* and it's %fp */
4234 "ld [$c+4], $b"; /* the previous LB */
4258 if (type_of_tos() == T_cst && top_const() <= MAX_UNROLL)
4260 n= pop_const(n_str);
4261 if (n == 4 || n == 8 || n<=32)
4263 else if (n<0 || n % 4)
4264 arg_error ("dup", n);
4269 "sub $reg_sp, $n_str, $reg_sp";
4270 for (i=0; i<n; i += 4)
4272 sprint(i_str, "%d", i);
4273 "ld [$reg_sp+$i_str+$n_str], $a";
4274 "st $a, [$reg_sp+$i_str]";
4287 "dec STACK_CLICK, $reg_sp";
4288 "ld [$reg_sp+ $a], $c";
4291 "st $c, [$reg_sp+ $a]"; /* delay slot */
4298 arg_error( "dus", $1).
4318 Comment0( exg_narg );
4319 if (type_of_tos() == T_cst && top_const() <= MAX_UNROLL)
4340 else if (n>0 && !(n % 4))
4345 for (i=0; i<n; i += 4)
4347 sprint(i_str, "%d", i);
4348 sprint(in_str, "%d", i+n);
4349 "ld [$reg_sp+$i_str], $a";
4350 "ld [$reg_sp+$in_str], $b";
4351 "st $b, [$reg_sp+$i_str]";
4352 "st $a, [$reg_sp+$in_str]";
4358 arg_error ("exg", n);
4367 "add $reg_sp, $a, $b";
4375 "st $c, [$b+$a]"; /* delay slot */
4384 Comment2( fil , $1 , $2);
4385 #ifdef FAST_LIN_LNI_FIL
4390 "set $lbl+$n, $reg_fil"
4409 Comment2( gto , $1 , $2 );
4416 forced_alloc_reg(a);
4417 forced_alloc_reg(b);
4418 forced_alloc_reg(c);
4419 forced_alloc_reg(d);
4431 "ld [$a+4], $reg_sp";
4435 "mov $d, $reg_o1"; /* delay slot */
4448 Comment( lin , $1 );
4449 #ifdef FAST_LIN_LNI_FIL
4452 sprint(n_str, "%d", $1);
4453 "set $n_str, $reg_fil";
4463 #ifdef FAST_LIN_LNI_FIL
4474 "sethi %hi(lino), $a";
4475 "ld [$a+%lo(lino)], $b";
4477 "st $b, [$a+%lo(lino)]"
4486 Comment( lor , $1 );
4487 soft_alloc_reg(reg_lb);
4493 Comment( lor , $1 );
4500 Comment( lor , $1 );
4514 arg_error( "lor", $1).
4519 C_adp( (arith)EM_BSIZE).
4524 force_alloc_output();
4543 Comment( rck , $1 );
4544 force_alloc_output();
4558 "set ERANGE, $reg_o0";
4568 arg_error( "rck", $1).
4613 Comment( str , $1 );
4615 "ld [$reg_sp], $reg_lb";
4616 "add $reg_lb, 4, %fp";
4618 "inc STACK_CLICK, $reg_sp"
4622 Comment( str , $1 );
4624 "ld [$reg_sp], $reg_sp";
4628 Comment( str , $1 );
4629 force_alloc_output();
4636 arg_error( "str", $1).
4641 force_alloc_output();
4648 /*****************************************************************************/
4652 Comment( ..icon , $1 );
4653 gen1( (ONE_BYTE) atoi( $1)).
4655 Comment( ..icon , $1 );
4656 gen2( (TWO_BYTES) atoi( $1)).
4658 Comment( ..icon , $1 );
4659 gen4( (FOUR_BYTES) atol( $1)).
4661 arg_error( "icon", $2).
4665 Comment( ..ucon , $1 );
4666 gen1( (ONE_BYTE) atoi( $1)).
4668 Comment( ..ucon , $1 );
4669 gen2( (TWO_BYTES) atoi( $1)).
4671 Comment( ..ucon , $1 );
4672 gen4( (FOUR_BYTES) atol( $1)).
4674 arg_error( "icon", $2).
4677 Comment( ..fcon , $1 );
4680 /*****************************************************************************/
4685 "sub $reg_sp, (EM_BSIZE-4), %g1";
4688 "save %sp, $reg_gap, %sp";
4689 "st %g0, [%sp+BP_OFFSET]";
4690 "sub %g1, EM_BSIZE, $reg_lb";
4692 forced_alloc_reg(reg_sp);
4693 forced_alloc_reg(reg_lb);
4694 forced_alloc_reg(reg_gap);
4695 #ifdef FAST_LIN_LNI_FIL
4696 reg_lin = alloc_reg();
4697 reg_fil = alloc_reg();
4704 Comment( jump , $1 );
4707 "nop"; /* delay slot */
4712 Comment( locals , $1 );
4714 soft_alloc_reg(reg_lb);