unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [PATCH] comp.c: Use the newly added bitcast API for type coercion, when available. (feature/jit-improved-type-punning)
@ 2022-09-27 18:15 Vibhav Pant
  2022-09-27 18:18 ` Lars Ingebrigtsen
  2022-09-28 12:37 ` Andrea Corallo
  0 siblings, 2 replies; 8+ messages in thread
From: Vibhav Pant @ 2022-09-27 18:15 UTC (permalink / raw)
  To: emacs-devel


[-- Attachment #1.1: Type: text/plain, Size: 557 bytes --]


* src/comp.c: Add declarations for gcc_jit_type_is_pointer,
gcc_jit_context_new_bitcast, when provided.

* (type_to_cast_index, define_type_punning, define_cast_from_to,
define_cast_functions): Define functions when
gcc_jit_context_new_bitcast is not available.

* (emit_coerce): Use gcc_jit_context_new_bitcast to coerce types, when
available.


The code is also available on the branch feature/jit-improved-type-
punning.

Thanks,
Vibhav

-- 
Vibhav Pant
vibhavp@gmail.com

GPG: 7ED1 D48C 513C A024 BE3A 785F E3FB 28CB 6AB5 9598


[-- Attachment #1.2: Type: text/x-patch, Size: 8686 bytes --]

diff --git a/src/comp.c b/src/comp.c
index 4813ca04a9..ddfbe2623e 100644
--- a/src/comp.c
+++ b/src/comp.c
@@ -68,6 +68,7 @@
 #undef gcc_jit_context_get_type
 #undef gcc_jit_context_new_array_access
 #undef gcc_jit_context_new_array_type
+#undef gcc_jit_context_new_bitcast
 #undef gcc_jit_context_new_binary_op
 #undef gcc_jit_context_new_call
 #undef gcc_jit_context_new_call_through_ptr
@@ -108,6 +109,7 @@
 #undef gcc_jit_struct_set_fields
 #undef gcc_jit_type_get_const
 #undef gcc_jit_type_get_pointer
+#undef gcc_jit_type_is_pointer
 #undef gcc_jit_version_major
 #undef gcc_jit_version_minor
 #undef gcc_jit_version_patchlevel
@@ -180,8 +182,13 @@ DEF_DLL_FN (gcc_jit_rvalue *, gcc_jit_context_new_call_through_ptr,
             (gcc_jit_context *ctxt, gcc_jit_location *loc,
              gcc_jit_rvalue *fn_ptr, int numargs, gcc_jit_rvalue **args));
 DEF_DLL_FN (gcc_jit_rvalue *, gcc_jit_context_new_cast,
+            (gcc_jit_context * ctxt, gcc_jit_location *loc,
+             gcc_jit_rvalue *rvalue, gcc_jit_type *type));
+#ifdef LIBGCCJIT_HAVE_gcc_jit_context_new_bitcast
+DEF_DLL_FN (gcc_jit_rvalue *, gcc_jit_context_new_bitcast,
             (gcc_jit_context *ctxt, gcc_jit_location *loc,
              gcc_jit_rvalue *rvalue, gcc_jit_type *type));
+#endif
 DEF_DLL_FN (gcc_jit_rvalue *, gcc_jit_context_new_comparison,
             (gcc_jit_context *ctxt, gcc_jit_location *loc,
              enum gcc_jit_comparison op, gcc_jit_rvalue *a, gcc_jit_rvalue *b));
@@ -224,6 +231,9 @@ DEF_DLL_FN (gcc_jit_type *, gcc_jit_struct_as_type,
             (gcc_jit_struct *struct_type));
 DEF_DLL_FN (gcc_jit_type *, gcc_jit_type_get_const, (gcc_jit_type *type));
 DEF_DLL_FN (gcc_jit_type *, gcc_jit_type_get_pointer, (gcc_jit_type *type));
+#ifdef LIBGCCJIT_HAVE_REFLECTION
+DEF_DLL_FN (gcc_jit_type *, gcc_jit_type_is_pointer, (gcc_jit_type *type));
+#endif
 DEF_DLL_FN (void, gcc_jit_block_add_assignment,
             (gcc_jit_block *block, gcc_jit_location *loc, gcc_jit_lvalue *lvalue,
              gcc_jit_rvalue *rvalue));
@@ -293,6 +303,9 @@ init_gccjit_functions (void)
   LOAD_DLL_FN (library, gcc_jit_context_get_type);
   LOAD_DLL_FN (library, gcc_jit_context_new_array_access);
   LOAD_DLL_FN (library, gcc_jit_context_new_array_type);
+#ifdef LIBGCCJIT_HAVE_gcc_jit_context_new_bitcast
+  LOAD_DLL_FN (library, gcc_jit_context_new_bitcast);
+#endif
   LOAD_DLL_FN (library, gcc_jit_context_new_binary_op);
   LOAD_DLL_FN (library, gcc_jit_context_new_call);
   LOAD_DLL_FN (library, gcc_jit_context_new_call_through_ptr);
@@ -334,6 +347,9 @@ init_gccjit_functions (void)
   LOAD_DLL_FN (library, gcc_jit_struct_set_fields);
   LOAD_DLL_FN (library, gcc_jit_type_get_const);
   LOAD_DLL_FN (library, gcc_jit_type_get_pointer);
+#ifdef LIBGCCJIT_HAVE_REFLECTION
+  LOAD_DLL_FN (library, gcc_jit_type_is_pointer);
+#endif
   LOAD_DLL_FN_OPT (library, gcc_jit_context_add_command_line_option);
   LOAD_DLL_FN_OPT (library, gcc_jit_context_add_driver_option);
 #if defined (LIBGCCJIT_HAVE_gcc_jit_global_set_initializer)
@@ -368,6 +384,9 @@ #define gcc_jit_context_get_int_type fn_gcc_jit_context_get_int_type
 #define gcc_jit_context_get_type fn_gcc_jit_context_get_type
 #define gcc_jit_context_new_array_access fn_gcc_jit_context_new_array_access
 #define gcc_jit_context_new_array_type fn_gcc_jit_context_new_array_type
+#ifdef LIBGCCJIT_HAVE_gcc_jit_context_new_bitcast
+  #define gcc_jit_context_new_bitcast fn_gcc_jit_context_new_bitcast
+#endif
 #define gcc_jit_context_new_binary_op fn_gcc_jit_context_new_binary_op
 #define gcc_jit_context_new_call fn_gcc_jit_context_new_call
 #define gcc_jit_context_new_call_through_ptr fn_gcc_jit_context_new_call_through_ptr
@@ -410,6 +429,9 @@ #define gcc_jit_rvalue_dereference_field fn_gcc_jit_rvalue_dereference_field
 #define gcc_jit_rvalue_get_type fn_gcc_jit_rvalue_get_type
 #define gcc_jit_struct_as_type fn_gcc_jit_struct_as_type
 #define gcc_jit_struct_set_fields fn_gcc_jit_struct_set_fields
+#ifdef LIBGCCJIT_HAVE_REFLECTION
+#define gcc_jit_type_is_pointer fn_gcc_jit_type_is_pointer
+#endif
 #define gcc_jit_type_get_const fn_gcc_jit_type_get_const
 #define gcc_jit_type_get_pointer fn_gcc_jit_type_get_pointer
 #if defined (LIBGCCJIT_HAVE_gcc_jit_version)
@@ -518,7 +540,9 @@ #define F_RELOC_MAX_SIZE 1500
 
 static f_reloc_t freloc;
 
+#ifndef LIBGCCJIT_HAVE_gcc_jit_context_new_bitcast
 #define NUM_CAST_TYPES 15
+#endif
 
 typedef struct {
   EMACS_INT len;
@@ -593,13 +617,15 @@ #define NUM_CAST_TYPES 15
   gcc_jit_rvalue *current_thread_ref;
   /* Other globals.  */
   gcc_jit_rvalue *pure_ptr;
-  /* libgccjit has really limited support for casting therefore this union will
-     be used for the scope.  */
+#ifndef LIBGCCJIT_HAVE_gcc_jit_context_new_bitcast
+  /* This version of libgccjit has really limited support for casting
+     therefore this union will be used for the scope.  */
   gcc_jit_type *cast_union_type;
   gcc_jit_function *cast_functions_from_to[NUM_CAST_TYPES][NUM_CAST_TYPES];
   gcc_jit_function *cast_ptr_to_int;
   gcc_jit_function *cast_int_to_ptr;
   gcc_jit_type *cast_types[NUM_CAST_TYPES];
+#endif
   gcc_jit_function *func; /* Current function being compiled.  */
   bool func_has_non_local; /* From comp-func has-non-local slot.  */
   EMACS_INT func_speed; /* From comp-func speed slot.  */
@@ -1100,6 +1126,7 @@ emit_cond_jump (gcc_jit_rvalue *test,
 
 }
 
+#ifndef LIBGCCJIT_HAVE_gcc_jit_context_new_bitcast
 static int
 type_to_cast_index (gcc_jit_type * type)
 {
@@ -1109,6 +1136,7 @@ type_to_cast_index (gcc_jit_type * type)
 
   xsignal1 (Qnative_ice, build_string ("unsupported cast"));
 }
+#endif
 
 static gcc_jit_rvalue *
 emit_coerce (gcc_jit_type *new_type, gcc_jit_rvalue *obj)
@@ -1145,14 +1173,41 @@ emit_coerce (gcc_jit_type *new_type, gcc_jit_rvalue *obj)
     }
 #endif
 
+#ifdef LIBGCCJIT_HAVE_gcc_jit_context_new_bitcast
+  bool old_is_ptr = gcc_jit_type_is_pointer (old_type) != NULL;
+  bool new_is_ptr = gcc_jit_type_is_pointer (new_type) != NULL;
+
+  gcc_jit_rvalue *tmp = obj;
+
+  if (old_is_ptr != new_is_ptr)
+    {
+      if (old_is_ptr)
+	{
+	  tmp = gcc_jit_context_new_cast (comp.ctxt, NULL, tmp,
+					  comp.void_ptr_type);
+	  tmp = gcc_jit_context_new_bitcast (comp.ctxt, NULL, tmp,
+					     comp.uintptr_type);
+	}
+      else
+	{
+	  tmp = gcc_jit_context_new_cast (comp.ctxt, NULL, tmp,
+					  comp.uintptr_type);
+	  tmp = gcc_jit_context_new_bitcast (comp.ctxt, NULL, tmp,
+					     comp.void_ptr_type);
+	}
+    }
+  return gcc_jit_context_new_cast (comp.ctxt, NULL, tmp, new_type);
+#else /* !defined(LIBGCCJIT_HAVE_gcc_jit_context_new_bitcast) */
   int old_index = type_to_cast_index (old_type);
   int new_index = type_to_cast_index (new_type);
 
   /* Lookup the appropriate cast function in the cast matrix.  */
   return gcc_jit_context_new_call (comp.ctxt,
-           NULL,
-           comp.cast_functions_from_to[old_index][new_index],
-           1, &obj);
+				   NULL,
+				   comp.cast_functions_from_to
+				   [old_index][new_index],
+				   1, &obj);
+#endif
 }
 
 static gcc_jit_rvalue *
