1 /* Dwarf2 assembler output helper routines.
2 Copyright (C) 2001, 2002 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, 59 Temple Place - Suite 330, 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 (size
, x
)
52 const char *op
= integer_asm_op (size
, FALSE
);
56 fputs (op
, asm_out_file
);
57 if (GET_CODE (x
) == CONST_INT
)
58 fprintf (asm_out_file
, HOST_WIDE_INT_PRINT_HEX
, INTVAL (x
));
60 output_addr_const (asm_out_file
, x
);
63 assemble_integer (x
, size
, BITS_PER_UNIT
, 1);
67 /* Output an immediate constant in a given size. */
70 dw2_asm_output_data
VPARAMS ((int size
, unsigned HOST_WIDE_INT value
,
71 const char *comment
, ...))
73 VA_OPEN (ap
, comment
);
74 VA_FIXEDARG (ap
, int, size
);
75 VA_FIXEDARG (ap
, unsigned HOST_WIDE_INT
, value
);
76 VA_FIXEDARG (ap
, const char *, comment
);
78 if (size
* 8 < HOST_BITS_PER_WIDE_INT
)
79 value
&= ~(~(unsigned HOST_WIDE_INT
) 0 << (size
* 8));
81 dw2_assemble_integer (size
, GEN_INT (value
));
83 if (flag_debug_asm
&& comment
)
85 fprintf (asm_out_file
, "\t%s ", ASM_COMMENT_START
);
86 vfprintf (asm_out_file
, comment
, ap
);
88 fputc ('\n', asm_out_file
);
93 /* Output the difference between two symbols in a given size. */
94 /* ??? There appear to be assemblers that do not like such
95 subtraction, but do support ASM_SET_OP. It's unfortunately
96 impossible to do here, since the ASM_SET_OP for the difference
97 symbol must appear after both symbols are defined. */
100 dw2_asm_output_delta
VPARAMS ((int size
, const char *lab1
, const char *lab2
,
101 const char *comment
, ...))
103 VA_OPEN (ap
, comment
);
104 VA_FIXEDARG (ap
, int, size
);
105 VA_FIXEDARG (ap
, const char *, lab1
);
106 VA_FIXEDARG (ap
, const char *, lab2
);
107 VA_FIXEDARG (ap
, const char *, comment
);
109 #ifdef ASM_OUTPUT_DWARF_DELTA
110 ASM_OUTPUT_DWARF_DELTA (asm_out_file
, size
, lab1
, lab2
);
112 dw2_assemble_integer (size
,
113 gen_rtx_MINUS (Pmode
,
114 gen_rtx_SYMBOL_REF (Pmode
, lab1
),
115 gen_rtx_SYMBOL_REF (Pmode
, lab2
)));
117 if (flag_debug_asm
&& comment
)
119 fprintf (asm_out_file
, "\t%s ", ASM_COMMENT_START
);
120 vfprintf (asm_out_file
, comment
, ap
);
122 fputc ('\n', asm_out_file
);
127 /* Output a section-relative reference to a label. In general this
128 can only be done for debugging symbols. E.g. on most targets with
129 the GNU linker, this is accomplished with a direct reference and
130 the knowledge that the debugging section will be placed at VMA 0.
131 Some targets have special relocations for this that we must use. */
134 dw2_asm_output_offset
VPARAMS ((int size
, const char *label
,
135 const char *comment
, ...))
137 VA_OPEN (ap
, comment
);
138 VA_FIXEDARG (ap
, int, size
);
139 VA_FIXEDARG (ap
, const char *, label
);
140 VA_FIXEDARG (ap
, const char *, comment
);
142 #ifdef ASM_OUTPUT_DWARF_OFFSET
143 ASM_OUTPUT_DWARF_OFFSET (asm_out_file
, size
, label
);
145 dw2_assemble_integer (size
, gen_rtx_SYMBOL_REF (Pmode
, label
));
148 if (flag_debug_asm
&& comment
)
150 fprintf (asm_out_file
, "\t%s ", ASM_COMMENT_START
);
151 vfprintf (asm_out_file
, comment
, ap
);
153 fputc ('\n', asm_out_file
);
158 /* Output a self-relative reference to a label, possibly in a
159 different section or object file. */
162 dw2_asm_output_pcrel
VPARAMS ((int size ATTRIBUTE_UNUSED
,
163 const char *label ATTRIBUTE_UNUSED
,
164 const char *comment
, ...))
166 VA_OPEN (ap
, comment
);
167 VA_FIXEDARG (ap
, int, size
);
168 VA_FIXEDARG (ap
, const char *, label
);
169 VA_FIXEDARG (ap
, const char *, comment
);
171 #ifdef ASM_OUTPUT_DWARF_PCREL
172 ASM_OUTPUT_DWARF_PCREL (asm_out_file
, size
, label
);
174 dw2_assemble_integer (size
,
175 gen_rtx_MINUS (Pmode
,
176 gen_rtx_SYMBOL_REF (Pmode
, label
),
180 if (flag_debug_asm
&& comment
)
182 fprintf (asm_out_file
, "\t%s ", ASM_COMMENT_START
);
183 vfprintf (asm_out_file
, comment
, ap
);
185 fputc ('\n', asm_out_file
);
190 /* Output an absolute reference to a label. */
193 dw2_asm_output_addr
VPARAMS ((int size
, const char *label
,
194 const char *comment
, ...))
196 VA_OPEN (ap
, comment
);
197 VA_FIXEDARG (ap
, int, size
);
198 VA_FIXEDARG (ap
, const char *, label
);
199 VA_FIXEDARG (ap
, const char *, comment
);
201 dw2_assemble_integer (size
, gen_rtx_SYMBOL_REF (Pmode
, label
));
203 if (flag_debug_asm
&& comment
)
205 fprintf (asm_out_file
, "\t%s ", ASM_COMMENT_START
);
206 vfprintf (asm_out_file
, comment
, ap
);
208 fputc ('\n', asm_out_file
);
213 /* Similar, but use an RTX expression instead of a text label. */
216 dw2_asm_output_addr_rtx
VPARAMS ((int size
, rtx addr
,
217 const char *comment
, ...))
219 VA_OPEN (ap
, comment
);
220 VA_FIXEDARG (ap
, int, size
);
221 VA_FIXEDARG (ap
, rtx
, addr
);
222 VA_FIXEDARG (ap
, const char *, comment
);
224 dw2_assemble_integer (size
, addr
);
226 if (flag_debug_asm
&& comment
)
228 fprintf (asm_out_file
, "\t%s ", ASM_COMMENT_START
);
229 vfprintf (asm_out_file
, comment
, ap
);
231 fputc ('\n', asm_out_file
);
237 dw2_asm_output_nstring
VPARAMS ((const char *str
, size_t orig_len
,
238 const char *comment
, ...))
242 VA_OPEN (ap
, comment
);
243 VA_FIXEDARG (ap
, const char *, str
);
244 VA_FIXEDARG (ap
, size_t, orig_len
);
245 VA_FIXEDARG (ap
, const char *, comment
);
249 if (len
== (size_t) -1)
252 if (flag_debug_asm
&& comment
)
254 fputs ("\t.ascii \"", asm_out_file
);
255 for (i
= 0; i
< len
; i
++)
258 if (c
== '\"' || c
== '\\')
259 fputc ('\\', asm_out_file
);
261 fputc (c
, asm_out_file
);
263 fprintf (asm_out_file
, "\\%o", c
);
265 fprintf (asm_out_file
, "\\0\"\t%s ", ASM_COMMENT_START
);
266 vfprintf (asm_out_file
, comment
, ap
);
267 fputc ('\n', asm_out_file
);
271 /* If an explicit length was given, we can't assume there
272 is a null termination in the string buffer. */
273 if (orig_len
== (size_t) -1)
275 ASM_OUTPUT_ASCII (asm_out_file
, str
, len
);
276 if (orig_len
!= (size_t) -1)
277 assemble_integer (const0_rtx
, 1, BITS_PER_UNIT
, 1);
284 /* Return the size of an unsigned LEB128 quantity. */
287 size_of_uleb128 (value
)
288 unsigned HOST_WIDE_INT value
;
302 /* Return the size of a signed LEB128 quantity. */
305 size_of_sleb128 (value
)
312 byte
= (value
& 0x7f);
316 while (!((value
== 0 && (byte
& 0x40) == 0)
317 || (value
== -1 && (byte
& 0x40) != 0)));
322 /* Given an encoding, return the number of bytes the format occupies.
323 This is only defined for fixed-size encodings, and so does not
327 size_of_encoded_value (encoding
)
330 if (encoding
== DW_EH_PE_omit
)
333 switch (encoding
& 0x07)
335 case DW_EH_PE_absptr
:
336 return POINTER_SIZE
/ BITS_PER_UNIT
;
337 case DW_EH_PE_udata2
:
339 case DW_EH_PE_udata4
:
341 case DW_EH_PE_udata8
:
347 /* Yield a name for a given pointer encoding. */
350 eh_data_format_name (format
)
353 #if HAVE_DESIGNATED_INITIALIZERS
354 #define S(p, v) [p] = v,
356 #define S(p, v) case p: return v;
359 #if HAVE_DESIGNATED_INITIALIZERS
360 __extension__
static const char * const format_names
[256] = {
365 S(DW_EH_PE_absptr
, "absolute")
366 S(DW_EH_PE_omit
, "omit")
367 S(DW_EH_PE_aligned
, "aligned absolute")
369 S(DW_EH_PE_uleb128
, "uleb128")
370 S(DW_EH_PE_udata2
, "udata2")
371 S(DW_EH_PE_udata4
, "udata4")
372 S(DW_EH_PE_udata8
, "udata8")
373 S(DW_EH_PE_sleb128
, "sleb128")
374 S(DW_EH_PE_sdata2
, "sdata2")
375 S(DW_EH_PE_sdata4
, "sdata4")
376 S(DW_EH_PE_sdata8
, "sdata8")
378 S(DW_EH_PE_absptr
| DW_EH_PE_pcrel
, "pcrel")
379 S(DW_EH_PE_uleb128
| DW_EH_PE_pcrel
, "pcrel uleb128")
380 S(DW_EH_PE_udata2
| DW_EH_PE_pcrel
, "pcrel udata2")
381 S(DW_EH_PE_udata4
| DW_EH_PE_pcrel
, "pcrel udata4")
382 S(DW_EH_PE_udata8
| DW_EH_PE_pcrel
, "pcrel udata8")
383 S(DW_EH_PE_sleb128
| DW_EH_PE_pcrel
, "pcrel sleb128")
384 S(DW_EH_PE_sdata2
| DW_EH_PE_pcrel
, "pcrel sdata2")
385 S(DW_EH_PE_sdata4
| DW_EH_PE_pcrel
, "pcrel sdata4")
386 S(DW_EH_PE_sdata8
| DW_EH_PE_pcrel
, "pcrel sdata8")
388 S(DW_EH_PE_absptr
| DW_EH_PE_textrel
, "textrel")
389 S(DW_EH_PE_uleb128
| DW_EH_PE_textrel
, "textrel uleb128")
390 S(DW_EH_PE_udata2
| DW_EH_PE_textrel
, "textrel udata2")
391 S(DW_EH_PE_udata4
| DW_EH_PE_textrel
, "textrel udata4")
392 S(DW_EH_PE_udata8
| DW_EH_PE_textrel
, "textrel udata8")
393 S(DW_EH_PE_sleb128
| DW_EH_PE_textrel
, "textrel sleb128")
394 S(DW_EH_PE_sdata2
| DW_EH_PE_textrel
, "textrel sdata2")
395 S(DW_EH_PE_sdata4
| DW_EH_PE_textrel
, "textrel sdata4")
396 S(DW_EH_PE_sdata8
| DW_EH_PE_textrel
, "textrel sdata8")
398 S(DW_EH_PE_absptr
| DW_EH_PE_datarel
, "datarel")
399 S(DW_EH_PE_uleb128
| DW_EH_PE_datarel
, "datarel uleb128")
400 S(DW_EH_PE_udata2
| DW_EH_PE_datarel
, "datarel udata2")
401 S(DW_EH_PE_udata4
| DW_EH_PE_datarel
, "datarel udata4")
402 S(DW_EH_PE_udata8
| DW_EH_PE_datarel
, "datarel udata8")
403 S(DW_EH_PE_sleb128
| DW_EH_PE_datarel
, "datarel sleb128")
404 S(DW_EH_PE_sdata2
| DW_EH_PE_datarel
, "datarel sdata2")
405 S(DW_EH_PE_sdata4
| DW_EH_PE_datarel
, "datarel sdata4")
406 S(DW_EH_PE_sdata8
| DW_EH_PE_datarel
, "datarel sdata8")
408 S(DW_EH_PE_absptr
| DW_EH_PE_funcrel
, "funcrel")
409 S(DW_EH_PE_uleb128
| DW_EH_PE_funcrel
, "funcrel uleb128")
410 S(DW_EH_PE_udata2
| DW_EH_PE_funcrel
, "funcrel udata2")
411 S(DW_EH_PE_udata4
| DW_EH_PE_funcrel
, "funcrel udata4")
412 S(DW_EH_PE_udata8
| DW_EH_PE_funcrel
, "funcrel udata8")
413 S(DW_EH_PE_sleb128
| DW_EH_PE_funcrel
, "funcrel sleb128")
414 S(DW_EH_PE_sdata2
| DW_EH_PE_funcrel
, "funcrel sdata2")
415 S(DW_EH_PE_sdata4
| DW_EH_PE_funcrel
, "funcrel sdata4")
416 S(DW_EH_PE_sdata8
| DW_EH_PE_funcrel
, "funcrel sdata8")
418 S(DW_EH_PE_indirect
| DW_EH_PE_absptr
| DW_EH_PE_pcrel
,
420 S(DW_EH_PE_indirect
| DW_EH_PE_uleb128
| DW_EH_PE_pcrel
,
421 "indirect pcrel uleb128")
422 S(DW_EH_PE_indirect
| DW_EH_PE_udata2
| DW_EH_PE_pcrel
,
423 "indirect pcrel udata2")
424 S(DW_EH_PE_indirect
| DW_EH_PE_udata4
| DW_EH_PE_pcrel
,
425 "indirect pcrel udata4")
426 S(DW_EH_PE_indirect
| DW_EH_PE_udata8
| DW_EH_PE_pcrel
,
427 "indirect pcrel udata8")
428 S(DW_EH_PE_indirect
| DW_EH_PE_sleb128
| DW_EH_PE_pcrel
,
429 "indirect pcrel sleb128")
430 S(DW_EH_PE_indirect
| DW_EH_PE_sdata2
| DW_EH_PE_pcrel
,
431 "indirect pcrel sdata2")
432 S(DW_EH_PE_indirect
| DW_EH_PE_sdata4
| DW_EH_PE_pcrel
,
433 "indirect pcrel sdata4")
434 S(DW_EH_PE_indirect
| DW_EH_PE_sdata8
| DW_EH_PE_pcrel
,
435 "indirect pcrel sdata8")
437 S(DW_EH_PE_indirect
| DW_EH_PE_absptr
| DW_EH_PE_textrel
,
439 S(DW_EH_PE_indirect
| DW_EH_PE_uleb128
| DW_EH_PE_textrel
,
440 "indirect textrel uleb128")
441 S(DW_EH_PE_indirect
| DW_EH_PE_udata2
| DW_EH_PE_textrel
,
442 "indirect textrel udata2")
443 S(DW_EH_PE_indirect
| DW_EH_PE_udata4
| DW_EH_PE_textrel
,
444 "indirect textrel udata4")
445 S(DW_EH_PE_indirect
| DW_EH_PE_udata8
| DW_EH_PE_textrel
,
446 "indirect textrel udata8")
447 S(DW_EH_PE_indirect
| DW_EH_PE_sleb128
| DW_EH_PE_textrel
,
448 "indirect textrel sleb128")
449 S(DW_EH_PE_indirect
| DW_EH_PE_sdata2
| DW_EH_PE_textrel
,
450 "indirect textrel sdata2")
451 S(DW_EH_PE_indirect
| DW_EH_PE_sdata4
| DW_EH_PE_textrel
,
452 "indirect textrel sdata4")
453 S(DW_EH_PE_indirect
| DW_EH_PE_sdata8
| DW_EH_PE_textrel
,
454 "indirect textrel sdata8")
456 S(DW_EH_PE_indirect
| DW_EH_PE_absptr
| DW_EH_PE_datarel
,
458 S(DW_EH_PE_indirect
| DW_EH_PE_uleb128
| DW_EH_PE_datarel
,
459 "indirect datarel uleb128")
460 S(DW_EH_PE_indirect
| DW_EH_PE_udata2
| DW_EH_PE_datarel
,
461 "indirect datarel udata2")
462 S(DW_EH_PE_indirect
| DW_EH_PE_udata4
| DW_EH_PE_datarel
,
463 "indirect datarel udata4")
464 S(DW_EH_PE_indirect
| DW_EH_PE_udata8
| DW_EH_PE_datarel
,
465 "indirect datarel udata8")
466 S(DW_EH_PE_indirect
| DW_EH_PE_sleb128
| DW_EH_PE_datarel
,
467 "indirect datarel sleb128")
468 S(DW_EH_PE_indirect
| DW_EH_PE_sdata2
| DW_EH_PE_datarel
,
469 "indirect datarel sdata2")
470 S(DW_EH_PE_indirect
| DW_EH_PE_sdata4
| DW_EH_PE_datarel
,
471 "indirect datarel sdata4")
472 S(DW_EH_PE_indirect
| DW_EH_PE_sdata8
| DW_EH_PE_datarel
,
473 "indirect datarel sdata8")
475 S(DW_EH_PE_indirect
| DW_EH_PE_absptr
| DW_EH_PE_funcrel
,
477 S(DW_EH_PE_indirect
| DW_EH_PE_uleb128
| DW_EH_PE_funcrel
,
478 "indirect funcrel uleb128")
479 S(DW_EH_PE_indirect
| DW_EH_PE_udata2
| DW_EH_PE_funcrel
,
480 "indirect funcrel udata2")
481 S(DW_EH_PE_indirect
| DW_EH_PE_udata4
| DW_EH_PE_funcrel
,
482 "indirect funcrel udata4")
483 S(DW_EH_PE_indirect
| DW_EH_PE_udata8
| DW_EH_PE_funcrel
,
484 "indirect funcrel udata8")
485 S(DW_EH_PE_indirect
| DW_EH_PE_sleb128
| DW_EH_PE_funcrel
,
486 "indirect funcrel sleb128")
487 S(DW_EH_PE_indirect
| DW_EH_PE_sdata2
| DW_EH_PE_funcrel
,
488 "indirect funcrel sdata2")
489 S(DW_EH_PE_indirect
| DW_EH_PE_sdata4
| DW_EH_PE_funcrel
,
490 "indirect funcrel sdata4")
491 S(DW_EH_PE_indirect
| DW_EH_PE_sdata8
| DW_EH_PE_funcrel
,
492 "indirect funcrel sdata8")
494 #if HAVE_DESIGNATED_INITIALIZERS
497 if (format
< 0 || format
> 0xff || format_names
[format
] == NULL
)
499 return format_names
[format
];
506 /* Output an unsigned LEB128 quantity. */
509 dw2_asm_output_data_uleb128
VPARAMS ((unsigned HOST_WIDE_INT value
,
510 const char *comment
, ...))
512 VA_OPEN (ap
, comment
);
513 VA_FIXEDARG (ap
, unsigned HOST_WIDE_INT
, value
);
514 VA_FIXEDARG (ap
, const char *, comment
);
516 #ifdef HAVE_AS_LEB128
517 fprintf (asm_out_file
, "\t.uleb128 " HOST_WIDE_INT_PRINT_HEX
, value
);
519 if (flag_debug_asm
&& comment
)
521 fprintf (asm_out_file
, "\t%s ", ASM_COMMENT_START
);
522 vfprintf (asm_out_file
, comment
, ap
);
526 unsigned HOST_WIDE_INT work
= value
;
527 const char *byte_op
= targetm
.asm_out
.byte_op
;
530 fputs (byte_op
, asm_out_file
);
533 int byte
= (work
& 0x7f);
536 /* More bytes to follow. */
541 fprintf (asm_out_file
, "0x%x", byte
);
543 fputc (',', asm_out_file
);
546 assemble_integer (GEN_INT (byte
), 1, BITS_PER_UNIT
, 1);
552 fprintf (asm_out_file
, "\t%s uleb128 " HOST_WIDE_INT_PRINT_HEX
,
553 ASM_COMMENT_START
, value
);
556 fputs ("; ", asm_out_file
);
557 vfprintf (asm_out_file
, comment
, ap
);
562 fputc ('\n', asm_out_file
);
567 /* Output a signed LEB128 quantity. */
570 dw2_asm_output_data_sleb128
VPARAMS ((HOST_WIDE_INT value
,
571 const char *comment
, ...))
573 VA_OPEN (ap
, comment
);
574 VA_FIXEDARG (ap
, HOST_WIDE_INT
, value
);
575 VA_FIXEDARG (ap
, const char *, comment
);
577 #ifdef HAVE_AS_LEB128
578 fprintf (asm_out_file
, "\t.sleb128 " HOST_WIDE_INT_PRINT_DEC
, value
);
580 if (flag_debug_asm
&& comment
)
582 fprintf (asm_out_file
, "\t%s ", ASM_COMMENT_START
);
583 vfprintf (asm_out_file
, comment
, ap
);
587 HOST_WIDE_INT work
= value
;
589 const char *byte_op
= targetm
.asm_out
.byte_op
;
592 fputs (byte_op
, asm_out_file
);
595 byte
= (work
& 0x7f);
596 /* arithmetic shift */
598 more
= !((work
== 0 && (byte
& 0x40) == 0)
599 || (work
== -1 && (byte
& 0x40) != 0));
605 fprintf (asm_out_file
, "0x%x", byte
);
607 fputc (',', asm_out_file
);
610 assemble_integer (GEN_INT (byte
), 1, BITS_PER_UNIT
, 1);
616 fprintf (asm_out_file
, "\t%s sleb128 " HOST_WIDE_INT_PRINT_DEC
,
617 ASM_COMMENT_START
, value
);
620 fputs ("; ", asm_out_file
);
621 vfprintf (asm_out_file
, comment
, ap
);
626 fputc ('\n', asm_out_file
);
632 dw2_asm_output_delta_uleb128
VPARAMS ((const char *lab1 ATTRIBUTE_UNUSED
,
633 const char *lab2 ATTRIBUTE_UNUSED
,
634 const char *comment
, ...))
636 VA_OPEN (ap
, comment
);
637 VA_FIXEDARG (ap
, const char *, lab1
);
638 VA_FIXEDARG (ap
, const char *, lab2
);
639 VA_FIXEDARG (ap
, const char *, comment
);
641 #ifdef HAVE_AS_LEB128
642 fputs ("\t.uleb128 ", asm_out_file
);
643 assemble_name (asm_out_file
, lab1
);
644 fputc ('-', asm_out_file
);
645 assemble_name (asm_out_file
, lab2
);
650 if (flag_debug_asm
&& comment
)
652 fprintf (asm_out_file
, "\t%s ", ASM_COMMENT_START
);
653 vfprintf (asm_out_file
, comment
, ap
);
655 fputc ('\n', asm_out_file
);
661 dw2_asm_output_delta_sleb128
VPARAMS ((const char *lab1 ATTRIBUTE_UNUSED
,
662 const char *lab2 ATTRIBUTE_UNUSED
,
663 const char *comment
, ...))
665 VA_OPEN (ap
, comment
);
666 VA_FIXEDARG (ap
, const char *, lab1
);
667 VA_FIXEDARG (ap
, const char *, lab2
);
668 VA_FIXEDARG (ap
, const char *, comment
);
670 #ifdef HAVE_AS_LEB128
671 fputs ("\t.sleb128 ", asm_out_file
);
672 assemble_name (asm_out_file
, lab1
);
673 fputc ('-', asm_out_file
);
674 assemble_name (asm_out_file
, lab2
);
679 if (flag_debug_asm
&& comment
)
681 fprintf (asm_out_file
, "\t%s ", ASM_COMMENT_START
);
682 vfprintf (asm_out_file
, comment
, ap
);
684 fputc ('\n', asm_out_file
);
689 static rtx dw2_force_const_mem
PARAMS ((rtx
));
690 static int dw2_output_indirect_constant_1
PARAMS ((splay_tree_node
, void *));
692 static GTY((param1_is (char *), param2_is (tree
))) splay_tree indirect_pool
;
694 static GTY(()) int dw2_const_labelno
;
696 #if defined(HAVE_GAS_HIDDEN) && defined(SUPPORTS_ONE_ONLY)
697 # define USE_LINKONCE_INDIRECT 1
699 # define USE_LINKONCE_INDIRECT 0
702 /* Put X, a SYMBOL_REF, in memory. Return a SYMBOL_REF to the allocated
703 memory. Differs from force_const_mem in that a single pool is used for
704 the entire unit of translation, and the memory is not guaranteed to be
705 "near" the function in any interesting sense. */
708 dw2_force_const_mem (x
)
711 splay_tree_node node
;
716 indirect_pool
= splay_tree_new_ggc (splay_tree_compare_pointers
);
718 if (GET_CODE (x
) != SYMBOL_REF
)
721 str
= (* targetm
.strip_name_encoding
) (XSTR (x
, 0));
722 node
= splay_tree_lookup (indirect_pool
, (splay_tree_key
) str
);
724 decl
= (tree
) node
->value
;
729 if (USE_LINKONCE_INDIRECT
)
731 char *ref_name
= alloca (strlen (str
) + sizeof "DW.ref.");
733 sprintf (ref_name
, "DW.ref.%s", str
);
734 id
= get_identifier (ref_name
);
735 decl
= build_decl (VAR_DECL
, id
, ptr_type_node
);
736 DECL_ARTIFICIAL (decl
) = 1;
737 TREE_PUBLIC (decl
) = 1;
738 DECL_INITIAL (decl
) = decl
;
739 make_decl_one_only (decl
);
745 ASM_GENERATE_INTERNAL_LABEL (label
, "LDFCM", dw2_const_labelno
);
747 id
= get_identifier (label
);
748 decl
= build_decl (VAR_DECL
, id
, ptr_type_node
);
749 DECL_ARTIFICIAL (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 (node
, data
)
770 splay_tree_node node
;
771 void* data ATTRIBUTE_UNUSED
;
776 sym
= (const char *) node
->key
;
777 sym_ref
= gen_rtx_SYMBOL_REF (Pmode
, sym
);
778 if (USE_LINKONCE_INDIRECT
)
779 fprintf (asm_out_file
, "\t.hidden DW.ref.%s\n", sym
);
780 assemble_variable ((tree
) node
->value
, 1, 1, 1);
781 assemble_integer (sym_ref
, POINTER_SIZE
/ BITS_PER_UNIT
, POINTER_SIZE
, 1);
786 /* Emit the constants queued through dw2_force_const_mem. */
789 dw2_output_indirect_constants ()
792 splay_tree_foreach (indirect_pool
, dw2_output_indirect_constant_1
, NULL
);
795 /* Like dw2_asm_output_addr_rtx, but encode the pointer as directed. */
798 dw2_asm_output_encoded_addr_rtx
VPARAMS ((int encoding
,
800 const char *comment
, ...))
804 VA_OPEN (ap
, comment
);
805 VA_FIXEDARG (ap
, int, encoding
);
806 VA_FIXEDARG (ap
, rtx
, addr
);
807 VA_FIXEDARG (ap
, const char *, 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,
841 or better, across the entire application (or DSO). */
842 addr
= dw2_force_const_mem (addr
);
843 encoding
&= ~DW_EH_PE_indirect
;
847 switch (encoding
& 0xF0)
849 case DW_EH_PE_absptr
:
850 dw2_assemble_integer (size
, addr
);
854 if (GET_CODE (addr
) != SYMBOL_REF
)
856 #ifdef ASM_OUTPUT_DWARF_PCREL
857 ASM_OUTPUT_DWARF_PCREL (asm_out_file
, size
, XSTR (addr
, 0));
859 dw2_assemble_integer (size
, gen_rtx_MINUS (Pmode
, addr
, pc_rtx
));
864 /* Other encodings should have been handled by
865 ASM_MAYBE_OUTPUT_ENCODED_ADDR_RTX. */
869 #ifdef ASM_MAYBE_OUTPUT_ENCODED_ADDR_RTX
874 if (flag_debug_asm
&& comment
)
876 fprintf (asm_out_file
, "\t%s ", ASM_COMMENT_START
);
877 vfprintf (asm_out_file
, comment
, ap
);
879 fputc ('\n', asm_out_file
);
884 #include "gt-dwarf2asm.h"