summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>2014-11-13 13:17:47 +0000
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>2014-11-13 13:17:47 +0000
commitf8edc4a4b1b30b6324d88d11ffb7ba07eb460744 (patch)
tree7ae33e08a278a0564b2f781a7843c3bdae0b387a
parente553a93ba8c905c2120da920d3147f0df430bcf7 (diff)
downloadbcm5719-llvm-f8edc4a4b1b30b6324d88d11ffb7ba07eb460744.tar.gz
bcm5719-llvm-f8edc4a4b1b30b6324d88d11ffb7ba07eb460744.zip
IR: Create the Metadata class
This will become the root of a new class hierarchy separate from `Value`. As a first step, stick it between `Value` and `MDNode`. This is part of PR21532. llvm-svn: 221886
-rw-r--r--llvm/include/llvm/IR/Metadata.h23
-rw-r--r--llvm/lib/IR/Metadata.cpp4
2 files changed, 23 insertions, 4 deletions
diff --git a/llvm/include/llvm/IR/Metadata.h b/llvm/include/llvm/IR/Metadata.h
index 9d3950f9063..a4e9f532980 100644
--- a/llvm/include/llvm/IR/Metadata.h
+++ b/llvm/include/llvm/IR/Metadata.h
@@ -34,11 +34,28 @@ enum LLVMConstants : uint32_t {
DEBUG_METADATA_VERSION = 2 // Current debug info version number.
};
+/// \brief Root of the metadata hierarchy.
+///
+/// This is a root class for typeless data in the IR.
+///
+/// TODO: Detach from the Value hierarchy.
+class Metadata : public Value {
+protected:
+ Metadata(Type *Type, unsigned ID) : Value(Type, ID) {}
+
+public:
+ static bool classof(const Value *V) {
+ return V->getValueID() == MDNodeVal;
+ }
+};
+
//===----------------------------------------------------------------------===//
/// \brief A single uniqued string.
///
/// These are used to efficiently contain a byte sequence for metadata.
/// MDString is always unnamed.
+///
+/// TODO: Inherit from Metadata.
class MDString : public Value {
virtual void anchor();
MDString(const MDString &) LLVM_DELETED_FUNCTION;
@@ -115,8 +132,8 @@ struct DenseMapInfo<AAMDNodes> {
class MDNodeOperand;
//===----------------------------------------------------------------------===//
-/// \brief A tuple of other values.
-class MDNode : public Value, public FoldingSetNode {
+/// \brief Generic tuple of metadata.
+class MDNode : public Metadata, public FoldingSetNode {
MDNode(const MDNode &) LLVM_DELETED_FUNCTION;
void operator=(const MDNode &) LLVM_DELETED_FUNCTION;
friend class MDNodeOperand;
@@ -241,6 +258,8 @@ private:
///
/// Despite its name, a NamedMDNode isn't itself an MDNode. NamedMDNodes belong
/// to modules, have names, and contain lists of MDNodes.
+///
+/// TODO: Inherit from Metadata.
class NamedMDNode : public ilist_node<NamedMDNode> {
friend class SymbolTableListTraits<NamedMDNode, Module>;
friend struct ilist_traits<NamedMDNode>;
diff --git a/llvm/lib/IR/Metadata.cpp b/llvm/lib/IR/Metadata.cpp
index 1fb15a075a6..8d616cfb0d6 100644
--- a/llvm/lib/IR/Metadata.cpp
+++ b/llvm/lib/IR/Metadata.cpp
@@ -109,8 +109,8 @@ void MDNode::replaceOperandWith(unsigned i, Value *Val) {
replaceOperand(Op, Val);
}
-MDNode::MDNode(LLVMContext &C, ArrayRef<Value*> Vals, bool isFunctionLocal)
-: Value(Type::getMetadataTy(C), Value::MDNodeVal) {
+MDNode::MDNode(LLVMContext &C, ArrayRef<Value *> Vals, bool isFunctionLocal)
+ : Metadata(Type::getMetadataTy(C), Value::MDNodeVal) {
NumOperands = Vals.size();
if (isFunctionLocal)
OpenPOWER on IntegriCloud