/*
 * Copyright (c) 2023 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

// TODO: Add other DW-based macros.
#if !(                                                                         \
    defined DW_TAG || defined DW_AT || defined DW_FORM || \
    defined DW_OP || defined DW_LANG || defined DW_ATE)
#error "Missing definition of DW*"
#endif

#ifndef DW_TAG
#define DW_TAG(ID, NAME)
#endif

#ifndef DW_AT
#define DW_AT(ID, NAME)
#endif

#ifndef DW_FORM
#define DW_FORM(ID, NAME)
#endif

#ifndef DW_OP
#define DW_OP(ID, NAME)
#endif

#ifndef DW_LANG
#define DW_LANG(ID, NAME, LOWER_BOUND)
#endif

#ifndef DW_ATE
#define DW_ATE(ID, NAME)
#endif

// Tag
DW_TAG(0x0000, null)
DW_TAG(0x0001, array_type)
DW_TAG(0x0002, class_type)
DW_TAG(0x0004, enumeration_type)
DW_TAG(0x0005, formal_parameter)
DW_TAG(0x000a, label)
DW_TAG(0x000b, lexical_block)
DW_TAG(0x000d, member)
DW_TAG(0x000f, pointer_type)
DW_TAG(0x0011, compile_unit)
DW_TAG(0x0013, structure_type)
DW_TAG(0x0015, subroutine_type)
DW_TAG(0x0016, typedef)
DW_TAG(0x0017, union_type)
DW_TAG(0x0018, unspecified_parameters)
DW_TAG(0x001c, inheritance)
DW_TAG(0x0021, subrange_type)
DW_TAG(0x0024, base_type)
DW_TAG(0x0026, const_type)
DW_TAG(0x0028, enumerator)
DW_TAG(0x002e, subprogram)
DW_TAG(0x0034, variable)
DW_TAG(0x0035, volatile_type)
// New in DWARF v3
DW_TAG(0x0038, interface_type)

// Attributes
DW_AT(0x01, sibling)
DW_AT(0x02, location)
DW_AT(0x03, name)
DW_AT(0x0b, byte_size)
DW_AT(0x0c, bit_offset)
DW_AT(0x0d, bit_size)
DW_AT(0x10, stmt_list)
DW_AT(0x11, low_pc)
DW_AT(0x12, high_pc)
DW_AT(0x13, language)
DW_AT(0x1b, comp_dir)
DW_AT(0x1c, const_value)
DW_AT(0x25, producer)
DW_AT(0x27, prototyped)
DW_AT(0x2f, upper_bound)
DW_AT(0x32, accessibility)
DW_AT(0x38, data_member_location)
DW_AT(0x39, decl_column)
DW_AT(0x3a, decl_file)
DW_AT(0x3b, decl_line)
DW_AT(0x3e, encoding)
DW_AT(0x3f, external)
DW_AT(0x40, frame_base)
DW_AT(0x47, specification)
DW_AT(0x49, type)
// New in DWARF v3
DW_AT(0x64, object_pointer)
// New in DWARF v5
DW_AT(0x8a, deleted)
// Vendor extensions
DW_AT (0x2116, GNU_all_tail_call_sites)

// Attribute form encodings
DW_FORM(0x01, addr)
DW_FORM(0x05, data2)
DW_FORM(0x06, data4)
DW_FORM(0x07, data8)
DW_FORM(0x08, string)
DW_FORM(0x0b, data1)
DW_FORM(0x0c, flag)
DW_FORM(0x0e, strp)
DW_FORM(0x10, ref_addr)
DW_FORM(0x11, ref1)
DW_FORM(0x12, ref2)
DW_FORM(0x13, ref4)
DW_FORM(0x14, ref8)
// New in DWARF v4
DW_FORM(0x17, sec_offset)
DW_FORM(0x18, exprloc)
DW_FORM(0x19, flag_present)
// This was defined out of sequence.
DW_FORM(0x20, ref_sig8)
// Alternate debug sections proposal (output of "dwz" tool).
DW_FORM(0x1f20, GNU_ref_alt)
DW_FORM(0x1f21, GNU_strp_alt)

// DWARF Expression operators.
DW_OP(0x03, addr)
DW_OP(0x70, breg0)
DW_OP(0x71, breg1)
DW_OP(0x72, breg2)
DW_OP(0x73, breg3)
DW_OP(0x74, breg4)
DW_OP(0x75, breg5)
DW_OP(0x76, breg6)
DW_OP(0x77, breg7)
DW_OP(0x91, fbreg)
// New in DWARF v3
DW_OP(0x9c, call_frame_cfa)

// DWARF languages.
DW_LANG(0x000c, C99, 0)

// DWARF attribute type encodings.
DW_ATE(0x01, address)
DW_ATE(0x02, boolean)
DW_ATE(0x03, complex_float)
DW_ATE(0x04, float)
DW_ATE(0x05, signed)
DW_ATE(0x06, signed_char)
DW_ATE(0x07, unsigned)
DW_ATE(0x08, unsigned_char)

#undef DW_TAG
#undef DW_AT
#undef DW_FORM
#undef DW_OP
#undef DW_LANG
#undef DW_ATE
