[LLVMdev] LLVMBuilder vs LLVMFoldingBuilder
Chris Lattner
sabre at nondot.org
Thu Apr 3 19:29:04 PDT 2008
On Apr 2, 2008, at 9:54 AM, Dominic Hamon wrote:
> Hello llvm dev peeps
>
> I would like to use an LLVMBuilder pointer as a base pointer to
> reference either an LLVMBuilder or an LLVMFoldingBuilder. As the
> methods
> in the Folding builder have the same names as the base class, I
> thought
> about submitting a patch whereby the base class methods would become
> virtual. However, the base class methods return specific types while
> the
> Folding builder, for good reason, return more general Value* types.
>
> Would it be reasonable for me to submit a patch whereby the
> LLVMBuilder
> methods also return the general Value* type and the LLVMFoldingBuilder
> methods become virtual overrides of the base class methods?
No, please don't do this. The idea of llvmbuilder is that it is a
"free" wrapper around the other existing API calls. Making the
methods virtual would make them much more expensive.
> Users (such as myself) could then decide at runtime which type of
> builder they wish to use.
Why do you want this?
> Another option that was discussed in #llvm is to nuke LLVMBuilder and
> rename LLVMFoldingBuilder to LLVMBuilder.
I'd strongly prefer this. The non-folding builder is not very useful
for anything, and anyone who wants unfolded instructions can call the
instruction ctors directly.
> If this was the case, I'd
> argue for a flag in the Builder that could retain the old non-folding
> functionality for debugging purposes.
Why?
-Chris
More information about the llvm-dev
mailing list