diff options
author | Quinton Miller <nicetas.c@gmail.com> | 2025-04-27 03:47:09 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-04-26 21:47:09 +0200 |
commit | 165acd3734b0bd04c5ae01f62cf01b5240606410 (patch) | |
tree | 0254a65721d79e96a296ac5bb3d56c462f8335dd /llvm/lib/IR/DebugInfo.cpp | |
parent | 419a2cb218245b90ace9e0a460d94057e7091002 (diff) | |
download | llvm-165acd3734b0bd04c5ae01f62cf01b5240606410.zip llvm-165acd3734b0bd04c5ae01f62cf01b5240606410.tar.gz llvm-165acd3734b0bd04c5ae01f62cf01b5240606410.tar.bz2 |
[LLVM-C] Support debug info for enumerators of arbitrary sizes (#76735)
Since `LLVMDIBuilderCreateEnumerator` only supports up to 64 bits, this
PR adds a new `LLVMDIBuilderCreateEnumeratorOfArbitraryPrecision`
function that takes an arbitrary number of words, based on
`LLVMConstIntOfArbitraryPrecision`. This allows even larger enumeration
types to represent their values exactly. (It seems LLVM should already
support i128 enums since 13.0.0.)
Diffstat (limited to 'llvm/lib/IR/DebugInfo.cpp')
-rw-r--r-- | llvm/lib/IR/DebugInfo.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/llvm/lib/IR/DebugInfo.cpp b/llvm/lib/IR/DebugInfo.cpp index 7a133b2..557b57d 100644 --- a/llvm/lib/IR/DebugInfo.cpp +++ b/llvm/lib/IR/DebugInfo.cpp @@ -13,6 +13,7 @@ #include "llvm-c/DebugInfo.h" #include "LLVMContextImpl.h" +#include "llvm/ADT/APSInt.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/DenseSet.h" #include "llvm/ADT/STLExtras.h" @@ -1297,6 +1298,15 @@ LLVMMetadataRef LLVMDIBuilderCreateEnumerator(LLVMDIBuilderRef Builder, IsUnsigned != 0)); } +LLVMMetadataRef LLVMDIBuilderCreateEnumeratorOfArbitraryPrecision( + LLVMDIBuilderRef Builder, const char *Name, size_t NameLen, + uint64_t SizeInBits, const uint64_t Words[], LLVMBool IsUnsigned) { + uint64_t NumWords = (SizeInBits + 63) / 64; + return wrap(unwrap(Builder)->createEnumerator( + {Name, NameLen}, + APSInt(APInt(SizeInBits, ArrayRef(Words, NumWords)), IsUnsigned != 0))); +} + LLVMMetadataRef LLVMDIBuilderCreateEnumerationType( LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name, size_t NameLen, LLVMMetadataRef File, unsigned LineNumber, |