diff options
| author | Andrea Corallo | 2019-06-15 18:31:41 +0200 |
|---|---|---|
| committer | Andrea Corallo | 2020-01-01 11:33:42 +0100 |
| commit | f245990714abfd33c869573ebc2ba91eaa336e59 (patch) | |
| tree | a112f893a37d518cbc4324c6c5b2ff0954c64f4c /src/comp.c | |
| parent | 433108104abecb5e84f28a476b9b977c0086694f (diff) | |
| download | emacs-f245990714abfd33c869573ebc2ba91eaa336e59.tar.gz emacs-f245990714abfd33c869573ebc2ba91eaa336e59.zip | |
emit_call funcs return now rval
Diffstat (limited to 'src/comp.c')
| -rw-r--r-- | src/comp.c | 87 |
1 files changed, 38 insertions, 49 deletions
diff --git a/src/comp.c b/src/comp.c index caa5cc96003..e74e67d1175 100644 --- a/src/comp.c +++ b/src/comp.c | |||
| @@ -128,7 +128,7 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */ | |||
| 128 | case B##name: \ | 128 | case B##name: \ |
| 129 | POP##nargs; \ | 129 | POP##nargs; \ |
| 130 | res = emit_call (STR(F##name), comp.lisp_obj_type, nargs, args); \ | 130 | res = emit_call (STR(F##name), comp.lisp_obj_type, nargs, args); \ |
| 131 | PUSH_LVAL (res); \ | 131 | PUSH_RVAL (res); \ |
| 132 | break | 132 | break |
| 133 | 133 | ||
| 134 | /* Emit calls to functions with prototype (ptrdiff_t nargs, Lisp_Object *args) | 134 | /* Emit calls to functions with prototype (ptrdiff_t nargs, Lisp_Object *args) |
| @@ -138,7 +138,7 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */ | |||
| 138 | do { \ | 138 | do { \ |
| 139 | pop (nargs, &stack, args); \ | 139 | pop (nargs, &stack, args); \ |
| 140 | res = emit_callN (name, nargs, args); \ | 140 | res = emit_callN (name, nargs, args); \ |
| 141 | PUSH_LVAL (res); \ | 141 | PUSH_RVAL (res); \ |
| 142 | } while (0) | 142 | } while (0) |
| 143 | 143 | ||
| 144 | #define EMIT_ARITHCOMPARE(comparison) \ | 144 | #define EMIT_ARITHCOMPARE(comparison) \ |
| @@ -148,7 +148,7 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */ | |||
| 148 | comp.int_type, \ | 148 | comp.int_type, \ |
| 149 | comparison); \ | 149 | comparison); \ |
| 150 | res = emit_call ("arithcompare", comp.lisp_obj_type, 3, args); \ | 150 | res = emit_call ("arithcompare", comp.lisp_obj_type, 3, args); \ |
| 151 | PUSH_LVAL (res); \ | 151 | PUSH_RVAL (res); \ |
| 152 | } while (0) | 152 | } while (0) |
| 153 | 153 | ||
| 154 | 154 | ||
| @@ -329,10 +329,9 @@ emit_func_declare (const char *f_name, gcc_jit_type *ret_type, | |||
| 329 | return func; | 329 | return func; |
| 330 | } | 330 | } |
| 331 | 331 | ||
| 332 | /* TODO this should return an rval */ | 332 | static gcc_jit_rvalue * |
| 333 | static gcc_jit_lvalue * | ||
| 334 | emit_call (const char *f_name, gcc_jit_type *ret_type, unsigned nargs, | 333 | emit_call (const char *f_name, gcc_jit_type *ret_type, unsigned nargs, |
| 335 | gcc_jit_rvalue **args) | 334 | gcc_jit_rvalue **args) |
| 336 | { | 335 | { |
| 337 | Lisp_Object key = make_string (f_name, strlen (f_name)); | 336 | Lisp_Object key = make_string (f_name, strlen (f_name)); |
| 338 | EMACS_UINT hash = 0; | 337 | EMACS_UINT hash = 0; |
| @@ -350,18 +349,11 @@ emit_call (const char *f_name, gcc_jit_type *ret_type, unsigned nargs, | |||
| 350 | Lisp_Object value = HASH_VALUE (ht, hash_lookup (ht, key, &hash)); | 349 | Lisp_Object value = HASH_VALUE (ht, hash_lookup (ht, key, &hash)); |
| 351 | gcc_jit_function *func = (gcc_jit_function *) XFIXNUMPTR (value); | 350 | gcc_jit_function *func = (gcc_jit_function *) XFIXNUMPTR (value); |
| 352 | 351 | ||
| 353 | gcc_jit_lvalue *res = gcc_jit_function_new_local(comp.func, | 352 | return gcc_jit_context_new_call(comp.ctxt, |
| 354 | NULL, | 353 | NULL, |
| 355 | ret_type, | 354 | func, |
| 356 | "res"); | 355 | nargs, |
| 357 | gcc_jit_block_add_assignment(comp.bblock->gcc_bb, NULL, | 356 | args); |
| 358 | res, | ||
| 359 | gcc_jit_context_new_call(comp.ctxt, | ||
| 360 | NULL, | ||
| 361 | func, | ||
| 362 | nargs, | ||
| 363 | args)); | ||
| 364 | return res; | ||
| 365 | } | 357 | } |
| 366 | 358 | ||
| 367 | /* Close current basic block emitting a conditional. */ | 359 | /* Close current basic block emitting a conditional. */ |
| @@ -578,12 +570,10 @@ declare_PSEUDOVECTORP (void) | |||
| 578 | /* FIXME XUNTAG missing here. */ | 570 | /* FIXME XUNTAG missing here. */ |
| 579 | gcc_jit_block_end_with_return (call_pseudovector_typep_b, | 571 | gcc_jit_block_end_with_return (call_pseudovector_typep_b, |
| 580 | NULL, | 572 | NULL, |
| 581 | gcc_jit_lvalue_as_rvalue( | 573 | emit_call ("helper_PSEUDOVECTOR_TYPEP_XUNTAG", |
| 582 | emit_call ( | 574 | comp.bool_type, |
| 583 | "helper_PSEUDOVECTOR_TYPEP_XUNTAG", | 575 | 2, |
| 584 | comp.bool_type, | 576 | args)); |
| 585 | 2, | ||
| 586 | args))); | ||
| 587 | } | 577 | } |
| 588 | 578 | ||
| 589 | static gcc_jit_rvalue * | 579 | static gcc_jit_rvalue * |
| @@ -705,7 +695,7 @@ emit_lisp_obj_from_ptr (basic_block_t *bblock, void *p) | |||
| 705 | return gcc_jit_lvalue_as_rvalue (lisp_obj); | 695 | return gcc_jit_lvalue_as_rvalue (lisp_obj); |
| 706 | } | 696 | } |
| 707 | 697 | ||
| 708 | static gcc_jit_lvalue * | 698 | static gcc_jit_rvalue * |
| 709 | emit_callN (const char *f_name, unsigned nargs, gcc_jit_rvalue **args) | 699 | emit_callN (const char *f_name, unsigned nargs, gcc_jit_rvalue **args) |
| 710 | { | 700 | { |
| 711 | /* Here we set all the pointers into the scratch call area. */ | 701 | /* Here we set all the pointers into the scratch call area. */ |
| @@ -1034,7 +1024,7 @@ compile_f (const char *f_name, ptrdiff_t bytestr_length, | |||
| 1034 | EMACS_INT stack_depth, Lisp_Object *vectorp, | 1024 | EMACS_INT stack_depth, Lisp_Object *vectorp, |
| 1035 | ptrdiff_t vector_size, Lisp_Object args_template) | 1025 | ptrdiff_t vector_size, Lisp_Object args_template) |
| 1036 | { | 1026 | { |
| 1037 | gcc_jit_lvalue *res; | 1027 | gcc_jit_rvalue *res; |
| 1038 | comp_f_res_t comp_res = { NULL, 0, 0 }; | 1028 | comp_f_res_t comp_res = { NULL, 0, 0 }; |
| 1039 | ptrdiff_t pc = 0; | 1029 | ptrdiff_t pc = 0; |
| 1040 | gcc_jit_rvalue *args[4]; | 1030 | gcc_jit_rvalue *args[4]; |
| @@ -1150,7 +1140,7 @@ compile_f (const char *f_name, ptrdiff_t bytestr_length, | |||
| 1150 | { | 1140 | { |
| 1151 | args[0] = emit_lisp_obj_from_ptr (comp.bblock, vectorp[op]); | 1141 | args[0] = emit_lisp_obj_from_ptr (comp.bblock, vectorp[op]); |
| 1152 | res = emit_call ("Fsymbol_value", comp.lisp_obj_type, 1, args); | 1142 | res = emit_call ("Fsymbol_value", comp.lisp_obj_type, 1, args); |
| 1153 | PUSH_LVAL (res); | 1143 | PUSH_RVAL (res); |
| 1154 | break; | 1144 | break; |
| 1155 | } | 1145 | } |
| 1156 | 1146 | ||
| @@ -1179,7 +1169,7 @@ compile_f (const char *f_name, ptrdiff_t bytestr_length, | |||
| 1179 | comp.int_type, | 1169 | comp.int_type, |
| 1180 | SET_INTERNAL_SET); | 1170 | SET_INTERNAL_SET); |
| 1181 | res = emit_call ("set_internal", comp.lisp_obj_type, 4, args); | 1171 | res = emit_call ("set_internal", comp.lisp_obj_type, 4, args); |
| 1182 | PUSH_LVAL (res); | 1172 | PUSH_RVAL (res); |
| 1183 | } | 1173 | } |
| 1184 | break; | 1174 | break; |
| 1185 | 1175 | ||
| @@ -1203,7 +1193,7 @@ compile_f (const char *f_name, ptrdiff_t bytestr_length, | |||
| 1203 | args[0] = emit_lisp_obj_from_ptr (comp.bblock, vectorp[op]); | 1193 | args[0] = emit_lisp_obj_from_ptr (comp.bblock, vectorp[op]); |
| 1204 | pop (1, &stack, &args[1]); | 1194 | pop (1, &stack, &args[1]); |
| 1205 | res = emit_call ("specbind", comp.lisp_obj_type, 2, args); | 1195 | res = emit_call ("specbind", comp.lisp_obj_type, 2, args); |
| 1206 | PUSH_LVAL (res); | 1196 | PUSH_RVAL (res); |
| 1207 | break; | 1197 | break; |
| 1208 | } | 1198 | } |
| 1209 | 1199 | ||
| @@ -1227,7 +1217,7 @@ compile_f (const char *f_name, ptrdiff_t bytestr_length, | |||
| 1227 | ptrdiff_t nargs = op + 1; | 1217 | ptrdiff_t nargs = op + 1; |
| 1228 | pop (nargs, &stack, args); | 1218 | pop (nargs, &stack, args); |
| 1229 | res = emit_callN ("Ffuncall", nargs, args); | 1219 | res = emit_callN ("Ffuncall", nargs, args); |
| 1230 | PUSH_LVAL (res); | 1220 | PUSH_RVAL (res); |
| 1231 | break; | 1221 | break; |
| 1232 | } | 1222 | } |
| 1233 | 1223 | ||
| @@ -1299,12 +1289,12 @@ compile_f (const char *f_name, ptrdiff_t bytestr_length, | |||
| 1299 | POP1; | 1289 | POP1; |
| 1300 | args[1] = nil; | 1290 | args[1] = nil; |
| 1301 | res = emit_call ("Fcons", comp.lisp_obj_type, 2, args); | 1291 | res = emit_call ("Fcons", comp.lisp_obj_type, 2, args); |
| 1302 | PUSH_LVAL (res); | 1292 | PUSH_RVAL (res); |
| 1303 | for (int i = 0; i < op; ++i) | 1293 | for (int i = 0; i < op; ++i) |
| 1304 | { | 1294 | { |
| 1305 | POP2; | 1295 | POP2; |
| 1306 | res = emit_call ("Fcons", comp.lisp_obj_type, 2, args); | 1296 | res = emit_call ("Fcons", comp.lisp_obj_type, 2, args); |
| 1307 | PUSH_LVAL (res); | 1297 | PUSH_RVAL (res); |
| 1308 | } | 1298 | } |
| 1309 | break; | 1299 | break; |
| 1310 | } | 1300 | } |
| @@ -1382,7 +1372,7 @@ compile_f (const char *f_name, ptrdiff_t bytestr_length, | |||
| 1382 | comp.bblock->gcc_bb = sub1_fcall_block; | 1372 | comp.bblock->gcc_bb = sub1_fcall_block; |
| 1383 | POP1; | 1373 | POP1; |
| 1384 | res = emit_call ("Fsub1", comp.lisp_obj_type, 1, args); | 1374 | res = emit_call ("Fsub1", comp.lisp_obj_type, 1, args); |
| 1385 | PUSH_LVAL (res); | 1375 | PUSH_RVAL (res); |
| 1386 | 1376 | ||
| 1387 | *comp.bblock = bb_orig; | 1377 | *comp.bblock = bb_orig; |
| 1388 | 1378 | ||
| @@ -1442,7 +1432,7 @@ compile_f (const char *f_name, ptrdiff_t bytestr_length, | |||
| 1442 | comp.bblock->gcc_bb = add1_fcall_block; | 1432 | comp.bblock->gcc_bb = add1_fcall_block; |
| 1443 | POP1; | 1433 | POP1; |
| 1444 | res = emit_call ("Fadd1", comp.lisp_obj_type, 1, args); | 1434 | res = emit_call ("Fadd1", comp.lisp_obj_type, 1, args); |
| 1445 | PUSH_LVAL (res); | 1435 | PUSH_RVAL (res); |
| 1446 | 1436 | ||
| 1447 | *comp.bblock = bb_orig; | 1437 | *comp.bblock = bb_orig; |
| 1448 | 1438 | ||
| @@ -1553,7 +1543,7 @@ compile_f (const char *f_name, ptrdiff_t bytestr_length, | |||
| 1553 | comp.lisp_obj_type, | 1543 | comp.lisp_obj_type, |
| 1554 | 1, | 1544 | 1, |
| 1555 | args); | 1545 | args); |
| 1556 | PUSH_LVAL (res); | 1546 | PUSH_RVAL (res); |
| 1557 | break; | 1547 | break; |
| 1558 | 1548 | ||
| 1559 | CASE_CALL_NARGS (goto_char, 1); | 1549 | CASE_CALL_NARGS (goto_char, 1); |
| @@ -1571,7 +1561,7 @@ compile_f (const char *f_name, ptrdiff_t bytestr_length, | |||
| 1571 | comp.lisp_obj_type, | 1561 | comp.lisp_obj_type, |
| 1572 | 1, | 1562 | 1, |
| 1573 | args); | 1563 | args); |
| 1574 | PUSH_LVAL (res); | 1564 | PUSH_RVAL (res); |
| 1575 | break; | 1565 | break; |
| 1576 | 1566 | ||
| 1577 | case Bpoint_min: | 1567 | case Bpoint_min: |
| @@ -1583,7 +1573,7 @@ compile_f (const char *f_name, ptrdiff_t bytestr_length, | |||
| 1583 | comp.lisp_obj_type, | 1573 | comp.lisp_obj_type, |
| 1584 | 1, | 1574 | 1, |
| 1585 | args); | 1575 | args); |
| 1586 | PUSH_LVAL (res); | 1576 | PUSH_RVAL (res); |
| 1587 | break; | 1577 | break; |
| 1588 | 1578 | ||
| 1589 | CASE_CALL_NARGS (char_after, 1); | 1579 | CASE_CALL_NARGS (char_after, 1); |
| @@ -1591,7 +1581,7 @@ compile_f (const char *f_name, ptrdiff_t bytestr_length, | |||
| 1591 | 1581 | ||
| 1592 | case Bpreceding_char: | 1582 | case Bpreceding_char: |
| 1593 | res = emit_call ("Fprevious_char", comp.lisp_obj_type, 0, args); | 1583 | res = emit_call ("Fprevious_char", comp.lisp_obj_type, 0, args); |
| 1594 | PUSH_LVAL (res); | 1584 | PUSH_RVAL (res); |
| 1595 | break; | 1585 | break; |
| 1596 | 1586 | ||
| 1597 | CASE_CALL_NARGS (current_column, 0); | 1587 | CASE_CALL_NARGS (current_column, 0); |
| @@ -1600,7 +1590,7 @@ compile_f (const char *f_name, ptrdiff_t bytestr_length, | |||
| 1600 | POP1; | 1590 | POP1; |
| 1601 | args[1] = nil; | 1591 | args[1] = nil; |
| 1602 | res = emit_call ("Findent_to", comp.lisp_obj_type, 2, args); | 1592 | res = emit_call ("Findent_to", comp.lisp_obj_type, 2, args); |
| 1603 | PUSH_LVAL (res); | 1593 | PUSH_RVAL (res); |
| 1604 | break; | 1594 | break; |
| 1605 | 1595 | ||
| 1606 | CASE_CALL_NARGS (eolp, 0); | 1596 | CASE_CALL_NARGS (eolp, 0); |
| @@ -1620,7 +1610,7 @@ compile_f (const char *f_name, ptrdiff_t bytestr_length, | |||
| 1620 | PUSH_RVAL (emit_lisp_obj_from_ptr (comp.bblock, | 1610 | PUSH_RVAL (emit_lisp_obj_from_ptr (comp.bblock, |
| 1621 | intern ("interactive-p"))); | 1611 | intern ("interactive-p"))); |
| 1622 | res = emit_call ("call0", comp.lisp_obj_type, 1, args); | 1612 | res = emit_call ("call0", comp.lisp_obj_type, 1, args); |
| 1623 | PUSH_LVAL (res); | 1613 | PUSH_RVAL (res); |
| 1624 | break; | 1614 | break; |
| 1625 | 1615 | ||
| 1626 | CASE_CALL_NARGS (forward_char, 1); | 1616 | CASE_CALL_NARGS (forward_char, 1); |
| @@ -1704,17 +1694,16 @@ compile_f (const char *f_name, ptrdiff_t bytestr_length, | |||
| 1704 | POP1; | 1694 | POP1; |
| 1705 | res = emit_call ("helper_save_window_excursion", | 1695 | res = emit_call ("helper_save_window_excursion", |
| 1706 | comp.lisp_obj_type, 1, args); | 1696 | comp.lisp_obj_type, 1, args); |
| 1707 | PUSH_LVAL (res); | 1697 | PUSH_RVAL (res); |
| 1708 | break; | 1698 | break; |
| 1709 | 1699 | ||
| 1710 | case Bsave_restriction: | 1700 | case Bsave_restriction: |
| 1711 | args[0] = emit_lisp_obj_from_ptr (comp.bblock, | 1701 | args[0] = emit_lisp_obj_from_ptr (comp.bblock, |
| 1712 | save_restriction_restore); | 1702 | save_restriction_restore); |
| 1713 | args[1] = | 1703 | args[1] = emit_call ("save_restriction_save", |
| 1714 | gcc_jit_lvalue_as_rvalue (emit_call ("save_restriction_save", | 1704 | comp.lisp_obj_type, |
| 1715 | comp.lisp_obj_type, | 1705 | 0, |
| 1716 | 0, | 1706 | NULL); |
| 1717 | NULL)); | ||
| 1718 | emit_call ("record_unwind_protect", comp.void_ptr_type, 2, args); | 1707 | emit_call ("record_unwind_protect", comp.void_ptr_type, 2, args); |
| 1719 | break; | 1708 | break; |
| 1720 | 1709 | ||
| @@ -1740,7 +1729,7 @@ compile_f (const char *f_name, ptrdiff_t bytestr_length, | |||
| 1740 | POP1; | 1729 | POP1; |
| 1741 | res = emit_call ("helper_temp_output_buffer_setup", comp.lisp_obj_type, | 1730 | res = emit_call ("helper_temp_output_buffer_setup", comp.lisp_obj_type, |
| 1742 | 1, args); | 1731 | 1, args); |
| 1743 | PUSH_LVAL (res); | 1732 | PUSH_RVAL (res); |
| 1744 | break; | 1733 | break; |
| 1745 | 1734 | ||
| 1746 | case Btemp_output_buffer_show: /* Obsolete since 24.1. */ | 1735 | case Btemp_output_buffer_show: /* Obsolete since 24.1. */ |
| @@ -1766,13 +1755,13 @@ compile_f (const char *f_name, ptrdiff_t bytestr_length, | |||
| 1766 | case Bstringeqlsign: | 1755 | case Bstringeqlsign: |
| 1767 | POP2; | 1756 | POP2; |
| 1768 | res = emit_call ("Fstring_equal", comp.lisp_obj_type, 2, args); | 1757 | res = emit_call ("Fstring_equal", comp.lisp_obj_type, 2, args); |
| 1769 | PUSH_LVAL (res); | 1758 | PUSH_RVAL (res); |
| 1770 | break; | 1759 | break; |
| 1771 | 1760 | ||
| 1772 | case Bstringlss: | 1761 | case Bstringlss: |
| 1773 | POP2; | 1762 | POP2; |
| 1774 | res = emit_call ("Fstring_lessp", comp.lisp_obj_type, 2, args); | 1763 | res = emit_call ("Fstring_lessp", comp.lisp_obj_type, 2, args); |
| 1775 | PUSH_LVAL (res); | 1764 | PUSH_RVAL (res); |
| 1776 | break; | 1765 | break; |
| 1777 | 1766 | ||
| 1778 | CASE_CALL_NARGS (equal, 2); | 1767 | CASE_CALL_NARGS (equal, 2); |