<ul>
<li><a href="#isa">The <tt>isa<></tt>, <tt>cast<></tt>
and <tt>dyn_cast<></tt> templates</a> </li>
+ <li><a href="#string_apis">Passing strings (the <tt>StringRef</tt>
+and <tt>Twine</tt> classes)</li>
+ <ul>
+ <li><a href="#StringRef">The <tt>StringRef</tt> class</a> </li>
+ <li><a href="#Twine">The <tt>Twine</tt> class</a> </li>
+ </ul>
<li><a href="#DEBUG">The <tt>DEBUG()</tt> macro and <tt>-debug</tt>
option</a>
<ul>
</div>
+
+<!-- ======================================================================= -->
+<div class="doc_subsection">
+ <a name="string_apis">Passing strings (the <tt>StringRef</tt>
+and <tt>Twine</tt> classes)</a>
+</div>
+
+<div class="doc_text">
+
+<p>Although LLVM generally does not do much string manipulation, we do have
+several important APIs which take string. Several important examples are the
+Value class -- which has names for instructions, functions, etc. -- and the
+StringMap class which is used extensively in LLVM and Clang.</p>
+
+<p>These are generic classes, and they need to be able to accept strings which
+may have embedded null characters. Therefore, they cannot simply take
+a <tt>const char *</tt>, and taking a <tt>const std::string&</tt> requires
+clients to perform a heap allocation which is usually unnecessary. Instead,
+many LLVM APIs use a <tt>const StringRef&</tt> or a <tt>const Twine&</tt> for
+passing strings efficiently.</p>
+
+</div>
+
+<!-- _______________________________________________________________________ -->
+<div class="doc_subsubsection">
+ <a name="StringRef">The <tt>StringRef</tt> class</a>
+</div>
+
+<div class="doc_text">
+
+<p>The <tt>StringRef</tt> data type represents a reference to a constant string
+(a character array and a length) and supports the common operations available
+on <tt>std:string</tt>, but does not require heap allocation.</p>
+
+It can be implicitly constructed using either a C style null-terminated string
+or an <tt>std::string</tt>, or explicitly with a character pointer and length.
+For example, the <tt>StringRef</tt> find function is declared as:</p>
+<div class="doc_code">
+ iterator find(const StringRef &Key);
+</div>
+
+<p>and clients can call it using any one of:</p>
+
+<div class="doc_code">
+<pre>
+ Map.find("foo"); <i>// Lookup "foo"</i>
+ Map.find(std::string("bar")); <i>// Lookup "bar"</i>
+ Map.find(StringRef("\0baz", 4)); <i>// Lookup "\0baz"</i>
+</pre>
+</div>
+
+<p>Similarly, APIs which need to return a string may return a <tt>StringRef</tt>
+instance, which can be used directly or converted to an <tt>std::string</tt>
+using the <tt>str</tt> member function. See
+"<tt><a href="/doxygen/classllvm_1_1StringRef_8h-source.html">llvm/ADT/StringRef.h</a></tt>"
+for more information.</p>
+
+<p>You should rarely use the <tt>StringRef</tt> class directly, because it contains
+pointers to external memory it is not generally safe to store an instance of the
+class (since the external storage may be freed).</p>
+
+</div>
+
+<!-- _______________________________________________________________________ -->
+<div class="doc_subsubsection">
+ <a name="Twine">The <tt>Twine</tt> class</a>
+</div>
+
+<div class="doc_text">
+
+<p>The <tt>Twine</tt> class is an efficient way for APIs to accept concatenated
+strings. For example, a common LLVM paradigm is to name one instruction based on
+the name of another instruction with a suffix, for example:</p>
+
+<div class="doc_code">
+<pre>
+ New = CmpInst::Create(<i>...</i>, SO->getName() + ".cmp");
+</pre>
+</div>
+
+<p>The <tt>Twine</tt> class is effectively a
+lightweight <a href="http://en.wikipedia.org/wiki/Rope_(computer_science)">rope</a>
+which points to temporary (stack allocated) objects. Twines can be implicitly
+constructed as the result of the plus operator applied to strings (i.e., a C
+strings, an <tt>std::string</tt>, or a <tt>StringRef</tt>). The twine delays the
+actual concatentation of strings until it is actually required, at which point
+it can be efficiently rendered directly into a character array. This avoids
+unnecessary heap allocation involved in constructing the temporary results of
+string concatenation. See
+"<tt><a href="/doxygen/classllvm_1_1Twine_8h-source.html">llvm/ADT/Twine.h</a></tt>"
+for more information.</p></tt>
+
+<p>As with a <tt>StringRef</tt>, <tt>Twine</tt> objects point to external memory
+and should almost never be stored or mentioned directly. They are intended
+solely for use when defining a function which should be able to efficiently
+accept concatenated strings.</p>
+
+</div>
+
+
<!-- ======================================================================= -->
<div class="doc_subsection">
<a name="DEBUG">The <tt>DEBUG()</tt> macro and <tt>-debug</tt> option</a>
<li><tt>SCEVHandle</tt> no longer exists, because reference counting is no
longer done for <tt>SCEV*</tt> objects, instead <tt>const SCEV*</tt> should be
used.</li>
+<li>Many APIs, notably <tt>llvm::Value</tt>, now use the <tt>StringRef</tt>
+and <tt>Twine</tt> classes instead of passing <tt>const char*</tt>
+or <tt>std::string</tt>, as described in
+the <a href="ProgrammersManual.html#string_apis">Programmer's Manual</a>. Most
+clients should be uneffected by this transition.</li>
<li>llvm-dis now fails if output file exists, instead of dumping to stdout.
-FIXME: describe any other tool changes due to the raw_fd_ostream change</li>
+FIXME: describe any other tool changes due to the raw_fd_ostream change. FIXME:
+This is not an API change, maybe there should be a tool changes section?</li>
<li>temporarely due to Context API change passes should call doInitialization()
method of the pass they inherit from, otherwise Context is NULL.
FIXME: remove this entry when this is no longer needed.<li>
/// Argument ctor - If Function argument is specified, this argument is
/// inserted at the end of the argument list for the function.
///
- explicit Argument(const Type *Ty, const std::string &Name = "",
- Function *F = 0);
+ explicit Argument(const Type *Ty, const Twine &Name = "", Function *F = 0);
inline const Function *getParent() const { return Parent; }
inline Function *getParent() { return Parent; }
/// is automatically inserted at either the end of the function (if
/// InsertBefore is null), or before the specified basic block.
///
- explicit BasicBlock(const std::string &Name = "", Function *Parent = 0,
+ explicit BasicBlock(const Twine &Name = "", Function *Parent = 0,
BasicBlock *InsertBefore = 0);
public:
/// getContext - Get the context in which this basic block lives,
/// Create - Creates a new BasicBlock. If the Parent parameter is specified,
/// the basic block is automatically inserted at either the end of the
/// function (if InsertBefore is 0), or before the specified basic block.
- static BasicBlock *Create(const std::string &Name = "", Function *Parent = 0,
+ static BasicBlock *Create(const Twine &Name = "", Function *Parent = 0,
BasicBlock *InsertBefore = 0) {
return new BasicBlock(Name, Parent, InsertBefore);
}
/// cause a degenerate basic block to be formed, having a terminator inside of
/// the basic block).
///
- BasicBlock *splitBasicBlock(iterator I, const std::string &BBName = "");
+ BasicBlock *splitBasicBlock(iterator I, const Twine &BBName = "");
};
} // End llvm namespace
/// the module.
///
Function(const FunctionType *Ty, LinkageTypes Linkage,
- const std::string &N = "", Module *M = 0);
+ const Twine &N = "", Module *M = 0);
public:
static Function *Create(const FunctionType *Ty, LinkageTypes Linkage,
- const std::string &N = "", Module *M = 0) {
+ const Twine &N = "", Module *M = 0) {
return new(0) Function(Ty, Linkage, N, M);
}
protected:
GlobalValue(const Type *ty, ValueTy vty, Use *Ops, unsigned NumOps,
- LinkageTypes linkage, const std::string &name = "")
+ LinkageTypes linkage, const Twine &Name = "")
: Constant(ty, vty, Ops, NumOps), Parent(0),
Linkage(linkage), Visibility(DefaultVisibility), Alignment(0) {
- if (!name.empty()) setName(name);
+ setName(Name);
}
Module *Parent;
/// automatically inserted into the end of the specified modules global list.
GlobalVariable(LLVMContext &Context, const Type *Ty, bool isConstant,
LinkageTypes Linkage,
- Constant *Initializer = 0, const std::string &Name = "",
+ Constant *Initializer = 0, const Twine &Name = "",
bool ThreadLocal = false, unsigned AddressSpace = 0);
/// GlobalVariable ctor - This creates a global and inserts it before the
/// specified other global.
GlobalVariable(Module &M, const Type *Ty, bool isConstant,
LinkageTypes Linkage, Constant *Initializer,
- const std::string &Name,
+ const Twine &Name,
GlobalVariable *InsertBefore = 0, bool ThreadLocal = false,
unsigned AddressSpace = 0);
protected:
void init(BinaryOps iType);
BinaryOperator(BinaryOps iType, Value *S1, Value *S2, const Type *Ty,
- const std::string &Name, Instruction *InsertBefore);
+ const Twine &Name, Instruction *InsertBefore);
BinaryOperator(BinaryOps iType, Value *S1, Value *S2, const Type *Ty,
- const std::string &Name, BasicBlock *InsertAtEnd);
+ const Twine &Name, BasicBlock *InsertAtEnd);
public:
// allocate space for exactly two operands
void *operator new(size_t s) {
/// Instruction is allowed to be a dereferenced end iterator.
///
static BinaryOperator *Create(BinaryOps Op, Value *S1, Value *S2,
- const std::string &Name = "",
+ const Twine &Name = "",
Instruction *InsertBefore = 0);
/// Create() - Construct a binary instruction, given the opcode and the two
/// BasicBlock specified.
///
static BinaryOperator *Create(BinaryOps Op, Value *S1, Value *S2,
- const std::string &Name,
- BasicBlock *InsertAtEnd);
+ const Twine &Name, BasicBlock *InsertAtEnd);
/// Create* - These methods just forward to Create, and are useful when you
/// statically know what type of instruction you're going to create. These
/// helpers just save some typing.
#define HANDLE_BINARY_INST(N, OPC, CLASS) \
static BinaryOperator *Create##OPC(Value *V1, Value *V2, \
- const std::string &Name = "") {\
+ const Twine &Name = "") {\
return Create(Instruction::OPC, V1, V2, Name);\
}
#include "llvm/Instruction.def"
#define HANDLE_BINARY_INST(N, OPC, CLASS) \
static BinaryOperator *Create##OPC(Value *V1, Value *V2, \
- const std::string &Name, BasicBlock *BB) {\
+ const Twine &Name, BasicBlock *BB) {\
return Create(Instruction::OPC, V1, V2, Name, BB);\
}
#include "llvm/Instruction.def"
#define HANDLE_BINARY_INST(N, OPC, CLASS) \
static BinaryOperator *Create##OPC(Value *V1, Value *V2, \
- const std::string &Name, Instruction *I) {\
+ const Twine &Name, Instruction *I) {\
return Create(Instruction::OPC, V1, V2, Name, I);\
}
#include "llvm/Instruction.def"
/// instructions out of SUB and XOR instructions.
///
static BinaryOperator *CreateNeg(LLVMContext &Context,
- Value *Op, const std::string &Name = "",
+ Value *Op, const Twine &Name = "",
Instruction *InsertBefore = 0);
static BinaryOperator *CreateNeg(LLVMContext &Context,
- Value *Op, const std::string &Name,
+ Value *Op, const Twine &Name,
BasicBlock *InsertAtEnd);
static BinaryOperator *CreateFNeg(LLVMContext &Context,
- Value *Op, const std::string &Name = "",
+ Value *Op, const Twine &Name = "",
Instruction *InsertBefore = 0);
static BinaryOperator *CreateFNeg(LLVMContext &Context,
- Value *Op, const std::string &Name,
+ Value *Op, const Twine &Name,
BasicBlock *InsertAtEnd);
static BinaryOperator *CreateNot(LLVMContext &Context,
- Value *Op, const std::string &Name = "",
+ Value *Op, const Twine &Name = "",
Instruction *InsertBefore = 0);
static BinaryOperator *CreateNot(LLVMContext &Context,
- Value *Op, const std::string &Name,
+ Value *Op, const Twine &Name,
BasicBlock *InsertAtEnd);
/// isNeg, isFNeg, isNot - Check if the given Value is a
protected:
/// @brief Constructor with insert-before-instruction semantics for subclasses
CastInst(const Type *Ty, unsigned iType, Value *S,
- const std::string &NameStr = "", Instruction *InsertBefore = 0)
+ const Twine &NameStr = "", Instruction *InsertBefore = 0)
: UnaryInstruction(Ty, iType, S, InsertBefore) {
setName(NameStr);
}
/// @brief Constructor with insert-at-end-of-block semantics for subclasses
CastInst(const Type *Ty, unsigned iType, Value *S,
- const std::string &NameStr, BasicBlock *InsertAtEnd)
+ const Twine &NameStr, BasicBlock *InsertAtEnd)
: UnaryInstruction(Ty, iType, S, InsertAtEnd) {
setName(NameStr);
}
Instruction::CastOps, ///< The opcode of the cast instruction
Value *S, ///< The value to be casted (operand 0)
const Type *Ty, ///< The type to which cast should be made
- const std::string &Name = "", ///< Name for the instruction
+ const Twine &Name = "", ///< Name for the instruction
Instruction *InsertBefore = 0 ///< Place to insert the instruction
);
/// Provides a way to construct any of the CastInst subclasses using an
Instruction::CastOps, ///< The opcode for the cast instruction
Value *S, ///< The value to be casted (operand 0)
const Type *Ty, ///< The type to which operand is casted
- const std::string &Name, ///< The name for the instruction
+ const Twine &Name, ///< The name for the instruction
BasicBlock *InsertAtEnd ///< The block to insert the instruction into
);
static CastInst *CreateZExtOrBitCast(
Value *S, ///< The value to be casted (operand 0)
const Type *Ty, ///< The type to which cast should be made
- const std::string &Name = "", ///< Name for the instruction
+ const Twine &Name = "", ///< Name for the instruction
Instruction *InsertBefore = 0 ///< Place to insert the instruction
);
static CastInst *CreateZExtOrBitCast(
Value *S, ///< The value to be casted (operand 0)
const Type *Ty, ///< The type to which operand is casted
- const std::string &Name, ///< The name for the instruction
+ const Twine &Name, ///< The name for the instruction
BasicBlock *InsertAtEnd ///< The block to insert the instruction into
);
static CastInst *CreateSExtOrBitCast(
Value *S, ///< The value to be casted (operand 0)
const Type *Ty, ///< The type to which cast should be made
- const std::string &Name = "", ///< Name for the instruction
+ const Twine &Name = "", ///< Name for the instruction
Instruction *InsertBefore = 0 ///< Place to insert the instruction
);
static CastInst *CreateSExtOrBitCast(
Value *S, ///< The value to be casted (operand 0)
const Type *Ty, ///< The type to which operand is casted
- const std::string &Name, ///< The name for the instruction
+ const Twine &Name, ///< The name for the instruction
BasicBlock *InsertAtEnd ///< The block to insert the instruction into
);
static CastInst *CreatePointerCast(
Value *S, ///< The pointer value to be casted (operand 0)
const Type *Ty, ///< The type to which operand is casted
- const std::string &Name, ///< The name for the instruction
+ const Twine &Name, ///< The name for the instruction
BasicBlock *InsertAtEnd ///< The block to insert the instruction into
);
static CastInst *CreatePointerCast(
Value *S, ///< The pointer value to be casted (operand 0)
const Type *Ty, ///< The type to which cast should be made
- const std::string &Name = "", ///< Name for the instruction
+ const Twine &Name = "", ///< Name for the instruction
Instruction *InsertBefore = 0 ///< Place to insert the instruction
);
Value *S, ///< The pointer value to be casted (operand 0)
const Type *Ty, ///< The type to which cast should be made
bool isSigned, ///< Whether to regard S as signed or not
- const std::string &Name = "", ///< Name for the instruction
+ const Twine &Name = "", ///< Name for the instruction
Instruction *InsertBefore = 0 ///< Place to insert the instruction
);
Value *S, ///< The integer value to be casted (operand 0)
const Type *Ty, ///< The integer type to which operand is casted
bool isSigned, ///< Whether to regard S as signed or not
- const std::string &Name, ///< The name for the instruction
+ const Twine &Name, ///< The name for the instruction
BasicBlock *InsertAtEnd ///< The block to insert the instruction into
);
static CastInst *CreateFPCast(
Value *S, ///< The floating point value to be casted
const Type *Ty, ///< The floating point type to cast to
- const std::string &Name = "", ///< Name for the instruction
+ const Twine &Name = "", ///< Name for the instruction
Instruction *InsertBefore = 0 ///< Place to insert the instruction
);
static CastInst *CreateFPCast(
Value *S, ///< The floating point value to be casted
const Type *Ty, ///< The floating point type to cast to
- const std::string &Name, ///< The name for the instruction
+ const Twine &Name, ///< The name for the instruction
BasicBlock *InsertAtEnd ///< The block to insert the instruction into
);
static CastInst *CreateTruncOrBitCast(
Value *S, ///< The value to be casted (operand 0)
const Type *Ty, ///< The type to which cast should be made
- const std::string &Name = "", ///< Name for the instruction
+ const Twine &Name = "", ///< Name for the instruction
Instruction *InsertBefore = 0 ///< Place to insert the instruction
);
static CastInst *CreateTruncOrBitCast(
Value *S, ///< The value to be casted (operand 0)
const Type *Ty, ///< The type to which operand is casted
- const std::string &Name, ///< The name for the instruction
+ const Twine &Name, ///< The name for the instruction
BasicBlock *InsertAtEnd ///< The block to insert the instruction into
);
CmpInst(); // do not implement
protected:
CmpInst(const Type *ty, Instruction::OtherOps op, unsigned short pred,
- Value *LHS, Value *RHS, const std::string &Name = "",
+ Value *LHS, Value *RHS, const Twine &Name = "",
Instruction *InsertBefore = 0);
CmpInst(const Type *ty, Instruction::OtherOps op, unsigned short pred,
- Value *LHS, Value *RHS, const std::string &Name,
+ Value *LHS, Value *RHS, const Twine &Name,
BasicBlock *InsertAtEnd);
public:
/// @brief Create a CmpInst
static CmpInst *Create(LLVMContext &Context, OtherOps Op,
unsigned short predicate, Value *S1,
- Value *S2, const std::string &Name = "",
+ Value *S2, const Twine &Name = "",
Instruction *InsertBefore = 0);
/// Construct a compare instruction, given the opcode, the predicate and the
/// the BasicBlock specified.
/// @brief Create a CmpInst
static CmpInst *Create(OtherOps Op, unsigned short predicate, Value *S1,
- Value *S2, const std::string &Name,
- BasicBlock *InsertAtEnd);
+ Value *S2, const Twine &Name, BasicBlock *InsertAtEnd);
/// @brief Get the opcode casted to the right type
OtherOps getOpcode() const {
class AllocationInst : public UnaryInstruction {
protected:
AllocationInst(const Type *Ty, Value *ArraySize,
- unsigned iTy, unsigned Align, const std::string &Name = "",
+ unsigned iTy, unsigned Align, const Twine &Name = "",
Instruction *InsertBefore = 0);
AllocationInst(const Type *Ty, Value *ArraySize,
- unsigned iTy, unsigned Align, const std::string &Name,
+ unsigned iTy, unsigned Align, const Twine &Name,
BasicBlock *InsertAtEnd);
public:
// Out of line virtual method, so the vtable, etc. has a home.
MallocInst(const MallocInst &MI);
public:
explicit MallocInst(const Type *Ty, Value *ArraySize = 0,
- const std::string &NameStr = "",
+ const Twine &NameStr = "",
Instruction *InsertBefore = 0)
: AllocationInst(Ty, ArraySize, Malloc,
0, NameStr, InsertBefore) {}
MallocInst(const Type *Ty, Value *ArraySize,
- const std::string &NameStr, BasicBlock *InsertAtEnd)
+ const Twine &NameStr, BasicBlock *InsertAtEnd)
: AllocationInst(Ty, ArraySize, Malloc, 0, NameStr, InsertAtEnd) {}
- MallocInst(const Type *Ty, const std::string &NameStr,
+ MallocInst(const Type *Ty, const Twine &NameStr,
Instruction *InsertBefore = 0)
: AllocationInst(Ty, 0, Malloc, 0, NameStr, InsertBefore) {}
- MallocInst(const Type *Ty, const std::string &NameStr,
+ MallocInst(const Type *Ty, const Twine &NameStr,
BasicBlock *InsertAtEnd)
: AllocationInst(Ty, 0, Malloc, 0, NameStr, InsertAtEnd) {}
MallocInst(const Type *Ty, Value *ArraySize,
- unsigned Align, const std::string &NameStr,
+ unsigned Align, const Twine &NameStr,
BasicBlock *InsertAtEnd)
: AllocationInst(Ty, ArraySize, Malloc,
Align, NameStr, InsertAtEnd) {}
MallocInst(const Type *Ty, Value *ArraySize,
- unsigned Align, const std::string &NameStr = "",
+ unsigned Align, const Twine &NameStr = "",
Instruction *InsertBefore = 0)
: AllocationInst(Ty, ArraySize,
Malloc, Align, NameStr, InsertBefore) {}
public:
explicit AllocaInst(const Type *Ty,
Value *ArraySize = 0,
- const std::string &NameStr = "",
+ const Twine &NameStr = "",
Instruction *InsertBefore = 0)
: AllocationInst(Ty, ArraySize, Alloca,
0, NameStr, InsertBefore) {}
AllocaInst(const Type *Ty,
- Value *ArraySize, const std::string &NameStr,
+ Value *ArraySize, const Twine &NameStr,
BasicBlock *InsertAtEnd)
: AllocationInst(Ty, ArraySize, Alloca, 0, NameStr, InsertAtEnd) {}
- AllocaInst(const Type *Ty, const std::string &NameStr,
+ AllocaInst(const Type *Ty, const Twine &NameStr,
Instruction *InsertBefore = 0)
: AllocationInst(Ty, 0, Alloca, 0, NameStr, InsertBefore) {}
- AllocaInst(const Type *Ty, const std::string &NameStr,
+ AllocaInst(const Type *Ty, const Twine &NameStr,
BasicBlock *InsertAtEnd)
: AllocationInst(Ty, 0, Alloca, 0, NameStr, InsertAtEnd) {}
AllocaInst(const Type *Ty, Value *ArraySize,
- unsigned Align, const std::string &NameStr = "",
+ unsigned Align, const Twine &NameStr = "",
Instruction *InsertBefore = 0)
: AllocationInst(Ty, ArraySize, Alloca,
Align, NameStr, InsertBefore) {}
AllocaInst(const Type *Ty, Value *ArraySize,
- unsigned Align, const std::string &NameStr,
+ unsigned Align, const Twine &NameStr,
BasicBlock *InsertAtEnd)
: AllocationInst(Ty, ArraySize, Alloca,
Align, NameStr, InsertAtEnd) {}
}
void AssertOK();
public:
- LoadInst(Value *Ptr, const std::string &NameStr, Instruction *InsertBefore);
- LoadInst(Value *Ptr, const std::string &NameStr, BasicBlock *InsertAtEnd);
- LoadInst(Value *Ptr, const std::string &NameStr, bool isVolatile = false,
+ LoadInst(Value *Ptr, const Twine &NameStr, Instruction *InsertBefore);
+ LoadInst(Value *Ptr, const Twine &NameStr, BasicBlock *InsertAtEnd);
+ LoadInst(Value *Ptr, const Twine &NameStr, bool isVolatile = false,
Instruction *InsertBefore = 0);
- LoadInst(Value *Ptr, const std::string &NameStr, bool isVolatile,
+ LoadInst(Value *Ptr, const Twine &NameStr, bool isVolatile,
unsigned Align, Instruction *InsertBefore = 0);
- LoadInst(Value *Ptr, const std::string &NameStr, bool isVolatile,
+ LoadInst(Value *Ptr, const Twine &NameStr, bool isVolatile,
BasicBlock *InsertAtEnd);
- LoadInst(Value *Ptr, const std::string &NameStr, bool isVolatile,
+ LoadInst(Value *Ptr, const Twine &NameStr, bool isVolatile,
unsigned Align, BasicBlock *InsertAtEnd);
LoadInst(Value *Ptr, const char *NameStr, Instruction *InsertBefore);
class GetElementPtrInst : public Instruction {
GetElementPtrInst(const GetElementPtrInst &GEPI);
void init(Value *Ptr, Value* const *Idx, unsigned NumIdx,
- const std::string &NameStr);
- void init(Value *Ptr, Value *Idx, const std::string &NameStr);
+ const Twine &NameStr);
+ void init(Value *Ptr, Value *Idx, const Twine &NameStr);
template<typename InputIterator>
void init(Value *Ptr, InputIterator IdxBegin, InputIterator IdxEnd,
- const std::string &NameStr,
+ const Twine &NameStr,
// This argument ensures that we have an iterator we can
// do arithmetic on in constant time
std::random_access_iterator_tag) {
inline GetElementPtrInst(Value *Ptr, InputIterator IdxBegin,
InputIterator IdxEnd,
unsigned Values,
- const std::string &NameStr,
+ const Twine &NameStr,
Instruction *InsertBefore);
template<typename InputIterator>
inline GetElementPtrInst(Value *Ptr,
InputIterator IdxBegin, InputIterator IdxEnd,
unsigned Values,
- const std::string &NameStr, BasicBlock *InsertAtEnd);
+ const Twine &NameStr, BasicBlock *InsertAtEnd);
/// Constructors - These two constructors are convenience methods because one
/// and two index getelementptr instructions are so common.
- GetElementPtrInst(Value *Ptr, Value *Idx, const std::string &NameStr = "",
+ GetElementPtrInst(Value *Ptr, Value *Idx, const Twine &NameStr = "",
Instruction *InsertBefore = 0);
GetElementPtrInst(Value *Ptr, Value *Idx,
- const std::string &NameStr, BasicBlock *InsertAtEnd);
+ const Twine &NameStr, BasicBlock *InsertAtEnd);
public:
template<typename InputIterator>
static GetElementPtrInst *Create(Value *Ptr, InputIterator IdxBegin,
InputIterator IdxEnd,
- const std::string &NameStr = "",
+ const Twine &NameStr = "",
Instruction *InsertBefore = 0) {
typename std::iterator_traits<InputIterator>::difference_type Values =
1 + std::distance(IdxBegin, IdxEnd);
template<typename InputIterator>
static GetElementPtrInst *Create(Value *Ptr,
InputIterator IdxBegin, InputIterator IdxEnd,
- const std::string &NameStr,
+ const Twine &NameStr,
BasicBlock *InsertAtEnd) {
typename std::iterator_traits<InputIterator>::difference_type Values =
1 + std::distance(IdxBegin, IdxEnd);
/// Constructors - These two creators are convenience methods because one
/// index getelementptr instructions are so common.
static GetElementPtrInst *Create(Value *Ptr, Value *Idx,
- const std::string &NameStr = "",
+ const Twine &NameStr = "",
Instruction *InsertBefore = 0) {
return new(2) GetElementPtrInst(Ptr, Idx, NameStr, InsertBefore);
}
static GetElementPtrInst *Create(Value *Ptr, Value *Idx,
- const std::string &NameStr,
+ const Twine &NameStr,
BasicBlock *InsertAtEnd) {
return new(2) GetElementPtrInst(Ptr, Idx, NameStr, InsertAtEnd);
}
InputIterator IdxBegin,
InputIterator IdxEnd,
unsigned Values,
- const std::string &NameStr,
+ const Twine &NameStr,
Instruction *InsertBefore)
: Instruction(PointerType::get(checkType(
getIndexedType(Ptr->getType(),
InputIterator IdxBegin,
InputIterator IdxEnd,
unsigned Values,
- const std::string &NameStr,
+ const Twine &NameStr,
BasicBlock *InsertAtEnd)
: Instruction(PointerType::get(checkType(
getIndexedType(Ptr->getType(),
Predicate pred, ///< The predicate to use for the comparison
Value *LHS, ///< The left-hand-side of the expression
Value *RHS, ///< The right-hand-side of the expression
- const std::string &NameStr = "" ///< Name of the instruction
+ const Twine &NameStr = "" ///< Name of the instruction
) : CmpInst(InsertBefore->getContext().makeCmpResultType(LHS->getType()),
Instruction::ICmp, pred, LHS, RHS, NameStr,
InsertBefore) {
Predicate pred, ///< The predicate to use for the comparison
Value *LHS, ///< The left-hand-side of the expression
Value *RHS, ///< The right-hand-side of the expression
- const std::string &NameStr = "" ///< Name of the instruction
+ const Twine &NameStr = "" ///< Name of the instruction
) : CmpInst(InsertAtEnd.getContext().makeCmpResultType(LHS->getType()),
Instruction::ICmp, pred, LHS, RHS, NameStr,
&InsertAtEnd) {
Predicate pred, ///< The predicate to use for the comparison
Value *LHS, ///< The left-hand-side of the expression
Value *RHS, ///< The right-hand-side of the expression
- const std::string &NameStr = "" ///< Name of the instruction
+ const Twine &NameStr = "" ///< Name of the instruction
) : CmpInst(Context.makeCmpResultType(LHS->getType()),
Instruction::ICmp, pred, LHS, RHS, NameStr) {
assert(pred >= CmpInst::FIRST_ICMP_PREDICATE &&
Predicate pred, ///< The predicate to use for the comparison
Value *LHS, ///< The left-hand-side of the expression
Value *RHS, ///< The right-hand-side of the expression
- const std::string &NameStr = "" ///< Name of the instruction
+ const Twine &NameStr = "" ///< Name of the instruction
) : CmpInst(InsertBefore->getContext().makeCmpResultType(LHS->getType()),
Instruction::FCmp, pred, LHS, RHS, NameStr,
InsertBefore) {
Predicate pred, ///< The predicate to use for the comparison
Value *LHS, ///< The left-hand-side of the expression
Value *RHS, ///< The right-hand-side of the expression
- const std::string &NameStr = "" ///< Name of the instruction
+ const Twine &NameStr = "" ///< Name of the instruction
) : CmpInst(InsertAtEnd.getContext().makeCmpResultType(LHS->getType()),
Instruction::FCmp, pred, LHS, RHS, NameStr,
&InsertAtEnd) {
Predicate pred, ///< The predicate to use for the comparison
Value *LHS, ///< The left-hand-side of the expression
Value *RHS, ///< The right-hand-side of the expression
- const std::string &NameStr = "" ///< Name of the instruction
+ const Twine &NameStr = "" ///< Name of the instruction
) : CmpInst(Context.makeCmpResultType(LHS->getType()),
Instruction::FCmp, pred, LHS, RHS, NameStr) {
assert(pred <= FCmpInst::LAST_FCMP_PREDICATE &&
template<typename InputIterator>
void init(Value *Func, InputIterator ArgBegin, InputIterator ArgEnd,
- const std::string &NameStr,
+ const Twine &NameStr,
// This argument ensures that we have an iterator we can
// do arithmetic on in constant time
std::random_access_iterator_tag) {
/// @brief Construct a CallInst from a range of arguments
template<typename InputIterator>
CallInst(Value *Func, InputIterator ArgBegin, InputIterator ArgEnd,
- const std::string &NameStr, Instruction *InsertBefore);
+ const Twine &NameStr, Instruction *InsertBefore);
/// Construct a CallInst given a range of arguments. InputIterator
/// must be a random-access iterator pointing to contiguous storage
/// @brief Construct a CallInst from a range of arguments
template<typename InputIterator>
inline CallInst(Value *Func, InputIterator ArgBegin, InputIterator ArgEnd,
- const std::string &NameStr, BasicBlock *InsertAtEnd);
+ const Twine &NameStr, BasicBlock *InsertAtEnd);
- CallInst(Value *F, Value *Actual, const std::string& NameStr,
+ CallInst(Value *F, Value *Actual, const Twine &NameStr,
Instruction *InsertBefore);
- CallInst(Value *F, Value *Actual, const std::string& NameStr,
+ CallInst(Value *F, Value *Actual, const Twine &NameStr,
BasicBlock *InsertAtEnd);
- explicit CallInst(Value *F, const std::string &NameStr,
+ explicit CallInst(Value *F, const Twine &NameStr,
Instruction *InsertBefore);
- CallInst(Value *F, const std::string &NameStr, BasicBlock *InsertAtEnd);
+ CallInst(Value *F, const Twine &NameStr, BasicBlock *InsertAtEnd);
public:
template<typename InputIterator>
static CallInst *Create(Value *Func,
InputIterator ArgBegin, InputIterator ArgEnd,
- const std::string &NameStr = "",
+ const Twine &NameStr = "",
Instruction *InsertBefore = 0) {
return new((unsigned)(ArgEnd - ArgBegin + 1))
CallInst(Func, ArgBegin, ArgEnd, NameStr, InsertBefore);
template<typename InputIterator>
static CallInst *Create(Value *Func,
InputIterator ArgBegin, InputIterator ArgEnd,
- const std::string &NameStr, BasicBlock *InsertAtEnd) {
+ const Twine &NameStr, BasicBlock *InsertAtEnd) {
return new((unsigned)(ArgEnd - ArgBegin + 1))
CallInst(Func, ArgBegin, ArgEnd, NameStr, InsertAtEnd);
}
static CallInst *Create(Value *F, Value *Actual,
- const std::string& NameStr = "",
+ const Twine &NameStr = "",
Instruction *InsertBefore = 0) {
return new(2) CallInst(F, Actual, NameStr, InsertBefore);
}
- static CallInst *Create(Value *F, Value *Actual, const std::string& NameStr,
+ static CallInst *Create(Value *F, Value *Actual, const Twine &NameStr,
BasicBlock *InsertAtEnd) {
return new(2) CallInst(F, Actual, NameStr, InsertAtEnd);
}
- static CallInst *Create(Value *F, const std::string &NameStr = "",
+ static CallInst *Create(Value *F, const Twine &NameStr = "",
Instruction *InsertBefore = 0) {
return new(1) CallInst(F, NameStr, InsertBefore);
}
- static CallInst *Create(Value *F, const std::string &NameStr,
+ static CallInst *Create(Value *F, const Twine &NameStr,
BasicBlock *InsertAtEnd) {
return new(1) CallInst(F, NameStr, InsertAtEnd);
}
template<typename InputIterator>
CallInst::CallInst(Value *Func, InputIterator ArgBegin, InputIterator ArgEnd,
- const std::string &NameStr, BasicBlock *InsertAtEnd)
+ const Twine &NameStr, BasicBlock *InsertAtEnd)
: Instruction(cast<FunctionType>(cast<PointerType>(Func->getType())
->getElementType())->getReturnType(),
Instruction::Call,
template<typename InputIterator>
CallInst::CallInst(Value *Func, InputIterator ArgBegin, InputIterator ArgEnd,
- const std::string &NameStr, Instruction *InsertBefore)
+ const Twine &NameStr, Instruction *InsertBefore)
: Instruction(cast<FunctionType>(cast<PointerType>(Func->getType())
->getElementType())->getReturnType(),
Instruction::Call,
: Instruction(SI.getType(), SI.getOpcode(), &Op<0>(), 3) {
init(SI.Op<0>(), SI.Op<1>(), SI.Op<2>());
}
- SelectInst(Value *C, Value *S1, Value *S2, const std::string &NameStr,
+ SelectInst(Value *C, Value *S1, Value *S2, const Twine &NameStr,
Instruction *InsertBefore)
: Instruction(S1->getType(), Instruction::Select,
&Op<0>(), 3, InsertBefore) {
init(C, S1, S2);
setName(NameStr);
}
- SelectInst(Value *C, Value *S1, Value *S2, const std::string &NameStr,
+ SelectInst(Value *C, Value *S1, Value *S2, const Twine &NameStr,
BasicBlock *InsertAtEnd)
: Instruction(S1->getType(), Instruction::Select,
&Op<0>(), 3, InsertAtEnd) {
}
public:
static SelectInst *Create(Value *C, Value *S1, Value *S2,
- const std::string &NameStr = "",
+ const Twine &NameStr = "",
Instruction *InsertBefore = 0) {
return new(3) SelectInst(C, S1, S2, NameStr, InsertBefore);
}
static SelectInst *Create(Value *C, Value *S1, Value *S2,
- const std::string &NameStr,
+ const Twine &NameStr,
BasicBlock *InsertAtEnd) {
return new(3) SelectInst(C, S1, S2, NameStr, InsertAtEnd);
}
VAArgInst(const VAArgInst &VAA)
: UnaryInstruction(VAA.getType(), VAArg, VAA.getOperand(0)) {}
public:
- VAArgInst(Value *List, const Type *Ty, const std::string &NameStr = "",
+ VAArgInst(Value *List, const Type *Ty, const Twine &NameStr = "",
Instruction *InsertBefore = 0)
: UnaryInstruction(Ty, VAArg, List, InsertBefore) {
setName(NameStr);
}
- VAArgInst(Value *List, const Type *Ty, const std::string &NameStr,
+ VAArgInst(Value *List, const Type *Ty, const Twine &NameStr,
BasicBlock *InsertAtEnd)
: UnaryInstruction(Ty, VAArg, List, InsertAtEnd) {
setName(NameStr);
Op<1>() = EE.Op<1>();
}
- ExtractElementInst(Value *Vec, Value *Idx, const std::string &NameStr = "",
+ ExtractElementInst(Value *Vec, Value *Idx, const Twine &NameStr = "",
Instruction *InsertBefore = 0);
- ExtractElementInst(Value *Vec, Value *Idx, const std::string &NameStr,
+ ExtractElementInst(Value *Vec, Value *Idx, const Twine &NameStr,
BasicBlock *InsertAtEnd);
public:
static ExtractElementInst *Create(const ExtractElementInst &EE) {
}
static ExtractElementInst *Create(Value *Vec, Value *Idx,
- const std::string &NameStr = "",
+ const Twine &NameStr = "",
Instruction *InsertBefore = 0) {
return new(2) ExtractElementInst(Vec, Idx, NameStr, InsertBefore);
}
static ExtractElementInst *Create(Value *Vec, Value *Idx,
- const std::string &NameStr,
+ const Twine &NameStr,
BasicBlock *InsertAtEnd) {
return new(2) ExtractElementInst(Vec, Idx, NameStr, InsertAtEnd);
}
class InsertElementInst : public Instruction {
InsertElementInst(const InsertElementInst &IE);
InsertElementInst(Value *Vec, Value *NewElt, Value *Idx,
- const std::string &NameStr = "",
+ const Twine &NameStr = "",
Instruction *InsertBefore = 0);
InsertElementInst(Value *Vec, Value *NewElt, Value *Idx,
- const std::string &NameStr, BasicBlock *InsertAtEnd);
+ const Twine &NameStr, BasicBlock *InsertAtEnd);
public:
static InsertElementInst *Create(const InsertElementInst &IE) {
return new(IE.getNumOperands()) InsertElementInst(IE);
}
static InsertElementInst *Create(Value *Vec, Value *NewElt, Value *Idx,
- const std::string &NameStr = "",
+ const Twine &NameStr = "",
Instruction *InsertBefore = 0) {
return new(3) InsertElementInst(Vec, NewElt, Idx, NameStr, InsertBefore);
}
static InsertElementInst *Create(Value *Vec, Value *NewElt, Value *Idx,
- const std::string &NameStr,
+ const Twine &NameStr,
BasicBlock *InsertAtEnd) {
return new(3) InsertElementInst(Vec, NewElt, Idx, NameStr, InsertAtEnd);
}
return User::operator new(s, 3);
}
ShuffleVectorInst(Value *V1, Value *V2, Value *Mask,
- const std::string &NameStr = "",
+ const Twine &NameStr = "",
Instruction *InsertBefor = 0);
ShuffleVectorInst(Value *V1, Value *V2, Value *Mask,
- const std::string &NameStr, BasicBlock *InsertAtEnd);
+ const Twine &NameStr, BasicBlock *InsertAtEnd);
/// isValidOperands - Return true if a shufflevector instruction can be
/// formed with the specified operands.
ExtractValueInst(const ExtractValueInst &EVI);
void init(const unsigned *Idx, unsigned NumIdx,
- const std::string &NameStr);
- void init(unsigned Idx, const std::string &NameStr);
+ const Twine &NameStr);
+ void init(unsigned Idx, const Twine &NameStr);
template<typename InputIterator>
void init(InputIterator IdxBegin, InputIterator IdxEnd,
- const std::string &NameStr,
+ const Twine &NameStr,
// This argument ensures that we have an iterator we can
// do arithmetic on in constant time
std::random_access_iterator_tag) {
template<typename InputIterator>
inline ExtractValueInst(Value *Agg, InputIterator IdxBegin,
InputIterator IdxEnd,
- const std::string &NameStr,
+ const Twine &NameStr,
Instruction *InsertBefore);
template<typename InputIterator>
inline ExtractValueInst(Value *Agg,
InputIterator IdxBegin, InputIterator IdxEnd,
- const std::string &NameStr, BasicBlock *InsertAtEnd);
+ const Twine &NameStr, BasicBlock *InsertAtEnd);
// allocate space for exactly one operand
void *operator new(size_t s) {
template<typename InputIterator>
static ExtractValueInst *Create(Value *Agg, InputIterator IdxBegin,
InputIterator IdxEnd,
- const std::string &NameStr = "",
+ const Twine &NameStr = "",
Instruction *InsertBefore = 0) {
return new
ExtractValueInst(Agg, IdxBegin, IdxEnd, NameStr, InsertBefore);
template<typename InputIterator>
static ExtractValueInst *Create(Value *Agg,
InputIterator IdxBegin, InputIterator IdxEnd,
- const std::string &NameStr,
+ const Twine &NameStr,
BasicBlock *InsertAtEnd) {
return new ExtractValueInst(Agg, IdxBegin, IdxEnd, NameStr, InsertAtEnd);
}
/// index extractvalue instructions are much more common than those with
/// more than one.
static ExtractValueInst *Create(Value *Agg, unsigned Idx,
- const std::string &NameStr = "",
+ const Twine &NameStr = "",
Instruction *InsertBefore = 0) {
unsigned Idxs[1] = { Idx };
return new ExtractValueInst(Agg, Idxs, Idxs + 1, NameStr, InsertBefore);
}
static ExtractValueInst *Create(Value *Agg, unsigned Idx,
- const std::string &NameStr,
+ const Twine &NameStr,
BasicBlock *InsertAtEnd) {
unsigned Idxs[1] = { Idx };
return new ExtractValueInst(Agg, Idxs, Idxs + 1, NameStr, InsertAtEnd);
ExtractValueInst::ExtractValueInst(Value *Agg,
InputIterator IdxBegin,
InputIterator IdxEnd,
- const std::string &NameStr,
+ const Twine &NameStr,
Instruction *InsertBefore)
: UnaryInstruction(checkType(getIndexedType(Agg->getType(),
IdxBegin, IdxEnd)),
ExtractValueInst::ExtractValueInst(Value *Agg,
InputIterator IdxBegin,
InputIterator IdxEnd,
- const std::string &NameStr,
+ const Twine &NameStr,
BasicBlock *InsertAtEnd)
: UnaryInstruction(checkType(getIndexedType(Agg->getType(),
IdxBegin, IdxEnd)),
void *operator new(size_t, unsigned); // Do not implement
InsertValueInst(const InsertValueInst &IVI);
void init(Value *Agg, Value *Val, const unsigned *Idx, unsigned NumIdx,
- const std::string &NameStr);
- void init(Value *Agg, Value *Val, unsigned Idx, const std::string &NameStr);
+ const Twine &NameStr);
+ void init(Value *Agg, Value *Val, unsigned Idx, const Twine &NameStr);
template<typename InputIterator>
void init(Value *Agg, Value *Val,
InputIterator IdxBegin, InputIterator IdxEnd,
- const std::string &NameStr,
+ const Twine &NameStr,
// This argument ensures that we have an iterator we can
// do arithmetic on in constant time
std::random_access_iterator_tag) {
template<typename InputIterator>
inline InsertValueInst(Value *Agg, Value *Val, InputIterator IdxBegin,
InputIterator IdxEnd,
- const std::string &NameStr,
+ const Twine &NameStr,
Instruction *InsertBefore);
template<typename InputIterator>
inline InsertValueInst(Value *Agg, Value *Val,
InputIterator IdxBegin, InputIterator IdxEnd,
- const std::string &NameStr, BasicBlock *InsertAtEnd);
+ const Twine &NameStr, BasicBlock *InsertAtEnd);
/// Constructors - These two constructors are convenience methods because one
/// and two index insertvalue instructions are so common.
InsertValueInst(Value *Agg, Value *Val,
- unsigned Idx, const std::string &NameStr = "",
+ unsigned Idx, const Twine &NameStr = "",
Instruction *InsertBefore = 0);
InsertValueInst(Value *Agg, Value *Val, unsigned Idx,
- const std::string &NameStr, BasicBlock *InsertAtEnd);
+ const Twine &NameStr, BasicBlock *InsertAtEnd);
public:
// allocate space for exactly two operands
void *operator new(size_t s) {
template<typename InputIterator>
static InsertValueInst *Create(Value *Agg, Value *Val, InputIterator IdxBegin,
InputIterator IdxEnd,
- const std::string &NameStr = "",
+ const Twine &NameStr = "",
Instruction *InsertBefore = 0) {
return new InsertValueInst(Agg, Val, IdxBegin, IdxEnd,
NameStr, InsertBefore);
template<typename InputIterator>
static InsertValueInst *Create(Value *Agg, Value *Val,
InputIterator IdxBegin, InputIterator IdxEnd,
- const std::string &NameStr,
+ const Twine &NameStr,
BasicBlock *InsertAtEnd) {
return new InsertValueInst(Agg, Val, IdxBegin, IdxEnd,
NameStr, InsertAtEnd);
/// index insertvalue instructions are much more common than those with
/// more than one.
static InsertValueInst *Create(Value *Agg, Value *Val, unsigned Idx,
- const std::string &NameStr = "",
+ const Twine &NameStr = "",
Instruction *InsertBefore = 0) {
return new InsertValueInst(Agg, Val, Idx, NameStr, InsertBefore);
}
static InsertValueInst *Create(Value *Agg, Value *Val, unsigned Idx,
- const std::string &NameStr,
+ const Twine &NameStr,
BasicBlock *InsertAtEnd) {
return new InsertValueInst(Agg, Val, Idx, NameStr, InsertAtEnd);
}
Value *Val,
InputIterator IdxBegin,
InputIterator IdxEnd,
- const std::string &NameStr,
+ const Twine &NameStr,
Instruction *InsertBefore)
: Instruction(Agg->getType(), InsertValue,
OperandTraits<InsertValueInst>::op_begin(this),
Value *Val,
InputIterator IdxBegin,
InputIterator IdxEnd,
- const std::string &NameStr,
+ const Twine &NameStr,
BasicBlock *InsertAtEnd)
: Instruction(Agg->getType(), InsertValue,
OperandTraits<InsertValueInst>::op_begin(this),
void *operator new(size_t s) {
return User::operator new(s, 0);
}
- explicit PHINode(const Type *Ty, const std::string &NameStr = "",
+ explicit PHINode(const Type *Ty, const Twine &NameStr = "",
Instruction *InsertBefore = 0)
: Instruction(Ty, Instruction::PHI, 0, 0, InsertBefore),
ReservedSpace(0) {
setName(NameStr);
}
- PHINode(const Type *Ty, const std::string &NameStr, BasicBlock *InsertAtEnd)
+ PHINode(const Type *Ty, const Twine &NameStr, BasicBlock *InsertAtEnd)
: Instruction(Ty, Instruction::PHI, 0, 0, InsertAtEnd),
ReservedSpace(0) {
setName(NameStr);
}
public:
- static PHINode *Create(const Type *Ty, const std::string &NameStr = "",
+ static PHINode *Create(const Type *Ty, const Twine &NameStr = "",
Instruction *InsertBefore = 0) {
return new PHINode(Ty, NameStr, InsertBefore);
}
- static PHINode *Create(const Type *Ty, const std::string &NameStr,
+ static PHINode *Create(const Type *Ty, const Twine &NameStr,
BasicBlock *InsertAtEnd) {
return new PHINode(Ty, NameStr, InsertAtEnd);
}
template<typename InputIterator>
void init(Value *Func, BasicBlock *IfNormal, BasicBlock *IfException,
InputIterator ArgBegin, InputIterator ArgEnd,
- const std::string &NameStr,
+ const Twine &NameStr,
// This argument ensures that we have an iterator we can
// do arithmetic on in constant time
std::random_access_iterator_tag) {
inline InvokeInst(Value *Func, BasicBlock *IfNormal, BasicBlock *IfException,
InputIterator ArgBegin, InputIterator ArgEnd,
unsigned Values,
- const std::string &NameStr, Instruction *InsertBefore);
+ const Twine &NameStr, Instruction *InsertBefore);
/// Construct an InvokeInst given a range of arguments.
/// InputIterator must be a random-access iterator pointing to
inline InvokeInst(Value *Func, BasicBlock *IfNormal, BasicBlock *IfException,
InputIterator ArgBegin, InputIterator ArgEnd,
unsigned Values,
- const std::string &NameStr, BasicBlock *InsertAtEnd);
+ const Twine &NameStr, BasicBlock *InsertAtEnd);
public:
template<typename InputIterator>
static InvokeInst *Create(Value *Func,
BasicBlock *IfNormal, BasicBlock *IfException,
InputIterator ArgBegin, InputIterator ArgEnd,
- const std::string &NameStr = "",
+ const Twine &NameStr = "",
Instruction *InsertBefore = 0) {
unsigned Values(ArgEnd - ArgBegin + 3);
return new(Values) InvokeInst(Func, IfNormal, IfException, ArgBegin, ArgEnd,
static InvokeInst *Create(Value *Func,
BasicBlock *IfNormal, BasicBlock *IfException,
InputIterator ArgBegin, InputIterator ArgEnd,
- const std::string &NameStr,
+ const Twine &NameStr,
BasicBlock *InsertAtEnd) {
unsigned Values(ArgEnd - ArgBegin + 3);
return new(Values) InvokeInst(Func, IfNormal, IfException, ArgBegin, ArgEnd,
BasicBlock *IfNormal, BasicBlock *IfException,
InputIterator ArgBegin, InputIterator ArgEnd,
unsigned Values,
- const std::string &NameStr, Instruction *InsertBefore)
+ const Twine &NameStr, Instruction *InsertBefore)
: TerminatorInst(cast<FunctionType>(cast<PointerType>(Func->getType())
->getElementType())->getReturnType(),
Instruction::Invoke,
BasicBlock *IfNormal, BasicBlock *IfException,
InputIterator ArgBegin, InputIterator ArgEnd,
unsigned Values,
- const std::string &NameStr, BasicBlock *InsertAtEnd)
+ const Twine &NameStr, BasicBlock *InsertAtEnd)
: TerminatorInst(cast<FunctionType>(cast<PointerType>(Func->getType())
->getElementType())->getReturnType(),
Instruction::Invoke,
TruncInst(
Value *S, ///< The value to be truncated
const Type *Ty, ///< The (smaller) type to truncate to
- const std::string &NameStr = "", ///< A name for the new instruction
+ const Twine &NameStr = "", ///< A name for the new instruction
Instruction *InsertBefore = 0 ///< Where to insert the new instruction
);
TruncInst(
Value *S, ///< The value to be truncated
const Type *Ty, ///< The (smaller) type to truncate to
- const std::string &NameStr, ///< A name for the new instruction
+ const Twine &NameStr, ///< A name for the new instruction
BasicBlock *InsertAtEnd ///< The block to insert the instruction into
);
ZExtInst(
Value *S, ///< The value to be zero extended
const Type *Ty, ///< The type to zero extend to
- const std::string &NameStr = "", ///< A name for the new instruction
+ const Twine &NameStr = "", ///< A name for the new instruction
Instruction *InsertBefore = 0 ///< Where to insert the new instruction
);
ZExtInst(
Value *S, ///< The value to be zero extended
const Type *Ty, ///< The type to zero extend to
- const std::string &NameStr, ///< A name for the new instruction
+ const Twine &NameStr, ///< A name for the new instruction
BasicBlock *InsertAtEnd ///< The block to insert the instruction into
);
SExtInst(
Value *S, ///< The value to be sign extended
const Type *Ty, ///< The type to sign extend to
- const std::string &NameStr = "", ///< A name for the new instruction
+ const Twine &NameStr = "", ///< A name for the new instruction
Instruction *InsertBefore = 0 ///< Where to insert the new instruction
);
SExtInst(
Value *S, ///< The value to be sign extended
const Type *Ty, ///< The type to sign extend to
- const std::string &NameStr, ///< A name for the new instruction
+ const Twine &NameStr, ///< A name for the new instruction
BasicBlock *InsertAtEnd ///< The block to insert the instruction into
);
FPTruncInst(
Value *S, ///< The value to be truncated
const Type *Ty, ///< The type to truncate to
- const std::string &NameStr = "", ///< A name for the new instruction
+ const Twine &NameStr = "", ///< A name for the new instruction
Instruction *InsertBefore = 0 ///< Where to insert the new instruction
);
FPTruncInst(
Value *S, ///< The value to be truncated
const Type *Ty, ///< The type to truncate to
- const std::string &NameStr, ///< A name for the new instruction
+ const Twine &NameStr, ///< A name for the new instruction
BasicBlock *InsertAtEnd ///< The block to insert the instruction into
);
FPExtInst(
Value *S, ///< The value to be extended
const Type *Ty, ///< The type to extend to
- const std::string &NameStr = "", ///< A name for the new instruction
+ const Twine &NameStr = "", ///< A name for the new instruction
Instruction *InsertBefore = 0 ///< Where to insert the new instruction
);
FPExtInst(
Value *S, ///< The value to be extended
const Type *Ty, ///< The type to extend to
- const std::string &NameStr, ///< A name for the new instruction
+ const Twine &NameStr, ///< A name for the new instruction
BasicBlock *InsertAtEnd ///< The block to insert the instruction into
);
UIToFPInst(
Value *S, ///< The value to be converted
const Type *Ty, ///< The type to convert to
- const std::string &NameStr = "", ///< A name for the new instruction
+ const Twine &NameStr = "", ///< A name for the new instruction
Instruction *InsertBefore = 0 ///< Where to insert the new instruction
);
UIToFPInst(
Value *S, ///< The value to be converted
const Type *Ty, ///< The type to convert to
- const std::string &NameStr, ///< A name for the new instruction
+ const Twine &NameStr, ///< A name for the new instruction
BasicBlock *InsertAtEnd ///< The block to insert the instruction into
);
SIToFPInst(
Value *S, ///< The value to be converted
const Type *Ty, ///< The type to convert to
- const std::string &NameStr = "", ///< A name for the new instruction
+ const Twine &NameStr = "", ///< A name for the new instruction
Instruction *InsertBefore = 0 ///< Where to insert the new instruction
);
SIToFPInst(
Value *S, ///< The value to be converted
const Type *Ty, ///< The type to convert to
- const std::string &NameStr, ///< A name for the new instruction
+ const Twine &NameStr, ///< A name for the new instruction
BasicBlock *InsertAtEnd ///< The block to insert the instruction into
);
FPToUIInst(
Value *S, ///< The value to be converted
const Type *Ty, ///< The type to convert to
- const std::string &NameStr = "", ///< A name for the new instruction
+ const Twine &NameStr = "", ///< A name for the new instruction
Instruction *InsertBefore = 0 ///< Where to insert the new instruction
);
FPToUIInst(
Value *S, ///< The value to be converted
const Type *Ty, ///< The type to convert to
- const std::string &NameStr, ///< A name for the new instruction
+ const Twine &NameStr, ///< A name for the new instruction
BasicBlock *InsertAtEnd ///< Where to insert the new instruction
);
FPToSIInst(
Value *S, ///< The value to be converted
const Type *Ty, ///< The type to convert to
- const std::string &NameStr = "", ///< A name for the new instruction
+ const Twine &NameStr = "", ///< A name for the new instruction
Instruction *InsertBefore = 0 ///< Where to insert the new instruction
);
FPToSIInst(
Value *S, ///< The value to be converted
const Type *Ty, ///< The type to convert to
- const std::string &NameStr, ///< A name for the new instruction
+ const Twine &NameStr, ///< A name for the new instruction
BasicBlock *InsertAtEnd ///< The block to insert the instruction into
);
IntToPtrInst(
Value *S, ///< The value to be converted
const Type *Ty, ///< The type to convert to
- const std::string &NameStr = "", ///< A name for the new instruction
+ const Twine &NameStr = "", ///< A name for the new instruction
Instruction *InsertBefore = 0 ///< Where to insert the new instruction
);
IntToPtrInst(
Value *S, ///< The value to be converted
const Type *Ty, ///< The type to convert to
- const std::string &NameStr, ///< A name for the new instruction
+ const Twine &NameStr, ///< A name for the new instruction
BasicBlock *InsertAtEnd ///< The block to insert the instruction into
);
PtrToIntInst(
Value *S, ///< The value to be converted
const Type *Ty, ///< The type to convert to
- const std::string &NameStr = "", ///< A name for the new instruction
+ const Twine &NameStr = "", ///< A name for the new instruction
Instruction *InsertBefore = 0 ///< Where to insert the new instruction
);
PtrToIntInst(
Value *S, ///< The value to be converted
const Type *Ty, ///< The type to convert to
- const std::string &NameStr, ///< A name for the new instruction
+ const Twine &NameStr, ///< A name for the new instruction
BasicBlock *InsertAtEnd ///< The block to insert the instruction into
);
BitCastInst(
Value *S, ///< The value to be casted
const Type *Ty, ///< The type to casted to
- const std::string &NameStr = "", ///< A name for the new instruction
+ const Twine &NameStr = "", ///< A name for the new instruction
Instruction *InsertBefore = 0 ///< Where to insert the new instruction
);
BitCastInst(
Value *S, ///< The value to be casted
const Type *Ty, ///< The type to casted to
- const std::string &NameStr, ///< A name for the new instruction
+ const Twine &NameStr, ///< A name for the new instruction
BasicBlock *InsertAtEnd ///< The block to insert the instruction into
);
#include "llvm/AbstractTypeUser.h"
#include "llvm/Use.h"
#include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/Twine.h"
#include "llvm/Support/Casting.h"
#include <iosfwd>
#include <string>
/// getName()/getNameStr() - Return the name of the specified value,
/// *constructing a string* to hold it. Because these are guaranteed to
/// construct a string, they are very expensive and should be avoided.
- std::string getName() const { return getNameStr(); }
+ StringRef getName() const { return StringRef(getNameStart(), getNameLen()); }
std::string getNameStr() const;
StringRef getNameRef() const;
- void setName(const std::string &name);
+ void setName(const Twine &Name);
void setName(const char *Name, unsigned NameLen);
void setName(const char *Name); // Takes a null-terminated string.
// Error - Simple wrapper function to conditionally assign to E and return true.
// This just makes error return conditions a little bit simpler...
-static inline bool Error(std::string *E, const std::string &Message) {
- if (E) *E = Message;
+static inline bool Error(std::string *E, const Twine &Message) {
+ if (E) *E = Message.str();
return true;
}
newOp1, newOp2,
C->getName()+".expr");
else if (ExtractElementInst* E = dyn_cast<ExtractElementInst>(U))
- newVal = ExtractElementInst::Create(newOp1, newOp2, E->getName()+".expr");
+ newVal = ExtractElementInst::Create(newOp1, newOp2,
+ E->getName()+".expr");
uint32_t v = VN.lookup_or_add(newVal);
if (StoreInst *SI = dyn_cast<StoreInst>(User)) {
assert(SI->getOperand(0) != Ptr && "Consistency error!");
- Value *Old = Builder.CreateLoad(NewAI, (NewAI->getName()+".in").c_str());
+ // FIXME: Remove once builder has Twine API.
+ Value *Old = Builder.CreateLoad(NewAI, (NewAI->getName()+".in").str().c_str());
Value *New = ConvertScalar_InsertValue(SI->getOperand(0), Old, Offset,
Builder);
Builder.CreateStore(New, NewAI);
for (unsigned i = 1; i != NumBytes; ++i)
APVal |= APVal << 8;
- Value *Old = Builder.CreateLoad(NewAI, (NewAI->getName()+".in").c_str());
+ // FIXME: Remove once builder has Twine API.
+ Value *Old = Builder.CreateLoad(NewAI, (NewAI->getName()+".in").str().c_str());
Value *New = ConvertScalar_InsertValue(
ConstantInt::get(User->getContext(), APVal),
Old, Offset, Builder);
template class SymbolTableListTraits<Instruction, BasicBlock>;
-BasicBlock::BasicBlock(const std::string &Name, Function *NewParent,
+BasicBlock::BasicBlock(const Twine &Name, Function *NewParent,
BasicBlock *InsertBefore)
: Value(Type::LabelTy, Value::BasicBlockVal), Parent(0) {
/// cause a degenerate basic block to be formed, having a terminator inside of
/// the basic block).
///
-BasicBlock *BasicBlock::splitBasicBlock(iterator I, const std::string &BBName) {
+BasicBlock *BasicBlock::splitBasicBlock(iterator I, const Twine &BBName) {
assert(getTerminator() && "Can't use splitBasicBlock on degenerate BB!");
assert(I != InstList.end() &&
"Trying to get me to create degenerate basic block!");
// Argument Implementation
//===----------------------------------------------------------------------===//
-Argument::Argument(const Type *Ty, const std::string &Name, Function *Par)
+Argument::Argument(const Type *Ty, const Twine &Name, Function *Par)
: Value(Ty, Value::ArgumentVal) {
Parent = 0;
//===----------------------------------------------------------------------===//
Function::Function(const FunctionType *Ty, LinkageTypes Linkage,
- const std::string &name, Module *ParentModule)
+ const Twine &name, Module *ParentModule)
: GlobalValue(PointerType::getUnqual(Ty),
Value::FunctionVal, 0, 0, Linkage, name) {
assert(FunctionType::isValidReturnType(getReturnType()) &&
GlobalVariable::GlobalVariable(LLVMContext &Context, const Type *Ty,
bool constant, LinkageTypes Link,
- Constant *InitVal, const std::string &Name,
+ Constant *InitVal, const Twine &Name,
bool ThreadLocal, unsigned AddressSpace)
: GlobalValue(Context.getPointerType(Ty, AddressSpace),
Value::GlobalVariableVal,
GlobalVariable::GlobalVariable(Module &M, const Type *Ty, bool constant,
LinkageTypes Link, Constant *InitVal,
- const std::string &Name,
+ const Twine &Name,
GlobalVariable *Before, bool ThreadLocal,
unsigned AddressSpace)
: GlobalValue(M.getContext().getPointerType(Ty, AddressSpace),
assert(FTy->getNumParams() == 0 && "Calling a function with bad signature");
}
-CallInst::CallInst(Value *Func, Value* Actual, const std::string &Name,
+CallInst::CallInst(Value *Func, Value* Actual, const Twine &Name,
Instruction *InsertBefore)
: Instruction(cast<FunctionType>(cast<PointerType>(Func->getType())
->getElementType())->getReturnType(),
setName(Name);
}
-CallInst::CallInst(Value *Func, Value* Actual, const std::string &Name,
+CallInst::CallInst(Value *Func, Value* Actual, const Twine &Name,
BasicBlock *InsertAtEnd)
: Instruction(cast<FunctionType>(cast<PointerType>(Func->getType())
->getElementType())->getReturnType(),
init(Func, Actual);
setName(Name);
}
-CallInst::CallInst(Value *Func, const std::string &Name,
+CallInst::CallInst(Value *Func, const Twine &Name,
Instruction *InsertBefore)
: Instruction(cast<FunctionType>(cast<PointerType>(Func->getType())
->getElementType())->getReturnType(),
setName(Name);
}
-CallInst::CallInst(Value *Func, const std::string &Name,
+CallInst::CallInst(Value *Func, const Twine &Name,
BasicBlock *InsertAtEnd)
: Instruction(cast<FunctionType>(cast<PointerType>(Func->getType())
->getElementType())->getReturnType(),
}
AllocationInst::AllocationInst(const Type *Ty, Value *ArraySize, unsigned iTy,
- unsigned Align, const std::string &Name,
+ unsigned Align, const Twine &Name,
Instruction *InsertBefore)
: UnaryInstruction(Ty->getContext().getPointerTypeUnqual(Ty), iTy,
getAISize(Ty->getContext(), ArraySize), InsertBefore) {
}
AllocationInst::AllocationInst(const Type *Ty, Value *ArraySize, unsigned iTy,
- unsigned Align, const std::string &Name,
+ unsigned Align, const Twine &Name,
BasicBlock *InsertAtEnd)
: UnaryInstruction(Ty->getContext().getPointerTypeUnqual(Ty), iTy,
getAISize(Ty->getContext(), ArraySize), InsertAtEnd) {
"Ptr must have pointer type.");
}
-LoadInst::LoadInst(Value *Ptr, const std::string &Name, Instruction *InsertBef)
+LoadInst::LoadInst(Value *Ptr, const Twine &Name, Instruction *InsertBef)
: UnaryInstruction(cast<PointerType>(Ptr->getType())->getElementType(),
Load, Ptr, InsertBef) {
setVolatile(false);
setName(Name);
}
-LoadInst::LoadInst(Value *Ptr, const std::string &Name, BasicBlock *InsertAE)
+LoadInst::LoadInst(Value *Ptr, const Twine &Name, BasicBlock *InsertAE)
: UnaryInstruction(cast<PointerType>(Ptr->getType())->getElementType(),
Load, Ptr, InsertAE) {
setVolatile(false);
setName(Name);
}
-LoadInst::LoadInst(Value *Ptr, const std::string &Name, bool isVolatile,
+LoadInst::LoadInst(Value *Ptr, const Twine &Name, bool isVolatile,
Instruction *InsertBef)
: UnaryInstruction(cast<PointerType>(Ptr->getType())->getElementType(),
Load, Ptr, InsertBef) {
setName(Name);
}
-LoadInst::LoadInst(Value *Ptr, const std::string &Name, bool isVolatile,
+LoadInst::LoadInst(Value *Ptr, const Twine &Name, bool isVolatile,
unsigned Align, Instruction *InsertBef)
: UnaryInstruction(cast<PointerType>(Ptr->getType())->getElementType(),
Load, Ptr, InsertBef) {
setName(Name);
}
-LoadInst::LoadInst(Value *Ptr, const std::string &Name, bool isVolatile,
+LoadInst::LoadInst(Value *Ptr, const Twine &Name, bool isVolatile,
unsigned Align, BasicBlock *InsertAE)
: UnaryInstruction(cast<PointerType>(Ptr->getType())->getElementType(),
Load, Ptr, InsertAE) {
setName(Name);
}
-LoadInst::LoadInst(Value *Ptr, const std::string &Name, bool isVolatile,
+LoadInst::LoadInst(Value *Ptr, const Twine &Name, bool isVolatile,
BasicBlock *InsertAE)
: UnaryInstruction(cast<PointerType>(Ptr->getType())->getElementType(),
Load, Ptr, InsertAE) {
}
void GetElementPtrInst::init(Value *Ptr, Value* const *Idx, unsigned NumIdx,
- const std::string &Name) {
+ const Twine &Name) {
assert(NumOperands == 1+NumIdx && "NumOperands not initialized?");
Use *OL = OperandList;
OL[0] = Ptr;
setName(Name);
}
-void GetElementPtrInst::init(Value *Ptr, Value *Idx, const std::string &Name) {
+void GetElementPtrInst::init(Value *Ptr, Value *Idx, const Twine &Name) {
assert(NumOperands == 2 && "NumOperands not initialized?");
Use *OL = OperandList;
OL[0] = Ptr;
}
GetElementPtrInst::GetElementPtrInst(Value *Ptr, Value *Idx,
- const std::string &Name, Instruction *InBe)
+ const Twine &Name, Instruction *InBe)
: Instruction(Ptr->getType()->getContext().getPointerType(
checkType(getIndexedType(Ptr->getType(),Idx)), retrieveAddrSpace(Ptr)),
GetElementPtr,
}
GetElementPtrInst::GetElementPtrInst(Value *Ptr, Value *Idx,
- const std::string &Name, BasicBlock *IAE)
+ const Twine &Name, BasicBlock *IAE)
: Instruction(Ptr->getType()->getContext().getPointerType(
checkType(getIndexedType(Ptr->getType(),Idx)),
retrieveAddrSpace(Ptr)),
//===----------------------------------------------------------------------===//
ExtractElementInst::ExtractElementInst(Value *Val, Value *Index,
- const std::string &Name,
+ const Twine &Name,
Instruction *InsertBef)
: Instruction(cast<VectorType>(Val->getType())->getElementType(),
ExtractElement,
}
ExtractElementInst::ExtractElementInst(Value *Val, Value *Index,
- const std::string &Name,
+ const Twine &Name,
BasicBlock *InsertAE)
: Instruction(cast<VectorType>(Val->getType())->getElementType(),
ExtractElement,
Op<2>() = IE.Op<2>();
}
InsertElementInst::InsertElementInst(Value *Vec, Value *Elt, Value *Index,
- const std::string &Name,
+ const Twine &Name,
Instruction *InsertBef)
: Instruction(Vec->getType(), InsertElement,
OperandTraits<InsertElementInst>::op_begin(this),
}
InsertElementInst::InsertElementInst(Value *Vec, Value *Elt, Value *Index,
- const std::string &Name,
+ const Twine &Name,
BasicBlock *InsertAE)
: Instruction(Vec->getType(), InsertElement,
OperandTraits<InsertElementInst>::op_begin(this),
}
ShuffleVectorInst::ShuffleVectorInst(Value *V1, Value *V2, Value *Mask,
- const std::string &Name,
+ const Twine &Name,
Instruction *InsertBefore)
: Instruction(V1->getType()->getContext().getVectorType(
cast<VectorType>(V1->getType())->getElementType(),
}
ShuffleVectorInst::ShuffleVectorInst(Value *V1, Value *V2, Value *Mask,
- const std::string &Name,
+ const Twine &Name,
BasicBlock *InsertAtEnd)
: Instruction(V1->getType(), ShuffleVector,
OperandTraits<ShuffleVectorInst>::op_begin(this),
//===----------------------------------------------------------------------===//
void InsertValueInst::init(Value *Agg, Value *Val, const unsigned *Idx,
- unsigned NumIdx, const std::string &Name) {
+ unsigned NumIdx, const Twine &Name) {
assert(NumOperands == 2 && "NumOperands not initialized?");
Op<0>() = Agg;
Op<1>() = Val;
}
void InsertValueInst::init(Value *Agg, Value *Val, unsigned Idx,
- const std::string &Name) {
+ const Twine &Name) {
assert(NumOperands == 2 && "NumOperands not initialized?");
Op<0>() = Agg;
Op<1>() = Val;
InsertValueInst::InsertValueInst(Value *Agg,
Value *Val,
unsigned Idx,
- const std::string &Name,
+ const Twine &Name,
Instruction *InsertBefore)
: Instruction(Agg->getType(), InsertValue,
OperandTraits<InsertValueInst>::op_begin(this),
InsertValueInst::InsertValueInst(Value *Agg,
Value *Val,
unsigned Idx,
- const std::string &Name,
+ const Twine &Name,
BasicBlock *InsertAtEnd)
: Instruction(Agg->getType(), InsertValue,
OperandTraits<InsertValueInst>::op_begin(this),
//===----------------------------------------------------------------------===//
void ExtractValueInst::init(const unsigned *Idx, unsigned NumIdx,
- const std::string &Name) {
+ const Twine &Name) {
assert(NumOperands == 1 && "NumOperands not initialized?");
Indices.insert(Indices.end(), Idx, Idx + NumIdx);
setName(Name);
}
-void ExtractValueInst::init(unsigned Idx, const std::string &Name) {
+void ExtractValueInst::init(unsigned Idx, const Twine &Name) {
assert(NumOperands == 1 && "NumOperands not initialized?");
Indices.push_back(Idx);
}
BinaryOperator::BinaryOperator(BinaryOps iType, Value *S1, Value *S2,
- const Type *Ty, const std::string &Name,
+ const Type *Ty, const Twine &Name,
Instruction *InsertBefore)
: Instruction(Ty, AdjustIType(iType, Ty),
OperandTraits<BinaryOperator>::op_begin(this),
}
BinaryOperator::BinaryOperator(BinaryOps iType, Value *S1, Value *S2,
- const Type *Ty, const std::string &Name,
+ const Type *Ty, const Twine &Name,
BasicBlock *InsertAtEnd)
: Instruction(Ty, AdjustIType(iType, Ty),
OperandTraits<BinaryOperator>::op_begin(this),
}
BinaryOperator *BinaryOperator::Create(BinaryOps Op, Value *S1, Value *S2,
- const std::string &Name,
+ const Twine &Name,
Instruction *InsertBefore) {
assert(S1->getType() == S2->getType() &&
"Cannot create binary operator with two operands of differing type!");
}
BinaryOperator *BinaryOperator::Create(BinaryOps Op, Value *S1, Value *S2,
- const std::string &Name,
+ const Twine &Name,
BasicBlock *InsertAtEnd) {
BinaryOperator *Res = Create(Op, S1, S2, Name);
InsertAtEnd->getInstList().push_back(Res);
}
BinaryOperator *BinaryOperator::CreateNeg(LLVMContext &Context,
- Value *Op, const std::string &Name,
+ Value *Op, const Twine &Name,
Instruction *InsertBefore) {
Value *zero = Context.getZeroValueForNegation(Op->getType());
return new BinaryOperator(Instruction::Sub,
}
BinaryOperator *BinaryOperator::CreateNeg(LLVMContext &Context,
- Value *Op, const std::string &Name,
+ Value *Op, const Twine &Name,
BasicBlock *InsertAtEnd) {
Value *zero = Context.getZeroValueForNegation(Op->getType());
return new BinaryOperator(Instruction::Sub,
}
BinaryOperator *BinaryOperator::CreateFNeg(LLVMContext &Context,
- Value *Op, const std::string &Name,
+ Value *Op, const Twine &Name,
Instruction *InsertBefore) {
Value *zero = Context.getZeroValueForNegation(Op->getType());
return new BinaryOperator(Instruction::FSub,
}
BinaryOperator *BinaryOperator::CreateFNeg(LLVMContext &Context,
- Value *Op, const std::string &Name,
+ Value *Op, const Twine &Name,
BasicBlock *InsertAtEnd) {
Value *zero = Context.getZeroValueForNegation(Op->getType());
return new BinaryOperator(Instruction::FSub,
}
BinaryOperator *BinaryOperator::CreateNot(LLVMContext &Context,
- Value *Op, const std::string &Name,
+ Value *Op, const Twine &Name,
Instruction *InsertBefore) {
Constant *C;
if (const VectorType *PTy = dyn_cast<VectorType>(Op->getType())) {
}
BinaryOperator *BinaryOperator::CreateNot(LLVMContext &Context,
- Value *Op, const std::string &Name,
+ Value *Op, const Twine &Name,
BasicBlock *InsertAtEnd) {
Constant *AllOnes;
if (const VectorType *PTy = dyn_cast<VectorType>(Op->getType())) {
}
CastInst *CastInst::Create(Instruction::CastOps op, Value *S, const Type *Ty,
- const std::string &Name, Instruction *InsertBefore) {
+ const Twine &Name, Instruction *InsertBefore) {
// Construct and return the appropriate CastInst subclass
switch (op) {
case Trunc: return new TruncInst (S, Ty, Name, InsertBefore);
}
CastInst *CastInst::Create(Instruction::CastOps op, Value *S, const Type *Ty,
- const std::string &Name, BasicBlock *InsertAtEnd) {
+ const Twine &Name, BasicBlock *InsertAtEnd) {
// Construct and return the appropriate CastInst subclass
switch (op) {
case Trunc: return new TruncInst (S, Ty, Name, InsertAtEnd);
}
CastInst *CastInst::CreateZExtOrBitCast(Value *S, const Type *Ty,
- const std::string &Name,
+ const Twine &Name,
Instruction *InsertBefore) {
if (S->getType()->getScalarSizeInBits() == Ty->getScalarSizeInBits())
return Create(Instruction::BitCast, S, Ty, Name, InsertBefore);
}
CastInst *CastInst::CreateZExtOrBitCast(Value *S, const Type *Ty,
- const std::string &Name,
+ const Twine &Name,
BasicBlock *InsertAtEnd) {
if (S->getType()->getScalarSizeInBits() == Ty->getScalarSizeInBits())
return Create(Instruction::BitCast, S, Ty, Name, InsertAtEnd);
}
CastInst *CastInst::CreateSExtOrBitCast(Value *S, const Type *Ty,
- const std::string &Name,
+ const Twine &Name,
Instruction *InsertBefore) {
if (S->getType()->getScalarSizeInBits() == Ty->getScalarSizeInBits())
return Create(Instruction::BitCast, S, Ty, Name, InsertBefore);
}
CastInst *CastInst::CreateSExtOrBitCast(Value *S, const Type *Ty,
- const std::string &Name,
+ const Twine &Name,
BasicBlock *InsertAtEnd) {
if (S->getType()->getScalarSizeInBits() == Ty->getScalarSizeInBits())
return Create(Instruction::BitCast, S, Ty, Name, InsertAtEnd);
}
CastInst *CastInst::CreateTruncOrBitCast(Value *S, const Type *Ty,
- const std::string &Name,
+ const Twine &Name,
Instruction *InsertBefore) {
if (S->getType()->getScalarSizeInBits() == Ty->getScalarSizeInBits())
return Create(Instruction::BitCast, S, Ty, Name, InsertBefore);
}
CastInst *CastInst::CreateTruncOrBitCast(Value *S, const Type *Ty,
- const std::string &Name,
+ const Twine &Name,
BasicBlock *InsertAtEnd) {
if (S->getType()->getScalarSizeInBits() == Ty->getScalarSizeInBits())
return Create(Instruction::BitCast, S, Ty, Name, InsertAtEnd);
}
CastInst *CastInst::CreatePointerCast(Value *S, const Type *Ty,
- const std::string &Name,
+ const Twine &Name,
BasicBlock *InsertAtEnd) {
assert(isa<PointerType>(S->getType()) && "Invalid cast");
assert((Ty->isInteger() || isa<PointerType>(Ty)) &&
/// @brief Create a BitCast or a PtrToInt cast instruction
CastInst *CastInst::CreatePointerCast(Value *S, const Type *Ty,
- const std::string &Name,
+ const Twine &Name,
Instruction *InsertBefore) {
assert(isa<PointerType>(S->getType()) && "Invalid cast");
assert((Ty->isInteger() || isa<PointerType>(Ty)) &&
}
CastInst *CastInst::CreateIntegerCast(Value *C, const Type *Ty,
- bool isSigned, const std::string &Name,
+ bool isSigned, const Twine &Name,
Instruction *InsertBefore) {
assert(C->getType()->isInteger() && Ty->isInteger() && "Invalid cast");
unsigned SrcBits = C->getType()->getScalarSizeInBits();
}
CastInst *CastInst::CreateIntegerCast(Value *C, const Type *Ty,
- bool isSigned, const std::string &Name,
+ bool isSigned, const Twine &Name,
BasicBlock *InsertAtEnd) {
assert(C->getType()->isIntOrIntVector() && Ty->isIntOrIntVector() &&
"Invalid cast");
}
CastInst *CastInst::CreateFPCast(Value *C, const Type *Ty,
- const std::string &Name,
+ const Twine &Name,
Instruction *InsertBefore) {
assert(C->getType()->isFPOrFPVector() && Ty->isFPOrFPVector() &&
"Invalid cast");
}
CastInst *CastInst::CreateFPCast(Value *C, const Type *Ty,
- const std::string &Name,
+ const Twine &Name,
BasicBlock *InsertAtEnd) {
assert(C->getType()->isFPOrFPVector() && Ty->isFPOrFPVector() &&
"Invalid cast");
}
TruncInst::TruncInst(
- Value *S, const Type *Ty, const std::string &Name, Instruction *InsertBefore
+ Value *S, const Type *Ty, const Twine &Name, Instruction *InsertBefore
) : CastInst(Ty, Trunc, S, Name, InsertBefore) {
assert(castIsValid(getOpcode(), S, Ty) && "Illegal Trunc");
}
TruncInst::TruncInst(
- Value *S, const Type *Ty, const std::string &Name, BasicBlock *InsertAtEnd
+ Value *S, const Type *Ty, const Twine &Name, BasicBlock *InsertAtEnd
) : CastInst(Ty, Trunc, S, Name, InsertAtEnd) {
assert(castIsValid(getOpcode(), S, Ty) && "Illegal Trunc");
}
ZExtInst::ZExtInst(
- Value *S, const Type *Ty, const std::string &Name, Instruction *InsertBefore
+ Value *S, const Type *Ty, const Twine &Name, Instruction *InsertBefore
) : CastInst(Ty, ZExt, S, Name, InsertBefore) {
assert(castIsValid(getOpcode(), S, Ty) && "Illegal ZExt");
}
ZExtInst::ZExtInst(
- Value *S, const Type *Ty, const std::string &Name, BasicBlock *InsertAtEnd
+ Value *S, const Type *Ty, const Twine &Name, BasicBlock *InsertAtEnd
) : CastInst(Ty, ZExt, S, Name, InsertAtEnd) {
assert(castIsValid(getOpcode(), S, Ty) && "Illegal ZExt");
}
SExtInst::SExtInst(
- Value *S, const Type *Ty, const std::string &Name, Instruction *InsertBefore
+ Value *S, const Type *Ty, const Twine &Name, Instruction *InsertBefore
) : CastInst(Ty, SExt, S, Name, InsertBefore) {
assert(castIsValid(getOpcode(), S, Ty) && "Illegal SExt");
}
SExtInst::SExtInst(
- Value *S, const Type *Ty, const std::string &Name, BasicBlock *InsertAtEnd
+ Value *S, const Type *Ty, const Twine &Name, BasicBlock *InsertAtEnd
) : CastInst(Ty, SExt, S, Name, InsertAtEnd) {
assert(castIsValid(getOpcode(), S, Ty) && "Illegal SExt");
}
FPTruncInst::FPTruncInst(
- Value *S, const Type *Ty, const std::string &Name, Instruction *InsertBefore
+ Value *S, const Type *Ty, const Twine &Name, Instruction *InsertBefore
) : CastInst(Ty, FPTrunc, S, Name, InsertBefore) {
assert(castIsValid(getOpcode(), S, Ty) && "Illegal FPTrunc");
}
FPTruncInst::FPTruncInst(
- Value *S, const Type *Ty, const std::string &Name, BasicBlock *InsertAtEnd
+ Value *S, const Type *Ty, const Twine &Name, BasicBlock *InsertAtEnd
) : CastInst(Ty, FPTrunc, S, Name, InsertAtEnd) {
assert(castIsValid(getOpcode(), S, Ty) && "Illegal FPTrunc");
}
FPExtInst::FPExtInst(
- Value *S, const Type *Ty, const std::string &Name, Instruction *InsertBefore
+ Value *S, const Type *Ty, const Twine &Name, Instruction *InsertBefore
) : CastInst(Ty, FPExt, S, Name, InsertBefore) {
assert(castIsValid(getOpcode(), S, Ty) && "Illegal FPExt");
}
FPExtInst::FPExtInst(
- Value *S, const Type *Ty, const std::string &Name, BasicBlock *InsertAtEnd
+ Value *S, const Type *Ty, const Twine &Name, BasicBlock *InsertAtEnd
) : CastInst(Ty, FPExt, S, Name, InsertAtEnd) {
assert(castIsValid(getOpcode(), S, Ty) && "Illegal FPExt");
}
UIToFPInst::UIToFPInst(
- Value *S, const Type *Ty, const std::string &Name, Instruction *InsertBefore
+ Value *S, const Type *Ty, const Twine &Name, Instruction *InsertBefore
) : CastInst(Ty, UIToFP, S, Name, InsertBefore) {
assert(castIsValid(getOpcode(), S, Ty) && "Illegal UIToFP");
}
UIToFPInst::UIToFPInst(
- Value *S, const Type *Ty, const std::string &Name, BasicBlock *InsertAtEnd
+ Value *S, const Type *Ty, const Twine &Name, BasicBlock *InsertAtEnd
) : CastInst(Ty, UIToFP, S, Name, InsertAtEnd) {
assert(castIsValid(getOpcode(), S, Ty) && "Illegal UIToFP");
}
SIToFPInst::SIToFPInst(
- Value *S, const Type *Ty, const std::string &Name, Instruction *InsertBefore
+ Value *S, const Type *Ty, const Twine &Name, Instruction *InsertBefore
) : CastInst(Ty, SIToFP, S, Name, InsertBefore) {
assert(castIsValid(getOpcode(), S, Ty) && "Illegal SIToFP");
}
SIToFPInst::SIToFPInst(
- Value *S, const Type *Ty, const std::string &Name, BasicBlock *InsertAtEnd
+ Value *S, const Type *Ty, const Twine &Name, BasicBlock *InsertAtEnd
) : CastInst(Ty, SIToFP, S, Name, InsertAtEnd) {
assert(castIsValid(getOpcode(), S, Ty) && "Illegal SIToFP");
}
FPToUIInst::FPToUIInst(
- Value *S, const Type *Ty, const std::string &Name, Instruction *InsertBefore
+ Value *S, const Type *Ty, const Twine &Name, Instruction *InsertBefore
) : CastInst(Ty, FPToUI, S, Name, InsertBefore) {
assert(castIsValid(getOpcode(), S, Ty) && "Illegal FPToUI");
}
FPToUIInst::FPToUIInst(
- Value *S, const Type *Ty, const std::string &Name, BasicBlock *InsertAtEnd
+ Value *S, const Type *Ty, const Twine &Name, BasicBlock *InsertAtEnd
) : CastInst(Ty, FPToUI, S, Name, InsertAtEnd) {
assert(castIsValid(getOpcode(), S, Ty) && "Illegal FPToUI");
}
FPToSIInst::FPToSIInst(
- Value *S, const Type *Ty, const std::string &Name, Instruction *InsertBefore
+ Value *S, const Type *Ty, const Twine &Name, Instruction *InsertBefore
) : CastInst(Ty, FPToSI, S, Name, InsertBefore) {
assert(castIsValid(getOpcode(), S, Ty) && "Illegal FPToSI");
}
FPToSIInst::FPToSIInst(
- Value *S, const Type *Ty, const std::string &Name, BasicBlock *InsertAtEnd
+ Value *S, const Type *Ty, const Twine &Name, BasicBlock *InsertAtEnd
) : CastInst(Ty, FPToSI, S, Name, InsertAtEnd) {
assert(castIsValid(getOpcode(), S, Ty) && "Illegal FPToSI");
}
PtrToIntInst::PtrToIntInst(
- Value *S, const Type *Ty, const std::string &Name, Instruction *InsertBefore
+ Value *S, const Type *Ty, const Twine &Name, Instruction *InsertBefore
) : CastInst(Ty, PtrToInt, S, Name, InsertBefore) {
assert(castIsValid(getOpcode(), S, Ty) && "Illegal PtrToInt");
}
PtrToIntInst::PtrToIntInst(
- Value *S, const Type *Ty, const std::string &Name, BasicBlock *InsertAtEnd
+ Value *S, const Type *Ty, const Twine &Name, BasicBlock *InsertAtEnd
) : CastInst(Ty, PtrToInt, S, Name, InsertAtEnd) {
assert(castIsValid(getOpcode(), S, Ty) && "Illegal PtrToInt");
}
IntToPtrInst::IntToPtrInst(
- Value *S, const Type *Ty, const std::string &Name, Instruction *InsertBefore
+ Value *S, const Type *Ty, const Twine &Name, Instruction *InsertBefore
) : CastInst(Ty, IntToPtr, S, Name, InsertBefore) {
assert(castIsValid(getOpcode(), S, Ty) && "Illegal IntToPtr");
}
IntToPtrInst::IntToPtrInst(
- Value *S, const Type *Ty, const std::string &Name, BasicBlock *InsertAtEnd
+ Value *S, const Type *Ty, const Twine &Name, BasicBlock *InsertAtEnd
) : CastInst(Ty, IntToPtr, S, Name, InsertAtEnd) {
assert(castIsValid(getOpcode(), S, Ty) && "Illegal IntToPtr");
}
BitCastInst::BitCastInst(
- Value *S, const Type *Ty, const std::string &Name, Instruction *InsertBefore
+ Value *S, const Type *Ty, const Twine &Name, Instruction *InsertBefore
) : CastInst(Ty, BitCast, S, Name, InsertBefore) {
assert(castIsValid(getOpcode(), S, Ty) && "Illegal BitCast");
}
BitCastInst::BitCastInst(
- Value *S, const Type *Ty, const std::string &Name, BasicBlock *InsertAtEnd
+ Value *S, const Type *Ty, const Twine &Name, BasicBlock *InsertAtEnd
) : CastInst(Ty, BitCast, S, Name, InsertAtEnd) {
assert(castIsValid(getOpcode(), S, Ty) && "Illegal BitCast");
}
//===----------------------------------------------------------------------===//
CmpInst::CmpInst(const Type *ty, OtherOps op, unsigned short predicate,
- Value *LHS, Value *RHS, const std::string &Name,
+ Value *LHS, Value *RHS, const Twine &Name,
Instruction *InsertBefore)
: Instruction(ty, op,
OperandTraits<CmpInst>::op_begin(this),
}
CmpInst::CmpInst(const Type *ty, OtherOps op, unsigned short predicate,
- Value *LHS, Value *RHS, const std::string &Name,
+ Value *LHS, Value *RHS, const Twine &Name,
BasicBlock *InsertAtEnd)
: Instruction(ty, op,
OperandTraits<CmpInst>::op_begin(this),
CmpInst *
CmpInst::Create(LLVMContext &Context, OtherOps Op, unsigned short predicate,
Value *S1, Value *S2,
- const std::string &Name, Instruction *InsertBefore) {
+ const Twine &Name, Instruction *InsertBefore) {
if (Op == Instruction::ICmp) {
if (InsertBefore)
return new ICmpInst(InsertBefore, CmpInst::Predicate(predicate),
CmpInst *
CmpInst::Create(OtherOps Op, unsigned short predicate, Value *S1, Value *S2,
- const std::string &Name, BasicBlock *InsertAtEnd) {
+ const Twine &Name, BasicBlock *InsertAtEnd) {
if (Op == Instruction::ICmp) {
return new ICmpInst(*InsertAtEnd, CmpInst::Predicate(predicate),
S1, S2, Name);
#include "llvm/Module.h"
#include "llvm/MDNode.h"
#include "llvm/ValueSymbolTable.h"
+#include "llvm/ADT/SmallString.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/LeakDetector.h"
return StringRef(Name->getKeyData(), Name->getKeyLength());
}
-void Value::setName(const std::string &name) {
- setName(&name[0], name.size());
+void Value::setName(const Twine &Name) {
+ SmallString<32> NameData;
+ Name.toVector(NameData);
+ setName(NameData.begin(), NameData.size());
}
void Value::setName(const char *Name) {
// CheckFailed - A check failed, so print out the condition and the message
// that failed. This provides a nice place to put a breakpoint if you want
// to see why something is not correct.
- void CheckFailed(const std::string &Message,
+ void CheckFailed(const Twine &Message,
const Value *V1 = 0, const Value *V2 = 0,
const Value *V3 = 0, const Value *V4 = 0) {
- msgs << Message << "\n";
+ msgs << Message.str() << "\n";
WriteValue(V1);
WriteValue(V2);
WriteValue(V3);
Broken = true;
}
- void CheckFailed( const std::string& Message, const Value* V1,
- const Type* T2, const Value* V3 = 0 ) {
- msgs << Message << "\n";
+ void CheckFailed(const Twine &Message, const Value* V1,
+ const Type* T2, const Value* V3 = 0) {
+ msgs << Message.str() << "\n";
WriteValue(V1);
WriteType(T2);
WriteValue(V3);