summaryrefslogtreecommitdiff
path: root/include/llvm/IR
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2017-04-20 21:19:10 +0000
committerDimitry Andric <dim@FreeBSD.org>2017-04-20 21:19:10 +0000
commitd99dafe2e4a385dd2a6c76da6d8258deb100657b (patch)
treeba60bf957558bd114f25dbff3d4996b5d7a61c82 /include/llvm/IR
parent71d5a2540a98c81f5bcaeb48805e0e2881f530ef (diff)
Notes
Diffstat (limited to 'include/llvm/IR')
-rw-r--r--include/llvm/IR/Argument.h12
-rw-r--r--include/llvm/IR/Attributes.h3
-rw-r--r--include/llvm/IR/ConstantRange.h30
-rw-r--r--include/llvm/IR/DIBuilder.h3
-rw-r--r--include/llvm/IR/DebugInfoMetadata.h5
-rw-r--r--include/llvm/IR/Instructions.h6
-rw-r--r--include/llvm/IR/Metadata.h9
-rw-r--r--include/llvm/IR/ModuleSummaryIndex.h4
-rw-r--r--include/llvm/IR/PatternMatch.h10
-rw-r--r--include/llvm/IR/Use.h24
10 files changed, 54 insertions, 52 deletions
diff --git a/include/llvm/IR/Argument.h b/include/llvm/IR/Argument.h
index 6fc1dd2f285a1..5c05f19abc1fd 100644
--- a/include/llvm/IR/Argument.h
+++ b/include/llvm/IR/Argument.h
@@ -108,18 +108,16 @@ public:
bool hasSExtAttr() const;
/// Add attributes to an argument.
- void addAttr(AttributeList AS);
+ void addAttrs(AttrBuilder &B);
- void addAttr(Attribute::AttrKind Kind) {
- addAttr(AttributeList::get(getContext(), getArgNo() + 1, Kind));
- }
+ void addAttr(Attribute::AttrKind Kind);
+
+ void addAttr(Attribute Attr);
/// Remove attributes from an argument.
void removeAttr(AttributeList AS);
- void removeAttr(Attribute::AttrKind Kind) {
- removeAttr(AttributeList::get(getContext(), getArgNo() + 1, Kind));
- }
+ void removeAttr(Attribute::AttrKind Kind);
/// Check if an argument has a given attribute.
bool hasAttribute(Attribute::AttrKind Kind) const;
diff --git a/include/llvm/IR/Attributes.h b/include/llvm/IR/Attributes.h
index 121f57a433acb..b13f197d25fdc 100644
--- a/include/llvm/IR/Attributes.h
+++ b/include/llvm/IR/Attributes.h
@@ -357,9 +357,6 @@ public:
AttributeList Attrs) const;
AttributeList addAttributes(LLVMContext &C, unsigned Index,
- AttributeSet AS) const;
-
- AttributeList addAttributes(LLVMContext &C, unsigned Index,
const AttrBuilder &B) const;
/// \brief Remove the specified attribute at the specified index from this
diff --git a/include/llvm/IR/ConstantRange.h b/include/llvm/IR/ConstantRange.h
index 6d704666933fc..47004e82cc19a 100644
--- a/include/llvm/IR/ConstantRange.h
+++ b/include/llvm/IR/ConstantRange.h
@@ -41,17 +41,14 @@ namespace llvm {
class MDNode;
/// This class represents a range of values.
-///
class ConstantRange {
APInt Lower, Upper;
public:
/// Initialize a full (the default) or empty set for the specified bit width.
- ///
explicit ConstantRange(uint32_t BitWidth, bool isFullSet = true);
/// Initialize a range to hold the single specified value.
- ///
ConstantRange(APInt Value);
/// @brief Initialize a range of values explicitly. This will assert out if
@@ -119,46 +116,36 @@ public:
bool getEquivalentICmp(CmpInst::Predicate &Pred, APInt &RHS) const;
/// Return the lower value for this range.
- ///
const APInt &getLower() const { return Lower; }
/// Return the upper value for this range.
- ///
const APInt &getUpper() const { return Upper; }
/// Get the bit width of this ConstantRange.
- ///
uint32_t getBitWidth() const { return Lower.getBitWidth(); }
/// Return true if this set contains all of the elements possible
/// for this data-type.
- ///
bool isFullSet() const;
/// Return true if this set contains no members.
- ///
bool isEmptySet() const;
/// Return true if this set wraps around the top of the range.
/// For example: [100, 8).
- ///
bool isWrappedSet() const;
/// Return true if this set wraps around the INT_MIN of
/// its bitwidth. For example: i8 [120, 140).
- ///
bool isSignWrappedSet() const;
/// Return true if the specified value is in the set.
- ///
bool contains(const APInt &Val) const;
/// Return true if the other range is a subset of this one.
- ///
bool contains(const ConstantRange &CR) const;
/// If this set contains a single element, return it, otherwise return null.
- ///
const APInt *getSingleElement() const {
if (Upper == Lower + 1)
return &Lower;
@@ -174,35 +161,27 @@ public:
}
/// Return true if this set contains exactly one member.
- ///
bool isSingleElement() const { return getSingleElement() != nullptr; }
/// Return the number of elements in this set.
- ///
APInt getSetSize() const;
/// Compare set size of this range with the range CR.
- ///
bool isSizeStrictlySmallerThanOf(const ConstantRange &CR) const;
/// Return the largest unsigned value contained in the ConstantRange.
- ///
APInt getUnsignedMax() const;
/// Return the smallest unsigned value contained in the ConstantRange.
- ///
APInt getUnsignedMin() const;
/// Return the largest signed value contained in the ConstantRange.
- ///
APInt getSignedMax() const;
/// Return the smallest signed value contained in the ConstantRange.
- ///
APInt getSignedMin() const;
/// Return true if this range is equal to another range.
- ///
bool operator==(const ConstantRange &CR) const {
return Lower == CR.Lower && Upper == CR.Upper;
}
@@ -213,8 +192,8 @@ public:
/// Subtract the specified constant from the endpoints of this constant range.
ConstantRange subtract(const APInt &CI) const;
- /// \brief Subtract the specified range from this range (aka relative
- /// complement of the sets).
+ /// Subtract the specified range from this range (aka relative complement of
+ /// the sets).
ConstantRange difference(const ConstantRange &CR) const;
/// Return the range that results from the intersection of
@@ -223,7 +202,6 @@ public:
/// smallest possible set size that does so. Because there may be two
/// intersections with the same set size, A.intersectWith(B) might not
/// be equal to B.intersectWith(A).
- ///
ConstantRange intersectWith(const ConstantRange &CR) const;
/// Return the range that results from the union of this range
@@ -231,7 +209,6 @@ public:
/// elements of both sets, but may contain more. For example, [3, 9) union
/// [12,15) is [3, 15), which includes 9, 10, and 11, which were not included
/// in either set before.
- ///
ConstantRange unionWith(const ConstantRange &CR) const;
/// Return a new range representing the possible values resulting
@@ -331,15 +308,12 @@ public:
ConstantRange lshr(const ConstantRange &Other) const;
/// Return a new range that is the logical not of the current set.
- ///
ConstantRange inverse() const;
/// Print out the bounds to a stream.
- ///
void print(raw_ostream &OS) const;
/// Allow printing from a debugger easily.
- ///
void dump() const;
};
diff --git a/include/llvm/IR/DIBuilder.h b/include/llvm/IR/DIBuilder.h
index 69bd5c847a8d0..a4b2a02d50503 100644
--- a/include/llvm/IR/DIBuilder.h
+++ b/include/llvm/IR/DIBuilder.h
@@ -778,6 +778,9 @@ namespace llvm {
}
};
+ // Create wrappers for C Binding types (see CBindingWrapping.h).
+ DEFINE_ISA_CONVERSION_FUNCTIONS(DIBuilder, LLVMDIBuilderRef)
+
} // end namespace llvm
#endif // LLVM_IR_DIBUILDER_H
diff --git a/include/llvm/IR/DebugInfoMetadata.h b/include/llvm/IR/DebugInfoMetadata.h
index 8a924b40143aa..8041e35e0e0a6 100644
--- a/include/llvm/IR/DebugInfoMetadata.h
+++ b/include/llvm/IR/DebugInfoMetadata.h
@@ -2232,6 +2232,9 @@ public:
expr_op_iterator expr_op_end() const {
return expr_op_iterator(elements_end());
}
+ iterator_range<expr_op_iterator> expr_ops() const {
+ return {expr_op_begin(), expr_op_end()};
+ }
/// @}
bool isValid() const;
@@ -2240,7 +2243,7 @@ public:
return MD->getMetadataID() == DIExpressionKind;
}
- /// Is the first element a DW_OP_deref?.
+ /// Return whether the first element a DW_OP_deref.
bool startsWithDeref() const {
return getNumElements() > 0 && getElement(0) == dwarf::DW_OP_deref;
}
diff --git a/include/llvm/IR/Instructions.h b/include/llvm/IR/Instructions.h
index 34dafebe0fc5d..d23c1ddf9257b 100644
--- a/include/llvm/IR/Instructions.h
+++ b/include/llvm/IR/Instructions.h
@@ -273,10 +273,11 @@ public:
Value *getPointerOperand() { return getOperand(0); }
const Value *getPointerOperand() const { return getOperand(0); }
static unsigned getPointerOperandIndex() { return 0U; }
+ Type *getPointerOperandType() const { return getPointerOperand()->getType(); }
/// Returns the address space of the pointer operand.
unsigned getPointerAddressSpace() const {
- return getPointerOperand()->getType()->getPointerAddressSpace();
+ return getPointerOperandType()->getPointerAddressSpace();
}
// Methods for support type inquiry through isa, cast, and dyn_cast:
@@ -397,10 +398,11 @@ public:
Value *getPointerOperand() { return getOperand(1); }
const Value *getPointerOperand() const { return getOperand(1); }
static unsigned getPointerOperandIndex() { return 1U; }
+ Type *getPointerOperandType() const { return getPointerOperand()->getType(); }
/// Returns the address space of the pointer operand.
unsigned getPointerAddressSpace() const {
- return getPointerOperand()->getType()->getPointerAddressSpace();
+ return getPointerOperandType()->getPointerAddressSpace();
}
// Methods for support type inquiry through isa, cast, and dyn_cast:
diff --git a/include/llvm/IR/Metadata.h b/include/llvm/IR/Metadata.h
index fd79355bff1ad..8f24a6a1d69d8 100644
--- a/include/llvm/IR/Metadata.h
+++ b/include/llvm/IR/Metadata.h
@@ -30,6 +30,7 @@
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Value.h"
#include "llvm/Support/Casting.h"
+#include "llvm/Support/CBindingWrapping.h"
#include "llvm/Support/ErrorHandling.h"
#include <cassert>
#include <cstddef>
@@ -133,6 +134,14 @@ public:
/// @}
};
+// Create wrappers for C Binding types (see CBindingWrapping.h).
+DEFINE_ISA_CONVERSION_FUNCTIONS(Metadata, LLVMMetadataRef)
+
+// Specialized opaque metadata conversions.
+inline Metadata **unwrap(LLVMMetadataRef *MDs) {
+ return reinterpret_cast<Metadata**>(MDs);
+}
+
#define HANDLE_METADATA(CLASS) class CLASS;
#include "llvm/IR/Metadata.def"
diff --git a/include/llvm/IR/ModuleSummaryIndex.h b/include/llvm/IR/ModuleSummaryIndex.h
index 09f6c18970095..9c0a4159cad2f 100644
--- a/include/llvm/IR/ModuleSummaryIndex.h
+++ b/include/llvm/IR/ModuleSummaryIndex.h
@@ -160,7 +160,6 @@ private:
std::vector<ValueInfo> RefEdgeList;
protected:
- /// GlobalValueSummary constructor.
GlobalValueSummary(SummaryKind K, GVFlags Flags, std::vector<ValueInfo> Refs)
: Kind(K), Flags(Flags), OriginalName(0), RefEdgeList(std::move(Refs)) {}
@@ -221,7 +220,6 @@ class AliasSummary : public GlobalValueSummary {
GlobalValueSummary *AliaseeSummary;
public:
- /// Summary constructors.
AliasSummary(GVFlags Flags, std::vector<ValueInfo> Refs)
: GlobalValueSummary(AliasKind, Flags, std::move(Refs)) {}
@@ -297,7 +295,6 @@ private:
std::unique_ptr<TypeIdInfo> TIdInfo;
public:
- /// Summary constructors.
FunctionSummary(GVFlags Flags, unsigned NumInsts, std::vector<ValueInfo> Refs,
std::vector<EdgeTy> CGEdges,
std::vector<GlobalValue::GUID> TypeTests,
@@ -418,7 +415,6 @@ template <> struct DenseMapInfo<FunctionSummary::ConstVCall> {
class GlobalVarSummary : public GlobalValueSummary {
public:
- /// Summary constructors.
GlobalVarSummary(GVFlags Flags, std::vector<ValueInfo> Refs)
: GlobalValueSummary(GlobalVarKind, Flags, std::move(Refs)) {}
diff --git a/include/llvm/IR/PatternMatch.h b/include/llvm/IR/PatternMatch.h
index 40f9c21f646bc..31a76b4ed6c32 100644
--- a/include/llvm/IR/PatternMatch.h
+++ b/include/llvm/IR/PatternMatch.h
@@ -267,15 +267,15 @@ inline cst_pred_ty<is_all_ones> m_AllOnes() {
}
inline api_pred_ty<is_all_ones> m_AllOnes(const APInt *&V) { return V; }
-struct is_sign_bit {
- bool isValue(const APInt &C) { return C.isSignBit(); }
+struct is_sign_mask {
+ bool isValue(const APInt &C) { return C.isSignMask(); }
};
/// \brief Match an integer or vector with only the sign bit(s) set.
-inline cst_pred_ty<is_sign_bit> m_SignBit() {
- return cst_pred_ty<is_sign_bit>();
+inline cst_pred_ty<is_sign_mask> m_SignMask() {
+ return cst_pred_ty<is_sign_mask>();
}
-inline api_pred_ty<is_sign_bit> m_SignBit(const APInt *&V) { return V; }
+inline api_pred_ty<is_sign_mask> m_SignMask(const APInt *&V) { return V; }
struct is_power2 {
bool isValue(const APInt &C) { return C.isPowerOf2(); }
diff --git a/include/llvm/IR/Use.h b/include/llvm/IR/Use.h
index 05b68ccbb38e8..6b56546f44219 100644
--- a/include/llvm/IR/Use.h
+++ b/include/llvm/IR/Use.h
@@ -61,9 +61,29 @@ public:
/// that also works with less standard-compliant compilers
void swap(Use &RHS);
+ /// Pointer traits for the UserRef PointerIntPair. This ensures we always
+ /// use the LSB regardless of pointer alignment on different targets.
+ struct UserRefPointerTraits {
+ static inline void *getAsVoidPointer(User *P) { return P; }
+ static inline User *getFromVoidPointer(void *P) {
+ return (User *)P;
+ }
+ enum { NumLowBitsAvailable = 1 };
+ };
+
// A type for the word following an array of hung-off Uses in memory, which is
// a pointer back to their User with the bottom bit set.
- typedef PointerIntPair<User *, 1, unsigned> UserRef;
+ typedef PointerIntPair<User *, 1, unsigned, UserRefPointerTraits> UserRef;
+
+ /// Pointer traits for the Prev PointerIntPair. This ensures we always use
+ /// the two LSBs regardless of pointer alignment on different targets.
+ struct PrevPointerTraits {
+ static inline void *getAsVoidPointer(Use **P) { return P; }
+ static inline Use **getFromVoidPointer(void *P) {
+ return (Use **)P;
+ }
+ enum { NumLowBitsAvailable = 2 };
+ };
private:
/// Destructor - Only for zap()
@@ -115,7 +135,7 @@ private:
Value *Val;
Use *Next;
- PointerIntPair<Use **, 2, PrevPtrTag> Prev;
+ PointerIntPair<Use **, 2, PrevPtrTag, PrevPointerTraits> Prev;
void setPrev(Use **NewPrev) { Prev.setPointer(NewPrev); }