public inbox for jit@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] libgccjit: Make is_int return false on vector types
@ 2023-12-07 22:32 Antoni Boucher
  2023-12-08  1:07 ` David Malcolm
  0 siblings, 1 reply; 4+ messages in thread
From: Antoni Boucher @ 2023-12-07 22:32 UTC (permalink / raw)
  To: jit, gcc-patches; +Cc: David Malcolm

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

Hi.
This patch changes the function is_int to return false on vector types.
Thanks for the review.

[-- Attachment #2: 0001-libgccjit-Make-is_int-return-false-on-vector-types.patch --]
[-- Type: text/x-patch, Size: 4110 bytes --]

From 60ebfb998bd349ca2f05b115de5452378027e4de Mon Sep 17 00:00:00 2001
From: Antoni Boucher <bouanto@zoho.com>
Date: Thu, 26 Oct 2023 19:17:55 -0400
Subject: [PATCH] libgccjit: Make is_int return false on vector types

gcc/jit/ChangeLog:

	* jit-recording.h (is_numeric_vector, vector_type::new_int): New
	functions.
	* libgccjit.cc (gcc_jit_context_new_unary_op,
	gcc_jit_context_new_binary_op): add checks for
	is_numeric_vector.

gcc/testsuite/ChangeLog:

	* jit.dg/test-reflection.c: Add check to make sure
	gcc_jit_type_is_integral returns 0 on a vector type.
---
 gcc/jit/jit-recording.h                | 12 +++++++++++-
 gcc/jit/libgccjit.cc                   |  4 ++--
 gcc/testsuite/jit.dg/test-reflection.c |  1 +
 3 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/gcc/jit/jit-recording.h b/gcc/jit/jit-recording.h
index 4a8082991fb..ffadbe968af 100644
--- a/gcc/jit/jit-recording.h
+++ b/gcc/jit/jit-recording.h
@@ -567,6 +567,7 @@ public:
   virtual bool is_int () const = 0;
   virtual bool is_float () const = 0;
   virtual bool is_bool () const = 0;
+  virtual bool is_numeric_vector () const { return false; }
   virtual type *is_pointer () = 0;
   virtual type *is_volatile () { return NULL; }
   virtual type *is_restrict () { return NULL; }
@@ -701,9 +702,10 @@ public:
 
   size_t get_size () final override { return m_other_type->get_size (); };
 
-  bool is_int () const final override { return m_other_type->is_int (); }
+  bool is_int () const override { return m_other_type->is_int (); }
   bool is_float () const final override { return m_other_type->is_float (); }
   bool is_bool () const final override { return m_other_type->is_bool (); }
+  bool is_numeric_vector () const override { return m_other_type->is_numeric_vector (); }
   type *is_pointer () final override { return m_other_type->is_pointer (); }
   type *is_array () final override { return m_other_type->is_array (); }
   struct_ *is_struct () final override { return m_other_type->is_struct (); }
@@ -826,6 +828,14 @@ public:
   : decorated_type (other_type),
     m_num_units (num_units) {}
 
+  bool is_int () const final override {
+    return false;
+  }
+
+  bool is_numeric_vector () const final override {
+    return true;
+  }
+
   size_t get_num_units () const { return m_num_units; }
 
   vector_type *dyn_cast_vector_type () final override { return this; }
diff --git a/gcc/jit/libgccjit.cc b/gcc/jit/libgccjit.cc
index 0451b4df7f9..852f4103839 100644
--- a/gcc/jit/libgccjit.cc
+++ b/gcc/jit/libgccjit.cc
@@ -2114,7 +2114,7 @@ gcc_jit_context_new_unary_op (gcc_jit_context *ctxt,
     op);
   RETURN_NULL_IF_FAIL (result_type, ctxt, loc, "NULL result_type");
   RETURN_NULL_IF_FAIL_PRINTF3 (
-    result_type->is_numeric (), ctxt, loc,
+    result_type->is_numeric () || result_type->is_numeric_vector (), ctxt, loc,
     "gcc_jit_unary_op %s with operand %s "
     "has non-numeric result_type: %s",
     gcc::jit::unary_op_reproducer_strings[op],
@@ -2171,7 +2171,7 @@ gcc_jit_context_new_binary_op (gcc_jit_context *ctxt,
     b->get_debug_string (),
     b->get_type ()->get_debug_string ());
   RETURN_NULL_IF_FAIL_PRINTF4 (
-    result_type->is_numeric (), ctxt, loc,
+    result_type->is_numeric () || result_type->is_numeric_vector (), ctxt, loc,
     "gcc_jit_binary_op %s with operands a: %s b: %s "
     "has non-numeric result_type: %s",
     gcc::jit::binary_op_reproducer_strings[op],
diff --git a/gcc/testsuite/jit.dg/test-reflection.c b/gcc/testsuite/jit.dg/test-reflection.c
index 112a2455c07..afa76ff81f6 100644
--- a/gcc/testsuite/jit.dg/test-reflection.c
+++ b/gcc/testsuite/jit.dg/test-reflection.c
@@ -59,6 +59,7 @@ verify_code (gcc_jit_context *ctxt, gcc_jit_result *result)
   CHECK (vec_type != double_type);
   CHECK_VALUE (gcc_jit_vector_type_get_element_type(vector_type), double_type);
   CHECK_VALUE (gcc_jit_vector_type_get_num_units(vector_type), 4);
+  CHECK (!gcc_jit_type_is_integral(vec_type));
 
   CHECK (!gcc_jit_type_is_pointer(double_type));
   CHECK_VALUE (gcc_jit_type_is_pointer(gcc_jit_type_get_pointer(double_type)), double_type);
-- 
2.43.0


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

* Re: [PATCH] libgccjit: Make is_int return false on vector types
  2023-12-07 22:32 [PATCH] libgccjit: Make is_int return false on vector types Antoni Boucher
@ 2023-12-08  1:07 ` David Malcolm
  2023-12-08  1:09   ` Antoni Boucher
  0 siblings, 1 reply; 4+ messages in thread
From: David Malcolm @ 2023-12-08  1:07 UTC (permalink / raw)
  To: Antoni Boucher, jit, gcc-patches

On Thu, 2023-12-07 at 17:32 -0500, Antoni Boucher wrote:
> Hi.
> This patch changes the function is_int to return false on vector
> types.
> Thanks for the review.

Thanks; looks good to me

Dave


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

* Re: [PATCH] libgccjit: Make is_int return false on vector types
  2023-12-08  1:07 ` David Malcolm
