[llvm] r178564 - Add MDBuilder utilities for path-aware TBAA.
Manman Ren
mren at apple.com
Tue Apr 2 12:50:50 PDT 2013
Author: mren
Date: Tue Apr 2 14:50:49 2013
New Revision: 178564
URL: http://llvm.org/viewvc/llvm-project?rev=178564&view=rev
Log:
Add MDBuilder utilities for path-aware TBAA.
Add utilities to create struct nodes in TBAA type DAG and to create path-aware
tags. The format of struct nodes in TBAA type DAG: a unique name, a list of
fields with field offsets and field types. The format of path-aware tags:
a base type in TBAA type DAG, an access type and an offset relative to the base
type.
Modified:
llvm/trunk/include/llvm/IR/MDBuilder.h
Modified: llvm/trunk/include/llvm/IR/MDBuilder.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/MDBuilder.h?rev=178564&r1=178563&r2=178564&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/MDBuilder.h (original)
+++ llvm/trunk/include/llvm/IR/MDBuilder.h Tue Apr 2 14:50:49 2013
@@ -156,6 +156,29 @@ public:
return MDNode::get(Context, Vals);
}
+ /// \brief Return metadata for a TBAA struct node in the type DAG
+ /// with the given name, parents in the TBAA DAG.
+ MDNode *createTBAAStructTypeNode(StringRef Name,
+ ArrayRef<std::pair<uint64_t, MDNode*> > Fields) {
+ SmallVector<Value *, 4> Ops(Fields.size() * 2 + 1);
+ Type *Int64 = IntegerType::get(Context, 64);
+ Ops[0] = createString(Name);
+ for (unsigned i = 0, e = Fields.size(); i != e; ++i) {
+ Ops[i * 2 + 1] = ConstantInt::get(Int64, Fields[i].first);
+ Ops[i * 2 + 2] = Fields[i].second;
+ }
+ 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,
+ uint64_t Offset) {
+ Type *Int64 = IntegerType::get(Context, 64);
+ Value *Ops[3] = { BaseType, AccessType, ConstantInt::get(Int64, Offset) };
+ return MDNode::get(Context, Ops);
+ }
+
};
} // end namespace llvm
More information about the llvm-commits
mailing list