1 /* Dwarf2 assembler output helper routines.
2 Copyright (C) 2001 Free Software Foundation, Inc.
4 This file is part of GNU CC.
6 GNU CC is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GNU CC is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU CC; see the file COPYING. If not, write to
18 the Free Software Foundation, 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
28 #include "dwarf2asm.h"
30 #include "splay-tree.h"
35 /* How to start an assembler comment. */
36 #ifndef ASM_COMMENT_START
37 #define ASM_COMMENT_START ";#"
40 /* Definitions of defaults for assembler-dependent names of various
41 pseudo-ops and section names. These may be overridden in the tm.h
42 file (if necessary) for a particular assembler. */
44 #ifdef OBJECT_FORMAT_ELF
45 #ifndef UNALIGNED_SHORT_ASM_OP
46 #define UNALIGNED_SHORT_ASM_OP "\t.2byte\t"
48 #ifndef UNALIGNED_INT_ASM_OP
49 #define UNALIGNED_INT_ASM_OP "\t.4byte\t"
51 #ifndef UNALIGNED_DOUBLE_INT_ASM_OP
52 #define UNALIGNED_DOUBLE_INT_ASM_OP "\t.8byte\t"
54 #endif /* OBJECT_FORMAT_ELF */
57 #define ASM_BYTE_OP "\t.byte\t"
60 /* We don't have unaligned support, let's hope the normal output works for
61 .debug_frame. But we know it won't work for .debug_info. */
62 #if !defined(UNALIGNED_INT_ASM_OP) && defined(DWARF2_DEBUGGING_INFO)
63 #error DWARF2_DEBUGGING_INFO requires UNALIGNED_INT_ASM_OP.
67 #ifdef UNALIGNED_INT_ASM_OP
68 static const char * unaligned_integer_asm_op
PARAMS ((int));
70 static inline const char *
71 unaligned_integer_asm_op (size
)
81 op
= UNALIGNED_SHORT_ASM_OP
;
84 op
= UNALIGNED_INT_ASM_OP
;
87 #ifdef UNALIGNED_DOUBLE_INT_ASM_OP
88 op
= UNALIGNED_DOUBLE_INT_ASM_OP
;
96 #endif /* UNALIGNED_INT_ASM_OP */
98 /* Output an immediate constant in a given size. */
101 dw2_asm_output_data
VPARAMS ((int size
, unsigned HOST_WIDE_INT value
,
102 const char *comment
, ...))
104 #ifndef ANSI_PROTOTYPES
106 unsigned HOST_WIDE_INT value
;
111 VA_START (ap
, comment
);
113 #ifndef ANSI_PROTOTYPES
114 size
= va_arg (ap
, int);
115 value
= va_arg (ap
, unsigned HOST_WIDE_INT
);
116 comment
= va_arg (ap
, const char *);
119 if (size
* 8 < HOST_BITS_PER_WIDE_INT
)
120 value
&= ~(~(unsigned HOST_WIDE_INT
)0 << (size
* 8));
122 #ifdef UNALIGNED_INT_ASM_OP
123 fputs (unaligned_integer_asm_op (size
), asm_out_file
);
124 fprintf (asm_out_file
, HOST_WIDE_INT_PRINT_HEX
, value
);
126 assemble_integer (GEN_INT (value
), size
, 1);
129 if (flag_debug_asm
&& comment
)
131 fprintf (asm_out_file
, "\t%s ", ASM_COMMENT_START
);
132 vfprintf (asm_out_file
, comment
, ap
);
134 fputc ('\n', asm_out_file
);
139 /* Output the difference between two symbols in a given size. */
140 /* ??? There appear to be assemblers that do not like such
141 subtraction, but do support ASM_SET_OP. It's unfortunately
142 impossible to do here, since the ASM_SET_OP for the difference
143 symbol must appear after both symbols are defined. */
146 dw2_asm_output_delta
VPARAMS ((int size
, const char *lab1
, const char *lab2
,
147 const char *comment
, ...))
149 #ifndef ANSI_PROTOTYPES
151 const char *lab1
, *lab2
;
156 VA_START (ap
, comment
);
158 #ifndef ANSI_PROTOTYPES
159 size
= va_arg (ap
, int);
160 lab1
= va_arg (ap
, const char *);
161 lab2
= va_arg (ap
, const char *);
162 comment
= va_arg (ap
, const char *);
165 #ifdef UNALIGNED_INT_ASM_OP
166 fputs (unaligned_integer_asm_op (size
), asm_out_file
);
167 assemble_name (asm_out_file
, lab1
);
168 fputc ('-', asm_out_file
);
169 assemble_name (asm_out_file
, lab2
);
171 assemble_integer (gen_rtx_MINUS (smallest_mode_for_size (size
, MODE_INT
),
172 gen_rtx_SYMBOL_REF (Pmode
, lab1
),
173 gen_rtx_SYMBOL_REF (Pmode
, lab2
)),
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
);
187 /* Output a section-relative reference to a label. In general this
188 can only be done for debugging symbols. E.g. on most targets with
189 the GNU linker, this is accomplished with a direct reference and
190 the knowledge that the debugging section will be placed at VMA 0.
191 Some targets have special relocations for this that we must use. */
194 dw2_asm_output_offset
VPARAMS ((int size
, const char *label
,
195 const char *comment
, ...))
197 #ifndef ANSI_PROTOTYPES
204 VA_START (ap
, comment
);
206 #ifndef ANSI_PROTOTYPES
207 size
= va_arg (ap
, int);
208 label
= va_arg (ap
, const char *);
209 comment
= va_arg (ap
, const char *);
212 #ifdef ASM_OUTPUT_DWARF_OFFSET
213 ASM_OUTPUT_DWARF_OFFSET (asm_out_file
, size
, label
);
215 #ifdef UNALIGNED_INT_ASM_OP
216 fputs (unaligned_integer_asm_op (size
), asm_out_file
);
217 assemble_name (asm_out_file
, label
);
219 assemble_integer (gen_rtx_SYMBOL_REF (Pmode
, label
), size
, 1);
223 if (flag_debug_asm
&& comment
)
225 fprintf (asm_out_file
, "\t%s ", ASM_COMMENT_START
);
226 vfprintf (asm_out_file
, comment
, ap
);
228 fputc ('\n', asm_out_file
);
233 /* Output a self-relative reference to a label, possibly in a
234 different section or object file. */
237 dw2_asm_output_pcrel
VPARAMS ((int size
, const char *label
,
238 const char *comment
, ...))
240 #ifndef ANSI_PROTOTYPES
247 VA_START (ap
, comment
);
249 #ifndef ANSI_PROTOTYPES
250 size
= va_arg (ap
, int);
251 label
= va_arg (ap
, const char *);
252 comment
= va_arg (ap
, const char *);
255 #ifdef ASM_OUTPUT_DWARF_PCREL
256 ASM_OUTPUT_DWARF_PCREL (asm_out_file
, size
, label
);
258 #ifdef UNALIGNED_INT_ASM_OP
259 fputs (unaligned_integer_asm_op (size
), asm_out_file
);
260 assemble_name (asm_out_file
, label
);
261 fputc ('-', asm_out_file
);
262 fputc ('.', asm_out_file
);
268 if (flag_debug_asm
&& comment
)
270 fprintf (asm_out_file
, "\t%s ", ASM_COMMENT_START
);
271 vfprintf (asm_out_file
, comment
, ap
);
273 fputc ('\n', asm_out_file
);
278 /* Output an absolute reference to a label. */
281 dw2_asm_output_addr
VPARAMS ((int size
, const char *label
,
282 const char *comment
, ...))
284 #ifndef ANSI_PROTOTYPES
291 VA_START (ap
, comment
);
293 #ifndef ANSI_PROTOTYPES
294 size
= va_arg (ap
, int);
295 label
= va_arg (ap
, const char *);
296 comment
= va_arg (ap
, const char *);
299 #ifdef UNALIGNED_INT_ASM_OP
300 fputs (unaligned_integer_asm_op (size
), asm_out_file
);
301 assemble_name (asm_out_file
, label
);
303 assemble_integer (gen_rtx_SYMBOL_REF (Pmode
, label
), size
, 1);
306 if (flag_debug_asm
&& comment
)
308 fprintf (asm_out_file
, "\t%s ", ASM_COMMENT_START
);
309 vfprintf (asm_out_file
, comment
, ap
);
311 fputc ('\n', asm_out_file
);
316 /* Similar, but use an RTX expression instead of a text label. */
319 dw2_asm_output_addr_rtx
VPARAMS ((int size
, rtx addr
,
320 const char *comment
, ...))
322 #ifndef ANSI_PROTOTYPES
329 VA_START (ap
, comment
);
331 #ifndef ANSI_PROTOTYPES
332 size
= va_arg (ap
, int);
333 addr
= va_arg (ap
, rtx
);
334 comment
= va_arg (ap
, const char *);
337 #ifdef UNALIGNED_INT_ASM_OP
338 fputs (unaligned_integer_asm_op (size
), asm_out_file
);
339 output_addr_const (asm_out_file
, addr
);
341 assemble_integer (addr
, size
, 1);
344 if (flag_debug_asm
&& comment
)
346 fprintf (asm_out_file
, "\t%s ", ASM_COMMENT_START
);
347 vfprintf (asm_out_file
, comment
, ap
);
349 fputc ('\n', asm_out_file
);
355 dw2_asm_output_nstring
VPARAMS ((const char *str
, size_t orig_len
,
356 const char *comment
, ...))
358 #ifndef ANSI_PROTOTYPES
364 size_t i
, len
= orig_len
;
366 VA_START (ap
, comment
);
368 #ifndef ANSI_PROTOTYPES
369 str
= va_arg (ap
, const char *);
370 len
= va_arg (ap
, size_t);
371 comment
= va_arg (ap
, const char *);
374 if (len
== (size_t) -1)
377 if (flag_debug_asm
&& comment
)
379 fputs ("\t.ascii \"", asm_out_file
);
380 for (i
= 0; i
< len
; i
++)
383 if (c
== '\"' || c
== '\\')
384 fputc ('\\', asm_out_file
);
386 fputc (c
, asm_out_file
);
388 fprintf (asm_out_file
, "\\%o", c
);
390 fprintf (asm_out_file
, "\\0\"\t%s ", ASM_COMMENT_START
);
391 vfprintf (asm_out_file
, comment
, ap
);
392 fputc ('\n', asm_out_file
);
396 /* If an explicit length was given, we can't assume there
397 is a null termination in the string buffer. */
398 if (orig_len
== (size_t) -1)
400 ASM_OUTPUT_ASCII (asm_out_file
, str
, len
);
401 if (orig_len
!= (size_t) -1)
402 fprintf (asm_out_file
, "%s0\n", ASM_BYTE_OP
);
409 /* Return the size of an unsigned LEB128 quantity. */
412 size_of_uleb128 (value
)
413 unsigned HOST_WIDE_INT value
;
419 byte
= (value
& 0x7f);
428 /* Return the size of a signed LEB128 quantity. */
431 size_of_sleb128 (value
)
438 byte
= (value
& 0x7f);
442 while (!((value
== 0 && (byte
& 0x40) == 0)
443 || (value
== -1 && (byte
& 0x40) != 0)));
448 /* Given an encoding, return the number of bytes the format occupies.
449 This is only defined for fixed-size encodings, and so does not
453 size_of_encoded_value (encoding
)
456 if (encoding
== DW_EH_PE_omit
)
459 switch (encoding
& 0x07)
461 case DW_EH_PE_absptr
:
462 return POINTER_SIZE
/ BITS_PER_UNIT
;
463 case DW_EH_PE_udata2
:
465 case DW_EH_PE_udata4
:
467 case DW_EH_PE_udata8
:
473 /* Yield a name for a given pointer encoding. */
476 eh_data_format_name (format
)
479 #if HAVE_DESIGNATED_INITIALIZERS
480 #define S(p, v) [p] = v,
482 #define S(p, v) case p: return v;
485 #if HAVE_DESIGNATED_INITIALIZERS
486 __extension__
static const char * const format_names
[256] = {
491 S(DW_EH_PE_absptr
, "absolute")
492 S(DW_EH_PE_omit
, "omit")
494 S(DW_EH_PE_uleb128
, "uleb128")
495 S(DW_EH_PE_udata2
, "udata2")
496 S(DW_EH_PE_udata4
, "udata4")
497 S(DW_EH_PE_udata8
, "udata8")
498 S(DW_EH_PE_sleb128
, "sleb128")
499 S(DW_EH_PE_sdata2
, "sdata2")
500 S(DW_EH_PE_sdata4
, "sdata4")
501 S(DW_EH_PE_sdata8
, "sdata8")
503 S(DW_EH_PE_absptr
| DW_EH_PE_pcrel
, "pcrel")
504 S(DW_EH_PE_uleb128
| DW_EH_PE_pcrel
, "pcrel uleb128")
505 S(DW_EH_PE_udata2
| DW_EH_PE_pcrel
, "pcrel udata2")
506 S(DW_EH_PE_udata4
| DW_EH_PE_pcrel
, "pcrel udata4")
507 S(DW_EH_PE_udata8
| DW_EH_PE_pcrel
, "pcrel udata8")
508 S(DW_EH_PE_sleb128
| DW_EH_PE_pcrel
, "pcrel sleb128")
509 S(DW_EH_PE_sdata2
| DW_EH_PE_pcrel
, "pcrel sdata2")
510 S(DW_EH_PE_sdata4
| DW_EH_PE_pcrel
, "pcrel sdata4")
511 S(DW_EH_PE_sdata8
| DW_EH_PE_pcrel
, "pcrel sdata8")
513 S(DW_EH_PE_absptr
| DW_EH_PE_textrel
, "textrel")
514 S(DW_EH_PE_uleb128
| DW_EH_PE_textrel
, "textrel uleb128")
515 S(DW_EH_PE_udata2
| DW_EH_PE_textrel
, "textrel udata2")
516 S(DW_EH_PE_udata4
| DW_EH_PE_textrel
, "textrel udata4")
517 S(DW_EH_PE_udata8
| DW_EH_PE_textrel
, "textrel udata8")
518 S(DW_EH_PE_sleb128
| DW_EH_PE_textrel
, "textrel sleb128")
519 S(DW_EH_PE_sdata2
| DW_EH_PE_textrel
, "textrel sdata2")
520 S(DW_EH_PE_sdata4
| DW_EH_PE_textrel
, "textrel sdata4")
521 S(DW_EH_PE_sdata8
| DW_EH_PE_textrel
, "textrel sdata8")
523 S(DW_EH_PE_absptr
| DW_EH_PE_datarel
, "datarel")
524 S(DW_EH_PE_uleb128
| DW_EH_PE_datarel
, "datarel uleb128")
525 S(DW_EH_PE_udata2
| DW_EH_PE_datarel
, "datarel udata2")
526 S(DW_EH_PE_udata4
| DW_EH_PE_datarel
, "datarel udata4")
527 S(DW_EH_PE_udata8
| DW_EH_PE_datarel
, "datarel udata8")
528 S(DW_EH_PE_sleb128
| DW_EH_PE_datarel
, "datarel sleb128")
529 S(DW_EH_PE_sdata2
| DW_EH_PE_datarel
, "datarel sdata2")
530 S(DW_EH_PE_sdata4
| DW_EH_PE_datarel
, "datarel sdata4")
531 S(DW_EH_PE_sdata8
| DW_EH_PE_datarel
, "datarel sdata8")
533 S(DW_EH_PE_absptr
| DW_EH_PE_funcrel
, "funcrel")
534 S(DW_EH_PE_uleb128
| DW_EH_PE_funcrel
, "funcrel uleb128")
535 S(DW_EH_PE_udata2
| DW_EH_PE_funcrel
, "funcrel udata2")
536 S(DW_EH_PE_udata4
| DW_EH_PE_funcrel
, "funcrel udata4")
537 S(DW_EH_PE_udata8
| DW_EH_PE_funcrel
, "funcrel udata8")
538 S(DW_EH_PE_sleb128
| DW_EH_PE_funcrel
, "funcrel sleb128")
539 S(DW_EH_PE_sdata2
| DW_EH_PE_funcrel
, "funcrel sdata2")
540 S(DW_EH_PE_sdata4
| DW_EH_PE_funcrel
, "funcrel sdata4")
541 S(DW_EH_PE_sdata8
| DW_EH_PE_funcrel
, "funcrel sdata8")
543 S(DW_EH_PE_indirect
| DW_EH_PE_absptr
| DW_EH_PE_pcrel
,
545 S(DW_EH_PE_indirect
| DW_EH_PE_uleb128
| DW_EH_PE_pcrel
,
546 "indirect pcrel uleb128")
547 S(DW_EH_PE_indirect
| DW_EH_PE_udata2
| DW_EH_PE_pcrel
,
548 "indirect pcrel udata2")
549 S(DW_EH_PE_indirect
| DW_EH_PE_udata4
| DW_EH_PE_pcrel
,
550 "indirect pcrel udata4")
551 S(DW_EH_PE_indirect
| DW_EH_PE_udata8
| DW_EH_PE_pcrel
,
552 "indirect pcrel udata8")
553 S(DW_EH_PE_indirect
| DW_EH_PE_sleb128
| DW_EH_PE_pcrel
,
554 "indirect pcrel sleb128")
555 S(DW_EH_PE_indirect
| DW_EH_PE_sdata2
| DW_EH_PE_pcrel
,
556 "indirect pcrel sdata2")
557 S(DW_EH_PE_indirect
| DW_EH_PE_sdata4
| DW_EH_PE_pcrel
,
558 "indirect pcrel sdata4")
559 S(DW_EH_PE_indirect
| DW_EH_PE_sdata8
| DW_EH_PE_pcrel
,
560 "indirect pcrel sdata8")
562 S(DW_EH_PE_indirect
| DW_EH_PE_absptr
| DW_EH_PE_textrel
,
564 S(DW_EH_PE_indirect
| DW_EH_PE_uleb128
| DW_EH_PE_textrel
,
565 "indirect textrel uleb128")
566 S(DW_EH_PE_indirect
| DW_EH_PE_udata2
| DW_EH_PE_textrel
,
567 "indirect textrel udata2")
568 S(DW_EH_PE_indirect
| DW_EH_PE_udata4
| DW_EH_PE_textrel
,
569 "indirect textrel udata4")
570 S(DW_EH_PE_indirect
| DW_EH_PE_udata8
| DW_EH_PE_textrel
,
571 "indirect textrel udata8")
572 S(DW_EH_PE_indirect
| DW_EH_PE_sleb128
| DW_EH_PE_textrel
,
573 "indirect textrel sleb128")
574 S(DW_EH_PE_indirect
| DW_EH_PE_sdata2
| DW_EH_PE_textrel
,
575 "indirect textrel sdata2")
576 S(DW_EH_PE_indirect
| DW_EH_PE_sdata4
| DW_EH_PE_textrel
,
577 "indirect textrel sdata4")
578 S(DW_EH_PE_indirect
| DW_EH_PE_sdata8
| DW_EH_PE_textrel
,
579 "indirect textrel sdata8")
581 S(DW_EH_PE_indirect
| DW_EH_PE_absptr
| DW_EH_PE_datarel
,
583 S(DW_EH_PE_indirect
| DW_EH_PE_uleb128
| DW_EH_PE_datarel
,
584 "indirect datarel uleb128")
585 S(DW_EH_PE_indirect
| DW_EH_PE_udata2
| DW_EH_PE_datarel
,
586 "indirect datarel udata2")
587 S(DW_EH_PE_indirect
| DW_EH_PE_udata4
| DW_EH_PE_datarel
,
588 "indirect datarel udata4")
589 S(DW_EH_PE_indirect
| DW_EH_PE_udata8
| DW_EH_PE_datarel
,
590 "indirect datarel udata8")
591 S(DW_EH_PE_indirect
| DW_EH_PE_sleb128
| DW_EH_PE_datarel
,
592 "indirect datarel sleb128")
593 S(DW_EH_PE_indirect
| DW_EH_PE_sdata2
| DW_EH_PE_datarel
,
594 "indirect datarel sdata2")
595 S(DW_EH_PE_indirect
| DW_EH_PE_sdata4
| DW_EH_PE_datarel
,
596 "indirect datarel sdata4")
597 S(DW_EH_PE_indirect
| DW_EH_PE_sdata8
| DW_EH_PE_datarel
,
598 "indirect datarel sdata8")
600 S(DW_EH_PE_indirect
| DW_EH_PE_absptr
| DW_EH_PE_funcrel
,
602 S(DW_EH_PE_indirect
| DW_EH_PE_uleb128
| DW_EH_PE_funcrel
,
603 "indirect funcrel uleb128")
604 S(DW_EH_PE_indirect
| DW_EH_PE_udata2
| DW_EH_PE_funcrel
,
605 "indirect funcrel udata2")
606 S(DW_EH_PE_indirect
| DW_EH_PE_udata4
| DW_EH_PE_funcrel
,
607 "indirect funcrel udata4")
608 S(DW_EH_PE_indirect
| DW_EH_PE_udata8
| DW_EH_PE_funcrel
,
609 "indirect funcrel udata8")
610 S(DW_EH_PE_indirect
| DW_EH_PE_sleb128
| DW_EH_PE_funcrel
,
611 "indirect funcrel sleb128")
612 S(DW_EH_PE_indirect
| DW_EH_PE_sdata2
| DW_EH_PE_funcrel
,
613 "indirect funcrel sdata2")
614 S(DW_EH_PE_indirect
| DW_EH_PE_sdata4
| DW_EH_PE_funcrel
,
615 "indirect funcrel sdata4")
616 S(DW_EH_PE_indirect
| DW_EH_PE_sdata8
| DW_EH_PE_funcrel
,
617 "indirect funcrel sdata8")
619 #if HAVE_DESIGNATED_INITIALIZERS
622 if (format
< 0 || format
> 0xff || format_names
[format
] == NULL
)
624 return format_names
[format
];
631 /* Output an unsigned LEB128 quantity. */
634 dw2_asm_output_data_uleb128
VPARAMS ((unsigned HOST_WIDE_INT value
,
635 const char *comment
, ...))
637 #ifndef ANSI_PROTOTYPES
638 unsigned HOST_WIDE_INT value
;
643 VA_START (ap
, comment
);
645 #ifndef ANSI_PROTOTYPES
646 value
= va_arg (ap
, unsigned HOST_WIDE_INT
);
647 comment
= va_arg (ap
, const char *);
650 #ifdef HAVE_AS_LEB128
651 fputs ("\t.uleb128 ", asm_out_file
);
652 fprintf (asm_out_file
, HOST_WIDE_INT_PRINT_HEX
, value
);
654 if (flag_debug_asm
&& comment
)
656 fprintf (asm_out_file
, "\t%s ", ASM_COMMENT_START
);
657 vfprintf (asm_out_file
, comment
, ap
);
661 unsigned HOST_WIDE_INT work
= value
;
663 fputs (ASM_BYTE_OP
, asm_out_file
);
666 int byte
= (work
& 0x7f);
669 /* More bytes to follow. */
672 fprintf (asm_out_file
, "0x%x", byte
);
674 fputc (',', asm_out_file
);
680 fprintf (asm_out_file
, "\t%s uleb128 ", ASM_COMMENT_START
);
681 fprintf (asm_out_file
, HOST_WIDE_INT_PRINT_HEX
, value
);
684 fputs ("; ", asm_out_file
);
685 vfprintf (asm_out_file
, comment
, ap
);
690 fputc ('\n', asm_out_file
);
695 /* Output an signed LEB128 quantity. */
698 dw2_asm_output_data_sleb128
VPARAMS ((HOST_WIDE_INT value
,
699 const char *comment
, ...))
701 #ifndef ANSI_PROTOTYPES
707 VA_START (ap
, comment
);
709 #ifndef ANSI_PROTOTYPES
710 value
= va_arg (ap
, HOST_WIDE_INT
);
711 comment
= va_arg (ap
, const char *);
714 #ifdef HAVE_AS_LEB128
715 fputs ("\t.sleb128 ", asm_out_file
);
716 fprintf (asm_out_file
, HOST_WIDE_INT_PRINT_DEC
, value
);
718 if (flag_debug_asm
&& comment
)
720 fprintf (asm_out_file
, "\t%s ", ASM_COMMENT_START
);
721 vfprintf (asm_out_file
, comment
, ap
);
725 HOST_WIDE_INT work
= value
;
728 fputs (ASM_BYTE_OP
, asm_out_file
);
731 byte
= (work
& 0x7f);
732 /* arithmetic shift */
734 more
= !((work
== 0 && (byte
& 0x40) == 0)
735 || (work
== -1 && (byte
& 0x40) != 0));
739 fprintf (asm_out_file
, "0x%x", byte
);
741 fputc (',', asm_out_file
);
747 fprintf (asm_out_file
, "\t%s sleb128 ", ASM_COMMENT_START
);
748 fprintf (asm_out_file
, HOST_WIDE_INT_PRINT_DEC
, value
);
751 fputs ("; ", asm_out_file
);
752 vfprintf (asm_out_file
, comment
, ap
);
757 fputc ('\n', asm_out_file
);
763 dw2_asm_output_delta_uleb128
VPARAMS ((const char *lab1 ATTRIBUTE_UNUSED
,
764 const char *lab2 ATTRIBUTE_UNUSED
,
765 const char *comment
, ...))
767 #ifndef ANSI_PROTOTYPES
768 const char *lab1
, *lab2
;
773 VA_START (ap
, comment
);
775 #ifndef ANSI_PROTOTYPES
776 lab1
= va_arg (ap
, const char *);
777 lab2
= va_arg (ap
, const char *);
778 comment
= va_arg (ap
, const char *);
781 #ifdef HAVE_AS_LEB128
782 fputs ("\t.uleb128 ", asm_out_file
);
783 assemble_name (asm_out_file
, lab1
);
784 fputc ('-', asm_out_file
);
785 assemble_name (asm_out_file
, lab2
);
790 if (flag_debug_asm
&& comment
)
792 fprintf (asm_out_file
, "\t%s ", ASM_COMMENT_START
);
793 vfprintf (asm_out_file
, comment
, ap
);
795 fputc ('\n', asm_out_file
);
801 dw2_asm_output_delta_sleb128
VPARAMS ((const char *lab1 ATTRIBUTE_UNUSED
,
802 const char *lab2 ATTRIBUTE_UNUSED
,
803 const char *comment
, ...))
805 #ifndef ANSI_PROTOTYPES
806 const char *lab1
, *lab2
;
811 VA_START (ap
, comment
);
813 #ifndef ANSI_PROTOTYPES
814 lab1
= va_arg (ap
, const char *);
815 lab2
= va_arg (ap
, const char *);
816 comment
= va_arg (ap
, const char *);
819 #ifdef HAVE_AS_LEB128
820 fputs ("\t.sleb128 ", asm_out_file
);
821 assemble_name (asm_out_file
, lab1
);
822 fputc ('-', asm_out_file
);
823 assemble_name (asm_out_file
, lab2
);
828 if (flag_debug_asm
&& comment
)
830 fprintf (asm_out_file
, "\t%s ", ASM_COMMENT_START
);
831 vfprintf (asm_out_file
, comment
, ap
);
833 fputc ('\n', asm_out_file
);
838 static rtx dw2_force_const_mem
PARAMS ((rtx
));
839 static int dw2_output_indirect_constant_1
PARAMS ((splay_tree_node
, void *));
841 static splay_tree indirect_pool
;
843 /* Put X, a SYMBOL_REF, in memory. Return a SYMBOL_REF to the allocated
844 memory. Differs from force_const_mem in that a single pool is used for
845 the entire unit of translation, and the memory is not guaranteed to be
846 "near" the function in any interesting sense. */
849 dw2_force_const_mem (x
)
852 splay_tree_node node
;
853 const char *const_sym
;
856 indirect_pool
= splay_tree_new (splay_tree_compare_pointers
, NULL
, NULL
);
858 if (GET_CODE (x
) != SYMBOL_REF
)
860 node
= splay_tree_lookup (indirect_pool
, (splay_tree_key
) XSTR (x
, 0));
862 const_sym
= (const char *) node
->value
;
865 extern int const_labelno
;
869 ASM_GENERATE_INTERNAL_LABEL (label
, "LC", const_labelno
);
871 const_sym
= ggc_strdup (label
);
873 id
= maybe_get_identifier (XSTR (x
, 0));
875 TREE_SYMBOL_REFERENCED (id
) = 1;
877 splay_tree_insert (indirect_pool
, (splay_tree_key
) XSTR (x
, 0),
878 (splay_tree_value
) const_sym
);
881 return gen_rtx_SYMBOL_REF (Pmode
, const_sym
);
884 /* A helper function for dw2_output_indirect_constants called through
885 splay_tree_foreach. Emit one queued constant to memory. */
888 dw2_output_indirect_constant_1 (node
, data
)
889 splay_tree_node node
;
890 void* data ATTRIBUTE_UNUSED
;
892 const char *label
, *sym
;
895 label
= (const char *) node
->value
;
896 sym
= (const char *) node
->key
;
897 sym_ref
= gen_rtx_SYMBOL_REF (Pmode
, sym
);
899 ASM_OUTPUT_LABEL (asm_out_file
, label
);
900 assemble_integer (sym_ref
, POINTER_SIZE
/ BITS_PER_UNIT
, 1);
905 /* Emit the constants queued through dw2_force_const_mem. */
908 dw2_output_indirect_constants ()
913 /* Assume that the whole reason we're emitting these symbol references
914 indirectly is that they contain dynamic relocations, and are thus
915 read-write. If there was no possibility of a dynamic relocation, we
916 might as well have used a direct relocation. */
919 /* Everything we're emitting is a pointer. Align appropriately. */
920 assemble_align (POINTER_SIZE
);
922 splay_tree_foreach (indirect_pool
, dw2_output_indirect_constant_1
, NULL
);
925 /* Like dw2_asm_output_addr_rtx, but encode the pointer as directed. */
928 dw2_asm_output_encoded_addr_rtx
VPARAMS ((int encoding
,
930 const char *comment
, ...))
932 #ifndef ANSI_PROTOTYPES
940 VA_START (ap
, comment
);
942 #ifndef ANSI_PROTOTYPES
943 encoding
= va_arg (ap
, int);
944 addr
= va_arg (ap
, rtx
);
945 comment
= va_arg (ap
, const char *);
948 size
= size_of_encoded_value (encoding
);
950 /* NULL is _always_ represented as a plain zero. */
951 if (addr
== const0_rtx
)
952 assemble_integer (addr
, size
, 1);
956 /* Allow the target first crack at emitting this. Some of the
957 special relocations require special directives instead of
958 just ".4byte" or whatever. */
959 #ifdef ASM_MAYBE_OUTPUT_ENCODED_ADDR_RTX
960 ASM_MAYBE_OUTPUT_ENCODED_ADDR_RTX (asm_out_file
, encoding
, size
,
964 /* Indirection is used to get dynamic relocations out of a
965 read-only section. */
966 if (encoding
& DW_EH_PE_indirect
)
968 /* It is very tempting to use force_const_mem so that we share data
969 with the normal constant pool. However, we've already emitted
970 the constant pool for this function. Moreover, we'd like to
971 share these constants across the entire unit of translation,
972 or better, across the entire application (or DSO). */
973 addr
= dw2_force_const_mem (addr
);
974 encoding
&= ~DW_EH_PE_indirect
;
978 switch (encoding
& 0xF0)
980 case DW_EH_PE_absptr
:
981 #ifdef UNALIGNED_INT_ASM_OP
982 fputs (unaligned_integer_asm_op (size
), asm_out_file
);
983 output_addr_const (asm_out_file
, addr
);
985 assemble_integer (addr
, size
, 1);
990 if (GET_CODE (addr
) != SYMBOL_REF
)
992 #ifdef ASM_OUTPUT_DWARF_PCREL
993 ASM_OUTPUT_DWARF_PCREL (asm_out_file
, size
, XSTR (addr
, 0));
995 #ifdef UNALIGNED_INT_ASM_OP
996 fputs (unaligned_integer_asm_op (size
), asm_out_file
);
997 assemble_name (asm_out_file
, XSTR (addr
, 0));
998 fputc ('-', asm_out_file
);
999 fputc ('.', asm_out_file
);
1007 /* Other encodings should have been handled by
1008 ASM_MAYBE_OUTPUT_ENCODED_ADDR_RTX. */
1012 #ifdef ASM_MAYBE_OUTPUT_ENCODED_ADDR_RTX
1017 if (flag_debug_asm
&& comment
)
1019 fprintf (asm_out_file
, "\t%s ", ASM_COMMENT_START
);
1020 vfprintf (asm_out_file
, comment
, ap
);
1022 fputc ('\n', asm_out_file
);