diff options
author | Manman Ren <mren@apple.com> | 2013-04-02 19:50:49 +0000 |
---|---|---|
committer | Manman Ren <mren@apple.com> | 2013-04-02 19:50:49 +0000 |
commit | 082bb7cf57e3a7089b8302a7d676fddf0bce276e (patch) | |
tree | c3ad23b6aed1005bb53074e871c02cc5f3cdf806 | |
parent | debf7d345aa297ebedf2d3b1db234feb44c71483 (diff) | |
download | external_llvm-082bb7cf57e3a7089b8302a7d676fddf0bce276e.zip external_llvm-082bb7cf57e3a7089b8302a7d676fddf0bce276e.tar.gz external_llvm-082bb7cf57e3a7089b8302a7d676fddf0bce276e.tar.bz2 |
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@178564 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/llvm/IR/MDBuilder.h | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/include/llvm/IR/MDBuilder.h b/include/llvm/IR/MDBuilder.h index 604051b..a1e3fb1 100644 --- a/include/llvm/IR/MDBuilder.h +++ b/include/llvm/IR/MDBuilder.h @@ -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 |