OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gcc-4.2.2/] [gcc/] [dwarf2asm.c] - Blame information for rev 867

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 38 julius
/* Dwarf2 assembler output helper routines.
2
   Copyright (C) 2001, 2002, 2003, 2004, 2005, 2007 Free Software Foundation, Inc.
3
 
4
This file is part of GCC.
5
 
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 3, or (at your option) any later
9
version.
10
 
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
14
for more details.
15
 
16
You should have received a copy of the GNU General Public License
17
along with GCC; see the file COPYING3.  If not see
18
<http://www.gnu.org/licenses/>.  */
19
 
20
 
21
#include "config.h"
22
#include "system.h"
23
#include "coretypes.h"
24
#include "tm.h"
25
#include "flags.h"
26
#include "tree.h"
27
#include "rtl.h"
28
#include "output.h"
29
#include "target.h"
30
#include "dwarf2asm.h"
31
#include "dwarf2.h"
32
#include "splay-tree.h"
33
#include "ggc.h"
34
#include "tm_p.h"
35
 
36
 
37
/* How to start an assembler comment.  */
38
#ifndef ASM_COMMENT_START
39
#define ASM_COMMENT_START ";#"
40
#endif
41
 
42
 
43
/* Output an unaligned integer with the given value and size.  Prefer not
44
   to print a newline, since the caller may want to add a comment.  */
45
 
46
void
47
dw2_assemble_integer (int size, rtx x)
48
{
49
  const char *op = integer_asm_op (size, FALSE);
50
 
51
  if (op)
52
    {
53
      fputs (op, asm_out_file);
54
      if (GET_CODE (x) == CONST_INT)
55
        fprintf (asm_out_file, HOST_WIDE_INT_PRINT_HEX, INTVAL (x));
56
      else
57
        output_addr_const (asm_out_file, x);
58
    }
59
  else
60
    assemble_integer (x, size, BITS_PER_UNIT, 1);
61
}
62
 
63
 
64
/* Output an immediate constant in a given size.  */
65
 
66
void
67
dw2_asm_output_data (int size, unsigned HOST_WIDE_INT value,
68
                     const char *comment, ...)
69
{
70
  va_list ap;
71
  const char *op = integer_asm_op (size, FALSE);
72
 
73
  va_start (ap, comment);
74
 
75
  if (size * 8 < HOST_BITS_PER_WIDE_INT)
76
    value &= ~(~(unsigned HOST_WIDE_INT) 0 << (size * 8));
77
 
78
  if (op)
79
    fprintf (asm_out_file, "%s" HOST_WIDE_INT_PRINT_HEX, op, value);
80
  else
81
    assemble_integer (GEN_INT (value), size, BITS_PER_UNIT, 1);
82
 
83
  if (flag_debug_asm && comment)
84
    {
85
      fprintf (asm_out_file, "\t%s ", ASM_COMMENT_START);
86
      vfprintf (asm_out_file, comment, ap);
87
    }
88
  fputc ('\n', asm_out_file);
89
 
90
  va_end (ap);
91
}
92
 
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.  */
98
 
99
void
100
dw2_asm_output_delta (int size, const char *lab1, const char *lab2,
101
                      const char *comment, ...)
102
{
103
  va_list ap;
104
 
105
  va_start (ap, comment);
106
 
107
#ifdef ASM_OUTPUT_DWARF_DELTA
108
  ASM_OUTPUT_DWARF_DELTA (asm_out_file, size, lab1, lab2);
109
#else
110
  dw2_assemble_integer (size,
111
                        gen_rtx_MINUS (Pmode,
112
                                       gen_rtx_SYMBOL_REF (Pmode, lab1),
113
                                       gen_rtx_SYMBOL_REF (Pmode, lab2)));
114
#endif
115
  if (flag_debug_asm && comment)
116
    {
117
      fprintf (asm_out_file, "\t%s ", ASM_COMMENT_START);
118
      vfprintf (asm_out_file, comment, ap);
119
    }
120
  fputc ('\n', asm_out_file);
121
 
122
  va_end (ap);
123
}
124
 
125
/* Output a section-relative reference to a LABEL, which was placed in
126
   BASE.  In general this can only be done for debugging symbols.
127
   E.g. on most targets with the GNU linker, this is accomplished with
128
   a direct reference and the knowledge that the debugging section
129
   will be placed at VMA 0.  Some targets have special relocations for
130
   this that we must use.  */
131
 
132
void
133
dw2_asm_output_offset (int size, const char *label,
134
                       section *base ATTRIBUTE_UNUSED,
135
                       const char *comment, ...)
