rustc_codegen_llvm/debuginfo/dwarf_const.rs
1//! Definitions of various DWARF-related constants.
2
3use libc::c_uint;
4
5/// Helper macro to let us redeclare gimli's constants as our own constants
6/// with a different type, with less risk of copy-paste errors.
7macro_rules! declare_constant {
8 (
9 $name:ident : $type:ty
10 ) => {
11 #[allow(non_upper_case_globals)]
12 pub(crate) const $name: $type = ::gimli::constants::$name.0 as $type;
13
14 // Assert that as-cast probably hasn't changed the value.
15 const _: () = assert!($name as i128 == ::gimli::constants::$name.0 as i128);
16 };
17}
18
19declare_constant!(DW_TAG_const_type: c_uint);
20
21// DWARF languages.
22declare_constant!(DW_LANG_Rust: c_uint);
23
24// DWARF attribute type encodings.
25declare_constant!(DW_ATE_boolean: c_uint);
26declare_constant!(DW_ATE_float: c_uint);
27declare_constant!(DW_ATE_signed: c_uint);
28declare_constant!(DW_ATE_unsigned: c_uint);
29declare_constant!(DW_ATE_UTF: c_uint);
30
31// DWARF expression operators.
32declare_constant!(DW_OP_deref: u64);
33declare_constant!(DW_OP_plus_uconst: u64);
34/// Defined by LLVM in `llvm/include/llvm/BinaryFormat/Dwarf.h`.
35/// Double-checked by a static assertion in `RustWrapper.cpp`.
36#[allow(non_upper_case_globals)]
37pub(crate) const DW_OP_LLVM_fragment: u64 = 0x1000;