14 #ifndef LLVM_LIB_BITCODE_WRITER_VALUEENUMERATOR_H 15 #define LLVM_LIB_BITCODE_WRITER_VALUEENUMERATOR_H 35 class LocalAsMetadata;
43 class ValueSymbolTable;
50 using ValueList = std::vector<std::pair<const Value *, unsigned>>;
70 std::vector<const Metadata *> MDs;
71 std::vector<const Metadata *> FunctionMDs;
79 explicit MDIndex(
unsigned F) :
F(F) {}
82 bool hasDifferentFunction(
unsigned NewF)
const {
return F && F != NewF; }
86 assert(ID &&
"Expected non-zero ID");
87 assert(ID <= MDs.size() &&
"Expected valid ID");
101 unsigned NumStrings = 0;
104 explicit MDRange(
unsigned First) : First(First) {}
108 bool ShouldPreserveUseListOrder;
112 std::vector<IndexAndAttrSet> AttributeGroups;
116 std::vector<AttributeList> AttributeLists;
124 unsigned InstructionCount;
128 std::vector<const BasicBlock*> BasicBlocks;
132 unsigned NumModuleValues;
136 unsigned NumModuleMDs = 0;
137 unsigned NumMDStrings = 0;
139 unsigned FirstFuncConstantID;
140 unsigned FirstInstID;
150 const char *Name)
const;
156 assert(
ID != 0 &&
"Metadata not in slotcalculator!");
161 return MetadataMap.
lookup(MD).ID;
164 unsigned numMDs()
const {
return MDs.size(); }
170 assert(I != TypeMap.
end() &&
"Type not in ValueEnumerator!");
180 assert(I != AttributeListMap.
end() &&
"Attribute not in ValueEnumerator!");
185 if (!Group.second.hasAttributes())
188 assert(I != AttributeGroupMap.
end() &&
"Attribute not in ValueEnumerator!");
195 Start = FirstFuncConstantID;
202 bool hasMDs()
const {
return NumModuleMDs < MDs.size(); }
206 return makeArrayRef(MDs).slice(NumModuleMDs, NumMDStrings);
211 return makeArrayRef(MDs).slice(NumModuleMDs).slice(NumMDStrings);
223 return AttributeGroups;
242 void OptimizeConstants(
unsigned CstStart,
unsigned CstEnd);
248 void organizeMetadata();
257 void incorporateFunctionMetadata(
const Function &F);
266 const MDNode *enumerateMetadataImpl(
unsigned F,
const Metadata *MD);
268 unsigned getMetadataFunctionID(
const Function *F)
const;
286 void EnumerateMetadata(
unsigned F,
const Metadata *MD);
289 void EnumerateFunctionLocalMetadata(
const Function &F,
291 void EnumerateFunctionLocalMetadata(
unsigned F,
const LocalAsMetadata *Local);
293 void EnumerateValue(
const Value *V);
294 void EnumerateType(
Type *
T);
295 void EnumerateOperandType(
const Value *V);
299 void EnumerateNamedMetadata(
const Module &M);
304 #endif // LLVM_LIB_BITCODE_WRITER_VALUEENUMERATOR_H
This class provides a symbol table of name/value pairs.
Type
MessagePack types as defined in the standard, with the exception of Integer being divided into a sign...
unsigned getMetadataOrNullID(const Metadata *MD) const
unsigned getValueID(const Value *V) const
const ValueList & getValues() const
This class represents lattice values for constants.
A Module instance is used to store all the information related to an LLVM module. ...
std::pair< unsigned, AttributeSet > IndexAndAttrSet
Attribute groups as encoded in bitcode are almost AttributeSets, but they include the AttributeList i...
void setInstructionID(const Instruction *I)
bool shouldPreserveUseListOrder() const
bool hasMDs() const
Check whether the current block has any metadata to emit.
unsigned getAttributeGroupID(IndexAndAttrSet Group) const
unsigned getMetadataID(const Metadata *MD) const
void incorporateFunction(const Function &F)
incorporateFunction/purgeFunction - If you'd like to deal with a function, use these two methods to g...
amdgpu Simplify well known AMD library false Value Value const Twine & Name
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
const TypeList & getTypes() const
This file contains the simple types necessary to represent the attributes associated with functions a...
uint64_t computeBitsRequiredForTypeIndicies() const
llvm::detail::DenseMapPair< const Metadata *, MDIndex > value_type
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
ArrayRef< const Metadata * > getMDStrings() const
Get the MDString metadata for this block.
iterator find(const_arg_type_t< KeyT > Val)
std::vector< Type * > TypeList
LLVM Basic Block Representation.
The instances of the Type class are immutable: once they are created, they are never changed...
void print(raw_ostream &OS, const ValueMapType &Map, const char *Name) const
unsigned getInstructionID(const Instruction *I) const
std::vector< UseListOrder > UseListOrderStack
ValueEnumerator(const Module &M, bool ShouldPreserveUseListOrder)
unsigned getGlobalBasicBlockID(const BasicBlock *BB) const
getGlobalBasicBlockID - This returns the function-specific ID for the specified basic block...
const std::vector< AttributeList > & getAttributeLists() const
ArrayRef< const Metadata * > getNonMDStrings() const
Get the non-MDString metadata for this block.
void getFunctionConstantRange(unsigned &Start, unsigned &End) const
getFunctionConstantRange - Return the range of values that corresponds to function-local constants...
std::vector< std::pair< const Value *, unsigned > > ValueList
ValueEnumerator & operator=(const ValueEnumerator &)=delete
const ComdatSetType & getComdats() const
unsigned getTypeID(Type *T) const
UseListOrderStack UseListOrders
const std::vector< IndexAndAttrSet > & getAttributeGroups() const
const std::vector< const BasicBlock * > & getBasicBlocks() const
ValueT lookup(const_arg_type_t< KeyT > Val) const
lookup - Return the entry for the specified key, or a default constructed value if no such entry exis...
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
LLVM Value Representation.
This class implements an extremely fast bulk output stream that can only output to a stream...
unsigned getComdatID(const Comdat *C) const
unsigned getAttributeListID(AttributeList PAL) const
bool isEmpty() const
Return true if there are no attributes.
UniqueVector - This class produces a sequential ID number (base 1) for each unique entry that is adde...
std::vector< uint32_t > Metadata
PAL metadata represented as a vector.