IR: MDNode => Value: Add Instruction::getMDNode()
[oota-llvm.git] / include / llvm / IR / Instruction.h
index 2671f0f8e9c45dd6383215749bcd3ff9ca29a847..ac042ff7ba99b80e81028452c083df2a438e67ae 100644 (file)
@@ -153,6 +153,24 @@ public:
     return getMetadataImpl(Kind);
   }
 
+  /// Get the the metadata as an MDNode.
+  ///
+  /// \pre Any KindID metadata is implemented using \a MDNode.
+  MDNode *getMDNode(unsigned KindID) const {
+    if (!hasMetadata())
+      return nullptr;
+    return getMDNodeImpl(KindID);
+  }
+
+  /// Get the the metadata as an MDNode.
+  ///
+  /// \pre Any KindID metadata is implemented using \a MDNode.
+  MDNode *getMDNode(StringRef Kind) const {
+    if (!hasMetadata())
+      return nullptr;
+    return getMDNodeImpl(Kind);
+  }
+
   /// getAllMetadata - Get all metadata attached to this Instruction.  The first
   /// element of each pair returned is the KindID, the second element is the
   /// metadata value.  This list is returned sorted by the KindID.
@@ -176,9 +194,9 @@ public:
 
   /// setMetadata - Set the metadata of the specified kind to the specified
   /// node.  This updates/replaces metadata if already present, or removes it if
-  /// Node is null.
-  void setMetadata(unsigned KindID, MDNode *Node);
-  void setMetadata(StringRef Kind, MDNode *Node);
+  /// MD is null.
+  void setMetadata(unsigned KindID, Value *MD);
+  void setMetadata(StringRef Kind, Value *MD);
 
   /// \brief Drop unknown metadata.
   /// Passes are required to drop metadata they don't understand. This is a
@@ -230,11 +248,16 @@ public:
   /// this flag.
   void setHasAllowReciprocal(bool B);
 
-  /// Convenience function for setting all the fast-math flags on this
+  /// Convenience function for setting multiple fast-math flags on this
   /// instruction, which must be an operator which supports these flags. See
-  /// LangRef.html for the meaning of these flats.
+  /// LangRef.html for the meaning of these flags.
   void setFastMathFlags(FastMathFlags FMF);
 
+  /// Convenience function for transferring all fast-math flag values to this
+  /// instruction, which must be an operator which supports these flags. See
+  /// LangRef.html for the meaning of these flags.
+  void copyFastMathFlags(FastMathFlags FMF);
+
   /// Determine whether the unsafe-algebra flag is set.
   bool hasUnsafeAlgebra() const;
 
@@ -268,6 +291,8 @@ private:
   // These are all implemented in Metadata.cpp.
   MDNode *getMetadataImpl(unsigned KindID) const;
   MDNode *getMetadataImpl(StringRef Kind) const;
+  MDNode *getMDNodeImpl(unsigned KindID) const;
+  MDNode *getMDNodeImpl(StringRef Kind) const;
   void getAllMetadataImpl(SmallVectorImpl<std::pair<unsigned,MDNode*> > &)const;
   void getAllMetadataOtherThanDebugLocImpl(SmallVectorImpl<std::pair<unsigned,
                                            MDNode*> > &) const;
@@ -333,6 +358,11 @@ public:
     return mayReadFromMemory() || mayWriteToMemory();
   }
 
+  /// isAtomic - Return true if this instruction has an
+  /// AtomicOrdering of unordered or higher.
+  ///
+  bool isAtomic() const;
+
   /// mayThrow - Return true if this instruction may throw an exception.
   ///
   bool mayThrow() const;