@@ -3318,6 +3373,7 @@ define_thread_state_struct (void)
     gcc_jit_type_get_pointer (gcc_jit_struct_as_type (comp.thread_state_s));
 }
 
+#ifndef LIBGCCJIT_HAVE_gcc_jit_context_new_bitcast
 static gcc_jit_function *
 define_type_punning (const char *name,
 		     gcc_jit_type *from, gcc_jit_field *from_field,
@@ -3336,6 +3392,7 @@ define_type_punning (const char *name,
 
   DECL_BLOCK (entry_block, result);
 
+
   gcc_jit_lvalue *tmp_union
     = gcc_jit_function_new_local (result,
                                   NULL,
@@ -3422,6 +3479,7 @@ define_cast_functions (void)
         { comp.unsigned_long_type, "unsigned_long", false },
         { comp.unsigned_type, "unsigned", false },
         { comp.void_ptr_type, "void_ptr", true } };
+
   gcc_jit_field *cast_union_fields[2];
 
   /* Define the union used for type punning.  */
@@ -3451,6 +3509,7 @@ define_cast_functions (void)
 					      comp.void_ptr_type,
 					      cast_union_fields[0]);
 
+
   for (int i = 0; i < NUM_CAST_TYPES; ++i)
     comp.cast_types[i] = cast_types[i].type;
 
@@ -3460,6 +3519,7 @@ define_cast_functions (void)
         comp.cast_functions_from_to[i][j] =
           define_cast_from_to (cast_types[i], cast_types[j]);
 }
+#endif /* !defined(LIBGCCJIT_HAVE_gcc_jit_context_new_bitcast) */
 
 static void
 define_CHECK_TYPE (void)
