diff options
Diffstat (limited to 'llvm/lib/IR/DebugInfo.cpp')
-rw-r--r-- | llvm/lib/IR/DebugInfo.cpp | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/llvm/lib/IR/DebugInfo.cpp b/llvm/lib/IR/DebugInfo.cpp index 4e09f84..84a56058 100644 --- a/llvm/lib/IR/DebugInfo.cpp +++ b/llvm/lib/IR/DebugInfo.cpp @@ -1325,6 +1325,63 @@ return wrap(unwrap(Builder)->createEnumerationType( LineNumber, SizeInBits, AlignInBits, Elts, unwrapDI<DIType>(ClassTy))); } +LLVMMetadataRef LLVMDIBuilderCreateSetType( + LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name, + size_t NameLen, LLVMMetadataRef File, unsigned LineNumber, + uint64_t SizeInBits, uint32_t AlignInBits, LLVMMetadataRef BaseTy) { + return wrap(unwrap(Builder)->createSetType( + unwrapDI<DIScope>(Scope), {Name, NameLen}, unwrapDI<DIFile>(File), + LineNumber, SizeInBits, AlignInBits, unwrapDI<DIType>(BaseTy))); +} + +LLVMMetadataRef LLVMDIBuilderCreateSubrangeType( + LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name, + size_t NameLen, unsigned LineNo, LLVMMetadataRef File, uint64_t SizeInBits, + uint32_t AlignInBits, LLVMDIFlags Flags, LLVMMetadataRef BaseTy, + LLVMMetadataRef LowerBound, LLVMMetadataRef UpperBound, + LLVMMetadataRef Stride, LLVMMetadataRef Bias) { + return wrap(unwrap(Builder)->createSubrangeType( + {Name, NameLen}, unwrapDI<DIFile>(File), LineNo, unwrapDI<DIScope>(Scope), + SizeInBits, AlignInBits, map_from_llvmDIFlags(Flags), + unwrapDI<DIType>(BaseTy), unwrap(LowerBound), unwrap(UpperBound), + unwrap(Stride), unwrap(Bias))); +} + +/// MD may be nullptr, a DIExpression or DIVariable. +PointerUnion<DIExpression *, DIVariable *> unwrapExprVar(LLVMMetadataRef MD) { + if (!MD) + return nullptr; + MDNode *MDN = unwrapDI<MDNode>(MD); + if (auto *E = dyn_cast<DIExpression>(MDN)) + return E; + assert(isa<DIVariable>(MDN) && "Expected DIExpression or DIVariable"); + return cast<DIVariable>(MDN); +} + +LLVMMetadataRef LLVMDIBuilderCreateDynamicArrayType( + LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name, + size_t NameLen, unsigned LineNo, LLVMMetadataRef File, uint64_t Size, + uint32_t AlignInBits, LLVMMetadataRef Ty, LLVMMetadataRef *Subscripts, + unsigned NumSubscripts, LLVMMetadataRef DataLocation, + LLVMMetadataRef Associated, LLVMMetadataRef Allocated, LLVMMetadataRef Rank, + LLVMMetadataRef BitStride) { + auto Subs = + unwrap(Builder)->getOrCreateArray({unwrap(Subscripts), NumSubscripts}); + return wrap(unwrap(Builder)->createArrayType( + unwrapDI<DIScope>(Scope), {Name, NameLen}, unwrapDI<DIFile>(File), LineNo, + Size, AlignInBits, unwrapDI<DIType>(Ty), Subs, + unwrapExprVar(DataLocation), unwrapExprVar(Associated), + unwrapExprVar(Allocated), unwrapExprVar(Rank), unwrap(BitStride))); +} + +void LLVMReplaceArrays(LLVMDIBuilderRef Builder, LLVMMetadataRef *T, + LLVMMetadataRef *Elements, unsigned NumElements) { + auto CT = unwrap<DICompositeType>(*T); + auto Elts = + unwrap(Builder)->getOrCreateArray({unwrap(Elements), NumElements}); + unwrap(Builder)->replaceArrays(CT, Elts); +} + LLVMMetadataRef LLVMDIBuilderCreateUnionType( LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name, size_t NameLen, LLVMMetadataRef File, unsigned LineNumber, |