[llvm] [C API] Add bindings for DWARF type encoding.wq (PR #102171)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 6 08:54:26 PDT 2024
https://github.com/deadalnix created https://github.com/llvm/llvm-project/pull/102171
As per title, there is no API that provides the proper values for this.
>From 30c3f7e316c7ebaa35a3cee6f9618b2481ba0784 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Amaury=20S=C3=A9chet?= <deadalnix at gmail.com>
Date: Tue, 6 Aug 2024 15:29:18 +0000
Subject: [PATCH] [C API] Add bindings for DWARF type encoding.wq
---
llvm/include/llvm-c/DebugInfo.h | 24 ++++++++++++++++++-
.../Bindings/llvm-c/debug_info_new_format.ll | 2 +-
llvm/tools/llvm-c-test/debuginfo.c | 2 +-
3 files changed, 25 insertions(+), 3 deletions(-)
diff --git a/llvm/include/llvm-c/DebugInfo.h b/llvm/include/llvm-c/DebugInfo.h
index 6d8891e7057722..3ee5d9e045b44c 100644
--- a/llvm/include/llvm-c/DebugInfo.h
+++ b/llvm/include/llvm-c/DebugInfo.h
@@ -200,7 +200,29 @@ typedef unsigned LLVMMetadataKind;
/**
* An LLVM DWARF type encoding.
*/
-typedef unsigned LLVMDWARFTypeEncoding;
+typedef enum {
+ LVMDWARFAddressTypeEncoding = 0x01,
+ LVMDWARFBooleanTypeEncoding = 0x02,
+ LVMDWARFComplexFloatTypeEncoding = 0x03,
+ LVMDWARFFloatTypeEncoding = 0x04,
+ LVMDWARFSignedTypeEncoding = 0x05,
+ LVMDWARFSignedCharTypeEncoding = 0x06,
+ LVMDWARFUnsignedTypeEncoding = 0x07,
+ LVMDWARFUnsignedCharTypeEncoding = 0x08,
+ // New in DWARF v3:
+ LVMDWARFImmaginaryFloatTypeEncoding = 0x09,
+ LVMDWARFPackedDecimalTypeEncoding = 0x0a,
+ LVMDWARFNumericStringTypeEncoding = 0x0b,
+ LVMDWARFEditedTypeEncoding = 0x0c,
+ LVMDWARFSignedFixedTypeEncoding = 0x0d,
+ LVMDWARFUnsignedFixedTypeEncoding = 0x0e,
+ LVMDWARFDecimalFloatTypeEncoding = 0x0f,
+ // New in DWARF v4:
+ LVMDWARFUTFTypeEncoding = 0x10,
+ // New in DWARF v5:
+ LVMDWARFUCSTypeEncoding = 0x11,
+ LVMDWARFASCIITypeEncoding = 0x12,
+} LLVMDWARFTypeEncoding;
/**
* Describes the kind of macro declaration used for LLVMDIBuilderCreateMacro.
diff --git a/llvm/test/Bindings/llvm-c/debug_info_new_format.ll b/llvm/test/Bindings/llvm-c/debug_info_new_format.ll
index a9ba9d7ad05a70..658af9a0b6caee 100644
--- a/llvm/test/Bindings/llvm-c/debug_info_new_format.ll
+++ b/llvm/test/Bindings/llvm-c/debug_info_new_format.ll
@@ -28,7 +28,7 @@
; CHECK-NEXT: !3 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "EnumTest", scope: !4, file: !1, baseType: !6, size: 64, elements: !7)
; CHECK-NEXT: !4 = !DINamespace(name: "NameSpace", scope: !5)
; CHECK-NEXT: !5 = !DIModule(scope: null, name: "llvm-c-test", includePath: "/test/include/llvm-c-test.h")
-; CHECK-NEXT: !6 = !DIBasicType(name: "Int64", size: 64)
+; CHECK-NEXT: !6 = !DIBasicType(name: "Int64", size: 64, encoding: DW_ATE_signed)
; CHECK-NEXT: !7 = !{!8, !9, !10}
; CHECK-NEXT: !8 = !DIEnumerator(name: "Test_A", value: 0, isUnsigned: true)
; CHECK-NEXT: !9 = !DIEnumerator(name: "Test_B", value: 1, isUnsigned: true)
diff --git a/llvm/tools/llvm-c-test/debuginfo.c b/llvm/tools/llvm-c-test/debuginfo.c
index 49c90f5b87b83a..8658790e288388 100644
--- a/llvm/tools/llvm-c-test/debuginfo.c
+++ b/llvm/tools/llvm-c-test/debuginfo.c
@@ -71,7 +71,7 @@ int llvm_test_dibuilder(void) {
GlobalClassValueExpr, NULL, 0);
LLVMMetadataRef Int64Ty =
- LLVMDIBuilderCreateBasicType(DIB, "Int64", 5, 64, 0, LLVMDIFlagZero);
+ LLVMDIBuilderCreateBasicType(DIB, "Int64", 5, 64, LVMDWARFSignedTypeEncoding, LLVMDIFlagZero);
LLVMMetadataRef Int64TypeDef =
LLVMDIBuilderCreateTypedef(DIB, Int64Ty, "int64_t", 7, File, 42, File, 0);
More information about the llvm-commits
mailing list