diff options
| author | Sanjoy Das <sanjoy@playingwithpointers.com> | 2015-09-24 19:14:18 +0000 |
|---|---|---|
| committer | Sanjoy Das <sanjoy@playingwithpointers.com> | 2015-09-24 19:14:18 +0000 |
| commit | 9303c246506dc7048f8de21a59082d1083f23869 (patch) | |
| tree | 2a3d88e699a0ae54c0540ab3af639314051935b1 /llvm/lib/IR/LLVMContextImpl.cpp | |
| parent | c28a08b8d2dc948d47e47b87b18e47e380782309 (diff) | |
| download | bcm5719-llvm-9303c246506dc7048f8de21a59082d1083f23869.tar.gz bcm5719-llvm-9303c246506dc7048f8de21a59082d1083f23869.zip | |
[IR] Add operand bundles to CallInst and InvokeInst.
Summary:
This change teaches `CallInst`s and `InvokeInst`s to maintain a set of
operand bundles as part of its operands. `CallInst`s and `InvokeInst`s
with operand bundles co-allocate some space before their `Use` array to
hold meta information about which of its operands are part of an operand
bundle.
The strings corresponding to the bundle tags are interned into
`LLVMContextImpl::BundleTagCache`
This change does not include any parsing / bitcode support. That's the
next change.
Depends on D12455.
Reviewers: reames, chandlerc, majnemer, dexonsmith, kmod, JosephTremoulet, rnk, bogner
Subscribers: MatzeB, sanjoy, llvm-commits
Differential Revision: http://reviews.llvm.org/D12456
llvm-svn: 248527
Diffstat (limited to 'llvm/lib/IR/LLVMContextImpl.cpp')
| -rw-r--r-- | llvm/lib/IR/LLVMContextImpl.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/llvm/lib/IR/LLVMContextImpl.cpp b/llvm/lib/IR/LLVMContextImpl.cpp index dc367fee884..5239b4f7d84 100644 --- a/llvm/lib/IR/LLVMContextImpl.cpp +++ b/llvm/lib/IR/LLVMContextImpl.cpp @@ -219,6 +219,23 @@ unsigned MDNodeOpsKey::calculateHash(ArrayRef<Metadata *> Ops) { return hash_combine_range(Ops.begin(), Ops.end()); } +StringMapEntry<uint32_t> *LLVMContextImpl::getOrInsertBundleTag(StringRef Tag) { + uint32_t NewIdx = BundleTagCache.size(); + return &*(BundleTagCache.insert(std::make_pair(Tag, NewIdx)).first); +} + +void LLVMContextImpl::getOperandBundleTags(SmallVectorImpl<StringRef> &Tags) const { + Tags.resize(BundleTagCache.size()); + for (const auto &T : BundleTagCache) + Tags[T.second] = T.first(); +} + +uint32_t LLVMContextImpl::getOperandBundleTagID(StringRef Tag) const { + auto I = BundleTagCache.find(Tag); + assert(I != BundleTagCache.end() && "Unknown tag!"); + return I->second; +} + // ConstantsContext anchors void UnaryConstantExpr::anchor() { } |

