diff options
| author | Andrea Corallo | 2019-10-21 10:51:25 +0200 |
|---|---|---|
| committer | Andrea Corallo | 2020-01-01 11:37:58 +0100 |
| commit | 96e2863f2e85bc907e5fc0cb7d86e0b6ff54317a (patch) | |
| tree | ddf58b7ed01a8387a514435b8c0bf86de91fa9c1 /src/comp.c | |
| parent | 8d08a8a1070435e12b77517808df34a8093abc67 (diff) | |
| download | emacs-96e2863f2e85bc907e5fc0cb7d86e0b6ff54317a.tar.gz emacs-96e2863f2e85bc907e5fc0cb7d86e0b6ff54317a.zip | |
rework emit_limple_insn arg parsing
Diffstat (limited to 'src/comp.c')
| -rw-r--r-- | src/comp.c | 55 |
1 files changed, 25 insertions, 30 deletions
diff --git a/src/comp.c b/src/comp.c index 6b3ca832d98..f71df794185 100644 --- a/src/comp.c +++ b/src/comp.c | |||
| @@ -1186,35 +1186,30 @@ emit_limple_insn (Lisp_Object insn) | |||
| 1186 | { | 1186 | { |
| 1187 | Lisp_Object op = XCAR (insn); | 1187 | Lisp_Object op = XCAR (insn); |
| 1188 | Lisp_Object args = XCDR (insn); | 1188 | Lisp_Object args = XCDR (insn); |
| 1189 | Lisp_Object arg0 UNINIT; | ||
| 1190 | gcc_jit_rvalue *res; | 1189 | gcc_jit_rvalue *res; |
| 1191 | |||
| 1192 | Lisp_Object arg[6]; | 1190 | Lisp_Object arg[6]; |
| 1191 | |||
| 1193 | Lisp_Object p = XCDR (insn); | 1192 | Lisp_Object p = XCDR (insn); |
| 1194 | ptrdiff_t n_args = list_length (p); | ||
| 1195 | unsigned i = 0; | 1193 | unsigned i = 0; |
| 1196 | FOR_EACH_TAIL (p) | 1194 | FOR_EACH_TAIL (p) |
| 1197 | { | 1195 | { |
| 1198 | eassert (i < n_args); | 1196 | eassert (i < sizeof (arg)); |
| 1199 | arg[i++] = XCAR (p); | 1197 | arg[i++] = XCAR (p); |
| 1200 | } | 1198 | } |
| 1201 | 1199 | ||
| 1202 | if (CONSP (args)) | ||
| 1203 | arg0 = XCAR (args); | ||
| 1204 | |||
| 1205 | if (EQ (op, Qjump)) | 1200 | if (EQ (op, Qjump)) |
| 1206 | { | 1201 | { |
| 1207 | /* Unconditional branch. */ | 1202 | /* Unconditional branch. */ |
| 1208 | gcc_jit_block *target = retrive_block (arg0); | 1203 | gcc_jit_block *target = retrive_block (arg[0]); |
| 1209 | gcc_jit_block_end_with_jump (comp.block, NULL, target); | 1204 | gcc_jit_block_end_with_jump (comp.block, NULL, target); |
| 1210 | } | 1205 | } |
| 1211 | else if (EQ (op, Qcond_jump)) | 1206 | else if (EQ (op, Qcond_jump)) |
| 1212 | { | 1207 | { |
| 1213 | /* Conditional branch. */ | 1208 | /* Conditional branch. */ |
| 1214 | gcc_jit_rvalue *a = emit_mvar_val (arg0); | 1209 | gcc_jit_rvalue *a = emit_mvar_val (arg[0]); |
| 1215 | gcc_jit_rvalue *b = emit_mvar_val (SECOND (args)); | 1210 | gcc_jit_rvalue *b = emit_mvar_val (arg[1]); |
| 1216 | gcc_jit_block *target1 = retrive_block (THIRD (args)); | 1211 | gcc_jit_block *target1 = retrive_block (arg[2]); |
| 1217 | gcc_jit_block *target2 = retrive_block (FORTH (args)); | 1212 | gcc_jit_block *target2 = retrive_block (arg[3]); |
| 1218 | 1213 | ||
| 1219 | emit_cond_jump (emit_EQ (a, b), target2, target1); | 1214 | emit_cond_jump (emit_EQ (a, b), target2, target1); |
| 1220 | } | 1215 | } |
| @@ -1229,9 +1224,9 @@ emit_limple_insn (Lisp_Object insn) | |||
| 1229 | gcc_jit_rvalue *n = | 1224 | gcc_jit_rvalue *n = |
| 1230 | gcc_jit_context_new_rvalue_from_int (comp.ctxt, | 1225 | gcc_jit_context_new_rvalue_from_int (comp.ctxt, |
| 1231 | comp.ptrdiff_type, | 1226 | comp.ptrdiff_type, |
| 1232 | XFIXNUM (arg0)); | 1227 | XFIXNUM (arg[0])); |
| 1233 | gcc_jit_block *target1 = retrive_block (SECOND (args)); | 1228 | gcc_jit_block *target1 = retrive_block (arg[1]); |
| 1234 | gcc_jit_block *target2 = retrive_block (THIRD (args)); | 1229 | gcc_jit_block *target2 = retrive_block (arg[2]); |
| 1235 | gcc_jit_rvalue *test = gcc_jit_context_new_comparison ( | 1230 | gcc_jit_rvalue *test = gcc_jit_context_new_comparison ( |
| 1236 | comp.ctxt, | 1231 | comp.ctxt, |
| 1237 | NULL, | 1232 | NULL, |
| @@ -1264,7 +1259,7 @@ emit_limple_insn (Lisp_Object insn) | |||
| 1264 | gcc_jit_block *handler_bb = retrive_block (arg[3]); | 1259 | gcc_jit_block *handler_bb = retrive_block (arg[3]); |
| 1265 | gcc_jit_block *guarded_bb = retrive_block (arg[4]); | 1260 | gcc_jit_block *guarded_bb = retrive_block (arg[4]); |
| 1266 | emit_limple_push_handler (handler, handler_type, handler_buff_n, | 1261 | emit_limple_push_handler (handler, handler_type, handler_buff_n, |
| 1267 | handler_bb, guarded_bb, arg0); | 1262 | handler_bb, guarded_bb, arg[0]); |
| 1268 | } | 1263 | } |
| 1269 | else if (EQ (op, Qpop_handler)) | 1264 | else if (EQ (op, Qpop_handler)) |
| 1270 | { | 1265 | { |
| @@ -1290,7 +1285,7 @@ emit_limple_insn (Lisp_Object insn) | |||
| 1290 | } | 1285 | } |
| 1291 | else if (EQ (op, Qfetch_handler)) | 1286 | else if (EQ (op, Qfetch_handler)) |
| 1292 | { | 1287 | { |
| 1293 | EMACS_UINT handler_buff_n = XFIXNUM (SECOND (args)); | 1288 | EMACS_UINT handler_buff_n = XFIXNUM (arg[1]); |
| 1294 | gcc_jit_lvalue *c = | 1289 | gcc_jit_lvalue *c = |
| 1295 | xmint_pointer (AREF (comp.buffer_handler_vec, handler_buff_n)); | 1290 | xmint_pointer (AREF (comp.buffer_handler_vec, handler_buff_n)); |
| 1296 | gcc_jit_lvalue *m_handlerlist = | 1291 | gcc_jit_lvalue *m_handlerlist = |
| @@ -1306,7 +1301,7 @@ emit_limple_insn (Lisp_Object insn) | |||
| 1306 | NULL, | 1301 | NULL, |
| 1307 | comp.handler_next_field))); | 1302 | comp.handler_next_field))); |
| 1308 | emit_frame_assignment ( | 1303 | emit_frame_assignment ( |
| 1309 | arg0, | 1304 | arg[0], |
| 1310 | gcc_jit_lvalue_as_rvalue( | 1305 | gcc_jit_lvalue_as_rvalue( |
| 1311 | gcc_jit_rvalue_dereference_field (gcc_jit_lvalue_as_rvalue (c), | 1306 | gcc_jit_rvalue_dereference_field (gcc_jit_lvalue_as_rvalue (c), |
| 1312 | NULL, | 1307 | NULL, |
| @@ -1335,7 +1330,7 @@ emit_limple_insn (Lisp_Object insn) | |||
| 1335 | } | 1330 | } |
| 1336 | else if (EQ (op, Qset)) | 1331 | else if (EQ (op, Qset)) |
| 1337 | { | 1332 | { |
| 1338 | Lisp_Object arg1 = SECOND (args); | 1333 | Lisp_Object arg1 = arg[1]; |
| 1339 | 1334 | ||
| 1340 | if (EQ (Ftype_of (arg1), Qcomp_mvar)) | 1335 | if (EQ (Ftype_of (arg1), Qcomp_mvar)) |
| 1341 | res = emit_mvar_val (arg1); | 1336 | res = emit_mvar_val (arg1); |
| @@ -1352,16 +1347,16 @@ emit_limple_insn (Lisp_Object insn) | |||
| 1352 | 1347 | ||
| 1353 | ICE_IF (!res, gcc_jit_context_get_first_error (comp.ctxt)); | 1348 | ICE_IF (!res, gcc_jit_context_get_first_error (comp.ctxt)); |
| 1354 | 1349 | ||
| 1355 | emit_frame_assignment (arg0, res); | 1350 | emit_frame_assignment (arg[0], res); |
| 1356 | } | 1351 | } |
| 1357 | else if (EQ (op, Qset_par_to_local)) | 1352 | else if (EQ (op, Qset_par_to_local)) |
| 1358 | { | 1353 | { |
| 1359 | /* Ex: (setpar #s(comp-mvar 2 0 nil nil nil) 0). */ | 1354 | /* Ex: (setpar #s(comp-mvar 2 0 nil nil nil) 0). */ |
| 1360 | EMACS_UINT param_n = XFIXNUM (SECOND (args)); | 1355 | EMACS_UINT param_n = XFIXNUM (arg[1]); |
| 1361 | gcc_jit_rvalue *param = | 1356 | gcc_jit_rvalue *param = |
| 1362 | gcc_jit_param_as_rvalue (gcc_jit_function_get_param (comp.func, | 1357 | gcc_jit_param_as_rvalue (gcc_jit_function_get_param (comp.func, |
| 1363 | param_n)); | 1358 | param_n)); |
| 1364 | emit_frame_assignment (arg0, param); | 1359 | emit_frame_assignment (arg[0], param); |
| 1365 | } | 1360 | } |
| 1366 | else if (EQ (op, Qset_args_to_local)) | 1361 | else if (EQ (op, Qset_args_to_local)) |
| 1367 | { | 1362 | { |
| @@ -1376,7 +1371,7 @@ emit_limple_insn (Lisp_Object insn) | |||
| 1376 | gcc_jit_rvalue *res = | 1371 | gcc_jit_rvalue *res = |
| 1377 | gcc_jit_lvalue_as_rvalue (gcc_jit_rvalue_dereference (gcc_args, NULL)); | 1372 | gcc_jit_lvalue_as_rvalue (gcc_jit_rvalue_dereference (gcc_args, NULL)); |
| 1378 | 1373 | ||
| 1379 | emit_frame_assignment (arg0, res); | 1374 | emit_frame_assignment (arg[0], res); |
| 1380 | } | 1375 | } |
| 1381 | else if (EQ (op, Qset_rest_args_to_local)) | 1376 | else if (EQ (op, Qset_rest_args_to_local)) |
| 1382 | { | 1377 | { |
| @@ -1385,7 +1380,7 @@ emit_limple_insn (Lisp_Object insn) | |||
| 1385 | C: local[2] = list (nargs - 2, args); | 1380 | C: local[2] = list (nargs - 2, args); |
| 1386 | */ | 1381 | */ |
| 1387 | 1382 | ||
| 1388 | EMACS_UINT slot_n = XFIXNUM (FUNCALL1 (comp-mvar-slot, arg0)); | 1383 | EMACS_UINT slot_n = XFIXNUM (FUNCALL1 (comp-mvar-slot, arg[0])); |
| 1389 | gcc_jit_rvalue *n = | 1384 | gcc_jit_rvalue *n = |
| 1390 | gcc_jit_context_new_rvalue_from_int (comp.ctxt, | 1385 | gcc_jit_context_new_rvalue_from_int (comp.ctxt, |
| 1391 | comp.ptrdiff_type, | 1386 | comp.ptrdiff_type, |
| @@ -1407,7 +1402,7 @@ emit_limple_insn (Lisp_Object insn) | |||
| 1407 | res = emit_call (Qlist, comp.lisp_obj_type, 2, | 1402 | res = emit_call (Qlist, comp.lisp_obj_type, 2, |
| 1408 | list_args, false); | 1403 | list_args, false); |
| 1409 | 1404 | ||
| 1410 | emit_frame_assignment (arg0, res); | 1405 | emit_frame_assignment (arg[0], res); |
| 1411 | } | 1406 | } |
| 1412 | else if (EQ (op, Qinc_args)) | 1407 | else if (EQ (op, Qinc_args)) |
| 1413 | { | 1408 | { |
| @@ -1433,10 +1428,10 @@ emit_limple_insn (Lisp_Object insn) | |||
| 1433 | gcc_jit_rvalue *reloc_n = | 1428 | gcc_jit_rvalue *reloc_n = |
| 1434 | gcc_jit_context_new_rvalue_from_int (comp.ctxt, | 1429 | gcc_jit_context_new_rvalue_from_int (comp.ctxt, |
| 1435 | comp.int_type, | 1430 | comp.int_type, |
| 1436 | XFIXNUM (SECOND (args))); | 1431 | XFIXNUM (arg[1])); |
| 1437 | emit_comment (SSDATA (Fprin1_to_string (THIRD (args), Qnil))); | 1432 | emit_comment (SSDATA (Fprin1_to_string (arg[2], Qnil))); |
| 1438 | emit_frame_assignment ( | 1433 | emit_frame_assignment ( |
| 1439 | arg0, | 1434 | arg[0], |
| 1440 | gcc_jit_lvalue_as_rvalue ( | 1435 | gcc_jit_lvalue_as_rvalue ( |
| 1441 | gcc_jit_context_new_array_access (comp.ctxt, | 1436 | gcc_jit_context_new_array_access (comp.ctxt, |
| 1442 | NULL, | 1437 | NULL, |
| @@ -1446,13 +1441,13 @@ emit_limple_insn (Lisp_Object insn) | |||
| 1446 | else if (EQ (op, Qcomment)) | 1441 | else if (EQ (op, Qcomment)) |
| 1447 | { | 1442 | { |
| 1448 | /* Ex: (comment "Function: foo"). */ | 1443 | /* Ex: (comment "Function: foo"). */ |
| 1449 | emit_comment((char *) SDATA (arg0)); | 1444 | emit_comment (SSDATA (arg[0])); |
| 1450 | } | 1445 | } |
| 1451 | else if (EQ (op, Qreturn)) | 1446 | else if (EQ (op, Qreturn)) |
| 1452 | { | 1447 | { |
| 1453 | gcc_jit_block_end_with_return (comp.block, | 1448 | gcc_jit_block_end_with_return (comp.block, |
| 1454 | NULL, | 1449 | NULL, |
| 1455 | emit_mvar_val (arg0)); | 1450 | emit_mvar_val (arg[0])); |
| 1456 | } | 1451 | } |
| 1457 | else | 1452 | else |
| 1458 | { | 1453 | { |