aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndrea Corallo2019-09-21 10:23:18 +0200
committerAndrea Corallo2020-01-01 11:37:51 +0100
commitbbf8b1df90f327a74423b2ccbfe557da9b04dd9d (patch)
tree656a5e13324cb88b558490ead1100c3263a353cf /src
parentd87d9e41f5890fbe7d279053c9c7328890c94b2f (diff)
downloademacs-bbf8b1df90f327a74423b2ccbfe557da9b04dd9d.tar.gz
emacs-bbf8b1df90f327a74423b2ccbfe557da9b04dd9d.zip
add direct-call direct-callref support into the backend
Diffstat (limited to 'src')
-rw-r--r--src/comp.c27
1 files changed, 14 insertions, 13 deletions
diff --git a/src/comp.c b/src/comp.c
index 0365f0e09e9..89eead5c6c4 100644
--- a/src/comp.c
+++ b/src/comp.c
@@ -390,14 +390,14 @@ emit_call (Lisp_Object subr_sym, gcc_jit_type *ret_type, unsigned nargs,
390 390
391static gcc_jit_rvalue * 391static gcc_jit_rvalue *
392emit_call_ref (Lisp_Object subr_sym, unsigned nargs, 392emit_call_ref (Lisp_Object subr_sym, unsigned nargs,
393 gcc_jit_lvalue *base_arg) 393 gcc_jit_lvalue *base_arg, bool direct)
394{ 394{
395 gcc_jit_rvalue *args[] = 395 gcc_jit_rvalue *args[] =
396 { gcc_jit_context_new_rvalue_from_int(comp.ctxt, 396 { gcc_jit_context_new_rvalue_from_int(comp.ctxt,
397 comp.ptrdiff_type, 397 comp.ptrdiff_type,
398 nargs), 398 nargs),
399 gcc_jit_lvalue_get_address (base_arg, NULL) }; 399 gcc_jit_lvalue_get_address (base_arg, NULL) };
400 return emit_call (subr_sym, comp.lisp_obj_type, 2, args, false); 400 return emit_call (subr_sym, comp.lisp_obj_type, 2, args, direct);
401} 401}
402 402
403/* Close current basic block emitting a conditional. */ 403/* Close current basic block emitting a conditional. */
@@ -1054,7 +1054,7 @@ emit_set_internal (Lisp_Object args)
1054/* This is for a regular function with arguments as m-var. */ 1054/* This is for a regular function with arguments as m-var. */
1055 1055
1056static gcc_jit_rvalue * 1056static gcc_jit_rvalue *
1057emit_simple_limple_call (Lisp_Object args, gcc_jit_type *ret_type) 1057emit_simple_limple_call (Lisp_Object args, gcc_jit_type *ret_type, bool direct)
1058{ 1058{
1059 USE_SAFE_ALLOCA; 1059 USE_SAFE_ALLOCA;
1060 int i = 0; 1060 int i = 0;
@@ -1066,25 +1066,23 @@ emit_simple_limple_call (Lisp_Object args, gcc_jit_type *ret_type)
1066 gcc_args[i++] = emit_mvar_val (XCAR (args)); 1066 gcc_args[i++] = emit_mvar_val (XCAR (args));
1067 1067
1068 SAFE_FREE (); 1068 SAFE_FREE ();
1069 return emit_call (callee, ret_type, nargs, gcc_args, false); 1069 return emit_call (callee, ret_type, nargs, gcc_args, direct);
1070} 1070}
1071 1071
1072static gcc_jit_rvalue * 1072static gcc_jit_rvalue *
1073emit_simple_limple_call_lisp_ret (Lisp_Object args) 1073emit_simple_limple_call_lisp_ret (Lisp_Object args)
1074{ 1074{
1075 /* 1075 /*
1076 Ex: (call Fcar #s(comp-mvar 4 0 nil nil nil))
1077
1078 Ex: (call Fcons #s(comp-mvar 3 0 t 1 nil) 1076 Ex: (call Fcons #s(comp-mvar 3 0 t 1 nil)
1079 #s(comp-mvar 4 nil t nil nil)) 1077 #s(comp-mvar 4 nil t nil nil))
1080 */ 1078 */
1081 return emit_simple_limple_call (args, comp.lisp_obj_type); 1079 return emit_simple_limple_call (args, comp.lisp_obj_type, false);
1082} 1080}
1083 1081
1084static gcc_jit_rvalue * 1082static gcc_jit_rvalue *
1085emit_simple_limple_call_void_ret (Lisp_Object args) 1083emit_simple_limple_call_void_ret (Lisp_Object args)
1086{ 1084{
1087 return emit_simple_limple_call (args, comp.void_type); 1085 return emit_simple_limple_call (args, comp.void_type, false);
1088} 1086}
1089 1087
1090/* Entry point to dispatch emitting (call fun ...). */ 1088/* Entry point to dispatch emitting (call fun ...). */
@@ -1105,7 +1103,7 @@ emit_limple_call (Lisp_Object insn)
1105} 1103}
1106 1104
1107static gcc_jit_rvalue * 1105static gcc_jit_rvalue *
1108emit_limple_call_ref (Lisp_Object insn) 1106emit_limple_call_ref (Lisp_Object insn, bool direct)
1109{ 1107{
1110 /* Ex: (callref < #s(comp-mvar 1 6 nil nil nil t) 1108 /* Ex: (callref < #s(comp-mvar 1 6 nil nil nil t)
1111 #s(comp-mvar 2 11 t 10 integer t)). */ 1109 #s(comp-mvar 2 11 t 10 integer t)). */
@@ -1113,7 +1111,7 @@ emit_limple_call_ref (Lisp_Object insn)
1113 Lisp_Object callee = FIRST (insn); 1111 Lisp_Object callee = FIRST (insn);
1114 EMACS_UINT nargs = XFIXNUM (Flength (CDR (insn))); 1112 EMACS_UINT nargs = XFIXNUM (Flength (CDR (insn)));
1115 EMACS_UINT base_ptr = XFIXNUM (FUNCALL1 (comp-mvar-slot, SECOND (insn))); 1113 EMACS_UINT base_ptr = XFIXNUM (FUNCALL1 (comp-mvar-slot, SECOND (insn)));
1116 return emit_call_ref (callee, nargs, comp.frame[base_ptr]); 1114 return emit_call_ref (callee, nargs, comp.frame[base_ptr], false);
1117} 1115}
1118 1116
1119/* Register an handler for a non local exit. */ 1117/* Register an handler for a non local exit. */
@@ -1290,11 +1288,14 @@ emit_limple_insn (Lisp_Object insn)
1290 1288
1291 if (EQ (Ftype_of (arg1), Qcomp_mvar)) 1289 if (EQ (Ftype_of (arg1), Qcomp_mvar))
1292 res = emit_mvar_val (arg1); 1290 res = emit_mvar_val (arg1);
1293 /* FIXME: should recurr here */
1294 else if (EQ (FIRST (arg1), Qcall)) 1291 else if (EQ (FIRST (arg1), Qcall))
1295 res = emit_limple_call (XCDR (arg1)); 1292 res = emit_limple_call (XCDR (arg1));
1296 else if (EQ (FIRST (arg1), Qcallref)) 1293 else if (EQ (FIRST (arg1), Qcallref))
1297 res = emit_limple_call_ref (XCDR (arg1)); 1294 res = emit_limple_call_ref (XCDR (arg1), false);
1295 else if (EQ (FIRST (arg1), Qdirect_call))
1296 res = emit_simple_limple_call (XCDR (arg1), comp.lisp_obj_type, true);
1297 else if (EQ (FIRST (arg1), Qcallref))
1298 res = emit_limple_call_ref (XCDR (arg1), true);
1298 else 1299 else
1299 ice ("LIMPLE inconsistent arg1 for op ="); 1300 ice ("LIMPLE inconsistent arg1 for op =");
1300 1301
@@ -2479,7 +2480,7 @@ define_negate (void)
2479 emit_make_fixnum (inline_res)); 2480 emit_make_fixnum (inline_res));
2480 2481
2481 comp.block = fcall_block; 2482 comp.block = fcall_block;
2482 gcc_jit_rvalue *call_res = emit_call_ref (Qminus, 1, n); 2483 gcc_jit_rvalue *call_res = emit_call_ref (Qminus, 1, n, false);
2483 gcc_jit_block_end_with_return (fcall_block, 2484 gcc_jit_block_end_with_return (fcall_block,
2484 NULL, 2485 NULL,
2485 call_res); 2486 call_res);