aboutsummaryrefslogtreecommitdiffstats
path: root/src/comp.c
diff options
context:
space:
mode:
authorAndrea Corallo2019-06-10 11:02:47 +0200
committerAndrea Corallo2020-01-01 11:33:40 +0100
commit7ce2c17a0fbde3203f311c6b91d8bb2ba77adeda (patch)
treed0f9d0be59f517a4c1ed813c1ad47e516d0f8289 /src/comp.c
parent65eb55ff4194c67ede020ceabd7b92e7d2128908 (diff)
downloademacs-7ce2c17a0fbde3203f311c6b91d8bb2ba77adeda.tar.gz
emacs-7ce2c17a0fbde3203f311c6b91d8bb2ba77adeda.zip
add Bnegate support
Diffstat (limited to 'src/comp.c')
-rw-r--r--src/comp.c63
1 files changed, 58 insertions, 5 deletions
diff --git a/src/comp.c b/src/comp.c
index d92e4822266..712fd01af07 100644
--- a/src/comp.c
+++ b/src/comp.c
@@ -634,6 +634,7 @@ compute_bblocks (ptrdiff_t bytestr_length, unsigned char *bytestr_data)
634 break; 634 break;
635 case Bsub1: 635 case Bsub1:
636 case Badd1: 636 case Badd1:
637 case Bnegate:
637 case Breturn: 638 case Breturn:
638 new_bb = true; 639 new_bb = true;
639 break; 640 break;
@@ -997,8 +998,8 @@ compile_f (const char *f_name, ptrdiff_t bytestr_length,
997 { 998 {
998 999
999 /* (FIXNUMP (TOP) && XFIXNUM (TOP) != MOST_NEGATIVE_FIXNUM 1000 /* (FIXNUMP (TOP) && XFIXNUM (TOP) != MOST_NEGATIVE_FIXNUM
1000 ? make_fixnum (XFIXNUM (TOP) - 1) 1001 ? make_fixnum (XFIXNUM (TOP) - 1)
1001 : Fsub1 (TOP)) */ 1002 : Fsub1 (TOP)) */
1002 1003
1003 gcc_jit_block *sub1_inline_block = 1004 gcc_jit_block *sub1_inline_block =
1004 gcc_jit_function_new_block (comp.func, "inline_sub1"); 1005 gcc_jit_function_new_block (comp.func, "inline_sub1");
@@ -1057,8 +1058,8 @@ compile_f (const char *f_name, ptrdiff_t bytestr_length,
1057 { 1058 {
1058 1059
1059 /* (FIXNUMP (TOP) && XFIXNUM (TOP) != MOST_POSITIVE_FIXNUM 1060 /* (FIXNUMP (TOP) && XFIXNUM (TOP) != MOST_POSITIVE_FIXNUM
1060 ? make_fixnum (XFIXNUM (TOP) + 1) 1061 ? make_fixnum (XFIXNUM (TOP) + 1)
1061 : Fadd (TOP)) */ 1062 : Fadd (TOP)) */
1062 1063
1063 gcc_jit_block *add1_inline_block = 1064 gcc_jit_block *add1_inline_block =
1064 gcc_jit_function_new_block (comp.func, "inline_add1"); 1065 gcc_jit_function_new_block (comp.func, "inline_add1");
@@ -1131,7 +1132,59 @@ compile_f (const char *f_name, ptrdiff_t bytestr_length,
1131 EMIT_SCRATCH_CALL_N ("Fminus", 2); 1132 EMIT_SCRATCH_CALL_N ("Fminus", 2);
1132 break; 1133 break;
1133 case Bnegate: 1134 case Bnegate:
1134 error ("Bnegate unsupported bytecode\n"); 1135 {
1136
1137 /* (FIXNUMP (TOP) && XFIXNUM (TOP) != MOST_NEGATIVE_FIXNUM
1138 ? make_fixnum (- XFIXNUM (TOP))
1139 : Fminus (1, &TOP)) */
1140
1141 gcc_jit_block *negate_inline_block =
1142 gcc_jit_function_new_block (comp.func, "inline_negate");
1143 gcc_jit_block *negate_fcall_block =
1144 gcc_jit_function_new_block (comp.func, "fcall_negate");
1145
1146 gcc_jit_rvalue *tos_as_num =
1147 comp_XFIXNUM (gcc_jit_lvalue_as_rvalue (TOS));
1148
1149 comp_emit_cond_jump (
1150 gcc_jit_context_new_binary_op (
1151 comp.ctxt,
1152 NULL,
1153 GCC_JIT_BINARY_OP_LOGICAL_AND,
1154 comp.bool_type,
1155 comp_cast (comp.bool_type,
1156 comp_FIXNUMP (gcc_jit_lvalue_as_rvalue (TOS))),
1157 gcc_jit_context_new_comparison (comp.ctxt,
1158 NULL,
1159 GCC_JIT_COMPARISON_NE,
1160 tos_as_num,
1161 comp.most_negative_fixnum)),
1162 negate_inline_block,
1163 negate_fcall_block);
1164
1165 gcc_jit_rvalue *negate_inline_res =
1166 gcc_jit_context_new_unary_op (comp.ctxt,
1167 NULL,
1168 GCC_JIT_UNARY_OP_MINUS,
1169 comp.long_long_type,
1170 tos_as_num);
1171
1172 gcc_jit_block_add_assignment (negate_inline_block,
1173 NULL,
1174 TOS,
1175 comp_make_fixnum (negate_inline_block,
1176 negate_inline_res));
1177 basic_block_t bb_orig = *comp.bblock;
1178
1179 comp.bblock->gcc_bb = negate_fcall_block;
1180 EMIT_SCRATCH_CALL_N ("Fminus", 1);
1181 *comp.bblock = bb_orig;
1182
1183 gcc_jit_block_end_with_jump (negate_inline_block, NULL,
1184 bb_map[pc].gcc_bb);
1185 gcc_jit_block_end_with_jump (negate_fcall_block, NULL,
1186 bb_map[pc].gcc_bb);
1187 }
1135 break; 1188 break;
1136 case Bplus: 1189 case Bplus:
1137 EMIT_SCRATCH_CALL_N ("Fplus", 2); 1190 EMIT_SCRATCH_CALL_N ("Fplus", 2);