@@ -4660,7 +4720,9 @@ DEFUN ("comp--init-ctxt", Fcomp__init_ctxt, Scomp__init_ctxt,
   define_jmp_buf ();
   define_handler_struct ();
   define_thread_state_struct ();
+#ifndef LIBGCCJIT_HAVE_gcc_jit_context_new_bitcast
   define_cast_functions ();
+#endif
 
   return Qt;
 }

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH] comp.c: Use the newly added bitcast API for type coercion, when available. (feature/jit-improved-type-punning)
  2022-09-27 18:15 [PATCH] comp.c: Use the newly added bitcast API for type coercion, when available. (feature/jit-improved-type-punning) Vibhav Pant
@ 2022-09-27 18:18 ` Lars Ingebrigtsen
  2022-09-28 12:39   ` Andrea Corallo
  2022-09-28 12:37 ` Andrea Corallo
  1 sibling, 1 reply; 8+ messages in thread
From: Lars Ingebrigtsen @ 2022-09-27 18:18 UTC (permalink / raw)
  To: Vibhav Pant; +Cc: emacs-devel, Andrea Corallo

Vibhav Pant <vibhavp@gmail.com> writes:

> * (emit_coerce): Use gcc_jit_context_new_bitcast to coerce types, when
> available.

Perhaps Andrea has some comments; added to the CCs.



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] comp.c: Use the newly added bitcast API for type coercion, when available. (feature/jit-improved-type-punning)
  2022-09-27 18:15 [PATCH] comp.c: Use the newly added bitcast API for type coercion, when available. (feature/jit-improved-type-punning) Vibhav Pant
  2022-09-27 18:18 ` Lars Ingebrigtsen
@ 2022-09-28 12:37 ` Andrea Corallo
  2022-10-02 17:27   ` Vibhav Pant
  1 sibling, 1 reply; 8+ messages in thread
From: Andrea Corallo @ 2022-09-28 12:37 UTC (permalink / raw)
  To: Vibhav Pant; +Cc: emacs-devel

Vibhav Pant <vibhavp@gmail.com> writes:

> * src/comp.c: Add declarations for gcc_jit_type_is_pointer,
> gcc_jit_context_new_bitcast, when provided.
>
> * (type_to_cast_index, define_type_punning, define_cast_from_to,
> define_cast_functions): Define functions when
> gcc_jit_context_new_bitcast is not available.
>
> * (emit_coerce): Use gcc_jit_context_new_bitcast to coerce types, when
> available.
>
>
> The code is also available on the branch feature/jit-improved-type-
> punning.
>
> Thanks,
> Vibhav

Hi Vibhav,

thanks for the patch, please find some comments below.

