summaryrefslogtreecommitdiff
path: root/include/llvm/Support/IRBuilder.h
diff options
context:
space:
mode:
authorEric Christopher <echristo@apple.com>2008-07-02 22:57:59 +0000
committerEric Christopher <echristo@apple.com>2008-07-02 22:57:59 +0000
commit9bd64ea1d935c54d0cd51953b5ce94e22c0aa538 (patch)
tree42514ecf56a214c424582a6a4daa3062ab1a7ad2 /include/llvm/Support/IRBuilder.h
parent8b69135f05cc2b8fff0f50bc826666b1da0661c4 (diff)
downloadllvm-9bd64ea1d935c54d0cd51953b5ce94e22c0aa538.tar.gz
llvm-9bd64ea1d935c54d0cd51953b5ce94e22c0aa538.tar.bz2
llvm-9bd64ea1d935c54d0cd51953b5ce94e22c0aa538.tar.xz
Add a couple more helper functions to deal with
creating global constant strings and pointers to global constant strings. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53051 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Support/IRBuilder.h')
-rw-r--r--include/llvm/Support/IRBuilder.h21
1 files changed, 20 insertions, 1 deletions
diff --git a/include/llvm/Support/IRBuilder.h b/include/llvm/Support/IRBuilder.h
index 09859092ae..b96c412ee1 100644
--- a/include/llvm/Support/IRBuilder.h
+++ b/include/llvm/Support/IRBuilder.h
@@ -18,6 +18,8 @@
#include "llvm/BasicBlock.h"
#include "llvm/Instructions.h"
#include "llvm/Constants.h"
+#include "llvm/GlobalVariable.h"
+#include "llvm/Function.h"
namespace llvm {
@@ -308,7 +310,24 @@ public:
return Insert(GetElementPtrInst::Create(Ptr, Idxs, Idxs+2), Name);
}
-
+ Value *CreateGlobalString(const char *Str = "", const char *Name = "") {
+ Constant *StrConstant = ConstantArray::get(Str, true);
+ GlobalVariable *gv = new llvm::GlobalVariable(StrConstant->getType(),
+ true,
+ GlobalValue::InternalLinkage,
+ StrConstant,
+ "",
+ BB->getParent()->getParent(),
+ false);
+ gv->setName(Name);
+ return gv;
+ }
+ Value *CreateGlobalStringPtr(const char *Str = "", const char *Name = "") {
+ Value *gv = CreateGlobalString(Str, Name);
+ Value *zero = llvm::ConstantInt::get(llvm::Type::Int32Ty, 0);
+ Value *Args[] = { zero, zero };
+ return CreateGEP(gv, Args, Args+2, Name);
+ }
//===--------------------------------------------------------------------===//
// Instruction creation methods: Cast/Conversion Operators
//===--------------------------------------------------------------------===//