Skip to content

Commit 423f6f4

Browse files
committed
Add support for creating a SetType, a Subrangetype, a dynamic array type
and for replacing arrays to the C inteface
1 parent dffef04 commit 423f6f4

File tree

2 files changed

+123
-1
lines changed

2 files changed

+123
-1
lines changed

llvm/include/llvm-c/DebugInfo.h

Lines changed: 72 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -673,7 +673,6 @@ LLVMMetadataRef LLVMDIBuilderCreateUnionType(
673673
LLVMMetadataRef *Elements, unsigned NumElements, unsigned RunTimeLang,
674674
const char *UniqueId, size_t UniqueIdLen);
675675

676-
677676
/**
678677
* Create debugging information entry for an array.
679678
* \param Builder The DIBuilder.
@@ -689,6 +688,78 @@ LLVMDIBuilderCreateArrayType(LLVMDIBuilderRef Builder, uint64_t Size,
689688
LLVMMetadataRef *Subscripts,
690689
unsigned NumSubscripts);
691690

691+
/**
692+
* Create debugging information entry for a set.
693+
* @param Builder The DIBuilder.
694+
* \param Scope The scope this module is imported into.
695+
* \param Name A name that uniquely identifies this set.
696+
* \param NameLen The length of the C string passed to \c Name.
697+
* \param File File where the set is located.
698+
* \param Line Line number of the declaration.
699+
* \param SizeInBits Set size.
700+
* \param AlignInBits Set alignment.
701+
* @param BaseTy The base type of the set.
702+
*/
703+
LLVMMetadataRef LLVMDIBuilderCreateSetType(
704+
LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name,
705+
size_t NameLen, LLVMMetadataRef File, unsigned LineNumber,
706+
uint64_t SizeInBits, uint32_t AlignInBits, LLVMMetadataRef BaseTy);
707+
708+
/**
709+
* Create a descriptor for a subrange with dynamic bounds.
710+
* \param Builder The DIBuilder.
711+
* \param Scope The scope this module is imported into.
712+
* \param Name A name that uniquely identifies this set.
713+
* \param NameLen The length of the C string passed to \c Name.
714+
* \param LineNo Line number.
715+
* \param File File where the subrange is located.
716+
* \param SizeInBits Member size.
717+
* \param AlignInBits Member alignment.
718+
* \param Flags Flags.
719+
* \param BaseTy The base type of the subrange. eg integer or enumeration
720+
* \param LowerBound Lower bound of the subrange.
721+
* \param UpperBound Upper bound of the subrange.
722+
* \param Stride Stride of the subrange.
723+
* \param Bias Bias of the subrange.
724+
*/
725+
LLVMMetadataRef LLVMDIBuilderCreateSubrangeType(
726+
LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name,
727+
size_t NameLen, unsigned LineNo, LLVMMetadataRef File,
728+
uint64_t SizeInBits, uint32_t AlignInBits,
729+
LLVMDIFlags Flags, LLVMMetadataRef BaseTy,
730+
LLVMMetadataRef LowerBound, LLVMMetadataRef UpperBound,
731+
LLVMMetadataRef Stride, LLVMMetadataRef Bias);
732+
733+
/**
734+
* Create debugging information entry for a dynamic array.
735+
* \param Builder The DIBuilder.
736+
* \param Size Array size.
737+
* \param AlignInBits Alignment.
738+
* \param Ty Element type.
739+
* \param Subscripts Subscripts.
740+
* \param NumSubscripts Number of subscripts.
741+
* \param DataLocation DataLocation.
742+
* \param Associated Associated.
743+
* \param Allocated Allocated.
744+
* \param Rank Rank.
745+
* \param BitStride BitStride.
746+
*/
747+
LLVMMetadataRef LLVMDIBuilderCreateDynamicArrayType(
748+
LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name,
749+
size_t NameLen, unsigned LineNo, LLVMMetadataRef File,
750+
uint64_t Size, uint32_t AlignInBits,
751+
LLVMMetadataRef Ty, LLVMMetadataRef *Subscripts, unsigned NumSubscripts,
752+
LLVMMetadataRef DataLocation, LLVMMetadataRef Associated,
753+
LLVMMetadataRef Allocated, LLVMMetadataRef Rank, LLVMMetadataRef BitStride);
754+
755+
/**
756+
* Replace arrays.
757+
*
758+
* @see DIBuilder::replaceArrays()
759+
*/
760+
void LLVMReplaceArrays(LLVMDIBuilderRef Builder, LLVMMetadataRef *T,
761+
LLVMMetadataRef *Elements, unsigned NumElements);
762+
692763
/**
693764
* Create debugging information entry for a vector type.
694765
* \param Builder The DIBuilder.

llvm/lib/IR/DebugInfo.cpp

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1309,6 +1309,57 @@ return wrap(unwrap(Builder)->createEnumerationType(
13091309
LineNumber, SizeInBits, AlignInBits, Elts, unwrapDI<DIType>(ClassTy)));
13101310
}
13111311

1312+
LLVMMetadataRef LLVMDIBuilderCreateSetType(
1313+
LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name,
1314+
size_t NameLen, LLVMMetadataRef File, unsigned LineNumber,
1315+
uint64_t SizeInBits, uint32_t AlignInBits, LLVMMetadataRef BaseTy) {
1316+
return wrap(unwrap(Builder)->createSetType(
1317+
unwrapDI<DIScope>(Scope), {Name, NameLen}, unwrapDI<DIFile>(File),
1318+
LineNumber, SizeInBits, AlignInBits, unwrapDI<DIType>(BaseTy)));
1319+
}
1320+
1321+
LLVMMetadataRef LLVMDIBuilderCreateSubrangeType(
1322+
LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name,
1323+
size_t NameLen, unsigned LineNo, LLVMMetadataRef File,
1324+
uint64_t SizeInBits, uint32_t AlignInBits,
1325+
LLVMDIFlags Flags, LLVMMetadataRef BaseTy,
1326+
LLVMMetadataRef LowerBound, LLVMMetadataRef UpperBound,
1327+
LLVMMetadataRef Stride, LLVMMetadataRef Bias
1328+
) {
1329+
return wrap(unwrap(Builder)->createSubrangeType(
1330+
{Name, NameLen}, unwrapDI<DIFile>(File), LineNo,
1331+
unwrapDI<DIScope>(Scope), SizeInBits, AlignInBits,
1332+
map_from_llvmDIFlags(Flags), unwrapDI<DIType>(BaseTy),
1333+
unwrap<DIExpression>(LowerBound), unwrap<DIExpression>(UpperBound),
1334+
unwrap<DIExpression>(Stride), unwrap<DIExpression>(Bias)));
1335+
}
1336+
1337+
LLVMMetadataRef LLVMDIBuilderCreateDynamicArrayType(
1338+
LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name,
1339+
size_t NameLen, unsigned LineNo, LLVMMetadataRef File,
1340+
uint64_t Size, uint32_t AlignInBits,
1341+
LLVMMetadataRef Ty, LLVMMetadataRef *Subscripts, unsigned NumSubscripts,
1342+
LLVMMetadataRef DataLocation, LLVMMetadataRef Associated,
1343+
LLVMMetadataRef Allocated, LLVMMetadataRef Rank, LLVMMetadataRef BitStride) {
1344+
auto Subs =
1345+
unwrap(Builder)->getOrCreateArray({unwrap(Subscripts), NumSubscripts});
1346+
return wrap(unwrap(Builder)->createArrayType(
1347+
unwrapDI<DIScope>(Scope),
1348+
{Name, NameLen}, unwrapDI<DIFile>(File), LineNo,
1349+
Size, AlignInBits, unwrapDI<DIType>(Ty), Subs,
1350+
unwrap<DIExpression>(DataLocation), unwrap<DIExpression>(Associated),
1351+
unwrap<DIExpression>(Allocated), unwrap<DIExpression>(Rank),
1352+
unwrap(BitStride)));
1353+
}
1354+
1355+
void LLVMReplaceArrays(LLVMDIBuilderRef Builder, LLVMMetadataRef *T,
1356+
LLVMMetadataRef *Elements, unsigned NumElements) {
1357+
auto Arr = unwrap<DICompositeType>(*T);
1358+
auto Elts = unwrap(Builder)->getOrCreateArray({unwrap(Elements),
1359+
NumElements});
1360+
unwrap(Builder)->replaceArrays(Arr, Elts);
1361+
}
1362+
13121363
LLVMMetadataRef LLVMDIBuilderCreateUnionType(
13131364
LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name,
13141365
size_t NameLen, LLVMMetadataRef File, unsigned LineNumber,

0 commit comments

Comments
 (0)