> diff --git a/src/comp.c b/src/comp.c
> index 4813ca04a9..ddfbe2623e 100644
> --- a/src/comp.c
> +++ b/src/comp.c
> @@ -68,6 +68,7 @@
>  #undef gcc_jit_context_get_type
>  #undef gcc_jit_context_new_array_access
>  #undef gcc_jit_context_new_array_type
> +#undef gcc_jit_context_new_bitcast
>  #undef gcc_jit_context_new_binary_op
>  #undef gcc_jit_context_new_call
>  #undef gcc_jit_context_new_call_through_ptr
> @@ -108,6 +109,7 @@
>  #undef gcc_jit_struct_set_fields
>  #undef gcc_jit_type_get_const
>  #undef gcc_jit_type_get_pointer
> +#undef gcc_jit_type_is_pointer
>  #undef gcc_jit_version_major
>  #undef gcc_jit_version_minor
>  #undef gcc_jit_version_patchlevel
> @@ -180,8 +182,13 @@ DEF_DLL_FN (gcc_jit_rvalue *, gcc_jit_context_new_call_through_ptr,
>              (gcc_jit_context *ctxt, gcc_jit_location *loc,
>               gcc_jit_rvalue *fn_ptr, int numargs, gcc_jit_rvalue **args));
>  DEF_DLL_FN (gcc_jit_rvalue *, gcc_jit_context_new_cast,
> +            (gcc_jit_context * ctxt, gcc_jit_location *loc,
> +             gcc_jit_rvalue *rvalue, gcc_jit_type *type));
> +#ifdef LIBGCCJIT_HAVE_gcc_jit_context_new_bitcast
> +DEF_DLL_FN (gcc_jit_rvalue *, gcc_jit_context_new_bitcast,
>              (gcc_jit_context *ctxt, gcc_jit_location *loc,
>               gcc_jit_rvalue *rvalue, gcc_jit_type *type));
> +#endif
>  DEF_DLL_FN (gcc_jit_rvalue *, gcc_jit_context_new_comparison,
>              (gcc_jit_context *ctxt, gcc_jit_location *loc,
>               enum gcc_jit_comparison op, gcc_jit_rvalue *a, gcc_jit_rvalue *b));
> @@ -224,6 +231,9 @@ DEF_DLL_FN (gcc_jit_type *, gcc_jit_struct_as_type,
>              (gcc_jit_struct *struct_type));
>  DEF_DLL_FN (gcc_jit_type *, gcc_jit_type_get_const, (gcc_jit_type *type));
>  DEF_DLL_FN (gcc_jit_type *, gcc_jit_type_get_pointer, (gcc_jit_type *type));
> +#ifdef LIBGCCJIT_HAVE_REFLECTION
> +DEF_DLL_FN (gcc_jit_type *, gcc_jit_type_is_pointer, (gcc_jit_type *type));
> +#endif
>  DEF_DLL_FN (void, gcc_jit_block_add_assignment,
>              (gcc_jit_block *block, gcc_jit_location *loc, gcc_jit_lvalue *lvalue,
>               gcc_jit_rvalue *rvalue));
> @@ -293,6 +303,9 @@ init_gccjit_functions (void)
>    LOAD_DLL_FN (library, gcc_jit_context_get_type);
>    LOAD_DLL_FN (library, gcc_jit_context_new_array_access);
>    LOAD_DLL_FN (library, gcc_jit_context_new_array_type);
> +#ifdef LIBGCCJIT_HAVE_gcc_jit_context_new_bitcast
> +  LOAD_DLL_FN (library, gcc_jit_context_new_bitcast);
> +#endif
>    LOAD_DLL_FN (library, gcc_jit_context_new_binary_op);
>    LOAD_DLL_FN (library, gcc_jit_context_new_call);
>    LOAD_DLL_FN (library, gcc_jit_context_new_call_through_ptr);
> @@ -334,6 +347,9 @@ init_gccjit_functions (void)
>    LOAD_DLL_FN (library, gcc_jit_struct_set_fields);
>    LOAD_DLL_FN (library, gcc_jit_type_get_const);
>    LOAD_DLL_FN (library, gcc_jit_type_get_pointer);
> +#ifdef LIBGCCJIT_HAVE_REFLECTION
> +  LOAD_DLL_FN (library, gcc_jit_type_is_pointer);
> +#endif
>    LOAD_DLL_FN_OPT (library, gcc_jit_context_add_command_line_option);
>    LOAD_DLL_FN_OPT (library, gcc_jit_context_add_driver_option);
>  #if defined (LIBGCCJIT_HAVE_gcc_jit_global_set_initializer)
> @@ -368,6 +384,9 @@ #define gcc_jit_context_get_int_type fn_gcc_jit_context_get_int_type
>  #define gcc_jit_context_get_type fn_gcc_jit_context_get_type
>  #define gcc_jit_context_new_array_access fn_gcc_jit_context_new_array_access
>  #define gcc_jit_context_new_array_type fn_gcc_jit_context_new_array_type
> +#ifdef LIBGCCJIT_HAVE_gcc_jit_context_new_bitcast
> +  #define gcc_jit_context_new_bitcast fn_gcc_jit_context_new_bitcast
> +#endif
>  #define gcc_jit_context_new_binary_op fn_gcc_jit_context_new_binary_op
>  #define gcc_jit_context_new_call fn_gcc_jit_context_new_call
>  #define gcc_jit_context_new_call_through_ptr fn_gcc_jit_context_new_call_through_ptr
> @@ -410,6 +429,9 @@ #define gcc_jit_rvalue_dereference_field fn_gcc_jit_rvalue_dereference_field
>  #define gcc_jit_rvalue_get_type fn_gcc_jit_rvalue_get_type
>  #define gcc_jit_struct_as_type fn_gcc_jit_struct_as_type
>  #define gcc_jit_struct_set_fields fn_gcc_jit_struct_set_fields
> +#ifdef LIBGCCJIT_HAVE_REFLECTION
> +#define gcc_jit_type_is_pointer fn_gcc_jit_type_is_pointer
> +#endif
>  #define gcc_jit_type_get_const fn_gcc_jit_type_get_const
>  #define gcc_jit_type_get_pointer fn_gcc_jit_type_get_pointer
>  #if defined (LIBGCCJIT_HAVE_gcc_jit_version)
> @@ -518,7 +540,9 @@ #define F_RELOC_MAX_SIZE 1500
>  
>  static f_reloc_t freloc;
>  
> +#ifndef LIBGCCJIT_HAVE_gcc_jit_context_new_bitcast
>  #define NUM_CAST_TYPES 15
> +#endif
>  
>  typedef struct {
>    EMACS_INT len;
> @@ -593,13 +617,15 @@ #define NUM_CAST_TYPES 15
>    gcc_jit_rvalue *current_thread_ref;
>    /* Other globals.  */
>    gcc_jit_rvalue *pure_ptr;
> -  /* libgccjit has really limited support for casting therefore this union will
> -     be used for the scope.  */
> +#ifndef LIBGCCJIT_HAVE_gcc_jit_context_new_bitcast
> +  /* This version of libgccjit has really limited support for casting
> +     therefore this union will be used for the scope.  */
>    gcc_jit_type *cast_union_type;
>    gcc_jit_function *cast_functions_from_to[NUM_CAST_TYPES][NUM_CAST_TYPES];
>    gcc_jit_function *cast_ptr_to_int;
>    gcc_jit_function *cast_int_to_ptr;
>    gcc_jit_type *cast_types[NUM_CAST_TYPES];
> +#endif
>    gcc_jit_function *func; /* Current function being compiled.  */
>    bool func_has_non_local; /* From comp-func has-non-local slot.  */
>    EMACS_INT func_speed; /* From comp-func speed slot.  */
> @@ -1100,6 +1126,7 @@ emit_cond_jump (gcc_jit_rvalue *test,
>  
>  }
>  
> +#ifndef LIBGCCJIT_HAVE_gcc_jit_context_new_bitcast
>  static int
>  type_to_cast_index (gcc_jit_type * type)
>  {
> @@ -1109,6 +1136,7 @@ type_to_cast_index (gcc_jit_type * type)
>  
>    xsignal1 (Qnative_ice, build_string ("unsupported cast"));
>  }
> +#endif
>  
>  static gcc_jit_rvalue *
>  emit_coerce (gcc_jit_type *new_type, gcc_jit_rvalue *obj)
> @@ -1145,14 +1173,41 @@ emit_coerce (gcc_jit_type *new_type, gcc_jit_rvalue *obj)
>      }
>  #endif
>  
> +#ifdef LIBGCCJIT_HAVE_gcc_jit_context_new_bitcast
> +  bool old_is_ptr = gcc_jit_type_is_pointer (old_type) != NULL;
> +  bool new_is_ptr = gcc_jit_type_is_pointer (new_type) != NULL;
> +
> +  gcc_jit_rvalue *tmp = obj;
> +
> +  if (old_is_ptr != new_is_ptr)
> +    {
> +      if (old_is_ptr)
> +	{
> +	  tmp = gcc_jit_context_new_cast (comp.ctxt, NULL, tmp,
> +					  comp.void_ptr_type);
> +	  tmp = gcc_jit_context_new_bitcast (comp.ctxt, NULL, tmp,
> +					     comp.uintptr_type);
> +	}
> +      else
> +	{
> +	  tmp = gcc_jit_context_new_cast (comp.ctxt, NULL, tmp,
> +					  comp.uintptr_type);
> +	  tmp = gcc_jit_context_new_bitcast (comp.ctxt, NULL, tmp,
> +					     comp.void_ptr_type);

Could you clarify why we need this double cast in both cases here?

> +	}
> +    }
> +  return gcc_jit_context_new_cast (comp.ctxt, NULL, tmp, new_type);
> +#else /* !defined(LIBGCCJIT_HAVE_gcc_jit_context_new_bitcast) */

Nit: I'd prefer a new line before and after this #else

