From: Andrea Corallo Date: Tue, 2 Jul 2019 21:14:36 +0000 (+0200) Subject: add emit_ptr_arithmetic X-Git-Tag: emacs-28.0.90~2727^2~1402 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=193688f2fc34c03a32b1e013d74fd6e5fac845c7;p=emacs.git add emit_ptr_arithmetic --- diff --git a/src/comp.c b/src/comp.c index 301ff83c8e6..a9b46fc8605 100644 --- a/src/comp.c +++ b/src/comp.c @@ -567,6 +567,41 @@ emit_cast (gcc_jit_type *new_type, gcc_jit_rvalue *obj) dest_field); } +/* + Emit the equivalent of + ptr[i] + ptr + size_of_ptr_ref * i +*/ + +static gcc_jit_rvalue * +emit_ptr_arithmetic (gcc_jit_rvalue *ptr, gcc_jit_type *ptr_type, + int size_of_ptr_ref, gcc_jit_rvalue *i) +{ + emit_comment ("ptr_arithmetic"); + + gcc_jit_rvalue *offset = + gcc_jit_context_new_binary_op ( + comp.ctxt, + NULL, + GCC_JIT_BINARY_OP_MULT, + comp.uintptr_type, + gcc_jit_context_new_rvalue_from_int (comp.ctxt, + comp.uintptr_type, + size_of_ptr_ref), + emit_cast (comp.uintptr_type, i)); + + return + emit_cast ( + 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), + offset)); +} + INLINE static gcc_jit_rvalue * emit_XLI (gcc_jit_rvalue *obj) {