003 File Manager
Current Path:
/usr/src/contrib/llvm-project/llvm/include/llvm/IR
usr
/
src
/
contrib
/
llvm-project
/
llvm
/
include
/
llvm
/
IR
/
📁
..
📄
AbstractCallSite.h
(9.5 KB)
📄
Argument.h
(5.03 KB)
📄
AssemblyAnnotationWriter.h
(2.2 KB)
📄
Attributes.h
(35.5 KB)
📄
Attributes.td
(8.96 KB)
📄
AutoUpgrade.h
(3.96 KB)
📄
BasicBlock.h
(21.91 KB)
📄
CFG.h
(13.84 KB)
📄
CallingConv.h
(9.27 KB)
📄
Comdat.h
(2.16 KB)
📄
Constant.h
(8.33 KB)
📄
ConstantFolder.h
(10.01 KB)
📄
ConstantRange.h
(21.6 KB)
📄
Constants.h
(53.03 KB)
📄
ConstrainedOps.def
(5.4 KB)
📄
DIBuilder.h
(44.36 KB)
📄
DataLayout.h
(24.11 KB)
📄
DebugInfo.h
(5.42 KB)
📄
DebugInfoFlags.def
(3.62 KB)
📄
DebugInfoMetadata.h
(132.91 KB)
📄
DebugLoc.h
(4.57 KB)
📄
DerivedTypes.h
(26.81 KB)
📄
DerivedUser.h
(1.32 KB)
📄
DiagnosticHandler.h
(2.89 KB)
📄
DiagnosticInfo.h
(41.02 KB)
📄
DiagnosticPrinter.h
(3.46 KB)
📄
Dominators.h
(9.94 KB)
📄
FPEnv.h
(1.97 KB)
📄
FixedMetadataKinds.def
(2.05 KB)
📄
Function.h
(31.39 KB)
📄
GVMaterializer.h
(1.45 KB)
📄
GetElementPtrTypeIterator.h
(5.54 KB)
📄
GlobalAlias.h
(3.16 KB)
📄
GlobalIFunc.h
(2.51 KB)
📄
GlobalIndirectSymbol.h
(3.11 KB)
📄
GlobalObject.h
(7.39 KB)
📄
GlobalValue.h
(21.2 KB)
📄
GlobalVariable.h
(9.6 KB)
📄
IRBuilder.h
(105.58 KB)
📄
IRBuilderFolder.h
(7.1 KB)
📄
IRPrintingPasses.h
(3.57 KB)
📄
InlineAsm.h
(15.84 KB)
📄
InstIterator.h
(5.06 KB)
📄
InstVisitor.h
(13.95 KB)
📄
InstrTypes.h
(86.25 KB)
📄
Instruction.def
(8.53 KB)
📄
Instruction.h
(30.74 KB)
📄
Instructions.h
(195.68 KB)
📄
IntrinsicInst.h
(29.03 KB)
📄
Intrinsics.h
(8.21 KB)
📄
Intrinsics.td
(78.88 KB)
📄
IntrinsicsAArch64.td
(100.59 KB)
📄
IntrinsicsAMDGPU.td
(80.43 KB)
📄
IntrinsicsARM.td
(65.15 KB)
📄
IntrinsicsBPF.td
(1.54 KB)
📄
IntrinsicsHexagon.td
(11.53 KB)
📄
IntrinsicsHexagonDep.td
(197.38 KB)
📄
IntrinsicsMips.td
(94.94 KB)
📄
IntrinsicsNVVM.td
(193.97 KB)
📄
IntrinsicsPowerPC.td
(68.23 KB)
📄
IntrinsicsRISCV.td
(3.24 KB)
📄
IntrinsicsSystemZ.td
(18.56 KB)
📄
IntrinsicsWebAssembly.td
(9.38 KB)
📄
IntrinsicsX86.td
(242.99 KB)
📄
IntrinsicsXCore.td
(6.83 KB)
📄
LLVMContext.h
(14.18 KB)
📄
LLVMRemarkStreamer.h
(3.36 KB)
📄
LegacyPassManager.h
(3.11 KB)
📄
LegacyPassManagers.h
(18.17 KB)
📄
LegacyPassNameParser.h
(3.73 KB)
📄
MDBuilder.h
(8.65 KB)
📄
Mangler.h
(2.06 KB)
📄
MatrixBuilder.h
(8.81 KB)
📄
Metadata.def
(5.07 KB)
📄
Metadata.h
(45.24 KB)
📄
Module.h
(34.6 KB)
📄
ModuleSlotTracker.h
(2.56 KB)
📄
ModuleSummaryIndex.h
(58.12 KB)
📄
ModuleSummaryIndexYAML.h
(10.93 KB)
📄
NoFolder.h
(11.32 KB)
📄
OperandTraits.h
(5.78 KB)
📄
Operator.h
(19.58 KB)
📄
OptBisect.h
(2.79 KB)
📄
PassInstrumentation.h
(8.05 KB)
📄
PassManager.h
(54.18 KB)
📄
PassManagerImpl.h
(5.76 KB)
📄
PassManagerInternal.h
(11.9 KB)
📄
PassTimingInfo.h
(3.65 KB)
📄
PatternMatch.h
(73.41 KB)
📄
PredIteratorCache.h
(2.59 KB)
📄
ProfileSummary.h
(4.34 KB)
📄
RuntimeLibcalls.def
(24.52 KB)
📄
SafepointIRVerifier.h
(1.63 KB)
📄
Statepoint.h
(13.61 KB)
📄
SymbolTableListTraits.h
(4.45 KB)
📄
TrackingMDRef.h
(4.5 KB)
📄
Type.h
(18.98 KB)
📄
TypeFinder.h
(2.57 KB)
📄
Use.h
(3.75 KB)
📄
UseListOrder.h
(1.18 KB)
📄
User.h
(11.75 KB)
📄
VPIntrinsics.def
(2.34 KB)
📄
Value.def
(3.62 KB)
📄
Value.h
(32.16 KB)
📄
ValueHandle.h
(18.11 KB)
📄
ValueMap.h
(14.09 KB)
📄
ValueSymbolTable.h
(4.22 KB)
📄
Verifier.h
(5.47 KB)
Editing: User.h
//===- llvm/User.h - User class definition ----------------------*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // // This class defines the interface that one who uses a Value must implement. // Each instance of the Value class keeps track of what User's have handles // to it. // // * Instructions are the largest class of Users. // * Constants may be users of other constants (think arrays and stuff) // //===----------------------------------------------------------------------===// #ifndef LLVM_IR_USER_H #define LLVM_IR_USER_H #include "llvm/ADT/iterator.h" #include "llvm/ADT/iterator_range.h" #include "llvm/IR/Use.h" #include "llvm/IR/Value.h" #include "llvm/Support/Casting.h" #include "llvm/Support/Compiler.h" #include "llvm/Support/ErrorHandling.h" #include <cassert> #include <cstddef> #include <cstdint> #include <iterator> namespace llvm { template <typename T> class ArrayRef; template <typename T> class MutableArrayRef; /// Compile-time customization of User operands. /// /// Customizes operand-related allocators and accessors. template <class> struct OperandTraits; class User : public Value { template <unsigned> friend struct HungoffOperandTraits; LLVM_ATTRIBUTE_ALWAYS_INLINE inline static void * allocateFixedOperandUser(size_t, unsigned, unsigned); protected: /// Allocate a User with an operand pointer co-allocated. /// /// This is used for subclasses which need to allocate a variable number /// of operands, ie, 'hung off uses'. void *operator new(size_t Size); /// Allocate a User with the operands co-allocated. /// /// This is used for subclasses which have a fixed number of operands. void *operator new(size_t Size, unsigned Us); /// Allocate a User with the operands co-allocated. If DescBytes is non-zero /// then allocate an additional DescBytes bytes before the operands. These /// bytes can be accessed by calling getDescriptor. /// /// DescBytes needs to be divisible by sizeof(void *). The allocated /// descriptor, if any, is aligned to sizeof(void *) bytes. /// /// This is used for subclasses which have a fixed number of operands. void *operator new(size_t Size, unsigned Us, unsigned DescBytes); User(Type *ty, unsigned vty, Use *, unsigned NumOps) : Value(ty, vty) { assert(NumOps < (1u << NumUserOperandsBits) && "Too many operands"); NumUserOperands = NumOps; // If we have hung off uses, then the operand list should initially be // null. assert((!HasHungOffUses || !getOperandList()) && "Error in initializing hung off uses for User"); } /// Allocate the array of Uses, followed by a pointer /// (with bottom bit set) to the User. /// \param IsPhi identifies callers which are phi nodes and which need /// N BasicBlock* allocated along with N void allocHungoffUses(unsigned N, bool IsPhi = false); /// Grow the number of hung off uses. Note that allocHungoffUses /// should be called if there are no uses. void growHungoffUses(unsigned N, bool IsPhi = false); protected: ~User() = default; // Use deleteValue() to delete a generic Instruction. public: User(const User &) = delete; /// Free memory allocated for User and Use objects. void operator delete(void *Usr); /// Placement delete - required by std, called if the ctor throws. void operator delete(void *Usr, unsigned) { // Note: If a subclass manipulates the information which is required to calculate the // Usr memory pointer, e.g. NumUserOperands, the operator delete of that subclass has // to restore the changed information to the original value, since the dtor of that class // is not called if the ctor fails. User::operator delete(Usr); #ifndef LLVM_ENABLE_EXCEPTIONS llvm_unreachable("Constructor throws?"); #endif } /// Placement delete - required by std, called if the ctor throws. void operator delete(void *Usr, unsigned, unsigned) { // Note: If a subclass manipulates the information which is required to calculate the // Usr memory pointer, e.g. NumUserOperands, the operator delete of that subclass has // to restore the changed information to the original value, since the dtor of that class // is not called if the ctor fails. User::operator delete(Usr); #ifndef LLVM_ENABLE_EXCEPTIONS llvm_unreachable("Constructor throws?"); #endif } protected: template <int Idx, typename U> static Use &OpFrom(const U *that) { return Idx < 0 ? OperandTraits<U>::op_end(const_cast<U*>(that))[Idx] : OperandTraits<U>::op_begin(const_cast<U*>(that))[Idx]; } template <int Idx> Use &Op() { return OpFrom<Idx>(this); } template <int Idx> const Use &Op() const { return OpFrom<Idx>(this); } private: const Use *getHungOffOperands() const { return *(reinterpret_cast<const Use *const *>(this) - 1); } Use *&getHungOffOperands() { return *(reinterpret_cast<Use **>(this) - 1); } const Use *getIntrusiveOperands() const { return reinterpret_cast<const Use *>(this) - NumUserOperands; } Use *getIntrusiveOperands() { return reinterpret_cast<Use *>(this) - NumUserOperands; } void setOperandList(Use *NewList) { assert(HasHungOffUses && "Setting operand list only required for hung off uses"); getHungOffOperands() = NewList; } public: const Use *getOperandList() const { return HasHungOffUses ? getHungOffOperands() : getIntrusiveOperands(); } Use *getOperandList() { return const_cast<Use *>(static_cast<const User *>(this)->getOperandList()); } Value *getOperand(unsigned i) const { assert(i < NumUserOperands && "getOperand() out of range!"); return getOperandList()[i]; } void setOperand(unsigned i, Value *Val) { assert(i < NumUserOperands && "setOperand() out of range!"); assert((!isa<Constant>((const Value*)this) || isa<GlobalValue>((const Value*)this)) && "Cannot mutate a constant with setOperand!"); getOperandList()[i] = Val; } const Use &getOperandUse(unsigned i) const { assert(i < NumUserOperands && "getOperandUse() out of range!"); return getOperandList()[i]; } Use &getOperandUse(unsigned i) { assert(i < NumUserOperands && "getOperandUse() out of range!"); return getOperandList()[i]; } unsigned getNumOperands() const { return NumUserOperands; } /// Returns the descriptor co-allocated with this User instance. ArrayRef<const uint8_t> getDescriptor() const; /// Returns the descriptor co-allocated with this User instance. MutableArrayRef<uint8_t> getDescriptor(); /// Set the number of operands on a GlobalVariable. /// /// GlobalVariable always allocates space for a single operands, but /// doesn't always use it. /// /// FIXME: As that the number of operands is used to find the start of /// the allocated memory in operator delete, we need to always think we have /// 1 operand before delete. void setGlobalVariableNumOperands(unsigned NumOps) { assert(NumOps <= 1 && "GlobalVariable can only have 0 or 1 operands"); NumUserOperands = NumOps; } /// Subclasses with hung off uses need to manage the operand count /// themselves. In these instances, the operand count isn't used to find the /// OperandList, so there's no issue in having the operand count change. void setNumHungOffUseOperands(unsigned NumOps) { assert(HasHungOffUses && "Must have hung off uses to use this method"); assert(NumOps < (1u << NumUserOperandsBits) && "Too many operands"); NumUserOperands = NumOps; } /// A droppable user is a user for which uses can be dropped without affecting /// correctness and should be dropped rather than preventing a transformation /// from happening. bool isDroppable() const; // --------------------------------------------------------------------------- // Operand Iterator interface... // using op_iterator = Use*; using const_op_iterator = const Use*; using op_range = iterator_range<op_iterator>; using const_op_range = iterator_range<const_op_iterator>; op_iterator op_begin() { return getOperandList(); } const_op_iterator op_begin() const { return getOperandList(); } op_iterator op_end() { return getOperandList() + NumUserOperands; } const_op_iterator op_end() const { return getOperandList() + NumUserOperands; } op_range operands() { return op_range(op_begin(), op_end()); } const_op_range operands() const { return const_op_range(op_begin(), op_end()); } /// Iterator for directly iterating over the operand Values. struct value_op_iterator : iterator_adaptor_base<value_op_iterator, op_iterator, std::random_access_iterator_tag, Value *, ptrdiff_t, Value *, Value *> { explicit value_op_iterator(Use *U = nullptr) : iterator_adaptor_base(U) {} Value *operator*() const { return *I; } Value *operator->() const { return operator*(); } }; value_op_iterator value_op_begin() { return value_op_iterator(op_begin()); } value_op_iterator value_op_end() { return value_op_iterator(op_end()); } iterator_range<value_op_iterator> operand_values() { return make_range(value_op_begin(), value_op_end()); } struct const_value_op_iterator : iterator_adaptor_base<const_value_op_iterator, const_op_iterator, std::random_access_iterator_tag, const Value *, ptrdiff_t, const Value *, const Value *> { explicit const_value_op_iterator(const Use *U = nullptr) : iterator_adaptor_base(U) {} const Value *operator*() const { return *I; } const Value *operator->() const { return operator*(); } }; const_value_op_iterator value_op_begin() const { return const_value_op_iterator(op_begin()); } const_value_op_iterator value_op_end() const { return const_value_op_iterator(op_end()); } iterator_range<const_value_op_iterator> operand_values() const { return make_range(value_op_begin(), value_op_end()); } /// Drop all references to operands. /// /// This function is in charge of "letting go" of all objects that this User /// refers to. This allows one to 'delete' a whole class at a time, even /// though there may be circular references... First all references are /// dropped, and all use counts go to zero. Then everything is deleted for /// real. Note that no operations are valid on an object that has "dropped /// all references", except operator delete. void dropAllReferences() { for (Use &U : operands()) U.set(nullptr); } /// Replace uses of one Value with another. /// /// Replaces all references to the "From" definition with references to the /// "To" definition. void replaceUsesOfWith(Value *From, Value *To); // Methods for support type inquiry through isa, cast, and dyn_cast: static bool classof(const Value *V) { return isa<Instruction>(V) || isa<Constant>(V); } }; // Either Use objects, or a Use pointer can be prepended to User. static_assert(alignof(Use) >= alignof(User), "Alignment is insufficient after objects prepended to User"); static_assert(alignof(Use *) >= alignof(User), "Alignment is insufficient after objects prepended to User"); template<> struct simplify_type<User::op_iterator> { using SimpleType = Value*; static SimpleType getSimplifiedValue(User::op_iterator &Val) { return Val->get(); } }; template<> struct simplify_type<User::const_op_iterator> { using SimpleType = /*const*/ Value*; static SimpleType getSimplifiedValue(User::const_op_iterator &Val) { return Val->get(); } }; } // end namespace llvm #endif // LLVM_IR_USER_H
Upload File
Create Folder