>    int old_index = type_to_cast_index (old_type);
>    int new_index = type_to_cast_index (new_type);
>  
>    /* Lookup the appropriate cast function in the cast matrix.  */
>    return gcc_jit_context_new_call (comp.ctxt,
> -           NULL,
> -           comp.cast_functions_from_to[old_index][new_index],
> -           1, &obj);
> +				   NULL,
> +				   comp.cast_functions_from_to
> +				   [old_index][new_index],
> +				   1, &obj);
> +#endif
>  }
>  
>  static gcc_jit_rvalue *
> @@ -3318,6 +3373,7 @@ define_thread_state_struct (void)
>      gcc_jit_type_get_pointer (gcc_jit_struct_as_type (comp.thread_state_s));
>  }
>  
> +#ifndef LIBGCCJIT_HAVE_gcc_jit_context_new_bitcast
>  static gcc_jit_function *
>  define_type_punning (const char *name,
>  		     gcc_jit_type *from, gcc_jit_field *from_field,
> @@ -3336,6 +3392,7 @@ define_type_punning (const char *name,
>  
>    DECL_BLOCK (entry_block, result);
>  
> +

Are this and the following new line added voluntarily?

>    gcc_jit_lvalue *tmp_union
>      = gcc_jit_function_new_local (result,
>                                    NULL,
> @@ -3422,6 +3479,7 @@ define_cast_functions (void)
>          { comp.unsigned_long_type, "unsigned_long", false },
>          { comp.unsigned_type, "unsigned", false },
>          { comp.void_ptr_type, "void_ptr", true } };
> +
>    gcc_jit_field *cast_union_fields[2];
>  
>    /* Define the union used for type punning.  */
> @@ -3451,6 +3509,7 @@ define_cast_functions (void)
>  					      comp.void_ptr_type,
>  					      cast_union_fields[0]);
>  
> +
>    for (int i = 0; i < NUM_CAST_TYPES; ++i)
>      comp.cast_types[i] = cast_types[i].type;
>  
> @@ -3460,6 +3519,7 @@ define_cast_functions (void)
>          comp.cast_functions_from_to[i][j] =
>            define_cast_from_to (cast_types[i], cast_types[j]);
>  }
> +#endif /* !defined(LIBGCCJIT_HAVE_gcc_jit_context_new_bitcast) */
>  
>  static void
>  define_CHECK_TYPE (void)
> @@ -4660,7 +4720,9 @@ DEFUN ("comp--init-ctxt", Fcomp__init_ctxt, Scomp__init_ctxt,
>    define_jmp_buf ();
>    define_handler_struct ();
>    define_thread_state_struct ();
> +#ifndef LIBGCCJIT_HAVE_gcc_jit_context_new_bitcast
>    define_cast_functions ();
> +#endif
>  
>    return Qt;
>  }

Which kind of tests did this patch went through?  I assumed you tried a
bootstrap could you please confirm?  Also have comp tests been tried?

Thanks

  Andrea



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] comp.c: Use the newly added bitcast API for type coercion, when available. (feature/jit-improved-type-punning)
  2022-09-27 18:18 ` Lars Ingebrigtsen
@ 2022-09-28 12:39   ` Andrea Corallo
  0 siblings, 0 replies; 8+ messages in thread
From: Andrea Corallo @ 2022-09-28 12:39 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: Vibhav Pant, emacs-devel

Lars Ingebrigtsen <larsi@gnus.org> writes:

> Vibhav Pant <vibhavp@gmail.com> writes:
>
>> * (emit_coerce): Use gcc_jit_context_new_bitcast to coerce types, when
>> available.
>
> Perhaps Andrea has some comments; added to the CCs.

Thanks Lars!  I catches all of these mails with my GNU scoring rules, I
sometimes need sometime to follow on them tho :)

  Andrea



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] comp.c: Use the newly added bitcast API for type coercion, when available. (feature/jit-improved-type-punning)
  2022-09-28 12:37 ` Andrea Corallo
@ 2022-10-02 17:27   ` Vibhav Pant
  2022-10-04 18:39     ` Andrea Corallo
  0 siblings, 1 reply; 8+ messages in thread
From: Vibhav Pant @ 2022-10-02 17:27 UTC (permalink / raw)
  To: Andrea Corallo; +Cc: emacs-devel


[-- Attachment #1.1: Type: text/plain, Size: 1082 bytes --]

On Wed, 2022-09-28 at 12:37 +0000, Andrea Corallo wrote:
> thanks for the patch, please find some comments below.
Hi Andrea,

Thanks for the feedback.

> 
> Could you clarify why we need this double cast in both cases here?
> 

gcc_jit_context_new_bitcast requires that the types being converted
between have the same layout and as such, doesn't allow converting
between an arbitrarily sized integer/boolean and a pointer. Casting it
to a uintptr/void* is still necessary, to ensure that it can be bitcast
into a void*/uintptr respectively.

> > 
> 
> Are this and the following new line added voluntarily?
> 

Oops, fixed.

> 
> 
> Which kind of tests did this patch went through?  I assumed you tried
> a
> bootstrap could you please confirm?  Also have comp tests been tried?
> 

I ran the regular test suite, the code bootstraps succesfully, and I
have been using it as a daily driver for more than a week. I've
attached the results of comp tests with the expensive selector enabled
below.

Thanks,
Vibhav


> Thanks
> 
>   Andrea


[-- Attachment #1.2: Type: text/x-log, Size: 11563 bytes --]

Compiling tests...

In comp-test-40187-2-f:
comp-test-funcs.el:286:8: Warning: function `comp-test-40187-2-f' defined multiple times in this file

In comp-test-46824-1-f:
comp-test-funcs.el:502:16: Warning: value returned from (format %S (error-message-string err)) is unused
comp-test-funcs.el:502:16: Warning: value returned from (format %S (error-message-string err)) is unused
comp-test-funcs.el:502:16: Warning: value returned from (format %S (error-message-string err)) is unused

In comp-test-silly-frame2:
comp-test-funcs.el:647:10: Warning: reference to free variable `c'
Loading /home/vibhavp/src/emacs/native-lisp/29.0.50-dbf5140f/comp-test-funcs-1959403c-f58ebfa6.eln (native compiled elisp)...
Loading /home/vibhavp/src/emacs/native-lisp/29.0.50-dbf5140f/comp-test-funcs-dyn-af61ca32-37b66b75.eln (native compiled elisp)...
Running 167 tests (2022-10-02 22:49:47+0530, selector `(not (tag :unstable))')
   passed    1/167  comp-tests-45576-1 (0.000135 sec)
   passed    2/167  comp-tests-45635-1 (0.000097 sec)
   passed    3/167  comp-tests-46670-1 (0.000091 sec)
   passed    4/167  comp-tests-46824-1 (0.000087 sec)
   passed    5/167  comp-tests-48029-1 (0.000096 sec)
   passed    6/167  comp-tests-> (0.000086 sec)
   passed    7/167  comp-tests-add1 (0.000094 sec)
   passed    8/167  comp-tests-and (0.000087 sec)
   passed    9/167  comp-tests-and-3 (0.000102 sec)
   passed   10/167  comp-tests-apply (0.000091 sec)
   passed   11/167  comp-tests-aref-aset (0.000080 sec)
   passed   12/167  comp-tests-arith-comp (0.000121 sec)
   passed   13/167  comp-tests-assume-double-neg (0.000081 sec)
   passed   14/167  comp-tests-assume-in-loop-1 (0.000081 sec)
   passed   15/167  comp-tests-bobp-and-eobp (0.000118 sec)
