[LLVMdev] LLVMBuilder vs LLVMFoldingBuilder
Duncan Sands
baldrick at free.fr
Fri Apr 11 01:44:26 PDT 2008
Hi Dominic,
+//===-- llvm/Support/IRBuilder.h - Builder for LLVM Instrs -----*- C++ -*-===//
is this line the right length? It seems shorter than the similar lines below like
this one:
+//===----------------------------------------------------------------------===//
+ GetElementPtrInst *CreateStructGEP(Value *Ptr, unsigned Idx,
+ const char *Name = "") {
+ llvm::Value *Idxs[] = {
+ ConstantInt::get(llvm::Type::Int32Ty, 0),
+ ConstantInt::get(llvm::Type::Int32Ty, Idx)
+ };
+ return Insert(GetElementPtrInst::Create(Ptr, Idxs, Idxs+2, Name));
+ }
This should constant fold if Ptr is a constant.
+ CallInst *CreateCall(Value *Callee, const char *Name = "") {
+ return Insert(CallInst::Create(Callee, Name));
You should be indenting by two spaces (I think Chris mentioned this).
- DEFINE_SIMPLE_CONVERSION_FUNCTIONS(LLVMFoldingBuilder, LLVMBuilderRef )
+ DEFINE_SIMPLE_CONVERSION_FUNCTIONS(IRBuilder, LLVMBuilderRef )
DEFINE_SIMPLE_CONVERSION_FUNCTIONS(PATypeHolder, LLVMTypeHandleRef )
Please add spaces so that these line up again.
-<p>Well, that was easy :). In practice, we recommend always using
...
+<p>Well, that iss easy :). In practice, we recommend always using
you changed was to iss, I guess you meant "is", though I would prefer "was".
- LLVMBuilder TmpB(&TheFunction->getEntryBlock(),
+ IRBuilder TmpB(&TheFunction->getEntryBlock(),
TheFunction->getEntryBlock().begin());
Here the arguments no longer line up properly.
- LLVMBuilder TmpB(&TheFunction->getEntryBlock(),
+ IRBuilder TmpB(&TheFunction->getEntryBlock(),
TheFunction->getEntryBlock().begin());
Likewise.
Index: Xcode/LLVM.xcodeproj/project.pbxproj
I don't know what this Xcode stuff is, so I've no idea if it is correct
or whether you should be committing it.
Thanks for doing this!
Best wishes,
Duncan.
More information about the llvm-dev
mailing list