forked from OSchip/llvm-project
parent
26e69ac5cb
commit
2d85eef974
|
@ -18,7 +18,7 @@
|
|||
namespace llvm {
|
||||
|
||||
class LLVMContextImpl;
|
||||
class Metadata;
|
||||
class MetadataContext;
|
||||
/// This is an important class for using LLVM in a threaded context. It
|
||||
/// (opaquely) owns and manages the core "global" data of LLVM's core
|
||||
/// infrastructure, including the type and constant uniquing tables.
|
||||
|
@ -30,7 +30,7 @@ class LLVMContext {
|
|||
void operator=(LLVMContext&);
|
||||
public:
|
||||
LLVMContextImpl* pImpl;
|
||||
Metadata &getMetadata();
|
||||
MetadataContext &getMetadata();
|
||||
bool RemoveDeadMetadata();
|
||||
LLVMContext();
|
||||
~LLVMContext();
|
||||
|
|
|
@ -304,10 +304,10 @@ public:
|
|||
};
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
/// Metadata -
|
||||
/// Metadata manages metadata used in a context.
|
||||
/// MetadataContext -
|
||||
/// MetadataContext manages metadata used in a context.
|
||||
|
||||
class Metadata {
|
||||
class MetadataContext {
|
||||
public:
|
||||
typedef std::pair<unsigned, WeakVH> MDPairTy;
|
||||
typedef SmallVector<MDPairTy, 2> MDMapTy;
|
||||
|
|
|
@ -42,7 +42,7 @@ class raw_ostream;
|
|||
class AssemblyAnnotationWriter;
|
||||
class ValueHandleBase;
|
||||
class LLVMContext;
|
||||
class Metadata;
|
||||
class MetadataContext;
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Value Class
|
||||
|
@ -83,7 +83,7 @@ private:
|
|||
friend class ValueSymbolTable; // Allow ValueSymbolTable to directly mod Name.
|
||||
friend class SymbolTable; // Allow SymbolTable to directly poke Name.
|
||||
friend class ValueHandleBase;
|
||||
friend class Metadata;
|
||||
friend class MetadataContext;
|
||||
friend class AbstractTypeUser;
|
||||
ValueName *Name;
|
||||
|
||||
|
|
|
@ -1038,7 +1038,7 @@ bool LLParser::ParseOptionalDbgInfo() {
|
|||
MetadataBase *Node;
|
||||
if (ParseMDNode(Node)) return true;
|
||||
|
||||
Metadata &TheMetadata = M->getContext().getMetadata();
|
||||
MetadataContext &TheMetadata = M->getContext().getMetadata();
|
||||
unsigned MDDbgKind = TheMetadata.getMDKind("dbg");
|
||||
if (!MDDbgKind)
|
||||
MDDbgKind = TheMetadata.RegisterMDKind("dbg");
|
||||
|
@ -2656,7 +2656,7 @@ bool LLParser::ParseBasicBlock(PerFunctionState &PFS) {
|
|||
ParseOptionalDbgInfo();
|
||||
|
||||
// Set metadata attached with this instruction.
|
||||
Metadata &TheMetadata = M->getContext().getMetadata();
|
||||
MetadataContext &TheMetadata = M->getContext().getMetadata();
|
||||
for (SmallVector<std::pair<unsigned, MDNode *>, 2>::iterator
|
||||
MDI = MDsOnInst.begin(), MDE = MDsOnInst.end(); MDI != MDE; ++MDI)
|
||||
TheMetadata.setMD(MDI->first, MDI->second, Inst);
|
||||
|
|
|
@ -839,7 +839,7 @@ bool BitcodeReader::ParseMetadata() {
|
|||
unsigned Kind = Record[0];
|
||||
for (unsigned i = 1; i != RecordLength; ++i)
|
||||
Name[i-1] = Record[i];
|
||||
Metadata &TheMetadata = Context.getMetadata();
|
||||
MetadataContext &TheMetadata = Context.getMetadata();
|
||||
assert(TheMetadata.MDHandlerNames.find(Name.str())
|
||||
== TheMetadata.MDHandlerNames.end() &&
|
||||
"Already registered MDKind!");
|
||||
|
@ -1556,7 +1556,7 @@ bool BitcodeReader::ParseMetadataAttachment() {
|
|||
if (Stream.EnterSubBlock(bitc::METADATA_ATTACHMENT_ID))
|
||||
return Error("Malformed block record");
|
||||
|
||||
Metadata &TheMetadata = Context.getMetadata();
|
||||
MetadataContext &TheMetadata = Context.getMetadata();
|
||||
SmallVector<uint64_t, 64> Record;
|
||||
while(1) {
|
||||
unsigned Code = Stream.ReadCode();
|
||||
|
|
|
@ -562,15 +562,15 @@ static void WriteMetadataAttachment(const Function &F,
|
|||
|
||||
// Write metadata attachments
|
||||
// METADATA_ATTACHMENT - [m x [value, [n x [id, mdnode]]]
|
||||
Metadata &TheMetadata = F.getContext().getMetadata();
|
||||
MetadataContext &TheMetadata = F.getContext().getMetadata();
|
||||
for (Function::const_iterator BB = F.begin(), E = F.end(); BB != E; ++BB)
|
||||
for (BasicBlock::const_iterator I = BB->begin(), E = BB->end();
|
||||
I != E; ++I) {
|
||||
const Metadata::MDMapTy *P = TheMetadata.getMDs(I);
|
||||
const MetadataContext::MDMapTy *P = TheMetadata.getMDs(I);
|
||||
if (!P) continue;
|
||||
bool RecordedInstruction = false;
|
||||
for (Metadata::MDMapTy::const_iterator PI = P->begin(), PE = P->end();
|
||||
PI != PE; ++PI) {
|
||||
for (MetadataContext::MDMapTy::const_iterator PI = P->begin(),
|
||||
PE = P->end(); PI != PE; ++PI) {
|
||||
if (MDNode *ND = dyn_cast_or_null<MDNode>(PI->second)) {
|
||||
if (RecordedInstruction == false) {
|
||||
Record.push_back(VE.getInstructionID(I));
|
||||
|
@ -601,7 +601,7 @@ static void WriteModuleMetadataStore(const Module *M,
|
|||
|
||||
// Write metadata kinds
|
||||
// METADATA_KIND - [n x [id, name]]
|
||||
Metadata &TheMetadata = M->getContext().getMetadata();
|
||||
MetadataContext &TheMetadata = M->getContext().getMetadata();
|
||||
const StringMap<unsigned> *Kinds = TheMetadata.getHandlerNames();
|
||||
for (StringMap<unsigned>::const_iterator
|
||||
I = Kinds->begin(), E = Kinds->end(); I != E; ++I) {
|
||||
|
|
|
@ -86,7 +86,7 @@ ValueEnumerator::ValueEnumerator(const Module *M) {
|
|||
I != E; ++I)
|
||||
EnumerateType(I->getType());
|
||||
|
||||
Metadata &TheMetadata = F->getContext().getMetadata();
|
||||
MetadataContext &TheMetadata = F->getContext().getMetadata();
|
||||
for (Function::const_iterator BB = F->begin(), E = F->end(); BB != E; ++BB)
|
||||
for (BasicBlock::const_iterator I = BB->begin(), E = BB->end(); I!=E;++I){
|
||||
for (User::const_op_iterator OI = I->op_begin(), E = I->op_end();
|
||||
|
@ -99,9 +99,9 @@ ValueEnumerator::ValueEnumerator(const Module *M) {
|
|||
EnumerateAttributes(II->getAttributes());
|
||||
|
||||
// Enumerate metadata attached with this instruction.
|
||||
const Metadata::MDMapTy *MDs = TheMetadata.getMDs(I);
|
||||
const MetadataContext::MDMapTy *MDs = TheMetadata.getMDs(I);
|
||||
if (MDs)
|
||||
for (Metadata::MDMapTy::const_iterator MI = MDs->begin(),
|
||||
for (MetadataContext::MDMapTy::const_iterator MI = MDs->begin(),
|
||||
ME = MDs->end(); MI != ME; ++MI)
|
||||
if (MDNode *MDN = dyn_cast_or_null<MDNode>(MI->second))
|
||||
EnumerateMetadata(MDN);
|
||||
|
|
|
@ -372,7 +372,7 @@ void SelectionDAGISel::SelectBasicBlock(BasicBlock *LLVMBB,
|
|||
BasicBlock::iterator Begin,
|
||||
BasicBlock::iterator End) {
|
||||
SDL->setCurrentBasicBlock(BB);
|
||||
Metadata &TheMetadata = LLVMBB->getParent()->getContext().getMetadata();
|
||||
MetadataContext &TheMetadata = LLVMBB->getParent()->getContext().getMetadata();
|
||||
unsigned MDDbgKind = TheMetadata.getMDKind("dbg");
|
||||
|
||||
// Lower all of the non-terminator instructions. If a call is emitted
|
||||
|
@ -655,7 +655,7 @@ void SelectionDAGISel::SelectAllBasicBlocks(Function &Fn,
|
|||
#endif
|
||||
);
|
||||
|
||||
Metadata &TheMetadata = Fn.getContext().getMetadata();
|
||||
MetadataContext &TheMetadata = Fn.getContext().getMetadata();
|
||||
unsigned MDDbgKind = TheMetadata.getMDKind("dbg");
|
||||
|
||||
// Iterate over all basic blocks in the function.
|
||||
|
|
|
@ -678,7 +678,7 @@ void SlotTracker::processFunction() {
|
|||
|
||||
ST_DEBUG("Inserting Instructions:\n");
|
||||
|
||||
Metadata &TheMetadata = TheFunction->getContext().getMetadata();
|
||||
MetadataContext &TheMetadata = TheFunction->getContext().getMetadata();
|
||||
|
||||
// Add all of the basic blocks and instructions with no names.
|
||||
for (Function::const_iterator BB = TheFunction->begin(),
|
||||
|
@ -695,9 +695,9 @@ void SlotTracker::processFunction() {
|
|||
CreateMetadataSlot(N);
|
||||
|
||||
// Process metadata attached with this instruction.
|
||||
const Metadata::MDMapTy *MDs = TheMetadata.getMDs(I);
|
||||
const MetadataContext::MDMapTy *MDs = TheMetadata.getMDs(I);
|
||||
if (MDs)
|
||||
for (Metadata::MDMapTy::const_iterator MI = MDs->begin(),
|
||||
for (MetadataContext::MDMapTy::const_iterator MI = MDs->begin(),
|
||||
ME = MDs->end(); MI != ME; ++MI)
|
||||
if (MDNode *MDN = dyn_cast_or_null<MDNode>(MI->second))
|
||||
CreateMetadataSlot(MDN);
|
||||
|
@ -1275,7 +1275,7 @@ public:
|
|||
: Out(o), Machine(Mac), TheModule(M), AnnotationWriter(AAW) {
|
||||
AddModuleTypesToPrinter(TypePrinter, NumberedTypes, M);
|
||||
// FIXME: Provide MDPrinter
|
||||
Metadata &TheMetadata = M->getContext().getMetadata();
|
||||
MetadataContext &TheMetadata = M->getContext().getMetadata();
|
||||
const StringMap<unsigned> *Names = TheMetadata.getHandlerNames();
|
||||
for (StringMapConstIterator<unsigned> I = Names->begin(),
|
||||
E = Names->end(); I != E; ++I) {
|
||||
|
@ -2001,10 +2001,10 @@ void AssemblyWriter::printInstruction(const Instruction &I) {
|
|||
}
|
||||
|
||||
// Print Metadata info
|
||||
Metadata &TheMetadata = I.getContext().getMetadata();
|
||||
const Metadata::MDMapTy *MDMap = TheMetadata.getMDs(&I);
|
||||
MetadataContext &TheMetadata = I.getContext().getMetadata();
|
||||
const MetadataContext::MDMapTy *MDMap = TheMetadata.getMDs(&I);
|
||||
if (MDMap)
|
||||
for (Metadata::MDMapTy::const_iterator MI = MDMap->begin(),
|
||||
for (MetadataContext::MDMapTy::const_iterator MI = MDMap->begin(),
|
||||
ME = MDMap->end(); MI != ME; ++MI)
|
||||
if (const MDNode *MD = dyn_cast_or_null<MDNode>(MI->second))
|
||||
Out << ", " << MDNames[MI->first]
|
||||
|
|
|
@ -71,6 +71,6 @@ bool LLVMContext::RemoveDeadMetadata() {
|
|||
return Changed;
|
||||
}
|
||||
|
||||
Metadata &LLVMContext::getMetadata() {
|
||||
MetadataContext &LLVMContext::getMetadata() {
|
||||
return pImpl->TheMetadata;
|
||||
}
|
||||
|
|
|
@ -179,7 +179,7 @@ public:
|
|||
typedef DenseMap<Value*, ValueHandleBase*> ValueHandlesTy;
|
||||
ValueHandlesTy ValueHandles;
|
||||
|
||||
Metadata TheMetadata;
|
||||
MetadataContext TheMetadata;
|
||||
LLVMContextImpl(LLVMContext &C) : TheTrueVal(0), TheFalseVal(0),
|
||||
VoidTy(C, Type::VoidTyID),
|
||||
LabelTy(C, Type::LabelTyID),
|
||||
|
|
|
@ -259,7 +259,7 @@ NamedMDNode::~NamedMDNode() {
|
|||
|
||||
/// RegisterMDKind - Register a new metadata kind and return its ID.
|
||||
/// A metadata kind can be registered only once.
|
||||
unsigned Metadata::RegisterMDKind(const char *Name) {
|
||||
unsigned MetadataContext::RegisterMDKind(const char *Name) {
|
||||
unsigned Count = MDHandlerNames.size();
|
||||
StringMap<unsigned>::iterator I = MDHandlerNames.find(Name);
|
||||
assert(I == MDHandlerNames.end() && "Already registered MDKind!");
|
||||
|
@ -269,7 +269,7 @@ unsigned Metadata::RegisterMDKind(const char *Name) {
|
|||
|
||||
/// getMDKind - Return metadata kind. If the requested metadata kind
|
||||
/// is not registered then return 0.
|
||||
unsigned Metadata::getMDKind(const char *Name) {
|
||||
unsigned MetadataContext::getMDKind(const char *Name) {
|
||||
StringMap<unsigned>::iterator I = MDHandlerNames.find(Name);
|
||||
if (I == MDHandlerNames.end())
|
||||
return 0;
|
||||
|
@ -278,7 +278,7 @@ unsigned Metadata::getMDKind(const char *Name) {
|
|||
}
|
||||
|
||||
/// setMD - Attach the metadata of given kind with an Instruction.
|
||||
void Metadata::setMD(unsigned MDKind, MDNode *Node, Instruction *Inst) {
|
||||
void MetadataContext::setMD(unsigned MDKind, MDNode *Node, Instruction *Inst) {
|
||||
MDStoreTy::iterator I = MetadataStore.find(Inst);
|
||||
Inst->HasMetadata = true;
|
||||
if (I == MetadataStore.end()) {
|
||||
|
@ -295,7 +295,7 @@ void Metadata::setMD(unsigned MDKind, MDNode *Node, Instruction *Inst) {
|
|||
|
||||
/// getMD - Get the metadata of given kind attached with an Instruction.
|
||||
/// If the metadata is not found then return 0.
|
||||
MDNode *Metadata::getMD(unsigned MDKind, const Instruction *Inst) {
|
||||
MDNode *MetadataContext::getMD(unsigned MDKind, const Instruction *Inst) {
|
||||
MDNode *Node = NULL;
|
||||
MDStoreTy::iterator I = MetadataStore.find(Inst);
|
||||
if (I == MetadataStore.end())
|
||||
|
@ -309,7 +309,7 @@ MDNode *Metadata::getMD(unsigned MDKind, const Instruction *Inst) {
|
|||
}
|
||||
|
||||
/// getMDs - Get the metadata attached with an Instruction.
|
||||
const Metadata::MDMapTy *Metadata::getMDs(const Instruction *Inst) {
|
||||
const MetadataContext::MDMapTy *MetadataContext::getMDs(const Instruction *Inst) {
|
||||
MDStoreTy::iterator I = MetadataStore.find(Inst);
|
||||
if (I == MetadataStore.end())
|
||||
return NULL;
|
||||
|
@ -319,13 +319,13 @@ const Metadata::MDMapTy *Metadata::getMDs(const Instruction *Inst) {
|
|||
|
||||
/// getHandlerNames - Get handler names. This is used by bitcode
|
||||
/// writer.
|
||||
const StringMap<unsigned> *Metadata::getHandlerNames() {
|
||||
const StringMap<unsigned> *MetadataContext::getHandlerNames() {
|
||||
return &MDHandlerNames;
|
||||
}
|
||||
|
||||
/// ValueIsDeleted - This handler is used to update metadata store
|
||||
/// when a value is deleted.
|
||||
void Metadata::ValueIsDeleted(const Instruction *Inst) {
|
||||
void MetadataContext::ValueIsDeleted(const Instruction *Inst) {
|
||||
// Find Metadata handles for this instruction.
|
||||
MDStoreTy::iterator I = MetadataStore.find(Inst);
|
||||
if (I == MetadataStore.end())
|
||||
|
@ -341,7 +341,7 @@ void Metadata::ValueIsDeleted(const Instruction *Inst) {
|
|||
|
||||
/// ValueIsCloned - This handler is used to update metadata store
|
||||
/// when In1 is cloned to create In2.
|
||||
void Metadata::ValueIsCloned(const Instruction *In1, Instruction *In2) {
|
||||
void MetadataContext::ValueIsCloned(const Instruction *In1, Instruction *In2) {
|
||||
// Find Metadata handles for In1.
|
||||
MDStoreTy::iterator I = MetadataStore.find(In1);
|
||||
if (I == MetadataStore.end())
|
||||
|
|
Loading…
Reference in New Issue