aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndrea Corallo2020-07-12 10:54:48 +0200
committerAndrea Corallo2020-07-13 14:32:04 +0200
commitc389feede5f1138b23e43edb23564e6ef14d4170 (patch)
tree6c8dad07cf869d89ff8649ce9523d26cb61e3b5a /src
parent5f13016cedd245a7388ffafddffa20268afaf023 (diff)
downloademacs-c389feede5f1138b23e43edb23564e6ef14d4170.tar.gz
emacs-c389feede5f1138b23e43edb23564e6ef14d4170.zip
* Rework the backend to allocate arument arrays for call by references
* src/comp.c (comp_t): Add 'zero' field. (emit_limple_call_ref): Allocate an array to host the parametes and generate the code moving values into. (Fcomp__init_ctxt): Initialize comp.zero.
Diffstat (limited to 'src')
-rw-r--r--src/comp.c60
1 files changed, 40 insertions, 20 deletions
diff --git a/src/comp.c b/src/comp.c
index 2464b58dad7..15c223c5641 100644
--- a/src/comp.c
+++ b/src/comp.c
@@ -541,6 +541,7 @@ typedef struct {
541 gcc_jit_block *block; /* Current basic block being compiled. */ 541 gcc_jit_block *block; /* Current basic block being compiled. */
542 gcc_jit_lvalue *scratch; /* Used as scratch slot for some code sequence (switch). */ 542 gcc_jit_lvalue *scratch; /* Used as scratch slot for some code sequence (switch). */
543 gcc_jit_lvalue ***arrays; /* Array index -> gcc_jit_lvalue **. */ 543 gcc_jit_lvalue ***arrays; /* Array index -> gcc_jit_lvalue **. */
544 gcc_jit_rvalue *zero;
544 gcc_jit_rvalue *one; 545 gcc_jit_rvalue *one;
545 gcc_jit_rvalue *inttypebits; 546 gcc_jit_rvalue *inttypebits;
546 gcc_jit_rvalue *lisp_int0; 547 gcc_jit_rvalue *lisp_int0;
@@ -1845,31 +1846,46 @@ emit_limple_call_ref (Lisp_Object insn, bool direct)
1845 /* Ex: (funcall #s(comp-mvar 1 5 t eql symbol t) 1846 /* Ex: (funcall #s(comp-mvar 1 5 t eql symbol t)
1846 #s(comp-mvar 2 6 nil nil nil t) 1847 #s(comp-mvar 2 6 nil nil nil t)
1847 #s(comp-mvar 3 7 t 0 fixnum t)). */ 1848 #s(comp-mvar 3 7 t 0 fixnum t)). */
1848 1849 static int i = 0;
1849 Lisp_Object callee = FIRST (insn); 1850 Lisp_Object callee = FIRST (insn);
1850 EMACS_INT nargs = XFIXNUM (Flength (CDR (insn))); 1851 EMACS_INT nargs = XFIXNUM (Flength (CDR (insn)));
1851 1852
1852 if (!nargs) 1853 gcc_jit_lvalue *tmp_arr =
1853 return emit_call_ref (callee, 1854 gcc_jit_function_new_local (
1854 nargs, 1855 comp.func,
1855 comp.arrays[0][0], 1856 NULL,
1856 direct); 1857 gcc_jit_context_new_array_type (comp.ctxt,
1857 1858 NULL,
1858 Lisp_Object first_arg = SECOND (insn); 1859 comp.lisp_obj_type,
1859 Lisp_Object arr_idx = CALL1I (comp-mvar-array-idx, first_arg); 1860 nargs),
1861 format_string ("call_arr_%d", i++));
1860 1862
1861 /* Make sure all the arguments are layout-ed into the same array. */ 1863 ptrdiff_t j = 0;
1862 Lisp_Object p = XCDR (XCDR (insn)); 1864 Lisp_Object arg = CDR (insn);
1863 FOR_EACH_TAIL (p) 1865 FOR_EACH_TAIL (arg)
1864 if (!EQ (arr_idx, CALL1I (comp-mvar-array-idx, XCAR (p)))) 1866 {
1865 xsignal2 (Qnative_ice, build_string ("incoherent array idx for insn"), 1867 gcc_jit_block_add_assignment (
1866 insn); 1868 comp.block,
1869 NULL,
1870 gcc_jit_context_new_array_access (
1871 comp.ctxt,
1872 NULL,
1873 gcc_jit_lvalue_as_rvalue (tmp_arr),
1874 gcc_jit_context_new_rvalue_from_int (comp.ctxt,
1875 comp.int_type,
1876 j)),
1877 emit_mvar_rval (XCAR (arg)));
1878 ++j;
1879 }
1867 1880
1868 EMACS_INT first_slot = XFIXNUM (CALL1I (comp-mvar-slot, first_arg)); 1881 return emit_call_ref (
1869 return emit_call_ref (callee, 1882 callee,
1870 nargs, 1883 nargs,
1871 comp.arrays[XFIXNUM (arr_idx)][first_slot], 1884 gcc_jit_context_new_array_access (comp.ctxt,
1872 direct); 1885 NULL,
1886 gcc_jit_lvalue_as_rvalue (tmp_arr),
1887 comp.zero),
1888 direct);
1873} 1889}
1874 1890
1875static gcc_jit_rvalue * 1891static gcc_jit_rvalue *
@@ -3966,6 +3982,10 @@ DEFUN ("comp--init-ctxt", Fcomp__init_ctxt, Scomp__init_ctxt,
3966 comp.lisp_obj_type = comp.lisp_word_type; 3982 comp.lisp_obj_type = comp.lisp_word_type;
3967#endif 3983#endif
3968 comp.lisp_obj_ptr_type = gcc_jit_type_get_pointer (comp.lisp_obj_type); 3984 comp.lisp_obj_ptr_type = gcc_jit_type_get_pointer (comp.lisp_obj_type);
3985 comp.zero =
3986 gcc_jit_context_new_rvalue_from_int (comp.ctxt,
3987 comp.emacs_int_type,
3988 0);
3969 comp.one = 3989 comp.one =
3970 gcc_jit_context_new_rvalue_from_int (comp.ctxt, 3990 gcc_jit_context_new_rvalue_from_int (comp.ctxt,
3971 comp.emacs_int_type, 3991 comp.emacs_int_type,