public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* How to define Struct / Array type with runtime invariants like SVE or RVV
       [not found] <25ab5a89-bea1-49b5-9e57-c3228177d672@Spark>
@ 2021-08-25  6:43 ` Jojo R
  2021-08-25  7:27   ` Jonathan Wakely
  0 siblings, 1 reply; 4+ messages in thread
From: Jojo R @ 2021-08-25  6:43 UTC (permalink / raw)
  To: GCC Development, llvm-dev

Hi,

	I want to use struct or array type as container in my project,

	but GCC does not support this usage by now because that

	the size of these types are decided at compile-time :(

	so is there any good solution to fix this ?

	or some new feature patches to add supporting for these types with
	computed size at runtime ?

— Jojo R

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

* Re: How to define Struct / Array type with runtime invariants like SVE or RVV
  2021-08-25  6:43 ` How to define Struct / Array type with runtime invariants like SVE or RVV Jojo R
@ 2021-08-25  7:27   ` Jonathan Wakely
  2021-08-25  9:07     ` Jojo R
  0 siblings, 1 reply; 4+ messages in thread
From: Jonathan Wakely @ 2021-08-25  7:27 UTC (permalink / raw)
  To: Jojo R; +Cc: GCC Development

On Wed, 25 Aug 2021, 07:45 Jojo R wrote:

> Hi,
>
>         I want to use struct or array type as container in my project,
>
>         but GCC does not support this usage by now because that
>
>         the size of these types are decided at compile-time :(
>
>         so is there any good solution to fix this ?
>
>         or some new feature patches to add supporting for these types with
>         computed size at runtime ?
>

Do you mean something like
https://en.m.wikipedia.org/wiki/Flexible_array_member ?

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

* Re: How to define Struct / Array type with runtime invariants like SVE or RVV
  2021-08-25  7:27   ` Jonathan Wakely
@ 2021-08-25  9:07     ` Jojo R
  2021-08-26  7:52       ` Richard Biener
  0 siblings, 1 reply; 4+ messages in thread
From: Jojo R @ 2021-08-25  9:07 UTC (permalink / raw)
  To: Jonathan Wakely; +Cc: GCC Development, llvm-dev


— Jojo
在 2021年8月25日 +0800 PM3:27,Jonathan Wakely <jwakely.gcc@gmail.com>,写道:
>
>
> On Wed, 25 Aug 2021, 07:45 Jojo R wrote:
> > Hi,
> >
> >         I want to use struct or array type as container in my project,
> >
> >         but GCC does not support this usage by now because that
> >
> >         the size of these types are decided at compile-time :(
> >
> >         so is there any good solution to fix this ?
> >
> >         or some new feature patches to add supporting for these types with
> >         computed size at runtime ?
>
> Do you mean something like
> https://en.m.wikipedia.org/wiki/Flexible_array_member ?
>
No, it’s similar but include vector type as member like :

struct vectord {
 vint8m1_t data; // Vector Length Agnostic (VLA)
};

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

* Re: How to define Struct / Array type with runtime invariants like SVE or RVV
  2021-08-25  9:07     ` Jojo R
@ 2021-08-26  7:52       ` Richard Biener
  0 siblings, 0 replies; 4+ messages in thread
From: Richard Biener @ 2021-08-26  7:52 UTC (permalink / raw)
  To: Jojo R; +Cc: Jonathan Wakely, llvm-dev, GCC Development

On Wed, Aug 25, 2021 at 11:09 AM Jojo R via Gcc <gcc@gcc.gnu.org> wrote:
>
>
> — Jojo
> 在 2021年8月25日 +0800 PM3:27,Jonathan Wakely <jwakely.gcc@gmail.com>,写道:
> >
> >
> > On Wed, 25 Aug 2021, 07:45 Jojo R wrote:
> > > Hi,
> > >
> > >         I want to use struct or array type as container in my project,
> > >
> > >         but GCC does not support this usage by now because that
> > >
> > >         the size of these types are decided at compile-time :(
> > >
> > >         so is there any good solution to fix this ?
> > >
> > >         or some new feature patches to add supporting for these types with
> > >         computed size at runtime ?
> >
> > Do you mean something like
> > https://en.m.wikipedia.org/wiki/Flexible_array_member ?
> >
> No, it’s similar but include vector type as member like :
>
> struct vectord {
>  vint8m1_t data; // Vector Length Agnostic (VLA)
> };

I think you should be able to use this at least when at the
last member and when you are not instantiating such
object but always use dynamic allocation like you'd
need to do with a flex array member.  But SVE folks might
have decided to disallow it even here.

Note GCC itself would be happy to have variable placement
of fields but obviously C/C++ are not ready for this.

Richard.

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

end of thread, other threads:[~2021-08-26  7:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <25ab5a89-bea1-49b5-9e57-c3228177d672@Spark>
2021-08-25  6:43 ` How to define Struct / Array type with runtime invariants like SVE or RVV Jojo R
2021-08-25  7:27   ` Jonathan Wakely
2021-08-25  9:07     ` Jojo R
2021-08-26  7:52       ` Richard Biener

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