diff options
| author | Andrea Corallo | 2019-09-21 10:23:18 +0200 |
|---|---|---|
| committer | Andrea Corallo | 2020-01-01 11:37:51 +0100 |
| commit | bbf8b1df90f327a74423b2ccbfe557da9b04dd9d (patch) | |
| tree | 656a5e13324cb88b558490ead1100c3263a353cf /src/comp.c | |
| parent | d87d9e41f5890fbe7d279053c9c7328890c94b2f (diff) | |
| download | emacs-bbf8b1df90f327a74423b2ccbfe557da9b04dd9d.tar.gz emacs-bbf8b1df90f327a74423b2ccbfe557da9b04dd9d.zip | |
add direct-call direct-callref support into the backend
Diffstat (limited to 'src/comp.c')
| -rw-r--r-- | src/comp.c | 27 |
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 | ||
| 391 | static gcc_jit_rvalue * | 391 | static gcc_jit_rvalue * |
| 392 | emit_call_ref (Lisp_Object subr_sym, unsigned nargs, | 392 | emit_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 | ||
| 1056 | static gcc_jit_rvalue * | 1056 | static gcc_jit_rvalue * |
| 1057 | emit_simple_limple_call (Lisp_Object args, gcc_jit_type *ret_type) | 1057 | emit_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 | ||
| 1072 | static gcc_jit_rvalue * | 1072 | static gcc_jit_rvalue * |
| 1073 | emit_simple_limple_call_lisp_ret (Lisp_Object args) | 1073 | emit_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 | ||
| 1084 | static gcc_jit_rvalue * | 1082 | static gcc_jit_rvalue * |
| 1085 | emit_simple_limple_call_void_ret (Lisp_Object args) | 1083 | emit_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 | ||
| 1107 | static gcc_jit_rvalue * | 1105 | static gcc_jit_rvalue * |
| 1108 | emit_limple_call_ref (Lisp_Object insn) | 1106 | emit_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); |