136
{
137
  va_list ap;
138
 
139
  va_start (ap, comment);
140
 
141
#ifdef ASM_OUTPUT_DWARF_OFFSET
142
  ASM_OUTPUT_DWARF_OFFSET (asm_out_file, size, label, base);
143
#else
144
  dw2_assemble_integer (size, gen_rtx_SYMBOL_REF (Pmode, label));
145
#endif
146
 
147
  if (flag_debug_asm && comment)
148
    {
149
      fprintf (asm_out_file, "\t%s ", ASM_COMMENT_START);
150
      vfprintf (asm_out_file, comment, ap);
151
    }
152
  fputc ('\n', asm_out_file);
153
 
154
  va_end (ap);
155
}
156
 
157
#if 0
158
 
159
/* Output a self-relative reference to a label, possibly in a
160
   different section or object file.  */
161
 
162
void
163
dw2_asm_output_pcrel (int size ATTRIBUTE_UNUSED,
164
                      const char *label ATTRIBUTE_UNUSED,
165
                      const char *comment, ...)
166
{
167
  va_list ap;
168
 
169
  va_start (ap, comment);
170
 
171
#ifdef ASM_OUTPUT_DWARF_PCREL
172
  ASM_OUTPUT_DWARF_PCREL (asm_out_file, size, label);
173
#else
174
  dw2_assemble_integer (size,
175
                        gen_rtx_MINUS (Pmode,
176
                                       gen_rtx_SYMBOL_REF (Pmode, label),
177
                                       pc_rtx));
178
#endif
179
 
180
  if (flag_debug_asm && comment)
181
    {
182
      fprintf (asm_out_file, "\t%s ", ASM_COMMENT_START);
183
      vfprintf (asm_out_file, comment, ap);
184
    }
185
  fputc ('\n', asm_out_file);
186
 
187
  va_end (ap);
188
}
189
#endif /* 0 */
190
 
191
/* Output an absolute reference to a label.  */
192
 
193
void
194
dw2_asm_output_addr (int size, const char *label,
195
                     const char *comment, ...)
196
{
197
  va_list ap;
198
 
199
  va_start (ap, comment);
200
 
201
  dw2_assemble_integer (size, gen_rtx_SYMBOL_REF (Pmode, label));
202
 
203
  if (flag_debug_asm && comment)
204
    {
205
      fprintf (asm_out_file, "\t%s ", ASM_COMMENT_START);
206
      vfprintf (asm_out_file, comment, ap);
207
    }
208
  fputc ('\n', asm_out_file);
209
 
210
  va_end (ap);
211
}
212
 
213
/* Similar, but use an RTX expression instead of a text label.  */
214
 
215
void
216
dw2_asm_output_addr_rtx (int size, rtx addr,
217
                         const char *comment, ...)
218
{
219
  va_list ap;
220
 
221
  va_start (ap, comment);
222
 
223
  dw2_assemble_integer (size, addr);
224
 
225
  if (flag_debug_asm && comment)
226
    {
227
      fprintf (asm_out_file, "\t%s ", ASM_COMMENT_START);
228
      vfprintf (asm_out_file, comment, ap);
229
    }
230
  fputc ('\n', asm_out_file);
231
 
232
  va_end (ap);
233
}
234
 
235
/* Output the first ORIG_LEN characters of STR as a string.
236
   If ORIG_LEN is equal to -1, ignore this parameter and output
237
   the entire STR instead.
238
   If COMMENT is not NULL and comments in the debug information
239
   have been requested by the user, append the given COMMENT
240
   to the generated output.  */
241
 
242
void
243
dw2_asm_output_nstring (const char *str, size_t orig_len,
244
                        const char *comment, ...)
245
{
246
  size_t i, len;
247
  va_list ap;
248
 
249
  va_start (ap, comment);
250
 
251
  len = orig_len;
252
 
253
  if (len == (size_t) -1)
254
    len = strlen (str);
255
 
256
  if (flag_debug_asm && comment)
257
    {
258
      fputs ("\t.ascii \"", asm_out_file);
259
      for (i = 0; i < len; i++)
260
        {
261
          int c = str[i];
262
          if (c == '\"' || c == '\\')
263
            fputc ('\\', asm_out_file);
264
          if (ISPRINT(c))
265
            fputc (c, asm_out_file);
266
          else
267
            fprintf (asm_out_file, "\\%o", c);
268
        }
269
      fprintf (asm_out_file, "\\0\"\t%s ", ASM_COMMENT_START);
270
      vfprintf (asm_out_file, comment, ap);
271
      fputc ('\n', asm_out_file);
272
    }
273
  else
274
    {
275
      /* If an explicit length was given, we can't assume there
276
         is a null termination in the string buffer.  */
277
      if (orig_len == (size_t) -1)
278
        len += 1;
279
      ASM_OUTPUT_ASCII (asm_out_file, str, len);
280
      if (orig_len != (size_t) -1)
281
        assemble_integer (const0_rtx, 1, BITS_PER_UNIT, 1);
282
    }
283
 
284
  va_end (ap);
285
}
286
 
