summaryrefslogtreecommitdiff
path: root/include/llvm
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2012-09-21 23:00:37 +0000
committerDan Gohman <gohman@apple.com>2012-09-21 23:00:37 +0000
commitc91249485527f69cf0d7e7b6dda9d8e6eb46d4b0 (patch)
treef9dc9f2da84f74ff963f671eca5d03909a5ad407 /include/llvm
parent0543c147df79efeb2ca36132158c51a5274b9c77 (diff)
downloadllvm-c91249485527f69cf0d7e7b6dda9d8e6eb46d4b0.tar.gz
llvm-c91249485527f69cf0d7e7b6dda9d8e6eb46d4b0.tar.bz2
llvm-c91249485527f69cf0d7e7b6dda9d8e6eb46d4b0.tar.xz
Add an MDBuilder utility for creating !tbaa.struct nodes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@164425 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm')
-rw-r--r--include/llvm/MDBuilder.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/include/llvm/MDBuilder.h b/include/llvm/MDBuilder.h
index 2aa48b0b47..1867a63923 100644
--- a/include/llvm/MDBuilder.h
+++ b/include/llvm/MDBuilder.h
@@ -134,6 +134,27 @@ namespace llvm {
}
}
+ 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