From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7855) id B88CC3858C98; Fri, 19 Jan 2024 20:54:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B88CC3858C98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1705697696; bh=tHVRIFTRN0pqS0/DbuCDjnw4lcXamsFCPImn4i3+eic=; h=From:To:Subject:Date:From; b=N3Isb6O3iVRkRdXHs+fX7dooNDsrPs1YNbbfP20s5B82yjAjjQk4I+LcIX2A8A9St PjWVZubTprdBFBbRTj1OmWPk343YikrGpAgcHVUhInDRckFJxBC9+w66YLgnMJKw5M wNYI/eaQ7x416t1+Hom8XccQ398GRc8P3FofKsrM= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Antoni Boucher To: gcc-cvs@gcc.gnu.org Subject: [gcc r14-8296] libgccjit: Make is_int return false on vector types X-Act-Checkin: gcc X-Git-Author: Antoni Boucher X-Git-Refname: refs/heads/master X-Git-Oldrev: 94b2e6cb1cc4feb122bf77f19a657c97bffa9b42 X-Git-Newrev: 63736351ec4d1e49261a483ea55e0f5ecfc591c8 Message-Id: <20240119205456.B88CC3858C98@sourceware.org> Date: Fri, 19 Jan 2024 20:54:56 +0000 (GMT) List-Id: https://gcc.gnu.org/g:63736351ec4d1e49261a483ea55e0f5ecfc591c8 commit r14-8296-g63736351ec4d1e49261a483ea55e0f5ecfc591c8 Author: Antoni Boucher Date: Thu Oct 26 19:17:55 2023 -0400 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. Diff: --- gcc/jit/jit-recording.h | 14 +++++++++++++- gcc/jit/libgccjit.cc | 4 ++-- gcc/testsuite/jit.dg/test-reflection.c | 1 + 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/gcc/jit/jit-recording.h b/gcc/jit/jit-recording.h index cd2e0adbe30..ab5ba6c7fbe 100644 --- a/gcc/jit/jit-recording.h +++ b/gcc/jit/jit-recording.h @@ -571,6 +571,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; } @@ -705,9 +706,12 @@ 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 (); } @@ -830,6 +834,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 9616f3802b8..bf0150f6047 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);