13#ifndef LLVM_LIB_BITCODE_WRITER_VALUEENUMERATOR_H
14#define LLVM_LIB_BITCODE_WRITER_VALUEENUMERATOR_H
41class ValueSymbolTable;
48 using ValueList = std::vector<std::pair<const Value *, unsigned>>;
68 std::vector<const Metadata *> MDs;
69 std::vector<const Metadata *> FunctionMDs;
77 explicit MDIndex(
unsigned F) :
F(
F) {}
80 bool hasDifferentFunction(
unsigned NewF)
const {
return F &&
F != NewF; }
84 assert(
ID &&
"Expected non-zero ID");
91 MetadataMapType MetadataMap;
99 unsigned NumStrings = 0;
102 explicit MDRange(
unsigned First) : First(First) {}
104 SmallDenseMap<unsigned, MDRange, 1> FunctionMDInfo;
106 bool ShouldPreserveUseListOrder;
108 using AttributeGroupMapType = DenseMap<IndexAndAttrSet, unsigned>;
109 AttributeGroupMapType AttributeGroupMap;
110 std::vector<IndexAndAttrSet> AttributeGroups;
112 using AttributeListMapType = DenseMap<AttributeList, unsigned>;
113 AttributeListMapType AttributeListMap;
114 std::vector<AttributeList> AttributeLists;
118 mutable DenseMap<const BasicBlock*, unsigned> GlobalBasicBlockIDs;
120 using InstructionMapType = DenseMap<const Instruction *, unsigned>;
121 InstructionMapType InstructionMap;
122 unsigned InstructionCount;
126 std::vector<const BasicBlock*> BasicBlocks;
130 unsigned NumModuleValues;
134 unsigned NumModuleMDs = 0;
135 unsigned NumMDStrings = 0;
137 unsigned FirstFuncConstantID;
138 unsigned FirstInstID;
148 const char *
Name)
const;
154 assert(
ID != 0 &&
"Metadata not in slotcalculator!");
159 return MetadataMap.lookup(MD).ID;
162 unsigned numMDs()
const {
return MDs.size(); }
168 assert(
I != TypeMap.
end() &&
"Type not in ValueEnumerator!");
178 assert(
I != AttributeListMap.end() &&
"Attribute not in ValueEnumerator!");
183 if (!Group.second.hasAttributes())
186 assert(
I != AttributeGroupMap.end() &&
"Attribute not in ValueEnumerator!");
193 Start = FirstFuncConstantID;
200 bool hasMDs()
const {
return NumModuleMDs < MDs.size(); }
209 return ArrayRef(MDs).
slice(NumModuleMDs).slice(NumMDStrings);
221 return AttributeGroups;
240 void OptimizeConstants(
unsigned CstStart,
unsigned CstEnd);
246 void organizeMetadata();
255 void incorporateFunctionMetadata(
const Function &
F);
266 unsigned getMetadataFunctionID(
const Function *
F)
const;
284 void EnumerateMetadata(
unsigned F,
const Metadata *MD);
287 void EnumerateFunctionLocalMetadata(
const Function &
F,
289 void EnumerateFunctionLocalMetadata(
unsigned F,
const LocalAsMetadata *Local);
290 void EnumerateFunctionLocalListMetadata(
const Function &
F,
292 void EnumerateFunctionLocalListMetadata(
unsigned F,
const DIArgList *Arglist);
294 void EnumerateValue(
const Value *V);
295 void EnumerateType(
Type *
T);
296 void EnumerateOperandType(
const Value *V);
300 void EnumerateNamedMetadata(
const Module &M);
This file contains the simple types necessary to represent the attributes associated with functions a...
This file defines the DenseMap class.
Machine Check Debug Module
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
size_t size() const
size - Get the array size.
ArrayRef< T > slice(size_t N, size_t M) const
slice(n, m) - Chop off the first N elements of the array, and keep M elements in the array.
bool isEmpty() const
Return true if there are no attributes.
LLVM Basic Block Representation.
List of ValueAsMetadata, to be used as an argument to a dbg.value intrinsic.
iterator find(const_arg_type_t< KeyT > Val)
A Module instance is used to store all the information related to an LLVM module.
The instances of the Type class are immutable: once they are created, they are never changed.
unsigned getTypeID(Type *T) const
unsigned getMetadataID(const Metadata *MD) const
UseListOrderStack UseListOrders
std::vector< std::pair< const Value *, unsigned > > ValueList
void print(raw_ostream &OS, const ValueMapType &Map, const char *Name) const
ArrayRef< const Metadata * > getNonMDStrings() const
Get the non-MDString metadata for this block.
unsigned getInstructionID(const Instruction *I) const
unsigned getAttributeListID(AttributeList PAL) const
void incorporateFunction(const Function &F)
incorporateFunction/purgeFunction - If you'd like to deal with a function, use these two methods to g...
void getFunctionConstantRange(unsigned &Start, unsigned &End) const
getFunctionConstantRange - Return the range of values that corresponds to function-local constants.
unsigned getAttributeGroupID(IndexAndAttrSet Group) const
bool hasMDs() const
Check whether the current block has any metadata to emit.
ValueEnumerator(const Module &M, bool ShouldPreserveUseListOrder)
unsigned getComdatID(const Comdat *C) const
uint64_t computeBitsRequiredForTypeIndices() const
ValueEnumerator(const ValueEnumerator &)=delete
unsigned getValueID(const Value *V) const
unsigned getMetadataOrNullID(const Metadata *MD) const
const std::vector< IndexAndAttrSet > & getAttributeGroups() const
const ValueList & getValues() const
unsigned getGlobalBasicBlockID(const BasicBlock *BB) const
getGlobalBasicBlockID - This returns the function-specific ID for the specified basic block.
void setInstructionID(const Instruction *I)
const std::vector< const BasicBlock * > & getBasicBlocks() const
const std::vector< AttributeList > & getAttributeLists() const
ValueEnumerator & operator=(const ValueEnumerator &)=delete
bool shouldPreserveUseListOrder() const
const ComdatSetType & getComdats() const
std::vector< Type * > TypeList
ArrayRef< const Metadata * > getMDStrings() const
Get the MDString metadata for this block.
std::pair< unsigned, AttributeSet > IndexAndAttrSet
Attribute groups as encoded in bitcode are almost AttributeSets, but they include the AttributeList i...
const TypeList & getTypes() const
This class provides a symbol table of name/value pairs.
LLVM Value Representation.
This class implements an extremely fast bulk output stream that can only output to a stream.
@ C
The default llvm calling convention, compatible with C.
@ BasicBlock
Various leaf nodes.
This is an optimization pass for GlobalISel generic memory operations.
std::vector< UseListOrder > UseListOrderStack
decltype(auto) get(const PointerIntPair< PointerTy, IntBits, IntType, PtrTraits, Info > &Pair)