287
 
288
/* Return the size of an unsigned LEB128 quantity.  */
289
 
290
int
291
size_of_uleb128 (unsigned HOST_WIDE_INT value)
292
{
293
  int size = 0;
294
 
295
  do
296
    {
297
      value >>= 7;
298
      size += 1;
299
    }
300
  while (value != 0);
301
 
302
  return size;
303
}
304
 
305
/* Return the size of a signed LEB128 quantity.  */
306
 
307
int
308
size_of_sleb128 (HOST_WIDE_INT value)
309
{
310
  int size = 0, byte;
311
 
312
  do
313
    {
314
      byte = (value & 0x7f);
315
      value >>= 7;
316
      size += 1;
317
    }
318
  while (!((value == 0 && (byte & 0x40) == 0)
319
           || (value == -1 && (byte & 0x40) != 0)));
320
 
321
  return size;
322
}
323
 
324
/* Given an encoding, return the number of bytes the format occupies.
325
   This is only defined for fixed-size encodings, and so does not
326
   include leb128.  */
327
 
328
int
329
size_of_encoded_value (int encoding)
330
{
331
  if (encoding == DW_EH_PE_omit)
332
    return 0;
333
 
334
  switch (encoding & 0x07)
335
    {
336
    case DW_EH_PE_absptr:
337
      return POINTER_SIZE / BITS_PER_UNIT;
338
    case DW_EH_PE_udata2:
339
      return 2;
340
    case DW_EH_PE_udata4:
341
      return 4;
342
    case DW_EH_PE_udata8:
343
      return 8;
344
    default:
345
      gcc_unreachable ();
346
    }
347
}
348
 
349
/* Yield a name for a given pointer encoding.  */
350
 
