mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-12 17:32:19 +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
|
NamedMDNode(const NamedMDNode &); // DO NOT IMPLEMENT
|
||||||
|
|
||||||
Module *Parent;
|
Module *Parent;
|
||||||
SmallVector<TrackingVH<MetadataBase>, 4> Node;
|
void *Operands; // SmallVector<TrackingVH<MetadataBase>, 4>
|
||||||
|
|
||||||
void setParent(Module *M) { Parent = M; }
|
void setParent(Module *M) { Parent = M; }
|
||||||
protected:
|
protected:
|
||||||
@ -188,21 +188,14 @@ public:
|
|||||||
inline const Module *getParent() const { return Parent; }
|
inline const Module *getParent() const { return Parent; }
|
||||||
|
|
||||||
/// getElement - Return specified element.
|
/// getElement - Return specified element.
|
||||||
MetadataBase *getElement(unsigned i) const {
|
MetadataBase *getElement(unsigned i) const;
|
||||||
assert(i < getNumElements() && "Invalid element number!");
|
|
||||||
return Node[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
/// getNumElements - Return number of NamedMDNode elements.
|
/// getNumElements - Return number of NamedMDNode elements.
|
||||||
unsigned getNumElements() const {
|
unsigned getNumElements() const;
|
||||||
return (unsigned)Node.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// addElement - Add metadata element.
|
/// addElement - Add metadata element.
|
||||||
void addElement(MetadataBase *M) {
|
void addElement(MetadataBase *M);
|
||||||
Node.push_back(TrackingVH<MetadataBase>(M));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Methods for support type inquiry through isa, cast, and dyn_cast:
|
/// Methods for support type inquiry through isa, cast, and dyn_cast:
|
||||||
static inline bool classof(const NamedMDNode *) { return true; }
|
static inline bool classof(const NamedMDNode *) { return true; }
|
||||||
static bool classof(const Value *V) {
|
static bool classof(const Value *V) {
|
||||||
|
@ -226,12 +226,19 @@ bool MDNode::getLocalFunction(Function *LocalFunction,
|
|||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
// NamedMDNode implementation.
|
// NamedMDNode implementation.
|
||||||
//
|
//
|
||||||
|
static SmallVector<TrackingVH<MetadataBase>, 4> &getNMDOps(void *Operands) {
|
||||||
|
return *(SmallVector<TrackingVH<MetadataBase>, 4>*)Operands;
|
||||||
|
}
|
||||||
|
|
||||||
NamedMDNode::NamedMDNode(LLVMContext &C, const Twine &N,
|
NamedMDNode::NamedMDNode(LLVMContext &C, const Twine &N,
|
||||||
MetadataBase *const *MDs,
|
MetadataBase *const *MDs,
|
||||||
unsigned NumMDs, Module *ParentModule)
|
unsigned NumMDs, Module *ParentModule)
|
||||||
: MetadataBase(Type::getMetadataTy(C), Value::NamedMDNodeVal), Parent(0) {
|
: MetadataBase(Type::getMetadataTy(C), Value::NamedMDNodeVal), Parent(0) {
|
||||||
setName(N);
|
setName(N);
|
||||||
|
|
||||||
|
Operands = new SmallVector<TrackingVH<MetadataBase>, 4>();
|
||||||
|
|
||||||
|
SmallVector<TrackingVH<MetadataBase>, 4> &Node = getNMDOps(Operands);
|
||||||
for (unsigned i = 0; i != NumMDs; ++i)
|
for (unsigned i = 0; i != NumMDs; ++i)
|
||||||
Node.push_back(TrackingVH<MetadataBase>(MDs[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) {
|
NamedMDNode *NamedMDNode::Create(const NamedMDNode *NMD, Module *M) {
|
||||||
assert(NMD && "Invalid source NamedMDNode!");
|
assert(NMD && "Invalid source NamedMDNode!");
|
||||||
SmallVector<MetadataBase *, 4> Elems;
|
SmallVector<MetadataBase *, 4> Elems;
|
||||||
|
Elems.reserve(NMD->getNumElements());
|
||||||
|
|
||||||
for (unsigned i = 0, e = NMD->getNumElements(); i != e; ++i)
|
for (unsigned i = 0, e = NMD->getNumElements(); i != e; ++i)
|
||||||
Elems.push_back(NMD->getElement(i));
|
Elems.push_back(NMD->getElement(i));
|
||||||
return new NamedMDNode(NMD->getContext(), NMD->getName().data(),
|
return new NamedMDNode(NMD->getContext(), NMD->getName().data(),
|
||||||
Elems.data(), Elems.size(), M);
|
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
|
/// eraseFromParent - Drop all references and remove the node from parent
|
||||||
/// module.
|
/// module.
|
||||||
void NamedMDNode::eraseFromParent() {
|
void NamedMDNode::eraseFromParent() {
|
||||||
@ -256,12 +286,9 @@ void NamedMDNode::eraseFromParent() {
|
|||||||
|
|
||||||
/// dropAllReferences - Remove all uses and clear node vector.
|
/// dropAllReferences - Remove all uses and clear node vector.
|
||||||
void NamedMDNode::dropAllReferences() {
|
void NamedMDNode::dropAllReferences() {
|
||||||
Node.clear();
|
getNMDOps(Operands).clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
NamedMDNode::~NamedMDNode() {
|
|
||||||
dropAllReferences();
|
|
||||||
}
|
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
// MetadataContextImpl implementation.
|
// MetadataContextImpl implementation.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user