Loading /home/vibhavp/src/emacs/lisp/emacs-lisp/comp.elc...
Compiling stage1...
Done in 127 secs
Loading /home/vibhavp/src/emacs/native-lisp/29.0.50-dbf5140f/emacs-test-2zFsGd-comp-stage1-a71fb8cb-8ba0ac7c.eln (native compiled elisp)...
Compiling stage2...
Done in 152 secs
Comparing /home/vibhavp/src/emacs/native-lisp/29.0.50-dbf5140f/emacs-test-2zFsGd-comp-stage1-a71fb8cb-8ba0ac7c.eln /home/vibhavp/src/emacs/native-lisp/29.0.50-dbf5140f/emacs-test-621qtZ-comp-stage2-6d8e140c-8ba0ac7c.eln
   passed   16/167  comp-tests-bootstrap (280.298308 sec)
   passed   17/167  comp-tests-bubble-sort (0.008626 sec)
   passed   18/167  comp-tests-buffer (0.000101 sec)
   passed   19/167  comp-tests-bug-40187 (0.000090 sec)
   passed   20/167  comp-tests-bug-42360 (0.000089 sec)
   passed   21/167  comp-tests-bug-44968 (0.000188 sec)
   passed   22/167  comp-tests-bug-45342 (0.000083 sec)
   passed   23/167  comp-tests-bug-45376-1 (0.000167 sec)
   passed   24/167  comp-tests-bug-45376-2 (0.000082 sec)
   passed   25/167  comp-tests-car-cdr (0.000111 sec)
   passed   26/167  comp-tests-car-cdr-safe (0.000102 sec)
   passed   27/167  comp-tests-catch (0.000087 sec)
   passed   28/167  comp-tests-cl-macro-exp (0.000082 sec)
   passed   29/167  comp-tests-cl-uninterned-arg-parse-f (0.000081 sec)
   passed   30/167  comp-tests-comp-test-47868-1 (0.000107 sec)
   passed   31/167  comp-tests-comp-test-defsubst (0.000082 sec)
   passed   32/167  comp-tests-comp-tests-cons-car-cdr (0.000086 sec)
   passed   33/167  comp-tests-compile-forms (0.570224 sec)
   passed   34/167  comp-tests-concat (0.000155 sec)
   passed   35/167  comp-tests-concatN (0.000143 sec)
   passed   36/167  comp-tests-cond-rw-1 (0.000137 sec)
   passed   37/167  comp-tests-conditionals (0.000096 sec)
   passed   38/167  comp-tests-consp (0.000092 sec)
   passed   39/167  comp-tests-copy-insn (0.000111 sec)
   passed   40/167  comp-tests-doc (0.000490 sec)
   passed   41/167  comp-tests-dynamic-arity (0.000098 sec)
   passed   42/167  comp-tests-dynamic-ffuncall (0.000128 sec)
   passed   43/167  comp-tests-dynamic-help-arglist (0.000089 sec)
   passed   44/167  comp-tests-eq (0.000092 sec)
   passed   45/167  comp-tests-ffuncall (0.000145 sec)
   passed   46/167  comp-tests-fixnum (0.000126 sec)
   passed   47/167  comp-tests-free-fun (0.275534 sec)
   passed   48/167  comp-tests-free-fun-silly-name (0.314101 sec)
   passed   49/167  comp-tests-func-call-removal (0.000179 sec)
   passed   50/167  comp-tests-fw-prop-1 (0.281738 sec)
   passed   51/167  comp-tests-gc (0.053151 sec)
   passed   52/167  comp-tests-if (0.000115 sec)
   passed   53/167  comp-tests-integerp (0.000109 sec)
   passed   54/167  comp-tests-interactive-form (0.000114 sec)
   passed   55/167  comp-tests-jump-table (0.000110 sec)
   passed   56/167  comp-tests-lambda-return (0.000096 sec)
   passed   57/167  comp-tests-length (0.000091 sec)
   passed   58/167  comp-tests-list (0.000144 sec)
   passed   59/167  comp-tests-listN (0.000093 sec)
   passed   60/167  comp-tests-listp (0.000101 sec)
   passed   61/167  comp-tests-macro (0.000091 sec)
   passed   62/167  comp-tests-memq (0.000095 sec)
   passed   63/167  comp-tests-negate (0.000107 sec)
   passed   64/167  comp-tests-non-locals (0.000130 sec)
   passed   65/167  comp-tests-not (0.000100 sec)
   passed   66/167  comp-tests-not-cons-1 (0.000235 sec)
   passed   67/167  comp-tests-num-inline (0.000123 sec)
   passed   68/167  comp-tests-numberp (0.000101 sec)
   passed   69/167  comp-tests-opt (0.000108 sec)
   passed   70/167  comp-tests-opt-rest (0.000169 sec)
   passed   71/167  comp-tests-or (0.000250 sec)
   passed   72/167  comp-tests-primitive-advice (0.258131 sec)
   passed   73/167  comp-tests-primitive-redefine (0.303571 sec)
   passed   74/167  comp-tests-primitive-redefine-compile-44221 (0.600463 sec)
   passed   75/167  comp-tests-provide (0.000098 sec)