351
const char *
352
eh_data_format_name (int format)
353
{
354
#if HAVE_DESIGNATED_INITIALIZERS
355
#define S(p, v)         [p] = v,
356
#else
357
#define S(p, v)         case p: return v;
358
#endif
359
 
360
#if HAVE_DESIGNATED_INITIALIZERS
361
  __extension__ static const char * const format_names[256] = {
362
#else
363
  switch (format) {
364
#endif
365
 
366
  S(DW_EH_PE_absptr, "absolute")
367
  S(DW_EH_PE_omit, "omit")
368
  S(DW_EH_PE_aligned, "aligned absolute")
369
 
370
  S(DW_EH_PE_uleb128, "uleb128")
371
  S(DW_EH_PE_udata2, "udata2")
372
  S(DW_EH_PE_udata4, "udata4")
373
  S(DW_EH_PE_udata8, "udata8")
374
  S(DW_EH_PE_sleb128, "sleb128")
375
  S(DW_EH_PE_sdata2, "sdata2")
376
  S(DW_EH_PE_sdata4, "sdata4")
377
  S(DW_EH_PE_sdata8, "sdata8")
378
 
379
  S(DW_EH_PE_absptr | DW_EH_PE_pcrel, "pcrel")
380
  S(DW_EH_PE_uleb128 | DW_EH_PE_pcrel, "pcrel uleb128")
381
  S(DW_EH_PE_udata2 | DW_EH_PE_pcrel, "pcrel udata2")
382
  S(DW_EH_PE_udata4 | DW_EH_PE_pcrel, "pcrel udata4")
383
  S(DW_EH_PE_udata8 | DW_EH_PE_pcrel, "pcrel udata8")
384
  S(DW_EH_PE_sleb128 | DW_EH_PE_pcrel, "pcrel sleb128")
385
  S(DW_EH_PE_sdata2 | DW_EH_PE_pcrel, "pcrel sdata2")
386
  S(DW_EH_PE_sdata4 | DW_EH_PE_pcrel, "pcrel sdata4")
387
  S(DW_EH_PE_sdata8 | DW_EH_PE_pcrel, "pcrel sdata8")
388
 
389
  S(DW_EH_PE_absptr | DW_EH_PE_textrel, "textrel")
390
  S(DW_EH_PE_uleb128 | DW_EH_PE_textrel, "textrel uleb128")
391
  S(DW_EH_PE_udata2 | DW_EH_PE_textrel, "textrel udata2")
392
  S(DW_EH_PE_udata4 | DW_EH_PE_textrel, "textrel udata4")
393
  S(DW_EH_PE_udata8 | DW_EH_PE_textrel, "textrel udata8")
394
  S(DW_EH_PE_sleb128 | DW_EH_PE_textrel, "textrel sleb128")
395
  S(DW_EH_PE_sdata2 | DW_EH_PE_textrel, "textrel sdata2")
396
  S(DW_EH_PE_sdata4 | DW_EH_PE_textrel, "textrel sdata4")
397
  S(DW_EH_PE_sdata8 | DW_EH_PE_textrel, "textrel sdata8")
398
 
399
  S(DW_EH_PE_absptr | DW_EH_PE_datarel, "datarel")
400
  S(DW_EH_PE_uleb128 | DW_EH_PE_datarel, "datarel uleb128")
401
  S(DW_EH_PE_udata2 | DW_EH_PE_datarel, "datarel udata2")
402
  S(DW_EH_PE_udata4 | DW_EH_PE_datarel, "datarel udata4")
403
  S(DW_EH_PE_udata8 | DW_EH_PE_datarel, "datarel udata8")
404
  S(DW_EH_PE_sleb128 | DW_EH_PE_datarel, "datarel sleb128")
405
  S(DW_EH_PE_sdata2 | DW_EH_PE_datarel, "datarel sdata2")
406
  S(DW_EH_PE_sdata4 | DW_EH_PE_datarel, "datarel sdata4")
407
  S(DW_EH_PE_sdata8 | DW_EH_PE_datarel, "datarel sdata8")
408
 
409
  S(DW_EH_PE_absptr | DW_EH_PE_funcrel, "funcrel")
410
  S(DW_EH_PE_uleb128 | DW_EH_PE_funcrel, "funcrel uleb128")
411
  S(DW_EH_PE_udata2 | DW_EH_PE_funcrel, "funcrel udata2")
412
  S(DW_EH_PE_udata4 | DW_EH_PE_funcrel, "funcrel udata4")
413
  S(DW_EH_PE_udata8 | DW_EH_PE_funcrel, "funcrel udata8")
414
  S(DW_EH_PE_sleb128 | DW_EH_PE_funcrel, "funcrel sleb128")
415
  S(DW_EH_PE_sdata2 | DW_EH_PE_funcrel, "funcrel sdata2")
416
  S(DW_EH_PE_sdata4 | DW_EH_PE_funcrel, "funcrel sdata4")
417
  S(DW_EH_PE_sdata8 | DW_EH_PE_funcrel, "funcrel sdata8")
418
 
419
  S(DW_EH_PE_indirect | DW_EH_PE_absptr | DW_EH_PE_pcrel,
420
    "indirect pcrel")
421
  S(DW_EH_PE_indirect | DW_EH_PE_uleb128 | DW_EH_PE_pcrel,
422
    "indirect pcrel uleb128")
423
  S(DW_EH_PE_indirect | DW_EH_PE_udata2 | DW_EH_PE_pcrel,
424
    "indirect pcrel udata2")
425
  S(DW_EH_PE_indirect | DW_EH_PE_udata4 | DW_EH_PE_pcrel,
426
    "indirect pcrel udata4")
427
  S(DW_EH_PE_indirect | DW_EH_PE_udata8 | DW_EH_PE_pcrel,
428
    "indirect pcrel udata8")
429
  S(DW_EH_PE_indirect | DW_EH_PE_sleb128 | DW_EH_PE_pcrel,
430
    "indirect pcrel sleb128")
431
  S(DW_EH_PE_indirect | DW_EH_PE_sdata2 | DW_EH_PE_pcrel,
432
    "indirect pcrel sdata2")
433
  S(DW_EH_PE_indirect | DW_EH_PE_sdata4 | DW_EH_PE_pcrel,
434
    "indirect pcrel sdata4")
435
  S(DW_EH_PE_indirect | DW_EH_PE_sdata8 | DW_EH_PE_pcrel,
436
    "indirect pcrel sdata8")
437
 
438
  S(DW_EH_PE_indirect | DW_EH_PE_absptr | DW_EH_PE_textrel,
439
    "indirect textrel")
440
  S(DW_EH_PE_indirect | DW_EH_PE_uleb128 | DW_EH_PE_textrel,
441
    "indirect textrel uleb128")
442
  S(DW_EH_PE_indirect | DW_EH_PE_udata2 | DW_EH_PE_textrel,
443
    "indirect textrel udata2")
444
  S(DW_EH_PE_indirect | DW_EH_PE_udata4 | DW_EH_PE_textrel,
445
    "indirect textrel udata4")
446
  S(DW_EH_PE_indirect | DW_EH_PE_udata8 | DW_EH_PE_textrel,
447
    "indirect textrel udata8")
448
  S(DW_EH_PE_indirect | DW_EH_PE_sleb128 | DW_EH_PE_textrel,
449
    "indirect textrel sleb128")
450
  S(DW_EH_PE_indirect | DW_EH_PE_sdata2 | DW_EH_PE_textrel,
451
    "indirect textrel sdata2")
452
  S(DW_EH_PE_indirect | DW_EH_PE_sdata4 | DW_EH_PE_textrel,
453
    "indirect textrel sdata4")
454
  S(DW_EH_PE_indirect | DW_EH_PE_sdata8 | DW_EH_PE_textrel,
455
    "indirect textrel sdata8")
456
 
457
  S(DW_EH_PE_indirect | DW_EH_PE_absptr | DW_EH_PE_datarel,
458
    "indirect datarel")
459
  S(DW_EH_PE_indirect | DW_EH_PE_uleb128 | DW_EH_PE_datarel,
460
    "indirect datarel uleb128")
461
  S(DW_EH_PE_indirect | DW_EH_PE_udata2 | DW_EH_PE_datarel,
462
    "indirect datarel udata2")
463
  S(DW_EH_PE_indirect | DW_EH_PE_udata4 | DW_EH_PE_datarel,
464
    "indirect datarel udata4")
465
  S(DW_EH_PE_indirect | DW_EH_PE_udata8 | DW_EH_PE_datarel,
466
    "indirect datarel udata8")
467
  S(DW_EH_PE_indirect | DW_EH_PE_sleb128 | DW_EH_PE_datarel,
468
    "indirect datarel sleb128")
469
  S(DW_EH_PE_indirect | DW_EH_PE_sdata2 | DW_EH_PE_datarel,
470
    "indirect datarel sdata2")
471
  S(DW_EH_PE_indirect | DW_EH_PE_sdata4 | DW_EH_PE_datarel,
472
    "indirect datarel sdata4")
473
  S(DW_EH_PE_indirect | DW_EH_PE_sdata8 | DW_EH_PE_datarel,
474
    "indirect datarel sdata8")
475
 
476
  S(DW_EH_PE_indirect | DW_EH_PE_absptr | DW_EH_PE_funcrel,
477
    "indirect funcrel")
478
  S(DW_EH_PE_indirect | DW_EH_PE_uleb128 | DW_EH_PE_funcrel,
479
    "indirect funcrel uleb128")
480
  S(DW_EH_PE_indirect | DW_EH_PE_udata2 | DW_EH_PE_funcrel,
481
    "indirect funcrel udata2")
482
  S(DW_EH_PE_indirect | DW_EH_PE_udata4 | DW_EH_PE_funcrel,
483
    "indirect funcrel udata4")
484
  S(DW_EH_PE_indirect | DW_EH_PE_udata8 | DW_EH_PE_funcrel,
485
    "indirect funcrel udata8")
486
  S(DW_EH_PE_indirect | DW_EH_PE_sleb128 | DW_EH_PE_funcrel,
487
    "indirect funcrel sleb128")
488
  S(DW_EH_PE_indirect | DW_EH_PE_sdata2 | DW_EH_PE_funcrel,
489
    "indirect funcrel sdata2")
490
  S(DW_EH_PE_indirect | DW_EH_PE_sdata4 | DW_EH_PE_funcrel,
491
    "indirect funcrel sdata4")
492
  S(DW_EH_PE_indirect | DW_EH_PE_sdata8 | DW_EH_PE_funcrel,
493
    "indirect funcrel sdata8")
494
 
495
#if HAVE_DESIGNATED_INITIALIZERS
496
  };
497
 
498
  gcc_assert (format >= 0 && format < 0x100 && format_names[format]);
499
 
500
  return format_names[format];
501
#else
502
  }
503
  gcc_unreachable ();
504
#endif
505
}
506
 
