llvm.org GIT mirror llvm / e0732bd
[IR] Fix some Clang-tidy modernize-use-equals-delete and Include What You Use warnings; other minor fixes (NFC). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@288853 91177308-0d34-0410-b5e6-96231b3b80d8 Eugene Zelenko 3 years ago
14 changed file(s) with 257 addition(s) and 168 deletion(s). Raw diff Collapse all Expand all
1313 #ifndef LLVM_IR_BASICBLOCK_H
1414 #define LLVM_IR_BASICBLOCK_H
1515
16 #include "llvm/ADT/ilist.h"
17 #include "llvm/ADT/ilist_node.h"
1618 #include "llvm/ADT/Twine.h"
17 #include "llvm/ADT/ilist.h"
1819 #include "llvm/IR/Instruction.h"
1920 #include "llvm/IR/SymbolTableListTraits.h"
21 #include "llvm/IR/Value.h"
2022 #include "llvm/Support/CBindingWrapping.h"
21 #include "llvm/Support/DataTypes.h"
23 #include "llvm-c/Types.h"
24 #include
25 #include
2226
2327 namespace llvm {
2428
2529 class CallInst;
30 class Function;
2631 class LandingPadInst;
32 class LLVMContext;
2733 class TerminatorInst;
28 class LLVMContext;
29 class BlockAddress;
30 class Function;
3134
3235 /// \brief LLVM Basic Block Representation
3336 ///
4649 /// are "well formed".
4750 class BasicBlock : public Value, // Basic blocks are data objects also
4851 public ilist_node_with_parent {
49 friend class BlockAddress;
5052 public:
5153 typedef SymbolTableList InstListType;
5254
5355 private:
56 friend class BlockAddress;
57 friend class SymbolTableListTraits;
58
5459 InstListType InstList;
5560 Function *Parent;
5661
5762 void setParent(Function *parent);
58 friend class SymbolTableListTraits;
59
60 BasicBlock(const BasicBlock &) = delete;
61 void operator=(const BasicBlock &) = delete;
6263
6364 /// \brief Constructor.
6465 ///
6869 explicit BasicBlock(LLVMContext &C, const Twine &Name = "",
6970 Function *Parent = nullptr,
7071 BasicBlock *InsertBefore = nullptr);
72
7173 public:
74 BasicBlock(const BasicBlock &) = delete;
75 BasicBlock &operator=(const BasicBlock &) = delete;
76 ~BasicBlock() override;
77
7278 /// \brief Get the context in which this basic block lives.
7379 LLVMContext &getContext() const;
7480
8894 BasicBlock *InsertBefore = nullptr) {
8995 return new BasicBlock(Context, Name, Parent, InsertBefore);
9096 }
91 ~BasicBlock() override;
9297
9398 /// \brief Return the enclosing method, or null if none.
9499 const Function *getParent() const { return Parent; }
329334 assert((int)(signed char)getSubclassDataFromValue() >= 0 &&
330335 "Refcount wrap-around");
331336 }
337
332338 /// \brief Shadow Value::setValueSubclassData with a private forwarding method
333339 /// so that any future subclasses cannot accidentally use it.
334340 void setValueSubclassData(unsigned short D) {
339345 // Create wrappers for C Binding types (see CBindingWrapping.h).
340346 DEFINE_SIMPLE_CONVERSION_FUNCTIONS(BasicBlock, LLVMBasicBlockRef)
341347
342 } // End llvm namespace
343
344 #endif
348 } // end namespace llvm
349
350 #endif // LLVM_IR_BASICBLOCK_H
3535 SameSize, ///< The data referenced by the COMDAT must be the same size.
3636 };
3737
38 Comdat(const Comdat &) = delete;
3839 Comdat(Comdat &&C);
40
3941 SelectionKind getSelectionKind() const { return SK; }
4042 void setSelectionKind(SelectionKind Val) { SK = Val; }
4143 StringRef getName() const;
4446
4547 private:
4648 friend class Module;
49
4750 Comdat();
48 Comdat(const Comdat &) = delete;
4951
5052 // Points to the map in Module.
5153 StringMapEntry *Name;
5759 return OS;
5860 }
5961
60 } // end llvm namespace
62 } // end namespace llvm
6163
62 #endif
64 #endif // LLVM_IR_COMDAT_H
1414 #ifndef LLVM_IR_DIBUILDER_H
1515 #define LLVM_IR_DIBUILDER_H
1616
17 #include "llvm/ADT/ArrayRef.h"
18 #include "llvm/ADT/DenseMap.h"
19 #include "llvm/ADT/None.h"
20 #include "llvm/ADT/SmallVector.h"
21 #include "llvm/ADT/StringRef.h"
1722 #include "llvm/IR/DebugInfo.h"
23 #include "llvm/IR/DebugInfoMetadata.h"
1824 #include "llvm/IR/TrackingMDRef.h"
19 #include "llvm/IR/ValueHandle.h"
20 #include "llvm/Support/DataTypes.h"
25 #include "llvm/Support/Casting.h"
26 #include
27 #include
2128
2229 namespace llvm {
30
2331 class BasicBlock;
32 class Constant;
33 class Function;
2434 class Instruction;
25 class Function;
35 class LLVMContext;
2636 class Module;
2737 class Value;
28 class Constant;
29 class LLVMContext;
30 class StringRef;
31 template class ArrayRef;
3238
3339 class DIBuilder {
3440 Module &M;
5662 /// copy.
5763 DenseMap> PreservedVariables;
5864
59 DIBuilder(const DIBuilder &) = delete;
60 void operator=(const DIBuilder &) = delete;
61
6265 /// Create a temporary.
6366 ///
6467 /// Create an \a temporary node and track it in \a UnresolvedNodes.
7073 /// If \c AllowUnresolved, collect unresolved nodes attached to the module
7174 /// in order to resolve cycles during \a finalize().
7275 explicit DIBuilder(Module &M, bool AllowUnresolved = true);
76 DIBuilder(const DIBuilder &) = delete;
77 DIBuilder &operator=(const DIBuilder &) = delete;
7378
7479 /// Construct any deferred debug info descriptors.
7580 void finalize();
222227 DIDerivedType *createStaticMemberType(DIScope *Scope, StringRef Name,
223228 DIFile *File, unsigned LineNo,
224229 DIType *Ty, DINode::DIFlags Flags,
225 llvm::Constant *Val,
230 Constant *Val,
226231 uint32_t AlignInBits = 0);
227232
228233 /// Create debugging information entry for Objective-C
741746 return Replacement;
742747 }
743748 };
749
744750 } // end namespace llvm
745751
746 #endif
752 #endif // LLVM_IR_DIBUILDER_H
1717 #ifndef LLVM_IR_GLOBALVALUE_H
1818 #define LLVM_IR_GLOBALVALUE_H
1919
20 #include "llvm/ADT/StringRef.h"
21 #include "llvm/ADT/Twine.h"
2022 #include "llvm/IR/Constant.h"
2123 #include "llvm/IR/DerivedTypes.h"
24 #include "llvm/IR/Value.h"
2225 #include "llvm/Support/MD5.h"
26 #include "llvm/Support/Casting.h"
27 #include "llvm/Support/ErrorHandling.h"
28 #include
29 #include
30 #include
2331
2432 namespace llvm {
2533
2634 class Comdat;
2735 class Error;
2836 class GlobalObject;
29 class PointerType;
3037 class Module;
3138
3239 namespace Intrinsic {
3340 enum ID : unsigned;
34 }
41 } // end namespace Intrinsic
3542
3643 class GlobalValue : public Constant {
37 GlobalValue(const GlobalValue &) = delete;
3844 public:
3945 /// @brief An enumeration for the kinds of linkage for global values.
4046 enum LinkageTypes {
8995 static const unsigned GlobalValueSubClassDataBits = 19;
9096
9197 private:
98 friend class Constant;
99
92100 // Give subclasses access to what otherwise would be wasted padding.
93101 // (19 + 4 + 2 + 2 + 2 + 3) == 32.
94102 unsigned SubClassData : GlobalValueSubClassDataBits;
95103
96 friend class Constant;
97104 void destroyConstantImpl();
98105 Value *handleOperandChangeImpl(Value *From, Value *To);
99106
154161 LocalExecTLSModel
155162 };
156163
164 GlobalValue(const GlobalValue &) = delete;
165
157166 ~GlobalValue() override {
158167 removeDeadConstantUsers(); // remove any dead constants using this.
159168 }
521530 }
522531 };
523532
524 } // End llvm namespace
525
526 #endif
533 } // end namespace llvm
534
535 #endif // LLVM_IR_GLOBALVALUE_H
2323 #include "llvm/ADT/ilist_node.h"
2424 #include "llvm/IR/GlobalObject.h"
2525 #include "llvm/IR/OperandTraits.h"
26 #include "llvm/IR/Value.h"
27 #include
28 #include
2629
2730 namespace llvm {
2831
2932 class Constant;
3033 class DIGlobalVariable;
3134 class Module;
35
3236 template class SymbolTableListTraits;
3337
3438 class GlobalVariable : public GlobalObject, public ilist_node {
3539 friend class SymbolTableListTraits;
36 void *operator new(size_t, unsigned) = delete;
37 void operator=(const GlobalVariable &) = delete;
38 GlobalVariable(const GlobalVariable &) = delete;
3940
4041 bool isConstantGlobal : 1; // Is this a global constant?
4142 bool isExternallyInitializedConstant : 1; // Is this a global whose value
4243 // can change from its initial
4344 // value before global
4445 // initializers are run?
46
4547 public:
46 // allocate space for exactly one operand
47 void *operator new(size_t s) {
48 return User::operator new(s, 1);
49 }
50
5148 /// GlobalVariable ctor - If a parent module is specified, the global is
5249 /// automatically inserted into the end of the specified modules global list.
5350 GlobalVariable(Type *Ty, bool isConstant, LinkageTypes Linkage,
6158 const Twine &Name = "", GlobalVariable *InsertBefore = nullptr,
6259 ThreadLocalMode = NotThreadLocal, unsigned AddressSpace = 0,
6360 bool isExternallyInitialized = false);
61 GlobalVariable(const GlobalVariable &) = delete;
62 GlobalVariable &operator=(const GlobalVariable &) = delete;
6463
6564 ~GlobalVariable() override {
6665 dropAllReferences();
6867 // FIXME: needed by operator delete
6968 setGlobalVariableNumOperands(1);
7069 }
70
71 // allocate space for exactly one operand
72 void *operator new(size_t s) {
73 return User::operator new(s, 1);
74 }
75
76 void *operator new(size_t, unsigned) = delete;
7177
7278 /// Provide fast operand accessors
7379 DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
179185
180186 DEFINE_TRANSPARENT_OPERAND_ACCESSORS(GlobalVariable, Value)
181187
182 } // End llvm namespace
188 } // end namespace llvm
183189
184 #endif
190 #endif // LLVM_IR_GLOBALVARIABLE_H
1616
1717 #include "llvm/ADT/ArrayRef.h"
1818 #include "llvm/ADT/None.h"
19 #include "llvm/ADT/SmallVector.h"
2019 #include "llvm/ADT/StringRef.h"
2120 #include "llvm/ADT/Twine.h"
2221 #include "llvm/IR/BasicBlock.h"
4443 #include
4544 #include
4645 #include
46 #include
47 #include
4748
4849 namespace llvm {
4950
100101 public:
101102 IRBuilderBase(LLVMContext &context, MDNode *FPMathTag = nullptr,
102103 ArrayRef OpBundles = None)
103 : Context(context), DefaultFPMathTag(FPMathTag), FMF(),
104 : Context(context), DefaultFPMathTag(FPMathTag),
104105 DefaultOperandBundles(OpBundles) {
105106 ClearInsertionPoint();
106107 }
164165
165166 /// InsertPoint - A saved insertion point.
166167 class InsertPoint {
167 BasicBlock *Block;
168 BasicBlock *Block = nullptr;
168169 BasicBlock::iterator Point;
169170
170171 public:
171172 /// \brief Creates a new insertion point which doesn't point to anything.
172 InsertPoint() : Block(nullptr) {}
173 InsertPoint() = default;
173174
174175 /// \brief Creates a new insertion point at the given location.
175176 InsertPoint(BasicBlock *InsertBlock, BasicBlock::iterator InsertPoint)
178179 /// \brief Returns true if this insert point is set.
179180 bool isSet() const { return (Block != nullptr); }
180181
181 llvm::BasicBlock *getBlock() const { return Block; }
182 llvm::BasicBlock::iterator getPoint() const { return Point; }
182 BasicBlock *getBlock() const { return Block; }
183 BasicBlock::iterator getPoint() const { return Point; }
183184 };
184185
185186 /// \brief Returns the current insert point.
229230 BasicBlock::iterator Point;
230231 DebugLoc DbgLoc;
231232
232 InsertPointGuard(const InsertPointGuard &) = delete;
233 InsertPointGuard &operator=(const InsertPointGuard &) = delete;
234
235233 public:
236234 InsertPointGuard(IRBuilderBase &B)
237235 : Builder(B), Block(B.GetInsertBlock()), Point(B.GetInsertPoint()),
238236 DbgLoc(B.getCurrentDebugLocation()) {}
237
238 InsertPointGuard(const InsertPointGuard &) = delete;
239 InsertPointGuard &operator=(const InsertPointGuard &) = delete;
239240
240241 ~InsertPointGuard() {
241242 Builder.restoreIP(InsertPoint(Block, Point));
250251 FastMathFlags FMF;
251252 MDNode *FPMathTag;
252253
253 FastMathFlagGuard(const FastMathFlagGuard &) = delete;
254 FastMathFlagGuard &operator=(
255 const FastMathFlagGuard &) = delete;
256
257254 public:
258255 FastMathFlagGuard(IRBuilderBase &B)
259256 : Builder(B), FMF(B.FMF), FPMathTag(B.DefaultFPMathTag) {}
257
258 FastMathFlagGuard(const FastMathFlagGuard &) = delete;
259 FastMathFlagGuard &operator=(const FastMathFlagGuard &) = delete;
260260
261261 ~FastMathFlagGuard() {
262262 Builder.FMF = FMF;
10341034 if (Constant *LC = dyn_cast(LHS))
10351035 if (Constant *RC = dyn_cast(RHS))
10361036 return Insert(Folder.CreateBinOp(Opc, LC, RC), Name);
1037 llvm::Instruction *BinOp = BinaryOperator::Create(Opc, LHS, RHS);
1037 Instruction *BinOp = BinaryOperator::Create(Opc, LHS, RHS);
10381038 if (isa(BinOp))
10391039 BinOp = AddFPMathAttributes(BinOp, FPMathTag, FMF);
10401040 return Insert(BinOp, Name);
14441444 return CreateBitCast(V, DestTy, Name);
14451445 }
14461446
1447 private:
1448 // \brief Provided to resolve 'CreateIntCast(Ptr, Ptr, "...")', giving a
1449 // compile time error, instead of converting the string to bool for the
1450 // isSigned parameter.
1451 Value *CreateIntCast(Value *, Type *, const char *) = delete;
1452
14531447 public:
14541448 Value *CreateFPCast(Value *V, Type *DestTy, const Twine &Name = "") {
14551449 if (V->getType() == DestTy)
14591453 return Insert(CastInst::CreateFPCast(V, DestTy), Name);
14601454 }
14611455
1456 // \brief Provided to resolve 'CreateIntCast(Ptr, Ptr, "...")', giving a
1457 // compile time error, instead of converting the string to bool for the
1458 // isSigned parameter.
1459 Value *CreateIntCast(Value *, Type *, const char *) = delete;
1460
14621461 //===--------------------------------------------------------------------===//
14631462 // Instruction creation methods: Compare Instructions
14641463 //===--------------------------------------------------------------------===//
15831582 return CreateCall(FTy, Callee, Args, Name, FPMathTag);
15841583 }
15851584
1586 CallInst *CreateCall(llvm::FunctionType *FTy, Value *Callee,
1585 CallInst *CreateCall(FunctionType *FTy, Value *Callee,
15871586 ArrayRef Args, const Twine &Name = "",
15881587 MDNode *FPMathTag = nullptr) {
15891588 CallInst *CI = CallInst::Create(FTy, Callee, Args, DefaultOperandBundles);
1717
1818 #include "llvm/ADT/StringRef.h"
1919 #include "llvm/IR/Value.h"
20 #include
21 #include
2022 #include
2123
2224 namespace llvm {
2325
26 class FunctionType;
2427 class PointerType;
25 class FunctionType;
26 class Module;
27
28 struct InlineAsmKeyType;
2928 template class ConstantUniqueMap;
3029
3130 class InlineAsm : public Value {
3938 friend struct InlineAsmKeyType;
4039 friend class ConstantUniqueMap;
4140
42 InlineAsm(const InlineAsm &) = delete;
43 void operator=(const InlineAsm&) = delete;
44
4541 std::string AsmString, Constraints;
4642 FunctionType *FTy;
4743 bool HasSideEffects;
5854 void destroyConstant();
5955
6056 public:
57 InlineAsm(const InlineAsm &) = delete;
58 InlineAsm &operator=(const InlineAsm &) = delete;
59
6160 /// InlineAsm::get - Return the specified uniqued inline asm string.
6261 ///
6362 static InlineAsm *get(FunctionType *Ty, StringRef AsmString,
360359 }
361360 };
362361
363 } // End llvm namespace
364
365 #endif
362 } // end namespace llvm
363
364 #endif // LLVM_IR_INLINEASM_H
2424 #define LLVM_IR_INTRINSICINST_H
2525
2626 #include "llvm/IR/Constants.h"
27 #include "llvm/IR/DerivedTypes.h"
2728 #include "llvm/IR/Function.h"
29 #include "llvm/IR/GlobalVariable.h"
2830 #include "llvm/IR/Instructions.h"
2931 #include "llvm/IR/Intrinsics.h"
3032 #include "llvm/IR/Metadata.h"
33 #include "llvm/IR/Value.h"
34 #include "llvm/Support/Casting.h"
35 #include
36 #include
3137
3238 namespace llvm {
39
3340 /// A wrapper class for inspecting calls to intrinsic functions.
3441 /// This allows the standard isa/dyncast/cast functionality to work with calls
3542 /// to intrinsic functions.
3643 class IntrinsicInst : public CallInst {
44 public:
3745 IntrinsicInst() = delete;
38 IntrinsicInst(const IntrinsicInst&) = delete;
39 void operator=(const IntrinsicInst&) = delete;
40 public:
46 IntrinsicInst(const IntrinsicInst &) = delete;
47 IntrinsicInst &operator=(const IntrinsicInst &) = delete;
48
4149 /// Return the intrinsic ID of this intrinsic.
4250 Intrinsic::ID getIntrinsicID() const {
4351 return getCalledFunction()->getIntrinsicID();
8088 class DbgDeclareInst : public DbgInfoIntrinsic {
8189 public:
8290 Value *getAddress() const { return getVariableLocation(); }
91
8392 DILocalVariable *getVariable() const {
8493 return cast(getRawVariable());
8594 }
95
8696 DIExpression *getExpression() const {
8797 return cast(getRawExpression());
8898 }
90100 Metadata *getRawVariable() const {
91101 return cast(getArgOperand(1))->getMetadata();
92102 }
103
93104 Metadata *getRawExpression() const {
94105 return cast(getArgOperand(2))->getMetadata();
95106 }
109120 Value *getValue() const {
110121 return getVariableLocation(/* AllowNullOp = */ false);
111122 }
123
112124 uint64_t getOffset() const {
113125 return cast(
114126 const_cast(getArgOperand(1)))->getZExtValue();
115127 }
128
116129 DILocalVariable *getVariable() const {
117130 return cast(getRawVariable());
118131 }
132
119133 DIExpression *getExpression() const {
120134 return cast(getRawExpression());
121135 }
123137 Metadata *getRawVariable() const {
124138 return cast(getArgOperand(2))->getMetadata();
125139 }
140
126141 Metadata *getRawExpression() const {
127142 return cast(getArgOperand(3))->getMetadata();
128143 }
158173 ConstantInt *getVolatileCst() const {
159174 return cast(const_cast(getArgOperand(4)));
160175 }
176
161177 bool isVolatile() const {
162178 return !getVolatileCst()->isZero();
163179 }
267283 }
268284 };
269285
270
271286 /// This class wraps the llvm.memcpy intrinsic.
272287 class MemCpyInst : public MemTransferInst {
273288 public:
358373 ConstantInt *getIndex() const {
359374 return cast(const_cast(getArgOperand(3)));
360375 }
376
361377 Value *getStep() const;
362378 };
363379
403419 return cast(const_cast(getArgOperand(4)));
404420 }
405421 };
406 } // namespace llvm
407
408 #endif
422
423 } // end namespace llvm
424
425 #endif // LLVM_IR_INTRINSICINST_H
1414 #ifndef LLVM_IR_LLVMCONTEXT_H
1515 #define LLVM_IR_LLVMCONTEXT_H
1616
17 #include "llvm-c/Types.h"
1718 #include "llvm/Support/CBindingWrapping.h"
1819 #include "llvm/Support/Options.h"
20 #include
21 #include
22 #include
1923
2024 namespace llvm {
2125
26 class DiagnosticInfo;
27 enum DiagnosticSeverity : char;
28 class Function;
29 class Instruction;
2230 class LLVMContextImpl;
31 class Module;
32 class OptBisect;
33 template class SmallVectorImpl;
34 class SMDiagnostic;
2335 class StringRef;
2436 class Twine;
25 class Instruction;
26 class Module;
27 class MDString;
28 class DICompositeType;
29 class SMDiagnostic;
30 class DiagnosticInfo;
31 enum DiagnosticSeverity : char;
32 template class SmallVectorImpl;
33 class Function;
34 class DebugLoc;
35 class OptBisect;
37
3638 namespace yaml {
3739 class Output;
38 }
40 } // end namespace yaml
3941
4042 /// This is an important class for using LLVM in a threaded context. It
4143 /// (opaquely) owns and manages the core "global" data of LLVM's core
4648 public:
4749 LLVMContextImpl *const pImpl;
4850 LLVMContext();
51 LLVMContext(LLVMContext &) = delete;
52 LLVMContext &operator=(const LLVMContext &) = delete;
4953 ~LLVMContext();
5054
5155 // Pinned metadata names, which always have the same value. This is a
258262 /// analysis.
259263 OptBisect &getOptBisect();
260264 private:
261 LLVMContext(LLVMContext&) = delete;
262 void operator=(LLVMContext&) = delete;
265 // Module needs access to the add/removeModule methods.
266 friend class Module;
263267
264268 /// addModule - Register a module as being instantiated in this context. If
265269 /// the context is deleted, the module will be deleted as well.
267271
268272 /// removeModule - Unregister a module from this context.
269273 void removeModule(Module*);
270
271 // Module needs access to the add/removeModule methods.
272 friend class Module;
273274 };
274275
275276 // Create wrappers for C Binding types (see CBindingWrapping.h).
285286 return reinterpret_cast(const_cast(Tys));
286287 }
287288
288 }
289
290 #endif
289 } // end namespace llvm
290
291 #endif // LLVM_IR_LLVMCONTEXT_H
1414 #ifndef LLVM_IR_OPERATOR_H
1515 #define LLVM_IR_OPERATOR_H
1616
17 #include "llvm/ADT/None.h"
18 #include "llvm/ADT/Optional.h"
1719 #include "llvm/IR/Constants.h"
1820 #include "llvm/IR/DataLayout.h"
1921 #include "llvm/IR/DerivedTypes.h"
2022 #include "llvm/IR/Instruction.h"
2123 #include "llvm/IR/Type.h"
24 #include "llvm/IR/Value.h"
25 #include "llvm/Support/Casting.h"
26 #include
2227
2328 namespace llvm {
24
25 class GetElementPtrInst;
26 class BinaryOperator;
27 class ConstantExpr;
2829
2930 /// This is a utility class that provides an abstraction for the common
3031 /// functionality between Instructions and ConstantExprs.
3132 class Operator : public User {
32 private:
33 // The Operator class is intended to be used as a utility, and is never itself
34 // instantiated.
35 void *operator new(size_t, unsigned) = delete;
36 void *operator new(size_t s) = delete;
37 Operator() = delete;
38
3933 protected:
4034 // NOTE: Cannot use = delete because it's not legal to delete
4135 // an overridden method that's not deleted in the base class. Cannot leave
4337 ~Operator() override;
4438
4539 public:
40 // The Operator class is intended to be used as a utility, and is never itself
41 // instantiated.
42 Operator() = delete;
43
44 void *operator new(size_t, unsigned) = delete;
45 void *operator new(size_t s) = delete;
46
4647 /// Return the opcode for this Instruction or ConstantExpr.
4748 unsigned getOpcode() const {
4849 if (const Instruction *I = dyn_cast(this))
8081 private:
8182 friend class Instruction;
8283 friend class ConstantExpr;
84
8385 void setHasNoUnsignedWrap(bool B) {
8486 SubclassOptionalData =
8587 (SubclassOptionalData & ~NoUnsignedWrap) | (B * NoUnsignedWrap);
131133 private:
132134 friend class Instruction;
133135 friend class ConstantExpr;
136
134137 void setIsExact(bool B) {
135138 SubclassOptionalData = (SubclassOptionalData & ~IsExact) | (B * IsExact);
136139 }
147150 OpC == Instruction::AShr ||
148151 OpC == Instruction::LShr;
149152 }
153
150154 static inline bool classof(const ConstantExpr *CE) {
151155 return isPossiblyExactOpcode(CE->getOpcode());
152156 }
163167 class FastMathFlags {
164168 private:
165169 friend class FPMathOperator;
166 unsigned Flags;
170
171 unsigned Flags = 0;
172
167173 FastMathFlags(unsigned F) : Flags(F) { }
168174
169175 public:
175181 AllowReciprocal = (1 << 4)
176182 };
177183
178 FastMathFlags() : Flags(0)
179 { }
184 FastMathFlags() = default;
180185
181186 /// Whether any flag is set
182187 bool any() const { return Flags != 0; }
209214 }
210215 };
211216
212
213217 /// Utility class for floating point operations which can have
214218 /// information about relaxed accuracy requirements attached to them.
215219 class FPMathOperator : public Operator {
229233 setHasAllowReciprocal(true);
230234 }
231235 }
236
232237 void setHasNoNaNs(bool B) {
233238 SubclassOptionalData =
234239 (SubclassOptionalData & ~FastMathFlags::NoNaNs) |
235240 (B * FastMathFlags::NoNaNs);
236241 }
242
237243 void setHasNoInfs(bool B) {
238244 SubclassOptionalData =
239245 (SubclassOptionalData & ~FastMathFlags::NoInfs) |
240246 (B * FastMathFlags::NoInfs);
241247 }
248
242249 void setHasNoSignedZeros(bool B) {
243250 SubclassOptionalData =
244251 (SubclassOptionalData & ~FastMathFlags::NoSignedZeros) |
245252 (B * FastMathFlags::NoSignedZeros);
246253 }
254
247255 void setHasAllowReciprocal(bool B) {
248256 SubclassOptionalData =
249257 (SubclassOptionalData & ~FastMathFlags::AllowReciprocal) |
312320 }
313321 };
314322
315
316323 /// A helper template for defining operators for individual opcodes.
317324 template
318325 class ConcreteOperator : public SuperClass {
342349 : public ConcreteOperator {
343350 };
344351
345
346352 class SDivOperator
347353 : public ConcreteOperator {
348354 };
356362 : public ConcreteOperator {
357363 };
358364
359
360365 class ZExtOperator : public ConcreteOperator {};
361
362366
363367 class GEPOperator
364368 : public ConcreteOperator {
369 friend class GetElementPtrInst;
370 friend class ConstantExpr;
371
365372 enum {
366373 IsInBounds = (1 << 0),
367374 // InRangeIndex: bits 1-6
368375 };
369376
370 friend class GetElementPtrInst;
371 friend class ConstantExpr;
372377 void setIsInBounds(bool B) {
373378 SubclassOptionalData =
374379 (SubclassOptionalData & ~IsInBounds) | (B * IsInBounds);
379384 bool isInBounds() const {
380385 return SubclassOptionalData & IsInBounds;
381386 }
387
382388 /// Returns the offset of the index with an inrange attachment, or None if
383389 /// none.
384390 Optional getInRangeIndex() const {
469475 const Value *getPointerOperand() const {
470476 return getOperand(0);
471477 }
478
472479 static unsigned getPointerOperandIndex() {
473480 return 0U; // get index for modifying correct operand
474481 }
499506 }
500507 };
501508
502 } // End llvm namespace
503
504 #endif
509 } // end namespace llvm
510
511 #endif // LLVM_IR_OPERATOR_H
None //===-- llvm/IR/Statepoint.h - gc.statepoint utilities ------ --*- C++ -*-===//
0 //===-- llvm/IR/Statepoint.h - gc.statepoint utilities ----------*- C++ -*-===//
11 //
22 // The LLVM Compiler Infrastructure
33 //
1818
1919 #include "llvm/ADT/iterator_range.h"
2020 #include "llvm/ADT/Optional.h"
21 #include "llvm/IR/Attributes.h"
2122 #include "llvm/IR/BasicBlock.h"
2223 #include "llvm/IR/CallSite.h"
2324 #include "llvm/IR/Constants.h"
2526 #include "llvm/IR/Instructions.h"
2627 #include "llvm/IR/IntrinsicInst.h"
2728 #include "llvm/IR/Intrinsics.h"
29 #include "llvm/Support/Casting.h"
30 #include
31 #include
32 #include
33 #include
2834
2935 namespace llvm {
36
3037 /// The statepoint intrinsic accepts a set of flags as its third argument.
3138 /// Valid values come out of this set.
3239 enum class StatepointFlags {
4653
4754 class GCRelocateInst;
4855 class GCResultInst;
49 class ImmutableStatepoint;
5056
5157 bool isStatepoint(ImmutableCallSite CS);
5258 bool isStatepoint(const Value *V);
6571 typename CallSiteTy>
6672 class StatepointBase {
6773 CallSiteTy StatepointCS;
68 void *operator new(size_t, unsigned) = delete;
69 void *operator new(size_t s) = delete;
7074
7175 protected:
7276 explicit StatepointBase(InstructionTy *I) {
7579 assert(StatepointCS && "isStatepoint implies CallSite");
7680 }
7781 }
82
7883 explicit StatepointBase(CallSiteTy CS) {
7984 if (isStatepoint(CS))
8085 StatepointCS = CS;
9196 FlagsPos = 4,
9297 CallArgsBeginPos = 5,
9398 };
99
100 void *operator new(size_t, unsigned) = delete;
101 void *operator new(size_t s) = delete;
94102
95103 explicit operator bool() const {
96104 // We do not assign non-statepoint CallSites to StatepointCS.
450458 /// Return \c true if the the \p Attr is an attribute that is a statepoint
451459 /// directive.
452460 bool isStatepointDirectiveAttr(Attribute Attr);
453 }
454
455 #endif
461
462 } // end namespace llvm
463
464 #endif // LLVM_IR_STATEPOINT_H
2626
2727 #include "llvm/ADT/PointerIntPair.h"
2828 #include "llvm/Support/CBindingWrapping.h"
29 #include
29 #include "llvm-c/Types.h"
3030
3131 namespace llvm {
3232
3939 template <> class PointerLikeTypeTraits {
4040 public:
4141 static inline void *getAsVoidPointer(Use **P) { return P; }
42
4243 static inline Use **getFromVoidPointer(void *P) {
4344 return static_cast(P);
4445 }
46
4547 enum { NumLowBitsAvailable = 2 };
4648 };
4749
6466 /// time complexity.
6567 class Use {
6668 public:
69 Use(const Use &U) = delete;
70
6771 /// \brief Provide a fast substitute to std::swap
6872 /// that also works with less standard-compliant compilers
6973 void swap(Use &RHS);
7377 typedef PointerIntPair UserRef;
7478
7579 private:
76 Use(const Use &U) = delete;
77
7880 /// Destructor - Only for zap()
7981 ~Use() {
8082 if (Val)
127129 PointerIntPair Prev;
128130
129131 void setPrev(Use **NewPrev) { Prev.setPointer(NewPrev); }
132
130133 void addToList(Use **List) {
131134 Next = *List;
132135 if (Next)
134137 setPrev(List);
135138 *List = this;
136139 }
140
137141 void removeFromList() {
138142 Use **StrippedPrev = Prev.getPointer();
139143 *StrippedPrev = Next;
158162 // Create wrappers for C Binding types (see CBindingWrapping.h).
159163 DEFINE_SIMPLE_CONVERSION_FUNCTIONS(Use, LLVMUseRef)
160164
161 }
165 } // end namespace llvm
162166
163 #endif
167 #endif // LLVM_IR_USE_H
2626 #define LLVM_IR_VALUEMAP_H
2727
2828 #include "llvm/ADT/DenseMap.h"
29 #include "llvm/ADT/DenseMapInfo.h"
30 #include "llvm/ADT/None.h"
2931 #include "llvm/ADT/Optional.h"
3032 #include "llvm/IR/TrackingMDRef.h"
3133 #include "llvm/IR/ValueHandle.h"
34 #include "llvm/Support/Casting.h"
3235 #include "llvm/Support/Mutex.h"
3336 #include "llvm/Support/UniqueLock.h"
34 #include "llvm/Support/type_traits.h"
37 #include
38 #include
39 #include
3540 #include
36 #include <memory>
41 #include <type_traits>
42 #include
3743
3844 namespace llvm {
3945
7682 };
7783
7884 /// See the file comment.
79 template >
85 template>
8086 class ValueMap {
8187 friend class ValueMapCallbackVH;
88
8289 typedef ValueMapCallbackVH ValueMapCVH;
83 typedef DenseMap > MapT;
90 typedef DenseMap> MapT;
8491 typedef DenseMap MDMapT;
8592 typedef typename Config::ExtraData ExtraData;
8693 MapT Map;
8996
9097 bool MayMapMetadata = true;
9198
92 ValueMap(const ValueMap&) = delete;
93 ValueMap& operator=(const ValueMap&) = delete;
9499 public:
95100 typedef KeyT key_type;
96101 typedef ValueT mapped_type;
101106 : Map(NumInitBuckets), Data() {}
102107 explicit ValueMap(const ExtraData &Data, unsigned NumInitBuckets = 64)
103108 : Map(NumInitBuckets), Data(Data) {}
109 ValueMap(const ValueMap &) = delete;
110 ValueMap &operator=(const ValueMap &) = delete;
104111
105112 bool hasMD() const { return bool(MDMap); }
106113 MDMapT &MD() {
181188 for (; I != E; ++I)
182189 insert(*I);
183190 }
184
185191
186192 bool erase(const KeyT &Val) {
187193 typename MapT::iterator I = Map.find_as(Val);
236242 class ValueMapCallbackVH final : public CallbackVH {
237243 friend class ValueMap;
238244 friend struct DenseMapInfo;
245
239246 typedef ValueMap ValueMapT;
240247 typedef typename std::remove_pointer::type KeySansPointerT;
241248
261268 Config::onDelete(Copy.Map->Data, Copy.Unwrap()); // May destroy *this.
262269 Copy.Map->Map.erase(Copy); // Definitely destroys *this.
263270 }
271
264272 void allUsesReplacedWith(Value *new_key) override {
265273 assert(isa(new_key) &&
266274 "Invalid RAUW on key of ValueMap<>");
288296 };
289297
290298 template
291 struct DenseMapInfo > {
299 struct DenseMapInfo> {
292300 typedef ValueMapCallbackVH VH;
293301
294302 static inline VH getEmptyKey() {
295303 return VH(DenseMapInfo::getEmptyKey());
296304 }
305
297306 static inline VH getTombstoneKey() {
298307 return VH(DenseMapInfo::getTombstoneKey());
299308 }
309
300310 static unsigned getHashValue(const VH &Val) {
301311 return DenseMapInfo::getHashValue(Val.Unwrap());
302312 }
313
303314 static unsigned getHashValue(const KeyT &Val) {
304315 return DenseMapInfo::getHashValue(Val);
305316 }
317
306318 static bool isEqual(const VH &LHS, const VH &RHS) {
307319 return LHS == RHS;
308320 }
321
309322 static bool isEqual(const KeyT &LHS, const VH &RHS) {
310323 return LHS == RHS.getValPtr();
311324 }
312325 };
313
314326
315327 template
316328 class ValueMapIterator :
319331 ptrdiff_t> {
320332 typedef typename DenseMapT::iterator BaseT;
321333 typedef typename DenseMapT::mapped_type ValueT;
334
322335 BaseT I;
336
323337 public:
324338 ValueMapIterator() : I() {}
325
326339 ValueMapIterator(BaseT I) : I(I) {}
327340
328341 BaseT base() const { return I; }
368381 ptrdiff_t> {
369382 typedef typename DenseMapT::const_iterator BaseT;
370383 typedef typename DenseMapT::mapped_type ValueT;
384
371385 BaseT I;
386
372387 public:
373388 ValueMapConstIterator() : I() {}
374389 ValueMapConstIterator(BaseT I) : I(I) {}
413428
414429 } // end namespace llvm
415430
416 #endif
431 #endif // LLVM_IR_VALUEMAP_H
1414 #ifndef LLVM_TRANSFORMS_UTILS_FUNCTIONCOMPARATOR_H
1515 #define LLVM_TRANSFORMS_UTILS_FUNCTIONCOMPARATOR_H
1616
17 #include "llvm/ADT/APFloat.h"
18 #include "llvm/ADT/DenseMap.h"
19 #include "llvm/ADT/StringRef.h"
1720 #include "llvm/IR/Function.h"
1821 #include "llvm/IR/ValueMap.h"
1922 #include "llvm/IR/Operator.h"
2023 #include "llvm/Support/AtomicOrdering.h"
24 #include "llvm/Support/Casting.h"
25 #include
26 #include
2127
2228 namespace llvm {
29
30 class GetElementPtrInst;
2331
2432 /// GlobalNumberState assigns an integer to each global value in the program,
2533 /// which is used by the comparison routine to order references to globals. This
4351 typedef ValueMap ValueNumberMap;
4452 ValueNumberMap GlobalNumbers;
4553 // The next unused serial number to assign to a global.
46 uint64_t NextNumber;
47 public:
48 GlobalNumberState() : GlobalNumbers(), NextNumber(0) {}
49 uint64_t getNumber(GlobalValue* Global) {
50 ValueNumberMap::iterator MapIter;
51 bool Inserted;
52 std::tie(MapIter, Inserted) = GlobalNumbers.insert({Global, NextNumber});
53 if (Inserted)
54 NextNumber++;
55 return MapIter->second;
56 }
57 void clear() {
58 GlobalNumbers.clear();
59 }
54 uint64_t NextNumber = 0;
55
56 public:
57 GlobalNumberState() = default;
58
59 uint64_t getNumber(GlobalValue* Global) {
60 ValueNumberMap::iterator MapIter;
61 bool Inserted;
62 std::tie(MapIter, Inserted) = GlobalNumbers.insert({Global, NextNumber});
63 if (Inserted)
64 NextNumber++;
65 return MapIter->second;
66 }
67
68 void clear() {
69 GlobalNumbers.clear();
70 }
6071 };
6172
6273 /// FunctionComparator - Compares two functions to determine whether or not
7788 static FunctionHash functionHash(Function &);
7889
7990 protected:
80
8191 /// Start the comparison.
8292 void beginCompare() {
8393 sn_mapL.clear();
301311 const Function *FnL, *FnR;
302312
303313 private:
304
305314 int cmpOrderings(AtomicOrdering L, AtomicOrdering R) const;
306315 int cmpInlineAsm(const InlineAsm *L, const InlineAsm *R) const;
307316 int cmpAttrs(const AttributeSet L, const AttributeSet R) const;
361370 GlobalNumberState* GlobalNumbers;
362371 };
363372
364 }
373 } // end namespace llvm
365374
366375 #endif // LLVM_TRANSFORMS_UTILS_FUNCTIONCOMPARATOR_H