00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "config.h"
00023 #include "system.h"
00024 #include "coretypes.h"
00025 #include "tm.h"
00026 #include "flags.h"
00027 #include "tree.h"
00028 #include "rtl.h"
00029 #include "output.h"
00030 #include "target.h"
00031 #include "dwarf2asm.h"
00032 #include "dwarf2.h"
00033 #include "splay-tree.h"
00034 #include "ggc.h"
00035 #include "tm_p.h"
00036
00037
00038
00039 #ifndef ASM_COMMENT_START
00040 #define ASM_COMMENT_START ";#"
00041 #endif
00042
00043
00044
00045
00046
00047 void
00048 dw2_assemble_integer (int size, rtx x)
00049 {
00050 const char *op = integer_asm_op (size, FALSE);
00051
00052 if (op)
00053 {
00054 fputs (op, asm_out_file);
00055 if (GET_CODE (x) == CONST_INT)
00056 fprintf (asm_out_file, HOST_WIDE_INT_PRINT_HEX, INTVAL (x));
00057 else
00058 output_addr_const (asm_out_file, x);
00059 }
00060 else
00061 assemble_integer (x, size, BITS_PER_UNIT, 1);
00062 }
00063
00064
00065
00066
00067 void
00068 dw2_asm_output_data (int size, unsigned HOST_WIDE_INT value,
00069 const char *comment, ...)
00070 {
00071 va_list ap;
00072 const char *op = integer_asm_op (size, FALSE);
00073
00074 va_start (ap, comment);
00075
00076 if (size * 8 < HOST_BITS_PER_WIDE_INT)
00077 value &= ~(~(unsigned HOST_WIDE_INT) 0 << (size * 8));
00078
00079 if (op)
00080 fprintf (asm_out_file, "%s" HOST_WIDE_INT_PRINT_HEX, op, value);
00081 else
00082 assemble_integer (GEN_INT (value), size, BITS_PER_UNIT, 1);
00083
00084 if (flag_debug_asm && comment)
00085 {
00086 fprintf (asm_out_file, "\t%s ", ASM_COMMENT_START);
00087 vfprintf (asm_out_file, comment, ap);
00088 }
00089 fputc ('\n', asm_out_file);
00090
00091 va_end (ap);
00092 }
00093
00094
00095
00096
00097
00098
00099
00100 void
00101 dw2_asm_output_delta (int size, const char *lab1, const char *lab2,
00102 const char *comment, ...)
00103 {
00104 va_list ap;
00105
00106 va_start (ap, comment);
00107
00108 #ifdef ASM_OUTPUT_DWARF_DELTA
00109 ASM_OUTPUT_DWARF_DELTA (asm_out_file, size, lab1, lab2);
00110 #else
00111 dw2_assemble_integer (size,
00112 gen_rtx_MINUS (Pmode,
00113 gen_rtx_SYMBOL_REF (Pmode, lab1),
00114 gen_rtx_SYMBOL_REF (Pmode, lab2)));
00115 #endif
00116 if (flag_debug_asm && comment)
00117 {
00118 fprintf (asm_out_file, "\t%s ", ASM_COMMENT_START);
00119 vfprintf (asm_out_file, comment, ap);
00120 }
00121 fputc ('\n', asm_out_file);
00122
00123 va_end (ap);
00124 }
00125
00126
00127
00128
00129
00130
00131
00132
00133 void
00134 dw2_asm_output_offset (int size, const char *label,
00135 section *base ATTRIBUTE_UNUSED,
00136 const char *comment, ...)
00137 {
00138 va_list ap;
00139
00140 va_start (ap, comment);
00141
00142 #ifdef ASM_OUTPUT_DWARF_OFFSET
00143 ASM_OUTPUT_DWARF_OFFSET (asm_out_file, size, label, base);
00144 #else
00145 dw2_assemble_integer (size, gen_rtx_SYMBOL_REF (Pmode, label));
00146 #endif
00147
00148 if (flag_debug_asm && comment)
00149 {
00150 fprintf (asm_out_file, "\t%s ", ASM_COMMENT_START);
00151 vfprintf (asm_out_file, comment, ap);
00152 }
00153 fputc ('\n', asm_out_file);
00154
00155 va_end (ap);
00156 }
00157
00158 #if 0
00159
00160
00161
00162
00163 void
00164 dw2_asm_output_pcrel (int size ATTRIBUTE_UNUSED,
00165 const char *label ATTRIBUTE_UNUSED,
00166 const char *comment, ...)
00167 {
00168 va_list ap;
00169
00170 va_start (ap, comment);
00171
00172 #ifdef ASM_OUTPUT_DWARF_PCREL
00173 ASM_OUTPUT_DWARF_PCREL (asm_out_file, size, label);
00174 #else
00175 dw2_assemble_integer (size,
00176 gen_rtx_MINUS (Pmode,
00177 gen_rtx_SYMBOL_REF (Pmode, label),
00178 pc_rtx));
00179 #endif
00180
00181 if (flag_debug_asm && comment)
00182 {
00183 fprintf (asm_out_file, "\t%s ", ASM_COMMENT_START);
00184 vfprintf (asm_out_file, comment, ap);
00185 }
00186 fputc ('\n', asm_out_file);
00187
00188 va_end (ap);
00189 }
00190 #endif
00191
00192
00193
00194 void
00195 dw2_asm_output_addr (int size, const char *label,
00196 const char *comment, ...)
00197 {
00198 va_list ap;
00199
00200 va_start (ap, comment);
00201
00202 dw2_assemble_integer (size, gen_rtx_SYMBOL_REF (Pmode, label));
00203
00204 if (flag_debug_asm && comment)
00205 {
00206 fprintf (asm_out_file, "\t%s ", ASM_COMMENT_START);
00207 vfprintf (asm_out_file, comment, ap);
00208 }
00209 fputc ('\n', asm_out_file);
00210
00211 va_end (ap);
00212 }
00213
00214
00215
00216 void
00217 dw2_asm_output_addr_rtx (int size, rtx addr,
00218 const char *comment, ...)
00219 {
00220 va_list ap;
00221
00222 va_start (ap, comment);
00223
00224 dw2_assemble_integer (size, addr);
00225
00226 if (flag_debug_asm && comment)
00227 {
00228 fprintf (asm_out_file, "\t%s ", ASM_COMMENT_START);
00229 vfprintf (asm_out_file, comment, ap);
00230 }
00231 fputc ('\n', asm_out_file);
00232
00233 va_end (ap);
00234 }
00235
00236
00237
00238
00239
00240
00241
00242
00243 void
00244 dw2_asm_output_nstring (const char *str, size_t orig_len,
00245 const char *comment, ...)
00246 {
00247 size_t i, len;
00248 va_list ap;
00249
00250 va_start (ap, comment);
00251
00252 len = orig_len;
00253
00254 if (len == (size_t) -1)
00255 len = strlen (str);
00256
00257 if (flag_debug_asm && comment)
00258 {
00259 fputs ("\t.ascii \"", asm_out_file);
00260 for (i = 0; i < len; i++)
00261 {
00262 int c = str[i];
00263 if (c == '\"' || c == '\\')
00264 fputc ('\\', asm_out_file);
00265 if (ISPRINT(c))
00266 fputc (c, asm_out_file);
00267 else
00268 fprintf (asm_out_file, "\\%o", c);
00269 }
00270 fprintf (asm_out_file, "\\0\"\t%s ", ASM_COMMENT_START);
00271 vfprintf (asm_out_file, comment, ap);
00272 fputc ('\n', asm_out_file);
00273 }
00274 else
00275 {
00276
00277
00278 if (orig_len == (size_t) -1)
00279 len += 1;
00280 ASM_OUTPUT_ASCII (asm_out_file, str, len);
00281 if (orig_len != (size_t) -1)
00282 assemble_integer (const0_rtx, 1, BITS_PER_UNIT, 1);
00283 }
00284
00285 va_end (ap);
00286 }
00287
00288
00289
00290
00291 int
00292 size_of_uleb128 (unsigned HOST_WIDE_INT value)
00293 {
00294 int size = 0;
00295
00296 do
00297 {
00298 value >>= 7;
00299 size += 1;
00300 }
00301 while (value != 0);
00302
00303 return size;
00304 }
00305
00306
00307
00308 int
00309 size_of_sleb128 (HOST_WIDE_INT value)
00310 {
00311 int size = 0, byte;
00312
00313 do
00314 {
00315 byte = (value & 0x7f);
00316 value >>= 7;
00317 size += 1;
00318 }
00319 while (!((value == 0 && (byte & 0x40) == 0)
00320 || (value == -1 && (byte & 0x40) != 0)));
00321
00322 return size;
00323 }
00324
00325
00326
00327
00328
00329 int
00330 size_of_encoded_value (int encoding)
00331 {
00332 if (encoding == DW_EH_PE_omit)
00333 return 0;
00334
00335 switch (encoding & 0x07)
00336 {
00337 case DW_EH_PE_absptr:
00338 return POINTER_SIZE / BITS_PER_UNIT;
00339 case DW_EH_PE_udata2:
00340 return 2;
00341 case DW_EH_PE_udata4:
00342 return 4;
00343 case DW_EH_PE_udata8:
00344 return 8;
00345 default:
00346 gcc_unreachable ();
00347 }
00348 }
00349
00350
00351
00352 const char *
00353 eh_data_format_name (int format)
00354 {
00355 #if HAVE_DESIGNATED_INITIALIZERS
00356 #define S(p, v) [p] = v,
00357 #else
00358 #define S(p, v) case p: return v;
00359 #endif
00360
00361 #if HAVE_DESIGNATED_INITIALIZERS
00362 __extension__ static const char * const format_names[256] = {
00363 #else
00364 switch (format) {
00365 #endif
00366
00367 S(DW_EH_PE_absptr, "absolute")
00368 S(DW_EH_PE_omit, "omit")
00369 S(DW_EH_PE_aligned, "aligned absolute")
00370
00371 S(DW_EH_PE_uleb128, "uleb128")
00372 S(DW_EH_PE_udata2, "udata2")
00373 S(DW_EH_PE_udata4, "udata4")
00374 S(DW_EH_PE_udata8, "udata8")
00375 S(DW_EH_PE_sleb128, "sleb128")
00376 S(DW_EH_PE_sdata2, "sdata2")
00377 S(DW_EH_PE_sdata4, "sdata4")
00378 S(DW_EH_PE_sdata8, "sdata8")
00379
00380 S(DW_EH_PE_absptr | DW_EH_PE_pcrel, "pcrel")
00381 S(DW_EH_PE_uleb128 | DW_EH_PE_pcrel, "pcrel uleb128")
00382 S(DW_EH_PE_udata2 | DW_EH_PE_pcrel, "pcrel udata2")
00383 S(DW_EH_PE_udata4 | DW_EH_PE_pcrel, "pcrel udata4")
00384 S(DW_EH_PE_udata8 | DW_EH_PE_pcrel, "pcrel udata8")
00385 S(DW_EH_PE_sleb128 | DW_EH_PE_pcrel, "pcrel sleb128")
00386 S(DW_EH_PE_sdata2 | DW_EH_PE_pcrel, "pcrel sdata2")
00387 S(DW_EH_PE_sdata4 | DW_EH_PE_pcrel, "pcrel sdata4")
00388 S(DW_EH_PE_sdata8 | DW_EH_PE_pcrel, "pcrel sdata8")
00389
00390 S(DW_EH_PE_absptr | DW_EH_PE_textrel, "textrel")
00391 S(DW_EH_PE_uleb128 | DW_EH_PE_textrel, "textrel uleb128")
00392 S(DW_EH_PE_udata2 | DW_EH_PE_textrel, "textrel udata2")
00393 S(DW_EH_PE_udata4 | DW_EH_PE_textrel, "textrel udata4")
00394 S(DW_EH_PE_udata8 | DW_EH_PE_textrel, "textrel udata8")
00395 S(DW_EH_PE_sleb128 | DW_EH_PE_textrel, "textrel sleb128")
00396 S(DW_EH_PE_sdata2 | DW_EH_PE_textrel, "textrel sdata2")
00397 S(DW_EH_PE_sdata4 | DW_EH_PE_textrel, "textrel sdata4")
00398 S(DW_EH_PE_sdata8 | DW_EH_PE_textrel, "textrel sdata8")
00399
00400 S(DW_EH_PE_absptr | DW_EH_PE_datarel, "datarel")
00401 S(DW_EH_PE_uleb128 | DW_EH_PE_datarel, "datarel uleb128")
00402 S(DW_EH_PE_udata2 | DW_EH_PE_datarel, "datarel udata2")
00403 S(DW_EH_PE_udata4 | DW_EH_PE_datarel, "datarel udata4")
00404 S(DW_EH_PE_udata8 | DW_EH_PE_datarel, "datarel udata8")
00405 S(DW_EH_PE_sleb128 | DW_EH_PE_datarel, "datarel sleb128")
00406 S(DW_EH_PE_sdata2 | DW_EH_PE_datarel, "datarel sdata2")
00407 S(DW_EH_PE_sdata4 | DW_EH_PE_datarel, "datarel sdata4")
00408 S(DW_EH_PE_sdata8 | DW_EH_PE_datarel, "datarel sdata8")
00409
00410 S(DW_EH_PE_absptr | DW_EH_PE_funcrel, "funcrel")
00411 S(DW_EH_PE_uleb128 | DW_EH_PE_funcrel, "funcrel uleb128")
00412 S(DW_EH_PE_udata2 | DW_EH_PE_funcrel, "funcrel udata2")
00413 S(DW_EH_PE_udata4 | DW_EH_PE_funcrel, "funcrel udata4")
00414 S(DW_EH_PE_udata8 | DW_EH_PE_funcrel, "funcrel udata8")
00415 S(DW_EH_PE_sleb128 | DW_EH_PE_funcrel, "funcrel sleb128")
00416 S(DW_EH_PE_sdata2 | DW_EH_PE_funcrel, "funcrel sdata2")
00417 S(DW_EH_PE_sdata4 | DW_EH_PE_funcrel, "funcrel sdata4")
00418 S(DW_EH_PE_sdata8 | DW_EH_PE_funcrel, "funcrel sdata8")
00419
00420 S(DW_EH_PE_indirect | DW_EH_PE_absptr | DW_EH_PE_pcrel,
00421 "indirect pcrel")
00422 S(DW_EH_PE_indirect | DW_EH_PE_uleb128 | DW_EH_PE_pcrel,
00423 "indirect pcrel uleb128")
00424 S(DW_EH_PE_indirect | DW_EH_PE_udata2 | DW_EH_PE_pcrel,
00425 "indirect pcrel udata2")
00426 S(DW_EH_PE_indirect | DW_EH_PE_udata4 | DW_EH_PE_pcrel,
00427 "indirect pcrel udata4")
00428 S(DW_EH_PE_indirect | DW_EH_PE_udata8 | DW_EH_PE_pcrel,
00429 "indirect pcrel udata8")
00430 S(DW_EH_PE_indirect | DW_EH_PE_sleb128 | DW_EH_PE_pcrel,
00431 "indirect pcrel sleb128")
00432 S(DW_EH_PE_indirect | DW_EH_PE_sdata2 | DW_EH_PE_pcrel,
00433 "indirect pcrel sdata2")
00434 S(DW_EH_PE_indirect | DW_EH_PE_sdata4 | DW_EH_PE_pcrel,
00435 "indirect pcrel sdata4")
00436 S(DW_EH_PE_indirect | DW_EH_PE_sdata8 | DW_EH_PE_pcrel,
00437 "indirect pcrel sdata8")
00438
00439 S(DW_EH_PE_indirect | DW_EH_PE_absptr | DW_EH_PE_textrel,
00440 "indirect textrel")
00441 S(DW_EH_PE_indirect | DW_EH_PE_uleb128 | DW_EH_PE_textrel,
00442 "indirect textrel uleb128")
00443 S(DW_EH_PE_indirect | DW_EH_PE_udata2 | DW_EH_PE_textrel,
00444 "indirect textrel udata2")
00445 S(DW_EH_PE_indirect | DW_EH_PE_udata4 | DW_EH_PE_textrel,
00446 "indirect textrel udata4")
00447 S(DW_EH_PE_indirect | DW_EH_PE_udata8 | DW_EH_PE_textrel,
00448 "indirect textrel udata8")
00449 S(DW_EH_PE_indirect | DW_EH_PE_sleb128 | DW_EH_PE_textrel,
00450 "indirect textrel sleb128")
00451 S(DW_EH_PE_indirect | DW_EH_PE_sdata2 | DW_EH_PE_textrel,
00452 "indirect textrel sdata2")
00453 S(DW_EH_PE_indirect | DW_EH_PE_sdata4 | DW_EH_PE_textrel,
00454 "indirect textrel sdata4")
00455 S(DW_EH_PE_indirect | DW_EH_PE_sdata8 | DW_EH_PE_textrel,
00456 "indirect textrel sdata8")
00457
00458 S(DW_EH_PE_indirect | DW_EH_PE_absptr | DW_EH_PE_datarel,
00459 "indirect datarel")
00460 S(DW_EH_PE_indirect | DW_EH_PE_uleb128 | DW_EH_PE_datarel,
00461 "indirect datarel uleb128")
00462 S(DW_EH_PE_indirect | DW_EH_PE_udata2 | DW_EH_PE_datarel,
00463 "indirect datarel udata2")
00464 S(DW_EH_PE_indirect | DW_EH_PE_udata4 | DW_EH_PE_datarel,
00465 "indirect datarel udata4")
00466 S(DW_EH_PE_indirect | DW_EH_PE_udata8 | DW_EH_PE_datarel,
00467 "indirect datarel udata8")
00468 S(DW_EH_PE_indirect | DW_EH_PE_sleb128 | DW_EH_PE_datarel,
00469 "indirect datarel sleb128")
00470 S(DW_EH_PE_indirect | DW_EH_PE_sdata2 | DW_EH_PE_datarel,
00471 "indirect datarel sdata2")
00472 S(DW_EH_PE_indirect | DW_EH_PE_sdata4 | DW_EH_PE_datarel,
00473 "indirect datarel sdata4")
00474 S(DW_EH_PE_indirect | DW_EH_PE_sdata8 | DW_EH_PE_datarel,
00475 "indirect datarel sdata8")
00476
00477 S(DW_EH_PE_indirect | DW_EH_PE_absptr | DW_EH_PE_funcrel,
00478 "indirect funcrel")
00479 S(DW_EH_PE_indirect | DW_EH_PE_uleb128 | DW_EH_PE_funcrel,
00480 "indirect funcrel uleb128")
00481 S(DW_EH_PE_indirect | DW_EH_PE_udata2 | DW_EH_PE_funcrel,
00482 "indirect funcrel udata2")
00483 S(DW_EH_PE_indirect | DW_EH_PE_udata4 | DW_EH_PE_funcrel,
00484 "indirect funcrel udata4")
00485 S(DW_EH_PE_indirect | DW_EH_PE_udata8 | DW_EH_PE_funcrel,
00486 "indirect funcrel udata8")
00487 S(DW_EH_PE_indirect | DW_EH_PE_sleb128 | DW_EH_PE_funcrel,
00488 "indirect funcrel sleb128")
00489 S(DW_EH_PE_indirect | DW_EH_PE_sdata2 | DW_EH_PE_funcrel,
00490 "indirect funcrel sdata2")
00491 S(DW_EH_PE_indirect | DW_EH_PE_sdata4 | DW_EH_PE_funcrel,
00492 "indirect funcrel sdata4")
00493 S(DW_EH_PE_indirect | DW_EH_PE_sdata8 | DW_EH_PE_funcrel,
00494 "indirect funcrel sdata8")
00495
00496 #if HAVE_DESIGNATED_INITIALIZERS
00497 };
00498
00499 gcc_assert (format >= 0 && format < 0x100 && format_names[format]);
00500
00501 return format_names[format];
00502 #else
00503 }
00504 gcc_unreachable ();
00505 #endif
00506 }
00507
00508
00509
00510 void
00511 dw2_asm_output_data_uleb128 (unsigned HOST_WIDE_INT value,
00512 const char *comment, ...)
00513 {
00514 va_list ap;
00515
00516 va_start (ap, comment);
00517
00518 #ifdef HAVE_AS_LEB128
00519 fprintf (asm_out_file, "\t.uleb128 " HOST_WIDE_INT_PRINT_HEX , value);
00520
00521 if (flag_debug_asm && comment)
00522 {
00523 fprintf (asm_out_file, "\t%s ", ASM_COMMENT_START);
00524 vfprintf (asm_out_file, comment, ap);
00525 }
00526 #else
00527 {
00528 unsigned HOST_WIDE_INT work = value;
00529 const char *byte_op = targetm.asm_out.byte_op;
00530
00531 if (byte_op)
00532 fputs (byte_op, asm_out_file);
00533 do
00534 {
00535 int byte = (work & 0x7f);
00536 work >>= 7;
00537 if (work != 0)
00538
00539 byte |= 0x80;
00540
00541 if (byte_op)
00542 {
00543 fprintf (asm_out_file, "0x%x", byte);
00544 if (work != 0)
00545 fputc (',', asm_out_file);
00546 }
00547 else
00548 assemble_integer (GEN_INT (byte), 1, BITS_PER_UNIT, 1);
00549 }
00550 while (work != 0);
00551
00552 if (flag_debug_asm)
00553 {
00554 fprintf (asm_out_file, "\t%s uleb128 " HOST_WIDE_INT_PRINT_HEX,
00555 ASM_COMMENT_START, value);
00556 if (comment)
00557 {
00558 fputs ("; ", asm_out_file);
00559 vfprintf (asm_out_file, comment, ap);
00560 }
00561 }
00562 }
00563 #endif
00564 fputc ('\n', asm_out_file);
00565
00566 va_end (ap);
00567 }
00568
00569
00570
00571 void
00572 dw2_asm_output_data_sleb128 (HOST_WIDE_INT value,
00573 const char *comment, ...)
00574 {
00575 va_list ap;
00576
00577 va_start (ap, comment);
00578
00579 #ifdef HAVE_AS_LEB128
00580 fprintf (asm_out_file, "\t.sleb128 " HOST_WIDE_INT_PRINT_DEC, value);
00581
00582 if (flag_debug_asm && comment)
00583 {
00584 fprintf (asm_out_file, "\t%s ", ASM_COMMENT_START);
00585 vfprintf (asm_out_file, comment, ap);
00586 }
00587 #else
00588 {
00589 HOST_WIDE_INT work = value;
00590 int more, byte;
00591 const char *byte_op = targetm.asm_out.byte_op;
00592
00593 if (byte_op)
00594 fputs (byte_op, asm_out_file);
00595 do
00596 {
00597 byte = (work & 0x7f);
00598
00599 work >>= 7;
00600 more = !((work == 0 && (byte & 0x40) == 0)
00601 || (work == -1 && (byte & 0x40) != 0));
00602 if (more)
00603 byte |= 0x80;
00604
00605 if (byte_op)
00606 {
00607 fprintf (asm_out_file, "0x%x", byte);
00608 if (more)
00609 fputc (',', asm_out_file);
00610 }
00611 else
00612 assemble_integer (GEN_INT (byte), 1, BITS_PER_UNIT, 1);
00613 }
00614 while (more);
00615
00616 if (flag_debug_asm)
00617 {
00618 fprintf (asm_out_file, "\t%s sleb128 " HOST_WIDE_INT_PRINT_DEC,
00619 ASM_COMMENT_START, value);
00620 if (comment)
00621 {
00622 fputs ("; ", asm_out_file);
00623 vfprintf (asm_out_file, comment, ap);
00624 }
00625 }
00626 }
00627 #endif
00628 fputc ('\n', asm_out_file);
00629
00630 va_end (ap);
00631 }
00632
00633 void
00634 dw2_asm_output_delta_uleb128 (const char *lab1 ATTRIBUTE_UNUSED,
00635 const char *lab2 ATTRIBUTE_UNUSED,
00636 const char *comment, ...)
00637 {
00638 va_list ap;
00639
00640 va_start (ap, comment);
00641
00642 #ifdef HAVE_AS_LEB128
00643 fputs ("\t.uleb128 ", asm_out_file);
00644 assemble_name (asm_out_file, lab1);
00645 fputc ('-', asm_out_file);
00646 assemble_name (asm_out_file, lab2);
00647 #else
00648 gcc_unreachable ();
00649 #endif
00650
00651 if (flag_debug_asm && comment)
00652 {
00653 fprintf (asm_out_file, "\t%s ", ASM_COMMENT_START);
00654 vfprintf (asm_out_file, comment, ap);
00655 }
00656 fputc ('\n', asm_out_file);
00657
00658 va_end (ap);
00659 }
00660
00661 #if 0
00662
00663 void
00664 dw2_asm_output_delta_sleb128 (const char *lab1 ATTRIBUTE_UNUSED,
00665 const char *lab2 ATTRIBUTE_UNUSED,
00666 const char *comment, ...)
00667 {
00668 va_list ap;
00669
00670 va_start (ap, comment);
00671
00672 #ifdef HAVE_AS_LEB128
00673 fputs ("\t.sleb128 ", asm_out_file);
00674 assemble_name (asm_out_file, lab1);
00675 fputc ('-', asm_out_file);
00676 assemble_name (asm_out_file, lab2);
00677 #else
00678 gcc_unreachable ();
00679 #endif
00680
00681 if (flag_debug_asm && comment)
00682 {
00683 fprintf (asm_out_file, "\t%s ", ASM_COMMENT_START);
00684 vfprintf (asm_out_file, comment, ap);
00685 }
00686 fputc ('\n', asm_out_file);
00687
00688 va_end (ap);
00689 }
00690 #endif
00691
00692 static rtx dw2_force_const_mem (rtx, bool);
00693 static int dw2_output_indirect_constant_1 (splay_tree_node, void *);
00694
00695 static GTY((param1_is (char *), param2_is (tree))) splay_tree indirect_pool;
00696
00697 static GTY(()) int dw2_const_labelno;
00698
00699 #if defined(HAVE_GAS_HIDDEN) && defined(SUPPORTS_ONE_ONLY)
00700 # define USE_LINKONCE_INDIRECT 1
00701 #else
00702 # define USE_LINKONCE_INDIRECT 0
00703 #endif
00704
00705
00706
00707
00708
00709
00710
00711 static rtx
00712 dw2_force_const_mem (rtx x, bool public)
00713 {
00714 splay_tree_node node;
00715 const char *str;
00716 tree decl;
00717
00718 if (! indirect_pool)
00719 indirect_pool = splay_tree_new_ggc (splay_tree_compare_pointers);
00720
00721 gcc_assert (GET_CODE (x) == SYMBOL_REF);
00722
00723 str = targetm.strip_name_encoding (XSTR (x, 0));
00724 node = splay_tree_lookup (indirect_pool, (splay_tree_key) str);
00725 if (node)
00726 decl = (tree) node->value;
00727 else
00728 {
00729 tree id;
00730
00731 if (public && USE_LINKONCE_INDIRECT)
00732 {
00733 char *ref_name = alloca (strlen (str) + sizeof "DW.ref.");
00734
00735 sprintf (ref_name, "DW.ref.%s", str);
00736 id = get_identifier (ref_name);
00737 decl = build_decl (VAR_DECL, id, ptr_type_node);
00738 DECL_ARTIFICIAL (decl) = 1;
00739 DECL_IGNORED_P (decl) = 1;
00740 TREE_PUBLIC (decl) = 1;
00741 DECL_INITIAL (decl) = decl;
00742 make_decl_one_only (decl);
00743 }
00744 else
00745 {
00746 char label[32];
00747
00748 ASM_GENERATE_INTERNAL_LABEL (label, "LDFCM", dw2_const_labelno);
00749 ++dw2_const_labelno;
00750 id = get_identifier (label);
00751 decl = build_decl (VAR_DECL, id, ptr_type_node);
00752 DECL_ARTIFICIAL (decl) = 1;
00753 DECL_IGNORED_P (decl) = 1;
00754 TREE_STATIC (decl) = 1;
00755 DECL_INITIAL (decl) = decl;
00756 }
00757
00758 id = maybe_get_identifier (str);
00759 if (id)
00760 TREE_SYMBOL_REFERENCED (id) = 1;
00761
00762 splay_tree_insert (indirect_pool, (splay_tree_key) str,
00763 (splay_tree_value) decl);
00764 }
00765
00766 return XEXP (DECL_RTL (decl), 0);
00767 }
00768
00769
00770
00771
00772 static int
00773 dw2_output_indirect_constant_1 (splay_tree_node node,
00774 void *data ATTRIBUTE_UNUSED)
00775 {
00776 const char *sym;
00777 rtx sym_ref;
00778 tree decl;
00779
00780 sym = (const char *) node->key;
00781 decl = (tree) node->value;
00782 sym_ref = gen_rtx_SYMBOL_REF (Pmode, sym);
00783 if (TREE_PUBLIC (decl) && USE_LINKONCE_INDIRECT)
00784 fprintf (asm_out_file, "\t.hidden %sDW.ref.%s\n", user_label_prefix, sym);
00785 assemble_variable (decl, 1, 1, 1);
00786 assemble_integer (sym_ref, POINTER_SIZE / BITS_PER_UNIT, POINTER_SIZE, 1);
00787
00788 return 0;
00789 }
00790
00791
00792
00793 void
00794 dw2_output_indirect_constants (void)
00795 {
00796 if (indirect_pool)
00797 splay_tree_foreach (indirect_pool, dw2_output_indirect_constant_1, NULL);
00798 }
00799
00800
00801
00802
00803
00804 void
00805 dw2_asm_output_encoded_addr_rtx (int encoding, rtx addr, bool public,
00806 const char *comment, ...)
00807 {
00808 int size;
00809 va_list ap;
00810
00811 va_start (ap, comment);
00812
00813 size = size_of_encoded_value (encoding);
00814
00815 if (encoding == DW_EH_PE_aligned)
00816 {
00817 assemble_align (POINTER_SIZE);
00818 assemble_integer (addr, size, POINTER_SIZE, 1);
00819 return;
00820 }
00821
00822
00823
00824 if (addr == const0_rtx || addr == const1_rtx)
00825 assemble_integer (addr, size, BITS_PER_UNIT, 1);
00826 else
00827 {
00828 restart:
00829
00830
00831
00832 #ifdef ASM_MAYBE_OUTPUT_ENCODED_ADDR_RTX
00833 ASM_MAYBE_OUTPUT_ENCODED_ADDR_RTX (asm_out_file, encoding, size,
00834 addr, done);
00835 #endif
00836
00837
00838
00839 if (encoding & DW_EH_PE_indirect)
00840 {
00841
00842
00843
00844
00845
00846 addr = dw2_force_const_mem (addr, public);
00847 encoding &= ~DW_EH_PE_indirect;
00848 goto restart;
00849 }
00850
00851 switch (encoding & 0xF0)
00852 {
00853 case DW_EH_PE_absptr:
00854 dw2_assemble_integer (size, addr);
00855 break;
00856
00857 case DW_EH_PE_pcrel:
00858 gcc_assert (GET_CODE (addr) == SYMBOL_REF);
00859 #ifdef ASM_OUTPUT_DWARF_PCREL
00860 ASM_OUTPUT_DWARF_PCREL (asm_out_file, size, XSTR (addr, 0));
00861 #else
00862 dw2_assemble_integer (size, gen_rtx_MINUS (Pmode, addr, pc_rtx));
00863 #endif
00864 break;
00865
00866 default:
00867
00868
00869 gcc_unreachable ();
00870 }
00871
00872 #ifdef ASM_MAYBE_OUTPUT_ENCODED_ADDR_RTX
00873 done:;
00874 #endif
00875 }
00876
00877 if (flag_debug_asm && comment)
00878 {
00879 fprintf (asm_out_file, "\t%s ", ASM_COMMENT_START);
00880 vfprintf (asm_out_file, comment, ap);
00881 }
00882 fputc ('\n', asm_out_file);
00883
00884 va_end (ap);
00885 }
00886
00887 #include "gt-dwarf2asm.h"