507
/* Output an unsigned LEB128 quantity.  */
508
 
509
void
510
dw2_asm_output_data_uleb128 (unsigned HOST_WIDE_INT value,
511
                             const char *comment, ...)
512
{
513
  va_list ap;
514
 
515
  va_start (ap, comment);
516
 
517
#ifdef HAVE_AS_LEB128
518
  fprintf (asm_out_file, "\t.uleb128 " HOST_WIDE_INT_PRINT_HEX , value);
519
 
520
  if (flag_debug_asm && comment)
521
    {
522
      fprintf (asm_out_file, "\t%s ", ASM_COMMENT_START);
523
      vfprintf (asm_out_file, comment, ap);
524
    }
525
#else
526
  {
527
    unsigned HOST_WIDE_INT work = value;
528
    const char *byte_op = targetm.asm_out.byte_op;
529
 
530
    if (byte_op)
531
      fputs (byte_op, asm_out_file);
532
    do
533
      {
534
        int byte = (work & 0x7f);
535
        work >>= 7;
536
        if (work != 0)
537
          /* More bytes to follow.  */
538
          byte |= 0x80;
539
 
540
        if (byte_op)
541
          {
542
            fprintf (asm_out_file, "0x%x", byte);
543
            if (work != 0)
544
              fputc (',', asm_out_file);
545
          }
546
        else
547
          assemble_integer (GEN_INT (byte), 1, BITS_PER_UNIT, 1);
548
      }
549
    while (work != 0);
550
 
551
  if (flag_debug_asm)
552
    {
553
      fprintf (asm_out_file, "\t%s uleb128 " HOST_WIDE_INT_PRINT_HEX,
554
               ASM_COMMENT_START, value);
555
      if (comment)
556
        {
557
          fputs ("; ", asm_out_file);
558
          vfprintf (asm_out_file, comment, ap);
559
        }
560
    }
561
  }
562
#endif
563
  fputc ('\n', asm_out_file);
564
 
565
  va_end (ap);
566
}
567
 
