]>
Commit | Line | Data |
---|---|---|
2e4b9b8c | 1 | /* Dwarf2 assembler output helper routines. |
3895ec53 | 2 | Copyright (C) 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010 |
66647d44 | 3 | Free Software Foundation, Inc. |
2e4b9b8c | 4 | |
1322177d | 5 | This file is part of GCC. |
2e4b9b8c | 6 | |
1322177d LB |
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 | |
9dcd6f09 | 9 | Software Foundation; either version 3, or (at your option) any later |
1322177d | 10 | version. |
2e4b9b8c | 11 | |
1322177d LB |
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. | |
2e4b9b8c RH |
16 | |
17 | You should have received a copy of the GNU General Public License | |
9dcd6f09 NC |
18 | along with GCC; see the file COPYING3. If not see |
19 | <http://www.gnu.org/licenses/>. */ | |
2e4b9b8c RH |
20 | |
21 | ||
22 | #include "config.h" | |
23 | #include "system.h" | |
4977bab6 ZW |
24 | #include "coretypes.h" |
25 | #include "tm.h" | |
2e4b9b8c | 26 | #include "flags.h" |
2a1ee410 | 27 | #include "tree.h" |
2e4b9b8c RH |
28 | #include "rtl.h" |
29 | #include "output.h" | |
301d03af | 30 | #include "target.h" |
2e4b9b8c | 31 | #include "dwarf2asm.h" |
a80b0574 | 32 | #include "dwarf2.h" |
2a1ee410 RH |
33 | #include "splay-tree.h" |
34 | #include "ggc.h" | |
2e4b9b8c RH |
35 | #include "tm_p.h" |
36 | ||
37 | ||
38 | /* How to start an assembler comment. */ | |
39 | #ifndef ASM_COMMENT_START | |
40 | #define ASM_COMMENT_START ";#" | |
41 | #endif | |
42 | ||
2e4b9b8c | 43 | \f |
301d03af RS |
44 | /* Output an unaligned integer with the given value and size. Prefer not |
45 | to print a newline, since the caller may want to add a comment. */ | |
46 | ||
47 | void | |
7080f735 | 48 | dw2_assemble_integer (int size, rtx x) |
2e4b9b8c | 49 | { |
301d03af RS |
50 | const char *op = integer_asm_op (size, FALSE); |
51 | ||
52 | if (op) | |
2e4b9b8c | 53 | { |
301d03af | 54 | fputs (op, asm_out_file); |
481683e1 | 55 | if (CONST_INT_P (x)) |
3d57d7ce DK |
56 | fprintf (asm_out_file, HOST_WIDE_INT_PRINT_HEX, |
57 | (unsigned HOST_WIDE_INT) INTVAL (x)); | |
301d03af RS |
58 | else |
59 | output_addr_const (asm_out_file, x); | |
2e4b9b8c | 60 | } |
301d03af RS |
61 | else |
62 | assemble_integer (x, size, BITS_PER_UNIT, 1); | |
2e4b9b8c | 63 | } |
3a538a66 | 64 | |
2e4b9b8c | 65 | |
d4ea4622 RH |
66 | /* Output a value of a given size in target byte order. */ |
67 | ||
68 | void | |
69 | dw2_asm_output_data_raw (int size, unsigned HOST_WIDE_INT value) | |
70 | { | |
71 | unsigned char bytes[8]; | |
72 | int i; | |
73 | ||
74 | for (i = 0; i < 8; ++i) | |
75 | { | |
76 | bytes[i] = value & 0xff; | |
77 | value >>= 8; | |
78 | } | |
79 | ||
80 | if (BYTES_BIG_ENDIAN) | |
81 | { | |
82 | for (i = size - 1; i > 0; --i) | |
a3f1cee4 UB |
83 | fprintf (asm_out_file, "%#x,", bytes[i]); |
84 | fprintf (asm_out_file, "%#x", bytes[0]); | |
d4ea4622 RH |
85 | } |
86 | else | |
87 | { | |
88 | for (i = 0; i < size - 1; ++i) | |
a3f1cee4 UB |
89 | fprintf (asm_out_file, "%#x,", bytes[i]); |
90 | fprintf (asm_out_file, "%#x", bytes[i]); | |
d4ea4622 RH |
91 | } |
92 | } | |
93 | ||
105f48ae | 94 | /* Output an immediate constant in a given SIZE in bytes. */ |
8e7fa2c8 | 95 | |
2e4b9b8c | 96 | void |
e34d07f2 KG |
97 | dw2_asm_output_data (int size, unsigned HOST_WIDE_INT value, |
98 | const char *comment, ...) | |
2e4b9b8c | 99 | { |
e34d07f2 | 100 | va_list ap; |
d61772b2 | 101 | const char *op = integer_asm_op (size, FALSE); |
7080f735 | 102 | |
e34d07f2 | 103 | va_start (ap, comment); |
2e4b9b8c | 104 | |
da6af203 | 105 | if (size * 8 < HOST_BITS_PER_WIDE_INT) |
c4f2c499 | 106 | value &= ~(~(unsigned HOST_WIDE_INT) 0 << (size * 8)); |
da6af203 | 107 | |
d61772b2 GK |
108 | if (op) |
109 | fprintf (asm_out_file, "%s" HOST_WIDE_INT_PRINT_HEX, op, value); | |
110 | else | |
111 | assemble_integer (GEN_INT (value), size, BITS_PER_UNIT, 1); | |
2e4b9b8c RH |
112 | |
113 | if (flag_debug_asm && comment) | |
114 | { | |
115 | fprintf (asm_out_file, "\t%s ", ASM_COMMENT_START); | |
116 | vfprintf (asm_out_file, comment, ap); | |
117 | } | |
118 | fputc ('\n', asm_out_file); | |
119 | ||
e34d07f2 | 120 | va_end (ap); |
2e4b9b8c RH |
121 | } |
122 | ||
8e7fa2c8 RH |
123 | /* Output the difference between two symbols in a given size. */ |
124 | /* ??? There appear to be assemblers that do not like such | |
125 | subtraction, but do support ASM_SET_OP. It's unfortunately | |
126 | impossible to do here, since the ASM_SET_OP for the difference | |
127 | symbol must appear after both symbols are defined. */ | |
128 | ||
2e4b9b8c | 129 | void |
e34d07f2 KG |
130 | dw2_asm_output_delta (int size, const char *lab1, const char *lab2, |
131 | const char *comment, ...) | |
2e4b9b8c | 132 | { |
e34d07f2 | 133 | va_list ap; |
7080f735 | 134 | |
e34d07f2 | 135 | va_start (ap, comment); |
2e4b9b8c | 136 | |
7606e68f SS |
137 | #ifdef ASM_OUTPUT_DWARF_DELTA |
138 | ASM_OUTPUT_DWARF_DELTA (asm_out_file, size, lab1, lab2); | |
139 | #else | |
301d03af RS |
140 | dw2_assemble_integer (size, |
141 | gen_rtx_MINUS (Pmode, | |
142 | gen_rtx_SYMBOL_REF (Pmode, lab1), | |
143 | gen_rtx_SYMBOL_REF (Pmode, lab2))); | |
7606e68f | 144 | #endif |
2e4b9b8c RH |
145 | if (flag_debug_asm && comment) |
146 | { | |
147 | fprintf (asm_out_file, "\t%s ", ASM_COMMENT_START); | |
148 | vfprintf (asm_out_file, comment, ap); | |
149 | } | |
150 | fputc ('\n', asm_out_file); | |
151 | ||
e34d07f2 | 152 | va_end (ap); |
2e4b9b8c RH |
153 | } |
154 | ||
67ad2ae7 DR |
155 | /* Output the difference between two symbols in instruction units |
156 | in a given size. */ | |
157 | ||
158 | void | |
159 | dw2_asm_output_vms_delta (int size ATTRIBUTE_UNUSED, | |
160 | const char *lab1, const char *lab2, | |
161 | const char *comment, ...) | |
162 | { | |
163 | va_list ap; | |
164 | ||
165 | va_start (ap, comment); | |
166 | ||
167 | #ifndef ASM_OUTPUT_DWARF_VMS_DELTA | |
168 | /* VMS Delta is only special on ia64-vms, but this funtion also gets | |
169 | called on alpha-vms so it has to do something sane. */ | |
170 | dw2_asm_output_delta (size, lab1, lab2, comment); | |
171 | #else | |
172 | ASM_OUTPUT_DWARF_VMS_DELTA (asm_out_file, size, lab1, lab2); | |
173 | if (flag_debug_asm && comment) | |
174 | { | |
175 | fprintf (asm_out_file, "\t%s ", ASM_COMMENT_START); | |
176 | vfprintf (asm_out_file, comment, ap); | |
177 | } | |
178 | fputc ('\n', asm_out_file); | |
179 | #endif | |
180 | ||
181 | va_end (ap); | |
182 | } | |
183 | ||
192d0f89 GK |
184 | /* Output a section-relative reference to a LABEL, which was placed in |
185 | BASE. In general this can only be done for debugging symbols. | |
186 | E.g. on most targets with the GNU linker, this is accomplished with | |
187 | a direct reference and the knowledge that the debugging section | |
188 | will be placed at VMA 0. Some targets have special relocations for | |
189 | this that we must use. */ | |
8e7fa2c8 | 190 | |
2e4b9b8c | 191 | void |
79252435 SB |
192 | dw2_asm_output_offset (int size, const char *label, |
193 | section *base ATTRIBUTE_UNUSED, | |
e34d07f2 | 194 | const char *comment, ...) |
2e4b9b8c | 195 | { |
e34d07f2 | 196 | va_list ap; |
7080f735 | 197 | |
e34d07f2 | 198 | va_start (ap, comment); |
2e4b9b8c | 199 | |
8e7fa2c8 | 200 | #ifdef ASM_OUTPUT_DWARF_OFFSET |
192d0f89 | 201 | ASM_OUTPUT_DWARF_OFFSET (asm_out_file, size, label, base); |
8e7fa2c8 | 202 | #else |
301d03af | 203 | dw2_assemble_integer (size, gen_rtx_SYMBOL_REF (Pmode, label)); |
2e4b9b8c RH |
204 | #endif |
205 | ||
206 | if (flag_debug_asm && comment) | |
207 | { | |
208 | fprintf (asm_out_file, "\t%s ", ASM_COMMENT_START); | |
209 | vfprintf (asm_out_file, comment, ap); | |
210 | } | |
211 | fputc ('\n', asm_out_file); | |
212 | ||
e34d07f2 | 213 | va_end (ap); |
2e4b9b8c RH |
214 | } |
215 | ||
c8f4fe99 BE |
216 | #if 0 |
217 | ||
8e7fa2c8 RH |
218 | /* Output a self-relative reference to a label, possibly in a |
219 | different section or object file. */ | |
220 | ||
2e4b9b8c | 221 | void |
e34d07f2 KG |
222 | dw2_asm_output_pcrel (int size ATTRIBUTE_UNUSED, |
223 | const char *label ATTRIBUTE_UNUSED, | |
224 | const char *comment, ...) | |
2e4b9b8c | 225 | { |
e34d07f2 | 226 | va_list ap; |
7080f735 | 227 | |
e34d07f2 | 228 | va_start (ap, comment); |
2e4b9b8c | 229 | |
8e7fa2c8 RH |
230 | #ifdef ASM_OUTPUT_DWARF_PCREL |
231 | ASM_OUTPUT_DWARF_PCREL (asm_out_file, size, label); | |
232 | #else | |
301d03af RS |
233 | dw2_assemble_integer (size, |
234 | gen_rtx_MINUS (Pmode, | |
235 | gen_rtx_SYMBOL_REF (Pmode, label), | |
236 | pc_rtx)); | |
8e7fa2c8 RH |
237 | #endif |
238 | ||
239 | if (flag_debug_asm && comment) | |
240 | { | |
241 | fprintf (asm_out_file, "\t%s ", ASM_COMMENT_START); | |
242 | vfprintf (asm_out_file, comment, ap); | |
243 | } | |
244 | fputc ('\n', asm_out_file); | |
245 | ||
e34d07f2 | 246 | va_end (ap); |
8e7fa2c8 | 247 | } |
c8f4fe99 | 248 | #endif /* 0 */ |
8e7fa2c8 RH |
249 | |
250 | /* Output an absolute reference to a label. */ | |
251 | ||
252 | void | |
e34d07f2 KG |
253 | dw2_asm_output_addr (int size, const char *label, |
254 | const char *comment, ...) | |
8e7fa2c8 | 255 | { |
e34d07f2 | 256 | va_list ap; |
7080f735 | 257 | |
e34d07f2 | 258 | va_start (ap, comment); |
8e7fa2c8 | 259 | |
301d03af | 260 | dw2_assemble_integer (size, gen_rtx_SYMBOL_REF (Pmode, label)); |
2e4b9b8c RH |
261 | |
262 | if (flag_debug_asm && comment) | |
263 | { | |
264 | fprintf (asm_out_file, "\t%s ", ASM_COMMENT_START); | |
265 | vfprintf (asm_out_file, comment, ap); | |
266 | } | |
267 | fputc ('\n', asm_out_file); | |
268 | ||
e34d07f2 | 269 | va_end (ap); |
2e4b9b8c RH |
270 | } |
271 | ||
8e7fa2c8 RH |
272 | /* Similar, but use an RTX expression instead of a text label. */ |
273 | ||
2e4b9b8c | 274 | void |
e34d07f2 KG |
275 | dw2_asm_output_addr_rtx (int size, rtx addr, |
276 | const char *comment, ...) | |
2e4b9b8c | 277 | { |
e34d07f2 | 278 | va_list ap; |
7080f735 | 279 | |
e34d07f2 | 280 | va_start (ap, comment); |
2e4b9b8c | 281 | |
301d03af | 282 | dw2_assemble_integer (size, addr); |
2e4b9b8c RH |
283 | |
284 | if (flag_debug_asm && comment) | |
285 | { | |
286 | fprintf (asm_out_file, "\t%s ", ASM_COMMENT_START); | |
287 | vfprintf (asm_out_file, comment, ap); | |
288 | } | |
289 | fputc ('\n', asm_out_file); | |
290 | ||
e34d07f2 | 291 | va_end (ap); |
2e4b9b8c RH |
292 | } |
293 | ||
1e290ba1 JB |
294 | /* Output the first ORIG_LEN characters of STR as a string. |
295 | If ORIG_LEN is equal to -1, ignore this parameter and output | |
296 | the entire STR instead. | |
297 | If COMMENT is not NULL and comments in the debug information | |
298 | have been requested by the user, append the given COMMENT | |
299 | to the generated output. */ | |
b8698a0f | 300 | |
2e4b9b8c | 301 | void |
e34d07f2 KG |
302 | dw2_asm_output_nstring (const char *str, size_t orig_len, |
303 | const char *comment, ...) | |
2e4b9b8c | 304 | { |
7a75edb7 | 305 | size_t i, len; |
e34d07f2 | 306 | va_list ap; |
2e4b9b8c | 307 | |
e34d07f2 | 308 | va_start (ap, comment); |
2e4b9b8c | 309 | |
7a75edb7 | 310 | len = orig_len; |
2e4b9b8c RH |
311 | |
312 | if (len == (size_t) -1) | |
313 | len = strlen (str); | |
314 | ||
315 | if (flag_debug_asm && comment) | |
316 | { | |
317 | fputs ("\t.ascii \"", asm_out_file); | |
318 | for (i = 0; i < len; i++) | |
319 | { | |
320 | int c = str[i]; | |
321 | if (c == '\"' || c == '\\') | |
322 | fputc ('\\', asm_out_file); | |
323 | if (ISPRINT(c)) | |
324 | fputc (c, asm_out_file); | |
325 | else | |
326 | fprintf (asm_out_file, "\\%o", c); | |
327 | } | |
328 | fprintf (asm_out_file, "\\0\"\t%s ", ASM_COMMENT_START); | |
329 | vfprintf (asm_out_file, comment, ap); | |
330 | fputc ('\n', asm_out_file); | |
331 | } | |
332 | else | |
333 | { | |
334 | /* If an explicit length was given, we can't assume there | |
335 | is a null termination in the string buffer. */ | |
336 | if (orig_len == (size_t) -1) | |
337 | len += 1; | |
338 | ASM_OUTPUT_ASCII (asm_out_file, str, len); | |
339 | if (orig_len != (size_t) -1) | |
301d03af | 340 | assemble_integer (const0_rtx, 1, BITS_PER_UNIT, 1); |
2e4b9b8c RH |
341 | } |
342 | ||
e34d07f2 | 343 | va_end (ap); |
2e4b9b8c RH |
344 | } |
345 | \f | |
346 | ||
347 | /* Return the size of an unsigned LEB128 quantity. */ | |
348 | ||
349 | int | |
7080f735 | 350 | size_of_uleb128 (unsigned HOST_WIDE_INT value) |
2e4b9b8c | 351 | { |
4977bab6 | 352 | int size = 0; |
2e4b9b8c RH |
353 | |
354 | do | |
355 | { | |
2e4b9b8c RH |
356 | value >>= 7; |
357 | size += 1; | |
358 | } | |
359 | while (value != 0); | |
360 | ||
361 | return size; | |
362 | } | |
363 | ||
364 | /* Return the size of a signed LEB128 quantity. */ | |
365 | ||
366 | int | |
7080f735 | 367 | size_of_sleb128 (HOST_WIDE_INT value) |
2e4b9b8c RH |
368 | { |
369 | int size = 0, byte; | |
370 | ||
371 | do | |
372 | { | |
373 | byte = (value & 0x7f); | |
374 | value >>= 7; | |
375 | size += 1; | |
376 | } | |
377 | while (!((value == 0 && (byte & 0x40) == 0) | |
378 | || (value == -1 && (byte & 0x40) != 0))); | |
379 | ||
380 | return size; | |
381 | } | |
382 | ||
b627d6fe | 383 | /* Given an encoding, return the number of bytes the format occupies. |
3a538a66 | 384 | This is only defined for fixed-size encodings, and so does not |
b627d6fe RH |
385 | include leb128. */ |
386 | ||
387 | int | |
7080f735 | 388 | size_of_encoded_value (int encoding) |
b627d6fe RH |
389 | { |
390 | if (encoding == DW_EH_PE_omit) | |
391 | return 0; | |
392 | ||
393 | switch (encoding & 0x07) | |
394 | { | |
395 | case DW_EH_PE_absptr: | |
396 | return POINTER_SIZE / BITS_PER_UNIT; | |
397 | case DW_EH_PE_udata2: | |
398 | return 2; | |
399 | case DW_EH_PE_udata4: | |
400 | return 4; | |
401 | case DW_EH_PE_udata8: | |
402 | return 8; | |
ced3f397 NS |
403 | default: |
404 | gcc_unreachable (); | |
b627d6fe | 405 | } |
b627d6fe RH |
406 | } |
407 | ||
e1f9550a RH |
408 | /* Yield a name for a given pointer encoding. */ |
409 | ||
410 | const char * | |
7080f735 | 411 | eh_data_format_name (int format) |
e1f9550a RH |
412 | { |
413 | #if HAVE_DESIGNATED_INITIALIZERS | |
414 | #define S(p, v) [p] = v, | |
415 | #else | |
416 | #define S(p, v) case p: return v; | |
417 | #endif | |
418 | ||
419 | #if HAVE_DESIGNATED_INITIALIZERS | |
420 | __extension__ static const char * const format_names[256] = { | |
421 | #else | |
422 | switch (format) { | |
423 | #endif | |
424 | ||
425 | S(DW_EH_PE_absptr, "absolute") | |
426 | S(DW_EH_PE_omit, "omit") | |
099c8b17 | 427 | S(DW_EH_PE_aligned, "aligned absolute") |
e1f9550a RH |
428 | |
429 | S(DW_EH_PE_uleb128, "uleb128") | |
430 | S(DW_EH_PE_udata2, "udata2") | |
431 | S(DW_EH_PE_udata4, "udata4") | |
432 | S(DW_EH_PE_udata8, "udata8") | |
433 | S(DW_EH_PE_sleb128, "sleb128") | |
434 | S(DW_EH_PE_sdata2, "sdata2") | |
435 | S(DW_EH_PE_sdata4, "sdata4") | |
436 | S(DW_EH_PE_sdata8, "sdata8") | |
437 | ||
f90811a2 | 438 | S(DW_EH_PE_absptr | DW_EH_PE_pcrel, "pcrel") |
e1f9550a RH |
439 | S(DW_EH_PE_uleb128 | DW_EH_PE_pcrel, "pcrel uleb128") |
440 | S(DW_EH_PE_udata2 | DW_EH_PE_pcrel, "pcrel udata2") | |
441 | S(DW_EH_PE_udata4 | DW_EH_PE_pcrel, "pcrel udata4") | |
442 | S(DW_EH_PE_udata8 | DW_EH_PE_pcrel, "pcrel udata8") | |
443 | S(DW_EH_PE_sleb128 | DW_EH_PE_pcrel, "pcrel sleb128") | |
444 | S(DW_EH_PE_sdata2 | DW_EH_PE_pcrel, "pcrel sdata2") | |
445 | S(DW_EH_PE_sdata4 | DW_EH_PE_pcrel, "pcrel sdata4") | |
446 | S(DW_EH_PE_sdata8 | DW_EH_PE_pcrel, "pcrel sdata8") | |
447 | ||
f90811a2 | 448 | S(DW_EH_PE_absptr | DW_EH_PE_textrel, "textrel") |
e1f9550a RH |
449 | S(DW_EH_PE_uleb128 | DW_EH_PE_textrel, "textrel uleb128") |
450 | S(DW_EH_PE_udata2 | DW_EH_PE_textrel, "textrel udata2") | |
451 | S(DW_EH_PE_udata4 | DW_EH_PE_textrel, "textrel udata4") | |
452 | S(DW_EH_PE_udata8 | DW_EH_PE_textrel, "textrel udata8") | |
453 | S(DW_EH_PE_sleb128 | DW_EH_PE_textrel, "textrel sleb128") | |
454 | S(DW_EH_PE_sdata2 | DW_EH_PE_textrel, "textrel sdata2") | |
455 | S(DW_EH_PE_sdata4 | DW_EH_PE_textrel, "textrel sdata4") | |
456 | S(DW_EH_PE_sdata8 | DW_EH_PE_textrel, "textrel sdata8") | |
457 | ||
f90811a2 | 458 | S(DW_EH_PE_absptr | DW_EH_PE_datarel, "datarel") |
e1f9550a RH |
459 | S(DW_EH_PE_uleb128 | DW_EH_PE_datarel, "datarel uleb128") |
460 | S(DW_EH_PE_udata2 | DW_EH_PE_datarel, "datarel udata2") | |
461 | S(DW_EH_PE_udata4 | DW_EH_PE_datarel, "datarel udata4") | |
462 | S(DW_EH_PE_udata8 | DW_EH_PE_datarel, "datarel udata8") | |
463 | S(DW_EH_PE_sleb128 | DW_EH_PE_datarel, "datarel sleb128") | |
464 | S(DW_EH_PE_sdata2 | DW_EH_PE_datarel, "datarel sdata2") | |
465 | S(DW_EH_PE_sdata4 | DW_EH_PE_datarel, "datarel sdata4") | |
466 | S(DW_EH_PE_sdata8 | DW_EH_PE_datarel, "datarel sdata8") | |
467 | ||
f90811a2 | 468 | S(DW_EH_PE_absptr | DW_EH_PE_funcrel, "funcrel") |
e1f9550a RH |
469 | S(DW_EH_PE_uleb128 | DW_EH_PE_funcrel, "funcrel uleb128") |
470 | S(DW_EH_PE_udata2 | DW_EH_PE_funcrel, "funcrel udata2") | |
471 | S(DW_EH_PE_udata4 | DW_EH_PE_funcrel, "funcrel udata4") | |
472 | S(DW_EH_PE_udata8 | DW_EH_PE_funcrel, "funcrel udata8") | |
473 | S(DW_EH_PE_sleb128 | DW_EH_PE_funcrel, "funcrel sleb128") | |
474 | S(DW_EH_PE_sdata2 | DW_EH_PE_funcrel, "funcrel sdata2") | |
475 | S(DW_EH_PE_sdata4 | DW_EH_PE_funcrel, "funcrel sdata4") | |
476 | S(DW_EH_PE_sdata8 | DW_EH_PE_funcrel, "funcrel sdata8") | |
477 | ||
49576e25 RS |
478 | S(DW_EH_PE_indirect | DW_EH_PE_absptr, "indirect absolute") |
479 | ||
f90811a2 RH |
480 | S(DW_EH_PE_indirect | DW_EH_PE_absptr | DW_EH_PE_pcrel, |
481 | "indirect pcrel") | |
e1f9550a RH |
482 | S(DW_EH_PE_indirect | DW_EH_PE_uleb128 | DW_EH_PE_pcrel, |
483 | "indirect pcrel uleb128") | |
484 | S(DW_EH_PE_indirect | DW_EH_PE_udata2 | DW_EH_PE_pcrel, | |
485 | "indirect pcrel udata2") | |
486 | S(DW_EH_PE_indirect | DW_EH_PE_udata4 | DW_EH_PE_pcrel, | |
487 | "indirect pcrel udata4") | |
488 | S(DW_EH_PE_indirect | DW_EH_PE_udata8 | DW_EH_PE_pcrel, | |
489 | "indirect pcrel udata8") | |
490 | S(DW_EH_PE_indirect | DW_EH_PE_sleb128 | DW_EH_PE_pcrel, | |
491 | "indirect pcrel sleb128") | |
492 | S(DW_EH_PE_indirect | DW_EH_PE_sdata2 | DW_EH_PE_pcrel, | |
493 | "indirect pcrel sdata2") | |
494 | S(DW_EH_PE_indirect | DW_EH_PE_sdata4 | DW_EH_PE_pcrel, | |
495 | "indirect pcrel sdata4") | |
496 | S(DW_EH_PE_indirect | DW_EH_PE_sdata8 | DW_EH_PE_pcrel, | |
497 | "indirect pcrel sdata8") | |
498 | ||
f90811a2 RH |
499 | S(DW_EH_PE_indirect | DW_EH_PE_absptr | DW_EH_PE_textrel, |
500 | "indirect textrel") | |
e1f9550a RH |
501 | S(DW_EH_PE_indirect | DW_EH_PE_uleb128 | DW_EH_PE_textrel, |
502 | "indirect textrel uleb128") | |
503 | S(DW_EH_PE_indirect | DW_EH_PE_udata2 | DW_EH_PE_textrel, | |
504 | "indirect textrel udata2") | |
505 | S(DW_EH_PE_indirect | DW_EH_PE_udata4 | DW_EH_PE_textrel, | |
506 | "indirect textrel udata4") | |
507 | S(DW_EH_PE_indirect | DW_EH_PE_udata8 | DW_EH_PE_textrel, | |
508 | "indirect textrel udata8") | |
509 | S(DW_EH_PE_indirect | DW_EH_PE_sleb128 | DW_EH_PE_textrel, | |
510 | "indirect textrel sleb128") | |
511 | S(DW_EH_PE_indirect | DW_EH_PE_sdata2 | DW_EH_PE_textrel, | |
512 | "indirect textrel sdata2") | |
513 | S(DW_EH_PE_indirect | DW_EH_PE_sdata4 | DW_EH_PE_textrel, | |
514 | "indirect textrel sdata4") | |
515 | S(DW_EH_PE_indirect | DW_EH_PE_sdata8 | DW_EH_PE_textrel, | |
516 | "indirect textrel sdata8") | |
517 | ||
f90811a2 RH |
518 | S(DW_EH_PE_indirect | DW_EH_PE_absptr | DW_EH_PE_datarel, |
519 | "indirect datarel") | |
e1f9550a RH |
520 | S(DW_EH_PE_indirect | DW_EH_PE_uleb128 | DW_EH_PE_datarel, |
521 | "indirect datarel uleb128") | |
522 | S(DW_EH_PE_indirect | DW_EH_PE_udata2 | DW_EH_PE_datarel, | |
523 | "indirect datarel udata2") | |
524 | S(DW_EH_PE_indirect | DW_EH_PE_udata4 | DW_EH_PE_datarel, | |
525 | "indirect datarel udata4") | |
526 | S(DW_EH_PE_indirect | DW_EH_PE_udata8 | DW_EH_PE_datarel, | |
527 | "indirect datarel udata8") | |
528 | S(DW_EH_PE_indirect | DW_EH_PE_sleb128 | DW_EH_PE_datarel, | |
529 | "indirect datarel sleb128") | |
530 | S(DW_EH_PE_indirect | DW_EH_PE_sdata2 | DW_EH_PE_datarel, | |
531 | "indirect datarel sdata2") | |
532 | S(DW_EH_PE_indirect | DW_EH_PE_sdata4 | DW_EH_PE_datarel, | |
533 | "indirect datarel sdata4") | |
534 | S(DW_EH_PE_indirect | DW_EH_PE_sdata8 | DW_EH_PE_datarel, | |
535 | "indirect datarel sdata8") | |
536 | ||
f90811a2 RH |
537 | S(DW_EH_PE_indirect | DW_EH_PE_absptr | DW_EH_PE_funcrel, |
538 | "indirect funcrel") | |
e1f9550a RH |
539 | S(DW_EH_PE_indirect | DW_EH_PE_uleb128 | DW_EH_PE_funcrel, |
540 | "indirect funcrel uleb128") | |
541 | S(DW_EH_PE_indirect | DW_EH_PE_udata2 | DW_EH_PE_funcrel, | |
542 | "indirect funcrel udata2") | |
543 | S(DW_EH_PE_indirect | DW_EH_PE_udata4 | DW_EH_PE_funcrel, | |
544 | "indirect funcrel udata4") | |
545 | S(DW_EH_PE_indirect | DW_EH_PE_udata8 | DW_EH_PE_funcrel, | |
546 | "indirect funcrel udata8") | |
547 | S(DW_EH_PE_indirect | DW_EH_PE_sleb128 | DW_EH_PE_funcrel, | |
548 | "indirect funcrel sleb128") | |
549 | S(DW_EH_PE_indirect | DW_EH_PE_sdata2 | DW_EH_PE_funcrel, | |
550 | "indirect funcrel sdata2") | |
551 | S(DW_EH_PE_indirect | DW_EH_PE_sdata4 | DW_EH_PE_funcrel, | |
552 | "indirect funcrel sdata4") | |
553 | S(DW_EH_PE_indirect | DW_EH_PE_sdata8 | DW_EH_PE_funcrel, | |
554 | "indirect funcrel sdata8") | |
555 | ||
556 | #if HAVE_DESIGNATED_INITIALIZERS | |
557 | }; | |
558 | ||
ced3f397 | 559 | gcc_assert (format >= 0 && format < 0x100 && format_names[format]); |
b8698a0f | 560 | |
e1f9550a RH |
561 | return format_names[format]; |
562 | #else | |
563 | } | |
ced3f397 | 564 | gcc_unreachable (); |
e1f9550a RH |
565 | #endif |
566 | } | |
567 | ||
d4ea4622 RH |
568 | /* Output an unsigned LEB128 quantity, but only the byte values. */ |
569 | ||
570 | void | |
571 | dw2_asm_output_data_uleb128_raw (unsigned HOST_WIDE_INT value) | |
572 | { | |
573 | while (1) | |
574 | { | |
575 | int byte = (value & 0x7f); | |
576 | value >>= 7; | |
577 | if (value != 0) | |
578 | /* More bytes to follow. */ | |
579 | byte |= 0x80; | |
580 | ||
a3f1cee4 | 581 | fprintf (asm_out_file, "%#x", byte); |
d4ea4622 RH |
582 | if (value == 0) |
583 | break; | |
584 | fputc (',', asm_out_file); | |
585 | } | |
586 | } | |
587 | ||
2e4b9b8c RH |
588 | /* Output an unsigned LEB128 quantity. */ |
589 | ||
590 | void | |
e34d07f2 KG |
591 | dw2_asm_output_data_uleb128 (unsigned HOST_WIDE_INT value, |
592 | const char *comment, ...) | |
2e4b9b8c | 593 | { |
e34d07f2 | 594 | va_list ap; |
7080f735 | 595 | |
e34d07f2 | 596 | va_start (ap, comment); |
2e4b9b8c RH |
597 | |
598 | #ifdef HAVE_AS_LEB128 | |
90ff44cf | 599 | fprintf (asm_out_file, "\t.uleb128 " HOST_WIDE_INT_PRINT_HEX , value); |
2e4b9b8c RH |
600 | |
601 | if (flag_debug_asm && comment) | |
602 | { | |
603 | fprintf (asm_out_file, "\t%s ", ASM_COMMENT_START); | |
604 | vfprintf (asm_out_file, comment, ap); | |
605 | } | |
606 | #else | |
607 | { | |
608 | unsigned HOST_WIDE_INT work = value; | |
301d03af | 609 | const char *byte_op = targetm.asm_out.byte_op; |
2e4b9b8c | 610 | |
301d03af RS |
611 | if (byte_op) |
612 | fputs (byte_op, asm_out_file); | |
2e4b9b8c RH |
613 | do |
614 | { | |
615 | int byte = (work & 0x7f); | |
616 | work >>= 7; | |
617 | if (work != 0) | |
618 | /* More bytes to follow. */ | |
619 | byte |= 0x80; | |
620 | ||
301d03af RS |
621 | if (byte_op) |
622 | { | |
a3f1cee4 | 623 | fprintf (asm_out_file, "%#x", byte); |
301d03af RS |
624 | if (work != 0) |
625 | fputc (',', asm_out_file); | |
626 | } | |
627 | else | |
628 | assemble_integer (GEN_INT (byte), 1, BITS_PER_UNIT, 1); | |
2e4b9b8c RH |
629 | } |
630 | while (work != 0); | |
631 | ||
632 | if (flag_debug_asm) | |
633 | { | |
90ff44cf KG |
634 | fprintf (asm_out_file, "\t%s uleb128 " HOST_WIDE_INT_PRINT_HEX, |
635 | ASM_COMMENT_START, value); | |
2e4b9b8c RH |
636 | if (comment) |
637 | { | |
638 | fputs ("; ", asm_out_file); | |
639 | vfprintf (asm_out_file, comment, ap); | |
640 | } | |
641 | } | |
642 | } | |
643 | #endif | |
644 | fputc ('\n', asm_out_file); | |
645 | ||
e34d07f2 | 646 | va_end (ap); |
2e4b9b8c RH |
647 | } |
648 | ||
d4ea4622 RH |
649 | /* Output an signed LEB128 quantity, but only the byte values. */ |
650 | ||
651 | void | |
652 | dw2_asm_output_data_sleb128_raw (HOST_WIDE_INT value) | |
653 | { | |
654 | int byte, more; | |
655 | ||
656 | while (1) | |
657 | { | |
658 | byte = (value & 0x7f); | |
659 | value >>= 7; | |
660 | more = !((value == 0 && (byte & 0x40) == 0) | |
661 | || (value == -1 && (byte & 0x40) != 0)); | |
662 | if (more) | |
663 | byte |= 0x80; | |
664 | ||
a3f1cee4 | 665 | fprintf (asm_out_file, "%#x", byte); |
d4ea4622 RH |
666 | if (!more) |
667 | break; | |
668 | fputc (',', asm_out_file); | |
669 | } | |
670 | } | |
671 | ||
09da1532 | 672 | /* Output a signed LEB128 quantity. */ |
2e4b9b8c RH |
673 | |
674 | void | |
e34d07f2 KG |
675 | dw2_asm_output_data_sleb128 (HOST_WIDE_INT value, |
676 | const char *comment, ...) | |
2e4b9b8c | 677 | { |
e34d07f2 | 678 | va_list ap; |
7080f735 | 679 | |
e34d07f2 | 680 | va_start (ap, comment); |
2e4b9b8c RH |
681 | |
682 | #ifdef HAVE_AS_LEB128 | |
90ff44cf | 683 | fprintf (asm_out_file, "\t.sleb128 " HOST_WIDE_INT_PRINT_DEC, value); |
2e4b9b8c RH |
684 | |
685 | if (flag_debug_asm && comment) | |
686 | { | |
687 | fprintf (asm_out_file, "\t%s ", ASM_COMMENT_START); | |
688 | vfprintf (asm_out_file, comment, ap); | |
689 | } | |
690 | #else | |
691 | { | |
692 | HOST_WIDE_INT work = value; | |
693 | int more, byte; | |
301d03af | 694 | const char *byte_op = targetm.asm_out.byte_op; |
2e4b9b8c | 695 | |
301d03af RS |
696 | if (byte_op) |
697 | fputs (byte_op, asm_out_file); | |
2e4b9b8c RH |
698 | do |
699 | { | |
700 | byte = (work & 0x7f); | |
701 | /* arithmetic shift */ | |
702 | work >>= 7; | |
703 | more = !((work == 0 && (byte & 0x40) == 0) | |
704 | || (work == -1 && (byte & 0x40) != 0)); | |
705 | if (more) | |
706 | byte |= 0x80; | |
707 | ||
301d03af RS |
708 | if (byte_op) |
709 | { | |
a3f1cee4 | 710 | fprintf (asm_out_file, "%#x", byte); |
301d03af RS |
711 | if (more) |
712 | fputc (',', asm_out_file); | |
713 | } | |
714 | else | |
715 | assemble_integer (GEN_INT (byte), 1, BITS_PER_UNIT, 1); | |
2e4b9b8c RH |
716 | } |
717 | while (more); | |
718 | ||
719 | if (flag_debug_asm) | |
720 | { | |
90ff44cf KG |
721 | fprintf (asm_out_file, "\t%s sleb128 " HOST_WIDE_INT_PRINT_DEC, |
722 | ASM_COMMENT_START, value); | |
2e4b9b8c RH |
723 | if (comment) |
724 | { | |
725 | fputs ("; ", asm_out_file); | |
726 | vfprintf (asm_out_file, comment, ap); | |
727 | } | |
728 | } | |
729 | } | |
730 | #endif | |
731 | fputc ('\n', asm_out_file); | |
732 | ||
e34d07f2 | 733 | va_end (ap); |
2e4b9b8c RH |
734 | } |
735 | ||
736 | void | |
e34d07f2 KG |
737 | dw2_asm_output_delta_uleb128 (const char *lab1 ATTRIBUTE_UNUSED, |
738 | const char *lab2 ATTRIBUTE_UNUSED, | |
739 | const char *comment, ...) | |
2e4b9b8c | 740 | { |
e34d07f2 KG |
741 | va_list ap; |
742 | ||
743 | va_start (ap, comment); | |
2e4b9b8c RH |
744 | |
745 | #ifdef HAVE_AS_LEB128 | |
da6af203 | 746 | fputs ("\t.uleb128 ", asm_out_file); |
2e4b9b8c RH |
747 | assemble_name (asm_out_file, lab1); |
748 | fputc ('-', asm_out_file); | |
749 | assemble_name (asm_out_file, lab2); | |
750 | #else | |
ced3f397 | 751 | gcc_unreachable (); |
2e4b9b8c RH |
752 | #endif |
753 | ||
754 | if (flag_debug_asm && comment) | |
755 | { | |
756 | fprintf (asm_out_file, "\t%s ", ASM_COMMENT_START); | |
757 | vfprintf (asm_out_file, comment, ap); | |
758 | } | |
759 | fputc ('\n', asm_out_file); | |
760 | ||
e34d07f2 | 761 | va_end (ap); |
2e4b9b8c RH |
762 | } |
763 | ||
c8f4fe99 BE |
764 | #if 0 |
765 | ||
2e4b9b8c | 766 | void |
e34d07f2 KG |
767 | dw2_asm_output_delta_sleb128 (const char *lab1 ATTRIBUTE_UNUSED, |
768 | const char *lab2 ATTRIBUTE_UNUSED, | |
769 | const char *comment, ...) | |
2e4b9b8c | 770 | { |
e34d07f2 | 771 | va_list ap; |
7080f735 | 772 | |
e34d07f2 | 773 | va_start (ap, comment); |
2e4b9b8c RH |
774 | |
775 | #ifdef HAVE_AS_LEB128 | |
da6af203 | 776 | fputs ("\t.sleb128 ", asm_out_file); |
2e4b9b8c RH |
777 | assemble_name (asm_out_file, lab1); |
778 | fputc ('-', asm_out_file); | |
779 | assemble_name (asm_out_file, lab2); | |
780 | #else | |
ced3f397 | 781 | gcc_unreachable (); |
2e4b9b8c RH |
782 | #endif |
783 | ||
784 | if (flag_debug_asm && comment) | |
785 | { | |
786 | fprintf (asm_out_file, "\t%s ", ASM_COMMENT_START); | |
787 | vfprintf (asm_out_file, comment, ap); | |
788 | } | |
789 | fputc ('\n', asm_out_file); | |
790 | ||
e34d07f2 | 791 | va_end (ap); |
2e4b9b8c | 792 | } |
c8f4fe99 | 793 | #endif /* 0 */ |
2a1ee410 | 794 | \f |
7080f735 | 795 | static int dw2_output_indirect_constant_1 (splay_tree_node, void *); |
2a1ee410 | 796 | |
17211ab5 GK |
797 | static GTY((param1_is (char *), param2_is (tree))) splay_tree indirect_pool; |
798 | ||
799 | static GTY(()) int dw2_const_labelno; | |
2a1ee410 | 800 | |
74b90fe2 JDA |
801 | #if defined(HAVE_GAS_HIDDEN) |
802 | # define USE_LINKONCE_INDIRECT (SUPPORTS_ONE_ONLY) | |
d6d26764 JJ |
803 | #else |
804 | # define USE_LINKONCE_INDIRECT 0 | |
805 | #endif | |
806 | ||
dc1327cd AO |
807 | /* Comparison function for a splay tree in which the keys are strings. |
808 | K1 and K2 have the dynamic type "const char *". Returns <0, 0, or | |
809 | >0 to indicate whether K1 is less than, equal to, or greater than | |
810 | K2, respectively. */ | |
811 | ||
812 | static int | |
813 | splay_tree_compare_strings (splay_tree_key k1, splay_tree_key k2) | |
814 | { | |
815 | const char *s1 = (const char *)k1; | |
816 | const char *s2 = (const char *)k2; | |
817 | int ret; | |
818 | ||
819 | if (s1 == s2) | |
820 | return 0; | |
821 | ||
822 | ret = strcmp (s1, s2); | |
823 | ||
824 | /* The strings are always those from IDENTIFIER_NODEs, and, | |
825 | therefore, we should never have two copies of the same | |
826 | string. */ | |
827 | gcc_assert (ret); | |
828 | ||
829 | return ret; | |
830 | } | |
831 | ||
e1f9550a RH |
832 | /* Put X, a SYMBOL_REF, in memory. Return a SYMBOL_REF to the allocated |
833 | memory. Differs from force_const_mem in that a single pool is used for | |
834 | the entire unit of translation, and the memory is not guaranteed to be | |
d858f359 | 835 | "near" the function in any interesting sense. IS_PUBLIC controls whether |
b03e9863 | 836 | the symbol can be shared across the entire application (or DSO). */ |
e1f9550a | 837 | |
d4ea4622 | 838 | rtx |
d858f359 | 839 | dw2_force_const_mem (rtx x, bool is_public) |
2a1ee410 RH |
840 | { |
841 | splay_tree_node node; | |
a2649528 | 842 | const char *key; |
78bd9046 | 843 | tree decl_id; |
2a1ee410 RH |
844 | |
845 | if (! indirect_pool) | |
dc1327cd AO |
846 | /* We use strcmp, rather than just comparing pointers, so that the |
847 | sort order will not depend on the host system. */ | |
a9429e29 LB |
848 | indirect_pool = splay_tree_new_ggc (splay_tree_compare_strings, |
849 | ggc_alloc_splay_tree_str_tree_node_splay_tree_s, | |
850 | ggc_alloc_splay_tree_str_tree_node_splay_tree_node_s); | |
2a1ee410 | 851 | |
ced3f397 | 852 | gcc_assert (GET_CODE (x) == SYMBOL_REF); |
1ee9fb20 | 853 | |
a2649528 JDA |
854 | key = XSTR (x, 0); |
855 | node = splay_tree_lookup (indirect_pool, (splay_tree_key) key); | |
2a1ee410 | 856 | if (node) |
78bd9046 | 857 | decl_id = (tree) node->value; |
2a1ee410 RH |
858 | else |
859 | { | |
2a1ee410 | 860 | tree id; |
a2649528 | 861 | const char *str = targetm.strip_name_encoding (key); |
2a1ee410 | 862 | |
d858f359 | 863 | if (is_public && USE_LINKONCE_INDIRECT) |
d6d26764 | 864 | { |
f883e0a7 | 865 | char *ref_name = XALLOCAVEC (char, strlen (str) + sizeof "DW.ref."); |
d6d26764 | 866 | |
1ee9fb20 | 867 | sprintf (ref_name, "DW.ref.%s", str); |
78bd9046 AO |
868 | gcc_assert (!maybe_get_identifier (ref_name)); |
869 | decl_id = get_identifier (ref_name); | |
870 | TREE_PUBLIC (decl_id) = 1; | |
d6d26764 JJ |
871 | } |
872 | else | |
873 | { | |
d6d26764 JJ |
874 | char label[32]; |
875 | ||
17211ab5 GK |
876 | ASM_GENERATE_INTERNAL_LABEL (label, "LDFCM", dw2_const_labelno); |
877 | ++dw2_const_labelno; | |
78bd9046 AO |
878 | gcc_assert (!maybe_get_identifier (label)); |
879 | decl_id = get_identifier (label); | |
d6d26764 | 880 | } |
2a1ee410 | 881 | |
1ee9fb20 | 882 | id = maybe_get_identifier (str); |
2a1ee410 RH |
883 | if (id) |
884 | TREE_SYMBOL_REFERENCED (id) = 1; | |
885 | ||
a2649528 | 886 | splay_tree_insert (indirect_pool, (splay_tree_key) key, |
78bd9046 | 887 | (splay_tree_value) decl_id); |
2a1ee410 RH |
888 | } |
889 | ||
78bd9046 | 890 | return gen_rtx_SYMBOL_REF (Pmode, IDENTIFIER_POINTER (decl_id)); |
2a1ee410 RH |
891 | } |
892 | ||
e1f9550a RH |
893 | /* A helper function for dw2_output_indirect_constants called through |
894 | splay_tree_foreach. Emit one queued constant to memory. */ | |
895 | ||
2a1ee410 | 896 | static int |
7080f735 AJ |
897 | dw2_output_indirect_constant_1 (splay_tree_node node, |
898 | void *data ATTRIBUTE_UNUSED) | |
2a1ee410 | 899 | { |
d6d26764 | 900 | const char *sym; |
2a1ee410 | 901 | rtx sym_ref; |
78bd9046 | 902 | tree id, decl; |
2a1ee410 | 903 | |
2a1ee410 | 904 | sym = (const char *) node->key; |
78bd9046 AO |
905 | id = (tree) node->value; |
906 | ||
c2255bc4 | 907 | decl = build_decl (UNKNOWN_LOCATION, VAR_DECL, id, ptr_type_node); |
9937ab02 | 908 | SET_DECL_ASSEMBLER_NAME (decl, id); |
78bd9046 AO |
909 | DECL_ARTIFICIAL (decl) = 1; |
910 | DECL_IGNORED_P (decl) = 1; | |
911 | DECL_INITIAL (decl) = decl; | |
3895ec53 | 912 | TREE_READONLY (decl) = 1; |
78bd9046 AO |
913 | |
914 | if (TREE_PUBLIC (id)) | |
915 | { | |
916 | TREE_PUBLIC (decl) = 1; | |
fc26fae3 | 917 | make_decl_one_only (decl, DECL_ASSEMBLER_NAME (decl)); |
78bd9046 AO |
918 | } |
919 | else | |
920 | TREE_STATIC (decl) = 1; | |
921 | ||
2a1ee410 | 922 | sym_ref = gen_rtx_SYMBOL_REF (Pmode, sym); |
a2649528 | 923 | sym = targetm.strip_name_encoding (sym); |
b03e9863 | 924 | if (TREE_PUBLIC (decl) && USE_LINKONCE_INDIRECT) |
a5c414e0 | 925 | fprintf (asm_out_file, "\t.hidden %sDW.ref.%s\n", user_label_prefix, sym); |
b03e9863 | 926 | assemble_variable (decl, 1, 1, 1); |
2919600a | 927 | assemble_integer (sym_ref, POINTER_SIZE / BITS_PER_UNIT, POINTER_SIZE, 1); |
2a1ee410 RH |
928 | |
929 | return 0; | |
930 | } | |
931 | ||
e1f9550a RH |
932 | /* Emit the constants queued through dw2_force_const_mem. */ |
933 | ||
2a1ee410 | 934 | void |
7080f735 | 935 | dw2_output_indirect_constants (void) |
2a1ee410 | 936 | { |
d6d26764 JJ |
937 | if (indirect_pool) |
938 | splay_tree_foreach (indirect_pool, dw2_output_indirect_constant_1, NULL); | |
2a1ee410 RH |
939 | } |
940 | ||
b03e9863 EB |
941 | /* Like dw2_asm_output_addr_rtx, but encode the pointer as directed. |
942 | If PUBLIC is set and the encoding is DW_EH_PE_indirect, the indirect | |
943 | reference is shared across the entire application (or DSO). */ | |
e1f9550a | 944 | |
2a1ee410 | 945 | void |
d858f359 | 946 | dw2_asm_output_encoded_addr_rtx (int encoding, rtx addr, bool is_public, |
e34d07f2 | 947 | const char *comment, ...) |
2a1ee410 RH |
948 | { |
949 | int size; | |
e34d07f2 | 950 | va_list ap; |
7080f735 | 951 | |
e34d07f2 | 952 | va_start (ap, comment); |
e1f9550a RH |
953 | |
954 | size = size_of_encoded_value (encoding); | |
2a1ee410 | 955 | |
099c8b17 RH |
956 | if (encoding == DW_EH_PE_aligned) |
957 | { | |
958 | assemble_align (POINTER_SIZE); | |
9f5cd0c5 | 959 | assemble_integer (addr, size, POINTER_SIZE, 1); |
0edf1bb2 | 960 | va_end (ap); |
9f5cd0c5 | 961 | return; |
099c8b17 RH |
962 | } |
963 | ||
3248917b RK |
964 | /* NULL is _always_ represented as a plain zero, as is 1 for Ada's |
965 | "all others". */ | |
966 | if (addr == const0_rtx || addr == const1_rtx) | |
c8af3574 | 967 | assemble_integer (addr, size, BITS_PER_UNIT, 1); |
e1f9550a | 968 | else |
2a1ee410 | 969 | { |
e1f9550a RH |
970 | restart: |
971 | /* Allow the target first crack at emitting this. Some of the | |
3a538a66 | 972 | special relocations require special directives instead of |
e1f9550a | 973 | just ".4byte" or whatever. */ |
2a1ee410 | 974 | #ifdef ASM_MAYBE_OUTPUT_ENCODED_ADDR_RTX |
e1f9550a RH |
975 | ASM_MAYBE_OUTPUT_ENCODED_ADDR_RTX (asm_out_file, encoding, size, |
976 | addr, done); | |
2a1ee410 RH |
977 | #endif |
978 | ||
e1f9550a RH |
979 | /* Indirection is used to get dynamic relocations out of a |
980 | read-only section. */ | |
981 | if (encoding & DW_EH_PE_indirect) | |
982 | { | |
983 | /* It is very tempting to use force_const_mem so that we share data | |
984 | with the normal constant pool. However, we've already emitted | |
985 | the constant pool for this function. Moreover, we'd like to | |
b03e9863 EB |
986 | share these constants across the entire unit of translation and |
987 | even, if possible, across the entire application (or DSO). */ | |
d858f359 | 988 | addr = dw2_force_const_mem (addr, is_public); |
e1f9550a RH |
989 | encoding &= ~DW_EH_PE_indirect; |
990 | goto restart; | |
991 | } | |
2a1ee410 | 992 | |
e1f9550a RH |
993 | switch (encoding & 0xF0) |
994 | { | |
995 | case DW_EH_PE_absptr: | |
301d03af | 996 | dw2_assemble_integer (size, addr); |
e1f9550a | 997 | break; |
2a1ee410 | 998 | |
e1f9550a | 999 | case DW_EH_PE_pcrel: |
ced3f397 | 1000 | gcc_assert (GET_CODE (addr) == SYMBOL_REF); |
2a1ee410 | 1001 | #ifdef ASM_OUTPUT_DWARF_PCREL |
e1f9550a | 1002 | ASM_OUTPUT_DWARF_PCREL (asm_out_file, size, XSTR (addr, 0)); |
2a1ee410 | 1003 | #else |
301d03af | 1004 | dw2_assemble_integer (size, gen_rtx_MINUS (Pmode, addr, pc_rtx)); |
2a1ee410 | 1005 | #endif |
e1f9550a | 1006 | break; |
2a1ee410 | 1007 | |
e1f9550a | 1008 | default: |
3a538a66 | 1009 | /* Other encodings should have been handled by |
e1f9550a | 1010 | ASM_MAYBE_OUTPUT_ENCODED_ADDR_RTX. */ |
ced3f397 | 1011 | gcc_unreachable (); |
e1f9550a | 1012 | } |
2a1ee410 RH |
1013 | |
1014 | #ifdef ASM_MAYBE_OUTPUT_ENCODED_ADDR_RTX | |
e1f9550a | 1015 | done:; |
2a1ee410 | 1016 | #endif |
e1f9550a RH |
1017 | } |
1018 | ||
1019 | if (flag_debug_asm && comment) | |
1020 | { | |
1021 | fprintf (asm_out_file, "\t%s ", ASM_COMMENT_START); | |
1022 | vfprintf (asm_out_file, comment, ap); | |
1023 | } | |
2a1ee410 | 1024 | fputc ('\n', asm_out_file); |
e1f9550a | 1025 | |
e34d07f2 | 1026 | va_end (ap); |
2a1ee410 | 1027 | } |
17211ab5 GK |
1028 | |
1029 | #include "gt-dwarf2asm.h" |