850812cf66d8b2b7ed461cd5868a206cde568600
[oota-llvm.git] / lib / VMCore / IRBuilder.cpp
1 //===---- IRBuilder.cpp - Builder for LLVM Instrs -------------------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file implements the IRBuilder class, which is used as a convenient way
11 // to create LLVM instructions with a consistent and simplified interface.
12 //
13 //===----------------------------------------------------------------------===//
14
15 #include "llvm/Support/IRBuilder.h"
16 #include "llvm/GlobalVariable.h"
17 using namespace llvm;
18
19 /// CreateGlobalString - Make a new global variable with an initializer that
20 /// has array of i8 type filled in the the nul terminated string value
21 /// specified.  If Name is specified, it is the name of the global variable
22 /// created.
23 Value *IRBuilderBase::CreateGlobalString(const char *Str, const Twine &Name) {
24   Constant *StrConstant = ConstantArray::get(Context, Str, true);
25   Module &M = *BB->getParent()->getParent();
26   GlobalVariable *GV = new GlobalVariable(M, StrConstant->getType(),
27                                           true, GlobalValue::InternalLinkage,
28                                           StrConstant, "", 0, false);
29   GV->setName(Name);
30   return GV;
31 }