* [PATCH] libgccjit: Support getting the size of a float
@ 2022-06-03 3:09 Antoni Boucher
2022-06-06 22:18 ` David Malcolm
0 siblings, 1 reply; 2+ messages in thread
From: Antoni Boucher @ 2022-06-03 3:09 UTC (permalink / raw)
To: gcc-patches, jit
[-- Attachment #1: Type: text/plain, Size: 120 bytes --]
Hi.
The attached patch fix bug 105829:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105829
Thanks for the review.
[-- Attachment #2: 0001-libgccjit-Support-getting-the-size-of-a-float.patch --]
[-- Type: text/x-patch, Size: 1859 bytes --]
From 5d75fd342cdcea94a785312252be0c0046afdf43 Mon Sep 17 00:00:00 2001
From: Antoni Boucher <bouanto@zoho.com>
Date: Wed, 4 May 2022 21:42:44 -0400
Subject: [PATCH] libgccjit: Support getting the size of a float
2022-06-02 Antoni Boucher <bouanto@zoho.com>
gcc/jit/
PR target/105829
* libgccjit.cc: Add support for floating-point types in
gcc_jit_type_get_size.
gcc/testsuite/
PR target/105829
* jit.dg/test-types.c: Add tests for gcc_jit_type_get_size.
---
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..12e7679988b 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 an int or float type 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..53bdeafed61 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)), 4);
+ CHECK_VALUE (gcc_jit_type_get_size (gcc_jit_context_get_type (ctxt, GCC_JIT_TYPE_DOUBLE)), 8);
}
--
2.26.2.7.g19db9cfb68.dirty
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] libgccjit: Support getting the size of a float
2022-06-03 3:09 [PATCH] libgccjit: Support getting the size of a float Antoni Boucher
@ 2022-06-06 22:18 ` David Malcolm
0 siblings, 0 replies; 2+ messages in thread
From: David Malcolm @ 2022-06-06 22:18 UTC (permalink / raw)
To: Antoni Boucher, gcc-patches, jit
On Thu, 2022-06-02 at 23:09 -0400, Antoni Boucher via Gcc-patches
wrote:
> Hi.
> The attached patch fix bug 105829:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105829
>
> Thanks for the review.
> diff --git a/gcc/jit/libgccjit.cc b/gcc/jit/libgccjit.cc
> index cc6486c9cad..12e7679988b 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 an int or float type is supported for now");
Reword to:
"only getting the size of integer or floating-point types is supported for now"
to avoid using the words "int" and "float" to refer to those kinds of
types, and to follow:
https://gcc.gnu.org/codingconventions.html#Spelling
> return type->get_size ();
> }
>
> diff --git a/gcc/testsuite/jit.dg/test-types.c b/gcc/testsuite/jit.dg/test-types.c
> index 6836597d14e..53bdeafed61 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)), 4);
> + CHECK_VALUE (gcc_jit_type_get_size (gcc_jit_context_get_type (ctxt, GCC_JIT_TYPE_DOUBLE)), 8);
I'm not sure these sizes are 4 and 8 on every target we support. I got
curious and found e.g. gcc/config/rl78/rl78.h has:
#define FLOAT_TYPE_SIZE 32
#define DOUBLE_TYPE_SIZE 32 /*64*/
Maybe use sizeof (float) and sizeof (double) in the assertion, rather
than hardcoding the values? (though this still assumes host == target).
Otherwise LGTM - OK for trunk with those nits fixed.
Thanks
Dave
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-06-06 22:19 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-03 3:09 [PATCH] libgccjit: Support getting the size of a float Antoni Boucher
2022-06-06 22:18 ` 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).