Go to the documentation of this file.
13 #ifndef LLVM_LIB_BITCODE_WRITER_VALUEENUMERATOR_H
14 #define LLVM_LIB_BITCODE_WRITER_VALUEENUMERATOR_H
33 class LocalAsMetadata;
41 class 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;
146 void print(raw_ostream &OS,
const ValueMapType &Map,
const char *
Name)
const;
147 void print(raw_ostream &OS,
const MetadataMapType &Map,
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(); }
204 return makeArrayRef(MDs).slice(NumModuleMDs, NumMDStrings);
209 return makeArrayRef(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);
305 #endif // LLVM_LIB_BITCODE_WRITER_VALUEENUMERATOR_H
const std::vector< IndexAndAttrSet > & getAttributeGroups() const
const TypeList & getTypes() const
List of ValueAsMetadata, to be used as an argument to a dbg.value intrinsic.
This is an optimization pass for GlobalISel generic memory operations.
const std::vector< AttributeList > & getAttributeLists() const
std::pair< unsigned, AttributeSet > IndexAndAttrSet
Attribute groups as encoded in bitcode are almost AttributeSets, but they include the AttributeList i...
The instances of the Type class are immutable: once they are created, they are never changed.
unsigned getMetadataID(const Metadata *MD) const
unsigned getTypeID(Type *T) const
const ValueList & getValues() const
UseListOrderStack UseListOrders
LLVM Basic Block Representation.
const std::vector< const BasicBlock * > & getBasicBlocks() const
unsigned getInstructionID(const Instruction *I) const
ArrayRef< const Metadata * > getNonMDStrings() const
Get the non-MDString metadata for this block.
(vector float) vec_cmpeq(*A, *B) C
uint64_t computeBitsRequiredForTypeIndicies() const
unsigned getAttributeGroupID(IndexAndAttrSet Group) const
into llvm powi allowing the code generator to produce balanced multiplication trees First
unsigned getValueID(const Value *V) const
void print(raw_ostream &OS, const ValueMapType &Map, const char *Name) const
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
bool shouldPreserveUseListOrder() const
unsigned getMetadataOrNullID(const Metadata *MD) const
unsigned getAttributeListID(AttributeList PAL) const
llvm::detail::DenseMapPair< const Metadata *, MDIndex > value_type
iterator find(const_arg_type_t< KeyT > Val)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
void incorporateFunction(const Function &F)
incorporateFunction/purgeFunction - If you'd like to deal with a function, use these two methods to g...
@ BasicBlock
Various leaf nodes.
A Module instance is used to store all the information related to an LLVM module.
void setInstructionID(const Instruction *I)
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
bool hasMDs() const
Check whether the current block has any metadata to emit.
Machine Check Debug Module
std::vector< UseListOrder > UseListOrderStack
Should compile to something r4 addze r3 instead we get
ValueEnumerator & operator=(const ValueEnumerator &)=delete
unsigned getComdatID(const Comdat *C) const
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
unsigned getGlobalBasicBlockID(const BasicBlock *BB) const
getGlobalBasicBlockID - This returns the function-specific ID for the specified basic block.
std::vector< std::pair< const Value *, unsigned > > ValueList
ValueEnumerator(const Module &M, bool ShouldPreserveUseListOrder)
This class provides a symbol table of name/value pairs.
size_t size() const
size - Get the array size.
ArrayRef< const Metadata * > getMDStrings() const
Get the MDString metadata for this block.
Common register allocation spilling lr str ldr sxth r3 ldr mla r4 can lr mov lr str ldr sxth r3 mla r4 and then merge mul and lr str ldr sxth r3 mla r4 It also increase the likelihood the store may become dead bb27 Successors according to LLVM BB
void getFunctionConstantRange(unsigned &Start, unsigned &End) const
getFunctionConstantRange - Return the range of values that corresponds to function-local constants.
LLVM Value Representation.
std::vector< Type * > TypeList
bool isEmpty() const
Return true if there are no attributes.
const ComdatSetType & getComdats() const