}
static gcc_jit_rvalue *
-emit_cast (gcc_jit_type *new_type, gcc_jit_rvalue *obj)
+emit_coerce (gcc_jit_type *new_type, gcc_jit_rvalue *obj)
{
static ptrdiff_t i;
+ gcc_jit_type *old_type = gcc_jit_rvalue_get_type (obj);
+
+ if (new_type == old_type)
+ return obj;
+
gcc_jit_field *orig_field =
- type_to_cast_field (gcc_jit_rvalue_get_type (obj));
+ type_to_cast_field (old_type);
gcc_jit_field *dest_field = type_to_cast_field (new_type);
gcc_jit_lvalue *tmp_u =
32));
return
- emit_cast (comp.long_long_type,
+ emit_coerce (comp.long_long_type,
gcc_jit_context_new_binary_op (
comp.ctxt,
NULL,
gcc_jit_context_new_rvalue_from_int (comp.ctxt,
comp.uintptr_type,
size_of_ptr_ref),
- emit_cast (comp.uintptr_type, i));
+ emit_coerce (comp.uintptr_type, i));
return
- emit_cast (
+ emit_coerce (
ptr_type,
gcc_jit_context_new_binary_op (
comp.ctxt,
NULL,
GCC_JIT_BINARY_OP_PLUS,
comp.uintptr_type,
- emit_cast (comp.uintptr_type, ptr),
+ emit_coerce (comp.uintptr_type, ptr),
offset));
}
emit_comment ("XUNTAG");
#ifndef WIDE_EMACS_INT
- return emit_cast (
+ return emit_coerce (
gcc_jit_type_get_pointer (type),
gcc_jit_context_new_binary_op (
comp.ctxt,
comp.emacs_int_type,
lisp_word_tag)));
#else
- return emit_cast (
+ return emit_coerce (
gcc_jit_type_get_pointer (type),
gcc_jit_context_new_binary_op (
comp.ctxt,
GCC_JIT_BINARY_OP_MINUS,
comp.unsigned_long_long_type,
/* FIXME Should be XLP. */
- emit_cast (comp.unsigned_long_long_type, emit_XLI (a)),
- emit_cast (comp.unsigned_long_long_type,
- emit_rvalue_from_long_long (lisp_word_tag))));
+ emit_coerce (comp.unsigned_long_long_type, emit_XLI (a)),
+ emit_coerce (comp.unsigned_long_long_type,
+ emit_rvalue_from_long_long (lisp_word_tag))));
#endif
}
NULL,
GCC_JIT_BINARY_OP_MINUS,
comp.unsigned_type,
- emit_cast (comp.unsigned_type, sh_res),
+ emit_coerce (comp.unsigned_type, sh_res),
gcc_jit_context_new_rvalue_from_int (
comp.ctxt,
comp.unsigned_type,
NULL,
GCC_JIT_BINARY_OP_MINUS,
comp.unsigned_type,
- emit_cast (comp.unsigned_type, sh_res),
+ emit_coerce (comp.unsigned_type, sh_res),
gcc_jit_context_new_rvalue_from_int (
comp.ctxt,
comp.unsigned_type,
emit_XFIXNUM (gcc_jit_rvalue *obj)
{
emit_comment ("XFIXNUM");
- gcc_jit_rvalue *i = emit_cast (comp.emacs_uint_type, emit_XLI (obj));
+ gcc_jit_rvalue *i = emit_coerce (comp.emacs_uint_type, emit_XLI (obj));
if (!USE_LSB_TAG)
{
NULL,
GCC_JIT_BINARY_OP_LSHIFT,
comp.emacs_uint_type,
- emit_cast (comp.emacs_uint_type, i),
+ emit_coerce (comp.emacs_uint_type, i),
comp.inttypebits);
return gcc_jit_context_new_binary_op (comp.ctxt,
NULL,
GCC_JIT_BINARY_OP_LOGICAL_OR,
comp.bool_type,
- emit_cast (comp.bool_type,
- emit_FIXNUMP (obj)),
+ emit_coerce (comp.bool_type,
+ emit_FIXNUMP (obj)),
emit_BIGNUMP (obj));
}
GCC_JIT_BINARY_OP_LOGICAL_OR,
comp.bool_type,
emit_INTEGERP (obj),
- emit_cast (comp.bool_type,
- emit_FLOATP (obj)));
+ emit_coerce (comp.bool_type,
+ emit_FLOATP (obj)));
}
static gcc_jit_rvalue *
NULL,
GCC_JIT_BINARY_OP_LSHIFT,
comp.emacs_int_type,
- emit_cast (comp.emacs_uint_type, n),
+ emit_coerce (comp.emacs_uint_type, n),
comp.inttypebits);
tmp = gcc_jit_context_new_binary_op (comp.ctxt,
*/
gcc_jit_rvalue *intmask =
- emit_cast (comp.emacs_uint_type,
- emit_rvalue_from_long_long ((EMACS_INT_MAX
- >> (INTTYPEBITS - 1))));
+ emit_coerce (comp.emacs_uint_type,
+ emit_rvalue_from_long_long ((EMACS_INT_MAX
+ >> (INTTYPEBITS - 1))));
n = gcc_jit_context_new_binary_op (
comp.ctxt,
NULL,
GCC_JIT_BINARY_OP_BITWISE_AND,
comp.emacs_uint_type,
intmask,
- emit_cast (comp.emacs_uint_type, n));
+ emit_coerce (comp.emacs_uint_type, n));
n = gcc_jit_context_new_binary_op (
comp.ctxt,
NULL,
GCC_JIT_BINARY_OP_LSHIFT,
comp.emacs_uint_type,
- emit_cast (comp.emacs_uint_type, comp.lisp_int0),
+ emit_coerce (comp.emacs_uint_type, comp.lisp_int0),
gcc_jit_context_new_rvalue_from_int (comp.ctxt,
comp.emacs_uint_type,
VALBITS)),
n);
- return emit_XLI (emit_cast (comp.emacs_int_type, n));
+ return emit_XLI (emit_coerce (comp.emacs_int_type, n));
}
SSDATA (Fprin1_to_string (obj, Qnil))));
if (NIL_IS_ZERO && EQ (obj, Qnil))
- return emit_cast (comp.lisp_obj_type,
- gcc_jit_context_new_rvalue_from_ptr (comp.ctxt,
- comp.void_ptr_type,
- NULL));
+ return emit_coerce (comp.lisp_obj_type,
+ gcc_jit_context_new_rvalue_from_ptr (comp.ctxt,
+ comp.void_ptr_type,
+ NULL));
imm_reloc_t reloc = obj_to_reloc (obj);
return
gcc_jit_lvalue_as_rvalue (
NULL,
GCC_JIT_BINARY_OP_MINUS,
comp.uintptr_type,
- emit_cast (comp.uintptr_type, ptr),
- emit_cast (comp.uintptr_type,
- gcc_jit_lvalue_as_rvalue (
- gcc_jit_rvalue_dereference (comp.pure_ref, NULL)))),
+ emit_coerce (comp.uintptr_type, ptr),
+ emit_coerce (comp.uintptr_type,
+ gcc_jit_lvalue_as_rvalue (
+ gcc_jit_rvalue_dereference (comp.pure_ref, NULL)))),
gcc_jit_context_new_rvalue_from_int (comp.ctxt,
comp.uintptr_type,
PURESIZE));
: gcc_jit_context_new_rvalue_from_long (comp.ctxt,
comp.void_ptr_type,
constant);
- return emit_cast (comp.lisp_obj_type, word);
+ return emit_coerce (comp.lisp_obj_type, word);
}
/* Other const objects are fetched from the reloc array. */
return emit_const_lisp_obj (constant);
emit_consp (Lisp_Object insn)
{
gcc_jit_rvalue *x = emit_mvar_val (SECOND (insn));
- gcc_jit_rvalue *res = emit_cast (comp.bool_type,
+ gcc_jit_rvalue *res = emit_coerce (comp.bool_type,
emit_CONSP (x));
return gcc_jit_context_new_call (comp.ctxt,
NULL,
GCC_JIT_BINARY_OP_LOGICAL_OR,
comp.bool_type,
gcc_jit_param_as_rvalue (param[1]),
- emit_cast (comp.bool_type,
- emit_CONSP (c))),
+ emit_coerce (comp.bool_type,
+ emit_CONSP (c))),
is_cons_b,
not_a_cons_b);
comp.block = is_cons_b;
GCC_JIT_BINARY_OP_LOGICAL_OR,
comp.bool_type,
gcc_jit_param_as_rvalue (param[1]),
- emit_cast (comp.bool_type,
- emit_FIXNUMP (n)));
+ emit_coerce (comp.bool_type,
+ emit_FIXNUMP (n)));
emit_cond_jump (
gcc_jit_context_new_binary_op (
GCC_JIT_BINARY_OP_LOGICAL_OR,
comp.bool_type,
gcc_jit_param_as_rvalue (param[1]),
- emit_cast (comp.bool_type,
- emit_FIXNUMP (gcc_jit_lvalue_as_rvalue (n))));
+ emit_coerce (comp.bool_type,
+ emit_FIXNUMP (gcc_jit_lvalue_as_rvalue (n))));
emit_cond_jump (
gcc_jit_context_new_binary_op (