[llvm-commits] [llvm] r164425 - /llvm/trunk/include/llvm/MDBuilder.h

Dan Gohman gohman at apple.com
Fri Sep 21 16:00:37 PDT 2012


Author: djg
Date: Fri Sep 21 18:00:37 2012
New Revision: 164425

URL: http://llvm.org/viewvc/llvm-project?rev=164425&view=rev
Log:
Add an MDBuilder utility for creating !tbaa.struct nodes.

Modified:
    llvm/trunk/include/llvm/MDBuilder.h

Modified: llvm/trunk/include/llvm/MDBuilder.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MDBuilder.h?rev=164425&r1=164424&r2=164425&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MDBuilder.h (original)
+++ llvm/trunk/include/llvm/MDBuilder.h Fri Sep 21 18:00:37 2012
@@ -134,6 +134,27 @@
       }
     }
 
+    struct TBAAStructField {
+      uint64_t Offset;
+      uint64_t Size;
+      MDNode *TBAA;
+      TBAAStructField(uint64_t Offset, uint64_t Size, MDNode *TBAA) :
+        Offset(Offset), Size(Size), TBAA(TBAA) {}
+    };
+
+    /// \brief Return metadata for a tbaa.struct node with the given
+    /// struct field descriptions.
+    MDNode *createTBAAStructNode(ArrayRef<TBAAStructField> Fields) {
+      SmallVector<Value *, 4> Vals(Fields.size() * 3);
+      Type *Int64 = IntegerType::get(Context, 64);
+      for (unsigned i = 0, e = Fields.size(); i != e; ++i) {
+        Vals[i * 3 + 0] = ConstantInt::get(Int64, Fields[i].Offset);
+        Vals[i * 3 + 1] = ConstantInt::get(Int64, Fields[i].Size);
+        Vals[i * 3 + 2] = Fields[i].TBAA;
+      }
+      return MDNode::get(Context, Vals);
+    }
+
   };
 
 } // end namespace llvm





More information about the llvm-commits mailing list