568
/* Output a signed LEB128 quantity.  */
569
 
570
void
571
dw2_asm_output_data_sleb128 (HOST_WIDE_INT value,
572
                             const char *comment, ...)
573
{
574
  va_list ap;
575
 
576
  va_start (ap, comment);
577
 
578
#ifdef HAVE_AS_LEB128
579
  fprintf (asm_out_file, "\t.sleb128 " HOST_WIDE_INT_PRINT_DEC, value);
580
 
581
  if (flag_debug_asm && comment)
582
    {
583
      fprintf (asm_out_file, "\t%s ", ASM_COMMENT_START);
584
      vfprintf (asm_out_file, comment, ap);
585
    }
586
#else
587
  {
588
    HOST_WIDE_INT work = value;
589
    int more, byte;
590
    const char *byte_op = targetm.asm_out.byte_op;
591
 
592
    if (byte_op)
593
      fputs (byte_op, asm_out_file);
594
    do
595
      {
596
        byte = (work & 0x7f);
597
        /* arithmetic shift */
598
        work >>= 7;
599
        more = !((work == 0 && (byte & 0x40) == 0)
600
                 || (work == -1 && (byte & 0x40) != 0));
601
        if (more)
602
          byte |= 0x80;
603
 
604
        if (byte_op)
605
          {
606
            fprintf (asm_out_file, "0x%x", byte);
607
            if (more)
608
              fputc (',', asm_out_file);
609
          }
610
        else
611
          assemble_integer (GEN_INT (byte), 1, BITS_PER_UNIT, 1);
612
      }
613
    while (more);
614
 
615
  if (flag_debug_asm)
616
    {
617
      fprintf (asm_out_file, "\t%s sleb128 " HOST_WIDE_INT_PRINT_DEC,
618
               ASM_COMMENT_START, value);
619
      if (comment)
620
        {
621
          fputs ("; ", asm_out_file);
622
          vfprintf (asm_out_file, comment, ap);
623
        }
624
    }
625
  }
626
#endif
627
  fputc ('\n', asm_out_file);
628
 
629
  va_end (ap);
630
}
631
 
632
void
633
dw2_asm_output_delta_uleb128 (const char *lab1 ATTRIBUTE_UNUSED,
634
                              const char *lab2 ATTRIBUTE_UNUSED,
635
                              const char *comment, ...)
636
{
637
  va_list ap;
638
 
639
  va_start (ap, comment);
640
 
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);
646
#else
647
  gcc_unreachable ();
648
#endif
649
 
650
  if (flag_debug_asm && comment)
651
    {
652
      fprintf (asm_out_file, "\t%s ", ASM_COMMENT_START);
653
      vfprintf (asm_out_file, comment, ap);
654
    }
655
  fputc ('\n', asm_out_file);
656
 
