1 /* Dwarf2 assembler output helper routines.
2 Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
4 This file is part of GCC.
6 GCC is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 2, or (at your option) any later
11 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 You should have received a copy of the GNU General Public License
17 along with GCC; see the file COPYING. If not, write to the Free
18 Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
24 #include "coretypes.h"
31 #include "dwarf2asm.h"
33 #include "splay-tree.h"
38 /* How to start an assembler comment. */
39 #ifndef ASM_COMMENT_START
40 #define ASM_COMMENT_START ";#"
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. */
48 dw2_assemble_integer (int size
, rtx x
)
50 const char *op
= integer_asm_op (size
, FALSE
);
54 fputs (op
, asm_out_file
);
55 if (GET_CODE (x
) == CONST_INT
)
56 fprintf (asm_out_file
, HOST_WIDE_INT_PRINT_HEX
, INTVAL (x
));
58 output_addr_const (asm_out_file
, x
);
61 assemble_integer (x
, size
, BITS_PER_UNIT
, 1);
65 /* Output an immediate constant in a given size. */
68 dw2_asm_output_data (int size
, unsigned HOST_WIDE_INT value
,
69 const char *comment
, ...)
73 va_start (ap
, comment
);
75 if (size
* 8 < HOST_BITS_PER_WIDE_INT
)
76 value
&= ~(~(unsigned HOST_WIDE_INT
) 0 << (size
* 8));
78 dw2_assemble_integer (size
, GEN_INT (value
));
80 if (flag_debug_asm
&& comment
)
82 fprintf (asm_out_file
, "\t%s ", ASM_COMMENT_START
);
83 vfprintf (asm_out_file
, comment
, ap
);
85 fputc ('\n', asm_out_file
);
90 /* Output the difference between two symbols in a given size. */
91 /* ??? There appear to be assemblers that do not like such
92 subtraction, but do support ASM_SET_OP. It's unfortunately
93 impossible to do here, since the ASM_SET_OP for the difference
94 symbol must appear after both symbols are defined. */
97 dw2_asm_output_delta (int size
, const char *lab1
, const char *lab2
,
98 const char *comment
, ...)
102 va_start (ap
, comment
);
104 #ifdef ASM_OUTPUT_DWARF_DELTA
105 ASM_OUTPUT_DWARF_DELTA (asm_out_file
, size
, lab1
, lab2
);
107 dw2_assemble_integer (size
,
108 gen_rtx_MINUS (Pmode
,
109 gen_rtx_SYMBOL_REF (Pmode
, lab1
),
110 gen_rtx_SYMBOL_REF (Pmode
, lab2
)));
112 if (flag_debug_asm
&& comment
)
114 fprintf (asm_out_file
, "\t%s ", ASM_COMMENT_START
);
115 vfprintf (asm_out_file
, comment
, ap
);
117 fputc ('\n', asm_out_file
);
122 /* Output a section-relative reference to a LABEL, which was placed in
123 BASE. In general this can only be done for debugging symbols.
124 E.g. on most targets with the GNU linker, this is accomplished with
125 a direct reference and the knowledge that the debugging section
126 will be placed at VMA 0. Some targets have special relocations for
127 this that we must use. */
130 dw2_asm_output_offset (int size
, const char *label
,
131 section
*base ATTRIBUTE_UNUSED
,
132 const char *comment
, ...)
136 va_start (ap
, comment
);
138 #ifdef ASM_OUTPUT_DWARF_OFFSET
139 ASM_OUTPUT_DWARF_OFFSET (asm_out_file
, size
, label
, base
);
141 dw2_assemble_integer (size
, gen_rtx_SYMBOL_REF (Pmode
, label
));
144 if (flag_debug_asm
&& comment
)
146 fprintf (asm_out_file
, "\t%s ", ASM_COMMENT_START
);
147 vfprintf (asm_out_file
, comment
, ap
);
149 fputc ('\n', asm_out_file
);
156 /* Output a self-relative reference to a label, possibly in a
157 different section or object file. */
160 dw2_asm_output_pcrel (int size ATTRIBUTE_UNUSED
,
161 const char *label ATTRIBUTE_UNUSED
,
162 const char *comment
, ...)
166 va_start (ap
, comment
);
168 #ifdef ASM_OUTPUT_DWARF_PCREL
169 ASM_OUTPUT_DWARF_PCREL (asm_out_file
, size
, label
);
171 dw2_assemble_integer (size
,
172 gen_rtx_MINUS (Pmode
,
173 gen_rtx_SYMBOL_REF (Pmode
, label
),
177 if (flag_debug_asm
&& comment
)
179 fprintf (asm_out_file
, "\t%s ", ASM_COMMENT_START
);
180 vfprintf (asm_out_file
, comment
, ap
);
182 fputc ('\n', asm_out_file
);
188 /* Output an absolute reference to a label. */
191 dw2_asm_output_addr (int size
, const char *label
,
192 const char *comment
, ...)
196 va_start (ap
, comment
);
198 dw2_assemble_integer (size
, gen_rtx_SYMBOL_REF (Pmode
, label
));
200 if (flag_debug_asm
&& comment
)
202 fprintf (asm_out_file
, "\t%s ", ASM_COMMENT_START
);
203 vfprintf (asm_out_file
, comment
, ap
);
205 fputc ('\n', asm_out_file
);
210 /* Similar, but use an RTX expression instead of a text label. */
213 dw2_asm_output_addr_rtx (int size
, rtx addr
,
214 const char *comment
, ...)
218 va_start (ap
, comment
);
220 dw2_assemble_integer (size
, addr
);
222 if (flag_debug_asm
&& comment
)
224 fprintf (asm_out_file
, "\t%s ", ASM_COMMENT_START
);
225 vfprintf (asm_out_file
, comment
, ap
);
227 fputc ('\n', asm_out_file
);
232 /* Output the first ORIG_LEN characters of STR as a string.
233 If ORIG_LEN is equal to -1, ignore this parameter and output
234 the entire STR instead.
235 If COMMENT is not NULL and comments in the debug information
236 have been requested by the user, append the given COMMENT
237 to the generated output. */
240 dw2_asm_output_nstring (const char *str
, size_t orig_len
,
241 const char *comment
, ...)
246 va_start (ap
, comment
);
250 if (len
== (size_t) -1)
253 if (flag_debug_asm
&& comment
)
255 fputs ("\t.ascii \"", asm_out_file
);
256 for (i
= 0; i
< len
; i
++)
259 if (c
== '\"' || c
== '\\')
260 fputc ('\\', asm_out_file
);
262 fputc (c
, asm_out_file
);
264 fprintf (asm_out_file
, "\\%o", c
);
266 fprintf (asm_out_file
, "\\0\"\t%s ", ASM_COMMENT_START
);
267 vfprintf (asm_out_file
, comment
, ap
);
268 fputc ('\n', asm_out_file
);
272 /* If an explicit length was given, we can't assume there
273 is a null termination in the string buffer. */
274 if (orig_len
== (size_t) -1)
276 ASM_OUTPUT_ASCII (asm_out_file
, str
, len
);
277 if (orig_len
!= (size_t) -1)
278 assemble_integer (const0_rtx
, 1, BITS_PER_UNIT
, 1);
285 /* Return the size of an unsigned LEB128 quantity. */
288 size_of_uleb128 (unsigned HOST_WIDE_INT value
)
302 /* Return the size of a signed LEB128 quantity. */
305 size_of_sleb128 (HOST_WIDE_INT value
)
311 byte
= (value
& 0x7f);
315 while (!((value
== 0 && (byte
& 0x40) == 0)
316 || (value
== -1 && (byte
& 0x40) != 0)));
321 /* Given an encoding, return the number of bytes the format occupies.
322 This is only defined for fixed-size encodings, and so does not
326 size_of_encoded_value (int encoding
)
328 if (encoding
== DW_EH_PE_omit
)
331 switch (encoding
& 0x07)
333 case DW_EH_PE_absptr
:
334 return POINTER_SIZE
/ BITS_PER_UNIT
;
335 case DW_EH_PE_udata2
:
337 case DW_EH_PE_udata4
:
339 case DW_EH_PE_udata8
:
346 /* Yield a name for a given pointer encoding. */
349 eh_data_format_name (int format
)
351 #if HAVE_DESIGNATED_INITIALIZERS
352 #define S(p, v) [p] = v,
354 #define S(p, v) case p: return v;
357 #if HAVE_DESIGNATED_INITIALIZERS
358 __extension__
static const char * const format_names
[256] = {
363 S(DW_EH_PE_absptr
, "absolute")
364 S(DW_EH_PE_omit
, "omit")
365 S(DW_EH_PE_aligned
, "aligned absolute")
367 S(DW_EH_PE_uleb128
, "uleb128")
368 S(DW_EH_PE_udata2
, "udata2")
369 S(DW_EH_PE_udata4
, "udata4")
370 S(DW_EH_PE_udata8
, "udata8")
371 S(DW_EH_PE_sleb128
, "sleb128")
372 S(DW_EH_PE_sdata2
, "sdata2")
373 S(DW_EH_PE_sdata4
, "sdata4")
374 S(DW_EH_PE_sdata8
, "sdata8")
376 S(DW_EH_PE_absptr
| DW_EH_PE_pcrel
, "pcrel")
377 S(DW_EH_PE_uleb128
| DW_EH_PE_pcrel
, "pcrel uleb128")
378 S(DW_EH_PE_udata2
| DW_EH_PE_pcrel
, "pcrel udata2")
379 S(DW_EH_PE_udata4
| DW_EH_PE_pcrel
, "pcrel udata4")
380 S(DW_EH_PE_udata8
| DW_EH_PE_pcrel
, "pcrel udata8")
381 S(DW_EH_PE_sleb128
| DW_EH_PE_pcrel
, "pcrel sleb128")
382 S(DW_EH_PE_sdata2
| DW_EH_PE_pcrel
, "pcrel sdata2")
383 S(DW_EH_PE_sdata4
| DW_EH_PE_pcrel
, "pcrel sdata4")
384 S(DW_EH_PE_sdata8
| DW_EH_PE_pcrel
, "pcrel sdata8")
386 S(DW_EH_PE_absptr
| DW_EH_PE_textrel
, "textrel")
387 S(DW_EH_PE_uleb128
| DW_EH_PE_textrel
, "textrel uleb128")
388 S(DW_EH_PE_udata2
| DW_EH_PE_textrel
, "textrel udata2")
389 S(DW_EH_PE_udata4
| DW_EH_PE_textrel
, "textrel udata4")
390 S(DW_EH_PE_udata8
| DW_EH_PE_textrel
, "textrel udata8")
391 S(DW_EH_PE_sleb128
| DW_EH_PE_textrel
, "textrel sleb128")
392 S(DW_EH_PE_sdata2
| DW_EH_PE_textrel
, "textrel sdata2")
393 S(DW_EH_PE_sdata4
| DW_EH_PE_textrel
, "textrel sdata4")
394 S(DW_EH_PE_sdata8
| DW_EH_PE_textrel
, "textrel sdata8")
396 S(DW_EH_PE_absptr
| DW_EH_PE_datarel
, "datarel")
397 S(DW_EH_PE_uleb128
| DW_EH_PE_datarel
, "datarel uleb128")
398 S(DW_EH_PE_udata2
| DW_EH_PE_datarel
, "datarel udata2")
399 S(DW_EH_PE_udata4
| DW_EH_PE_datarel
, "datarel udata4")
400 S(DW_EH_PE_udata8
| DW_EH_PE_datarel
, "datarel udata8")
401 S(DW_EH_PE_sleb128
| DW_EH_PE_datarel
, "datarel sleb128")
402 S(DW_EH_PE_sdata2
| DW_EH_PE_datarel
, "datarel sdata2")
403 S(DW_EH_PE_sdata4
| DW_EH_PE_datarel
, "datarel sdata4")
404 S(DW_EH_PE_sdata8
| DW_EH_PE_datarel
, "datarel sdata8")
406 S(DW_EH_PE_absptr
| DW_EH_PE_funcrel
, "funcrel")
407 S(DW_EH_PE_uleb128
| DW_EH_PE_funcrel
, "funcrel uleb128")
408 S(DW_EH_PE_udata2
| DW_EH_PE_funcrel
, "funcrel udata2")
409 S(DW_EH_PE_udata4
| DW_EH_PE_funcrel
, "funcrel udata4")
410 S(DW_EH_PE_udata8
| DW_EH_PE_funcrel
, "funcrel udata8")
411 S(DW_EH_PE_sleb128
| DW_EH_PE_funcrel
, "funcrel sleb128")
412 S(DW_EH_PE_sdata2
| DW_EH_PE_funcrel
, "funcrel sdata2")
413 S(DW_EH_PE_sdata4
| DW_EH_PE_funcrel
, "funcrel sdata4")
414 S(DW_EH_PE_sdata8
| DW_EH_PE_funcrel
, "funcrel sdata8")
416 S(DW_EH_PE_indirect
| DW_EH_PE_absptr
| DW_EH_PE_pcrel
,
418 S(DW_EH_PE_indirect
| DW_EH_PE_uleb128
| DW_EH_PE_pcrel
,
419 "indirect pcrel uleb128")
420 S(DW_EH_PE_indirect
| DW_EH_PE_udata2
| DW_EH_PE_pcrel
,
421 "indirect pcrel udata2")
422 S(DW_EH_PE_indirect
| DW_EH_PE_udata4
| DW_EH_PE_pcrel
,
423 "indirect pcrel udata4")
424 S(DW_EH_PE_indirect
| DW_EH_PE_udata8
| DW_EH_PE_pcrel
,
425 "indirect pcrel udata8")
426 S(DW_EH_PE_indirect
| DW_EH_PE_sleb128
| DW_EH_PE_pcrel
,
427 "indirect pcrel sleb128")
428 S(DW_EH_PE_indirect
| DW_EH_PE_sdata2
| DW_EH_PE_pcrel
,
429 "indirect pcrel sdata2")
430 S(DW_EH_PE_indirect
| DW_EH_PE_sdata4
| DW_EH_PE_pcrel
,
431 "indirect pcrel sdata4")
432 S(DW_EH_PE_indirect
| DW_EH_PE_sdata8
| DW_EH_PE_pcrel
,
433 "indirect pcrel sdata8")
435 S(DW_EH_PE_indirect
| DW_EH_PE_absptr
| DW_EH_PE_textrel
,
437 S(DW_EH_PE_indirect
| DW_EH_PE_uleb128
| DW_EH_PE_textrel
,
438 "indirect textrel uleb128")
439 S(DW_EH_PE_indirect
| DW_EH_PE_udata2
| DW_EH_PE_textrel
,
440 "indirect textrel udata2")
441 S(DW_EH_PE_indirect
| DW_EH_PE_udata4
| DW_EH_PE_textrel
,
442 "indirect textrel udata4")
443 S(DW_EH_PE_indirect
| DW_EH_PE_udata8
| DW_EH_PE_textrel
,
444 "indirect textrel udata8")
445 S(DW_EH_PE_indirect
| DW_EH_PE_sleb128
| DW_EH_PE_textrel
,
446 "indirect textrel sleb128")
447 S(DW_EH_PE_indirect
| DW_EH_PE_sdata2
| DW_EH_PE_textrel
,
448 "indirect textrel sdata2")
449 S(DW_EH_PE_indirect
| DW_EH_PE_sdata4
| DW_EH_PE_textrel
,
450 "indirect textrel sdata4")
451 S(DW_EH_PE_indirect
| DW_EH_PE_sdata8
| DW_EH_PE_textrel
,
452 "indirect textrel sdata8")
454 S(DW_EH_PE_indirect
| DW_EH_PE_absptr
| DW_EH_PE_datarel
,
456 S(DW_EH_PE_indirect
| DW_EH_PE_uleb128
| DW_EH_PE_datarel
,
457 "indirect datarel uleb128")
458 S(DW_EH_PE_indirect
| DW_EH_PE_udata2
| DW_EH_PE_datarel
,
459 "indirect datarel udata2")
460 S(DW_EH_PE_indirect
| DW_EH_PE_udata4
| DW_EH_PE_datarel
,
461 "indirect datarel udata4")
462 S(DW_EH_PE_indirect
| DW_EH_PE_udata8
| DW_EH_PE_datarel
,
463 "indirect datarel udata8")
464 S(DW_EH_PE_indirect
| DW_EH_PE_sleb128
| DW_EH_PE_datarel
,
465 "indirect datarel sleb128")
466 S(DW_EH_PE_indirect
| DW_EH_PE_sdata2
| DW_EH_PE_datarel
,
467 "indirect datarel sdata2")
468 S(DW_EH_PE_indirect
| DW_EH_PE_sdata4
| DW_EH_PE_datarel
,
469 "indirect datarel sdata4")
470 S(DW_EH_PE_indirect
| DW_EH_PE_sdata8
| DW_EH_PE_datarel
,
471 "indirect datarel sdata8")
473 S(DW_EH_PE_indirect
| DW_EH_PE_absptr
| DW_EH_PE_funcrel
,
475 S(DW_EH_PE_indirect
| DW_EH_PE_uleb128
| DW_EH_PE_funcrel
,
476 "indirect funcrel uleb128")
477 S(DW_EH_PE_indirect
| DW_EH_PE_udata2
| DW_EH_PE_funcrel
,
478 "indirect funcrel udata2")
479 S(DW_EH_PE_indirect
| DW_EH_PE_udata4
| DW_EH_PE_funcrel
,
480 "indirect funcrel udata4")
481 S(DW_EH_PE_indirect
| DW_EH_PE_udata8
| DW_EH_PE_funcrel
,
482 "indirect funcrel udata8")
483 S(DW_EH_PE_indirect
| DW_EH_PE_sleb128
| DW_EH_PE_funcrel
,
484 "indirect funcrel sleb128")
485 S(DW_EH_PE_indirect
| DW_EH_PE_sdata2
| DW_EH_PE_funcrel
,
486 "indirect funcrel sdata2")
487 S(DW_EH_PE_indirect
| DW_EH_PE_sdata4
| DW_EH_PE_funcrel
,
488 "indirect funcrel sdata4")
489 S(DW_EH_PE_indirect
| DW_EH_PE_sdata8
| DW_EH_PE_funcrel
,
490 "indirect funcrel sdata8")
492 #if HAVE_DESIGNATED_INITIALIZERS
495 gcc_assert (format
>= 0 && format
< 0x100 && format_names
[format
]);
497 return format_names
[format
];
504 /* Output an unsigned LEB128 quantity. */
507 dw2_asm_output_data_uleb128 (unsigned HOST_WIDE_INT value
,
508 const char *comment
, ...)
512 va_start (ap
, comment
);
514 #ifdef HAVE_AS_LEB128
515 fprintf (asm_out_file
, "\t.uleb128 " HOST_WIDE_INT_PRINT_HEX
, value
);
517 if (flag_debug_asm
&& comment
)
519 fprintf (asm_out_file
, "\t%s ", ASM_COMMENT_START
);
520 vfprintf (asm_out_file
, comment
, ap
);
524 unsigned HOST_WIDE_INT work
= value
;
525 const char *byte_op
= targetm
.asm_out
.byte_op
;
528 fputs (byte_op
, asm_out_file
);
531 int byte
= (work
& 0x7f);
534 /* More bytes to follow. */
539 fprintf (asm_out_file
, "0x%x", byte
);
541 fputc (',', asm_out_file
);
544 assemble_integer (GEN_INT (byte
), 1, BITS_PER_UNIT
, 1);
550 fprintf (asm_out_file
, "\t%s uleb128 " HOST_WIDE_INT_PRINT_HEX
,
551 ASM_COMMENT_START
, value
);
554 fputs ("; ", asm_out_file
);
555 vfprintf (asm_out_file
, comment
, ap
);
560 fputc ('\n', asm_out_file
);
565 /* Output a signed LEB128 quantity. */
568 dw2_asm_output_data_sleb128 (HOST_WIDE_INT value
,
569 const char *comment
, ...)
573 va_start (ap
, comment
);
575 #ifdef HAVE_AS_LEB128
576 fprintf (asm_out_file
, "\t.sleb128 " HOST_WIDE_INT_PRINT_DEC
, value
);
578 if (flag_debug_asm
&& comment
)
580 fprintf (asm_out_file
, "\t%s ", ASM_COMMENT_START
);
581 vfprintf (asm_out_file
, comment
, ap
);
585 HOST_WIDE_INT work
= value
;
587 const char *byte_op
= targetm
.asm_out
.byte_op
;
590 fputs (byte_op
, asm_out_file
);
593 byte
= (work
& 0x7f);
594 /* arithmetic shift */
596 more
= !((work
== 0 && (byte
& 0x40) == 0)
597 || (work
== -1 && (byte
& 0x40) != 0));
603 fprintf (asm_out_file
, "0x%x", byte
);
605 fputc (',', asm_out_file
);
608 assemble_integer (GEN_INT (byte
), 1, BITS_PER_UNIT
, 1);
614 fprintf (asm_out_file
, "\t%s sleb128 " HOST_WIDE_INT_PRINT_DEC
,
615 ASM_COMMENT_START
, value
);
618 fputs ("; ", asm_out_file
);
619 vfprintf (asm_out_file
, comment
, ap
);
624 fputc ('\n', asm_out_file
);
630 dw2_asm_output_delta_uleb128 (const char *lab1 ATTRIBUTE_UNUSED
,
631 const char *lab2 ATTRIBUTE_UNUSED
,
632 const char *comment
, ...)
636 va_start (ap
, comment
);
638 #ifdef HAVE_AS_LEB128
639 fputs ("\t.uleb128 ", asm_out_file
);
640 assemble_name (asm_out_file
, lab1
);
641 fputc ('-', asm_out_file
);
642 assemble_name (asm_out_file
, lab2
);
647 if (flag_debug_asm
&& comment
)
649 fprintf (asm_out_file
, "\t%s ", ASM_COMMENT_START
);
650 vfprintf (asm_out_file
, comment
, ap
);
652 fputc ('\n', asm_out_file
);
660 dw2_asm_output_delta_sleb128 (const char *lab1 ATTRIBUTE_UNUSED
,
661 const char *lab2 ATTRIBUTE_UNUSED
,
662 const char *comment
, ...)
666 va_start (ap
, comment
);
668 #ifdef HAVE_AS_LEB128
669 fputs ("\t.sleb128 ", asm_out_file
);
670 assemble_name (asm_out_file
, lab1
);
671 fputc ('-', asm_out_file
);
672 assemble_name (asm_out_file
, lab2
);
677 if (flag_debug_asm
&& comment
)
679 fprintf (asm_out_file
, "\t%s ", ASM_COMMENT_START
);
680 vfprintf (asm_out_file
, comment
, ap
);
682 fputc ('\n', asm_out_file
);
688 static rtx
dw2_force_const_mem (rtx
, bool);
689 static int dw2_output_indirect_constant_1 (splay_tree_node
, void *);
691 static GTY((param1_is (char *), param2_is (tree
))) splay_tree indirect_pool
;
693 static GTY(()) int dw2_const_labelno
;
695 #if defined(HAVE_GAS_HIDDEN) && defined(SUPPORTS_ONE_ONLY)
696 # define USE_LINKONCE_INDIRECT 1
698 # define USE_LINKONCE_INDIRECT 0
701 /* Put X, a SYMBOL_REF, in memory. Return a SYMBOL_REF to the allocated
702 memory. Differs from force_const_mem in that a single pool is used for
703 the entire unit of translation, and the memory is not guaranteed to be
704 "near" the function in any interesting sense. PUBLIC controls whether
705 the symbol can be shared across the entire application (or DSO). */
708 dw2_force_const_mem (rtx x
, bool public)
710 splay_tree_node node
;
715 indirect_pool
= splay_tree_new_ggc (splay_tree_compare_pointers
);
717 gcc_assert (GET_CODE (x
) == SYMBOL_REF
);
719 str
= targetm
.strip_name_encoding (XSTR (x
, 0));
720 node
= splay_tree_lookup (indirect_pool
, (splay_tree_key
) str
);
722 decl
= (tree
) node
->value
;
727 if (public && USE_LINKONCE_INDIRECT
)
729 char *ref_name
= alloca (strlen (str
) + sizeof "DW.ref.");
731 sprintf (ref_name
, "DW.ref.%s", str
);
732 id
= get_identifier (ref_name
);
733 decl
= build_decl (VAR_DECL
, id
, ptr_type_node
);
734 DECL_ARTIFICIAL (decl
) = 1;
735 DECL_IGNORED_P (decl
) = 1;
736 TREE_PUBLIC (decl
) = 1;
737 DECL_INITIAL (decl
) = decl
;
738 make_decl_one_only (decl
);
744 ASM_GENERATE_INTERNAL_LABEL (label
, "LDFCM", dw2_const_labelno
);
746 id
= get_identifier (label
);
747 decl
= build_decl (VAR_DECL
, id
, ptr_type_node
);
748 DECL_ARTIFICIAL (decl
) = 1;
749 DECL_IGNORED_P (decl
) = 1;
750 TREE_STATIC (decl
) = 1;
751 DECL_INITIAL (decl
) = decl
;
754 id
= maybe_get_identifier (str
);
756 TREE_SYMBOL_REFERENCED (id
) = 1;
758 splay_tree_insert (indirect_pool
, (splay_tree_key
) str
,
759 (splay_tree_value
) decl
);
762 return XEXP (DECL_RTL (decl
), 0);
765 /* A helper function for dw2_output_indirect_constants called through
766 splay_tree_foreach. Emit one queued constant to memory. */
769 dw2_output_indirect_constant_1 (splay_tree_node node
,
770 void *data ATTRIBUTE_UNUSED
)
776 sym
= (const char *) node
->key
;
777 decl
= (tree
) node
->value
;
778 sym_ref
= gen_rtx_SYMBOL_REF (Pmode
, sym
);
779 if (TREE_PUBLIC (decl
) && USE_LINKONCE_INDIRECT
)
780 fprintf (asm_out_file
, "\t.hidden %sDW.ref.%s\n", user_label_prefix
, sym
);
781 assemble_variable (decl
, 1, 1, 1);
782 assemble_integer (sym_ref
, POINTER_SIZE
/ BITS_PER_UNIT
, POINTER_SIZE
, 1);
787 /* Emit the constants queued through dw2_force_const_mem. */
790 dw2_output_indirect_constants (void)
793 splay_tree_foreach (indirect_pool
, dw2_output_indirect_constant_1
, NULL
);
796 /* Like dw2_asm_output_addr_rtx, but encode the pointer as directed.
797 If PUBLIC is set and the encoding is DW_EH_PE_indirect, the indirect
798 reference is shared across the entire application (or DSO). */
801 dw2_asm_output_encoded_addr_rtx (int encoding
, rtx addr
, bool public,
802 const char *comment
, ...)
807 va_start (ap
, comment
);
809 size
= size_of_encoded_value (encoding
);
811 if (encoding
== DW_EH_PE_aligned
)
813 assemble_align (POINTER_SIZE
);
814 assemble_integer (addr
, size
, POINTER_SIZE
, 1);
818 /* NULL is _always_ represented as a plain zero, as is 1 for Ada's
820 if (addr
== const0_rtx
|| addr
== const1_rtx
)
821 assemble_integer (addr
, size
, BITS_PER_UNIT
, 1);
825 /* Allow the target first crack at emitting this. Some of the
826 special relocations require special directives instead of
827 just ".4byte" or whatever. */
828 #ifdef ASM_MAYBE_OUTPUT_ENCODED_ADDR_RTX
829 ASM_MAYBE_OUTPUT_ENCODED_ADDR_RTX (asm_out_file
, encoding
, size
,
833 /* Indirection is used to get dynamic relocations out of a
834 read-only section. */
835 if (encoding
& DW_EH_PE_indirect
)
837 /* It is very tempting to use force_const_mem so that we share data
838 with the normal constant pool. However, we've already emitted
839 the constant pool for this function. Moreover, we'd like to
840 share these constants across the entire unit of translation and
841 even, if possible, across the entire application (or DSO). */
842 addr
= dw2_force_const_mem (addr
, public);
843 encoding
&= ~DW_EH_PE_indirect
;
847 switch (encoding
& 0xF0)
849 case DW_EH_PE_absptr
:
850 dw2_assemble_integer (size
, addr
);
854 gcc_assert (GET_CODE (addr
) == SYMBOL_REF
);
855 #ifdef ASM_OUTPUT_DWARF_PCREL
856 ASM_OUTPUT_DWARF_PCREL (asm_out_file
, size
, XSTR (addr
, 0));
858 dw2_assemble_integer (size
, gen_rtx_MINUS (Pmode
, addr
, pc_rtx
));
863 /* Other encodings should have been handled by
864 ASM_MAYBE_OUTPUT_ENCODED_ADDR_RTX. */
868 #ifdef ASM_MAYBE_OUTPUT_ENCODED_ADDR_RTX
873 if (flag_debug_asm
&& comment
)
875 fprintf (asm_out_file
, "\t%s ", ASM_COMMENT_START
);
876 vfprintf (asm_out_file
, comment
, ap
);
878 fputc ('\n', asm_out_file
);
883 #include "gt-dwarf2asm.h"