[llvm-dev] The best way of generating a good representation for an array with header?

John Reagan via llvm-dev llvm-dev at lists.llvm.org
Mon Nov 18 07:49:32 PST 2019


Sorry for the delay.  I've been away from the computer.  Yes, we have already coded up support for our Pascal's VARYING OF CHAR (based on PL/Is VARYING OF CHAR) which has a 16-bit length at the front.  The layout is also influenced by the VAX architecture's MOVC/CMPC instructions which have a max size of 64K.   We have vendor-specific DWARF tags for these VS strings.  I'm not sure if any of this helps, but send email if you'd like to see any examples (our current cross-compiler environment is based on ancient 3.4.2 so you'll have extrapolate to something newer - we're working on a bootstrap now to 9.0.0)

John

On 11/12/2019 3:51 PM, Robinson, Paul wrote:
OpenVMS has something called a “varstring” (IIRC) which is a 16-bit length followed by the string data.  I don’t know if John Reagan has support for any VMS languages with that construct yet, but I’d expect it to be effectively a struct with the length as the first member and a VLA-like thing holding the array.  Your container might want to look something like that.
--paulr

From: llvm-dev <llvm-dev-bounces at lists.llvm.org><mailto:llvm-dev-bounces at lists.llvm.org> On Behalf Of David Blaikie via llvm-dev
Sent: Tuesday, November 12, 2019 2:35 PM
To: Christoffer Lernö <christoffer at aegik.com><mailto:christoffer at aegik.com>
Cc: via llvm-dev <llvm-dev at lists.llvm.org><mailto:llvm-dev at lists.llvm.org>
Subject: Re: [llvm-dev] The best way of generating a good representation for an array with header?

the pointer points to the first element, and you walk backwards from there to find the header details about the bounds/etc?

In any case - I'd look at something like C++'s std::vector, which is a variable length array, and model your situation similarly. I doubt there's anything in particular you'll want to/be able to teach the optimizations about your situation (nothing especially special that they know about std::vector-like things either, that I know of - they maybe can deduce certain things about how the bounds relate, and they certainly can optimize a lot of std::vector usage) & debug info would probably look like std::vector, in that it'd be a custom type, etc. Though if my guess above was right about using prefix data to describe the bounds - that might be hard to model in DWARF & you might be better off not being "tricky" like that & modelling this closer to something that you could have written in C or C++ more naturally.

On Tue, Nov 12, 2019 at 4:14 AM Christoffer Lernö via llvm-dev <llvm-dev at lists.llvm.org<mailto:llvm-dev at lists.llvm.org>> wrote:
I’m considering building in variable arrays by implementing them as a stretchy buffer, that is a single allocation with header + elements with the pointer passed around pointing to the first element. (Example: https://www.gamasutra.com/blogs/NiklasGray/20180109/312683/Minimalist_container_library_in_C_part_1.php)

Is there a good way to represent this in LLVM? I mean both in terms of helping the optimizer passes understand how the layout works and to make sure the debug info looks ok.


Best regards,
Christoffer
_______________________________________________
LLVM Developers mailing list
llvm-dev at lists.llvm.org<mailto:llvm-dev at lists.llvm.org>
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20191118/f5a67d84/attachment.html>


More information about the llvm-dev mailing list