Jojo R via llvm-dev
2021-Aug-25 09:07 UTC
[llvm-dev] How to define Struct / Array type with runtime invariants like SVE or RVV
— Jojo 在 2021年8月25日 +0800 PM3:27,Jonathan Wakely <jwakely.gcc at 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) }; -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20210825/d30e1547/attachment.html>
Richard Biener via llvm-dev
2021-Aug-26 07:52 UTC
[llvm-dev] How to define Struct / Array type with runtime invariants like SVE or RVV
On Wed, Aug 25, 2021 at 11:09 AM Jojo R via Gcc <gcc at gcc.gnu.org> wrote:> > > — Jojo > 在 2021年8月25日 +0800 PM3:27,Jonathan Wakely <jwakely.gcc at 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.