1 /* Function return value location for Linux/TILE-Gx ABI.
2 Copyright (C) 2012 Tilera Corporation
3 Copyright (C) 2014 Red Hat, Inc.
4 This file is part of elfutils.
6 This file is free software; you can redistribute it and/or modify
7 it under the terms of either
9 * the GNU Lesser General Public License as published by the Free
10 Software Foundation; either version 3 of the License, or (at
11 your option) any later version
15 * the GNU General Public License as published by the Free
16 Software Foundation; either version 2 of the License, or (at
17 your option) any later version
19 or both in parallel, as here.
21 elfutils is distributed in the hope that it will be useful, but
22 WITHOUT ANY WARRANTY; without even the implied warranty of
23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24 General Public License for more details.
26 You should have received copies of the GNU General Public License and
27 the GNU Lesser General Public License along with this program. If
28 not, see <http://www.gnu.org/licenses/>. */
38 #define BACKEND tilegx_
39 #include "libebl_CPU.h"
43 static const Dwarf_Op loc_intreg[] =
45 { .atom = DW_OP_reg0 }
49 /* The return value is a structure and is actually stored in stack space
50 passed in a hidden argument by the caller. But, the compiler
51 helpfully returns the address of that space in r0. */
52 static const Dwarf_Op loc_aggregate[] =
54 { .atom = DW_OP_breg0, .number = 0 }
56 #define nloc_aggregate 1
59 tilegx_return_value_location (Dwarf_Die *functypedie, const Dwarf_Op **locp)
61 /* Start with the function's type, and get the DW_AT_type attribute,
62 which is the type of the return value. */
63 Dwarf_Die die_mem, *typedie = &die_mem;
64 int tag = dwarf_peeled_die_type (functypedie, typedie);
74 case DW_TAG_subrange_type:
75 if (! dwarf_hasattr_integrate (typedie, DW_AT_byte_size))
77 Dwarf_Attribute attr_mem, *attr;
78 attr = dwarf_attr_integrate (typedie, DW_AT_type, &attr_mem);
79 typedie = dwarf_formref_die (attr, &die_mem);
80 tag = DWARF_TAG_OR_RETURN (typedie);
84 case DW_TAG_base_type:
85 case DW_TAG_enumeration_type:
86 case DW_TAG_pointer_type:
87 case DW_TAG_ptr_to_member_type:
89 Dwarf_Attribute attr_mem;
90 if (dwarf_formudata (dwarf_attr_integrate (typedie, DW_AT_byte_size,
91 &attr_mem), &size) != 0)
93 if (tag == DW_TAG_pointer_type || tag == DW_TAG_ptr_to_member_type)
98 if (tag == DW_TAG_base_type)
101 if (dwarf_formudata (dwarf_attr_integrate (typedie, DW_AT_encoding,
108 /* Small enough structs are passed directly in registers R0 ... R7. */
116 /* Else fall through. */
117 case DW_TAG_structure_type:
118 case DW_TAG_class_type:
119 case DW_TAG_union_type:
121 *locp = loc_aggregate;
122 return nloc_aggregate;
124 case DW_TAG_array_type:
125 case DW_TAG_string_type:
126 if (dwarf_aggregate_size (typedie, &size) == 0 && size <= 8)
128 if (tag == DW_TAG_array_type)
130 Dwarf_Attribute attr_mem, *attr;
131 /* Check if it's a character array. */
132 attr = dwarf_attr_integrate (typedie, DW_AT_type, &attr_mem);
133 typedie = dwarf_formref_die (attr, &die_mem);
134 tag = DWARF_TAG_OR_RETURN (typedie);
135 if (tag != DW_TAG_base_type)
137 if (dwarf_formudata (dwarf_attr_integrate (typedie,
150 /* XXX We don't have a good way to return specific errors from ebl calls.
151 This value means we do not understand the type, but it is well-formed
152 DWARF and might be valid. */