#ifndef LLVM_IR_BASICBLOCK_H
#define LLVM_IR_BASICBLOCK_H
-#include "llvm/ADT/Twine.h"
#include "llvm/ADT/ilist.h"
+#include "llvm/ADT/ilist_node.h"
+#include "llvm/ADT/Twine.h"
#include "llvm/IR/Instruction.h"
#include "llvm/IR/SymbolTableListTraits.h"
+#include "llvm/IR/Value.h"
#include "llvm/Support/CBindingWrapping.h"
-#include "llvm/Support/DataTypes.h"
+#include "llvm-c/Types.h"
+#include <cassert>
+#include <cstddef>
namespace llvm {
class CallInst;
+class Function;
class LandingPadInst;
-class TerminatorInst;
class LLVMContext;
-class BlockAddress;
-class Function;
+class TerminatorInst;
/// \brief LLVM Basic Block Representation
///
/// are "well formed".
class BasicBlock : public Value, // Basic blocks are data objects also
public ilist_node_with_parent<BasicBlock, Function> {
- friend class BlockAddress;
public:
typedef SymbolTableList<Instruction> InstListType;
private:
+ friend class BlockAddress;
+ friend class SymbolTableListTraits<BasicBlock>;
+
InstListType InstList;
Function *Parent;
void setParent(Function *parent);
- friend class SymbolTableListTraits<BasicBlock>;
-
- BasicBlock(const BasicBlock &) = delete;
- void operator=(const BasicBlock &) = delete;
/// \brief Constructor.
///
explicit BasicBlock(LLVMContext &C, const Twine &Name = "",
Function *Parent = nullptr,
BasicBlock *InsertBefore = nullptr);
+
public:
+ BasicBlock(const BasicBlock &) = delete;
+ BasicBlock &operator=(const BasicBlock &) = delete;
+ ~BasicBlock() override;
+
/// \brief Get the context in which this basic block lives.
LLVMContext &getContext() const;
BasicBlock *InsertBefore = nullptr) {
return new BasicBlock(Context, Name, Parent, InsertBefore);
}
- ~BasicBlock() override;
/// \brief Return the enclosing method, or null if none.
const Function *getParent() const { return Parent; }
assert((int)(signed char)getSubclassDataFromValue() >= 0 &&
"Refcount wrap-around");
}
+
/// \brief Shadow Value::setValueSubclassData with a private forwarding method
/// so that any future subclasses cannot accidentally use it.
void setValueSubclassData(unsigned short D) {
// Create wrappers for C Binding types (see CBindingWrapping.h).
DEFINE_SIMPLE_CONVERSION_FUNCTIONS(BasicBlock, LLVMBasicBlockRef)
-} // End llvm namespace
+} // end namespace llvm
-#endif
+#endif // LLVM_IR_BASICBLOCK_H
SameSize, ///< The data referenced by the COMDAT must be the same size.
};
+ Comdat(const Comdat &) = delete;
Comdat(Comdat &&C);
+
SelectionKind getSelectionKind() const { return SK; }
void setSelectionKind(SelectionKind Val) { SK = Val; }
StringRef getName() const;
private:
friend class Module;
+
Comdat();
- Comdat(const Comdat &) = delete;
// Points to the map in Module.
StringMapEntry<Comdat> *Name;
return OS;
}
-} // end llvm namespace
+} // end namespace llvm
-#endif
+#endif // LLVM_IR_COMDAT_H
#ifndef LLVM_IR_DIBUILDER_H
#define LLVM_IR_DIBUILDER_H
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/None.h"
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/StringRef.h"
#include "llvm/IR/DebugInfo.h"
+#include "llvm/IR/DebugInfoMetadata.h"
#include "llvm/IR/TrackingMDRef.h"
-#include "llvm/IR/ValueHandle.h"
-#include "llvm/Support/DataTypes.h"
+#include "llvm/Support/Casting.h"
+#include <algorithm>
+#include <cstdint>
namespace llvm {
+
class BasicBlock;
- class Instruction;
+ class Constant;
class Function;
+ class Instruction;
+ class LLVMContext;
class Module;
class Value;
- class Constant;
- class LLVMContext;
- class StringRef;
- template <typename T> class ArrayRef;
class DIBuilder {
Module &M;
/// copy.
DenseMap<MDNode *, SmallVector<TrackingMDNodeRef, 1>> PreservedVariables;
- DIBuilder(const DIBuilder &) = delete;
- void operator=(const DIBuilder &) = delete;
-
/// Create a temporary.
///
/// Create an \a temporary node and track it in \a UnresolvedNodes.
/// If \c AllowUnresolved, collect unresolved nodes attached to the module
/// in order to resolve cycles during \a finalize().
explicit DIBuilder(Module &M, bool AllowUnresolved = true);
+ DIBuilder(const DIBuilder &) = delete;
+ DIBuilder &operator=(const DIBuilder &) = delete;
/// Construct any deferred debug info descriptors.
void finalize();
DIDerivedType *createStaticMemberType(DIScope *Scope, StringRef Name,
DIFile *File, unsigned LineNo,
DIType *Ty, DINode::DIFlags Flags,
- llvm::Constant *Val,
+ Constant *Val,
uint32_t AlignInBits = 0);
/// Create debugging information entry for Objective-C
return Replacement;
}
};
+
} // end namespace llvm
-#endif
+#endif // LLVM_IR_DIBUILDER_H
#ifndef LLVM_IR_GLOBALVALUE_H
#define LLVM_IR_GLOBALVALUE_H
+#include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/Twine.h"
#include "llvm/IR/Constant.h"
#include "llvm/IR/DerivedTypes.h"
+#include "llvm/IR/Value.h"
#include "llvm/Support/MD5.h"
+#include "llvm/Support/Casting.h"
+#include "llvm/Support/ErrorHandling.h"
+#include <cassert>
+#include <cstdint>
+#include <string>
namespace llvm {
class Comdat;
class Error;
class GlobalObject;
-class PointerType;
class Module;
namespace Intrinsic {
enum ID : unsigned;
-}
+} // end namespace Intrinsic
class GlobalValue : public Constant {
- GlobalValue(const GlobalValue &) = delete;
public:
/// @brief An enumeration for the kinds of linkage for global values.
enum LinkageTypes {
static const unsigned GlobalValueSubClassDataBits = 19;
private:
+ friend class Constant;
+
// Give subclasses access to what otherwise would be wasted padding.
// (19 + 4 + 2 + 2 + 2 + 3) == 32.
unsigned SubClassData : GlobalValueSubClassDataBits;
- friend class Constant;
void destroyConstantImpl();
Value *handleOperandChangeImpl(Value *From, Value *To);
LocalExecTLSModel
};
+ GlobalValue(const GlobalValue &) = delete;
+
~GlobalValue() override {
removeDeadConstantUsers(); // remove any dead constants using this.
}
}
};
-} // End llvm namespace
+} // end namespace llvm
-#endif
+#endif // LLVM_IR_GLOBALVALUE_H
#include "llvm/ADT/ilist_node.h"
#include "llvm/IR/GlobalObject.h"
#include "llvm/IR/OperandTraits.h"
+#include "llvm/IR/Value.h"
+#include <cassert>
+#include <cstddef>
namespace llvm {
class Constant;
class DIGlobalVariable;
class Module;
+
template <typename ValueSubClass> class SymbolTableListTraits;
class GlobalVariable : public GlobalObject, public ilist_node<GlobalVariable> {
friend class SymbolTableListTraits<GlobalVariable>;
- void *operator new(size_t, unsigned) = delete;
- void operator=(const GlobalVariable &) = delete;
- GlobalVariable(const GlobalVariable &) = delete;
bool isConstantGlobal : 1; // Is this a global constant?
bool isExternallyInitializedConstant : 1; // Is this a global whose value
// can change from its initial
// value before global
// initializers are run?
-public:
- // allocate space for exactly one operand
- void *operator new(size_t s) {
- return User::operator new(s, 1);
- }
+public:
/// GlobalVariable ctor - If a parent module is specified, the global is
/// automatically inserted into the end of the specified modules global list.
GlobalVariable(Type *Ty, bool isConstant, LinkageTypes Linkage,
const Twine &Name = "", GlobalVariable *InsertBefore = nullptr,
ThreadLocalMode = NotThreadLocal, unsigned AddressSpace = 0,
bool isExternallyInitialized = false);
+ GlobalVariable(const GlobalVariable &) = delete;
+ GlobalVariable &operator=(const GlobalVariable &) = delete;
~GlobalVariable() override {
dropAllReferences();
setGlobalVariableNumOperands(1);
}
+ // allocate space for exactly one operand
+ void *operator new(size_t s) {
+ return User::operator new(s, 1);
+ }
+
+ void *operator new(size_t, unsigned) = delete;
+
/// Provide fast operand accessors
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
DEFINE_TRANSPARENT_OPERAND_ACCESSORS(GlobalVariable, Value)
-} // End llvm namespace
+} // end namespace llvm
-#endif
+#endif // LLVM_IR_GLOBALVARIABLE_H
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/None.h"
-#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/Twine.h"
#include "llvm/IR/BasicBlock.h"
#include <cassert>
#include <cstddef>
#include <cstdint>
+#include <algorithm>
+#include <functional>
namespace llvm {
public:
IRBuilderBase(LLVMContext &context, MDNode *FPMathTag = nullptr,
ArrayRef<OperandBundleDef> OpBundles = None)
- : Context(context), DefaultFPMathTag(FPMathTag), FMF(),
+ : Context(context), DefaultFPMathTag(FPMathTag),
DefaultOperandBundles(OpBundles) {
ClearInsertionPoint();
}
/// InsertPoint - A saved insertion point.
class InsertPoint {
- BasicBlock *Block;
+ BasicBlock *Block = nullptr;
BasicBlock::iterator Point;
public:
/// \brief Creates a new insertion point which doesn't point to anything.
- InsertPoint() : Block(nullptr) {}
+ InsertPoint() = default;
/// \brief Creates a new insertion point at the given location.
InsertPoint(BasicBlock *InsertBlock, BasicBlock::iterator InsertPoint)
/// \brief Returns true if this insert point is set.
bool isSet() const { return (Block != nullptr); }
- llvm::BasicBlock *getBlock() const { return Block; }
- llvm::BasicBlock::iterator getPoint() const { return Point; }
+ BasicBlock *getBlock() const { return Block; }
+ BasicBlock::iterator getPoint() const { return Point; }
};
/// \brief Returns the current insert point.
BasicBlock::iterator Point;
DebugLoc DbgLoc;
- InsertPointGuard(const InsertPointGuard &) = delete;
- InsertPointGuard &operator=(const InsertPointGuard &) = delete;
-
public:
InsertPointGuard(IRBuilderBase &B)
: Builder(B), Block(B.GetInsertBlock()), Point(B.GetInsertPoint()),
DbgLoc(B.getCurrentDebugLocation()) {}
+ InsertPointGuard(const InsertPointGuard &) = delete;
+ InsertPointGuard &operator=(const InsertPointGuard &) = delete;
+
~InsertPointGuard() {
Builder.restoreIP(InsertPoint(Block, Point));
Builder.SetCurrentDebugLocation(DbgLoc);
FastMathFlags FMF;
MDNode *FPMathTag;
- FastMathFlagGuard(const FastMathFlagGuard &) = delete;
- FastMathFlagGuard &operator=(
- const FastMathFlagGuard &) = delete;
-
public:
FastMathFlagGuard(IRBuilderBase &B)
: Builder(B), FMF(B.FMF), FPMathTag(B.DefaultFPMathTag) {}
+ FastMathFlagGuard(const FastMathFlagGuard &) = delete;
+ FastMathFlagGuard &operator=(const FastMathFlagGuard &) = delete;
+
~FastMathFlagGuard() {
Builder.FMF = FMF;
Builder.DefaultFPMathTag = FPMathTag;
if (Constant *LC = dyn_cast<Constant>(LHS))
if (Constant *RC = dyn_cast<Constant>(RHS))
return Insert(Folder.CreateBinOp(Opc, LC, RC), Name);
- llvm::Instruction *BinOp = BinaryOperator::Create(Opc, LHS, RHS);
+ Instruction *BinOp = BinaryOperator::Create(Opc, LHS, RHS);
if (isa<FPMathOperator>(BinOp))
BinOp = AddFPMathAttributes(BinOp, FPMathTag, FMF);
return Insert(BinOp, Name);
return CreateBitCast(V, DestTy, Name);
}
-private:
- // \brief Provided to resolve 'CreateIntCast(Ptr, Ptr, "...")', giving a
- // compile time error, instead of converting the string to bool for the
- // isSigned parameter.
- Value *CreateIntCast(Value *, Type *, const char *) = delete;
-
public:
Value *CreateFPCast(Value *V, Type *DestTy, const Twine &Name = "") {
if (V->getType() == DestTy)
return Insert(CastInst::CreateFPCast(V, DestTy), Name);
}
+ // \brief Provided to resolve 'CreateIntCast(Ptr, Ptr, "...")', giving a
+ // compile time error, instead of converting the string to bool for the
+ // isSigned parameter.
+ Value *CreateIntCast(Value *, Type *, const char *) = delete;
+
//===--------------------------------------------------------------------===//
// Instruction creation methods: Compare Instructions
//===--------------------------------------------------------------------===//
return CreateCall(FTy, Callee, Args, Name, FPMathTag);
}
- CallInst *CreateCall(llvm::FunctionType *FTy, Value *Callee,
+ CallInst *CreateCall(FunctionType *FTy, Value *Callee,
ArrayRef<Value *> Args, const Twine &Name = "",
MDNode *FPMathTag = nullptr) {
CallInst *CI = CallInst::Create(FTy, Callee, Args, DefaultOperandBundles);
#include "llvm/ADT/StringRef.h"
#include "llvm/IR/Value.h"
+#include <cassert>
+#include <string>
#include <vector>
namespace llvm {
-class PointerType;
class FunctionType;
-class Module;
-
-struct InlineAsmKeyType;
+class PointerType;
template <class ConstantClass> class ConstantUniqueMap;
class InlineAsm : public Value {
friend struct InlineAsmKeyType;
friend class ConstantUniqueMap<InlineAsm>;
- InlineAsm(const InlineAsm &) = delete;
- void operator=(const InlineAsm&) = delete;
-
std::string AsmString, Constraints;
FunctionType *FTy;
bool HasSideEffects;
void destroyConstant();
public:
+ InlineAsm(const InlineAsm &) = delete;
+ InlineAsm &operator=(const InlineAsm &) = delete;
+
/// InlineAsm::get - Return the specified uniqued inline asm string.
///
static InlineAsm *get(FunctionType *Ty, StringRef AsmString,
}
};
-} // End llvm namespace
+} // end namespace llvm
-#endif
+#endif // LLVM_IR_INLINEASM_H
#define LLVM_IR_INTRINSICINST_H
#include "llvm/IR/Constants.h"
+#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/Function.h"
+#include "llvm/IR/GlobalVariable.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/Intrinsics.h"
#include "llvm/IR/Metadata.h"
+#include "llvm/IR/Value.h"
+#include "llvm/Support/Casting.h"
+#include <cassert>
+#include <cstdint>
namespace llvm {
+
/// A wrapper class for inspecting calls to intrinsic functions.
/// This allows the standard isa/dyncast/cast functionality to work with calls
/// to intrinsic functions.
class IntrinsicInst : public CallInst {
- IntrinsicInst() = delete;
- IntrinsicInst(const IntrinsicInst&) = delete;
- void operator=(const IntrinsicInst&) = delete;
public:
+ IntrinsicInst() = delete;
+ IntrinsicInst(const IntrinsicInst &) = delete;
+ IntrinsicInst &operator=(const IntrinsicInst &) = delete;
+
/// Return the intrinsic ID of this intrinsic.
Intrinsic::ID getIntrinsicID() const {
return getCalledFunction()->getIntrinsicID();
class DbgDeclareInst : public DbgInfoIntrinsic {
public:
Value *getAddress() const { return getVariableLocation(); }
+
DILocalVariable *getVariable() const {
return cast<DILocalVariable>(getRawVariable());
}
+
DIExpression *getExpression() const {
return cast<DIExpression>(getRawExpression());
}
Metadata *getRawVariable() const {
return cast<MetadataAsValue>(getArgOperand(1))->getMetadata();
}
+
Metadata *getRawExpression() const {
return cast<MetadataAsValue>(getArgOperand(2))->getMetadata();
}
Value *getValue() const {
return getVariableLocation(/* AllowNullOp = */ false);
}
+
uint64_t getOffset() const {
return cast<ConstantInt>(
const_cast<Value*>(getArgOperand(1)))->getZExtValue();
}
+
DILocalVariable *getVariable() const {
return cast<DILocalVariable>(getRawVariable());
}
+
DIExpression *getExpression() const {
return cast<DIExpression>(getRawExpression());
}
Metadata *getRawVariable() const {
return cast<MetadataAsValue>(getArgOperand(2))->getMetadata();
}
+
Metadata *getRawExpression() const {
return cast<MetadataAsValue>(getArgOperand(3))->getMetadata();
}
ConstantInt *getVolatileCst() const {
return cast<ConstantInt>(const_cast<Value*>(getArgOperand(4)));
}
+
bool isVolatile() const {
return !getVolatileCst()->isZero();
}
}
};
-
/// This class wraps the llvm.memcpy intrinsic.
class MemCpyInst : public MemTransferInst {
public:
ConstantInt *getIndex() const {
return cast<ConstantInt>(const_cast<Value *>(getArgOperand(3)));
}
+
Value *getStep() const;
};
return cast<ConstantInt>(const_cast<Value *>(getArgOperand(4)));
}
};
-} // namespace llvm
-#endif
+} // end namespace llvm
+
+#endif // LLVM_IR_INTRINSICINST_H
#ifndef LLVM_IR_LLVMCONTEXT_H
#define LLVM_IR_LLVMCONTEXT_H
+#include "llvm-c/Types.h"
#include "llvm/Support/CBindingWrapping.h"
#include "llvm/Support/Options.h"
+#include <cstdint>
+#include <memory>
+#include <string>
namespace llvm {
-class LLVMContextImpl;
-class StringRef;
-class Twine;
-class Instruction;
-class Module;
-class MDString;
-class DICompositeType;
-class SMDiagnostic;
class DiagnosticInfo;
enum DiagnosticSeverity : char;
-template <typename T> class SmallVectorImpl;
class Function;
-class DebugLoc;
+class Instruction;
+class LLVMContextImpl;
+class Module;
class OptBisect;
+template <typename T> class SmallVectorImpl;
+class SMDiagnostic;
+class StringRef;
+class Twine;
+
namespace yaml {
class Output;
-}
+} // end namespace yaml
/// This is an important class for using LLVM in a threaded context. It
/// (opaquely) owns and manages the core "global" data of LLVM's core
public:
LLVMContextImpl *const pImpl;
LLVMContext();
+ LLVMContext(LLVMContext &) = delete;
+ LLVMContext &operator=(const LLVMContext &) = delete;
~LLVMContext();
// Pinned metadata names, which always have the same value. This is a
/// analysis.
OptBisect &getOptBisect();
private:
- LLVMContext(LLVMContext&) = delete;
- void operator=(LLVMContext&) = delete;
+ // Module needs access to the add/removeModule methods.
+ friend class Module;
/// addModule - Register a module as being instantiated in this context. If
/// the context is deleted, the module will be deleted as well.
/// removeModule - Unregister a module from this context.
void removeModule(Module*);
-
- // Module needs access to the add/removeModule methods.
- friend class Module;
};
// Create wrappers for C Binding types (see CBindingWrapping.h).
return reinterpret_cast<LLVMContextRef*>(const_cast<LLVMContext**>(Tys));
}
-}
+} // end namespace llvm
-#endif
+#endif // LLVM_IR_LLVMCONTEXT_H
#ifndef LLVM_IR_OPERATOR_H
#define LLVM_IR_OPERATOR_H
+#include "llvm/ADT/None.h"
+#include "llvm/ADT/Optional.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/Instruction.h"
#include "llvm/IR/Type.h"
+#include "llvm/IR/Value.h"
+#include "llvm/Support/Casting.h"
+#include <cstddef>
namespace llvm {
-class GetElementPtrInst;
-class BinaryOperator;
-class ConstantExpr;
-
/// This is a utility class that provides an abstraction for the common
/// functionality between Instructions and ConstantExprs.
class Operator : public User {
-private:
- // The Operator class is intended to be used as a utility, and is never itself
- // instantiated.
- void *operator new(size_t, unsigned) = delete;
- void *operator new(size_t s) = delete;
- Operator() = delete;
-
protected:
// NOTE: Cannot use = delete because it's not legal to delete
// an overridden method that's not deleted in the base class. Cannot leave
~Operator() override;
public:
+ // The Operator class is intended to be used as a utility, and is never itself
+ // instantiated.
+ Operator() = delete;
+
+ void *operator new(size_t, unsigned) = delete;
+ void *operator new(size_t s) = delete;
+
/// Return the opcode for this Instruction or ConstantExpr.
unsigned getOpcode() const {
if (const Instruction *I = dyn_cast<Instruction>(this))
private:
friend class Instruction;
friend class ConstantExpr;
+
void setHasNoUnsignedWrap(bool B) {
SubclassOptionalData =
(SubclassOptionalData & ~NoUnsignedWrap) | (B * NoUnsignedWrap);
private:
friend class Instruction;
friend class ConstantExpr;
+
void setIsExact(bool B) {
SubclassOptionalData = (SubclassOptionalData & ~IsExact) | (B * IsExact);
}
OpC == Instruction::AShr ||
OpC == Instruction::LShr;
}
+
static inline bool classof(const ConstantExpr *CE) {
return isPossiblyExactOpcode(CE->getOpcode());
}
class FastMathFlags {
private:
friend class FPMathOperator;
- unsigned Flags;
+
+ unsigned Flags = 0;
+
FastMathFlags(unsigned F) : Flags(F) { }
public:
AllowReciprocal = (1 << 4)
};
- FastMathFlags() : Flags(0)
- { }
+ FastMathFlags() = default;
/// Whether any flag is set
bool any() const { return Flags != 0; }
}
};
-
/// Utility class for floating point operations which can have
/// information about relaxed accuracy requirements attached to them.
class FPMathOperator : public Operator {
setHasAllowReciprocal(true);
}
}
+
void setHasNoNaNs(bool B) {
SubclassOptionalData =
(SubclassOptionalData & ~FastMathFlags::NoNaNs) |
(B * FastMathFlags::NoNaNs);
}
+
void setHasNoInfs(bool B) {
SubclassOptionalData =
(SubclassOptionalData & ~FastMathFlags::NoInfs) |
(B * FastMathFlags::NoInfs);
}
+
void setHasNoSignedZeros(bool B) {
SubclassOptionalData =
(SubclassOptionalData & ~FastMathFlags::NoSignedZeros) |
(B * FastMathFlags::NoSignedZeros);
}
+
void setHasAllowReciprocal(bool B) {
SubclassOptionalData =
(SubclassOptionalData & ~FastMathFlags::AllowReciprocal) |
}
};
-
/// A helper template for defining operators for individual opcodes.
template<typename SuperClass, unsigned Opc>
class ConcreteOperator : public SuperClass {
: public ConcreteOperator<OverflowingBinaryOperator, Instruction::Shl> {
};
-
class SDivOperator
: public ConcreteOperator<PossiblyExactOperator, Instruction::SDiv> {
};
: public ConcreteOperator<PossiblyExactOperator, Instruction::LShr> {
};
-
class ZExtOperator : public ConcreteOperator<Operator, Instruction::ZExt> {};
-
class GEPOperator
: public ConcreteOperator<Operator, Instruction::GetElementPtr> {
+ friend class GetElementPtrInst;
+ friend class ConstantExpr;
+
enum {
IsInBounds = (1 << 0),
// InRangeIndex: bits 1-6
};
- friend class GetElementPtrInst;
- friend class ConstantExpr;
void setIsInBounds(bool B) {
SubclassOptionalData =
(SubclassOptionalData & ~IsInBounds) | (B * IsInBounds);
bool isInBounds() const {
return SubclassOptionalData & IsInBounds;
}
+
/// Returns the offset of the index with an inrange attachment, or None if
/// none.
Optional<unsigned> getInRangeIndex() const {
const Value *getPointerOperand() const {
return getOperand(0);
}
+
static unsigned getPointerOperandIndex() {
return 0U; // get index for modifying correct operand
}
}
};
-} // End llvm namespace
+} // end namespace llvm
-#endif
+#endif // LLVM_IR_OPERATOR_H
-//===-- llvm/IR/Statepoint.h - gc.statepoint utilities ------ --*- C++ -*-===//
+//===-- llvm/IR/Statepoint.h - gc.statepoint utilities ----------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
#include "llvm/ADT/iterator_range.h"
#include "llvm/ADT/Optional.h"
+#include "llvm/IR/Attributes.h"
#include "llvm/IR/BasicBlock.h"
#include "llvm/IR/CallSite.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/Intrinsics.h"
+#include "llvm/Support/Casting.h"
+#include <cassert>
+#include <cstddef>
+#include <cstdint>
+#include <vector>
namespace llvm {
+
/// The statepoint intrinsic accepts a set of flags as its third argument.
/// Valid values come out of this set.
enum class StatepointFlags {
class GCRelocateInst;
class GCResultInst;
-class ImmutableStatepoint;
bool isStatepoint(ImmutableCallSite CS);
bool isStatepoint(const Value *V);
typename CallSiteTy>
class StatepointBase {
CallSiteTy StatepointCS;
- void *operator new(size_t, unsigned) = delete;
- void *operator new(size_t s) = delete;
protected:
explicit StatepointBase(InstructionTy *I) {
assert(StatepointCS && "isStatepoint implies CallSite");
}
}
+
explicit StatepointBase(CallSiteTy CS) {
if (isStatepoint(CS))
StatepointCS = CS;
CallArgsBeginPos = 5,
};
+ void *operator new(size_t, unsigned) = delete;
+ void *operator new(size_t s) = delete;
+
explicit operator bool() const {
// We do not assign non-statepoint CallSites to StatepointCS.
return (bool)StatepointCS;
/// Return \c true if the the \p Attr is an attribute that is a statepoint
/// directive.
bool isStatepointDirectiveAttr(Attribute Attr);
-}
-#endif
+} // end namespace llvm
+
+#endif // LLVM_IR_STATEPOINT_H
#include "llvm/ADT/PointerIntPair.h"
#include "llvm/Support/CBindingWrapping.h"
-#include <cstddef>
+#include "llvm-c/Types.h"
namespace llvm {
template <> class PointerLikeTypeTraits<Use **> {
public:
static inline void *getAsVoidPointer(Use **P) { return P; }
+
static inline Use **getFromVoidPointer(void *P) {
return static_cast<Use **>(P);
}
+
enum { NumLowBitsAvailable = 2 };
};
/// time complexity.
class Use {
public:
+ Use(const Use &U) = delete;
+
/// \brief Provide a fast substitute to std::swap<Use>
/// that also works with less standard-compliant compilers
void swap(Use &RHS);
typedef PointerIntPair<User *, 1, unsigned> UserRef;
private:
- Use(const Use &U) = delete;
-
/// Destructor - Only for zap()
~Use() {
if (Val)
PointerIntPair<Use **, 2, PrevPtrTag> Prev;
void setPrev(Use **NewPrev) { Prev.setPointer(NewPrev); }
+
void addToList(Use **List) {
Next = *List;
if (Next)
setPrev(List);
*List = this;
}
+
void removeFromList() {
Use **StrippedPrev = Prev.getPointer();
*StrippedPrev = Next;
// Create wrappers for C Binding types (see CBindingWrapping.h).
DEFINE_SIMPLE_CONVERSION_FUNCTIONS(Use, LLVMUseRef)
-}
+} // end namespace llvm
-#endif
+#endif // LLVM_IR_USE_H
#define LLVM_IR_VALUEMAP_H
#include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/DenseMapInfo.h"
+#include "llvm/ADT/None.h"
#include "llvm/ADT/Optional.h"
#include "llvm/IR/TrackingMDRef.h"
#include "llvm/IR/ValueHandle.h"
+#include "llvm/Support/Casting.h"
#include "llvm/Support/Mutex.h"
#include "llvm/Support/UniqueLock.h"
-#include "llvm/Support/type_traits.h"
+#include <algorithm>
+#include <cassert>
+#include <cstddef>
#include <iterator>
-#include <memory>
+#include <type_traits>
+#include <utility>
namespace llvm {
};
/// See the file comment.
-template<typename KeyT, typename ValueT, typename Config =ValueMapConfig<KeyT> >
+template<typename KeyT, typename ValueT, typename Config =ValueMapConfig<KeyT>>
class ValueMap {
friend class ValueMapCallbackVH<KeyT, ValueT, Config>;
+
typedef ValueMapCallbackVH<KeyT, ValueT, Config> ValueMapCVH;
- typedef DenseMap<ValueMapCVH, ValueT, DenseMapInfo<ValueMapCVH> > MapT;
+ typedef DenseMap<ValueMapCVH, ValueT, DenseMapInfo<ValueMapCVH>> MapT;
typedef DenseMap<const Metadata *, TrackingMDRef> MDMapT;
typedef typename Config::ExtraData ExtraData;
MapT Map;
bool MayMapMetadata = true;
- ValueMap(const ValueMap&) = delete;
- ValueMap& operator=(const ValueMap&) = delete;
public:
typedef KeyT key_type;
typedef ValueT mapped_type;
: Map(NumInitBuckets), Data() {}
explicit ValueMap(const ExtraData &Data, unsigned NumInitBuckets = 64)
: Map(NumInitBuckets), Data(Data) {}
+ ValueMap(const ValueMap &) = delete;
+ ValueMap &operator=(const ValueMap &) = delete;
bool hasMD() const { return bool(MDMap); }
MDMapT &MD() {
insert(*I);
}
-
bool erase(const KeyT &Val) {
typename MapT::iterator I = Map.find_as(Val);
if (I == Map.end())
class ValueMapCallbackVH final : public CallbackVH {
friend class ValueMap<KeyT, ValueT, Config>;
friend struct DenseMapInfo<ValueMapCallbackVH>;
+
typedef ValueMap<KeyT, ValueT, Config> ValueMapT;
typedef typename std::remove_pointer<KeyT>::type KeySansPointerT;
Config::onDelete(Copy.Map->Data, Copy.Unwrap()); // May destroy *this.
Copy.Map->Map.erase(Copy); // Definitely destroys *this.
}
+
void allUsesReplacedWith(Value *new_key) override {
assert(isa<KeySansPointerT>(new_key) &&
"Invalid RAUW on key of ValueMap<>");
};
template<typename KeyT, typename ValueT, typename Config>
-struct DenseMapInfo<ValueMapCallbackVH<KeyT, ValueT, Config> > {
+struct DenseMapInfo<ValueMapCallbackVH<KeyT, ValueT, Config>> {
typedef ValueMapCallbackVH<KeyT, ValueT, Config> VH;
static inline VH getEmptyKey() {
return VH(DenseMapInfo<Value *>::getEmptyKey());
}
+
static inline VH getTombstoneKey() {
return VH(DenseMapInfo<Value *>::getTombstoneKey());
}
+
static unsigned getHashValue(const VH &Val) {
return DenseMapInfo<KeyT>::getHashValue(Val.Unwrap());
}
+
static unsigned getHashValue(const KeyT &Val) {
return DenseMapInfo<KeyT>::getHashValue(Val);
}
+
static bool isEqual(const VH &LHS, const VH &RHS) {
return LHS == RHS;
}
+
static bool isEqual(const KeyT &LHS, const VH &RHS) {
return LHS == RHS.getValPtr();
}
};
-
template<typename DenseMapT, typename KeyT>
class ValueMapIterator :
public std::iterator<std::forward_iterator_tag,
ptrdiff_t> {
typedef typename DenseMapT::iterator BaseT;
typedef typename DenseMapT::mapped_type ValueT;
+
BaseT I;
+
public:
ValueMapIterator() : I() {}
-
ValueMapIterator(BaseT I) : I(I) {}
BaseT base() const { return I; }
ptrdiff_t> {
typedef typename DenseMapT::const_iterator BaseT;
typedef typename DenseMapT::mapped_type ValueT;
+
BaseT I;
+
public:
ValueMapConstIterator() : I() {}
ValueMapConstIterator(BaseT I) : I(I) {}
} // end namespace llvm
-#endif
+#endif // LLVM_IR_VALUEMAP_H
#ifndef LLVM_TRANSFORMS_UTILS_FUNCTIONCOMPARATOR_H
#define LLVM_TRANSFORMS_UTILS_FUNCTIONCOMPARATOR_H
+#include "llvm/ADT/APFloat.h"
+#include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/StringRef.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/ValueMap.h"
#include "llvm/IR/Operator.h"
#include "llvm/Support/AtomicOrdering.h"
+#include "llvm/Support/Casting.h"
+#include <cstdint>
+#include <tuple>
namespace llvm {
+class GetElementPtrInst;
+
/// GlobalNumberState assigns an integer to each global value in the program,
/// which is used by the comparison routine to order references to globals. This
/// state must be preserved throughout the pass, because Functions and other
typedef ValueMap<GlobalValue *, uint64_t, Config> ValueNumberMap;
ValueNumberMap GlobalNumbers;
// The next unused serial number to assign to a global.
- uint64_t NextNumber;
- public:
- GlobalNumberState() : GlobalNumbers(), NextNumber(0) {}
- uint64_t getNumber(GlobalValue* Global) {
- ValueNumberMap::iterator MapIter;
- bool Inserted;
- std::tie(MapIter, Inserted) = GlobalNumbers.insert({Global, NextNumber});
- if (Inserted)
- NextNumber++;
- return MapIter->second;
- }
- void clear() {
- GlobalNumbers.clear();
- }
+ uint64_t NextNumber = 0;
+
+public:
+ GlobalNumberState() = default;
+
+ uint64_t getNumber(GlobalValue* Global) {
+ ValueNumberMap::iterator MapIter;
+ bool Inserted;
+ std::tie(MapIter, Inserted) = GlobalNumbers.insert({Global, NextNumber});
+ if (Inserted)
+ NextNumber++;
+ return MapIter->second;
+ }
+
+ void clear() {
+ GlobalNumbers.clear();
+ }
};
/// FunctionComparator - Compares two functions to determine whether or not
static FunctionHash functionHash(Function &);
protected:
-
/// Start the comparison.
void beginCompare() {
sn_mapL.clear();
const Function *FnL, *FnR;
private:
-
int cmpOrderings(AtomicOrdering L, AtomicOrdering R) const;
int cmpInlineAsm(const InlineAsm *L, const InlineAsm *R) const;
int cmpAttrs(const AttributeSet L, const AttributeSet R) const;
GlobalNumberState* GlobalNumbers;
};
-}
+} // end namespace llvm
#endif // LLVM_TRANSFORMS_UTILS_FUNCTIONCOMPARATOR_H