[RS6000] dg-do !compile and scan-assembler
[official-gcc.git] / gcc / symtab-thunks.h
bloba23fc552950f9b9130caf90546915ec0b7f4f86b
1 /* Representation of thunks inside symbol table.
2 Copyright (C) 2003-2020 Free Software Foundation, Inc.
3 Contributed by Jan Hubicka
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 3, or (at your option) any later
10 version.
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */
21 #ifndef GCC_SYMTAB_THUNKS_H
22 #define GCC_SYMTAB_THUNKS_H
24 /* This symbol annotation holds information about thunk.
26 Thunks are basically wrappers around methods which are introduced in case
27 of multiple inheritance in order to adjust the value of the "this" pointer
28 or of the returned value.
30 In the case of this-adjusting thunks, each back-end can override the
31 can_output_mi_thunk/output_mi_thunk target hooks to generate a minimal thunk
32 (with a tail call for instance) directly as assembly. For the default hook
33 or for the case where the can_output_mi_thunk hooks return false, the thunk
34 is gimplified and lowered using the regular machinery. */
36 struct GTY(()) thunk_info {
37 /* Constructor. */
38 thunk_info ()
39 : fixed_offset (0),
40 virtual_value (0),
41 indirect_offset (0),
42 alias (NULL),
43 this_adjusting (false),
44 virtual_offset_p (false)
47 /* Copy constructor. */
48 thunk_info (const thunk_info &t)
49 : fixed_offset (t.fixed_offset),
50 virtual_value (t.virtual_value),
51 indirect_offset (t.indirect_offset),
52 alias (t.alias),
53 this_adjusting (t.this_adjusting),
54 virtual_offset_p (t.virtual_offset_p)
58 /* Compare for equiality. */
59 bool
60 operator==(const thunk_info &other) const
62 return fixed_offset == other.fixed_offset
63 && virtual_value == other.virtual_value
64 && indirect_offset == other.indirect_offset
65 && this_adjusting == other.this_adjusting
66 && virtual_offset_p == other.virtual_offset_p;
68 bool
69 operator!=(const thunk_info &other) const
71 return !(*this == other);
73 /* Copy operator. */
74 thunk_info &
75 operator=(const thunk_info &other)
77 fixed_offset = other.fixed_offset;
78 virtual_value = other.virtual_value;
79 indirect_offset = other.indirect_offset;
80 this_adjusting = other.this_adjusting;
81 virtual_offset_p = other.virtual_offset_p;
82 return *this;
85 /* Offset used to adjust "this". */
86 HOST_WIDE_INT fixed_offset;
88 /* Offset in the virtual table to get the offset to adjust "this". Valid iff
89 VIRTUAL_OFFSET_P is true. */
90 HOST_WIDE_INT virtual_value;
92 /* Offset from "this" to get the offset to adjust "this". Zero means: this
93 offset is to be ignored. */
94 HOST_WIDE_INT indirect_offset;
96 /* Thunk target, i.e. the method that this thunk wraps. Depending on the
97 TARGET_USE_LOCAL_THUNK_ALIAS_P macro, this may have to be a new alias. */
98 tree alias;
100 /* Nonzero for a "this" adjusting thunk and zero for a result adjusting
101 thunk. */
102 bool this_adjusting;
104 /* If true, this thunk is what we call a virtual thunk. In this case:
105 * for this-adjusting thunks, after the FIXED_OFFSET based adjustment is
106 done, add to the result the offset found in the vtable at:
107 vptr + VIRTUAL_VALUE
108 * for result-adjusting thunks, the FIXED_OFFSET adjustment is done after
109 the virtual one. */
110 bool virtual_offset_p;
114 /* Dump thunk_info. */
115 void dump (FILE *);
117 /* Stream out thunk_info. */
118 void stream_out (class lto_simple_output_block *);
120 /* Stream in trunk_info. */
121 void stream_in (class lto_input_block *);
123 hashval_t hash ();
127 /* Return thunk_info, if available. */
128 static thunk_info *get (cgraph_node *node);
130 /* Return thunk_info possibly creating new one. */
131 static thunk_info *get_create (cgraph_node *node);
133 /* Remove thunk_info. */
134 static void remove (cgraph_node *node);
136 /* Release all thunk_infos. */
137 static void release (void);
140 bool expand_thunk (cgraph_node *, bool, bool);
142 /* Return thunk_info, if available. */
143 inline thunk_info *
144 thunk_info::get (cgraph_node *node)
146 if (!symtab->m_thunks)
147 return NULL;
148 return symtab->m_thunks->get (node);
151 /* Remove thunk_info association for NODE. */
152 inline void
153 thunk_info::remove (cgraph_node *node)
155 symtab->m_thunks->remove (node);
158 /* Free thunk info summaries. */
159 inline void
160 thunk_info::release ()
162 if (symtab->m_thunks)
163 delete (symtab->m_thunks);
164 symtab->m_thunks = NULL;
166 #endif /* GCC_SYMTAB_THUNKS_H */