#define LLVM_IR_CFG_H
#include "llvm/ADT/GraphTraits.h"
+#include "llvm/ADT/iterator.h"
#include "llvm/ADT/iterator_range.h"
+#include "llvm/IR/BasicBlock.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/InstrTypes.h"
+#include "llvm/IR/Value.h"
+#include "llvm/Support/Casting.h"
+#include "llvm/Support/type_traits.h"
+#include <cassert>
+#include <cstddef>
+#include <iterator>
namespace llvm {
typedef typename super::pointer pointer;
typedef typename super::reference reference;
- PredIterator() {}
+ PredIterator() = default;
explicit inline PredIterator(Ptr *bb) : It(bb->user_begin()) {
advancePastNonTerminators();
}
typedef PredIterator<BasicBlock, Value::user_iterator> pred_iterator;
typedef PredIterator<const BasicBlock,
Value::const_user_iterator> const_pred_iterator;
-typedef llvm::iterator_range<pred_iterator> pred_range;
-typedef llvm::iterator_range<const_pred_iterator> pred_const_range;
+typedef iterator_range<pred_iterator> pred_range;
+typedef iterator_range<const_pred_iterator> pred_const_range;
inline pred_iterator pred_begin(BasicBlock *BB) { return pred_iterator(BB); }
inline const_pred_iterator pred_begin(const BasicBlock *BB) {
succ_iterator;
typedef TerminatorInst::SuccIterator<const TerminatorInst *, const BasicBlock>
succ_const_iterator;
-typedef llvm::iterator_range<succ_iterator> succ_range;
-typedef llvm::iterator_range<succ_const_iterator> succ_const_range;
+typedef iterator_range<succ_iterator> succ_range;
+typedef iterator_range<succ_const_iterator> succ_const_range;
inline succ_iterator succ_begin(BasicBlock *BB) {
return succ_iterator(BB->getTerminator());
static const bool value = isPodLike<T>::value;
};
-
-
//===--------------------------------------------------------------------===//
// GraphTraits specializations for basic block graphs (CFGs)
//===--------------------------------------------------------------------===//
// a function is considered to be when traversing the predecessor edges of a BB
// instead of the successor edges.
//
-template <> struct GraphTraits<Inverse<BasicBlock*> > {
+template <> struct GraphTraits<Inverse<BasicBlock*>> {
typedef BasicBlock *NodeRef;
typedef pred_iterator ChildIteratorType;
static NodeRef getEntryNode(Inverse<BasicBlock *> G) { return G.Graph; }
static ChildIteratorType child_end(NodeRef N) { return pred_end(N); }
};
-template <> struct GraphTraits<Inverse<const BasicBlock*> > {
+template <> struct GraphTraits<Inverse<const BasicBlock*>> {
typedef const BasicBlock *NodeRef;
typedef const_pred_iterator ChildIteratorType;
static NodeRef getEntryNode(Inverse<const BasicBlock *> G) { return G.Graph; }
static ChildIteratorType child_end(NodeRef N) { return pred_end(N); }
};
-
-
//===--------------------------------------------------------------------===//
// GraphTraits specializations for function basic block graphs (CFGs)
//===--------------------------------------------------------------------===//
// nodes_iterator/begin/end - Allow iteration over all nodes in the graph
typedef pointer_iterator<Function::iterator> nodes_iterator;
+
static nodes_iterator nodes_begin(Function *F) {
return nodes_iterator(F->begin());
}
+
static nodes_iterator nodes_end(Function *F) {
return nodes_iterator(F->end());
}
- static size_t size (Function *F) { return F->size(); }
+
+ static size_t size(Function *F) { return F->size(); }
};
template <> struct GraphTraits<const Function*> :
public GraphTraits<const BasicBlock*> {
// nodes_iterator/begin/end - Allow iteration over all nodes in the graph
typedef pointer_iterator<Function::const_iterator> nodes_iterator;
+
static nodes_iterator nodes_begin(const Function *F) {
return nodes_iterator(F->begin());
}
+
static nodes_iterator nodes_end(const Function *F) {
return nodes_iterator(F->end());
}
- static size_t size (const Function *F) { return F->size(); }
-};
+ static size_t size(const Function *F) { return F->size(); }
+};
// Provide specializations of GraphTraits to be able to treat a function as a
// graph of basic blocks... and to walk it in inverse order. Inverse order for
// a function is considered to be when traversing the predecessor edges of a BB
// instead of the successor edges.
//
-template <> struct GraphTraits<Inverse<Function*> > :
- public GraphTraits<Inverse<BasicBlock*> > {
+template <> struct GraphTraits<Inverse<Function*>> :
+ public GraphTraits<Inverse<BasicBlock*>> {
static NodeRef getEntryNode(Inverse<Function *> G) {
return &G.Graph->getEntryBlock();
}
};
-template <> struct GraphTraits<Inverse<const Function*> > :
- public GraphTraits<Inverse<const BasicBlock*> > {
+template <> struct GraphTraits<Inverse<const Function*>> :
+ public GraphTraits<Inverse<const BasicBlock*>> {
static NodeRef getEntryNode(Inverse<const Function *> G) {
return &G.Graph->getEntryBlock();
}
};
-} // End llvm namespace
+} // end namespace llvm
-#endif
+#endif // LLVM_IR_CFG_H
#ifndef LLVM_IR_CALLSITE_H
#define LLVM_IR_CALLSITE_H
-#include "llvm/ADT/PointerIntPair.h"
#include "llvm/ADT/iterator_range.h"
+#include "llvm/ADT/Optional.h"
+#include "llvm/ADT/PointerIntPair.h"
#include "llvm/IR/Attributes.h"
#include "llvm/IR/CallingConv.h"
+#include "llvm/IR/Function.h"
+#include "llvm/IR/InstrTypes.h"
+#include "llvm/IR/Instruction.h"
#include "llvm/IR/Instructions.h"
+#include "llvm/IR/Intrinsics.h"
+#include "llvm/Support/Casting.h"
+#include "llvm/IR/Use.h"
+#include "llvm/IR/User.h"
+#include "llvm/IR/Value.h"
+#include <cassert>
+#include <cstdint>
+#include <iterator>
namespace llvm {
-class CallInst;
-class InvokeInst;
-
template <typename FunTy = const Function,
typename BBTy = const BasicBlock,
typename ValTy = const Value,
Instruction, CallInst, InvokeInst,
User::op_iterator> {
public:
- CallSite() {}
+ CallSite() = default;
CallSite(CallSiteBase B) : CallSiteBase(B) {}
CallSite(CallInst *CI) : CallSiteBase(CI) {}
CallSite(InvokeInst *II) : CallSiteBase(II) {}
private:
friend struct DenseMapInfo<CallSite>;
+
User::op_iterator getCallee() const;
};
template <> struct DenseMapInfo<CallSite> {
- using BaseInfo = llvm::DenseMapInfo<decltype(CallSite::I)>;
+ using BaseInfo = DenseMapInfo<decltype(CallSite::I)>;
static CallSite getEmptyKey() {
CallSite CS;
CS.I = BaseInfo::getEmptyKey();
return CS;
}
+
static CallSite getTombstoneKey() {
CallSite CS;
CS.I = BaseInfo::getTombstoneKey();
return CS;
}
+
static unsigned getHashValue(const CallSite &CS) {
return BaseInfo::getHashValue(CS.I);
}
+
static bool isEqual(const CallSite &LHS, const CallSite &RHS) {
return LHS == RHS;
}
/// ImmutableCallSite - establish a view to a call site for examination
class ImmutableCallSite : public CallSiteBase<> {
public:
- ImmutableCallSite() {}
+ ImmutableCallSite() = default;
ImmutableCallSite(const CallInst *CI) : CallSiteBase(CI) {}
ImmutableCallSite(const InvokeInst *II) : CallSiteBase(II) {}
explicit ImmutableCallSite(const Instruction *II) : CallSiteBase(II) {}
ImmutableCallSite(CallSite CS) : CallSiteBase(CS.getInstruction()) {}
};
-} // End llvm namespace
+} // end namespace llvm
-#endif
+#endif // LLVM_IR_CALLSITE_H
#ifndef LLVM_IR_CONSTANTFOLDER_H
#define LLVM_IR_CONSTANTFOLDER_H
+#include "llvm/ADT/ArrayRef.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/InstrTypes.h"
+#include "llvm/IR/Instruction.h"
namespace llvm {
/// ConstantFolder - Create constants with minimum, target independent, folding.
class ConstantFolder {
public:
- explicit ConstantFolder() {}
+ explicit ConstantFolder() = default;
//===--------------------------------------------------------------------===//
// Binary Operators
bool HasNUW = false, bool HasNSW = false) const {
return ConstantExpr::getAdd(LHS, RHS, HasNUW, HasNSW);
}
+
Constant *CreateFAdd(Constant *LHS, Constant *RHS) const {
return ConstantExpr::getFAdd(LHS, RHS);
}
+
Constant *CreateSub(Constant *LHS, Constant *RHS,
bool HasNUW = false, bool HasNSW = false) const {
return ConstantExpr::getSub(LHS, RHS, HasNUW, HasNSW);
}
+
Constant *CreateFSub(Constant *LHS, Constant *RHS) const {
return ConstantExpr::getFSub(LHS, RHS);
}
+
Constant *CreateMul(Constant *LHS, Constant *RHS,
bool HasNUW = false, bool HasNSW = false) const {
return ConstantExpr::getMul(LHS, RHS, HasNUW, HasNSW);
}
+
Constant *CreateFMul(Constant *LHS, Constant *RHS) const {
return ConstantExpr::getFMul(LHS, RHS);
}
+
Constant *CreateUDiv(Constant *LHS, Constant *RHS,
bool isExact = false) const {
return ConstantExpr::getUDiv(LHS, RHS, isExact);
}
+
Constant *CreateSDiv(Constant *LHS, Constant *RHS,
bool isExact = false) const {
return ConstantExpr::getSDiv(LHS, RHS, isExact);
}
+
Constant *CreateFDiv(Constant *LHS, Constant *RHS) const {
return ConstantExpr::getFDiv(LHS, RHS);
}
+
Constant *CreateURem(Constant *LHS, Constant *RHS) const {
return ConstantExpr::getURem(LHS, RHS);
}
+
Constant *CreateSRem(Constant *LHS, Constant *RHS) const {
return ConstantExpr::getSRem(LHS, RHS);
}
+
Constant *CreateFRem(Constant *LHS, Constant *RHS) const {
return ConstantExpr::getFRem(LHS, RHS);
}
+
Constant *CreateShl(Constant *LHS, Constant *RHS,
bool HasNUW = false, bool HasNSW = false) const {
return ConstantExpr::getShl(LHS, RHS, HasNUW, HasNSW);
}
+
Constant *CreateLShr(Constant *LHS, Constant *RHS,
bool isExact = false) const {
return ConstantExpr::getLShr(LHS, RHS, isExact);
}
+
Constant *CreateAShr(Constant *LHS, Constant *RHS,
bool isExact = false) const {
return ConstantExpr::getAShr(LHS, RHS, isExact);
}
+
Constant *CreateAnd(Constant *LHS, Constant *RHS) const {
return ConstantExpr::getAnd(LHS, RHS);
}
+
Constant *CreateOr(Constant *LHS, Constant *RHS) const {
return ConstantExpr::getOr(LHS, RHS);
}
+
Constant *CreateXor(Constant *LHS, Constant *RHS) const {
return ConstantExpr::getXor(LHS, RHS);
}
bool HasNUW = false, bool HasNSW = false) const {
return ConstantExpr::getNeg(C, HasNUW, HasNSW);
}
+
Constant *CreateFNeg(Constant *C) const {
return ConstantExpr::getFNeg(C);
}
+
Constant *CreateNot(Constant *C) const {
return ConstantExpr::getNot(C);
}
ArrayRef<Constant *> IdxList) const {
return ConstantExpr::getGetElementPtr(Ty, C, IdxList);
}
+
Constant *CreateGetElementPtr(Type *Ty, Constant *C, Constant *Idx) const {
// This form of the function only exists to avoid ambiguous overload
// warnings about whether to convert Idx to ArrayRef<Constant *> or
// ArrayRef<Value *>.
return ConstantExpr::getGetElementPtr(Ty, C, Idx);
}
+
Constant *CreateGetElementPtr(Type *Ty, Constant *C,
ArrayRef<Value *> IdxList) const {
return ConstantExpr::getGetElementPtr(Ty, C, IdxList);
ArrayRef<Constant *> IdxList) const {
return ConstantExpr::getInBoundsGetElementPtr(Ty, C, IdxList);
}
+
Constant *CreateInBoundsGetElementPtr(Type *Ty, Constant *C,
Constant *Idx) const {
// This form of the function only exists to avoid ambiguous overload
// ArrayRef<Value *>.
return ConstantExpr::getInBoundsGetElementPtr(Ty, C, Idx);
}
+
Constant *CreateInBoundsGetElementPtr(Type *Ty, Constant *C,
ArrayRef<Value *> IdxList) const {
return ConstantExpr::getInBoundsGetElementPtr(Ty, C, IdxList);
Type *DestTy) const {
return ConstantExpr::getCast(Op, C, DestTy);
}
+
Constant *CreatePointerCast(Constant *C, Type *DestTy) const {
return ConstantExpr::getPointerCast(C, DestTy);
}
bool isSigned) const {
return ConstantExpr::getIntegerCast(C, DestTy, isSigned);
}
+
Constant *CreateFPCast(Constant *C, Type *DestTy) const {
return ConstantExpr::getFPCast(C, DestTy);
}
Constant *CreateBitCast(Constant *C, Type *DestTy) const {
return CreateCast(Instruction::BitCast, C, DestTy);
}
+
Constant *CreateIntToPtr(Constant *C, Type *DestTy) const {
return CreateCast(Instruction::IntToPtr, C, DestTy);
}
+
Constant *CreatePtrToInt(Constant *C, Type *DestTy) const {
return CreateCast(Instruction::PtrToInt, C, DestTy);
}
+
Constant *CreateZExtOrBitCast(Constant *C, Type *DestTy) const {
return ConstantExpr::getZExtOrBitCast(C, DestTy);
}
+
Constant *CreateSExtOrBitCast(Constant *C, Type *DestTy) const {
return ConstantExpr::getSExtOrBitCast(C, DestTy);
}
Constant *RHS) const {
return ConstantExpr::getCompare(P, LHS, RHS);
}
+
Constant *CreateFCmp(CmpInst::Predicate P, Constant *LHS,
Constant *RHS) const {
return ConstantExpr::getCompare(P, LHS, RHS);
}
};
-}
+} // end namespace llvm
-#endif
+#endif // LLVM_IR_CONSTANTFOLDER_H
#ifndef LLVM_IR_DEBUGINFOMETADATA_H
#define LLVM_IR_DEBUGINFOMETADATA_H
+#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/BitmaskEnum.h"
+#include "llvm/ADT/None.h"
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/StringRef.h"
#include "llvm/IR/Metadata.h"
+#include "llvm/Support/Casting.h"
#include "llvm/Support/Dwarf.h"
+#include <cassert>
+#include <climits>
+#include <cstddef>
+#include <cstdint>
+#include <iterator>
+#include <type_traits>
+#include <vector>
// Helper macros for defining get() overrides.
#define DEFINE_MDNODE_GET_UNPACK_IMPL(...) __VA_ARGS__
public:
iterator() = default;
explicit iterator(MDNode::op_iterator I) : I(I) {}
+
DITypeRef operator*() const { return DITypeRef(*I); }
+
iterator &operator++() {
++I;
return *this;
}
+
iterator operator++(int) {
iterator Temp(*this);
++I;
return Temp;
}
+
bool operator==(const iterator &X) const { return I == X.I; }
bool operator!=(const iterator &X) const { return I != X.I; }
};
class DICompileUnit : public DIScope {
friend class LLVMContextImpl;
friend class MDNode;
+
public:
enum DebugEmissionKind : unsigned {
NoDebug = 0,
LineTablesOnly,
LastEmissionKind = LineTablesOnly
};
+
static Optional<DebugEmissionKind> getEmissionKind(StringRef Str);
static const char *EmissionKindString(DebugEmissionKind EK);
getMacros(), DWOId, getSplitDebugInlining());
}
+public:
static void get() = delete;
static void getIfExists() = delete;
-public:
DEFINE_MDNODE_GET_DISTINCT_TEMPORARY(
DICompileUnit,
(unsigned SourceLanguage, DIFile *File, StringRef Producer,
getRawInlinedAt());
}
+public:
// Disallow replacing operands.
void replaceOperandWith(unsigned I, Metadata *New) = delete;
-public:
DEFINE_MDNODE_GET(DILocation,
(unsigned Line, unsigned Column, Metadata *Scope,
Metadata *InlinedAt = nullptr),
DIModule(LLVMContext &Context, StorageType Storage, ArrayRef<Metadata *> Ops)
: DIScope(Context, DIModuleKind, Storage, dwarf::DW_TAG_module, Ops) {}
- ~DIModule() {}
+ ~DIModule() = default;
static DIModule *getImpl(LLVMContext &Context, DIScope *Scope,
StringRef Name, StringRef ConfigurationMacros,
#undef DEFINE_MDNODE_GET_UNPACK
#undef DEFINE_MDNODE_GET
-#endif
+#endif // LLVM_IR_DEBUGINFOMETADATA_H
#ifndef LLVM_IR_DIAGNOSTICINFO_H
#define LLVM_IR_DIAGNOSTICINFO_H
-#include "llvm-c/Types.h"
+#include "llvm/ADT/None.h"
#include "llvm/ADT/Optional.h"
-#include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/Twine.h"
#include "llvm/IR/DebugLoc.h"
#include "llvm/Support/CBindingWrapping.h"
#include "llvm/Support/YAMLTraits.h"
+#include "llvm-c/Types.h"
#include <functional>
+#include <algorithm>
+#include <cstdint>
+#include <iterator>
#include <string>
namespace llvm {
DiagnosticInfo(/* DiagnosticKind */ int Kind, DiagnosticSeverity Severity)
: Kind(Kind), Severity(Severity) {}
- virtual ~DiagnosticInfo() {}
+ virtual ~DiagnosticInfo() = default;
/* DiagnosticKind */ int getKind() const { return Kind; }
DiagnosticSeverity getSeverity() const { return Severity; }
}
};
-
/// Diagnostic information for the sample profiler.
class DiagnosticInfoSampleProfile : public DiagnosticInfo {
public:
#include <string>
namespace llvm {
+
// Forward declarations.
class Module;
class raw_ostream;
/// \brief Interface for custom diagnostic printing.
class DiagnosticPrinter {
public:
- virtual ~DiagnosticPrinter() {}
+ virtual ~DiagnosticPrinter() = default;
// Simple types.
virtual DiagnosticPrinter &operator<<(char C) = 0;
// Other types.
DiagnosticPrinter &operator<<(const SMDiagnostic &Diag) override;
};
-} // End namespace llvm
-#endif
+} // end namespace llvm
+
+#endif // LLVM_IR_DIAGNOSTICPRINTER_H
#include <vector>
namespace llvm {
+
class Error;
-class Function;
class GlobalValue;
-class Module;
class StructType;
class GVMaterializer {
protected:
- GVMaterializer() {}
+ GVMaterializer() = default;
public:
virtual ~GVMaterializer();
virtual std::vector<StructType *> getIdentifiedStructTypes() const = 0;
};
-} // End llvm namespace
+} // end namespace llvm
-#endif
+#endif // LLVM_IR_GVMATERIALIZER_H
#ifndef LLVM_IR_GETELEMENTPTRTYPEITERATOR_H
#define LLVM_IR_GETELEMENTPTRTYPEITERATOR_H
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/PointerIntPair.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/Operator.h"
#include "llvm/IR/User.h"
-#include "llvm/ADT/PointerIntPair.h"
+#include "llvm/Support/Casting.h"
+#include <cstddef>
+#include <iterator>
namespace llvm {
+
template<typename ItTy = User::const_op_iterator>
class generic_gep_type_iterator
: public std::iterator<std::forward_iterator_tag, Type *, ptrdiff_t> {
ItTy OpIt;
PointerIntPair<Type *, 1> CurTy;
unsigned AddrSpace;
- generic_gep_type_iterator() {}
- public:
+ generic_gep_type_iterator() = default;
+
+ public:
static generic_gep_type_iterator begin(Type *Ty, unsigned AddrSpace,
ItTy It) {
generic_gep_type_iterator I;
I.OpIt = It;
return I;
}
+
static generic_gep_type_iterator end(ItTy It) {
generic_gep_type_iterator I;
I.OpIt = It;
bool operator==(const generic_gep_type_iterator& x) const {
return OpIt == x.OpIt;
}
+
bool operator!=(const generic_gep_type_iterator& x) const {
return !operator==(x);
}
->getAddressSpace(),
GEP->op_begin() + 1);
}
+
inline gep_type_iterator gep_type_end(const User *GEP) {
return gep_type_iterator::end(GEP->op_end());
}
+
inline gep_type_iterator gep_type_begin(const User &GEP) {
auto &GEPOp = cast<GEPOperator>(GEP);
return gep_type_iterator::begin(
->getAddressSpace(),
GEP.op_begin() + 1);
}
+
inline gep_type_iterator gep_type_end(const User &GEP) {
return gep_type_iterator::end(GEP.op_end());
}
gep_type_end(Type * /*Op0*/, unsigned /*AS*/, ArrayRef<T> A) {
return generic_gep_type_iterator<const T *>::end(A.end());
}
+
} // end namespace llvm
-#endif
+#endif // LLVM_IR_GETELEMENTPTRTYPEITERATOR_H
#ifndef LLVM_IR_INSTITERATOR_H
#define LLVM_IR_INSTITERATOR_H
+#include "llvm/ADT/iterator_range.h"
#include "llvm/IR/BasicBlock.h"
#include "llvm/IR/Function.h"
+#include "llvm/IR/SymbolTableListTraits.h"
+#include <iterator>
namespace llvm {
BB_t *BBs; // BasicBlocksType
BB_i_t BB; // BasicBlocksType::iterator
BI_t BI; // BasicBlock::iterator
+
public:
typedef std::bidirectional_iterator_tag iterator_category;
typedef IIty value_type;
typedef IIty& reference;
// Default constructor
- InstIterator() {}
+ InstIterator() = default;
// Copy constructor...
template<typename A, typename B, typename C, typename D>
--BI;
return *this;
}
- inline InstIterator operator--(int) {
+ inline InstIterator operator--(int) {
InstIterator tmp = *this; --*this; return tmp;
}
return const_inst_range(inst_begin(F), inst_end(F));
}
-} // End llvm namespace
+} // end namespace llvm
-#endif
+#endif // LLVM_IR_INSTITERATOR_H
#ifndef LLVM_IR_INSTRTYPES_H
#define LLVM_IR_INSTRTYPES_H
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/iterator_range.h"
+#include "llvm/ADT/None.h"
#include "llvm/ADT/Optional.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/StringMap.h"
+#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/Twine.h"
#include "llvm/IR/Attributes.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/Instruction.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/OperandTraits.h"
+#include "llvm/IR/User.h"
+#include "llvm/Support/Casting.h"
+#include "llvm/Support/ErrorHandling.h"
+#include <algorithm>
+#include <cassert>
+#include <cstddef>
+#include <cstdint>
+#include <iterator>
+#include <string>
+#include <vector>
namespace llvm {
-class LLVMContext;
-
//===----------------------------------------------------------------------===//
// TerminatorInst Class
//===----------------------------------------------------------------------===//
typedef SuccIterator<TerminatorInst *, BasicBlock> succ_iterator;
typedef SuccIterator<const TerminatorInst *, const BasicBlock>
succ_const_iterator;
- typedef llvm::iterator_range<succ_iterator> succ_range;
- typedef llvm::iterator_range<succ_const_iterator> succ_const_range;
+ typedef iterator_range<succ_iterator> succ_range;
+ typedef iterator_range<succ_const_iterator> succ_const_range;
private:
inline succ_iterator succ_begin() { return succ_iterator(this); }
//===----------------------------------------------------------------------===//
class UnaryInstruction : public Instruction {
- void *operator new(size_t, unsigned) = delete;
-
protected:
UnaryInstruction(Type *Ty, unsigned iType, Value *V,
Instruction *IB = nullptr)
return User::operator new(s, 1);
}
+ void *operator new(size_t, unsigned) = delete;
+
// Out of line virtual method, so the vtable, etc has a home.
~UnaryInstruction() override;
//===----------------------------------------------------------------------===//
class BinaryOperator : public Instruction {
- void *operator new(size_t, unsigned) = delete;
-
protected:
void init(BinaryOps iType);
BinaryOperator(BinaryOps iType, Value *S1, Value *S2, Type *Ty,
return User::operator new(s, 2);
}
+ void *operator new(size_t, unsigned) = delete;
+
/// Transparently provide more efficient getOperand methods.
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
BAD_ICMP_PREDICATE = ICMP_SLE + 1
};
-private:
- void *operator new(size_t, unsigned) = delete;
- CmpInst() = delete;
-
protected:
CmpInst(Type *ty, Instruction::OtherOps op, Predicate pred,
Value *LHS, Value *RHS, const Twine &Name = "",
void anchor() override; // Out of line virtual method.
public:
+ CmpInst() = delete;
+
// allocate space for exactly two operands
void *operator new(size_t s) {
return User::operator new(s, 2);
}
+
+ void *operator new(size_t, unsigned) = delete;
+
/// Construct a compare instruction, given the opcode, the predicate and
/// the two operands. Optionally (if InstBefore is specified) insert the
/// instruction into a BasicBlock right before the specified instruction.
struct OperandBundleUse {
ArrayRef<Use> Inputs;
- OperandBundleUse() {}
+ OperandBundleUse() = default;
explicit OperandBundleUse(StringMapEntry<uint32_t> *Tag, ArrayRef<Use> Inputs)
: Inputs(Inputs), Tag(Tag) {}
#include "llvm/ADT/ArrayRef.h"
#include "llvm/IR/Constants.h"
+#include "llvm/IR/InstrTypes.h"
+#include "llvm/IR/Instruction.h"
#include "llvm/IR/Instructions.h"
namespace llvm {
/// NoFolder - Create "constants" (actually, instructions) with no folding.
class NoFolder {
public:
- explicit NoFolder() {}
+ explicit NoFolder() = default;
//===--------------------------------------------------------------------===//
// Binary Operators
if (HasNSW) BO->setHasNoSignedWrap();
return BO;
}
+
Instruction *CreateNSWAdd(Constant *LHS, Constant *RHS) const {
return BinaryOperator::CreateNSWAdd(LHS, RHS);
}
+
Instruction *CreateNUWAdd(Constant *LHS, Constant *RHS) const {
return BinaryOperator::CreateNUWAdd(LHS, RHS);
}
+
Instruction *CreateFAdd(Constant *LHS, Constant *RHS) const {
return BinaryOperator::CreateFAdd(LHS, RHS);
}
+
Instruction *CreateSub(Constant *LHS, Constant *RHS,
bool HasNUW = false, bool HasNSW = false) const {
BinaryOperator *BO = BinaryOperator::CreateSub(LHS, RHS);
if (HasNSW) BO->setHasNoSignedWrap();
return BO;
}
+
Instruction *CreateNSWSub(Constant *LHS, Constant *RHS) const {
return BinaryOperator::CreateNSWSub(LHS, RHS);
}
+
Instruction *CreateNUWSub(Constant *LHS, Constant *RHS) const {
return BinaryOperator::CreateNUWSub(LHS, RHS);
}
+
Instruction *CreateFSub(Constant *LHS, Constant *RHS) const {
return BinaryOperator::CreateFSub(LHS, RHS);
}
+
Instruction *CreateMul(Constant *LHS, Constant *RHS,
bool HasNUW = false, bool HasNSW = false) const {
BinaryOperator *BO = BinaryOperator::CreateMul(LHS, RHS);
if (HasNSW) BO->setHasNoSignedWrap();
return BO;
}
+
Instruction *CreateNSWMul(Constant *LHS, Constant *RHS) const {
return BinaryOperator::CreateNSWMul(LHS, RHS);
}
+
Instruction *CreateNUWMul(Constant *LHS, Constant *RHS) const {
return BinaryOperator::CreateNUWMul(LHS, RHS);
}
+
Instruction *CreateFMul(Constant *LHS, Constant *RHS) const {
return BinaryOperator::CreateFMul(LHS, RHS);
}
+
Instruction *CreateUDiv(Constant *LHS, Constant *RHS,
bool isExact = false) const {
if (!isExact)
return BinaryOperator::CreateUDiv(LHS, RHS);
return BinaryOperator::CreateExactUDiv(LHS, RHS);
}
+
Instruction *CreateExactUDiv(Constant *LHS, Constant *RHS) const {
return BinaryOperator::CreateExactUDiv(LHS, RHS);
}
+
Instruction *CreateSDiv(Constant *LHS, Constant *RHS,
bool isExact = false) const {
if (!isExact)
return BinaryOperator::CreateSDiv(LHS, RHS);
return BinaryOperator::CreateExactSDiv(LHS, RHS);
}
+
Instruction *CreateExactSDiv(Constant *LHS, Constant *RHS) const {
return BinaryOperator::CreateExactSDiv(LHS, RHS);
}
+
Instruction *CreateFDiv(Constant *LHS, Constant *RHS) const {
return BinaryOperator::CreateFDiv(LHS, RHS);
}
+
Instruction *CreateURem(Constant *LHS, Constant *RHS) const {
return BinaryOperator::CreateURem(LHS, RHS);
}
+
Instruction *CreateSRem(Constant *LHS, Constant *RHS) const {
return BinaryOperator::CreateSRem(LHS, RHS);
}
+
Instruction *CreateFRem(Constant *LHS, Constant *RHS) const {
return BinaryOperator::CreateFRem(LHS, RHS);
}
+
Instruction *CreateShl(Constant *LHS, Constant *RHS, bool HasNUW = false,
bool HasNSW = false) const {
BinaryOperator *BO = BinaryOperator::CreateShl(LHS, RHS);
if (HasNSW) BO->setHasNoSignedWrap();
return BO;
}
+
Instruction *CreateLShr(Constant *LHS, Constant *RHS,
bool isExact = false) const {
if (!isExact)
return BinaryOperator::CreateLShr(LHS, RHS);
return BinaryOperator::CreateExactLShr(LHS, RHS);
}
+
Instruction *CreateAShr(Constant *LHS, Constant *RHS,
bool isExact = false) const {
if (!isExact)
return BinaryOperator::CreateAShr(LHS, RHS);
return BinaryOperator::CreateExactAShr(LHS, RHS);
}
+
Instruction *CreateAnd(Constant *LHS, Constant *RHS) const {
return BinaryOperator::CreateAnd(LHS, RHS);
}
+
Instruction *CreateOr(Constant *LHS, Constant *RHS) const {
return BinaryOperator::CreateOr(LHS, RHS);
}
+
Instruction *CreateXor(Constant *LHS, Constant *RHS) const {
return BinaryOperator::CreateXor(LHS, RHS);
}
if (HasNSW) BO->setHasNoSignedWrap();
return BO;
}
+
Instruction *CreateNSWNeg(Constant *C) const {
return BinaryOperator::CreateNSWNeg(C);
}
+
Instruction *CreateNUWNeg(Constant *C) const {
return BinaryOperator::CreateNUWNeg(C);
}
+
Instruction *CreateFNeg(Constant *C) const {
return BinaryOperator::CreateFNeg(C);
}
+
Instruction *CreateNot(Constant *C) const {
return BinaryOperator::CreateNot(C);
}
ArrayRef<Constant *> IdxList) const {
return ConstantExpr::getGetElementPtr(Ty, C, IdxList);
}
+
Constant *CreateGetElementPtr(Type *Ty, Constant *C, Constant *Idx) const {
// This form of the function only exists to avoid ambiguous overload
// warnings about whether to convert Idx to ArrayRef<Constant *> or
// ArrayRef<Value *>.
return ConstantExpr::getGetElementPtr(Ty, C, Idx);
}
+
Instruction *CreateGetElementPtr(Type *Ty, Constant *C,
ArrayRef<Value *> IdxList) const {
return GetElementPtrInst::Create(Ty, C, IdxList);
ArrayRef<Constant *> IdxList) const {
return ConstantExpr::getInBoundsGetElementPtr(Ty, C, IdxList);
}
+
Constant *CreateInBoundsGetElementPtr(Type *Ty, Constant *C,
Constant *Idx) const {
// This form of the function only exists to avoid ambiguous overload
// ArrayRef<Value *>.
return ConstantExpr::getInBoundsGetElementPtr(Ty, C, Idx);
}
+
Instruction *CreateInBoundsGetElementPtr(Type *Ty, Constant *C,
ArrayRef<Value *> IdxList) const {
return GetElementPtrInst::CreateInBounds(Ty, C, IdxList);
Type *DestTy) const {
return CastInst::Create(Op, C, DestTy);
}
+
Instruction *CreatePointerCast(Constant *C, Type *DestTy) const {
return CastInst::CreatePointerCast(C, DestTy);
}
+
Instruction *CreateIntCast(Constant *C, Type *DestTy,
bool isSigned) const {
return CastInst::CreateIntegerCast(C, DestTy, isSigned);
}
+
Instruction *CreateFPCast(Constant *C, Type *DestTy) const {
return CastInst::CreateFPCast(C, DestTy);
}
Instruction *CreateBitCast(Constant *C, Type *DestTy) const {
return CreateCast(Instruction::BitCast, C, DestTy);
}
+
Instruction *CreateIntToPtr(Constant *C, Type *DestTy) const {
return CreateCast(Instruction::IntToPtr, C, DestTy);
}
+
Instruction *CreatePtrToInt(Constant *C, Type *DestTy) const {
return CreateCast(Instruction::PtrToInt, C, DestTy);
}
+
Instruction *CreateZExtOrBitCast(Constant *C, Type *DestTy) const {
return CastInst::CreateZExtOrBitCast(C, DestTy);
}
+
Instruction *CreateSExtOrBitCast(Constant *C, Type *DestTy) const {
return CastInst::CreateSExtOrBitCast(C, DestTy);
}
Constant *LHS, Constant *RHS) const {
return new ICmpInst(P, LHS, RHS);
}
+
Instruction *CreateFCmp(CmpInst::Predicate P,
Constant *LHS, Constant *RHS) const {
return new FCmpInst(P, LHS, RHS);
}
};
-}
+} // end namespace llvm
-#endif
+#endif // LLVM_IR_NOFOLDER_H
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringRef.h"
+#include <memory>
+#include <utility>
namespace llvm {
template <typename IRUnitT, typename AnalysisManagerT, typename... ExtraArgTs>
struct PassConcept {
// Boiler plate necessary for the container of derived classes.
- virtual ~PassConcept() {}
+ virtual ~PassConcept() = default;
/// \brief The polymorphic API which runs the pass over a given IR entity.
///
// refuses to generate them.
PassModel(const PassModel &Arg) : Pass(Arg.Pass) {}
PassModel(PassModel &&Arg) : Pass(std::move(Arg.Pass)) {}
+
friend void swap(PassModel &LHS, PassModel &RHS) {
using std::swap;
swap(LHS.Pass, RHS.Pass);
}
+
PassModel &operator=(PassModel RHS) {
swap(*this, RHS);
return *this;
ExtraArgTs... ExtraArgs) override {
return Pass.run(IR, AM, ExtraArgs...);
}
+
StringRef name() override { return PassT::name(); }
+
PassT Pass;
};
/// This concept is parameterized over the IR unit that this result pertains
/// to.
template <typename IRUnitT> struct AnalysisResultConcept {
- virtual ~AnalysisResultConcept() {}
+ virtual ~AnalysisResultConcept() = default;
/// \brief Method to try and mark a result as invalid.
///
AnalysisResultModel(const AnalysisResultModel &Arg) : Result(Arg.Result) {}
AnalysisResultModel(AnalysisResultModel &&Arg)
: Result(std::move(Arg.Result)) {}
+
friend void swap(AnalysisResultModel &LHS, AnalysisResultModel &RHS) {
using std::swap;
swap(LHS.Result, RHS.Result);
}
+
AnalysisResultModel &operator=(AnalysisResultModel RHS) {
swap(*this, RHS);
return *this;
AnalysisResultModel(const AnalysisResultModel &Arg) : Result(Arg.Result) {}
AnalysisResultModel(AnalysisResultModel &&Arg)
: Result(std::move(Arg.Result)) {}
+
friend void swap(AnalysisResultModel &LHS, AnalysisResultModel &RHS) {
using std::swap;
swap(LHS.Result, RHS.Result);
}
+
AnalysisResultModel &operator=(AnalysisResultModel RHS) {
swap(*this, RHS);
return *this;
/// This concept is parameterized over the IR unit that it can run over and
/// produce an analysis result.
template <typename IRUnitT, typename... ExtraArgTs> struct AnalysisPassConcept {
- virtual ~AnalysisPassConcept() {}
+ virtual ~AnalysisPassConcept() = default;
/// \brief Method to run this analysis over a unit of IR.
/// \returns A unique_ptr to the analysis result object to be queried by
// refuses to generate them.
AnalysisPassModel(const AnalysisPassModel &Arg) : Pass(Arg.Pass) {}
AnalysisPassModel(AnalysisPassModel &&Arg) : Pass(std::move(Arg.Pass)) {}
+
friend void swap(AnalysisPassModel &LHS, AnalysisPassModel &RHS) {
using std::swap;
swap(LHS.Pass, RHS.Pass);
}
+
AnalysisPassModel &operator=(AnalysisPassModel RHS) {
swap(*this, RHS);
return *this;
PassT Pass;
};
-} // End namespace detail
-}
+} // end namespace detail
+
+} // end namespace llvm
-#endif
+#endif // LLVM_IR_PASSMANAGERINTERNAL_H