Loading /tmp/test-nativecomp-cache-By7pRC/29.0.50-dbf5140f/comp-test-pure-5020ed44-446ae10b.eln (native compiled elisp)...
   passed   76/167  comp-tests-pure (0.290764 sec)
   passed   77/167  comp-tests-recursive (0.000177 sec)
   passed   78/167  comp-tests-ret-type-spec-1 (0.272534 sec)
   passed   79/167  comp-tests-ret-type-spec-10 (0.280535 sec)
   passed   80/167  comp-tests-ret-type-spec-11 (0.291971 sec)
   passed   81/167  comp-tests-ret-type-spec-12 (0.277817 sec)
   passed   82/167  comp-tests-ret-type-spec-13 (0.321801 sec)
   passed   83/167  comp-tests-ret-type-spec-14 (0.301459 sec)
   passed   84/167  comp-tests-ret-type-spec-15 (0.291450 sec)
   passed   85/167  comp-tests-ret-type-spec-16 (0.277157 sec)
 Warning: Unused lexical variable `x'
   passed   86/167  comp-tests-ret-type-spec-17 (0.276892 sec)
   passed   87/167  comp-tests-ret-type-spec-18 (0.281342 sec)
   passed   88/167  comp-tests-ret-type-spec-19 (0.287684 sec)
   passed   89/167  comp-tests-ret-type-spec-2 (0.281564 sec)
   passed   90/167  comp-tests-ret-type-spec-20 (0.303452 sec)
   passed   91/167  comp-tests-ret-type-spec-21 (0.279921 sec)
   passed   92/167  comp-tests-ret-type-spec-22 (2.759134 sec)
   passed   93/167  comp-tests-ret-type-spec-23 (0.289070 sec)
   passed   94/167  comp-tests-ret-type-spec-24 (0.276128 sec)
   passed   95/167  comp-tests-ret-type-spec-25 (0.296596 sec)
   passed   96/167  comp-tests-ret-type-spec-26 (0.303224 sec)
   passed   97/167  comp-tests-ret-type-spec-27 (0.287032 sec)
   passed   98/167  comp-tests-ret-type-spec-28 (0.308105 sec)
   passed   99/167  comp-tests-ret-type-spec-29 (0.283869 sec)
   passed  100/167  comp-tests-ret-type-spec-3 (0.277329 sec)
   passed  101/167  comp-tests-ret-type-spec-30 (0.280996 sec)
   passed  102/167  comp-tests-ret-type-spec-31 (0.318439 sec)
   passed  103/167  comp-tests-ret-type-spec-32 (0.288356 sec)
   passed  104/167  comp-tests-ret-type-spec-33 (0.287069 sec)
   passed  105/167  comp-tests-ret-type-spec-34 (0.302556 sec)
   passed  106/167  comp-tests-ret-type-spec-35 (0.286318 sec)
   passed  107/167  comp-tests-ret-type-spec-36 (0.282842 sec)
   passed  108/167  comp-tests-ret-type-spec-37 (0.283415 sec)
   passed  109/167  comp-tests-ret-type-spec-38 (0.317173 sec)
   passed  110/167  comp-tests-ret-type-spec-39 (0.284419 sec)
   passed  111/167  comp-tests-ret-type-spec-4 (0.274697 sec)
   passed  112/167  comp-tests-ret-type-spec-40 (0.321292 sec)
   passed  113/167  comp-tests-ret-type-spec-41 (0.311932 sec)
   passed  114/167  comp-tests-ret-type-spec-42 (0.290013 sec)
   passed  115/167  comp-tests-ret-type-spec-43 (0.280319 sec)
   passed  116/167  comp-tests-ret-type-spec-44 (0.324355 sec)
   passed  117/167  comp-tests-ret-type-spec-45 (0.345043 sec)
   passed  118/167  comp-tests-ret-type-spec-46 (0.439334 sec)
   passed  119/167  comp-tests-ret-type-spec-47 (0.318829 sec)
   passed  120/167  comp-tests-ret-type-spec-48 (0.283179 sec)
   passed  121/167  comp-tests-ret-type-spec-49 (0.256813 sec)
   passed  122/167  comp-tests-ret-type-spec-5 (0.312993 sec)
   passed  123/167  comp-tests-ret-type-spec-50 (0.282475 sec)
   passed  124/167  comp-tests-ret-type-spec-51 (0.284644 sec)
   passed  125/167  comp-tests-ret-type-spec-52 (0.309145 sec)
   passed  126/167  comp-tests-ret-type-spec-53 (0.285351 sec)
   passed  127/167  comp-tests-ret-type-spec-54 (0.306183 sec)
   passed  128/167  comp-tests-ret-type-spec-55 (0.291400 sec)
   passed  129/167  comp-tests-ret-type-spec-56 (0.312149 sec)
   passed  130/167  comp-tests-ret-type-spec-57 (0.289313 sec)
   passed  131/167  comp-tests-ret-type-spec-58 (0.307401 sec)
   passed  132/167  comp-tests-ret-type-spec-59 (0.292955 sec)
   passed  133/167  comp-tests-ret-type-spec-6 (0.280503 sec)
   passed  134/167  comp-tests-ret-type-spec-60 (0.307431 sec)
   passed  135/167  comp-tests-ret-type-spec-61 (0.282792 sec)
   passed  136/167  comp-tests-ret-type-spec-62 (0.283371 sec)
   passed  137/167  comp-tests-ret-type-spec-63 (0.291698 sec)
   passed  138/167  comp-tests-ret-type-spec-64 (0.278352 sec)
   passed  139/167  comp-tests-ret-type-spec-65 (0.303208 sec)
   passed  140/167  comp-tests-ret-type-spec-66 (0.290234 sec)
   passed  141/167  comp-tests-ret-type-spec-67 (0.275930 sec)
   passed  142/167  comp-tests-ret-type-spec-68 (0.289036 sec)
   passed  143/167  comp-tests-ret-type-spec-69 (0.285698 sec)
   passed  144/167  comp-tests-ret-type-spec-7 (0.316235 sec)
   passed  145/167  comp-tests-ret-type-spec-70 (0.286930 sec)
   passed  146/167  comp-tests-ret-type-spec-71 (0.285470 sec)
   passed  147/167  comp-tests-ret-type-spec-72 (0.279710 sec)
   passed  148/167  comp-tests-ret-type-spec-73 (0.305579 sec)
   passed  149/167  comp-tests-ret-type-spec-74 (0.296679 sec)
   passed  150/167  comp-tests-ret-type-spec-8 (0.280416 sec)
   passed  151/167  comp-tests-ret-type-spec-9 (0.305530 sec)
   passed  152/167  comp-tests-save-excursion (0.000221 sec)
   passed  153/167  comp-tests-setcarcdr (0.000204 sec)
   passed  154/167  comp-tests-signal (0.000151 sec)
   passed  155/167  comp-tests-speed--1 (0.000121 sec)
   passed  156/167  comp-tests-stack (0.000114 sec)
   passed  157/167  comp-tests-string-trim (0.000100 sec)
   passed  158/167  comp-tests-stringp (0.000102 sec)
   passed  159/167  comp-tests-sub1 (0.000142 sec)
   passed  160/167  comp-tests-symbol-value (0.000094 sec)
   passed  161/167  comp-tests-symbolp (0.000103 sec)
   passed  162/167  comp-tests-tco (0.319600 sec)
   passed  163/167  comp-tests-trampoline-removal (0.000154 sec)
   passed  164/167  comp-tests-type-hints (0.000151 sec)
   passed  165/167  comp-tests-unwind-protect (0.000153 sec)
   passed  166/167  comp-tests-varref (0.000093 sec)
   passed  167/167  comp-tests-varset (0.000098 sec)

Ran 167 tests, 167 results as expected, 0 unexpected (2022-10-02 22:54:55+0530, 307.936575 sec)


[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] comp.c: Use the newly added bitcast API for type coercion, when available. (feature/jit-improved-type-punning)
  2022-10-02 17:27   ` Vibhav Pant
