2009-07-28 21:49:47 +00:00
|
|
|
//===-- Metadata.cpp - Implement Metadata classes -------------------------===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file implements the Metadata classes.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "llvm/Metadata.h"
|
2009-07-29 00:33:07 +00:00
|
|
|
#include "llvm/Module.h"
|
2009-07-29 17:16:17 +00:00
|
|
|
#include "SymbolTableListTraitsImpl.h"
|
2009-07-28 21:49:47 +00:00
|
|
|
using namespace llvm;
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//MDNode implementation
|
|
|
|
//
|
|
|
|
MDNode::MDNode(Value*const* Vals, unsigned NumVals)
|
|
|
|
: MetadataBase(Type::MetadataTy, Value::MDNodeVal) {
|
|
|
|
for (unsigned i = 0; i != NumVals; ++i)
|
|
|
|
Node.push_back(WeakVH(Vals[i]));
|
|
|
|
}
|
|
|
|
|
|
|
|
void MDNode::Profile(FoldingSetNodeID &ID) const {
|
|
|
|
for (const_elem_iterator I = elem_begin(), E = elem_end(); I != E; ++I)
|
|
|
|
ID.AddPointer(*I);
|
|
|
|
}
|
2009-07-29 00:33:07 +00:00
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//NamedMDNode implementation
|
|
|
|
//
|
2009-07-29 21:58:56 +00:00
|
|
|
NamedMDNode::NamedMDNode(const Twine &N, MetadataBase*const* MDs,
|
|
|
|
unsigned NumMDs, Module *ParentModule)
|
2009-07-30 15:35:55 +00:00
|
|
|
: MetadataBase(Type::MetadataTy, Value::NamedMDNodeVal), Parent(0) {
|
2009-07-29 17:16:17 +00:00
|
|
|
setName(N);
|
2009-07-29 00:33:07 +00:00
|
|
|
for (unsigned i = 0; i != NumMDs; ++i)
|
|
|
|
Node.push_back(WeakMetadataVH(MDs[i]));
|
2009-07-29 21:58:56 +00:00
|
|
|
if (ParentModule)
|
|
|
|
ParentModule->getNamedMDList().push_back(this);
|
2009-07-29 00:33:07 +00:00
|
|
|
}
|