[llvm] [C API] Add bindings for DWARF type encoding. (PR #102171)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 9 08:28:57 PDT 2024
https://github.com/deadalnix updated https://github.com/llvm/llvm-project/pull/102171
>From 6720223b2df2e60e0b89f0d151553de413eb449d 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.
---
llvm/include/llvm-c/DebugInfo.h | 24 ++++++++++++++++++-
.../Bindings/llvm-c/debug_info_new_format.ll | 2 +-
llvm/tools/llvm-c-test/debuginfo.c | 4 ++--
3 files changed, 26 insertions(+), 4 deletions(-)
diff --git a/llvm/include/llvm-c/DebugInfo.h b/llvm/include/llvm-c/DebugInfo.h
index 6d8891e7057722..e821f91c92c641 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 {
+ LLVMDWARFAddressTypeEncoding = 0x01,
+ LLVMDWARFBooleanTypeEncoding = 0x02,
+ LLVMDWARFComplexFloatTypeEncoding = 0x03,
+ LLVMDWARFFloatTypeEncoding = 0x04,
+ LLVMDWARFSignedTypeEncoding = 0x05,
+ LLVMDWARFSignedCharTypeEncoding = 0x06,
+ LLVMDWARFUnsignedTypeEncoding = 0x07,
+ LLVMDWARFUnsignedCharTypeEncoding = 0x08,
+ // New in DWARF v3:
+ LLVMDWARFImmaginaryFloatTypeEncoding = 0x09,
+ LLVMDWARFPackedDecimalTypeEncoding = 0x0a,
+ LLVMDWARFNumericStringTypeEncoding = 0x0b,
+ LLVMDWARFEditedTypeEncoding = 0x0c,
+ LLVMDWARFSignedFixedTypeEncoding = 0x0d,
+ LLVMDWARFUnsignedFixedTypeEncoding = 0x0e,
+ LLVMDWARFDecimalFloatTypeEncoding = 0x0f,
+ // New in DWARF v4:
+ LLVMDWARFUTFTypeEncoding = 0x10,
+ // New in DWARF v5:
+ LLVMDWARFUCSTypeEncoding = 0x11,
+ LLVMDWARFASCIITypeEncoding = 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..2e6662b09cb16c 100644
--- a/llvm/tools/llvm-c-test/debuginfo.c
+++ b/llvm/tools/llvm-c-test/debuginfo.c
@@ -70,8 +70,8 @@ int llvm_test_dibuilder(void) {
DIB, Module, "globalClass", 11, "", 0, File, 1, ClassTy, true,
GlobalClassValueExpr, NULL, 0);
- LLVMMetadataRef Int64Ty =
- LLVMDIBuilderCreateBasicType(DIB, "Int64", 5, 64, 0, LLVMDIFlagZero);
+ LLVMMetadataRef Int64Ty = LLVMDIBuilderCreateBasicType(
+ DIB, "Int64", 5, 64, LLVMDWARFSignedTypeEncoding, LLVMDIFlagZero);
LLVMMetadataRef Int64TypeDef =
LLVMDIBuilderCreateTypedef(DIB, Int64Ty, "int64_t", 7, File, 42, File, 0);
More information about the llvm-commits
mailing list