aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndrea Corallo2019-06-24 20:23:49 +0200
committerAndrea Corallo2020-01-01 11:33:46 +0100
commit0b7ea165471091d4f998f7bc8cdcda9e27bde531 (patch)
tree4ce8fa2272bb9cbe43caf845bc74eb314d87877c /src
parent7ca1835309e5aff1fd2454010ee92b3e38069065 (diff)
downloademacs-0b7ea165471091d4f998f7bc8cdcda9e27bde531.tar.gz
emacs-0b7ea165471091d4f998f7bc8cdcda9e27bde531.zip
add define_check_type
Diffstat (limited to 'src')
-rw-r--r--src/comp.c70
1 files changed, 69 insertions, 1 deletions
diff --git a/src/comp.c b/src/comp.c
index b6b470c20df..203d476df15 100644
--- a/src/comp.c
+++ b/src/comp.c
@@ -233,6 +233,7 @@ typedef struct {
233 gcc_jit_function *bool_to_lisp_obj; 233 gcc_jit_function *bool_to_lisp_obj;
234 gcc_jit_function *car; 234 gcc_jit_function *car;
235 gcc_jit_function *cdr; 235 gcc_jit_function *cdr;
236 gcc_jit_function *check_type;
236 basic_block_t *block; /* Current basic block */ 237 basic_block_t *block; /* Current basic block */
237 Lisp_Object func_hash; /* f_name -> gcc_func */ 238 Lisp_Object func_hash; /* f_name -> gcc_func */
238} comp_t; 239} comp_t;
@@ -824,6 +825,12 @@ emit_XCDR (gcc_jit_rvalue *c)
824} 825}
825 826
826static gcc_jit_rvalue * 827static gcc_jit_rvalue *
828emit_CHECK_CONS (gcc_jit_rvalue *x)
829{
830 return NULL;
831}
832
833static gcc_jit_rvalue *
827emit_call_n_ref (const char *f_name, unsigned nargs, 834emit_call_n_ref (const char *f_name, unsigned nargs,
828 gcc_jit_lvalue *base_arg) 835 gcc_jit_lvalue *base_arg)
829{ 836{
@@ -1134,6 +1141,66 @@ define_cast_union (void)
1134 cast_union_fields); 1141 cast_union_fields);
1135} 1142}
1136 1143
1144static void
1145define_check_type (void)
1146{
1147 gcc_jit_param *param[] =
1148 { gcc_jit_context_new_param (comp.ctxt,
1149 NULL,
1150 comp.int_type,
1151 "ok"),
1152 gcc_jit_context_new_param (comp.ctxt,
1153 NULL,
1154 comp.lisp_obj_type,
1155 "predicate"),
1156 gcc_jit_context_new_param (comp.ctxt,
1157 NULL,
1158 comp.lisp_obj_type,
1159 "x") };
1160 comp.check_type =
1161 gcc_jit_context_new_function (comp.ctxt, NULL,
1162 GCC_JIT_FUNCTION_ALWAYS_INLINE,
1163 comp.void_type,
1164 "CHECK_TYPE",
1165 3,
1166 param,
1167 0);
1168 gcc_jit_rvalue *ok = gcc_jit_param_as_rvalue (param[0]);
1169 gcc_jit_rvalue *predicate = gcc_jit_param_as_rvalue (param[1]);
1170 gcc_jit_rvalue *x = gcc_jit_param_as_rvalue (param[2]);
1171
1172 gcc_jit_block *initial_block =
1173 gcc_jit_function_new_block (comp.check_type, "initial_block");
1174 gcc_jit_block *ok_block =
1175 gcc_jit_function_new_block (comp.check_type, "ok_block");
1176 gcc_jit_block *not_ok_block =
1177 gcc_jit_function_new_block (comp.check_type, "not_ok_block");
1178
1179 /* Set current context as needed */
1180 basic_block_t block = { .gcc_bb = initial_block,
1181 .terminated = false };
1182 comp.block = █
1183 comp.func = comp.check_type;
1184
1185 emit_cond_jump (emit_cast (comp.bool_type, ok),
1186 ok_block,
1187 not_ok_block);
1188
1189 gcc_jit_block_end_with_void_return (ok_block, NULL);
1190
1191 comp.block->gcc_bb = not_ok_block;
1192
1193 gcc_jit_rvalue *wrong_type_args[] = { predicate, x };
1194
1195 gcc_jit_block_add_eval (comp.block->gcc_bb,
1196 NULL,
1197 emit_call ("wrong_type_argument",
1198 comp.lisp_obj_type, 2, wrong_type_args));
1199
1200 gcc_jit_block_end_with_void_return (not_ok_block, NULL);
1201}
1202
1203
1137/* Declare a substitute for CAR as always inlined function. */ 1204/* Declare a substitute for CAR as always inlined function. */
1138 1205
1139static void 1206static void
@@ -1261,7 +1328,7 @@ define_PSEUDOVECTORP (void)
1261 0); 1328 0);
1262 1329
1263 gcc_jit_block *initial_block = 1330 gcc_jit_block *initial_block =
1264 gcc_jit_function_new_block (comp.pseudovectorp, "PSEUDOVECTORP_initial_block"); 1331 gcc_jit_function_new_block (comp.pseudovectorp, "initial_block");
1265 1332
1266 gcc_jit_block *ret_false_b = 1333 gcc_jit_block *ret_false_b =
1267 gcc_jit_function_new_block (comp.pseudovectorp, "ret_false"); 1334 gcc_jit_function_new_block (comp.pseudovectorp, "ret_false");
@@ -1594,6 +1661,7 @@ init_comp (int opt_level)
1594 define_handler_struct (); 1661 define_handler_struct ();
1595 define_thread_state_struct (); 1662 define_thread_state_struct ();
1596 define_cast_union (); 1663 define_cast_union ();
1664 define_check_type ();
1597 1665
1598 comp.current_thread = 1666 comp.current_thread =
1599 gcc_jit_context_new_rvalue_from_ptr (comp.ctxt, 1667 gcc_jit_context_new_rvalue_from_ptr (comp.ctxt,