diff options
| author | Andrea Corallo | 2019-06-09 16:58:54 +0200 |
|---|---|---|
| committer | Andrea Corallo | 2020-01-01 11:33:40 +0100 |
| commit | efd20b8c4bec0b6edfeb0c415719cb7b230496ba (patch) | |
| tree | 15bf9350348af206fe6cc1ba94682429b48bc28e /src | |
| parent | 34d1a15307a4cb1f667e8af6ecca523369c436c1 (diff) | |
| download | emacs-efd20b8c4bec0b6edfeb0c415719cb7b230496ba.tar.gz emacs-efd20b8c4bec0b6edfeb0c415719cb7b230496ba.zip | |
add comp_xfixnum + comp_make_fixnum
Diffstat (limited to 'src')
| -rw-r--r-- | src/comp.c | 61 |
1 files changed, 60 insertions, 1 deletions
diff --git a/src/comp.c b/src/comp.c index 44d9a783f0e..12d952ca2a1 100644 --- a/src/comp.c +++ b/src/comp.c | |||
| @@ -162,6 +162,8 @@ typedef struct { | |||
| 162 | gcc_jit_rvalue *most_positive_fixnum; | 162 | gcc_jit_rvalue *most_positive_fixnum; |
| 163 | gcc_jit_rvalue *most_negative_fixnum; | 163 | gcc_jit_rvalue *most_negative_fixnum; |
| 164 | gcc_jit_rvalue *one; | 164 | gcc_jit_rvalue *one; |
| 165 | gcc_jit_rvalue *inttypebits; | ||
| 166 | gcc_jit_rvalue *lisp_int0; | ||
| 165 | basic_block_t *bblock; /* Current basic block */ | 167 | basic_block_t *bblock; /* Current basic block */ |
| 166 | Lisp_Object func_hash; /* f_name -> gcc_func */ | 168 | Lisp_Object func_hash; /* f_name -> gcc_func */ |
| 167 | } comp_t; | 169 | } comp_t; |
| @@ -209,6 +211,54 @@ pop (unsigned n, gcc_jit_lvalue ***stack_ref, gcc_jit_rvalue *args[]) | |||
| 209 | *stack_ref = stack; | 211 | *stack_ref = stack; |
| 210 | } | 212 | } |
| 211 | 213 | ||
| 214 | INLINE static gcc_jit_rvalue * | ||
| 215 | comp_xfixnum (gcc_jit_rvalue *obj) | ||
| 216 | { | ||
| 217 | return gcc_jit_context_new_binary_op ( | ||
| 218 | comp.ctxt, | ||
| 219 | NULL, | ||
| 220 | GCC_JIT_BINARY_OP_RSHIFT, | ||
| 221 | comp.long_long_type, | ||
| 222 | gcc_jit_rvalue_access_field (obj, | ||
| 223 | NULL, | ||
| 224 | comp.lisp_obj_as_num), | ||
| 225 | comp.inttypebits); | ||
| 226 | } | ||
| 227 | |||
| 228 | INLINE static gcc_jit_rvalue * | ||
| 229 | comp_make_fixnum (gcc_jit_rvalue *obj) | ||
| 230 | { | ||
| 231 | gcc_jit_rvalue *tmp = | ||
| 232 | gcc_jit_context_new_binary_op (comp.ctxt, | ||
| 233 | NULL, | ||
| 234 | GCC_JIT_BINARY_OP_LSHIFT, | ||
| 235 | comp.long_long_type, | ||
| 236 | obj, | ||
| 237 | comp.inttypebits); | ||
| 238 | |||
| 239 | tmp = gcc_jit_context_new_binary_op (comp.ctxt, | ||
| 240 | NULL, | ||
| 241 | GCC_JIT_BINARY_OP_PLUS, | ||
| 242 | comp.long_long_type, | ||
| 243 | tmp, | ||
| 244 | comp.lisp_int0); | ||
| 245 | |||
| 246 | gcc_jit_lvalue *res = gcc_jit_function_new_local (comp.func, | ||
| 247 | NULL, | ||
| 248 | comp.lisp_obj_type, | ||
| 249 | "lisp_obj_fixnum"); | ||
| 250 | |||
| 251 | gcc_jit_block_add_assignment (comp.bblock->gcc_bb, | ||
| 252 | NULL, | ||
| 253 | gcc_jit_lvalue_access_field ( | ||
| 254 | res, | ||
| 255 | NULL, | ||
| 256 | comp.lisp_obj_as_num), | ||
| 257 | tmp); | ||
| 258 | |||
| 259 | return gcc_jit_lvalue_as_rvalue (res); | ||
| 260 | } | ||
| 261 | |||
| 212 | /* Construct fill and return a lisp object form a raw pointer. */ | 262 | /* Construct fill and return a lisp object form a raw pointer. */ |
| 213 | 263 | ||
| 214 | INLINE static gcc_jit_rvalue * | 264 | INLINE static gcc_jit_rvalue * |
| @@ -217,7 +267,7 @@ comp_lisp_obj_as_ptr_from_ptr (basic_block_t *bblock, void *p) | |||
| 217 | gcc_jit_lvalue *lisp_obj = gcc_jit_function_new_local (comp.func, | 267 | gcc_jit_lvalue *lisp_obj = gcc_jit_function_new_local (comp.func, |
| 218 | NULL, | 268 | NULL, |
| 219 | comp.lisp_obj_type, | 269 | comp.lisp_obj_type, |
| 220 | "lisp_obj"); | 270 | "lisp_obj_from_ptr"); |
| 221 | gcc_jit_lvalue *lisp_obj_as_ptr = | 271 | gcc_jit_lvalue *lisp_obj_as_ptr = |
| 222 | gcc_jit_lvalue_access_field (lisp_obj, | 272 | gcc_jit_lvalue_access_field (lisp_obj, |
| 223 | NULL, | 273 | NULL, |
| @@ -1457,6 +1507,15 @@ init_comp (void) | |||
| 1457 | gcc_jit_context_new_rvalue_from_int (comp.ctxt, | 1507 | gcc_jit_context_new_rvalue_from_int (comp.ctxt, |
| 1458 | comp.long_long_type, /* FIXME? */ | 1508 | comp.long_long_type, /* FIXME? */ |
| 1459 | 1); | 1509 | 1); |
| 1510 | comp.inttypebits = | ||
| 1511 | gcc_jit_context_new_rvalue_from_int (comp.ctxt, | ||
| 1512 | comp.long_long_type, /* FIXME? */ | ||
| 1513 | INTTYPEBITS); | ||
| 1514 | |||
| 1515 | comp.lisp_int0 = | ||
| 1516 | gcc_jit_context_new_rvalue_from_int (comp.ctxt, | ||
| 1517 | comp.long_long_type, /* FIXME? */ | ||
| 1518 | Lisp_Int0); | ||
| 1460 | 1519 | ||
| 1461 | enum gcc_jit_types ptrdiff_t_gcc; | 1520 | enum gcc_jit_types ptrdiff_t_gcc; |
| 1462 | if (sizeof (ptrdiff_t) == sizeof (int)) | 1521 | if (sizeof (ptrdiff_t) == sizeof (int)) |