Add a pinned metadata name for fpaccuracy, and document it
authorPeter Collingbourne <peter@pcc.me.uk>
Thu, 27 Oct 2011 19:19:14 +0000 (19:19 +0000)
committerPeter Collingbourne <peter@pcc.me.uk>
Thu, 27 Oct 2011 19:19:14 +0000 (19:19 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@143135 91177308-0d34-0410-b5e6-96231b3b80d8

docs/LangRef.html
include/llvm/LLVMContext.h
lib/VMCore/LLVMContext.cpp

index 8dca4151720cc307f03d19f43eda1c8ae3a01a01..a12a42b39df27e3930dcfb6dc8968cdb62fdeb50 100644 (file)
       <li><a href="#metadata">Metadata Nodes and Metadata Strings</a>
         <ol>
           <li><a href="#tbaa">'<tt>tbaa</tt>' Metadata</a></li>
+          <li><a href="#fpaccuracy">'<tt>fpaccuracy</tt>' Metadata</a></li>
         </ol>
       </li>
     </ol>
@@ -2966,6 +2967,35 @@ call void @llvm.dbg.value(metadata !24, i64 0, metadata !25)
 
 </div>
 
+<h4>
+  <a name="fpaccuracy">'<tt>fpaccuracy</tt>' Metadata</a>
+</h4>
+<div>
+
+<p><tt>fpaccuracy</tt> metadata may be attached to any instruction of floating
+   point type.  It expresses the maximum relative error of the result of
+   that instruction, in ULPs. ULP is defined as follows:</p>
+
+<blockquote><p>
+If x is a real number that lies between two finite consecutive floating-point
+numbers a and b, without being equal to one of them, then ulp(x) = |b - a|,
+otherwise ulp(x) is the distance between the two non-equal finite
+floating-point numbers nearest x. Moreover, ulp(NaN) is NaN.
+</p></blockquote>
+
+<p>The maximum relative error may be any rational number.  The metadata node
+   shall consist of a pair of unsigned integers respectively representing
+   the numerator and denominator.  For example, 2.5 ULP:</p>
+
+<div class="doc_code">
+<pre>
+!0 = metadata !{ i32 5, i32 2 }
+</pre>
+</div>
+
+</div>
+
 </div>
 
 </div>
index 65146c31aaa33a29c7527cc9a3c6ff702651f3ec..1c5063011d783619d888f053a8b76a3590cdef91 100644 (file)
@@ -40,7 +40,8 @@ public:
   enum {
     MD_dbg = 0,  // "dbg"
     MD_tbaa = 1, // "tbaa"
-    MD_prof = 2  // "prof"
+    MD_prof = 2,  // "prof"
+    MD_fpaccuracy = 3  // "fpaccuracy"
   };
   
   /// getMDKindID - Return a unique non-zero ID for the specified metadata kind.
index 3ed2c2c7e9ea74e15bfb4aece248662c996211de..e1a9b17724347b4fd5619e20ad25433540c43791 100644 (file)
@@ -43,6 +43,11 @@ LLVMContext::LLVMContext() : pImpl(new LLVMContextImpl(*this)) {
   // Create the 'prof' metadata kind.
   unsigned ProfID = getMDKindID("prof");
   assert(ProfID == MD_prof && "prof kind id drifted"); (void)ProfID;
+
+  // Create the 'fpaccuracy' metadata kind.
+  unsigned FPAccuracyID = getMDKindID("fpaccuracy");
+  assert(FPAccuracyID == MD_fpaccuracy && "fpaccuracy kind id drifted");
+  (void)FPAccuracyID;
 }
 LLVMContext::~LLVMContext() { delete pImpl; }