1 # Copyright 2021-2023 Free Software Foundation, Inc.
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 3 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16 # This test checks if GDB can identify bfloat16 and IEEE half float types and
17 # print them correctly.
21 # This test can only be run on targets which support DWARF-2 and use gas.
22 if {![dwarf2_support]} {
26 standard_testfile main.c -dw.S
28 # Make some DWARF for the test.
29 # 0x4049 is the equivalent of 3.141 for bfloat16.
30 # 0x4248 is the equivalent of 3.1406 for IEEE half float.
31 set asm_file [standard_output_file $srcfile2]
32 Dwarf::assemble $asm_file {
33 global srcdir subdir srcfile
37 {DW_AT_language @DW_LANG_C}
41 declare_labels bf16_type fp16_type \
44 bf16_type: DW_TAG_base_type {
46 {encoding @DW_ATE_float}
47 {DW_AT_byte_size 2 DW_FORM_sdata}
50 fp16_type: DW_TAG_base_type {
52 {encoding @DW_ATE_float}
53 {DW_AT_byte_size 2 DW_FORM_sdata}
56 bf16_var: DW_TAG_variable {
58 {DW_AT_type :${bf16_type}}
59 {DW_AT_const_value 0x4049 DW_FORM_sdata}
62 fp16_var: DW_TAG_variable {
64 {DW_AT_type :${fp16_type}}
65 {DW_AT_const_value 0x4248 DW_FORM_sdata}
71 if { [prepare_for_testing "failed to prepare" ${testfile} \
72 [list $srcfile $asm_file] {nodebug}] } {
80 # Make sure we can print both types correctly.
81 gdb_test "print bf16_1" " = 3.141"
82 gdb_test "print fp16_1" " = 3.1406"