@ 2023-12-08  1:09   ` Antoni Boucher
  2023-12-08 12:14     ` David Malcolm
  0 siblings, 1 reply; 4+ messages in thread
From: Antoni Boucher @ 2023-12-08  1:09 UTC (permalink / raw)
  To: David Malcolm, jit, gcc-patches

Can I merge this on master even though we're not in phase 1 anymore?

On Thu, 2023-12-07 at 20:07 -0500, David Malcolm wrote:
> On Thu, 2023-12-07 at 17:32 -0500, Antoni Boucher wrote:
> > Hi.
> > This patch changes the function is_int to return false on vector
> > types.
> > Thanks for the review.
> 
> Thanks; looks good to me
> 
> Dave
> 


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

* Re: [PATCH] libgccjit: Make is_int return false on vector types
  2023-12-08  1:09   ` Antoni Boucher
@ 2023-12-08 12:14     ` David Malcolm
  0 siblings, 0 replies; 4+ messages in thread
From: David Malcolm @ 2023-12-08 12:14 UTC (permalink / raw)
  To: Antoni Boucher, jit, gcc-patches

On Thu, 2023-12-07 at 20:09 -0500, Antoni Boucher wrote:
> Can I merge this on master even though we're not in phase 1 anymore?

Yes, assuming it passes the regression testsuite.

> 
> On Thu, 2023-12-07 at 20:07 -0500, David Malcolm wrote:
> > On Thu, 2023-12-07 at 17:32 -0500, Antoni Boucher wrote:
> > > Hi.
> > > This patch changes the function is_int to return false on vector
> > > types.
> > > Thanks for the review.
> > 
> > Thanks; looks good to me
> > 
> > Dave
> > 
> 


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

end of thread, other threads:[~2023-12-08 12:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-07 22:32 [PATCH] libgccjit: Make is_int return false on vector types Antoni Boucher
2023-12-08  1:07 ` David Malcolm
2023-12-08  1:09   ` Antoni Boucher
2023-12-08 12:14     ` David Malcolm

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).