rename "elements" of metadata to "operands". "Elements" are

things that occur in types.  "operands" are things that occur
in values.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92322 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2009-12-31 01:22:29 +00:00
parent b76359e36e
commit 5d0cacdbb6
13 changed files with 136 additions and 136 deletions

View File

@ -369,19 +369,19 @@ namespace llvm {
unsigned isDefinition() const { return getUnsignedField(10); } unsigned isDefinition() const { return getUnsignedField(10); }
unsigned getVirtuality() const { unsigned getVirtuality() const {
if (DbgNode->getNumElements() < 14) if (DbgNode->getNumOperands() < 14)
return 0; return 0;
return getUnsignedField(11); return getUnsignedField(11);
} }
unsigned getVirtualIndex() const { unsigned getVirtualIndex() const {
if (DbgNode->getNumElements() < 14) if (DbgNode->getNumOperands() < 14)
return 0; return 0;
return getUnsignedField(12); return getUnsignedField(12);
} }
DICompositeType getContainingType() const { DICompositeType getContainingType() const {
assert (DbgNode->getNumElements() >= 14 && "Invalid type!"); assert (DbgNode->getNumOperands() >= 14 && "Invalid type!");
return getFieldAs<DICompositeType>(13); return getFieldAs<DICompositeType>(13);
} }
@ -439,7 +439,7 @@ namespace llvm {
return getNumAddrElements() > 0; return getNumAddrElements() > 0;
} }
unsigned getNumAddrElements() const { return DbgNode->getNumElements()-6; } unsigned getNumAddrElements() const { return DbgNode->getNumOperands()-6; }
uint64_t getAddrElement(unsigned Idx) const { uint64_t getAddrElement(unsigned Idx) const {
return getUInt64Field(Idx+6); return getUInt64Field(Idx+6);

View File

@ -98,8 +98,8 @@ namespace llvm {
return unsigned(cast<ConstantInt>(getOperand(2))->getZExtValue()); return unsigned(cast<ConstantInt>(getOperand(2))->getZExtValue());
} }
Value* getFileName() const; Value *getFileName() const;
Value* getDirectory() const; Value *getDirectory() const;
// 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 DbgStopPointInst *) { return true; } static inline bool classof(const DbgStopPointInst *) { return true; }
@ -175,8 +175,8 @@ namespace llvm {
/// DbgValueInst - This represents the llvm.dbg.value instruction. /// DbgValueInst - This represents the llvm.dbg.value instruction.
/// ///
struct DbgValueInst : public DbgInfoIntrinsic { struct DbgValueInst : public DbgInfoIntrinsic {
Value *getValue() const { Value *getValue() const {
return cast<MDNode>(getOperand(1))->getElement(0); return cast<MDNode>(getOperand(1))->getOperand(0);
} }
Value *getOffset() const { return getOperand(2); } Value *getOffset() const { return getOperand(2); }
MDNode *getVariable() const { return cast<MDNode>(getOperand(3)); } MDNode *getVariable() const { return cast<MDNode>(getOperand(3)); }

View File

@ -26,6 +26,9 @@ class Instruction;
class LLVMContext; class LLVMContext;
class Module; class Module;
template <typename T> class SmallVectorImpl; template <typename T> class SmallVectorImpl;
template<typename ValueSubClass, typename ItemParentClass>
class SymbolTableListTraits;
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// MetadataBase - A base class for MDNode, MDString and NamedMDNode. // MetadataBase - A base class for MDNode, MDString and NamedMDNode.
@ -81,16 +84,16 @@ public:
}; };
class MDNodeElement; class MDNodeOperand;
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
/// MDNode - a tuple of other values. /// MDNode - a tuple of other values.
class MDNode : public MetadataBase, public FoldingSetNode { class MDNode : public MetadataBase, public FoldingSetNode {
MDNode(const MDNode &); // DO NOT IMPLEMENT MDNode(const MDNode &); // DO NOT IMPLEMENT
void operator=(const MDNode &); // DO NOT IMPLEMENT void operator=(const MDNode &); // DO NOT IMPLEMENT
friend class MDNodeElement; friend class MDNodeOperand;
/// NumOperands - This many 'MDNodeElement' items are co-allocated onto the /// NumOperands - This many 'MDNodeOperand' items are co-allocated onto the
/// end of this MDNode. /// end of this MDNode.
unsigned NumOperands; unsigned NumOperands;
@ -110,8 +113,8 @@ class MDNode : public MetadataBase, public FoldingSetNode {
DestroyFlag = 1 << 2 DestroyFlag = 1 << 2
}; };
// Replace each instance of F from the element list of this node with T. // Replace each instance of F from the operand list of this node with T.
void replaceElement(MDNodeElement *Op, Value *NewVal); void replaceOperand(MDNodeOperand *Op, Value *NewVal);
~MDNode(); ~MDNode();
protected: protected:
@ -122,11 +125,11 @@ public:
static MDNode *get(LLVMContext &Context, Value *const *Vals, unsigned NumVals, static MDNode *get(LLVMContext &Context, Value *const *Vals, unsigned NumVals,
bool isFunctionLocal = false); bool isFunctionLocal = false);
/// getElement - Return specified element. /// getOperand - Return specified operand.
Value *getElement(unsigned i) const; Value *getOperand(unsigned i) const;
/// getNumElements - Return number of MDNode elements. /// getNumOperands - Return number of MDNode operands.
unsigned getNumElements() const { return NumOperands; } unsigned getNumOperands() const { return NumOperands; }
/// isFunctionLocal - Return whether MDNode is local to a function. /// isFunctionLocal - Return whether MDNode is local to a function.
/// Note: MDNodes are designated as function-local when created, and keep /// Note: MDNodes are designated as function-local when created, and keep
@ -165,10 +168,7 @@ private:
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
/// NamedMDNode - a tuple of other metadata. /// NamedMDNode - a tuple of other metadata.
/// NamedMDNode is always named. All NamedMDNode element has a type of metadata. /// NamedMDNode is always named. All NamedMDNode operand has a type of metadata.
template<typename ValueSubClass, typename ItemParentClass>
class SymbolTableListTraits;
class NamedMDNode : public MetadataBase, public ilist_node<NamedMDNode> { class NamedMDNode : public MetadataBase, public ilist_node<NamedMDNode> {
friend class SymbolTableListTraits<NamedMDNode, Module>; friend class SymbolTableListTraits<NamedMDNode, Module>;
friend class LLVMContextImpl; friend class LLVMContextImpl;
@ -205,14 +205,14 @@ public:
inline Module *getParent() { return Parent; } inline Module *getParent() { return Parent; }
inline const Module *getParent() const { return Parent; } inline const Module *getParent() const { return Parent; }
/// getElement - Return specified element. /// getOperand - Return specified operand.
MetadataBase *getElement(unsigned i) const; MetadataBase *getOperand(unsigned i) const;
/// getNumElements - Return number of NamedMDNode elements. /// getNumOperands - Return the number of NamedMDNode operands.
unsigned getNumElements() const; unsigned getNumOperands() const;
/// addElement - Add metadata element. /// addOperand - Add metadata operand.
void addElement(MetadataBase *M); void addOperand(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; }

View File

@ -83,8 +83,8 @@ DIDescriptor::getStringField(unsigned Elt) const {
if (DbgNode == 0) if (DbgNode == 0)
return StringRef(); return StringRef();
if (Elt < DbgNode->getNumElements()) if (Elt < DbgNode->getNumOperands())
if (MDString *MDS = dyn_cast_or_null<MDString>(DbgNode->getElement(Elt))) if (MDString *MDS = dyn_cast_or_null<MDString>(DbgNode->getOperand(Elt)))
return MDS->getString(); return MDS->getString();
return StringRef(); return StringRef();
@ -94,8 +94,8 @@ uint64_t DIDescriptor::getUInt64Field(unsigned Elt) const {
if (DbgNode == 0) if (DbgNode == 0)
return 0; return 0;
if (Elt < DbgNode->getNumElements()) if (Elt < DbgNode->getNumOperands())
if (ConstantInt *CI = dyn_cast<ConstantInt>(DbgNode->getElement(Elt))) if (ConstantInt *CI = dyn_cast<ConstantInt>(DbgNode->getOperand(Elt)))
return CI->getZExtValue(); return CI->getZExtValue();
return 0; return 0;
@ -105,8 +105,8 @@ DIDescriptor DIDescriptor::getDescriptorField(unsigned Elt) const {
if (DbgNode == 0) if (DbgNode == 0)
return DIDescriptor(); return DIDescriptor();
if (Elt < DbgNode->getNumElements() && DbgNode->getElement(Elt)) if (Elt < DbgNode->getNumOperands() && DbgNode->getOperand(Elt))
return DIDescriptor(dyn_cast<MDNode>(DbgNode->getElement(Elt))); return DIDescriptor(dyn_cast<MDNode>(DbgNode->getOperand(Elt)));
return DIDescriptor(); return DIDescriptor();
} }
@ -115,8 +115,8 @@ GlobalVariable *DIDescriptor::getGlobalVariableField(unsigned Elt) const {
if (DbgNode == 0) if (DbgNode == 0)
return 0; return 0;
if (Elt < DbgNode->getNumElements()) if (Elt < DbgNode->getNumOperands())
return dyn_cast_or_null<GlobalVariable>(DbgNode->getElement(Elt)); return dyn_cast_or_null<GlobalVariable>(DbgNode->getOperand(Elt));
return 0; return 0;
} }
@ -264,7 +264,7 @@ DIType::DIType(MDNode *N) : DIDescriptor(N) {
unsigned DIArray::getNumElements() const { unsigned DIArray::getNumElements() const {
assert(DbgNode && "Invalid DIArray"); assert(DbgNode && "Invalid DIArray");
return DbgNode->getNumElements(); return DbgNode->getNumOperands();
} }
/// replaceAllUsesWith - Replace all uses of debug info referenced by /// replaceAllUsesWith - Replace all uses of debug info referenced by
@ -886,18 +886,18 @@ DISubprogram DIFactory::CreateSubprogramDefinition(DISubprogram &SPDeclaration)
Value *Elts[] = { Value *Elts[] = {
GetTagConstant(dwarf::DW_TAG_subprogram), GetTagConstant(dwarf::DW_TAG_subprogram),
llvm::Constant::getNullValue(Type::getInt32Ty(VMContext)), llvm::Constant::getNullValue(Type::getInt32Ty(VMContext)),
DeclNode->getElement(2), // Context DeclNode->getOperand(2), // Context
DeclNode->getElement(3), // Name DeclNode->getOperand(3), // Name
DeclNode->getElement(4), // DisplayName DeclNode->getOperand(4), // DisplayName
DeclNode->getElement(5), // LinkageName DeclNode->getOperand(5), // LinkageName
DeclNode->getElement(6), // CompileUnit DeclNode->getOperand(6), // CompileUnit
DeclNode->getElement(7), // LineNo DeclNode->getOperand(7), // LineNo
DeclNode->getElement(8), // Type DeclNode->getOperand(8), // Type
DeclNode->getElement(9), // isLocalToUnit DeclNode->getOperand(9), // isLocalToUnit
ConstantInt::get(Type::getInt1Ty(VMContext), true), ConstantInt::get(Type::getInt1Ty(VMContext), true),
DeclNode->getElement(11), // Virtuality DeclNode->getOperand(11), // Virtuality
DeclNode->getElement(12), // VIndex DeclNode->getOperand(12), // VIndex
DeclNode->getElement(13) // Containting Type DeclNode->getOperand(13) // Containting Type
}; };
return DISubprogram(MDNode::get(VMContext, &Elts[0], 14)); return DISubprogram(MDNode::get(VMContext, &Elts[0], 14));
} }
@ -930,7 +930,7 @@ DIFactory::CreateGlobalVariable(DIDescriptor Context, StringRef Name,
// Create a named metadata so that we do not lose this mdnode. // Create a named metadata so that we do not lose this mdnode.
NamedMDNode *NMD = M.getOrInsertNamedMetadata("llvm.dbg.gv"); NamedMDNode *NMD = M.getOrInsertNamedMetadata("llvm.dbg.gv");
NMD->addElement(Node); NMD->addOperand(Node);
return DIGlobalVariable(Node); return DIGlobalVariable(Node);
} }
@ -1106,8 +1106,8 @@ void DebugInfoFinder::processModule(Module &M) {
if (!NMD) if (!NMD)
return; return;
for (unsigned i = 0, e = NMD->getNumElements(); i != e; ++i) { for (unsigned i = 0, e = NMD->getNumOperands(); i != e; ++i) {
DIGlobalVariable DIG(cast<MDNode>(NMD->getElement(i))); DIGlobalVariable DIG(cast<MDNode>(NMD->getOperand(i)));
if (addGlobalVariable(DIG)) { if (addGlobalVariable(DIG)) {
addCompileUnit(DIG.getCompileUnit()); addCompileUnit(DIG.getCompileUnit());
processType(DIG.getType()); processType(DIG.getType());
@ -1289,8 +1289,8 @@ Value *llvm::findDbgGlobalDeclare(GlobalVariable *V) {
if (!NMD) if (!NMD)
return 0; return 0;
for (unsigned i = 0, e = NMD->getNumElements(); i != e; ++i) { for (unsigned i = 0, e = NMD->getNumOperands(); i != e; ++i) {
DIGlobalVariable DIG(cast_or_null<MDNode>(NMD->getElement(i))); DIGlobalVariable DIG(cast_or_null<MDNode>(NMD->getOperand(i)));
if (DIG.isNull()) if (DIG.isNull())
continue; continue;
if (DIG.getGlobal() == V) if (DIG.getGlobal() == V)

View File

@ -475,10 +475,10 @@ static void WriteMDNode(const MDNode *N,
const ValueEnumerator &VE, const ValueEnumerator &VE,
BitstreamWriter &Stream, BitstreamWriter &Stream,
SmallVector<uint64_t, 64> &Record) { SmallVector<uint64_t, 64> &Record) {
for (unsigned i = 0, e = N->getNumElements(); i != e; ++i) { for (unsigned i = 0, e = N->getNumOperands(); i != e; ++i) {
if (N->getElement(i)) { if (N->getOperand(i)) {
Record.push_back(VE.getTypeID(N->getElement(i)->getType())); Record.push_back(VE.getTypeID(N->getOperand(i)->getType()));
Record.push_back(VE.getValueID(N->getElement(i))); Record.push_back(VE.getValueID(N->getOperand(i)));
} else { } else {
Record.push_back(VE.getTypeID(Type::getVoidTy(N->getContext()))); Record.push_back(VE.getTypeID(Type::getVoidTy(N->getContext())));
Record.push_back(0); Record.push_back(0);
@ -535,10 +535,10 @@ static void WriteModuleMetadata(const ValueEnumerator &VE,
Stream.EmitRecord(bitc::METADATA_NAME, Record, 0/*TODO*/); Stream.EmitRecord(bitc::METADATA_NAME, Record, 0/*TODO*/);
Record.clear(); Record.clear();
// Write named metadata elements. // Write named metadata operands.
for (unsigned i = 0, e = NMD->getNumElements(); i != e; ++i) { for (unsigned i = 0, e = NMD->getNumOperands(); i != e; ++i) {
if (NMD->getElement(i)) if (NMD->getOperand(i))
Record.push_back(VE.getValueID(NMD->getElement(i))); Record.push_back(VE.getValueID(NMD->getOperand(i)));
else else
Record.push_back(0); Record.push_back(0);
} }

View File

@ -212,8 +212,8 @@ void ValueEnumerator::EnumerateMetadata(const MetadataBase *MD) {
MDValues.push_back(std::make_pair(MD, 1U)); MDValues.push_back(std::make_pair(MD, 1U));
MDValueMap[MD] = MDValues.size(); MDValueMap[MD] = MDValues.size();
MDValueID = MDValues.size(); MDValueID = MDValues.size();
for (unsigned i = 0, e = N->getNumElements(); i != e; ++i) { for (unsigned i = 0, e = N->getNumOperands(); i != e; ++i) {
if (Value *V = N->getElement(i)) if (Value *V = N->getOperand(i))
EnumerateValue(V); EnumerateValue(V);
else else
EnumerateType(Type::getVoidTy(MD->getContext())); EnumerateType(Type::getVoidTy(MD->getContext()));
@ -222,8 +222,8 @@ void ValueEnumerator::EnumerateMetadata(const MetadataBase *MD) {
} }
if (const NamedMDNode *N = dyn_cast<NamedMDNode>(MD)) { if (const NamedMDNode *N = dyn_cast<NamedMDNode>(MD)) {
for (unsigned i = 0, e = N->getNumElements(); i != e; ++i) for (unsigned i = 0, e = N->getNumOperands(); i != e; ++i)
EnumerateValue(N->getElement(i)); EnumerateValue(N->getOperand(i));
MDValues.push_back(std::make_pair(MD, 1U)); MDValues.push_back(std::make_pair(MD, 1U));
MDValueMap[MD] = Values.size(); MDValueMap[MD] = Values.size();
return; return;
@ -327,8 +327,8 @@ void ValueEnumerator::EnumerateOperandType(const Value *V) {
} }
if (const MDNode *N = dyn_cast<MDNode>(V)) { if (const MDNode *N = dyn_cast<MDNode>(V)) {
for (unsigned i = 0, e = N->getNumElements(); i != e; ++i) for (unsigned i = 0, e = N->getNumOperands(); i != e; ++i)
if (Value *Elem = N->getElement(i)) if (Value *Elem = N->getOperand(i))
EnumerateOperandType(Elem); EnumerateOperandType(Elem);
} }
} else if (isa<MDString>(V) || isa<MDNode>(V)) } else if (isa<MDString>(V) || isa<MDNode>(V))

View File

@ -538,8 +538,8 @@ static void LinkNamedMDNodes(Module *Dest, Module *Src) {
NamedMDNode::Create(SrcNMD, Dest); NamedMDNode::Create(SrcNMD, Dest);
else { else {
// Add Src elements into Dest node. // Add Src elements into Dest node.
for (unsigned i = 0, e = SrcNMD->getNumElements(); i != e; ++i) for (unsigned i = 0, e = SrcNMD->getNumOperands(); i != e; ++i)
DestNMD->addElement(SrcNMD->getElement(i)); DestNMD->addOperand(SrcNMD->getOperand(i));
} }
} }
} }

View File

@ -360,9 +360,9 @@ static MDNode *UpdateInlinedAtInfo(MDNode *InsnMD, MDNode *TheCallMD) {
NewLoc = UpdateInlinedAtInfo(OrigLocation.getNode(), TheCallMD); NewLoc = UpdateInlinedAtInfo(OrigLocation.getNode(), TheCallMD);
Value *MDVs[] = { Value *MDVs[] = {
InsnMD->getElement(0), // Line InsnMD->getOperand(0), // Line
InsnMD->getElement(1), // Col InsnMD->getOperand(1), // Col
InsnMD->getElement(2), // Scope InsnMD->getOperand(2), // Scope
NewLoc NewLoc
}; };
return MDNode::get(InsnMD->getContext(), MDVs, 4); return MDNode::get(InsnMD->getContext(), MDVs, 4);

View File

@ -648,8 +648,8 @@ void SlotTracker::processModule() {
I = TheModule->named_metadata_begin(), I = TheModule->named_metadata_begin(),
E = TheModule->named_metadata_end(); I != E; ++I) { E = TheModule->named_metadata_end(); I != E; ++I) {
const NamedMDNode *NMD = I; const NamedMDNode *NMD = I;
for (unsigned i = 0, e = NMD->getNumElements(); i != e; ++i) { for (unsigned i = 0, e = NMD->getNumOperands(); i != e; ++i) {
MDNode *MD = dyn_cast_or_null<MDNode>(NMD->getElement(i)); MDNode *MD = dyn_cast_or_null<MDNode>(NMD->getOperand(i));
if (MD) if (MD)
CreateMetadataSlot(MD); CreateMetadataSlot(MD);
} }
@ -722,8 +722,8 @@ void SlotTracker::processMDNode() {
void SlotTracker::processNamedMDNode() { void SlotTracker::processNamedMDNode() {
ST_DEBUG("begin processNamedMDNode!\n"); ST_DEBUG("begin processNamedMDNode!\n");
mdnNext = 0; mdnNext = 0;
for (unsigned i = 0, e = TheNamedMDNode->getNumElements(); i != e; ++i) { for (unsigned i = 0, e = TheNamedMDNode->getNumOperands(); i != e; ++i) {
MDNode *MD = dyn_cast_or_null<MDNode>(TheNamedMDNode->getElement(i)); MDNode *MD = dyn_cast_or_null<MDNode>(TheNamedMDNode->getOperand(i));
if (MD) if (MD)
CreateMetadataSlot(MD); CreateMetadataSlot(MD);
} }
@ -819,8 +819,8 @@ void SlotTracker::CreateMetadataSlot(const MDNode *N) {
unsigned DestSlot = mdnNext++; unsigned DestSlot = mdnNext++;
mdnMap[N] = DestSlot; mdnMap[N] = DestSlot;
for (unsigned i = 0, e = N->getNumElements(); i != e; ++i) { for (unsigned i = 0, e = N->getNumOperands(); i != e; ++i) {
const Value *TV = N->getElement(i); const Value *TV = N->getOperand(i);
if (TV) if (TV)
if (const MDNode *N2 = dyn_cast<MDNode>(TV)) if (const MDNode *N2 = dyn_cast<MDNode>(TV))
CreateMetadataSlot(N2); CreateMetadataSlot(N2);
@ -872,9 +872,9 @@ static const char *getPredicateText(unsigned predicate) {
static void WriteMDNodeComment(const MDNode *Node, static void WriteMDNodeComment(const MDNode *Node,
formatted_raw_ostream &Out) { formatted_raw_ostream &Out) {
if (Node->getNumElements() < 1) if (Node->getNumOperands() < 1)
return; return;
ConstantInt *CI = dyn_cast_or_null<ConstantInt>(Node->getElement(0)); ConstantInt *CI = dyn_cast_or_null<ConstantInt>(Node->getOperand(0));
if (!CI) return; if (!CI) return;
unsigned Val = CI->getZExtValue(); unsigned Val = CI->getZExtValue();
unsigned Tag = Val & ~LLVMDebugVersionMask; unsigned Tag = Val & ~LLVMDebugVersionMask;
@ -908,8 +908,8 @@ static void WriteMDNodes(formatted_raw_ostream &Out, TypePrinting &TypePrinter,
Out << '!' << i << " = metadata "; Out << '!' << i << " = metadata ";
const MDNode *Node = Nodes[i]; const MDNode *Node = Nodes[i];
Out << "!{"; Out << "!{";
for (unsigned mi = 0, me = Node->getNumElements(); mi != me; ++mi) { for (unsigned mi = 0, me = Node->getNumOperands(); mi != me; ++mi) {
const Value *V = Node->getElement(mi); const Value *V = Node->getOperand(mi);
if (!V) if (!V)
Out << "null"; Out << "null";
else if (const MDNode *N = dyn_cast<MDNode>(V)) { else if (const MDNode *N = dyn_cast<MDNode>(V)) {
@ -919,7 +919,7 @@ static void WriteMDNodes(formatted_raw_ostream &Out, TypePrinting &TypePrinter,
else { else {
TypePrinter.print(V->getType(), Out); TypePrinter.print(V->getType(), Out);
Out << ' '; Out << ' ';
WriteAsOperandInternal(Out, Node->getElement(mi), WriteAsOperandInternal(Out, Node->getOperand(mi),
&TypePrinter, &Machine); &TypePrinter, &Machine);
} }
if (mi + 1 != me) if (mi + 1 != me)
@ -1231,14 +1231,14 @@ static void WriteAsOperandInternal(raw_ostream &Out, const Value *V,
if (N->isFunctionLocal()) { if (N->isFunctionLocal()) {
// Print metadata inline, not via slot reference number. // Print metadata inline, not via slot reference number.
Out << "!{"; Out << "!{";
for (unsigned mi = 0, me = N->getNumElements(); mi != me; ++mi) { for (unsigned mi = 0, me = N->getNumOperands(); mi != me; ++mi) {
const Value *Val = N->getElement(mi); const Value *Val = N->getOperand(mi);
if (!Val) if (!Val)
Out << "null"; Out << "null";
else { else {
TypePrinter->print(N->getElement(0)->getType(), Out); TypePrinter->print(N->getOperand(0)->getType(), Out);
Out << ' '; Out << ' ';
WriteAsOperandInternal(Out, N->getElement(0), TypePrinter, Machine); WriteAsOperandInternal(Out, N->getOperand(0), TypePrinter, Machine);
} }
if (mi + 1 != me) if (mi + 1 != me)
Out << ", "; Out << ", ";
@ -1478,9 +1478,9 @@ void AssemblyWriter::printModule(const Module *M) {
E = M->named_metadata_end(); I != E; ++I) { E = M->named_metadata_end(); I != E; ++I) {
const NamedMDNode *NMD = I; const NamedMDNode *NMD = I;
Out << "!" << NMD->getName() << " = !{"; Out << "!" << NMD->getName() << " = !{";
for (unsigned i = 0, e = NMD->getNumElements(); i != e; ++i) { for (unsigned i = 0, e = NMD->getNumOperands(); i != e; ++i) {
if (i) Out << ", "; if (i) Out << ", ";
MDNode *MD = dyn_cast_or_null<MDNode>(NMD->getElement(i)); MDNode *MD = dyn_cast_or_null<MDNode>(NMD->getOperand(i));
Out << '!' << Machine.getMetadataSlot(MD); Out << '!' << Machine.getMetadataSlot(MD);
} }
Out << "}\n"; Out << "}\n";
@ -2138,9 +2138,9 @@ void Value::print(raw_ostream &ROS, AssemblyAnnotationWriter *AAW) const {
TypePrinting TypePrinter; TypePrinting TypePrinter;
SlotTable.initialize(); SlotTable.initialize();
OS << "!" << N->getName() << " = !{"; OS << "!" << N->getName() << " = !{";
for (unsigned i = 0, e = N->getNumElements(); i != e; ++i) { for (unsigned i = 0, e = N->getNumOperands(); i != e; ++i) {
if (i) OS << ", "; if (i) OS << ", ";
MDNode *MD = dyn_cast_or_null<MDNode>(N->getElement(i)); MDNode *MD = dyn_cast_or_null<MDNode>(N->getOperand(i));
if (MD) if (MD)
OS << '!' << SlotTable.getMetadataSlot(MD); OS << '!' << SlotTable.getMetadataSlot(MD);
else else

View File

@ -61,11 +61,11 @@ Value *DbgInfoIntrinsic::StripCast(Value *C) {
Value *DbgStopPointInst::getFileName() const { Value *DbgStopPointInst::getFileName() const {
// Once the operand indices are verified, update this assert // Once the operand indices are verified, update this assert
assert(LLVMDebugVersion == (7 << 16) && "Verify operand indices"); assert(LLVMDebugVersion == (7 << 16) && "Verify operand indices");
return getContext()->getElement(3); return getContext()->getOperand(3);
} }
Value *DbgStopPointInst::getDirectory() const { Value *DbgStopPointInst::getDirectory() const {
// Once the operand indices are verified, update this assert // Once the operand indices are verified, update this assert
assert(LLVMDebugVersion == (7 << 16) && "Verify operand indices"); assert(LLVMDebugVersion == (7 << 16) && "Verify operand indices");
return getContext()->getElement(4); return getContext()->getOperand(4);
} }

View File

@ -48,16 +48,16 @@ MDString *MDString::get(LLVMContext &Context, const char *Str) {
} }
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// MDNodeElement implementation. // MDNodeOperand implementation.
// //
// Use CallbackVH to hold MDNode elements. // Use CallbackVH to hold MDNode operands.
namespace llvm { namespace llvm {
class MDNodeElement : public CallbackVH { class MDNodeOperand : public CallbackVH {
MDNode *Parent; MDNode *Parent;
public: public:
MDNodeElement(Value *V, MDNode *P) : CallbackVH(V), Parent(P) {} MDNodeOperand(Value *V, MDNode *P) : CallbackVH(V), Parent(P) {}
~MDNodeElement() {} ~MDNodeOperand() {}
void set(Value *V) { void set(Value *V) {
setValPtr(V); setValPtr(V);
@ -69,12 +69,12 @@ public:
} // end namespace llvm. } // end namespace llvm.
void MDNodeElement::deleted() { void MDNodeOperand::deleted() {
Parent->replaceElement(this, 0); Parent->replaceOperand(this, 0);
} }
void MDNodeElement::allUsesReplacedWith(Value *NV) { void MDNodeOperand::allUsesReplacedWith(Value *NV) {
Parent->replaceElement(this, NV); Parent->replaceOperand(this, NV);
} }
@ -83,11 +83,11 @@ void MDNodeElement::allUsesReplacedWith(Value *NV) {
// MDNode implementation. // MDNode implementation.
// //
/// getOperandPtr - Helper function to get the MDNodeElement's coallocated on /// getOperandPtr - Helper function to get the MDNodeOperand's coallocated on
/// the end of the MDNode. /// the end of the MDNode.
static MDNodeElement *getOperandPtr(MDNode *N, unsigned Op) { static MDNodeOperand *getOperandPtr(MDNode *N, unsigned Op) {
assert(Op < N->getNumElements() && "Invalid operand number"); assert(Op < N->getNumOperands() && "Invalid operand number");
return reinterpret_cast<MDNodeElement*>(N+1)+Op; return reinterpret_cast<MDNodeOperand*>(N+1)+Op;
} }
MDNode::MDNode(LLVMContext &C, Value *const *Vals, unsigned NumVals, MDNode::MDNode(LLVMContext &C, Value *const *Vals, unsigned NumVals,
@ -99,9 +99,9 @@ MDNode::MDNode(LLVMContext &C, Value *const *Vals, unsigned NumVals,
setValueSubclassData(getSubclassDataFromValue() | FunctionLocalBit); setValueSubclassData(getSubclassDataFromValue() | FunctionLocalBit);
// Initialize the operand list, which is co-allocated on the end of the node. // Initialize the operand list, which is co-allocated on the end of the node.
for (MDNodeElement *Op = getOperandPtr(this, 0), *E = Op+NumOperands; for (MDNodeOperand *Op = getOperandPtr(this, 0), *E = Op+NumOperands;
Op != E; ++Op, ++Vals) Op != E; ++Op, ++Vals)
new (Op) MDNodeElement(*Vals, this); new (Op) MDNodeOperand(*Vals, this);
} }
@ -115,9 +115,9 @@ MDNode::~MDNode() {
} }
// Destroy the operands. // Destroy the operands.
for (MDNodeElement *Op = getOperandPtr(this, 0), *E = Op+NumOperands; for (MDNodeOperand *Op = getOperandPtr(this, 0), *E = Op+NumOperands;
Op != E; ++Op) Op != E; ++Op)
Op->~MDNodeElement(); Op->~MDNodeOperand();
} }
// destroy - Delete this node. Only when there are no uses. // destroy - Delete this node. Only when there are no uses.
@ -139,8 +139,8 @@ MDNode *MDNode::get(LLVMContext &Context, Value*const* Vals, unsigned NumVals,
void *InsertPoint; void *InsertPoint;
MDNode *N = pImpl->MDNodeSet.FindNodeOrInsertPos(ID, InsertPoint); MDNode *N = pImpl->MDNodeSet.FindNodeOrInsertPos(ID, InsertPoint);
if (!N) { if (!N) {
// Coallocate space for the node and elements together, then placement new. // Coallocate space for the node and Operands together, then placement new.
void *Ptr = malloc(sizeof(MDNode)+NumVals*sizeof(MDNodeElement)); void *Ptr = malloc(sizeof(MDNode)+NumVals*sizeof(MDNodeOperand));
N = new (Ptr) MDNode(Context, Vals, NumVals, isFunctionLocal); N = new (Ptr) MDNode(Context, Vals, NumVals, isFunctionLocal);
// InsertPoint will have been set by the FindNodeOrInsertPos call. // InsertPoint will have been set by the FindNodeOrInsertPos call.
@ -149,19 +149,19 @@ MDNode *MDNode::get(LLVMContext &Context, Value*const* Vals, unsigned NumVals,
return N; return N;
} }
/// getElement - Return specified element. /// getOperand - Return specified operand.
Value *MDNode::getElement(unsigned i) const { Value *MDNode::getOperand(unsigned i) const {
return *getOperandPtr(const_cast<MDNode*>(this), i); return *getOperandPtr(const_cast<MDNode*>(this), i);
} }
void MDNode::Profile(FoldingSetNodeID &ID) const { void MDNode::Profile(FoldingSetNodeID &ID) const {
for (unsigned i = 0, e = getNumElements(); i != e; ++i) for (unsigned i = 0, e = getNumOperands(); i != e; ++i)
ID.AddPointer(getElement(i)); ID.AddPointer(getOperand(i));
} }
// Replace value from this node's element list. // Replace value from this node's operand list.
void MDNode::replaceElement(MDNodeElement *Op, Value *To) { void MDNode::replaceOperand(MDNodeOperand *Op, Value *To) {
Value *From = *Op; Value *From = *Op;
if (From == To) if (From == To)
@ -233,10 +233,10 @@ 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()); Elems.reserve(NMD->getNumOperands());
for (unsigned i = 0, e = NMD->getNumElements(); i != e; ++i) for (unsigned i = 0, e = NMD->getNumOperands(); i != e; ++i)
Elems.push_back(NMD->getElement(i)); Elems.push_back(NMD->getOperand(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);
} }
@ -246,19 +246,19 @@ NamedMDNode::~NamedMDNode() {
delete &getNMDOps(Operands); delete &getNMDOps(Operands);
} }
/// getNumElements - Return number of NamedMDNode elements. /// getNumOperands - Return number of NamedMDNode operands.
unsigned NamedMDNode::getNumElements() const { unsigned NamedMDNode::getNumOperands() const {
return (unsigned)getNMDOps(Operands).size(); return (unsigned)getNMDOps(Operands).size();
} }
/// getElement - Return specified element. /// getOperand - Return specified operand.
MetadataBase *NamedMDNode::getElement(unsigned i) const { MetadataBase *NamedMDNode::getOperand(unsigned i) const {
assert(i < getNumElements() && "Invalid element number!"); assert(i < getNumOperands() && "Invalid Operand number!");
return getNMDOps(Operands)[i]; return getNMDOps(Operands)[i];
} }
/// addElement - Add metadata element. /// addOperand - Add metadata Operand.
void NamedMDNode::addElement(MetadataBase *M) { void NamedMDNode::addOperand(MetadataBase *M) {
getNMDOps(Operands).push_back(TrackingVH<MetadataBase>(M)); getNMDOps(Operands).push_back(TrackingVH<MetadataBase>(M));
} }

View File

@ -1538,8 +1538,8 @@ void Verifier::VerifyFunctionLocalMetadata(MDNode *N, Function *F,
if (!Visited.insert(N)) if (!Visited.insert(N))
return; return;
for (unsigned i = 0, e = N->getNumElements(); i != e; ++i) { for (unsigned i = 0, e = N->getNumOperands(); i != e; ++i) {
Value *V = N->getElement(i); Value *V = N->getOperand(i);
if (!V) continue; if (!V) continue;
Function *ActualF = 0; Function *ActualF = 0;

View File

@ -92,13 +92,13 @@ TEST(MDNodeTest, Simple) {
(void) n3; (void) n3;
#endif #endif
EXPECT_EQ(3u, n1->getNumElements()); EXPECT_EQ(3u, n1->getNumOperands());
EXPECT_EQ(s1, n1->getElement(0)); EXPECT_EQ(s1, n1->getOperand(0));
EXPECT_EQ(CI, n1->getElement(1)); EXPECT_EQ(CI, n1->getOperand(1));
EXPECT_EQ(s2, n1->getElement(2)); EXPECT_EQ(s2, n1->getOperand(2));
EXPECT_EQ(1u, n2->getNumElements()); EXPECT_EQ(1u, n2->getNumOperands());
EXPECT_EQ(n1, n2->getElement(0)); EXPECT_EQ(n1, n2->getOperand(0));
std::string Str; std::string Str;
raw_string_ostream oss(Str); raw_string_ostream oss(Str);