about summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm/src/debuginfo/dwarf_const.rs
diff options
context:
space:
mode:
authorJakub Beránek <berykubik@gmail.com>2025-01-08 13:40:53 +0100
committerJakub Beránek <berykubik@gmail.com>2025-01-08 13:40:53 +0100
commit2f3ee5dae58447454bcf2d2c8bb40577e87a3c1b (patch)
tree62f9293b25cc5f9af35d2338559afb224b00a719 /compiler/rustc_codegen_llvm/src/debuginfo/dwarf_const.rs
parenta5e424e07af577c87d46e5eddc1c3a1eb014d343 (diff)
parent93a19501c2bad56e73f0ac9f3ae062b614d30832 (diff)
downloadrust-2f3ee5dae58447454bcf2d2c8bb40577e87a3c1b.tar.gz
rust-2f3ee5dae58447454bcf2d2c8bb40577e87a3c1b.zip
Merge from rustc
Diffstat (limited to 'compiler/rustc_codegen_llvm/src/debuginfo/dwarf_const.rs')
-rw-r--r--compiler/rustc_codegen_llvm/src/debuginfo/dwarf_const.rs37
1 files changed, 37 insertions, 0 deletions
diff --git a/compiler/rustc_codegen_llvm/src/debuginfo/dwarf_const.rs b/compiler/rustc_codegen_llvm/src/debuginfo/dwarf_const.rs
new file mode 100644
index 00000000000..40842915222
--- /dev/null
+++ b/compiler/rustc_codegen_llvm/src/debuginfo/dwarf_const.rs
@@ -0,0 +1,37 @@
+//! Definitions of various DWARF-related constants.
+
+use libc::c_uint;
+
+/// Helper macro to let us redeclare gimli's constants as our own constants
+/// with a different type, with less risk of copy-paste errors.
+macro_rules! declare_constant {
+    (
+        $name:ident : $type:ty
+    ) => {
+        #[allow(non_upper_case_globals)]
+        pub(crate) const $name: $type = ::gimli::constants::$name.0 as $type;
+
+        // Assert that as-cast probably hasn't changed the value.
+        const _: () = assert!($name as i128 == ::gimli::constants::$name.0 as i128);
+    };
+}
+
+declare_constant!(DW_TAG_const_type: c_uint);
+
+// DWARF languages.
+declare_constant!(DW_LANG_Rust: c_uint);
+
+// DWARF attribute type encodings.
+declare_constant!(DW_ATE_boolean: c_uint);
+declare_constant!(DW_ATE_float: c_uint);
+declare_constant!(DW_ATE_signed: c_uint);
+declare_constant!(DW_ATE_unsigned: c_uint);
+declare_constant!(DW_ATE_UTF: c_uint);
+
+// DWARF expression operators.
+declare_constant!(DW_OP_deref: u64);
+declare_constant!(DW_OP_plus_uconst: u64);
+/// Defined by LLVM in `llvm/include/llvm/BinaryFormat/Dwarf.h`.
+/// Double-checked by a static assertion in `RustWrapper.cpp`.
+#[allow(non_upper_case_globals)]
+pub(crate) const DW_OP_LLVM_fragment: u64 = 0x1000;