From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7855) id 3118F3857B94; Fri, 10 Jun 2022 02:02:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3118F3857B94 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 r13-1036] libgccjit: Support getting the size of a float [PR105829] X-Act-Checkin: gcc X-Git-Author: Antoni Boucher X-Git-Refname: refs/heads/master X-Git-Oldrev: e3bba42fb5d64d2b49a9cd3511f8f57e36d46dfe X-Git-Newrev: 5940b4e59f8e198dbf7e8b733561ef72a9ba2cbc Message-Id: <20220610020223.3118F3857B94@sourceware.org> Date: Fri, 10 Jun 2022 02:02:23 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 10 Jun 2022 02:02:23 -0000 https://gcc.gnu.org/g:5940b4e59f8e198dbf7e8b733561ef72a9ba2cbc commit r13-1036-g5940b4e59f8e198dbf7e8b733561ef72a9ba2cbc Author: Antoni Boucher Date: Thu Jun 9 21:37:23 2022 -0400 libgccjit: Support getting the size of a float [PR105829] 2022-06-09 Antoni Boucher gcc/jit/ PR jit/105829 * libgccjit.cc: Add support for floating-point types in gcc_jit_type_get_size. gcc/testsuite/ PR jit/105829 * jit.dg/test-types.c: Add tests for gcc_jit_type_get_size. Diff: --- gcc/jit/libgccjit.cc | 4 ++-- gcc/testsuite/jit.dg/test-types.c | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/gcc/jit/libgccjit.cc b/gcc/jit/libgccjit.cc index cc6486c9cad..0e76097b4ba 100644 --- a/gcc/jit/libgccjit.cc +++ b/gcc/jit/libgccjit.cc @@ -545,8 +545,8 @@ gcc_jit_type_get_size (gcc_jit_type *type) { RETURN_VAL_IF_FAIL (type, -1, NULL, NULL, "NULL type"); RETURN_VAL_IF_FAIL - (type->is_int (), -1, NULL, NULL, - "only getting the size of an integer type is supported for now"); + (type->is_int () || type->is_float (), -1, NULL, NULL, + "only getting the size of integer or floating-point types is supported for now"); return type->get_size (); } diff --git a/gcc/testsuite/jit.dg/test-types.c b/gcc/testsuite/jit.dg/test-types.c index 6836597d14e..a01944e35fa 100644 --- a/gcc/testsuite/jit.dg/test-types.c +++ b/gcc/testsuite/jit.dg/test-types.c @@ -489,4 +489,7 @@ verify_code (gcc_jit_context *ctxt, gcc_jit_result *result) CHECK (gcc_jit_compatible_types ( gcc_jit_context_get_type (ctxt, GCC_JIT_TYPE_LONG), gcc_jit_context_get_type (ctxt, GCC_JIT_TYPE_INT64_T))); + + CHECK_VALUE (gcc_jit_type_get_size (gcc_jit_context_get_type (ctxt, GCC_JIT_TYPE_FLOAT)), sizeof (float)); + CHECK_VALUE (gcc_jit_type_get_size (gcc_jit_context_get_type (ctxt, GCC_JIT_TYPE_DOUBLE)), sizeof (double)); }