[llvm-commits] PATCH: Additional convenience methods for ConstantStruct, ConstantArray, and ConstantVector.

Talin viridia at gmail.com
Thu Feb 17 16:17:41 PST 2011


On Thu, Feb 17, 2011 at 3:55 PM, Chris Lattner <clattner at apple.com> wrote:

>
> On Feb 10, 2011, at 1:40 PM, Talin wrote:
>
> > This patch adds a new "get" method to ConstantStruct, ConstantArray and
> ConstantVector. The new method accepts a pair of RandomAccessIterators,
> similar to other LLVM method signatures. This allows constants to be build
> using a small vector or other sequential container type more easily.
>
> Hi Talin,
>
> I don't think that this is the right way to go.  Generic random access
> iterators are not guaranteed to be contiguous in memory (e.g. std::deque).
>

OK - I was just following the patterns that I saw used elsewhere in LLVM.

>
> Doesn't ArrayRef solve this need?
>

Yes, although you'll have to manually call the ArrayRef constructor in cases
like this instead of having it be implicit, but that's not a huge deal for
me.

>
> > In addition, I've also added an END_WITH_NULL variant for
> ConstantStruct::get(). I only added it to ConstantStruct because I figured
> that it would be an uncommon use case for arrays and vectors, whereas the
> creation of small constant structs of predetermined length is fairly common.
>
> This part seems fine to me,
>

Good cause this is the part I really care about :)

Should I wait until you've converted ConstantStruct and friends to use
ArrayRef before sending you a new patch? (I'd do it myself, except as you've
discovered there may be other projects broken by such changes and you're in
a better position to detect and correct those.)

-- 
-- Talin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20110217/012f0249/attachment.html>


More information about the llvm-commits mailing list