@ 2022-10-04 18:39     ` Andrea Corallo
  2022-10-05  9:21       ` Vibhav Pant
  0 siblings, 1 reply; 8+ messages in thread
From: Andrea Corallo @ 2022-10-04 18:39 UTC (permalink / raw)
  To: Vibhav Pant; +Cc: emacs-devel

Vibhav Pant <vibhavp@gmail.com> writes:

> On Wed, 2022-09-28 at 12:37 +0000, Andrea Corallo wrote:
>> thanks for the patch, please find some comments below.
> Hi Andrea,
>
> Thanks for the feedback.
>
>> 
>> Could you clarify why we need this double cast in both cases here?
>> 
>
> gcc_jit_context_new_bitcast requires that the types being converted
> between have the same layout and as such, doesn't allow converting
> between an arbitrarily sized integer/boolean and a pointer. Casting it
> to a uintptr/void* is still necessary, to ensure that it can be bitcast
> into a void*/uintptr respectively.

I see thanks, I'd like to have a comment recording this in the code.

>> > 
>> 
>> Are this and the following new line added voluntarily?
>> 
>
> Oops, fixed.

The patch is okay for me with the suggestions implemented.  I assume you
have write access, if is not the case just post the patch here and I'll
install it.

Thanks for your work.

Bests

  Andrea



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] comp.c: Use the newly added bitcast API for type coercion, when available. (feature/jit-improved-type-punning)
  2022-10-04 18:39     ` Andrea Corallo
@ 2022-10-05  9:21       ` Vibhav Pant
  2022-10-05 10:42         ` Andrea Corallo
  0 siblings, 1 reply; 8+ messages in thread
From: Vibhav Pant @ 2022-10-05  9:21 UTC (permalink / raw)
  To: Andrea Corallo; +Cc: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 1196 bytes --]

On Tue, 2022-10-04 at 18:39 +0000, Andrea Corallo wrote:
> Vibhav Pant <vibhavp@gmail.com> writes:
> 
> > On Wed, 2022-09-28 at 12:37 +0000, Andrea Corallo wrote:
> > > thanks for the patch, please find some comments below.
> > Hi Andrea,
> > 
> > Thanks for the feedback.
> > 
> > > 
> > > Could you clarify why we need this double cast in both cases
> > > here?
> > > 
> > 
> > gcc_jit_context_new_bitcast requires that the types being converted
> > between have the same layout and as such, doesn't allow converting
> > between an arbitrarily sized integer/boolean and a pointer. Casting
> > it
> > to a uintptr/void* is still necessary, to ensure that it can be
> > bitcast
> > into a void*/uintptr respectively.
> 
> I see thanks, I'd like to have a comment recording this in the code.
> 
Good idea, done.

> > > 
> The patch is okay for me with the suggestions implemented.  I assume
> you
> have write access, if is not the case just post the patch here and
> I'll
> install it.
> 
Sure, I merged the branch last night. Thanks for the help.

Best,
Vibhav

-- 
Vibhav Pant
vibhavp@gmail.com
GPG: 7ED1 D48C 513C A024 BE3A  785F E3FB 28CB 6AB5 9598

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] comp.c: Use the newly added bitcast API for type coercion, when available. (feature/jit-improved-type-punning)
  2022-10-05  9:21       ` Vibhav Pant
@ 2022-10-05 10:42         ` Andrea Corallo
  0 siblings, 0 replies; 8+ messages in thread
From: Andrea Corallo @ 2022-10-05 10:42 UTC (permalink / raw)
  To: Vibhav Pant; +Cc: emacs-devel

Vibhav Pant <vibhavp@gmail.com> writes:

> On Tue, 2022-10-04 at 18:39 +0000, Andrea Corallo wrote:
>> Vibhav Pant <vibhavp@gmail.com> writes:
>> 
>> > On Wed, 2022-09-28 at 12:37 +0000, Andrea Corallo wrote:
>> > > thanks for the patch, please find some comments below.
>> > Hi Andrea,
>> > 
>> > Thanks for the feedback.
>> > 
>> > > 
>> > > Could you clarify why we need this double cast in both cases
>> > > here?
>> > > 
>> > 
>> > gcc_jit_context_new_bitcast requires that the types being converted
>> > between have the same layout and as such, doesn't allow converting
>> > between an arbitrarily sized integer/boolean and a pointer. Casting
>> > it
>> > to a uintptr/void* is still necessary, to ensure that it can be
>> > bitcast
>> > into a void*/uintptr respectively.
>> 
>> I see thanks, I'd like to have a comment recording this in the code.
>> 
> Good idea, done.
>
>> > > 
>> The patch is okay for me with the suggestions implemented.  I assume
>> you
>> have write access, if is not the case just post the patch here and
>> I'll
>> install it.
>> 
> Sure, I merged the branch last night. Thanks for the help.

Thanks, next time please squash the requested changes in the original
change before pushing it.

Best Regards

  Andrea



^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2022-10-05 10:42 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-27 18:15 [PATCH] comp.c: Use the newly added bitcast API for type coercion, when available. (feature/jit-improved-type-punning) Vibhav Pant
2022-09-27 18:18 ` Lars Ingebrigtsen
2022-09-28 12:39   ` Andrea Corallo
2022-09-28 12:37 ` Andrea Corallo
2022-10-02 17:27   ` Vibhav Pant
2022-10-04 18:39     ` Andrea Corallo
2022-10-05  9:21       ` Vibhav Pant
2022-10-05 10:42         ` Andrea Corallo

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).