14#ifndef LLVM_DXILWRITER_VALUEENUMERATOR_H
15#define LLVM_DXILWRITER_VALUEENUMERATOR_H
42class ValueSymbolTable;
51 using ValueList = std::vector<std::pair<const Value *, unsigned>>;
71 std::vector<const Metadata *> MDs;
72 std::vector<const Metadata *> FunctionMDs;
80 explicit MDIndex(
unsigned F) :
F(
F) {}
83 bool hasDifferentFunction(
unsigned NewF)
const {
return F &&
F != NewF; }
87 assert(
ID &&
"Expected non-zero ID");
94 MetadataMapType MetadataMap;
102 unsigned NumStrings = 0;
105 explicit MDRange(
unsigned First) : First(First) {}
107 SmallDenseMap<unsigned, MDRange, 1> FunctionMDInfo;
109 using AttributeGroupMapType = DenseMap<IndexAndAttrSet, unsigned>;
110 AttributeGroupMapType AttributeGroupMap;
111 std::vector<IndexAndAttrSet> AttributeGroups;
113 using AttributeListMapType = DenseMap<AttributeList, unsigned>;
114 AttributeListMapType AttributeListMap;
115 std::vector<AttributeList> AttributeLists;
119 mutable DenseMap<const BasicBlock *, unsigned> GlobalBasicBlockIDs;
121 using InstructionMapType = DenseMap<const Instruction *, unsigned>;
122 InstructionMapType InstructionMap;
123 unsigned InstructionCount;
127 std::vector<const BasicBlock *> BasicBlocks;
131 unsigned NumModuleValues;
135 unsigned NumModuleMDs = 0;
136 unsigned NumMDStrings = 0;
138 unsigned FirstFuncConstantID;
139 unsigned FirstInstID;
142 ValueEnumerator(
const Module &M, Type *
PrefixType);
149 const char *
Name)
const;
155 assert(
ID != 0 &&
"Metadata not in slotcalculator!");
160 return MetadataMap.lookup(MD).ID;
163 unsigned numMDs()
const {
return MDs.size(); }
167 assert(
I != TypeMap.
end() &&
"Type not in ValueEnumerator!");
168 return I->second - 1;
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);
219 return AttributeLists;
223 return AttributeGroups;
249 void organizeMetadata();
258 void incorporateFunctionMetadata(
const Function &
F);
269 unsigned getMetadataFunctionID(
const Function *
F)
const;
287 void EnumerateMetadata(
unsigned F,
const Metadata *MD);
290 void EnumerateFunctionLocalMetadata(
const Function &
F,
292 void EnumerateFunctionLocalMetadata(
unsigned F,
const LocalAsMetadata *Local);
293 void EnumerateFunctionLocalListMetadata(
const Function &
F,
295 void EnumerateFunctionLocalListMetadata(
unsigned F,
const DIArgList *Arglist);
297 void EnumerateValue(
const Value *V);
298 void EnumerateOperandType(
const Value *V);
302 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.
This class provides a symbol table of name/value pairs.
LLVM Value Representation.
ArrayRef< const Metadata * > getNonMDStrings() const
Get the non-MDString metadata for this block.
unsigned getValueID(const Value *V) const
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)
void EnumerateType(Type *T)
unsigned getMetadataOrNullID(const Metadata *MD) const
const std::vector< IndexAndAttrSet > & getAttributeGroups() const
unsigned getComdatID(const Comdat *C) const
ArrayRef< const Metadata * > getMDStrings() const
Get the MDString metadata for this block.
bool hasMDs() const
Check whether the current block has any metadata to emit.
uint64_t computeBitsRequiredForTypeIndices() const
const ComdatSetType & getComdats() const
unsigned getAttributeListID(AttributeList PAL) const
unsigned getMetadataID(const Metadata *MD) const
ValueEnumerator & operator=(const ValueEnumerator &)=delete
void print(raw_ostream &OS, const MetadataMapType &Map, const char *Name) const
std::vector< std::pair< const Value *, unsigned > > ValueList
const TypeList & getTypes() const
const std::vector< AttributeList > & getAttributeLists() const
void print(raw_ostream &OS, const ValueMapType &Map, const char *Name) const
std::vector< Type * > TypeList
void incorporateFunction(const Function &F)
incorporateFunction/purgeFunction - If you'd like to deal with a function, use these two methods to g...
unsigned getTypeID(Type *T) const
unsigned getInstructionID(const Instruction *I) const
const ValueList & getValues() const
ValueEnumerator(const ValueEnumerator &)=delete
unsigned getGlobalBasicBlockID(const BasicBlock *BB) const
getGlobalBasicBlockID - This returns the function-specific ID for the specified basic block.
UseListOrderStack UseListOrders
void getFunctionConstantRange(unsigned &Start, unsigned &End) const
getFunctionConstantRange - Return the range of values that corresponds to function-local constants.
const std::vector< const BasicBlock * > & getBasicBlocks() const
unsigned getAttributeGroupID(IndexAndAttrSet Group) const
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)