[LLVMdev] RFC: Constant Creation API

Chris Lattner clattner at apple.com
Fri Jul 24 09:00:21 PDT 2009

On Jul 23, 2009, at 11:56 PM, Jeffrey Yasskin wrote:

> On Thu, Jul 23, 2009 at 7:35 PM, Owen Anderson<resistor at mac.com>  
> wrote:
>> So, as you all probably noticed, the APIs for creating constants  
>> have been
>> moved (or in a specific cases, are about to be moved) from static  
>> methods on
>> Constant to instance methods on LLVMContext.
>> However, as was recently pointed out on llvm-commits and on IRC,  
>> this is no
>> longer strictly necessary.  Because types have contexts, all of the  
>> constant
>> subclasses could be friended to LLVMContext, and then put the work of
>> uniquing by accessing the context off of the type.
>> There are obviously some pros and to both approaches.  Going back  
>> to the
>> old-style increases compatibility with 2.5, and breaks up the massive
>> LLVMContext class.  On the downside, it would cause massive  
>> thrashing on
>> TOT, because I will have to revert about two weeks worth of commits  
>> in
>> widely dispersed parts of the tree, and because a number of clients  
>> have
>> already switched to the new TOT API.
>> Any comments and/or opinions on this decision are welcome.
> This also works for several of the Type classes, since many of them
> take another type in their constructors. Functions, arrays, pointers,
> vectors, and all structs except the empty one can pull the Context out
> of one of their nested types. On the other hand, consistency may argue
> for putting all type creators in one place.

The ones that don't can be static functions on the type class that  
take a context.  For example, Type::Int32Ty needs to become a function  
that takes a context at some point.


More information about the llvm-dev mailing list