657
  va_end (ap);
658
}
659
 
660
#if 0
661
 
662
void
663
dw2_asm_output_delta_sleb128 (const char *lab1 ATTRIBUTE_UNUSED,
664
                              const char *lab2 ATTRIBUTE_UNUSED,
665
                              const char *comment, ...)
666
{
667
  va_list ap;
668
 
669
  va_start (ap, comment);
670
 
671
#ifdef HAVE_AS_LEB128
672
  fputs ("\t.sleb128 ", asm_out_file);
673
  assemble_name (asm_out_file, lab1);
674
  fputc ('-', asm_out_file);
675
  assemble_name (asm_out_file, lab2);
676
#else
677
  gcc_unreachable ();
678
#endif
679
 
680
  if (flag_debug_asm && comment)
681
    {
682
      fprintf (asm_out_file, "\t%s ", ASM_COMMENT_START);
683
      vfprintf (asm_out_file, comment, ap);
684
    }
685
  fputc ('\n', asm_out_file);
686
 
687
  va_end (ap);
688
}
689
#endif /* 0 */
690
 
691
static rtx dw2_force_const_mem (rtx, bool);
692
static int dw2_output_indirect_constant_1 (splay_tree_node, void *);
693
 
694
static GTY((param1_is (char *), param2_is (tree))) splay_tree indirect_pool;
695
 
696
static GTY(()) int dw2_const_labelno;
697
 
698
#if defined(HAVE_GAS_HIDDEN) && defined(SUPPORTS_ONE_ONLY)
699
# define USE_LINKONCE_INDIRECT 1
700
#else
701
# define USE_LINKONCE_INDIRECT 0
702
#endif
703
 
704
/* Put X, a SYMBOL_REF, in memory.  Return a SYMBOL_REF to the allocated
705
   memory.  Differs from force_const_mem in that a single pool is used for
706
   the entire unit of translation, and the memory is not guaranteed to be
707
   "near" the function in any interesting sense.  PUBLIC controls whether
708
   the symbol can be shared across the entire application (or DSO).  */
709
 
710
static rtx
711
dw2_force_const_mem (rtx x, bool public)
712
{
713
  splay_tree_node node;
714
  const char *str;
715
  tree decl;
716
 
717
  if (! indirect_pool)
718
    indirect_pool = splay_tree_new_ggc (splay_tree_compare_pointers);
719
 
720
  gcc_assert (GET_CODE (x) == SYMBOL_REF);
721
 
722
  str = targetm.strip_name_encoding (XSTR (x, 0));
723
  node = splay_tree_lookup (indirect_pool, (splay_tree_key) str);
724
  if (node)
725
    decl = (tree) node->value;
726
  else
727
    {
728
      tree id;
729
 
730
      if (public && USE_LINKONCE_INDIRECT)
731
        {
732
          char *ref_name = alloca (strlen (str) + sizeof "DW.ref.");
733
 
734
          sprintf (ref_name, "DW.ref.%s", str);
735
          id = get_identifier (ref_name);
736
          decl = build_decl (VAR_DECL, id, ptr_type_node);
737
          DECL_ARTIFICIAL (decl) = 1;
738
          DECL_IGNORED_P (decl) = 1;
739
          TREE_PUBLIC (decl) = 1;
740
          DECL_INITIAL (decl) = decl;
741
          make_decl_one_only (decl);
742
        }
743
      else
744
        {
745
          char label[32];
746
 
747
          ASM_GENERATE_INTERNAL_LABEL (label, "LDFCM", dw2_const_labelno);
748
          ++dw2_const_labelno;
749
          id = get_identifier (label);
750
          decl = build_decl (VAR_DECL, id, ptr_type_node);
751
          DECL_ARTIFICIAL (decl) = 1;
752
          DECL_IGNORED_P (decl) = 1;
753
          TREE_STATIC (decl) = 1;
754
          DECL_INITIAL (decl) = decl;
755
        }
756
 
757
      id = maybe_get_identifier (str);
758
      if (id)
759
        TREE_SYMBOL_REFERENCED (id) = 1;
760
 
761
      splay_tree_insert (indirect_pool, (splay_tree_key) str,
762
                         (splay_tree_value) decl);
763
    }
764
 
765
  return XEXP (DECL_RTL (decl), 0);
766
}
767
 
768
/* A helper function for dw2_output_indirect_constants called through
769
   splay_tree_foreach.  Emit one queued constant to memory.  */
770
 
771
static int
772
dw2_output_indirect_constant_1 (splay_tree_node node,
773
                                void *data ATTRIBUTE_UNUSED)
