From: Jakub Jelinek <jakub@redhat.com>
To: Richard Biener <rguenther@suse.de>
Cc: Joseph Myers <joseph@codesourcery.com>,
Jason Merrill <jason@redhat.com>,
gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] middle-end, v2: Add new value for vector types for __builtin_classify_type
Date: Mon, 20 Nov 2023 10:41:17 +0100 [thread overview]
Message-ID: <ZVspuzuIn2AOEMp4@tucnak> (raw)
In-Reply-To: <nycvar.YFH.7.77.849.2311200803010.8772@jbgna.fhfr.qr>
On Mon, Nov 20, 2023 at 08:03:18AM +0000, Richard Biener wrote:
> OK. Do we have to adjust any of our documentation for this?
I've done it this way. We don't really document the exact values
in the documentation, so I think it is sufficient like that.
Committed to trunk.
2023-11-20 Jakub Jelinek <jakub@redhat.com>
gcc/
* typeclass.h (enum type_class): Add vector_type_class.
* builtins.cc (type_to_class): Return vector_type_class for
VECTOR_TYPE.
* doc/extend.texi (__builtin_classify_type): Mention bit-precise
integer types and vector types.
gcc/testsuite/
* c-c++-common/builtin-classify-type-1.c (main): Add tests for vector
types.
--- gcc/typeclass.h.jj 2023-09-06 17:28:24.238977355 +0200
+++ gcc/typeclass.h 2023-11-10 10:50:59.519007647 +0100
@@ -38,7 +38,7 @@ enum type_class
record_type_class, union_type_class,
array_type_class, string_type_class,
lang_type_class, opaque_type_class,
- bitint_type_class
+ bitint_type_class, vector_type_class
};
#endif /* GCC_TYPECLASS_H */
--- gcc/builtins.cc.jj 2023-11-09 09:17:40.230182483 +0100
+++ gcc/builtins.cc 2023-11-10 11:19:29.669129855 +0100
@@ -1859,6 +1859,7 @@ type_to_class (tree type)
case LANG_TYPE: return lang_type_class;
case OPAQUE_TYPE: return opaque_type_class;
case BITINT_TYPE: return bitint_type_class;
+ case VECTOR_TYPE: return vector_type_class;
default: return no_type_class;
}
}
--- gcc/doc/extend.texi.jj
+++ gcc/doc/extend.texi
@@ -14746,11 +14746,11 @@ The @code{__builtin_classify_type} returns a small integer with a category
of @var{arg} argument's type, like void type, integer type, enumeral type,
boolean type, pointer type, reference type, offset type, real type, complex
type, function type, method type, record type, union type, array type,
-string type, etc. When the argument is an expression, for
-backwards compatibility reason the argument is promoted like arguments
-passed to @code{...} in varargs function, so some classes are never returned
-in certain languages. Alternatively, the argument of the built-in
-function can be a typename, such as the @code{typeof} specifier.
+string type, bit-precise integer type, vector type, etc. When the argument
+is an expression, for backwards compatibility reason the argument is promoted
+like arguments passed to @code{...} in varargs function, so some classes are
+never returned in certain languages. Alternatively, the argument of the
+built-in function can be a typename, such as the @code{typeof} specifier.
@smallexample
int a[2];
--- gcc/testsuite/c-c++-common/builtin-classify-type-1.c.jj 2023-09-26 09:25:30.019599039 +0200
+++ gcc/testsuite/c-c++-common/builtin-classify-type-1.c 2023-11-10 11:02:01.927776922 +0100
@@ -22,6 +22,10 @@ main ()
const char *p = (const char *) 0;
float f = 0.0;
_Complex double c = 0.0;
+ typedef int VI __attribute__((vector_size (4 * sizeof (int))));
+ typedef float VF __attribute__((vector_size (4 * sizeof (int))));
+ VI vi = { 0, 0, 0, 0 };
+ VF vf = { 0.0f, 0.0f, 0.0f, 0.0f };
#ifdef __cplusplus
struct T { void foo (); };
int &r = a[0];
@@ -43,6 +47,8 @@ main ()
static_assert (__builtin_classify_type (struct S) == 12, "");
static_assert (__builtin_classify_type (union U) == 13, "");
static_assert (__builtin_classify_type (int [2]) == 14, "");
+ static_assert (__builtin_classify_type (VI) == 19, "");
+ static_assert (__builtin_classify_type (VF) == 19, "");
static_assert (__builtin_classify_type (__typeof__ (a[0])) == 1, "");
static_assert (__builtin_classify_type (__typeof__ (e)) == 3, "");
static_assert (__builtin_classify_type (__typeof__ (b)) == 4, "");
@@ -57,6 +63,8 @@ main ()
static_assert (__builtin_classify_type (__typeof__ (s)) == 12, "");
static_assert (__builtin_classify_type (__typeof__ (u)) == 13, "");
static_assert (__builtin_classify_type (__typeof__ (a)) == 14, "");
+ static_assert (__builtin_classify_type (__typeof__ (vi)) == 19, "");
+ static_assert (__builtin_classify_type (__typeof__ (vf)) == 19, "");
#ifndef __cplusplus
static_assert (__builtin_classify_type (a[0]) == 1, "");
static_assert (__builtin_classify_type (e) == 1, "");
@@ -102,4 +110,8 @@ main ()
abort ();
if (__builtin_classify_type (a) != 5)
abort ();
+ if (__builtin_classify_type (vi) != 19)
+ abort ();
+ if (__builtin_classify_type (vf) != 19)
+ abort ();
}
Jakub
prev parent reply other threads:[~2023-11-21 8:21 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-11 8:22 [PATCH] c, c++: Add new value for vector types for __builtin_classify_type (type) Jakub Jelinek
2023-11-16 21:52 ` Jason Merrill
2023-11-16 23:49 ` Joseph Myers
2023-11-17 14:04 ` [PATCH] middle-end, v2: Add new value for vector types for __builtin_classify_type Jakub Jelinek
2023-11-20 8:03 ` Richard Biener
2023-11-20 9:41 ` Jakub Jelinek [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZVspuzuIn2AOEMp4@tucnak \
--to=jakub@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jason@redhat.com \
--cc=joseph@codesourcery.com \
--cc=rguenther@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).