aboutsummaryrefslogtreecommitdiff
path: root/include/llvm/IR
diff options
context:
space:
mode:
Diffstat (limited to 'include/llvm/IR')
-rw-r--r--include/llvm/IR/Argument.h4
-rw-r--r--include/llvm/IR/Attributes.h38
-rw-r--r--include/llvm/IR/BasicBlock.h4
-rw-r--r--include/llvm/IR/Constants.h19
-rw-r--r--include/llvm/IR/DataLayout.h73
-rw-r--r--include/llvm/IR/DerivedTypes.h24
-rw-r--r--include/llvm/IR/Function.h18
-rw-r--r--include/llvm/IR/GlobalValue.h3
-rw-r--r--include/llvm/IR/IRBuilder.h25
-rw-r--r--include/llvm/IR/Instructions.h158
-rw-r--r--include/llvm/IR/Intrinsics.h20
-rw-r--r--include/llvm/IR/IntrinsicsMips.td16
-rw-r--r--include/llvm/IR/IntrinsicsNVVM.td2
-rw-r--r--include/llvm/IR/IntrinsicsPowerPC.td25
-rw-r--r--include/llvm/IR/IntrinsicsX86.td9
-rw-r--r--include/llvm/IR/LLVMContext.h18
-rw-r--r--include/llvm/IR/MDBuilder.h35
-rw-r--r--include/llvm/IR/Module.h11
-rw-r--r--include/llvm/IR/Type.h15
-rw-r--r--include/llvm/IR/Use.h13
-rw-r--r--include/llvm/IR/User.h20
-rw-r--r--include/llvm/IR/Value.h41
22 files changed, 399 insertions, 192 deletions
diff --git a/include/llvm/IR/Argument.h b/include/llvm/IR/Argument.h
index ef4e4fc7aa..40d61ff685 100644
--- a/include/llvm/IR/Argument.h
+++ b/include/llvm/IR/Argument.h
@@ -78,6 +78,10 @@ public:
/// containing function.
bool hasStructRetAttr() const;
+ /// \brief Return true if this argument has the returned attribute on it in
+ /// its containing function.
+ bool hasReturnedAttr() const;
+
/// \brief Add a Attribute to an argument.
void addAttr(AttributeSet AS);
diff --git a/include/llvm/IR/Attributes.h b/include/llvm/IR/Attributes.h
index 30c0965337..2c7da6485d 100644
--- a/include/llvm/IR/Attributes.h
+++ b/include/llvm/IR/Attributes.h
@@ -87,6 +87,7 @@ public:
OptimizeForSize, ///< opt_size
ReadNone, ///< Function does not access memory
ReadOnly, ///< Function only reads from memory
+ Returned, ///< Return value is always equal to this argument
ReturnsTwice, ///< Function can return twice
SExt, ///< Sign extended before/after call
StackAlignment, ///< Alignment of stack for function (3 bits)
@@ -209,7 +210,7 @@ private:
AttributeSetImpl *pImpl;
/// \brief The attributes for the specified index are returned.
- AttributeSetNode *getAttributes(unsigned Idx) const;
+ AttributeSetNode *getAttributes(unsigned Index) const;
/// \brief Create an AttributeSet with the specified parameters in it.
static AttributeSet get(LLVMContext &C,
@@ -226,11 +227,6 @@ private:
explicit AttributeSet(AttributeSetImpl *LI) : pImpl(LI) {}
public:
AttributeSet() : pImpl(0) {}
- AttributeSet(const AttributeSet &P) : pImpl(P.pImpl) {}
- const AttributeSet &operator=(const AttributeSet &RHS) {
- pImpl = RHS.pImpl;
- return *this;
- }
//===--------------------------------------------------------------------===//
// AttributeSet Construction and Mutation
@@ -238,30 +234,35 @@ public:
/// \brief Return an AttributeSet with the specified parameters in it.
static AttributeSet get(LLVMContext &C, ArrayRef<AttributeSet> Attrs);
- static AttributeSet get(LLVMContext &C, unsigned Idx,
+ static AttributeSet get(LLVMContext &C, unsigned Index,
ArrayRef<Attribute::AttrKind> Kind);
- static AttributeSet get(LLVMContext &C, unsigned Idx, AttrBuilder &B);
+ static AttributeSet get(LLVMContext &C, unsigned Index, AttrBuilder &B);
/// \brief Add an attribute to the attribute set at the given index. Since
/// attribute sets are immutable, this returns a new set.
- AttributeSet addAttribute(LLVMContext &C, unsigned Idx,
+ AttributeSet addAttribute(LLVMContext &C, unsigned Index,
Attribute::AttrKind Attr) const;
+ /// \brief Add an attribute to the attribute set at the given index. Since
+ /// attribute sets are immutable, this returns a new set.
+ AttributeSet addAttribute(LLVMContext &C, unsigned Index,
+ StringRef Kind) const;
+
/// \brief Add attributes to the attribute set at the given index. Since
/// attribute sets are immutable, this returns a new set.
- AttributeSet addAttributes(LLVMContext &C, unsigned Idx,
+ AttributeSet addAttributes(LLVMContext &C, unsigned Index,
AttributeSet Attrs) const;
/// \brief Remove the specified attribute at the specified index from this
/// attribute list. Since attribute lists are immutable, this returns the new
/// list.
- AttributeSet removeAttribute(LLVMContext &C, unsigned Idx,
+ AttributeSet removeAttribute(LLVMContext &C, unsigned Index,
Attribute::AttrKind Attr) const;
/// \brief Remove the specified attributes at the specified index from this
/// attribute list. Since attribute lists are immutable, this returns the new
/// list.
- AttributeSet removeAttributes(LLVMContext &C, unsigned Idx,
+ AttributeSet removeAttributes(LLVMContext &C, unsigned Index,
AttributeSet Attrs) const;
//===--------------------------------------------------------------------===//
@@ -272,7 +273,7 @@ public:
LLVMContext &getContext() const;
/// \brief The attributes for the specified index are returned.
- AttributeSet getParamAttributes(unsigned Idx) const;
+ AttributeSet getParamAttributes(unsigned Index) const;
/// \brief The attributes for the ret value are returned.
AttributeSet getRetAttributes() const;
@@ -300,7 +301,7 @@ public:
Attribute getAttribute(unsigned Index, StringRef Kind) const;
/// \brief Return the alignment for the specified function parameter.
- unsigned getParamAlignment(unsigned Idx) const;
+ unsigned getParamAlignment(unsigned Index) const;
/// \brief Get the stack alignment.
unsigned getStackAlignment(unsigned Index) const;
@@ -310,8 +311,8 @@ public:
typedef ArrayRef<Attribute>::iterator iterator;
- iterator begin(unsigned Idx) const;
- iterator end(unsigned Idx) const;
+ iterator begin(unsigned Slot) const;
+ iterator end(unsigned Slot) const;
/// operator==/!= - Provide equality predicates.
bool operator==(const AttributeSet &RHS) const {
@@ -344,7 +345,7 @@ public:
unsigned getNumSlots() const;
/// \brief Return the index for the given slot.
- uint64_t getSlotIndex(unsigned Slot) const;
+ unsigned getSlotIndex(unsigned Slot) const;
/// \brief Return the attributes at the given slot.
AttributeSet getSlotAttributes(unsigned Slot) const;
@@ -473,9 +474,6 @@ public:
bool td_empty() const { return TargetDepAttrs.empty(); }
- /// \brief Remove attributes that are used on functions only.
- void removeFunctionOnlyAttrs();
-
bool operator==(const AttrBuilder &B);
bool operator!=(const AttrBuilder &B) {
return !(*this == B);
diff --git a/include/llvm/IR/BasicBlock.h b/include/llvm/IR/BasicBlock.h
index ea5695a9e6..3bdc95d556 100644
--- a/include/llvm/IR/BasicBlock.h
+++ b/include/llvm/IR/BasicBlock.h
@@ -18,6 +18,7 @@
#include "llvm/ADT/ilist.h"
#include "llvm/IR/Instruction.h"
#include "llvm/IR/SymbolTableListTraits.h"
+#include "llvm/Support/CBindingWrapping.h"
#include "llvm/Support/DataTypes.h"
namespace llvm {
@@ -298,6 +299,9 @@ private:
}
};
+// Create wrappers for C Binding types (see CBindingWrapping.h).
+DEFINE_SIMPLE_CONVERSION_FUNCTIONS(BasicBlock, LLVMBasicBlockRef)
+
} // End llvm namespace
#endif
diff --git a/include/llvm/IR/Constants.h b/include/llvm/IR/Constants.h
index ad258f9aca..2f29f54594 100644
--- a/include/llvm/IR/Constants.h
+++ b/include/llvm/IR/Constants.h
@@ -26,6 +26,7 @@
#include "llvm/ADT/ArrayRef.h"
#include "llvm/IR/Constant.h"
#include "llvm/IR/OperandTraits.h"
+#include "llvm/IR/DerivedTypes.h"
namespace llvm {
@@ -138,7 +139,7 @@ public:
/// which reduces the amount of casting needed in parts of the compiler.
///
inline IntegerType *getType() const {
- return reinterpret_cast<IntegerType*>(Value::getType());
+ return cast<IntegerType>(Value::getType());
}
/// This static method returns true if the type Ty is big enough to
@@ -354,7 +355,7 @@ public:
/// which reduces the amount of casting needed in parts of the compiler.
///
inline ArrayType *getType() const {
- return reinterpret_cast<ArrayType*>(Value::getType());
+ return cast<ArrayType>(Value::getType());
}
virtual void destroyConstant();
@@ -412,7 +413,7 @@ public:
/// getType() specialization - Reduce amount of casting...
///
inline StructType *getType() const {
- return reinterpret_cast<StructType*>(Value::getType());
+ return cast<StructType>(Value::getType());
}
virtual void destroyConstant();
@@ -455,7 +456,7 @@ public:
/// which reduces the amount of casting needed in parts of the compiler.
///
inline VectorType *getType() const {
- return reinterpret_cast<VectorType*>(Value::getType());
+ return cast<VectorType>(Value::getType());
}
/// getSplatValue - If this is a splat constant, meaning that all of the
@@ -486,7 +487,7 @@ class ConstantPointerNull : public Constant {
ConstantPointerNull(const ConstantPointerNull &) LLVM_DELETED_FUNCTION;
protected:
explicit ConstantPointerNull(PointerType *T)
- : Constant(reinterpret_cast<Type*>(T),
+ : Constant(T,
Value::ConstantPointerNullVal, 0, 0) {}
protected:
@@ -504,7 +505,7 @@ public:
/// which reduces the amount of casting needed in parts of the compiler.
///
inline PointerType *getType() const {
- return reinterpret_cast<PointerType*>(Value::getType());
+ return cast<PointerType>(Value::getType());
}
/// Methods for support type inquiry through isa, cast, and dyn_cast:
@@ -580,7 +581,7 @@ public:
/// SequentialType, which reduces the amount of casting needed in parts of the
/// compiler.
inline SequentialType *getType() const {
- return reinterpret_cast<SequentialType*>(Value::getType());
+ return cast<SequentialType>(Value::getType());
}
/// getElementType - Return the element type of the array/vector.
@@ -679,7 +680,7 @@ public:
/// which reduces the amount of casting needed in parts of the compiler.
///
inline ArrayType *getType() const {
- return reinterpret_cast<ArrayType*>(Value::getType());
+ return cast<ArrayType>(Value::getType());
}
/// Methods for support type inquiry through isa, cast, and dyn_cast:
@@ -732,7 +733,7 @@ public:
/// which reduces the amount of casting needed in parts of the compiler.
///
inline VectorType *getType() const {
- return reinterpret_cast<VectorType*>(Value::getType());
+ return cast<VectorType>(Value::getType());
}
/// Methods for support type inquiry through isa, cast, and dyn_cast:
diff --git a/include/llvm/IR/DataLayout.h b/include/llvm/IR/DataLayout.h
index 73d9c4ffce..b0def6be3f 100644
--- a/include/llvm/IR/DataLayout.h
+++ b/include/llvm/IR/DataLayout.h
@@ -22,6 +22,8 @@
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/SmallVector.h"
+#include "llvm/IR/DerivedTypes.h"
+#include "llvm/IR/Type.h"
#include "llvm/Pass.h"
#include "llvm/Support/DataTypes.h"
@@ -169,18 +171,22 @@ public:
/// Initialize target data from properties stored in the module.
explicit DataLayout(const Module *M);
- DataLayout(const DataLayout &TD) :
+ DataLayout(const DataLayout &DL) :
ImmutablePass(ID),
- LittleEndian(TD.isLittleEndian()),
- StackNaturalAlign(TD.StackNaturalAlign),
- LegalIntWidths(TD.LegalIntWidths),
- Alignments(TD.Alignments),
- Pointers(TD.Pointers),
+ LittleEndian(DL.isLittleEndian()),
+ StackNaturalAlign(DL.StackNaturalAlign),
+ LegalIntWidths(DL.LegalIntWidths),
+ Alignments(DL.Alignments),
+ Pointers(DL.Pointers),
LayoutMap(0)
{ }
~DataLayout(); // Not virtual, do not subclass this class
+ /// DataLayout is an immutable pass, but holds state. This allows the pass
+ /// manager to clear its mutable state.
+ bool doFinalization(Module &M);
+
/// Parse a data layout string (with fallback to default values). Ensure that
/// the data layout pass is registered.
void init(StringRef LayoutDescription);
@@ -284,7 +290,7 @@ public:
/// getTypeSizeInBits - Return the number of bits necessary to hold the
/// specified type. For example, returns 36 for i36 and 80 for x86_fp80.
/// The type passed must have a size (Type::isSized() must return true).
- uint64_t getTypeSizeInBits(Type* Ty) const;
+ uint64_t getTypeSizeInBits(Type *Ty) const;
/// getTypeStoreSize - Return the maximum number of bytes that may be
/// overwritten by storing the specified type. For example, returns 5
@@ -304,7 +310,7 @@ public:
/// of the specified type, including alignment padding. This is the amount
/// that alloca reserves for this type. For example, returns 12 or 16 for
/// x86_fp80, depending on alignment.
- uint64_t getTypeAllocSize(Type* Ty) const {
+ uint64_t getTypeAllocSize(Type *Ty) const {
// Round up to the next alignment boundary.
return RoundUpAlignment(getTypeStoreSize(Ty), getABITypeAlignment(Ty));
}
@@ -313,7 +319,7 @@ public:
/// objects of the specified type, including alignment padding; always a
/// multiple of 8. This is the amount that alloca reserves for this type.
/// For example, returns 96 or 128 for x86_fp80, depending on alignment.
- uint64_t getTypeAllocSizeInBits(Type* Ty) const {
+ uint64_t getTypeAllocSizeInBits(Type *Ty) const {
return 8*getTypeAllocSize(Ty);
}
@@ -346,6 +352,10 @@ public:
/// type.
Type *getIntPtrType(Type *) const;
+ /// getSmallestLegalIntType - Return the smallest integer type with size at
+ /// least as big as Width bits.
+ Type *getSmallestLegalIntType(LLVMContext &C, unsigned Width = 0) const;
+
/// getIndexedOffset - return the offset from the beginning of the type for
/// the specified indices. This is used to implement getelementptr.
uint64_t getIndexedOffset(Type *Ty, ArrayRef<Value *> Indices) const;
@@ -416,9 +426,52 @@ public:
private:
friend class DataLayout; // Only DataLayout can create this class
- StructLayout(StructType *ST, const DataLayout &TD);
+ StructLayout(StructType *ST, const DataLayout &DL);
};
+
+// The implementation of this method is provided inline as it is particularly
+// well suited to constant folding when called on a specific Type subclass.
+inline uint64_t DataLayout::getTypeSizeInBits(Type *Ty) const {
+ assert(Ty->isSized() && "Cannot getTypeInfo() on a type that is unsized!");
+ switch (Ty->getTypeID()) {
+ case Type::LabelTyID:
+ return getPointerSizeInBits(0);
+ case Type::PointerTyID:
+ return getPointerSizeInBits(cast<PointerType>(Ty)->getAddressSpace());
+ case Type::ArrayTyID: {
+ ArrayType *ATy = cast<ArrayType>(Ty);
+ return ATy->getNumElements() *
+ getTypeAllocSizeInBits(ATy->getElementType());
+ }
+ case Type::StructTyID:
+ // Get the layout annotation... which is lazily created on demand.
+ return getStructLayout(cast<StructType>(Ty))->getSizeInBits();
+ case Type::IntegerTyID:
+ return cast<IntegerType>(Ty)->getBitWidth();
+ case Type::HalfTyID:
+ return 16;
+ case Type::FloatTyID:
+ return 32;
+ case Type::DoubleTyID:
+ case Type::X86_MMXTyID:
+ return 64;
+ case Type::PPC_FP128TyID:
+ case Type::FP128TyID:
+ return 128;
+ // In memory objects this is always aligned to a higher boundary, but
+ // only 80 bits contain information.
+ case Type::X86_FP80TyID:
+ return 80;
+ case Type::VectorTyID: {
+ VectorType *VTy = cast<VectorType>(Ty);
+ return VTy->getNumElements() * getTypeSizeInBits(VTy->getElementType());
+ }
+ default:
+ llvm_unreachable("DataLayout::getTypeSizeInBits(): Unsupported type");
+ }
+}
+
} // End llvm namespace
#endif
diff --git a/include/llvm/IR/DerivedTypes.h b/include/llvm/IR/DerivedTypes.h
index 3bf7885f47..e279e60e47 100644
--- a/include/llvm/IR/DerivedTypes.h
+++ b/include/llvm/IR/DerivedTypes.h
@@ -84,7 +84,7 @@ public:
/// @brief Is this a power-of-2 byte-width IntegerType ?
bool isPowerOf2ByteWidth() const;
- // Methods for support type inquiry through isa, cast, and dyn_cast.
+ /// Methods for support type inquiry through isa, cast, and dyn_cast.
static inline bool classof(const Type *T) {
return T->getTypeID() == IntegerTyID;
}
@@ -117,14 +117,14 @@ public:
/// argument type.
static bool isValidArgumentType(Type *ArgTy);
- bool isVarArg() const { return getSubclassData(); }
+ bool isVarArg() const { return getSubclassData()!=0; }
Type *getReturnType() const { return ContainedTys[0]; }
typedef Type::subtype_iterator param_iterator;
param_iterator param_begin() const { return ContainedTys + 1; }
param_iterator param_end() const { return &ContainedTys[NumContainedTys]; }
- // Parameter type accessors.
+ /// Parameter type accessors.
Type *getParamType(unsigned i) const { return ContainedTys[i+1]; }
/// getNumParams - Return the number of fixed parameters this function type
@@ -132,7 +132,7 @@ public:
///
unsigned getNumParams() const { return NumContainedTys - 1; }
- // Methods for support type inquiry through isa, cast, and dyn_cast.
+ /// Methods for support type inquiry through isa, cast, and dyn_cast.
static inline bool classof(const Type *T) {
return T->getTypeID() == FunctionTyID;
}
@@ -154,7 +154,7 @@ public:
bool indexValid(const Value *V) const;
bool indexValid(unsigned Idx) const;
- // Methods for support type inquiry through isa, cast, and dyn_cast.
+ /// Methods for support type inquiry through isa, cast, and dyn_cast.
static inline bool classof(const Type *T) {
return T->getTypeID() == ArrayTyID ||
T->getTypeID() == StructTyID ||
@@ -190,7 +190,7 @@ class StructType : public CompositeType {
StructType(LLVMContext &C)
: CompositeType(C, StructTyID), SymbolTableEntry(0) {}
enum {
- // This is the contents of the SubClassData field.
+ /// This is the contents of the SubClassData field.
SCDB_HasBody = 1,
SCDB_Packed = 2,
SCDB_IsLiteral = 4,
@@ -282,14 +282,14 @@ public:
/// specified struct.
bool isLayoutIdentical(StructType *Other) const;
- // Random access to the elements
+ /// Random access to the elements
unsigned getNumElements() const { return NumContainedTys; }
Type *getElementType(unsigned N) const {
assert(N < NumContainedTys && "Element number out of range!");
return ContainedTys[N];
}
- // Methods for support type inquiry through isa, cast, and dyn_cast.
+ /// Methods for support type inquiry through isa, cast, and dyn_cast.
static inline bool classof(const Type *T) {
return T->getTypeID() == StructTyID;
}
@@ -318,7 +318,7 @@ protected:
public:
Type *getElementType() const { return ContainedTys[0]; }
- // Methods for support type inquiry through isa, cast, and dyn_cast.
+ /// Methods for support type inquiry through isa, cast, and dyn_cast.
static inline bool classof(const Type *T) {
return T->getTypeID() == ArrayTyID ||
T->getTypeID() == PointerTyID ||
@@ -347,7 +347,7 @@ public:
uint64_t getNumElements() const { return NumElements; }
- // Methods for support type inquiry through isa, cast, and dyn_cast.
+ /// Methods for support type inquiry through isa, cast, and dyn_cast.
static inline bool classof(const Type *T) {
return T->getTypeID() == ArrayTyID;
}
@@ -413,7 +413,7 @@ public:
return NumElements * getElementType()->getPrimitiveSizeInBits();
}
- // Methods for support type inquiry through isa, cast, and dyn_cast.
+ /// Methods for support type inquiry through isa, cast, and dyn_cast.
static inline bool classof(const Type *T) {
return T->getTypeID() == VectorTyID;
}
@@ -444,7 +444,7 @@ public:
/// @brief Return the address space of the Pointer type.
inline unsigned getAddressSpace() const { return getSubclassData(); }
- // Implement support type inquiry through isa, cast, and dyn_cast.
+ /// Implement support type inquiry through isa, cast, and dyn_cast.
static inline bool classof(const Type *T) {
return T->getTypeID() == PointerTyID;
}
diff --git a/include/llvm/IR/Function.h b/include/llvm/IR/Function.h
index 568b55c87b..f97929f658 100644
--- a/include/llvm/IR/Function.h
+++ b/include/llvm/IR/Function.h
@@ -113,6 +113,10 @@ private:
Function(const Function&) LLVM_DELETED_FUNCTION;
void operator=(const Function&) LLVM_DELETED_FUNCTION;
+ /// Do the actual lookup of an intrinsic ID when the query could not be
+ /// answered from the cache.
+ unsigned lookupIntrinsicID() const LLVM_READONLY;
+
/// Function ctor - If the (optional) Module argument is specified, the
/// function is automatically inserted into the end of the function list for
/// the module.
@@ -141,10 +145,12 @@ public:
/// getIntrinsicID - This method returns the ID number of the specified
/// function, or Intrinsic::not_intrinsic if the function is not an
- /// instrinsic, or if the pointer is null. This value is always defined to be
+ /// intrinsic, or if the pointer is null. This value is always defined to be
/// zero to allow easy checking for whether a function is intrinsic or not.
/// The particular intrinsic functions which correspond to this value are
- /// defined in llvm/Intrinsics.h.
+ /// defined in llvm/Intrinsics.h. Results are cached in the LLVM context,
+ /// subsequent requests for the same ID return results much faster from the
+ /// cache.
///
unsigned getIntrinsicID() const LLVM_READONLY;
bool isIntrinsic() const { return getName().startswith("llvm."); }
@@ -175,6 +181,14 @@ public:
AttributeSet::FunctionIndex, N));
}
+ /// addFnAttr - Add function attributes to this function.
+ ///
+ void addFnAttr(StringRef Kind) {
+ setAttributes(
+ AttributeSets.addAttribute(getContext(),
+ AttributeSet::FunctionIndex, Kind));
+ }
+
/// \brief Return true if the function has the attribute.
bool hasFnAttribute(Attribute::AttrKind Kind) const {
return AttributeSets.hasAttribute(AttributeSet::FunctionIndex, Kind);
diff --git a/include/llvm/IR/GlobalValue.h b/include/llvm/IR/GlobalValue.h
index c87e7d06b3..5bd70856e9 100644
--- a/include/llvm/IR/GlobalValue.h
+++ b/include/llvm/IR/GlobalValue.h
@@ -19,6 +19,7 @@
#define LLVM_IR_GLOBALVALUE_H
#include "llvm/IR/Constant.h"
+#include "llvm/IR/DerivedTypes.h"
namespace llvm {
@@ -125,7 +126,7 @@ public:
/// getType - Global values are always pointers.
inline PointerType *getType() const {
- return reinterpret_cast<PointerType*>(User::getType());
+ return cast<PointerType>(User::getType());
}
static LinkageTypes getLinkOnceLinkage(bool ODR) {
diff --git a/include/llvm/IR/IRBuilder.h b/include/llvm/IR/IRBuilder.h
index 1c71d0a901..f11d3b4e0b 100644
--- a/include/llvm/IR/IRBuilder.h
+++ b/include/llvm/IR/IRBuilder.h
@@ -23,6 +23,7 @@
#include "llvm/IR/Instructions.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Operator.h"
+#include "llvm/Support/CBindingWrapping.h"
#include "llvm/Support/ConstantFolder.h"
namespace llvm {
@@ -48,6 +49,10 @@ protected:
class IRBuilderBase {
DebugLoc CurDbgLocation;
protected:
+ /// Save the current debug location here while we are suppressing
+ /// line table entries.
+ llvm::DebugLoc SavedDbgLocation;
+
BasicBlock *BB;
BasicBlock::iterator InsertPt;
LLVMContext &Context;
@@ -112,6 +117,23 @@ public:
CurDbgLocation = L;
}
+ /// \brief Temporarily suppress DebugLocations from being attached
+ /// to emitted instructions, until the next call to
+ /// SetCurrentDebugLocation() or EnableDebugLocations(). Use this
+ /// if you want an instruction to be counted towards the prologue or
+ /// if there is no useful source location.
+ void DisableDebugLocations() {
+ llvm::DebugLoc Empty;
+ SavedDbgLocation = getCurrentDebugLocation();
+ SetCurrentDebugLocation(Empty);
+ }
+
+ /// \brief Restore the previously saved DebugLocation.
+ void EnableDebugLocations() {
+ assert(CurDbgLocation.isUnknown());
+ SetCurrentDebugLocation(SavedDbgLocation);
+ }
+
/// \brief Get location information used by debugging information.
DebugLoc getCurrentDebugLocation() const { return CurDbgLocation; }
@@ -1396,6 +1418,9 @@ public:
}
};
+// Create wrappers for C Binding types (see CBindingWrapping.h).
+DEFINE_SIMPLE_CONVERSION_FUNCTIONS(IRBuilder<>, LLVMBuilderRef)
+
}
#endif
diff --git a/include/llvm/IR/Instructions.h b/include/llvm/IR/Instructions.h
index 1ae8850cbc..7e29699f73 100644
--- a/include/llvm/IR/Instructions.h
+++ b/include/llvm/IR/Instructions.h
@@ -281,7 +281,7 @@ public:
unsigned Align, AtomicOrdering Order,
SynchronizationScope SynchScope,
BasicBlock *InsertAtEnd);
-
+
/// isVolatile - Return true if this is a store to a volatile memory
/// location.
@@ -516,15 +516,15 @@ public:
Value *getCompareOperand() { return getOperand(1); }
const Value *getCompareOperand() const { return getOperand(1); }
-
+
Value *getNewValOperand() { return getOperand(2); }
const Value *getNewValOperand() const { return getOperand(2); }
-
+
/// \brief Returns the address space of the pointer operand.
unsigned getPointerAddressSpace() const {
return getPointerOperand()->getType()->getPointerAddressSpace();
}
-
+
// Methods for support type inquiry through isa, cast, and dyn_cast:
static inline bool classof(const Instruction *I) {
return I->getOpcode() == Instruction::AtomicCmpXchg;
@@ -1272,7 +1272,7 @@ public:
void setAttributes(const AttributeSet &Attrs) { AttributeList = Attrs; }
/// addAttribute - adds the attribute to the list of attributes.
- void addAttribute(unsigned i, Attribute attr);
+ void addAttribute(unsigned i, Attribute::AttrKind attr);
/// removeAttribute - removes the attribute from the list of attributes.
void removeAttribute(unsigned i, Attribute attr);
@@ -1291,8 +1291,7 @@ public:
/// \brief Return true if the call should not be inlined.
bool isNoInline() const { return hasFnAttr(Attribute::NoInline); }
void setIsNoInline() {
- addAttribute(AttributeSet::FunctionIndex,
- Attribute::get(getContext(), Attribute::NoInline));
+ addAttribute(AttributeSet::FunctionIndex, Attribute::NoInline);
}
/// \brief Return true if the call can return twice
@@ -1300,8 +1299,7 @@ public:
return hasFnAttr(Attribute::ReturnsTwice);
}
void setCanReturnTwice() {
- addAttribute(AttributeSet::FunctionIndex,
- Attribute::get(getContext(), Attribute::ReturnsTwice));
+ addAttribute(AttributeSet::FunctionIndex, Attribute::ReturnsTwice);
}
/// \brief Determine if the call does not access memory.
@@ -1309,8 +1307,7 @@ public:
return hasFnAttr(Attribute::ReadNone);
}
void setDoesNotAccessMemory() {
- addAttribute(AttributeSet::FunctionIndex,
- Attribute::get(getContext(), Attribute::ReadNone));
+ addAttribute(AttributeSet::FunctionIndex, Attribute::ReadNone);
}
/// \brief Determine if the call does not access or only reads memory.
@@ -1318,29 +1315,25 @@ public:
return doesNotAccessMemory() || hasFnAttr(Attribute::ReadOnly);
}
void setOnlyReadsMemory() {
- addAttribute(AttributeSet::FunctionIndex,
- Attribute::get(getContext(), Attribute::ReadOnly));
+ addAttribute(AttributeSet::FunctionIndex, Attribute::ReadOnly);
}
/// \brief Determine if the call cannot return.
bool doesNotReturn() const { return hasFnAttr(Attribute::NoReturn); }
void setDoesNotReturn() {
- addAttribute(AttributeSet::FunctionIndex,
- Attribute::get(getContext(), Attribute::NoReturn));
+ addAttribute(AttributeSet::FunctionIndex, Attribute::NoReturn);
}
/// \brief Determine if the call cannot unwind.
bool doesNotThrow() const { return hasFnAttr(Attribute::NoUnwind); }
void setDoesNotThrow() {
- addAttribute(AttributeSet::FunctionIndex,
- Attribute::get(getContext(), Attribute::NoUnwind));
+ addAttribute(AttributeSet::FunctionIndex, Attribute::NoUnwind);
}
/// \brief Determine if the call cannot be duplicated.
bool cannotDuplicate() const {return hasFnAttr(Attribute::NoDuplicate); }
void setCannotDuplicate() {
- addAttribute(AttributeSet::FunctionIndex,
- Attribute::get(getContext(), Attribute::NoDuplicate));
+ addAttribute(AttributeSet::FunctionIndex, Attribute::NoDuplicate);
}
/// \brief Determine if the call returns a structure through first
@@ -1690,7 +1683,7 @@ public:
Constant *getMask() const {
return cast<Constant>(getOperand(2));
}
-
+
/// getMaskValue - Return the index from the shuffle mask for the specified
/// output result. This is either -1 if the element is undef or a number less
/// than 2*numelements.
@@ -1699,7 +1692,7 @@ public:
int getMaskValue(unsigned i) const {
return getMaskValue(getMask(), i);
}
-
+
/// getShuffleMask - Return the full mask for this instruction, where each
/// element is the element number and undef's are returned as -1.
static void getShuffleMask(Constant *Mask, SmallVectorImpl<int> &Result);
@@ -2016,7 +2009,7 @@ public:
Instruction *InsertBefore = 0) {
return new PHINode(Ty, NumReservedValues, NameStr, InsertBefore);
}
- static PHINode *Create(Type *Ty, unsigned NumReservedValues,
+ static PHINode *Create(Type *Ty, unsigned NumReservedValues,
const Twine &NameStr, BasicBlock *InsertAtEnd) {
return new PHINode(Ty, NumReservedValues, NameStr, InsertAtEnd);
}
@@ -2455,7 +2448,7 @@ class SwitchInst : public TerminatorInst {
// Operand[1] = Default basic block destination
// Operand[2n ] = Value to match
// Operand[2n+1] = BasicBlock to go to on match
-
+
// Store case values separately from operands list. We needn't User-Use
// concept here, since it is just a case value, it will always constant,
// and case value couldn't reused with another instructions/values.
@@ -2472,9 +2465,9 @@ class SwitchInst : public TerminatorInst {
typedef std::list<IntegersSubset> Subsets;
typedef Subsets::iterator SubsetsIt;
typedef Subsets::const_iterator SubsetsConstIt;
-
+
Subsets TheSubsets;
-
+
SwitchInst(const SwitchInst &SI);
void init(Value *Value, BasicBlock *Default, unsigned NumReserved);
void growOperands();