73f89caa388ef20021bbcfd264a1362d2301b925
[oota-llvm.git] / lib / VMCore / Metadata.cpp
1 //===-- Metadata.cpp - Implement Metadata classes -------------------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file implements the Metadata classes.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #include "llvm/Metadata.h"
15 #include "llvm/Module.h"
16 using namespace llvm;
17
18 //===----------------------------------------------------------------------===//
19 //MDNode implementation
20 //
21 MDNode::MDNode(Value*const* Vals, unsigned NumVals)
22   : MetadataBase(Type::MetadataTy, Value::MDNodeVal) {
23   for (unsigned i = 0; i != NumVals; ++i)
24     Node.push_back(WeakVH(Vals[i]));
25 }
26
27 void MDNode::Profile(FoldingSetNodeID &ID) const {
28   for (const_elem_iterator I = elem_begin(), E = elem_end(); I != E; ++I)
29     ID.AddPointer(*I);
30 }
31
32 //===----------------------------------------------------------------------===//
33 //NamedMDNode implementation
34 //
35 NamedMDNode::NamedMDNode(const char *N, unsigned NameLength,
36                          MetadataBase*const* MDs, unsigned NumMDs,
37                          Module *M)
38   : MetadataBase(Type::MetadataTy, Value::NamedMDNodeVal),
39     Parent(M), Name(N, NameLength) {
40   for (unsigned i = 0; i != NumMDs; ++i)
41     Node.push_back(WeakMetadataVH(MDs[i]));
42
43   // FIXME : Add into the parent module.
44 }