aboutsummaryrefslogtreecommitdiffstats
path: root/src/comp.c
diff options
context:
space:
mode:
authorAndrea Corallo2019-07-13 16:34:59 +0200
committerAndrea Corallo2020-01-01 11:33:53 +0100
commitba8ca065a7cde2f8221767ddb632b56eeefb29b5 (patch)
treee5973603d34437d82cbf3b48a9a4006fdb2f4c2f /src/comp.c
parent73cb29c3fb6d56f32f77ec201f9b61ac77e57290 (diff)
downloademacs-ba8ca065a7cde2f8221767ddb632b56eeefb29b5.tar.gz
emacs-ba8ca065a7cde2f8221767ddb632b56eeefb29b5.zip
let limple support calls with no assignment
Diffstat (limited to 'src/comp.c')
-rw-r--r--src/comp.c93
1 files changed, 42 insertions, 51 deletions
diff --git a/src/comp.c b/src/comp.c
index 25598aa20c1..f164bf892a5 100644
--- a/src/comp.c
+++ b/src/comp.c
@@ -976,12 +976,10 @@ emit_limple_call (Lisp_Object arg1)
976 if (calle[0] == 'F') 976 if (calle[0] == 'F')
977 { 977 {
978 /* 978 /*
979 Ex: (= #s(comp-mvar 6 1 nil nil nil) 979 Ex: (call Fcar #s(comp-mvar 4 0 nil nil nil))
980 (call Fcar #s(comp-mvar 4 0 nil nil nil)))
981 980
982 Ex: (= #s(comp-mvar 5 0 nil nil cons) 981 Ex: (call Fcons #s(comp-mvar 3 0 t 1 nil)
983 (call Fcons #s(comp-mvar 3 0 t 1 nil) 982 #s(comp-mvar 4 nil t nil nil))
984 #s(comp-mvar 4 nil t nil nil)))
985 */ 983 */
986 984
987 ptrdiff_t nargs = list_length (call_args); 985 ptrdiff_t nargs = list_length (call_args);
@@ -994,10 +992,9 @@ emit_limple_call (Lisp_Object arg1)
994 else if (!strcmp (calle, "set_internal")) 992 else if (!strcmp (calle, "set_internal"))
995 { 993 {
996 /* 994 /*
997 Ex: (set #s(comp-mvar 8 1 nil nil nil) 995 Ex: (call set_internal
998 (call set_internal 996 #s(comp-mvar 7 nil t xxx nil)
999 #s(comp-mvar 7 nil t xxx nil) 997 #s(comp-mvar 6 1 t 3 nil))
1000 #s(comp-mvar 6 1 t 3 nil)))
1001 */ 998 */
1002 /* TODO: Inline the most common case. */ 999 /* TODO: Inline the most common case. */
1003 eassert (list_length (call_args) == 2); 1000 eassert (list_length (call_args) == 2);
@@ -1008,14 +1005,26 @@ emit_limple_call (Lisp_Object arg1)
1008 gcc_args[3] = gcc_jit_context_new_rvalue_from_int (comp.ctxt, 1005 gcc_args[3] = gcc_jit_context_new_rvalue_from_int (comp.ctxt,
1009 comp.int_type, 1006 comp.int_type,
1010 SET_INTERNAL_SET); 1007 SET_INTERNAL_SET);
1011 gcc_jit_block_add_eval ( 1008 return emit_call ("set_internal", comp.void_type , 4, gcc_args);
1012 comp.block,
1013 NULL,
1014 emit_call ("set_internal", comp.void_type , 4, gcc_args));
1015
1016 return NULL;
1017 } 1009 }
1018 error ("LIMPLE inconsiste call"); 1010 error ("LIMPLE call is inconsistet");
1011}
1012
1013static gcc_jit_rvalue *
1014emit_limple_call_ref (Lisp_Object arg1)
1015{
1016 /* Ex: (callref Fplus 2 0). */
1017
1018 char *calle = (char *) SDATA (SYMBOL_NAME (SECOND (arg1)));
1019 EMACS_UINT nargs = XFIXNUM (THIRD (arg1));
1020 EMACS_UINT base_ptr = XFIXNUM (FORTH (arg1));
1021 gcc_jit_rvalue *gcc_args[2] =
1022 { gcc_jit_context_new_rvalue_from_int (comp.ctxt,
1023 comp.ptrdiff_type,
1024 nargs),
1025 gcc_jit_lvalue_get_address (comp.frame[base_ptr], NULL) };
1026
1027 return emit_call (calle, comp.lisp_obj_type, 2, gcc_args);
1019} 1028}
1020 1029
1021static void 1030static void
@@ -1032,53 +1041,35 @@ emit_limple_inst (Lisp_Object inst)
1032 } 1041 }
1033 else if (EQ (op, Qjump)) 1042 else if (EQ (op, Qjump))
1034 { 1043 {
1035 /* Unconditional branch. */ 1044 /* Unconditional branch. */
1036 gcc_jit_block *target = retrive_block (arg0); 1045 gcc_jit_block *target = retrive_block (arg0);
1037 gcc_jit_block_end_with_jump (comp.block, NULL, target); 1046 gcc_jit_block_end_with_jump (comp.block, NULL, target);
1038 comp.block = target; 1047 comp.block = target;
1039 } 1048 }
1049 else if (EQ (op, Qcall))
1050 {
1051 gcc_jit_block_add_eval (comp.block,
1052 NULL,
1053 emit_limple_call (inst));
1054 }
1040 else if (EQ (op, Qset)) 1055 else if (EQ (op, Qset))
1041 { 1056 {
1042 EMACS_UINT slot_n = XFIXNUM (FUNCALL1 (comp-mvar-slot, arg0)); 1057 EMACS_UINT slot_n = XFIXNUM (FUNCALL1 (comp-mvar-slot, arg0));
1043 Lisp_Object arg1 = THIRD (inst); 1058 Lisp_Object arg1 = THIRD (inst);
1044 1059
1045 if (EQ (Ftype_of (arg1), Qcomp_mvar)) 1060 if (EQ (Ftype_of (arg1), Qcomp_mvar))
1046 { 1061 res = emit_mvar_val (arg1);
1047 /*
1048 Ex: (= #s(comp-mvar 6 2 nil nil nil)
1049 #s(comp-mvar 6 0 nil nil nil)).
1050 */
1051 res = emit_mvar_val (arg1);
1052 }
1053 else if (EQ (FIRST (arg1), Qcall)) 1062 else if (EQ (FIRST (arg1), Qcall))
1054 { 1063 res = emit_limple_call (arg1);
1055 res = emit_limple_call (arg1);
1056 }
1057 else if (EQ (FIRST (arg1), Qcallref)) 1064 else if (EQ (FIRST (arg1), Qcallref))
1058 { 1065 res = emit_limple_call_ref (arg1);
1059 /* Ex: (= #s(comp-mvar 10 1 nil nil nil) (callref Fplus 2 0)). */
1060
1061 char *calle = (char *) SDATA (SYMBOL_NAME (SECOND (arg1)));
1062 EMACS_UINT nargs = XFIXNUM (THIRD (arg1));
1063 EMACS_UINT base_ptr = XFIXNUM (FORTH (arg1));
1064 gcc_jit_rvalue *gcc_args[2] =
1065 { gcc_jit_context_new_rvalue_from_int (comp.ctxt,
1066 comp.ptrdiff_type,
1067 nargs),
1068 gcc_jit_lvalue_get_address (
1069 comp.frame[base_ptr],
1070 NULL) };
1071 res = emit_call (calle, comp.lisp_obj_type, 2, gcc_args);
1072 }
1073 else 1066 else
1074 { 1067 error ("LIMPLE inconsistent arg1 for op =");
1075 error ("LIMPLE inconsistent arg1 for op ="); 1068 eassert (res);
1076 } 1069 gcc_jit_block_add_assignment (comp.block,
1077 if (res) 1070 NULL,
1078 gcc_jit_block_add_assignment (comp.block, 1071 comp.frame[slot_n],
1079 NULL, 1072 res);
1080 comp.frame[slot_n],
1081 res);
1082 } 1073 }
1083 else if (EQ (op, Qsetpar)) 1074 else if (EQ (op, Qsetpar))
1084 { 1075 {
@@ -1105,7 +1096,7 @@ emit_limple_inst (Lisp_Object inst)
1105 } 1096 }
1106 else if (EQ (op, Qcomment)) 1097 else if (EQ (op, Qcomment))
1107 { 1098 {
1108 /* Ex: (comment "Function: foo"). */ 1099 /* Ex: (comment "Function: foo"). */
1109 emit_comment((char *) SDATA (arg0)); 1100 emit_comment((char *) SDATA (arg0));
1110 } 1101 }
1111 else if (EQ (op, Qreturn)) 1102 else if (EQ (op, Qreturn))