TBAA: add utility to create a TBAA scalar type node
authorManman Ren <mren@apple.com>
Thu, 11 Apr 2013 22:51:30 +0000 (22:51 +0000)
committerManman Ren <mren@apple.com>
Thu, 11 Apr 2013 22:51:30 +0000 (22:51 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@179331 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/IR/MDBuilder.h

index a1e3fb1966ed3dc4de2846812697f7cb3cd2a22f..074db78a767af398de0e951ca51c7aba000b901a 100644 (file)
@@ -157,7 +157,7 @@ public:
   }
 
   /// \brief Return metadata for a TBAA struct node in the type DAG
-  /// with the given name, parents in the TBAA DAG.
+  /// with the given name, a list of pairs (offset, field type in the type DAG).
   MDNode *createTBAAStructTypeNode(StringRef Name,
              ArrayRef<std::pair<uint64_t, MDNode*> > Fields) {
     SmallVector<Value *, 4> Ops(Fields.size() * 2 + 1);
@@ -170,6 +170,18 @@ public:
     return MDNode::get(Context, Ops);
   }
 
+  /// \brief Return metadata for a TBAA scalar type node with the
+  /// given name, an offset and a parent in the TBAA type DAG.
+  MDNode *createTBAAScalarTypeNode(StringRef Name, uint64_t Offset,
+                                   MDNode *Parent) {
+    SmallVector<Value *, 4> Ops(3);
+    Type *Int64 = IntegerType::get(Context, 64);
+    Ops[0] = createString(Name);
+    Ops[1] = ConstantInt::get(Int64, Offset);
+    Ops[2] = Parent;
+    return MDNode::get(Context, Ops);
+  }
+
   /// \brief Return metadata for a TBAA tag node with the given
   /// base type, access type and offset relative to the base type.
   MDNode *createTBAAStructTagNode(MDNode *BaseType, MDNode *AccessType,