mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-21 18:29:46 +00:00
change NamedMDNode to use a pimpl for its operand list instead
of making it a declared part of the value. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92209 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
a327524b69
commit
5710969728
@ -158,7 +158,7 @@ class NamedMDNode : public MetadataBase, public ilist_node<NamedMDNode> {
|
||||
NamedMDNode(const NamedMDNode &); // DO NOT IMPLEMENT
|
||||
|
||||
Module *Parent;
|
||||
SmallVector<TrackingVH<MetadataBase>, 4> Node;
|
||||
void *Operands; // SmallVector<TrackingVH<MetadataBase>, 4>
|
||||
|
||||
void setParent(Module *M) { Parent = M; }
|
||||
protected:
|
||||
@ -188,20 +188,13 @@ public:
|
||||
inline const Module *getParent() const { return Parent; }
|
||||
|
||||
/// getElement - Return specified element.
|
||||
MetadataBase *getElement(unsigned i) const {
|
||||
assert(i < getNumElements() && "Invalid element number!");
|
||||
return Node[i];
|
||||
}
|
||||
MetadataBase *getElement(unsigned i) const;
|
||||
|
||||
/// getNumElements - Return number of NamedMDNode elements.
|
||||
unsigned getNumElements() const {
|
||||
return (unsigned)Node.size();
|
||||
}
|
||||
unsigned getNumElements() const;
|
||||
|
||||
/// addElement - Add metadata element.
|
||||
void addElement(MetadataBase *M) {
|
||||
Node.push_back(TrackingVH<MetadataBase>(M));
|
||||
}
|
||||
void addElement(MetadataBase *M);
|
||||
|
||||
/// Methods for support type inquiry through isa, cast, and dyn_cast:
|
||||
static inline bool classof(const NamedMDNode *) { return true; }
|
||||
|
@ -226,12 +226,19 @@ bool MDNode::getLocalFunction(Function *LocalFunction,
|
||||
//===----------------------------------------------------------------------===//
|
||||
// NamedMDNode implementation.
|
||||
//
|
||||
static SmallVector<TrackingVH<MetadataBase>, 4> &getNMDOps(void *Operands) {
|
||||
return *(SmallVector<TrackingVH<MetadataBase>, 4>*)Operands;
|
||||
}
|
||||
|
||||
NamedMDNode::NamedMDNode(LLVMContext &C, const Twine &N,
|
||||
MetadataBase *const *MDs,
|
||||
unsigned NumMDs, Module *ParentModule)
|
||||
: MetadataBase(Type::getMetadataTy(C), Value::NamedMDNodeVal), Parent(0) {
|
||||
setName(N);
|
||||
|
||||
Operands = new SmallVector<TrackingVH<MetadataBase>, 4>();
|
||||
|
||||
SmallVector<TrackingVH<MetadataBase>, 4> &Node = getNMDOps(Operands);
|
||||
for (unsigned i = 0; i != NumMDs; ++i)
|
||||
Node.push_back(TrackingVH<MetadataBase>(MDs[i]));
|
||||
|
||||
@ -242,12 +249,35 @@ NamedMDNode::NamedMDNode(LLVMContext &C, const Twine &N,
|
||||
NamedMDNode *NamedMDNode::Create(const NamedMDNode *NMD, Module *M) {
|
||||
assert(NMD && "Invalid source NamedMDNode!");
|
||||
SmallVector<MetadataBase *, 4> Elems;
|
||||
Elems.reserve(NMD->getNumElements());
|
||||
|
||||
for (unsigned i = 0, e = NMD->getNumElements(); i != e; ++i)
|
||||
Elems.push_back(NMD->getElement(i));
|
||||
return new NamedMDNode(NMD->getContext(), NMD->getName().data(),
|
||||
Elems.data(), Elems.size(), M);
|
||||
}
|
||||
|
||||
NamedMDNode::~NamedMDNode() {
|
||||
dropAllReferences();
|
||||
delete &getNMDOps(Operands);
|
||||
}
|
||||
|
||||
/// getNumElements - Return number of NamedMDNode elements.
|
||||
unsigned NamedMDNode::getNumElements() const {
|
||||
return (unsigned)getNMDOps(Operands).size();
|
||||
}
|
||||
|
||||
/// getElement - Return specified element.
|
||||
MetadataBase *NamedMDNode::getElement(unsigned i) const {
|
||||
assert(i < getNumElements() && "Invalid element number!");
|
||||
return getNMDOps(Operands)[i];
|
||||
}
|
||||
|
||||
/// addElement - Add metadata element.
|
||||
void NamedMDNode::addElement(MetadataBase *M) {
|
||||
getNMDOps(Operands).push_back(TrackingVH<MetadataBase>(M));
|
||||
}
|
||||
|
||||
/// eraseFromParent - Drop all references and remove the node from parent
|
||||
/// module.
|
||||
void NamedMDNode::eraseFromParent() {
|
||||
@ -256,12 +286,9 @@ void NamedMDNode::eraseFromParent() {
|
||||
|
||||
/// dropAllReferences - Remove all uses and clear node vector.
|
||||
void NamedMDNode::dropAllReferences() {
|
||||
Node.clear();
|
||||
getNMDOps(Operands).clear();
|
||||
}
|
||||
|
||||
NamedMDNode::~NamedMDNode() {
|
||||
dropAllReferences();
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// MetadataContextImpl implementation.
|
||||
|
Loading…
Reference in New Issue
Block a user