774
{
775
  const char *sym;
776
  rtx sym_ref;
777
  tree decl;
778
 
779
  sym = (const char *) node->key;
780
  decl = (tree) node->value;
781
  sym_ref = gen_rtx_SYMBOL_REF (Pmode, sym);
782
  if (TREE_PUBLIC (decl) && USE_LINKONCE_INDIRECT)
783
    fprintf (asm_out_file, "\t.hidden %sDW.ref.%s\n", user_label_prefix, sym);
784
  assemble_variable (decl, 1, 1, 1);
785
  assemble_integer (sym_ref, POINTER_SIZE / BITS_PER_UNIT, POINTER_SIZE, 1);
786
 
787
  return 0;
788
}
789
 
790
/* Emit the constants queued through dw2_force_const_mem.  */
791
 
792
void
793
dw2_output_indirect_constants (void)
794
{
795
  if (indirect_pool)
796
    splay_tree_foreach (indirect_pool, dw2_output_indirect_constant_1, NULL);
797
}
798
 
799
/* Like dw2_asm_output_addr_rtx, but encode the pointer as directed.
800
   If PUBLIC is set and the encoding is DW_EH_PE_indirect, the indirect
801
   reference is shared across the entire application (or DSO).  */
802
 
803
void
804
dw2_asm_output_encoded_addr_rtx (int encoding, rtx addr, bool public,
805
                                 const char *comment, ...)
806
{
807
  int size;
808
  va_list ap;
809
 
810
  va_start (ap, comment);
811
 
812
  size = size_of_encoded_value (encoding);
813
 
814
  if (encoding == DW_EH_PE_aligned)
815
    {
816
      assemble_align (POINTER_SIZE);
817
      assemble_integer (addr, size, POINTER_SIZE, 1);
818
      return;
819
    }
820
 
821
  /* NULL is _always_ represented as a plain zero, as is 1 for Ada's
822
     "all others".  */
823
  if (addr == const0_rtx || addr == const1_rtx)
824
    assemble_integer (addr, size, BITS_PER_UNIT, 1);
825
  else
826
    {
827
    restart:
828
      /* Allow the target first crack at emitting this.  Some of the
829
         special relocations require special directives instead of
830
         just ".4byte" or whatever.  */
831
#ifdef ASM_MAYBE_OUTPUT_ENCODED_ADDR_RTX
832
      ASM_MAYBE_OUTPUT_ENCODED_ADDR_RTX (asm_out_file, encoding, size,
833
                                         addr, done);
834
#endif
835
 
836
      /* Indirection is used to get dynamic relocations out of a
837
         read-only section.  */
838
      if (encoding & DW_EH_PE_indirect)
839
        {
840
          /* It is very tempting to use force_const_mem so that we share data
841
             with the normal constant pool.  However, we've already emitted
842
             the constant pool for this function.  Moreover, we'd like to
843
             share these constants across the entire unit of translation and
844
             even, if possible, across the entire application (or DSO).  */
845
          addr = dw2_force_const_mem (addr, public);
846
          encoding &= ~DW_EH_PE_indirect;
847
          goto restart;
848
        }
849
 
850
      switch (encoding & 0xF0)
851
        {
852
        case DW_EH_PE_absptr:
853
          dw2_assemble_integer (size, addr);
854
          break;
855
 
856
        case DW_EH_PE_pcrel:
857
          gcc_assert (GET_CODE (addr) == SYMBOL_REF);
858
#ifdef ASM_OUTPUT_DWARF_PCREL
859
          ASM_OUTPUT_DWARF_PCREL (asm_out_file, size, XSTR (addr, 0));
860
#else
861
          dw2_assemble_integer (size, gen_rtx_MINUS (Pmode, addr, pc_rtx));
862
#endif
863
          break;
864
 
865
        default:
866
          /* Other encodings should have been handled by
867
             ASM_MAYBE_OUTPUT_ENCODED_ADDR_RTX.  */
868
          gcc_unreachable ();
869
        }
870
 
871
#ifdef ASM_MAYBE_OUTPUT_ENCODED_ADDR_RTX
872
    done:;
873
#endif
874
    }
875
 
876
  if (flag_debug_asm && comment)
877
    {
878
      fprintf (asm_out_file, "\t%s ", ASM_COMMENT_START);
879
      vfprintf (asm_out_file, comment, ap);
880
    }
881
  fputc ('\n', asm_out_file);
882
 
883
  va_end (ap);
884
}
885
 
886
#include "gt-dwarf2asm.h"

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.