]>
Commit | Line | Data |
---|---|---|
79e68feb RS |
1 | /* Output variables, constants and external declarations, for GNU compiler. |
2 | Copyright (C) 1987, 1988, 1989, 1992 Free Software Foundation, Inc. | |
3 | ||
4 | This file is part of GNU CC. | |
5 | ||
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) | |
9 | any later version. | |
10 | ||
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. | |
15 | ||
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, 675 Mass Ave, Cambridge, MA 02139, USA. */ | |
19 | ||
20 | ||
21 | /* This file handles generation of all the assembler code | |
22 | *except* the instructions of a function. | |
23 | This includes declarations of variables and their initial values. | |
24 | ||
25 | We also output the assembler code for constants stored in memory | |
26 | and are responsible for combining constants with the same value. */ | |
27 | ||
28 | #include <stdio.h> | |
29 | #include <setjmp.h> | |
30 | /* #include <stab.h> */ | |
31 | #include "config.h" | |
32 | #include "rtl.h" | |
33 | #include "tree.h" | |
34 | #include "flags.h" | |
35 | #include "expr.h" | |
36 | #include "hard-reg-set.h" | |
37 | #include "regs.h" | |
38 | ||
39 | #include "obstack.h" | |
40 | ||
b4ac57ab RS |
41 | #ifdef XCOFF_DEBUGGING_INFO |
42 | #include "xcoff.h" | |
43 | #endif | |
44 | ||
79e68feb RS |
45 | #ifndef ASM_STABS_OP |
46 | #define ASM_STABS_OP ".stabs" | |
47 | #endif | |
48 | ||
49 | /* File in which assembler code is being written. */ | |
50 | ||
51 | extern FILE *asm_out_file; | |
52 | ||
53 | /* The (assembler) name of the first globally-visible object output. */ | |
54 | char *first_global_object_name; | |
55 | ||
56 | extern struct obstack *current_obstack; | |
57 | extern struct obstack *saveable_obstack; | |
58 | extern struct obstack permanent_obstack; | |
59 | #define obstack_chunk_alloc xmalloc | |
60 | extern int xmalloc (); | |
61 | ||
62 | /* Number for making the label on the next | |
63 | constant that is stored in memory. */ | |
64 | ||
65 | int const_labelno; | |
66 | ||
67 | /* Number for making the label on the next | |
68 | static variable internal to a function. */ | |
69 | ||
70 | int var_labelno; | |
71 | ||
72 | /* Nonzero if at least one function definition has been seen. */ | |
73 | static int function_defined; | |
74 | ||
75 | extern FILE *asm_out_file; | |
76 | ||
77 | static char *compare_constant_1 (); | |
78 | static void record_constant_1 (); | |
79 | void output_constant_pool (); | |
80 | void assemble_name (); | |
81 | int output_addressed_constants (); | |
82 | void output_constant (); | |
83 | void output_constructor (); | |
84 | \f | |
85 | #ifdef EXTRA_SECTIONS | |
86 | static enum in_section {no_section, in_text, in_data, EXTRA_SECTIONS} in_section | |
87 | = no_section; | |
88 | #else | |
89 | static enum in_section {no_section, in_text, in_data} in_section | |
90 | = no_section; | |
91 | #endif | |
92 | ||
93 | /* Define functions like text_section for any extra sections. */ | |
94 | #ifdef EXTRA_SECTION_FUNCTIONS | |
95 | EXTRA_SECTION_FUNCTIONS | |
96 | #endif | |
97 | ||
98 | /* Tell assembler to switch to text section. */ | |
99 | ||
100 | void | |
101 | text_section () | |
102 | { | |
103 | if (in_section != in_text) | |
104 | { | |
105 | fprintf (asm_out_file, "%s\n", TEXT_SECTION_ASM_OP); | |
106 | in_section = in_text; | |
107 | } | |
108 | } | |
109 | ||
110 | /* Tell assembler to switch to read-only data section. This is normally | |
111 | the text section. */ | |
112 | ||
113 | void | |
114 | readonly_data_section () | |
115 | { | |
116 | #ifdef READONLY_DATA_SECTION | |
117 | READONLY_DATA_SECTION (); | |
118 | #else | |
119 | text_section (); | |
120 | #endif | |
121 | } | |
122 | ||
123 | /* Tell assembler to switch to data section. */ | |
124 | ||
125 | void | |
126 | data_section () | |
127 | { | |
128 | if (in_section != in_data) | |
129 | { | |
130 | if (flag_shared_data) | |
131 | { | |
132 | #ifdef SHARED_SECTION_ASM_OP | |
133 | fprintf (asm_out_file, "%s\n", SHARED_SECTION_ASM_OP); | |
134 | #else | |
135 | fprintf (asm_out_file, "%s\n", DATA_SECTION_ASM_OP); | |
136 | #endif | |
137 | } | |
138 | else | |
139 | fprintf (asm_out_file, "%s\n", DATA_SECTION_ASM_OP); | |
140 | ||
141 | in_section = in_data; | |
142 | } | |
143 | } | |
144 | ||
145 | /* Determine if we're in the text section. */ | |
146 | ||
147 | int | |
148 | in_text_section () | |
149 | { | |
150 | return in_section == in_text; | |
151 | } | |
152 | \f | |
153 | /* Create the rtl to represent a function, for a function definition. | |
154 | DECL is a FUNCTION_DECL node which describes which function. | |
155 | The rtl is stored into DECL. */ | |
156 | ||
157 | void | |
158 | make_function_rtl (decl) | |
159 | tree decl; | |
160 | { | |
161 | char *name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)); | |
162 | ||
163 | /* Rename a nested function to avoid conflicts. */ | |
164 | if (decl_function_context (decl) != 0 | |
165 | && DECL_INITIAL (decl) != 0 | |
166 | && DECL_RTL (decl) == 0) | |
167 | { | |
168 | char *label; | |
169 | ||
170 | name = IDENTIFIER_POINTER (DECL_NAME (decl)); | |
171 | ASM_FORMAT_PRIVATE_NAME (label, name, var_labelno); | |
172 | name = obstack_copy0 (saveable_obstack, label, strlen (label)); | |
173 | var_labelno++; | |
174 | } | |
175 | ||
176 | if (DECL_RTL (decl) == 0) | |
177 | { | |
178 | DECL_RTL (decl) | |
179 | = gen_rtx (MEM, DECL_MODE (decl), | |
180 | gen_rtx (SYMBOL_REF, Pmode, name)); | |
181 | ||
182 | /* Optionally set flags or add text to the name to record information | |
183 | such as that it is a function name. If the name is changed, the macro | |
184 | ASM_OUTPUT_LABELREF will have to know how to strip this information. | |
185 | And if it finds a * at the beginning after doing so, it must handle | |
186 | that too. */ | |
187 | #ifdef ENCODE_SECTION_INFO | |
188 | ENCODE_SECTION_INFO (decl); | |
189 | #endif | |
190 | } | |
191 | ||
192 | /* Record at least one function has been defined. */ | |
193 | function_defined = 1; | |
194 | } | |
195 | ||
b4ac57ab RS |
196 | /* Given NAME, a putative register name, discard any customary prefixes. */ |
197 | ||
198 | static char * | |
199 | strip_reg_name (name) | |
200 | char *name; | |
201 | { | |
202 | #ifdef REGISTER_PREFIX | |
203 | if (!strncmp (name, REGISTER_PREFIX, strlen (REGISTER_PREFIX))) | |
204 | name += strlen (REGISTER_PREFIX); | |
205 | #endif | |
206 | if (name[0] == '%' || name[0] == '#') | |
207 | name++; | |
208 | return name; | |
209 | } | |
210 | ||
79e68feb RS |
211 | /* Decode an `asm' spec for a declaration as a register name. |
212 | Return the register number, or -1 if nothing specified, | |
b4ac57ab RS |
213 | or -2 if the name is not a register. Accept an exact spelling or |
214 | a decimal number. Prefixes such as % are optional. */ | |
79e68feb RS |
215 | |
216 | int | |
217 | decode_reg_name (asmspec) | |
218 | char *asmspec; | |
219 | { | |
220 | if (asmspec != 0) | |
221 | { | |
222 | int i; | |
223 | ||
b4ac57ab RS |
224 | /* Get rid of confusing prefixes. */ |
225 | asmspec = strip_reg_name (asmspec); | |
226 | ||
fff9e713 MT |
227 | /* Allow a decimal number as a "register name". */ |
228 | for (i = strlen (asmspec) - 1; i >= 0; i--) | |
229 | if (! (asmspec[i] >= '0' && asmspec[i] <= '9')) | |
230 | break; | |
231 | if (asmspec[0] != 0 && i < 0) | |
232 | { | |
233 | i = atoi (asmspec); | |
234 | if (i < FIRST_PSEUDO_REGISTER && i >= 0) | |
235 | return i; | |
236 | else | |
237 | return -2; | |
238 | } | |
239 | ||
79e68feb | 240 | for (i = 0; i < FIRST_PSEUDO_REGISTER; i++) |
b4ac57ab RS |
241 | if (reg_names[i][0] |
242 | && ! strcmp (asmspec, strip_reg_name (reg_names[i]))) | |
79e68feb RS |
243 | return i; |
244 | ||
79e68feb RS |
245 | #ifdef ADDITIONAL_REGISTER_NAMES |
246 | { | |
247 | static struct { char *name; int number; } table[] | |
248 | = ADDITIONAL_REGISTER_NAMES; | |
249 | ||
250 | for (i = 0; i < sizeof (table) / sizeof (table[0]); i++) | |
251 | if (! strcmp (asmspec, table[i].name)) | |
252 | return table[i].number; | |
79e68feb RS |
253 | } |
254 | #endif /* ADDITIONAL_REGISTER_NAMES */ | |
255 | ||
256 | return -2; | |
257 | } | |
258 | ||
259 | return -1; | |
260 | } | |
261 | \f | |
262 | /* Create the DECL_RTL for a declaration for a static or external variable | |
263 | or static or external function. | |
264 | ASMSPEC, if not 0, is the string which the user specified | |
265 | as the assembler symbol name. | |
266 | TOP_LEVEL is nonzero if this is a file-scope variable. | |
267 | ||
268 | This is never called for PARM_DECL nodes. */ | |
269 | ||
270 | void | |
271 | make_decl_rtl (decl, asmspec, top_level) | |
272 | tree decl; | |
273 | char *asmspec; | |
274 | int top_level; | |
275 | { | |
276 | register char *name; | |
277 | int reg_number = decode_reg_name (asmspec); | |
278 | ||
279 | if (DECL_ASSEMBLER_NAME (decl) != NULL_TREE) | |
280 | name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)); | |
281 | ||
282 | if (reg_number == -2) | |
283 | { | |
284 | /* ASMSPEC is given, and not the name of a register. */ | |
285 | name = (char *) obstack_alloc (saveable_obstack, | |
286 | strlen (asmspec) + 2); | |
287 | name[0] = '*'; | |
288 | strcpy (&name[1], asmspec); | |
289 | } | |
290 | ||
291 | /* For a duplicate declaration, we can be called twice on the | |
292 | same DECL node. Don't alter the RTL already made | |
293 | unless the old mode is wrong (which can happen when | |
294 | the previous rtl was made when the type was incomplete). */ | |
295 | if (DECL_RTL (decl) == 0 | |
296 | || GET_MODE (DECL_RTL (decl)) != DECL_MODE (decl)) | |
297 | { | |
298 | DECL_RTL (decl) = 0; | |
299 | ||
300 | /* First detect errors in declaring global registers. */ | |
301 | if (TREE_REGDECL (decl) && reg_number == -1) | |
302 | error_with_decl (decl, | |
303 | "register name not specified for `%s'"); | |
304 | else if (TREE_REGDECL (decl) && reg_number == -2) | |
305 | error_with_decl (decl, | |
306 | "invalid register name for `%s'"); | |
307 | else if (reg_number >= 0 && ! TREE_REGDECL (decl)) | |
308 | error_with_decl (decl, | |
309 | "register name given for non-register variable `%s'"); | |
310 | else if (TREE_REGDECL (decl) && TREE_CODE (decl) == FUNCTION_DECL) | |
311 | error ("function declared `register'"); | |
312 | else if (TREE_REGDECL (decl) && TYPE_MODE (TREE_TYPE (decl)) == BLKmode) | |
313 | error_with_decl (decl, "data type of `%s' isn't suitable for a register"); | |
314 | /* Now handle properly declared static register variables. */ | |
315 | else if (TREE_REGDECL (decl)) | |
316 | { | |
317 | int nregs; | |
318 | #if 0 /* yylex should print the warning for this */ | |
319 | if (pedantic) | |
320 | pedwarn ("ANSI C forbids global register variables"); | |
321 | #endif | |
322 | if (DECL_INITIAL (decl) != 0 && top_level) | |
323 | { | |
324 | DECL_INITIAL (decl) = 0; | |
325 | error ("global register variable has initial value"); | |
326 | } | |
327 | if (fixed_regs[reg_number] == 0 | |
328 | && function_defined && top_level) | |
329 | error ("global register variable follows a function definition"); | |
330 | if (TREE_THIS_VOLATILE (decl)) | |
331 | warning ("volatile register variables don't work as you might wish"); | |
332 | DECL_RTL (decl) = gen_rtx (REG, DECL_MODE (decl), reg_number); | |
333 | REG_USERVAR_P (DECL_RTL (decl)) = 1; | |
334 | ||
335 | if (top_level) | |
336 | { | |
337 | /* Make this register fixed, so not usable for anything else. */ | |
338 | nregs = HARD_REGNO_NREGS (reg_number, DECL_MODE (decl)); | |
339 | while (nregs > 0) | |
340 | global_regs[reg_number + --nregs] = 1; | |
341 | init_reg_sets_1 (); | |
342 | } | |
343 | } | |
344 | ||
345 | /* Now handle ordinary static variables and functions (in memory). | |
346 | Also handle vars declared register invalidly. */ | |
347 | if (DECL_RTL (decl) == 0) | |
348 | { | |
349 | /* Can't use just the variable's own name for a variable | |
350 | whose scope is less than the whole file. | |
351 | Concatenate a distinguishing number. */ | |
352 | if (!top_level && !TREE_EXTERNAL (decl) && asmspec == 0) | |
353 | { | |
354 | char *label; | |
355 | ||
356 | ASM_FORMAT_PRIVATE_NAME (label, name, var_labelno); | |
357 | name = obstack_copy0 (saveable_obstack, label, strlen (label)); | |
358 | var_labelno++; | |
359 | } | |
360 | ||
361 | DECL_RTL (decl) = gen_rtx (MEM, DECL_MODE (decl), | |
362 | gen_rtx (SYMBOL_REF, Pmode, name)); | |
363 | if (TREE_THIS_VOLATILE (decl)) | |
364 | MEM_VOLATILE_P (DECL_RTL (decl)) = 1; | |
365 | if (TREE_READONLY (decl)) | |
366 | RTX_UNCHANGING_P (DECL_RTL (decl)) = 1; | |
367 | MEM_IN_STRUCT_P (DECL_RTL (decl)) | |
368 | = (TREE_CODE (TREE_TYPE (decl)) == ARRAY_TYPE | |
369 | || TREE_CODE (TREE_TYPE (decl)) == RECORD_TYPE | |
370 | || TREE_CODE (TREE_TYPE (decl)) == UNION_TYPE); | |
371 | ||
372 | /* Optionally set flags or add text to the name to record information | |
373 | such as that it is a function name. | |
374 | If the name is changed, the macro ASM_OUTPUT_LABELREF | |
375 | will have to know how to strip this information. | |
376 | And if it finds a * at the beginning after doing so, | |
377 | it must handle that too. */ | |
378 | #ifdef ENCODE_SECTION_INFO | |
379 | ENCODE_SECTION_INFO (decl); | |
380 | #endif | |
381 | } | |
382 | } | |
383 | } | |
384 | \f | |
385 | /* Output a string of literal assembler code | |
386 | for an `asm' keyword used between functions. */ | |
387 | ||
388 | void | |
389 | assemble_asm (string) | |
390 | tree string; | |
391 | { | |
392 | app_enable (); | |
393 | ||
394 | if (TREE_CODE (string) == ADDR_EXPR) | |
395 | string = TREE_OPERAND (string, 0); | |
396 | ||
397 | fprintf (asm_out_file, "\t%s\n", TREE_STRING_POINTER (string)); | |
398 | } | |
399 | ||
400 | /* Tiemann: please get rid of this conditional and put appropriate | |
401 | definitions in each of the files that should have them. | |
402 | The type of debugging format is not the right parameter to | |
403 | control how some other aspect of assembler output is done. */ | |
404 | ||
405 | #if !(defined(DBX_DEBUGGING_INFO) && !defined(FASCIST_ASSEMBLER)) | |
406 | #ifndef ASM_OUTPUT_CONSTRUCTOR | |
407 | #define ASM_OUTPUT_CONSTRUCTOR(file, name) | |
408 | #endif | |
409 | #ifndef ASM_OUTPUT_DESTRUCTOR | |
410 | #define ASM_OUTPUT_DESTRUCTOR(file, name) | |
411 | #endif | |
412 | #endif | |
413 | ||
414 | /* Record an element in the table of global destructors. | |
415 | How this is done depends on what sort of assembler and linker | |
416 | are in use. | |
417 | ||
418 | NAME should be the name of a global function to be called | |
419 | at exit time. This name is output using assemble_name. */ | |
420 | ||
421 | void | |
422 | assemble_destructor (name) | |
423 | char *name; | |
424 | { | |
425 | #ifdef ASM_OUTPUT_DESTRUCTOR | |
426 | ASM_OUTPUT_DESTRUCTOR (asm_out_file, name); | |
427 | #else | |
428 | if (flag_gnu_linker) | |
429 | { | |
430 | /* Now tell GNU LD that this is part of the static destructor set. */ | |
431 | /* This code works for any machine provided you use GNU as/ld. */ | |
432 | fprintf (asm_out_file, "%s \"___DTOR_LIST__\",22,0,0,", ASM_STABS_OP); | |
433 | assemble_name (asm_out_file, name); | |
434 | fputc ('\n', asm_out_file); | |
435 | } | |
436 | #endif | |
437 | } | |
438 | ||
439 | /* Likewise for global constructors. */ | |
440 | ||
441 | void | |
442 | assemble_constructor (name) | |
443 | char *name; | |
444 | { | |
445 | #ifdef ASM_OUTPUT_CONSTRUCTOR | |
446 | ASM_OUTPUT_CONSTRUCTOR (asm_out_file, name); | |
447 | #else | |
448 | if (flag_gnu_linker) | |
449 | { | |
450 | /* Now tell GNU LD that this is part of the static constructor set. */ | |
451 | /* This code works for any machine provided you use GNU as/ld. */ | |
452 | fprintf (asm_out_file, "%s \"___CTOR_LIST__\",22,0,0,", ASM_STABS_OP); | |
453 | assemble_name (asm_out_file, name); | |
454 | fputc ('\n', asm_out_file); | |
455 | } | |
456 | #endif | |
457 | } | |
458 | ||
459 | /* Likewise for entries we want to record for garbage collection. | |
460 | Garbage collection is still under development. */ | |
461 | ||
462 | void | |
463 | assemble_gc_entry (name) | |
464 | char *name; | |
465 | { | |
466 | #ifdef ASM_OUTPUT_GC_ENTRY | |
467 | ASM_OUTPUT_GC_ENTRY (asm_out_file, name); | |
468 | #else | |
469 | if (flag_gnu_linker) | |
470 | { | |
471 | /* Now tell GNU LD that this is part of the static constructor set. */ | |
472 | fprintf (asm_out_file, "%s \"___PTR_LIST__\",22,0,0,", ASM_STABS_OP); | |
473 | assemble_name (asm_out_file, name); | |
474 | fputc ('\n', asm_out_file); | |
475 | } | |
476 | #endif | |
477 | } | |
478 | \f | |
479 | /* Output assembler code for the constant pool of a function and associated | |
480 | with defining the name of the function. DECL describes the function. | |
481 | NAME is the function's name. For the constant pool, we use the current | |
482 | constant pool data. */ | |
483 | ||
484 | void | |
485 | assemble_start_function (decl, fnname) | |
486 | tree decl; | |
487 | char *fnname; | |
488 | { | |
489 | int align; | |
490 | ||
491 | /* The following code does not need preprocessing in the assembler. */ | |
492 | ||
493 | app_disable (); | |
494 | ||
495 | output_constant_pool (fnname, decl); | |
496 | ||
497 | text_section (); | |
498 | ||
499 | ||
500 | /* Tell assembler to move to target machine's alignment for functions. */ | |
501 | align = floor_log2 (FUNCTION_BOUNDARY / BITS_PER_UNIT); | |
502 | if (align > 0) | |
503 | ASM_OUTPUT_ALIGN (asm_out_file, align); | |
504 | ||
505 | #ifdef ASM_OUTPUT_FUNCTION_PREFIX | |
506 | ASM_OUTPUT_FUNCTION_PREFIX (asm_out_file, fnname); | |
507 | #endif | |
508 | ||
509 | #ifdef SDB_DEBUGGING_INFO | |
510 | /* Output SDB definition of the function. */ | |
511 | if (write_symbols == SDB_DEBUG) | |
512 | sdbout_mark_begin_function (); | |
513 | #endif | |
514 | ||
515 | #ifdef DBX_DEBUGGING_INFO | |
e5c90c23 | 516 | /* Output DBX definition of the function. */ |
79e68feb | 517 | if (write_symbols == DBX_DEBUG) |
e5c90c23 | 518 | dbxout_begin_function (decl); |
79e68feb RS |
519 | #endif |
520 | ||
521 | /* Make function name accessible from other files, if appropriate. */ | |
522 | ||
523 | if (TREE_PUBLIC (decl)) | |
524 | { | |
525 | if (!first_global_object_name) | |
526 | first_global_object_name = fnname + (fnname[0] == '*'); | |
527 | ASM_GLOBALIZE_LABEL (asm_out_file, fnname); | |
528 | } | |
529 | ||
530 | /* Do any machine/system dependent processing of the function name */ | |
531 | #ifdef ASM_DECLARE_FUNCTION_NAME | |
532 | ASM_DECLARE_FUNCTION_NAME (asm_out_file, fnname, current_function_decl); | |
533 | #else | |
534 | /* Standard thing is just output label for the function. */ | |
535 | ASM_OUTPUT_LABEL (asm_out_file, fnname); | |
536 | #endif /* ASM_DECLARE_FUNCTION_NAME */ | |
537 | } | |
538 | ||
539 | /* Output assembler code associated with defining the size of the | |
540 | function. DECL describes the function. NAME is the function's name. */ | |
541 | ||
542 | void | |
543 | assemble_end_function (decl, fnname) | |
544 | tree decl; | |
545 | char *fnname; | |
546 | { | |
547 | #ifdef ASM_DECLARE_FUNCTION_SIZE | |
548 | ASM_DECLARE_FUNCTION_SIZE (asm_out_file, fnname, decl); | |
549 | #endif | |
550 | } | |
551 | \f | |
552 | /* Assemble code to leave SIZE bytes of zeros. */ | |
553 | ||
554 | void | |
555 | assemble_zeros (size) | |
556 | int size; | |
557 | { | |
558 | #ifdef ASM_NO_SKIP_IN_TEXT | |
559 | /* The `space' pseudo in the text section outputs nop insns rather than 0s, | |
560 | so we must output 0s explicitly in the text section. */ | |
561 | if (ASM_NO_SKIP_IN_TEXT && in_text_section ()) | |
562 | { | |
563 | int i; | |
564 | ||
565 | for (i = 0; i < size - 20; i += 20) | |
566 | { | |
567 | #ifdef ASM_BYTE_OP | |
568 | fprintf (asm_out_file, | |
569 | "%s 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0\n", ASM_BYTE_OP); | |
570 | #else | |
571 | fprintf (asm_out_file, | |
572 | "\tbyte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0\n"); | |
573 | #endif | |
574 | } | |
575 | if (i < size) | |
576 | { | |
577 | #ifdef ASM_BYTE_OP | |
578 | fprintf (asm_out_file, "%s 0", ASM_BYTE_OP); | |
579 | #else | |
580 | fprintf (asm_out_file, "\tbyte 0"); | |
581 | #endif | |
582 | i++; | |
583 | for (; i < size; i++) | |
584 | fprintf (asm_out_file, ",0"); | |
585 | fprintf (asm_out_file, "\n"); | |
586 | } | |
587 | } | |
588 | else | |
589 | #endif | |
590 | ASM_OUTPUT_SKIP (asm_out_file, size); | |
591 | } | |
592 | ||
593 | /* Assemble a string constant with the specified C string as contents. */ | |
594 | ||
595 | void | |
596 | assemble_string (p, size) | |
597 | unsigned char *p; | |
598 | int size; | |
599 | { | |
600 | register int i; | |
601 | int pos = 0; | |
602 | int maximum = 2000; | |
603 | ||
604 | /* If the string is very long, split it up. */ | |
605 | ||
606 | while (pos < size) | |
607 | { | |
608 | int thissize = size - pos; | |
609 | if (thissize > maximum) | |
610 | thissize = maximum; | |
611 | ||
612 | #ifdef ASM_OUTPUT_ASCII | |
613 | ASM_OUTPUT_ASCII (asm_out_file, p, thissize); | |
614 | #else | |
615 | fprintf (asm_out_file, "\t.ascii \""); | |
616 | ||
617 | for (i = 0; i < thissize; i++) | |
618 | { | |
619 | register int c = p[i]; | |
620 | if (c == '\"' || c == '\\') | |
621 | putc ('\\', asm_out_file); | |
622 | if (c >= ' ' && c < 0177) | |
623 | putc (c, asm_out_file); | |
624 | else | |
625 | { | |
626 | fprintf (asm_out_file, "\\%o", c); | |
627 | /* After an octal-escape, if a digit follows, | |
628 | terminate one string constant and start another. | |
629 | The Vax assembler fails to stop reading the escape | |
630 | after three digits, so this is the only way we | |
631 | can get it to parse the data properly. */ | |
632 | if (i < thissize - 1 | |
633 | && p[i + 1] >= '0' && p[i + 1] <= '9') | |
634 | fprintf (asm_out_file, "\"\n\t.ascii \""); | |
635 | } | |
636 | } | |
637 | fprintf (asm_out_file, "\"\n"); | |
638 | #endif /* no ASM_OUTPUT_ASCII */ | |
639 | ||
640 | pos += thissize; | |
641 | p += thissize; | |
642 | } | |
643 | } | |
644 | \f | |
645 | /* Assemble everything that is needed for a variable or function declaration. | |
646 | Not used for automatic variables, and not used for function definitions. | |
647 | Should not be called for variables of incomplete structure type. | |
648 | ||
649 | TOP_LEVEL is nonzero if this variable has file scope. | |
650 | AT_END is nonzero if this is the special handling, at end of compilation, | |
651 | to define things that have had only tentative definitions. */ | |
652 | ||
653 | void | |
654 | assemble_variable (decl, top_level, at_end) | |
655 | tree decl; | |
656 | int top_level; | |
657 | int at_end; | |
658 | { | |
659 | register char *name; | |
660 | int align; | |
661 | tree size_tree; | |
662 | int reloc = 0; | |
663 | ||
664 | if (GET_CODE (DECL_RTL (decl)) == REG) | |
665 | { | |
666 | /* Do output symbol info for global register variables, but do nothing | |
667 | else for them. */ | |
668 | ||
669 | if (TREE_ASM_WRITTEN (decl)) | |
670 | return; | |
671 | TREE_ASM_WRITTEN (decl) = 1; | |
672 | ||
b4ac57ab | 673 | #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO) |
79e68feb | 674 | /* File-scope global variables are output here. */ |
b4ac57ab RS |
675 | if ((write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG) |
676 | && top_level) | |
79e68feb RS |
677 | dbxout_symbol (decl, 0); |
678 | #endif | |
679 | #ifdef SDB_DEBUGGING_INFO | |
680 | if (write_symbols == SDB_DEBUG && top_level | |
681 | /* Leave initialized global vars for end of compilation; | |
682 | see comment in compile_file. */ | |
683 | && (TREE_PUBLIC (decl) == 0 || DECL_INITIAL (decl) == 0)) | |
684 | sdbout_symbol (decl, 0); | |
685 | #endif | |
686 | ||
687 | /* Don't output any DWARF debugging information for variables here. | |
688 | In the case of local variables, the information for them is output | |
689 | when we do our recursive traversal of the tree representation for | |
690 | the entire containing function. In the case of file-scope variables, | |
691 | we output information for all of them at the very end of compilation | |
692 | while we are doing our final traversal of the chain of file-scope | |
693 | declarations. */ | |
694 | ||
695 | return; | |
696 | } | |
697 | ||
698 | /* Normally no need to say anything for external references, | |
699 | since assembler considers all undefined symbols external. */ | |
700 | ||
701 | if (TREE_EXTERNAL (decl)) | |
702 | return; | |
703 | ||
704 | /* Output no assembler code for a function declaration. | |
705 | Only definitions of functions output anything. */ | |
706 | ||
707 | if (TREE_CODE (decl) == FUNCTION_DECL) | |
708 | return; | |
709 | ||
710 | /* If type was incomplete when the variable was declared, | |
711 | see if it is complete now. */ | |
712 | ||
713 | if (DECL_SIZE (decl) == 0) | |
714 | layout_decl (decl, 0); | |
715 | ||
716 | /* Still incomplete => don't allocate it; treat the tentative defn | |
717 | (which is what it must have been) as an `extern' reference. */ | |
718 | ||
719 | if (DECL_SIZE (decl) == 0) | |
720 | { | |
721 | error_with_file_and_line (DECL_SOURCE_FILE (decl), | |
722 | DECL_SOURCE_LINE (decl), | |
723 | "storage size of static var `%s' isn't known", | |
724 | IDENTIFIER_POINTER (DECL_NAME (decl))); | |
725 | return; | |
726 | } | |
727 | ||
728 | /* The first declaration of a variable that comes through this function | |
729 | decides whether it is global (in C, has external linkage) | |
730 | or local (in C, has internal linkage). So do nothing more | |
731 | if this function has already run. */ | |
732 | ||
733 | if (TREE_ASM_WRITTEN (decl)) | |
734 | return; | |
735 | ||
736 | TREE_ASM_WRITTEN (decl) = 1; | |
737 | ||
738 | #ifdef DBX_DEBUGGING_INFO | |
739 | /* File-scope global variables are output here. */ | |
740 | if (write_symbols == DBX_DEBUG && top_level) | |
741 | dbxout_symbol (decl, 0); | |
742 | #endif | |
743 | #ifdef SDB_DEBUGGING_INFO | |
744 | if (write_symbols == SDB_DEBUG && top_level | |
745 | /* Leave initialized global vars for end of compilation; | |
746 | see comment in compile_file. */ | |
747 | && (TREE_PUBLIC (decl) == 0 || DECL_INITIAL (decl) == 0)) | |
748 | sdbout_symbol (decl, 0); | |
749 | #endif | |
750 | ||
751 | /* Don't output any DWARF debugging information for variables here. | |
752 | In the case of local variables, the information for them is output | |
753 | when we do our recursive traversal of the tree representation for | |
754 | the entire containing function. In the case of file-scope variables, | |
755 | we output information for all of them at the very end of compilation | |
756 | while we are doing our final traversal of the chain of file-scope | |
757 | declarations. */ | |
758 | ||
759 | /* If storage size is erroneously variable, just continue. | |
760 | Error message was already made. */ | |
761 | ||
762 | if (TREE_CODE (DECL_SIZE (decl)) != INTEGER_CST) | |
b4ac57ab | 763 | goto finish; |
79e68feb RS |
764 | |
765 | app_disable (); | |
766 | ||
767 | /* This is better than explicit arithmetic, since it avoids overflow. */ | |
768 | size_tree = size_binop (CEIL_DIV_EXPR, | |
769 | DECL_SIZE (decl), size_int (BITS_PER_UNIT)); | |
770 | ||
771 | if (TREE_INT_CST_HIGH (size_tree) != 0) | |
772 | { | |
773 | error_with_decl (decl, "size of variable `%s' is too large"); | |
b4ac57ab | 774 | goto finish; |
79e68feb RS |
775 | } |
776 | ||
777 | name = XSTR (XEXP (DECL_RTL (decl), 0), 0); | |
778 | ||
779 | /* Handle uninitialized definitions. */ | |
780 | ||
781 | /* ANSI specifies that a tentative definition which is not merged with | |
782 | a non-tentative definition behaves exactly like a definition with an | |
783 | initializer equal to zero. (Section 3.7.2) | |
784 | -fno-common gives strict ANSI behavior. Usually you don't want it. */ | |
785 | if (! flag_no_common | |
786 | && (DECL_INITIAL (decl) == 0 || DECL_INITIAL (decl) == error_mark_node)) | |
787 | { | |
788 | int size = TREE_INT_CST_LOW (size_tree); | |
789 | int rounded = size; | |
790 | ||
791 | if (TREE_INT_CST_HIGH (size_tree) != 0) | |
792 | error_with_decl (decl, "size of variable `%s' is too large"); | |
793 | /* Don't allocate zero bytes of common, | |
794 | since that means "undefined external" in the linker. */ | |
795 | if (size == 0) rounded = 1; | |
796 | /* Round size up to multiple of BIGGEST_ALIGNMENT bits | |
797 | so that each uninitialized object starts on such a boundary. */ | |
798 | rounded += (BIGGEST_ALIGNMENT / BITS_PER_UNIT) - 1; | |
799 | rounded = (rounded / (BIGGEST_ALIGNMENT / BITS_PER_UNIT) | |
800 | * (BIGGEST_ALIGNMENT / BITS_PER_UNIT)); | |
801 | #if 0 | |
802 | if (flag_shared_data) | |
803 | data_section (); | |
804 | #endif | |
805 | if (TREE_PUBLIC (decl)) | |
806 | { | |
807 | #ifdef ASM_OUTPUT_SHARED_COMMON | |
808 | if (flag_shared_data) | |
809 | ASM_OUTPUT_SHARED_COMMON (asm_out_file, name, size, rounded); | |
810 | else | |
811 | #endif | |
812 | #ifdef ASM_OUTPUT_ALIGNED_COMMON | |
813 | ASM_OUTPUT_ALIGNED_COMMON (asm_out_file, name, size, | |
814 | DECL_ALIGN (decl)); | |
815 | #else | |
816 | ASM_OUTPUT_COMMON (asm_out_file, name, size, rounded); | |
817 | #endif | |
818 | } | |
819 | else | |
820 | { | |
821 | #ifdef ASM_OUTPUT_SHARED_LOCAL | |
822 | if (flag_shared_data) | |
823 | ASM_OUTPUT_SHARED_LOCAL (asm_out_file, name, size, rounded); | |
824 | else | |
825 | #endif | |
826 | #ifdef ASM_OUTPUT_ALIGNED_LOCAL | |
827 | ASM_OUTPUT_ALIGNED_LOCAL (asm_out_file, name, size, | |
828 | DECL_ALIGN (decl)); | |
829 | #else | |
830 | ASM_OUTPUT_LOCAL (asm_out_file, name, size, rounded); | |
831 | #endif | |
832 | } | |
b4ac57ab | 833 | goto finish; |
79e68feb RS |
834 | } |
835 | ||
836 | /* Handle initialized definitions. */ | |
837 | ||
838 | /* First make the assembler name(s) global if appropriate. */ | |
839 | if (TREE_PUBLIC (decl) && DECL_NAME (decl)) | |
840 | { | |
841 | if (!first_global_object_name) | |
842 | first_global_object_name = name + (name[0] == '*'); | |
843 | ASM_GLOBALIZE_LABEL (asm_out_file, name); | |
844 | } | |
845 | #if 0 | |
846 | for (d = equivalents; d; d = TREE_CHAIN (d)) | |
847 | { | |
848 | tree e = TREE_VALUE (d); | |
849 | if (TREE_PUBLIC (e) && DECL_NAME (e)) | |
850 | ASM_GLOBALIZE_LABEL (asm_out_file, | |
851 | XSTR (XEXP (DECL_RTL (e), 0), 0)); | |
852 | } | |
853 | #endif | |
854 | ||
855 | /* Output any data that we will need to use the address of. */ | |
856 | if (DECL_INITIAL (decl)) | |
857 | reloc = output_addressed_constants (DECL_INITIAL (decl)); | |
858 | ||
859 | /* Switch to the proper section for this data. */ | |
860 | #ifdef SELECT_SECTION | |
861 | SELECT_SECTION (decl, reloc); | |
862 | #else | |
863 | if (TREE_READONLY (decl) | |
864 | && ! TREE_THIS_VOLATILE (decl) | |
865 | && ! (flag_pic && reloc)) | |
866 | readonly_data_section (); | |
867 | else | |
868 | data_section (); | |
869 | #endif | |
870 | ||
871 | /* Compute and output the alignment of this data. */ | |
872 | ||
873 | align = DECL_ALIGN (decl); | |
874 | /* Some object file formats have a maximum alignment which they support. | |
875 | In particular, a.out format supports a maximum alignment of 4. */ | |
876 | #ifndef MAX_OFILE_ALIGNMENT | |
877 | #define MAX_OFILE_ALIGNMENT BIGGEST_ALIGNMENT | |
878 | #endif | |
879 | if (align > MAX_OFILE_ALIGNMENT) | |
880 | { | |
881 | warning_with_decl (decl, | |
882 | "alignment of `%s' is greater than maximum object file alignment"); | |
883 | align = MAX_OFILE_ALIGNMENT; | |
884 | } | |
885 | #ifdef DATA_ALIGNMENT | |
886 | /* On some machines, it is good to increase alignment sometimes. */ | |
887 | align = DATA_ALIGNMENT (TREE_TYPE (decl), align); | |
888 | #endif | |
889 | #ifdef CONSTANT_ALIGNMENT | |
890 | if (DECL_INITIAL (decl)) | |
891 | align = CONSTANT_ALIGNMENT (DECL_INITIAL (decl), align); | |
892 | #endif | |
893 | ||
894 | /* Reset the alignment in case we have made it tighter, so we can benefit | |
895 | from it in get_pointer_alignment. */ | |
896 | DECL_ALIGN (decl) = align; | |
897 | ||
898 | if (align > BITS_PER_UNIT) | |
899 | ASM_OUTPUT_ALIGN (asm_out_file, floor_log2 (align / BITS_PER_UNIT)); | |
900 | ||
901 | /* Do any machine/system dependent processing of the object. */ | |
902 | #ifdef ASM_DECLARE_OBJECT_NAME | |
903 | ASM_DECLARE_OBJECT_NAME (asm_out_file, name, decl); | |
904 | #else | |
905 | /* Standard thing is just output label for the object. */ | |
906 | ASM_OUTPUT_LABEL (asm_out_file, name); | |
907 | #endif /* ASM_DECLARE_OBJECT_NAME */ | |
908 | ||
909 | #if 0 | |
910 | for (d = equivalents; d; d = TREE_CHAIN (d)) | |
911 | { | |
912 | tree e = TREE_VALUE (d); | |
913 | ASM_OUTPUT_LABEL (asm_out_file, XSTR (XEXP (DECL_RTL (e), 0), 0)); | |
914 | } | |
915 | #endif | |
916 | ||
917 | if (DECL_INITIAL (decl)) | |
918 | /* Output the actual data. */ | |
919 | output_constant (DECL_INITIAL (decl), | |
920 | int_size_in_bytes (TREE_TYPE (decl))); | |
921 | else | |
922 | /* Leave space for it. */ | |
923 | assemble_zeros (int_size_in_bytes (TREE_TYPE (decl))); | |
b4ac57ab RS |
924 | |
925 | finish: | |
926 | #ifdef XCOFF_DEBUGGING_INFO | |
927 | /* Unfortunately, the IBM assembler cannot handle stabx before the actual | |
928 | declaration. When something like ".stabx "aa:S-2",aa,133,0" is emitted | |
929 | and `aa' hasn't been output yet, the assembler generates a stab entry with | |
930 | a value of zero, in addition to creating an unnecessary external entry | |
931 | for `aa'. Hence, we must pospone dbxout_symbol to here at the end. */ | |
932 | ||
933 | /* File-scope global variables are output here. */ | |
934 | if (write_symbols == XCOFF_DEBUG && top_level) | |
935 | dbxout_symbol (decl, 0); | |
936 | #else | |
937 | /* There must be a statement after a label. */ | |
938 | ; | |
939 | #endif | |
79e68feb RS |
940 | } |
941 | ||
942 | /* Output something to declare an external symbol to the assembler. | |
fff9e713 MT |
943 | (Most assemblers don't need this, so we normally output nothing.) |
944 | Do nothing if DECL is not external. */ | |
79e68feb RS |
945 | |
946 | void | |
947 | assemble_external (decl) | |
948 | tree decl; | |
949 | { | |
79e68feb | 950 | #ifdef ASM_OUTPUT_EXTERNAL |
fff9e713 MT |
951 | if (TREE_CODE_CLASS (TREE_CODE (decl)) == 'd' |
952 | && TREE_EXTERNAL (decl) && TREE_PUBLIC (decl)) | |
79e68feb | 953 | { |
fff9e713 MT |
954 | rtx rtl = DECL_RTL (decl); |
955 | ||
956 | if (GET_CODE (rtl) == MEM && GET_CODE (XEXP (rtl, 0)) == SYMBOL_REF | |
957 | && ! SYMBOL_REF_USED (XEXP (rtl, 0))) | |
958 | { | |
959 | /* Some systems do require some output. */ | |
960 | SYMBOL_REF_USED (XEXP (rtl, 0)) = 1; | |
961 | ASM_OUTPUT_EXTERNAL (asm_out_file, decl, XSTR (XEXP (rtl, 0), 0)); | |
962 | } | |
79e68feb RS |
963 | } |
964 | #endif | |
965 | } | |
966 | ||
967 | /* Similar, for calling a library function FUN. */ | |
968 | ||
969 | void | |
970 | assemble_external_libcall (fun) | |
971 | rtx fun; | |
972 | { | |
973 | #ifdef ASM_OUTPUT_EXTERNAL_LIBCALL | |
974 | /* Declare library function name external when first used, if nec. */ | |
975 | if (! SYMBOL_REF_USED (fun)) | |
976 | { | |
977 | SYMBOL_REF_USED (fun) = 1; | |
978 | ASM_OUTPUT_EXTERNAL_LIBCALL (asm_out_file, fun); | |
979 | } | |
980 | #endif | |
981 | } | |
982 | ||
983 | /* Declare the label NAME global. */ | |
984 | ||
985 | void | |
986 | assemble_global (name) | |
987 | char *name; | |
988 | { | |
989 | ASM_GLOBALIZE_LABEL (asm_out_file, name); | |
990 | } | |
991 | ||
992 | /* Assemble a label named NAME. */ | |
993 | ||
994 | void | |
995 | assemble_label (name) | |
996 | char *name; | |
997 | { | |
998 | ASM_OUTPUT_LABEL (asm_out_file, name); | |
999 | } | |
1000 | ||
1001 | /* Output to FILE a reference to the assembler name of a C-level name NAME. | |
1002 | If NAME starts with a *, the rest of NAME is output verbatim. | |
1003 | Otherwise NAME is transformed in an implementation-defined way | |
1004 | (usually by the addition of an underscore). | |
1005 | Many macros in the tm file are defined to call this function. */ | |
1006 | ||
1007 | void | |
1008 | assemble_name (file, name) | |
1009 | FILE *file; | |
1010 | char *name; | |
1011 | { | |
1012 | if (name[0] == '*') | |
1013 | fputs (&name[1], file); | |
1014 | else | |
1015 | ASM_OUTPUT_LABELREF (file, name); | |
1016 | } | |
1017 | ||
1018 | /* Allocate SIZE bytes writable static space with a gensym name | |
1019 | and return an RTX to refer to its address. */ | |
1020 | ||
1021 | rtx | |
1022 | assemble_static_space (size) | |
1023 | int size; | |
1024 | { | |
1025 | char name[12]; | |
1026 | char *namestring; | |
1027 | rtx x; | |
1028 | /* Round size up to multiple of BIGGEST_ALIGNMENT bits | |
1029 | so that each uninitialized object starts on such a boundary. */ | |
1030 | int rounded = ((size + (BIGGEST_ALIGNMENT / BITS_PER_UNIT) - 1) | |
1031 | / (BIGGEST_ALIGNMENT / BITS_PER_UNIT) | |
1032 | * (BIGGEST_ALIGNMENT / BITS_PER_UNIT)); | |
1033 | ||
1034 | #if 0 | |
1035 | if (flag_shared_data) | |
1036 | data_section (); | |
1037 | #endif | |
1038 | ||
1039 | ASM_GENERATE_INTERNAL_LABEL (name, "LF", const_labelno); | |
1040 | ++const_labelno; | |
1041 | ||
1042 | namestring = (char *) obstack_alloc (saveable_obstack, | |
1043 | strlen (name) + 2); | |
1044 | strcpy (namestring, name); | |
1045 | ||
1046 | x = gen_rtx (SYMBOL_REF, Pmode, namestring); | |
1047 | #ifdef ASM_OUTPUT_ALIGNED_LOCAL | |
1048 | ASM_OUTPUT_ALIGNED_LOCAL (asm_out_file, name, size, BIGGEST_ALIGNMENT); | |
1049 | #else | |
1050 | ASM_OUTPUT_LOCAL (asm_out_file, name, size, rounded); | |
1051 | #endif | |
1052 | return x; | |
1053 | } | |
1054 | ||
1055 | /* Assemble the static constant template for function entry trampolines. | |
1056 | This is done at most once per compilation. | |
1057 | Returns an RTX for the address of the template. */ | |
1058 | ||
1059 | rtx | |
1060 | assemble_trampoline_template () | |
1061 | { | |
1062 | char label[256]; | |
1063 | char *name; | |
1064 | int align; | |
1065 | ||
1066 | /* Write the assembler code to define one. */ | |
1067 | align = floor_log2 (FUNCTION_BOUNDARY / BITS_PER_UNIT); | |
1068 | if (align > 0) | |
1069 | ASM_OUTPUT_ALIGN (asm_out_file, align); | |
1070 | ||
1071 | ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "LTRAMP", 0); | |
1072 | TRAMPOLINE_TEMPLATE (asm_out_file); | |
1073 | ||
1074 | /* Record the rtl to refer to it. */ | |
1075 | ASM_GENERATE_INTERNAL_LABEL (label, "LTRAMP", 0); | |
1076 | name | |
1077 | = (char *) obstack_copy0 (&permanent_obstack, label, strlen (label)); | |
1078 | return gen_rtx (SYMBOL_REF, Pmode, name); | |
1079 | } | |
1080 | \f | |
1081 | /* Assemble the integer constant X into an object of SIZE bytes. | |
1082 | X must be either a CONST_INT or CONST_DOUBLE. | |
1083 | ||
1084 | Return 1 if we were able to output the constant, otherwise 0. If FORCE is | |
1085 | non-zero, abort if we can't output the constant. */ | |
1086 | ||
1087 | int | |
1088 | assemble_integer (x, size, force) | |
1089 | rtx x; | |
1090 | int size; | |
1091 | int force; | |
1092 | { | |
1093 | /* First try to use the standard 1, 2, 4, 8, and 16 byte | |
1094 | ASM_OUTPUT... macros. */ | |
1095 | ||
1096 | switch (size) | |
1097 | { | |
1098 | #ifdef ASM_OUTPUT_CHAR | |
1099 | case 1: | |
1100 | ASM_OUTPUT_CHAR (asm_out_file, x); | |
1101 | return 1; | |
1102 | #endif | |
1103 | ||
1104 | #ifdef ASM_OUTPUT_SHORT | |
1105 | case 2: | |
1106 | ASM_OUTPUT_SHORT (asm_out_file, x); | |
1107 | return 1; | |
1108 | #endif | |
1109 | ||
1110 | #ifdef ASM_OUTPUT_INT | |
1111 | case 4: | |
1112 | ASM_OUTPUT_INT (asm_out_file, x); | |
1113 | return 1; | |
1114 | #endif | |
1115 | ||
1116 | #ifdef ASM_OUTPUT_DOUBLE_INT | |
1117 | case 8: | |
1118 | ASM_OUTPUT_DOUBLE_INT (asm_out_file, x); | |
1119 | return 1; | |
1120 | #endif | |
1121 | ||
1122 | #ifdef ASM_OUTPUT_QUADRUPLE_INT | |
1123 | case 16: | |
1124 | ASM_OUTPUT_QUADRUPLE_INT (asm_out_file, x); | |
1125 | return 1; | |
1126 | #endif | |
1127 | } | |
1128 | ||
1129 | /* If we couldn't do it that way, there are two other possibilities: First, | |
1130 | if the machine can output an explicit byte and this is a 1 byte constant, | |
1131 | we can use ASM_OUTPUT_BYTE. */ | |
1132 | ||
1133 | #ifdef ASM_OUTPUT_BYTE | |
1134 | if (size == 1 && GET_CODE (x) == CONST_INT) | |
1135 | { | |
1136 | ASM_OUTPUT_BYTE (asm_out_file, INTVAL (x)); | |
1137 | return 1; | |
1138 | } | |
1139 | #endif | |
1140 | ||
1141 | /* Finally, if SIZE is larger than a single word, try to output the constant | |
1142 | one word at a time. */ | |
1143 | ||
1144 | if (size > UNITS_PER_WORD) | |
1145 | { | |
1146 | int i; | |
1147 | enum machine_mode mode | |
1148 | = mode_for_size (size * BITS_PER_UNIT, MODE_INT, 0); | |
1149 | rtx word; | |
1150 | ||
1151 | for (i = 0; i < size / UNITS_PER_WORD; i++) | |
1152 | { | |
1153 | word = operand_subword (x, i, 0, mode); | |
1154 | ||
1155 | if (word == 0) | |
1156 | break; | |
1157 | ||
fff9e713 MT |
1158 | if (! assemble_integer (word, UNITS_PER_WORD, 0)) |
1159 | break; | |
79e68feb RS |
1160 | } |
1161 | ||
1162 | if (i == size / UNITS_PER_WORD) | |
1163 | return 1; | |
fff9e713 MT |
1164 | /* If we output at least one word and then could not finish, |
1165 | there is no valid way to continue. */ | |
1166 | if (i > 0) | |
1167 | abort (); | |
79e68feb RS |
1168 | } |
1169 | ||
1170 | if (force) | |
1171 | abort (); | |
1172 | ||
1173 | return 0; | |
1174 | } | |
1175 | \f | |
1176 | /* Assemble the floating-point constant D into an object of size MODE. */ | |
1177 | ||
1178 | void | |
1179 | assemble_real (d, mode) | |
1180 | REAL_VALUE_TYPE d; | |
1181 | enum machine_mode mode; | |
1182 | { | |
1183 | jmp_buf output_constant_handler; | |
1184 | ||
1185 | if (setjmp (output_constant_handler)) | |
1186 | { | |
1187 | error ("floating point trap outputting a constant"); | |
1188 | #ifdef REAL_IS_NOT_DOUBLE | |
1189 | bzero (&d, sizeof d); | |
1190 | d = dconst0; | |
1191 | #else | |
1192 | d = 0; | |
1193 | #endif | |
1194 | } | |
1195 | ||
1196 | set_float_handler (output_constant_handler); | |
1197 | ||
1198 | switch (mode) | |
1199 | { | |
1200 | #ifdef ASM_OUTPUT_FLOAT | |
1201 | case SFmode: | |
1202 | ASM_OUTPUT_FLOAT (asm_out_file, d); | |
1203 | break; | |
1204 | #endif | |
1205 | ||
1206 | #ifdef ASM_OUTPUT_DOUBLE | |
1207 | case DFmode: | |
1208 | ASM_OUTPUT_DOUBLE (asm_out_file, d); | |
1209 | break; | |
1210 | #endif | |
1211 | ||
1212 | #ifdef ASM_OUTPUT_LONG_DOUBLE | |
1213 | case TFmode: | |
1214 | ASM_OUTPUT_LONG_DOUBLE (asm_out_file, d); | |
1215 | break; | |
1216 | #endif | |
1217 | ||
1218 | default: | |
1219 | abort (); | |
1220 | } | |
1221 | ||
1222 | set_float_handler (0); | |
1223 | } | |
1224 | \f | |
1225 | /* Here we combine duplicate floating constants to make | |
1226 | CONST_DOUBLE rtx's, and force those out to memory when necessary. */ | |
1227 | ||
1228 | /* Chain of all CONST_DOUBLE rtx's constructed for the current function. | |
1229 | They are chained through the CONST_DOUBLE_CHAIN. | |
1230 | A CONST_DOUBLE rtx has CONST_DOUBLE_MEM != cc0_rtx iff it is on this chain. | |
1231 | In that case, CONST_DOUBLE_MEM is either a MEM, | |
1232 | or const0_rtx if no MEM has been made for this CONST_DOUBLE yet. */ | |
1233 | ||
1234 | static rtx const_double_chain; | |
1235 | ||
1236 | /* Return a CONST_DOUBLE for a value specified as a pair of ints. | |
1237 | For an integer, I0 is the low-order word and I1 is the high-order word. | |
1238 | For a real number, I0 is the word with the low address | |
1239 | and I1 is the word with the high address. */ | |
1240 | ||
1241 | rtx | |
1242 | immed_double_const (i0, i1, mode) | |
1243 | int i0, i1; | |
1244 | enum machine_mode mode; | |
1245 | { | |
1246 | register rtx r; | |
1247 | int in_current_obstack; | |
1248 | ||
1249 | if (GET_MODE_CLASS (mode) == MODE_INT) | |
1250 | { | |
1251 | /* We clear out all bits that don't belong in MODE, unless they and our | |
1252 | sign bit are all one. So we get either a reasonable negative value | |
1253 | or a reasonable unsigned value for this mode. */ | |
1254 | int width = GET_MODE_BITSIZE (mode); | |
1255 | if (width < HOST_BITS_PER_INT | |
1256 | && ((i0 & ((-1) << (width - 1))) != ((-1) << (width - 1)))) | |
1257 | i0 &= (1 << width) - 1, i1 = 0; | |
1258 | else if (width == HOST_BITS_PER_INT | |
1259 | && ! (i1 == ~0 && i0 < 0)) | |
1260 | i1 = 0; | |
1261 | else if (width > 2 * HOST_BITS_PER_INT) | |
1262 | /* We cannot represent this value as a constant. */ | |
1263 | abort (); | |
1264 | ||
1265 | /* If MODE fits within HOST_BITS_PER_INT, always use a CONST_INT. | |
1266 | ||
1267 | ??? Strictly speaking, this is wrong if we create a CONST_INT | |
1268 | for a large unsigned constant with the size of MODE being | |
1269 | HOST_BITS_PER_INT and later try to interpret that constant in a wider | |
1270 | mode. In that case we will mis-interpret it as a negative number. | |
1271 | ||
1272 | Unfortunately, the only alternative is to make a CONST_DOUBLE | |
1273 | for any constant in any mode if it is an unsigned constant larger | |
1274 | than the maximum signed integer in an int on the host. However, | |
1275 | doing this will break everyone that always expects to see a CONST_INT | |
1276 | for SImode and smaller. | |
1277 | ||
1278 | We have always been making CONST_INTs in this case, so nothing new | |
1279 | is being broken. */ | |
1280 | ||
1281 | if (width <= HOST_BITS_PER_INT) | |
1282 | i1 = (i0 < 0) ? ~0 : 0; | |
1283 | ||
1284 | /* If this integer fits in one word, return a CONST_INT. */ | |
1285 | if ((i1 == 0 && i0 >= 0) | |
1286 | || (i1 == ~0 && i0 < 0)) | |
1287 | return gen_rtx (CONST_INT, VOIDmode, i0); | |
1288 | ||
1289 | /* We use VOIDmode for integers. */ | |
1290 | mode = VOIDmode; | |
1291 | } | |
1292 | ||
1293 | /* Search the chain for an existing CONST_DOUBLE with the right value. | |
1294 | If one is found, return it. */ | |
1295 | ||
1296 | for (r = const_double_chain; r; r = CONST_DOUBLE_CHAIN (r)) | |
1297 | if (CONST_DOUBLE_LOW (r) == i0 && CONST_DOUBLE_HIGH (r) == i1 | |
1298 | && GET_MODE (r) == mode) | |
1299 | return r; | |
1300 | ||
1301 | /* No; make a new one and add it to the chain. | |
1302 | ||
1303 | We may be called by an optimizer which may be discarding any memory | |
1304 | allocated during its processing (such as combine and loop). However, | |
1305 | we will be leaving this constant on the chain, so we cannot tolerate | |
1306 | freed memory. So switch to saveable_obstack for this allocation | |
1307 | and then switch back if we were in current_obstack. */ | |
1308 | ||
1309 | in_current_obstack = rtl_in_saveable_obstack (); | |
1310 | r = gen_rtx (CONST_DOUBLE, mode, 0, i0, i1); | |
1311 | if (in_current_obstack) | |
1312 | rtl_in_current_obstack (); | |
1313 | ||
1314 | CONST_DOUBLE_CHAIN (r) = const_double_chain; | |
1315 | const_double_chain = r; | |
1316 | ||
1317 | /* Store const0_rtx in mem-slot since this CONST_DOUBLE is on the chain. | |
1318 | Actual use of mem-slot is only through force_const_mem. */ | |
1319 | ||
1320 | CONST_DOUBLE_MEM (r) = const0_rtx; | |
1321 | ||
1322 | return r; | |
1323 | } | |
1324 | ||
1325 | /* Return a CONST_DOUBLE for a specified `double' value | |
1326 | and machine mode. */ | |
1327 | ||
1328 | rtx | |
1329 | immed_real_const_1 (d, mode) | |
1330 | REAL_VALUE_TYPE d; | |
1331 | enum machine_mode mode; | |
1332 | { | |
1333 | union real_extract u; | |
1334 | register rtx r; | |
1335 | int in_current_obstack; | |
1336 | ||
1337 | /* Get the desired `double' value as a sequence of ints | |
1338 | since that is how they are stored in a CONST_DOUBLE. */ | |
1339 | ||
1340 | u.d = d; | |
1341 | ||
1342 | /* Detect special cases. */ | |
1343 | ||
1344 | if (REAL_VALUES_EQUAL (dconst0, d)) | |
1345 | return CONST0_RTX (mode); | |
1346 | else if (REAL_VALUES_EQUAL (dconst1, d)) | |
1347 | return CONST1_RTX (mode); | |
1348 | ||
1349 | if (sizeof u == 2 * sizeof (int)) | |
1350 | return immed_double_const (u.i[0], u.i[1], mode); | |
1351 | ||
1352 | /* The rest of this function handles the case where | |
1353 | a float value requires more than 2 ints of space. | |
1354 | It will be deleted as dead code on machines that don't need it. */ | |
1355 | ||
1356 | /* Search the chain for an existing CONST_DOUBLE with the right value. | |
1357 | If one is found, return it. */ | |
1358 | ||
1359 | for (r = const_double_chain; r; r = CONST_DOUBLE_CHAIN (r)) | |
1360 | if (! bcmp (&CONST_DOUBLE_LOW (r), &u, sizeof u) | |
1361 | && GET_MODE (r) == mode) | |
1362 | return r; | |
1363 | ||
1364 | /* No; make a new one and add it to the chain. | |
1365 | ||
1366 | We may be called by an optimizer which may be discarding any memory | |
1367 | allocated during its processing (such as combine and loop). However, | |
1368 | we will be leaving this constant on the chain, so we cannot tolerate | |
1369 | freed memory. So switch to saveable_obstack for this allocation | |
1370 | and then switch back if we were in current_obstack. */ | |
1371 | ||
1372 | in_current_obstack = rtl_in_saveable_obstack (); | |
1373 | r = rtx_alloc (CONST_DOUBLE); | |
1374 | PUT_MODE (r, mode); | |
1375 | bcopy (&u, &CONST_DOUBLE_LOW (r), sizeof u); | |
1376 | if (in_current_obstack) | |
1377 | rtl_in_current_obstack (); | |
1378 | ||
1379 | CONST_DOUBLE_CHAIN (r) = const_double_chain; | |
1380 | const_double_chain = r; | |
1381 | ||
1382 | /* Store const0_rtx in CONST_DOUBLE_MEM since this CONST_DOUBLE is on the | |
1383 | chain, but has not been allocated memory. Actual use of CONST_DOUBLE_MEM | |
1384 | is only through force_const_mem. */ | |
1385 | ||
1386 | CONST_DOUBLE_MEM (r) = const0_rtx; | |
1387 | ||
1388 | return r; | |
1389 | } | |
1390 | ||
1391 | /* Return a CONST_DOUBLE rtx for a value specified by EXP, | |
1392 | which must be a REAL_CST tree node. */ | |
1393 | ||
1394 | rtx | |
1395 | immed_real_const (exp) | |
1396 | tree exp; | |
1397 | { | |
1398 | return immed_real_const_1 (TREE_REAL_CST (exp), TYPE_MODE (TREE_TYPE (exp))); | |
1399 | } | |
1400 | ||
1401 | /* At the end of a function, forget the memory-constants | |
1402 | previously made for CONST_DOUBLEs. Mark them as not on real_constant_chain. | |
1403 | Also clear out real_constant_chain and clear out all the chain-pointers. */ | |
1404 | ||
1405 | void | |
1406 | clear_const_double_mem () | |
1407 | { | |
1408 | register rtx r, next; | |
1409 | ||
1410 | for (r = const_double_chain; r; r = next) | |
1411 | { | |
1412 | next = CONST_DOUBLE_CHAIN (r); | |
1413 | CONST_DOUBLE_CHAIN (r) = 0; | |
1414 | CONST_DOUBLE_MEM (r) = cc0_rtx; | |
1415 | } | |
1416 | const_double_chain = 0; | |
1417 | } | |
1418 | \f | |
1419 | /* Given an expression EXP with a constant value, | |
1420 | reduce it to the sum of an assembler symbol and an integer. | |
1421 | Store them both in the structure *VALUE. | |
1422 | Abort if EXP does not reduce. */ | |
1423 | ||
1424 | struct addr_const | |
1425 | { | |
1426 | rtx base; | |
1427 | int offset; | |
1428 | }; | |
1429 | ||
1430 | static void | |
1431 | decode_addr_const (exp, value) | |
1432 | tree exp; | |
1433 | struct addr_const *value; | |
1434 | { | |
1435 | register tree target = TREE_OPERAND (exp, 0); | |
1436 | register int offset = 0; | |
1437 | register rtx x; | |
1438 | ||
1439 | while (1) | |
1440 | { | |
1441 | if (TREE_CODE (target) == COMPONENT_REF | |
1442 | && (TREE_CODE (DECL_FIELD_BITPOS (TREE_OPERAND (target, 1))) | |
1443 | == INTEGER_CST)) | |
1444 | { | |
1445 | offset += TREE_INT_CST_LOW (DECL_FIELD_BITPOS (TREE_OPERAND (target, 1))) / BITS_PER_UNIT; | |
1446 | target = TREE_OPERAND (target, 0); | |
1447 | } | |
1448 | else if (TREE_CODE (target) == ARRAY_REF) | |
1449 | { | |
1450 | if (TREE_CODE (TREE_OPERAND (target, 1)) != INTEGER_CST | |
1451 | || TREE_CODE (TYPE_SIZE (TREE_TYPE (target))) != INTEGER_CST) | |
1452 | abort (); | |
1453 | offset += ((TREE_INT_CST_LOW (TYPE_SIZE (TREE_TYPE (target))) | |
1454 | * TREE_INT_CST_LOW (TREE_OPERAND (target, 1))) | |
1455 | / BITS_PER_UNIT); | |
1456 | target = TREE_OPERAND (target, 0); | |
1457 | } | |
1458 | else | |
1459 | break; | |
1460 | } | |
1461 | ||
1462 | switch (TREE_CODE (target)) | |
1463 | { | |
1464 | case VAR_DECL: | |
1465 | case FUNCTION_DECL: | |
1466 | x = DECL_RTL (target); | |
1467 | break; | |
1468 | ||
1469 | case LABEL_DECL: | |
1470 | x = gen_rtx (MEM, FUNCTION_MODE, | |
1471 | gen_rtx (LABEL_REF, VOIDmode, | |
1472 | label_rtx (TREE_OPERAND (exp, 0)))); | |
1473 | break; | |
1474 | ||
1475 | case REAL_CST: | |
1476 | case STRING_CST: | |
1477 | case COMPLEX_CST: | |
1478 | case CONSTRUCTOR: | |
1479 | x = TREE_CST_RTL (target); | |
1480 | break; | |
1481 | ||
1482 | default: | |
1483 | abort (); | |
1484 | } | |
1485 | ||
1486 | if (GET_CODE (x) != MEM) | |
1487 | abort (); | |
1488 | x = XEXP (x, 0); | |
1489 | ||
1490 | value->base = x; | |
1491 | value->offset = offset; | |
1492 | } | |
1493 | \f | |
1494 | /* Uniquize all constants that appear in memory. | |
1495 | Each constant in memory thus far output is recorded | |
1496 | in `const_hash_table' with a `struct constant_descriptor' | |
1497 | that contains a polish representation of the value of | |
1498 | the constant. | |
1499 | ||
1500 | We cannot store the trees in the hash table | |
1501 | because the trees may be temporary. */ | |
1502 | ||
1503 | struct constant_descriptor | |
1504 | { | |
1505 | struct constant_descriptor *next; | |
1506 | char *label; | |
1507 | char contents[1]; | |
1508 | }; | |
1509 | ||
1510 | #define HASHBITS 30 | |
1511 | #define MAX_HASH_TABLE 1009 | |
1512 | static struct constant_descriptor *const_hash_table[MAX_HASH_TABLE]; | |
1513 | ||
1514 | /* Compute a hash code for a constant expression. */ | |
1515 | ||
1516 | int | |
1517 | const_hash (exp) | |
1518 | tree exp; | |
1519 | { | |
1520 | register char *p; | |
1521 | register int len, hi, i; | |
1522 | register enum tree_code code = TREE_CODE (exp); | |
1523 | ||
1524 | if (code == INTEGER_CST) | |
1525 | { | |
1526 | p = (char *) &TREE_INT_CST_LOW (exp); | |
1527 | len = 2 * sizeof TREE_INT_CST_LOW (exp); | |
1528 | } | |
1529 | else if (code == REAL_CST) | |
1530 | { | |
1531 | p = (char *) &TREE_REAL_CST (exp); | |
1532 | len = sizeof TREE_REAL_CST (exp); | |
1533 | } | |
1534 | else if (code == STRING_CST) | |
1535 | p = TREE_STRING_POINTER (exp), len = TREE_STRING_LENGTH (exp); | |
1536 | else if (code == COMPLEX_CST) | |
1537 | return const_hash (TREE_REALPART (exp)) * 5 | |
1538 | + const_hash (TREE_IMAGPART (exp)); | |
1539 | else if (code == CONSTRUCTOR) | |
1540 | { | |
1541 | register tree link; | |
1542 | ||
1543 | /* For record type, include the type in the hashing. | |
1544 | We do not do so for array types | |
1545 | because (1) the sizes of the elements are sufficient | |
1546 | and (2) distinct array types can have the same constructor. */ | |
1547 | if (TREE_CODE (TREE_TYPE (exp)) == RECORD_TYPE) | |
1548 | hi = ((int) TREE_TYPE (exp) & ((1 << HASHBITS) - 1)) % MAX_HASH_TABLE; | |
1549 | else | |
1550 | hi = 5; | |
1551 | ||
1552 | for (link = CONSTRUCTOR_ELTS (exp); link; link = TREE_CHAIN (link)) | |
1553 | hi = (hi * 603 + const_hash (TREE_VALUE (link))) % MAX_HASH_TABLE; | |
1554 | ||
1555 | return hi; | |
1556 | } | |
1557 | else if (code == ADDR_EXPR) | |
1558 | { | |
1559 | struct addr_const value; | |
1560 | decode_addr_const (exp, &value); | |
1561 | if (GET_CODE (value.base) == SYMBOL_REF) | |
1562 | { | |
1563 | /* Don't hash the address of the SYMBOL_REF; | |
1564 | only use the offset and the symbol name. */ | |
1565 | hi = value.offset; | |
1566 | p = XSTR (value.base, 0); | |
1567 | for (i = 0; p[i] != 0; i++) | |
1568 | hi = ((hi * 613) + (unsigned)(p[i])); | |
1569 | } | |
1570 | else if (GET_CODE (value.base) == LABEL_REF) | |
1571 | hi = value.offset + CODE_LABEL_NUMBER (XEXP (value.base, 0)) * 13; | |
1572 | ||
1573 | hi &= (1 << HASHBITS) - 1; | |
1574 | hi %= MAX_HASH_TABLE; | |
1575 | return hi; | |
1576 | } | |
1577 | else if (code == PLUS_EXPR || code == MINUS_EXPR) | |
1578 | return const_hash (TREE_OPERAND (exp, 0)) * 9 | |
1579 | + const_hash (TREE_OPERAND (exp, 1)); | |
1580 | else if (code == NOP_EXPR || code == CONVERT_EXPR) | |
1581 | return const_hash (TREE_OPERAND (exp, 0)) * 7 + 2; | |
1582 | ||
1583 | /* Compute hashing function */ | |
1584 | hi = len; | |
1585 | for (i = 0; i < len; i++) | |
1586 | hi = ((hi * 613) + (unsigned)(p[i])); | |
1587 | ||
1588 | hi &= (1 << HASHBITS) - 1; | |
1589 | hi %= MAX_HASH_TABLE; | |
1590 | return hi; | |
1591 | } | |
1592 | \f | |
1593 | /* Compare a constant expression EXP with a constant-descriptor DESC. | |
1594 | Return 1 if DESC describes a constant with the same value as EXP. */ | |
1595 | ||
1596 | static int | |
1597 | compare_constant (exp, desc) | |
1598 | tree exp; | |
1599 | struct constant_descriptor *desc; | |
1600 | { | |
1601 | return 0 != compare_constant_1 (exp, desc->contents); | |
1602 | } | |
1603 | ||
1604 | /* Compare constant expression EXP with a substring P of a constant descriptor. | |
1605 | If they match, return a pointer to the end of the substring matched. | |
1606 | If they do not match, return 0. | |
1607 | ||
1608 | Since descriptors are written in polish prefix notation, | |
1609 | this function can be used recursively to test one operand of EXP | |
1610 | against a subdescriptor, and if it succeeds it returns the | |
1611 | address of the subdescriptor for the next operand. */ | |
1612 | ||
1613 | static char * | |
1614 | compare_constant_1 (exp, p) | |
1615 | tree exp; | |
1616 | char *p; | |
1617 | { | |
1618 | register char *strp; | |
1619 | register int len; | |
1620 | register enum tree_code code = TREE_CODE (exp); | |
1621 | ||
1622 | if (code != (enum tree_code) *p++) | |
1623 | return 0; | |
1624 | ||
1625 | if (code == INTEGER_CST) | |
1626 | { | |
1627 | /* Integer constants are the same only if the same width of type. */ | |
1628 | if (*p++ != TYPE_PRECISION (TREE_TYPE (exp))) | |
1629 | return 0; | |
1630 | strp = (char *) &TREE_INT_CST_LOW (exp); | |
1631 | len = 2 * sizeof TREE_INT_CST_LOW (exp); | |
1632 | } | |
1633 | else if (code == REAL_CST) | |
1634 | { | |
1635 | /* Real constants are the same only if the same width of type. */ | |
1636 | if (*p++ != TYPE_PRECISION (TREE_TYPE (exp))) | |
1637 | return 0; | |
1638 | strp = (char *) &TREE_REAL_CST (exp); | |
1639 | len = sizeof TREE_REAL_CST (exp); | |
1640 | } | |
1641 | else if (code == STRING_CST) | |
1642 | { | |
1643 | if (flag_writable_strings) | |
1644 | return 0; | |
1645 | strp = TREE_STRING_POINTER (exp); | |
1646 | len = TREE_STRING_LENGTH (exp); | |
1647 | if (bcmp (&TREE_STRING_LENGTH (exp), p, | |
1648 | sizeof TREE_STRING_LENGTH (exp))) | |
1649 | return 0; | |
1650 | p += sizeof TREE_STRING_LENGTH (exp); | |
1651 | } | |
1652 | else if (code == COMPLEX_CST) | |
1653 | { | |
1654 | p = compare_constant_1 (TREE_REALPART (exp), p); | |
1655 | if (p == 0) return 0; | |
1656 | p = compare_constant_1 (TREE_IMAGPART (exp), p); | |
1657 | return p; | |
1658 | } | |
1659 | else if (code == CONSTRUCTOR) | |
1660 | { | |
1661 | register tree link; | |
1662 | int length = list_length (CONSTRUCTOR_ELTS (exp)); | |
1663 | tree type; | |
1664 | ||
1665 | if (bcmp (&length, p, sizeof length)) | |
1666 | return 0; | |
1667 | p += sizeof length; | |
1668 | ||
1669 | /* For record constructors, insist that the types match. | |
1670 | For arrays, just verify both constructors are for arrays. */ | |
1671 | if (TREE_CODE (TREE_TYPE (exp)) == RECORD_TYPE) | |
1672 | type = TREE_TYPE (exp); | |
1673 | else | |
1674 | type = 0; | |
1675 | if (bcmp (&type, p, sizeof type)) | |
1676 | return 0; | |
1677 | p += sizeof type; | |
1678 | ||
1679 | for (link = CONSTRUCTOR_ELTS (exp); link; link = TREE_CHAIN (link)) | |
1680 | if ((p = compare_constant_1 (TREE_VALUE (link), p)) == 0) | |
1681 | return 0; | |
1682 | return p; | |
1683 | } | |
1684 | else if (code == ADDR_EXPR) | |
1685 | { | |
1686 | struct addr_const value; | |
1687 | decode_addr_const (exp, &value); | |
1688 | strp = (char *) &value.offset; | |
1689 | len = sizeof value.offset; | |
1690 | /* Compare the offset. */ | |
1691 | while (--len >= 0) | |
1692 | if (*p++ != *strp++) | |
1693 | return 0; | |
1694 | /* Compare symbol name. */ | |
1695 | strp = XSTR (value.base, 0); | |
1696 | len = strlen (strp) + 1; | |
1697 | } | |
1698 | else if (code == PLUS_EXPR || code == MINUS_EXPR) | |
1699 | { | |
1700 | p = compare_constant_1 (TREE_OPERAND (exp, 0), p); | |
1701 | if (p == 0) return 0; | |
1702 | p = compare_constant_1 (TREE_OPERAND (exp, 1), p); | |
1703 | return p; | |
1704 | } | |
1705 | else if (code == NOP_EXPR || code == CONVERT_EXPR) | |
1706 | { | |
1707 | p = compare_constant_1 (TREE_OPERAND (exp, 0), p); | |
1708 | return p; | |
1709 | } | |
1710 | ||
1711 | /* Compare constant contents. */ | |
1712 | while (--len >= 0) | |
1713 | if (*p++ != *strp++) | |
1714 | return 0; | |
1715 | ||
1716 | return p; | |
1717 | } | |
1718 | \f | |
1719 | /* Construct a constant descriptor for the expression EXP. | |
1720 | It is up to the caller to enter the descriptor in the hash table. */ | |
1721 | ||
1722 | static struct constant_descriptor * | |
1723 | record_constant (exp) | |
1724 | tree exp; | |
1725 | { | |
1726 | struct constant_descriptor *ptr = 0; | |
1727 | int buf; | |
1728 | ||
1729 | obstack_grow (&permanent_obstack, &ptr, sizeof ptr); | |
1730 | obstack_grow (&permanent_obstack, &buf, sizeof buf); | |
1731 | record_constant_1 (exp); | |
1732 | return (struct constant_descriptor *) obstack_finish (&permanent_obstack); | |
1733 | } | |
1734 | ||
1735 | /* Add a description of constant expression EXP | |
1736 | to the object growing in `permanent_obstack'. | |
1737 | No need to return its address; the caller will get that | |
1738 | from the obstack when the object is complete. */ | |
1739 | ||
1740 | static void | |
1741 | record_constant_1 (exp) | |
1742 | tree exp; | |
1743 | { | |
1744 | register char *strp; | |
1745 | register int len; | |
1746 | register enum tree_code code = TREE_CODE (exp); | |
1747 | ||
1748 | obstack_1grow (&permanent_obstack, (unsigned int) code); | |
1749 | ||
1750 | if (code == INTEGER_CST) | |
1751 | { | |
1752 | obstack_1grow (&permanent_obstack, TYPE_PRECISION (TREE_TYPE (exp))); | |
1753 | strp = (char *) &TREE_INT_CST_LOW (exp); | |
1754 | len = 2 * sizeof TREE_INT_CST_LOW (exp); | |
1755 | } | |
1756 | else if (code == REAL_CST) | |
1757 | { | |
1758 | obstack_1grow (&permanent_obstack, TYPE_PRECISION (TREE_TYPE (exp))); | |
1759 | strp = (char *) &TREE_REAL_CST (exp); | |
1760 | len = sizeof TREE_REAL_CST (exp); | |
1761 | } | |
1762 | else if (code == STRING_CST) | |
1763 | { | |
1764 | if (flag_writable_strings) | |
1765 | return; | |
1766 | strp = TREE_STRING_POINTER (exp); | |
1767 | len = TREE_STRING_LENGTH (exp); | |
1768 | obstack_grow (&permanent_obstack, (char *) &TREE_STRING_LENGTH (exp), | |
1769 | sizeof TREE_STRING_LENGTH (exp)); | |
1770 | } | |
1771 | else if (code == COMPLEX_CST) | |
1772 | { | |
1773 | record_constant_1 (TREE_REALPART (exp)); | |
1774 | record_constant_1 (TREE_IMAGPART (exp)); | |
1775 | return; | |
1776 | } | |
1777 | else if (code == CONSTRUCTOR) | |
1778 | { | |
1779 | register tree link; | |
1780 | int length = list_length (CONSTRUCTOR_ELTS (exp)); | |
1781 | tree type; | |
1782 | ||
1783 | obstack_grow (&permanent_obstack, (char *) &length, sizeof length); | |
1784 | ||
1785 | /* For record constructors, insist that the types match. | |
1786 | For arrays, just verify both constructors are for arrays. */ | |
1787 | if (TREE_CODE (TREE_TYPE (exp)) == RECORD_TYPE) | |
1788 | type = TREE_TYPE (exp); | |
1789 | else | |
1790 | type = 0; | |
1791 | obstack_grow (&permanent_obstack, (char *) &type, sizeof type); | |
1792 | ||
1793 | for (link = CONSTRUCTOR_ELTS (exp); link; link = TREE_CHAIN (link)) | |
1794 | record_constant_1 (TREE_VALUE (link)); | |
1795 | return; | |
1796 | } | |
1797 | else if (code == ADDR_EXPR) | |
1798 | { | |
1799 | struct addr_const value; | |
1800 | decode_addr_const (exp, &value); | |
1801 | /* Record the offset. */ | |
1802 | obstack_grow (&permanent_obstack, | |
1803 | (char *) &value.offset, sizeof value.offset); | |
1804 | /* Record the symbol name. */ | |
1805 | obstack_grow (&permanent_obstack, XSTR (value.base, 0), | |
1806 | strlen (XSTR (value.base, 0)) + 1); | |
1807 | return; | |
1808 | } | |
1809 | else if (code == PLUS_EXPR || code == MINUS_EXPR) | |
1810 | { | |
1811 | record_constant_1 (TREE_OPERAND (exp, 0)); | |
1812 | record_constant_1 (TREE_OPERAND (exp, 1)); | |
1813 | return; | |
1814 | } | |
1815 | else if (code == NOP_EXPR || code == CONVERT_EXPR) | |
1816 | { | |
1817 | record_constant_1 (TREE_OPERAND (exp, 0)); | |
1818 | return; | |
1819 | } | |
1820 | ||
1821 | /* Record constant contents. */ | |
1822 | obstack_grow (&permanent_obstack, strp, len); | |
1823 | } | |
1824 | \f | |
1825 | /* Return an rtx representing a reference to constant data in memory | |
1826 | for the constant expression EXP. | |
1827 | If assembler code for such a constant has already been output, | |
1828 | return an rtx to refer to it. | |
1829 | Otherwise, output such a constant in memory and generate | |
1830 | an rtx for it. The TREE_CST_RTL of EXP is set up to point to that rtx. | |
1831 | The const_hash_table records which constants already have label strings. */ | |
1832 | ||
1833 | rtx | |
1834 | output_constant_def (exp) | |
1835 | tree exp; | |
1836 | { | |
1837 | register int hash, align; | |
1838 | register struct constant_descriptor *desc; | |
1839 | char label[256]; | |
1840 | char *found = 0; | |
1841 | int reloc; | |
1842 | register rtx def; | |
1843 | ||
1844 | if (TREE_CODE (exp) == INTEGER_CST) | |
1845 | abort (); /* No TREE_CST_RTL slot in these. */ | |
1846 | ||
1847 | if (TREE_CST_RTL (exp)) | |
1848 | return TREE_CST_RTL (exp); | |
1849 | ||
1850 | /* Make sure any other constants whose addresses appear in EXP | |
1851 | are assigned label numbers. */ | |
1852 | ||
1853 | reloc = output_addressed_constants (exp); | |
1854 | ||
1855 | /* Compute hash code of EXP. Search the descriptors for that hash code | |
1856 | to see if any of them describes EXP. If yes, the descriptor records | |
1857 | the label number already assigned. */ | |
1858 | ||
1859 | hash = const_hash (exp) % MAX_HASH_TABLE; | |
1860 | ||
1861 | for (desc = const_hash_table[hash]; desc; desc = desc->next) | |
1862 | if (compare_constant (exp, desc)) | |
1863 | { | |
1864 | found = desc->label; | |
1865 | break; | |
1866 | } | |
1867 | ||
1868 | if (found == 0) | |
1869 | { | |
1870 | /* No constant equal to EXP is known to have been output. | |
1871 | Make a constant descriptor to enter EXP in the hash table. | |
1872 | Assign the label number and record it in the descriptor for | |
1873 | future calls to this function to find. */ | |
1874 | ||
1875 | /* Create a string containing the label name, in LABEL. */ | |
1876 | ASM_GENERATE_INTERNAL_LABEL (label, "LC", const_labelno); | |
1877 | ||
1878 | desc = record_constant (exp); | |
1879 | desc->next = const_hash_table[hash]; | |
1880 | desc->label | |
1881 | = (char *) obstack_copy0 (&permanent_obstack, label, strlen (label)); | |
1882 | const_hash_table[hash] = desc; | |
1883 | } | |
1884 | ||
1885 | /* We have a symbol name; construct the SYMBOL_REF and the MEM. */ | |
1886 | ||
1887 | push_obstacks_nochange (); | |
1888 | if (TREE_PERMANENT (exp)) | |
1889 | end_temporary_allocation (); | |
1890 | ||
1891 | def = gen_rtx (SYMBOL_REF, Pmode, desc->label); | |
1892 | ||
1893 | TREE_CST_RTL (exp) | |
1894 | = gen_rtx (MEM, TYPE_MODE (TREE_TYPE (exp)), def); | |
1895 | RTX_UNCHANGING_P (TREE_CST_RTL (exp)) = 1; | |
1896 | ||
1897 | pop_obstacks (); | |
1898 | ||
1899 | /* Optionally set flags or add text to the name to record information | |
1900 | such as that it is a function name. If the name is changed, the macro | |
1901 | ASM_OUTPUT_LABELREF will have to know how to strip this information. | |
1902 | And if it finds a * at the beginning after doing so, it must handle | |
1903 | that too. */ | |
1904 | #ifdef ENCODE_SECTION_INFO | |
1905 | ENCODE_SECTION_INFO (exp); | |
1906 | #endif | |
1907 | ||
1908 | if (found == 0) | |
1909 | { | |
1910 | /* Now output assembler code to define that label | |
1911 | and follow it with the data of EXP. */ | |
1912 | ||
1913 | /* First switch to text section, except for writable strings. */ | |
1914 | #ifdef SELECT_SECTION | |
1915 | SELECT_SECTION (exp, reloc); | |
1916 | #else | |
1917 | if (((TREE_CODE (exp) == STRING_CST) && flag_writable_strings) | |
1918 | || (flag_pic && reloc)) | |
1919 | data_section (); | |
1920 | else | |
1921 | readonly_data_section (); | |
1922 | #endif | |
1923 | ||
1924 | /* Align the location counter as required by EXP's data type. */ | |
1925 | align = TYPE_ALIGN (TREE_TYPE (exp)); | |
1926 | #ifdef CONSTANT_ALIGNMENT | |
1927 | align = CONSTANT_ALIGNMENT (exp, align); | |
1928 | #endif | |
1929 | ||
1930 | if (align > BITS_PER_UNIT) | |
1931 | ASM_OUTPUT_ALIGN (asm_out_file, floor_log2 (align / BITS_PER_UNIT)); | |
1932 | ||
1933 | /* Output the label itself. */ | |
1934 | ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "LC", const_labelno); | |
1935 | ||
1936 | /* Output the value of EXP. */ | |
1937 | output_constant (exp, | |
1938 | (TREE_CODE (exp) == STRING_CST | |
1939 | ? TREE_STRING_LENGTH (exp) | |
1940 | : int_size_in_bytes (TREE_TYPE (exp)))); | |
1941 | ||
1942 | ++const_labelno; | |
1943 | } | |
1944 | ||
1945 | return TREE_CST_RTL (exp); | |
1946 | } | |
1947 | \f | |
1948 | /* Similar hash facility for making memory-constants | |
1949 | from constant rtl-expressions. It is used on RISC machines | |
1950 | where immediate integer arguments and constant addresses are restricted | |
1951 | so that such constants must be stored in memory. | |
1952 | ||
1953 | This pool of constants is reinitialized for each function | |
1954 | so each function gets its own constants-pool that comes right before it. | |
1955 | ||
1956 | All structures allocated here are discarded when functions are saved for | |
1957 | inlining, so they do not need to be allocated permanently. */ | |
1958 | ||
1959 | #define MAX_RTX_HASH_TABLE 61 | |
1960 | static struct constant_descriptor *const_rtx_hash_table[MAX_RTX_HASH_TABLE]; | |
1961 | ||
1962 | /* Structure to represent sufficient information about a constant so that | |
1963 | it can be output when the constant pool is output, so that function | |
1964 | integration can be done, and to simplify handling on machines that reference | |
1965 | constant pool as base+displacement. */ | |
1966 | ||
1967 | struct pool_constant | |
1968 | { | |
1969 | struct constant_descriptor *desc; | |
1970 | struct pool_constant *next; | |
1971 | enum machine_mode mode; | |
1972 | rtx constant; | |
1973 | int labelno; | |
1974 | int align; | |
1975 | int offset; | |
1976 | }; | |
1977 | ||
1978 | /* Pointers to first and last constant in pool. */ | |
1979 | ||
1980 | static struct pool_constant *first_pool, *last_pool; | |
1981 | ||
1982 | /* Current offset in constant pool (does not include any machine-specific | |
1983 | header. */ | |
1984 | ||
1985 | static int pool_offset; | |
1986 | ||
1987 | /* Structure used to maintain hash table mapping symbols used to their | |
1988 | corresponding constants. */ | |
1989 | ||
1990 | struct pool_sym | |
1991 | { | |
1992 | char *label; | |
1993 | struct pool_constant *pool; | |
1994 | struct pool_sym *next; | |
1995 | }; | |
1996 | ||
1997 | static struct pool_sym *const_rtx_sym_hash_table[MAX_RTX_HASH_TABLE]; | |
1998 | ||
1999 | /* Hash code for a SYMBOL_REF with CONSTANT_POOL_ADDRESS_P true. | |
2000 | The argument is XSTR (... , 0) */ | |
2001 | ||
2002 | #define SYMHASH(LABEL) \ | |
2003 | ((((int) (LABEL)) & ((1 << HASHBITS) - 1)) % MAX_RTX_HASH_TABLE) | |
2004 | \f | |
2005 | /* Initialize constant pool hashing for next function. */ | |
2006 | ||
2007 | void | |
2008 | init_const_rtx_hash_table () | |
2009 | { | |
2010 | bzero (const_rtx_hash_table, sizeof const_rtx_hash_table); | |
2011 | bzero (const_rtx_sym_hash_table, sizeof const_rtx_sym_hash_table); | |
2012 | ||
2013 | first_pool = last_pool = 0; | |
2014 | pool_offset = 0; | |
2015 | } | |
2016 | ||
2017 | enum kind { RTX_DOUBLE, RTX_INT }; | |
2018 | ||
2019 | struct rtx_const | |
2020 | { | |
2021 | #ifdef ONLY_INT_FIELDS | |
2022 | unsigned int kind : 16; | |
2023 | unsigned int mode : 16; | |
2024 | #else | |
2025 | enum kind kind : 16; | |
2026 | enum machine_mode mode : 16; | |
2027 | #endif | |
2028 | union { | |
2029 | union real_extract du; | |
2030 | struct addr_const addr; | |
2031 | } un; | |
2032 | }; | |
2033 | ||
2034 | /* Express an rtx for a constant integer (perhaps symbolic) | |
2035 | as the sum of a symbol or label plus an explicit integer. | |
2036 | They are stored into VALUE. */ | |
2037 | ||
2038 | static void | |
2039 | decode_rtx_const (mode, x, value) | |
2040 | enum machine_mode mode; | |
2041 | rtx x; | |
2042 | struct rtx_const *value; | |
2043 | { | |
2044 | /* Clear the whole structure, including any gaps. */ | |
2045 | ||
2046 | { | |
2047 | int *p = (int *) value; | |
2048 | int *end = (int *) (value + 1); | |
2049 | while (p < end) | |
2050 | *p++ = 0; | |
2051 | } | |
2052 | ||
2053 | value->kind = RTX_INT; /* Most usual kind. */ | |
2054 | value->mode = mode; | |
2055 | ||
2056 | switch (GET_CODE (x)) | |
2057 | { | |
2058 | case CONST_DOUBLE: | |
2059 | value->kind = RTX_DOUBLE; | |
2060 | value->mode = GET_MODE (x); | |
2061 | bcopy (&CONST_DOUBLE_LOW (x), &value->un.du, sizeof value->un.du); | |
2062 | break; | |
2063 | ||
2064 | case CONST_INT: | |
2065 | value->un.addr.offset = INTVAL (x); | |
2066 | break; | |
2067 | ||
2068 | case SYMBOL_REF: | |
2069 | case LABEL_REF: | |
2070 | value->un.addr.base = x; | |
2071 | break; | |
2072 | ||
2073 | case CONST: | |
2074 | x = XEXP (x, 0); | |
2075 | if (GET_CODE (x) == PLUS) | |
2076 | { | |
2077 | value->un.addr.base = XEXP (x, 0); | |
2078 | if (GET_CODE (XEXP (x, 1)) != CONST_INT) | |
2079 | abort (); | |
2080 | value->un.addr.offset = INTVAL (XEXP (x, 1)); | |
2081 | } | |
2082 | else if (GET_CODE (x) == MINUS) | |
2083 | { | |
2084 | value->un.addr.base = XEXP (x, 0); | |
2085 | if (GET_CODE (XEXP (x, 1)) != CONST_INT) | |
2086 | abort (); | |
2087 | value->un.addr.offset = - INTVAL (XEXP (x, 1)); | |
2088 | } | |
2089 | else | |
2090 | abort (); | |
2091 | break; | |
2092 | ||
2093 | default: | |
2094 | abort (); | |
2095 | } | |
2096 | ||
2097 | if (value->kind == RTX_INT && value->un.addr.base != 0) | |
2098 | switch (GET_CODE (value->un.addr.base)) | |
2099 | { | |
2100 | case SYMBOL_REF: | |
2101 | case LABEL_REF: | |
2102 | /* Use the string's address, not the SYMBOL_REF's address, | |
2103 | for the sake of addresses of library routines. | |
2104 | For a LABEL_REF, compare labels. */ | |
2105 | value->un.addr.base = XEXP (value->un.addr.base, 0); | |
2106 | } | |
2107 | } | |
2108 | ||
2109 | /* Compute a hash code for a constant RTL expression. */ | |
2110 | ||
2111 | int | |
2112 | const_hash_rtx (mode, x) | |
2113 | enum machine_mode mode; | |
2114 | rtx x; | |
2115 | { | |
2116 | register int hi, i; | |
2117 | ||
2118 | struct rtx_const value; | |
2119 | decode_rtx_const (mode, x, &value); | |
2120 | ||
2121 | /* Compute hashing function */ | |
2122 | hi = 0; | |
2123 | for (i = 0; i < sizeof value / sizeof (int); i++) | |
2124 | hi += ((int *) &value)[i]; | |
2125 | ||
2126 | hi &= (1 << HASHBITS) - 1; | |
2127 | hi %= MAX_RTX_HASH_TABLE; | |
2128 | return hi; | |
2129 | } | |
2130 | ||
2131 | /* Compare a constant rtl object X with a constant-descriptor DESC. | |
2132 | Return 1 if DESC describes a constant with the same value as X. */ | |
2133 | ||
2134 | static int | |
2135 | compare_constant_rtx (mode, x, desc) | |
2136 | enum machine_mode mode; | |
2137 | rtx x; | |
2138 | struct constant_descriptor *desc; | |
2139 | { | |
2140 | register int *p = (int *) desc->contents; | |
2141 | register int *strp; | |
2142 | register int len; | |
2143 | struct rtx_const value; | |
2144 | ||
2145 | decode_rtx_const (mode, x, &value); | |
2146 | strp = (int *) &value; | |
2147 | len = sizeof value / sizeof (int); | |
2148 | ||
2149 | /* Compare constant contents. */ | |
2150 | while (--len >= 0) | |
2151 | if (*p++ != *strp++) | |
2152 | return 0; | |
2153 | ||
2154 | return 1; | |
2155 | } | |
2156 | ||
2157 | /* Construct a constant descriptor for the rtl-expression X. | |
2158 | It is up to the caller to enter the descriptor in the hash table. */ | |
2159 | ||
2160 | static struct constant_descriptor * | |
2161 | record_constant_rtx (mode, x) | |
2162 | enum machine_mode mode; | |
2163 | rtx x; | |
2164 | { | |
2165 | struct constant_descriptor *ptr; | |
2166 | char *label; | |
2167 | struct rtx_const value; | |
2168 | ||
2169 | decode_rtx_const (mode, x, &value); | |
2170 | ||
2171 | obstack_grow (current_obstack, &ptr, sizeof ptr); | |
2172 | obstack_grow (current_obstack, &label, sizeof label); | |
2173 | ||
2174 | /* Record constant contents. */ | |
2175 | obstack_grow (current_obstack, &value, sizeof value); | |
2176 | ||
2177 | return (struct constant_descriptor *) obstack_finish (current_obstack); | |
2178 | } | |
2179 | \f | |
2180 | /* Given a constant rtx X, make (or find) a memory constant for its value | |
2181 | and return a MEM rtx to refer to it in memory. */ | |
2182 | ||
2183 | rtx | |
2184 | force_const_mem (mode, x) | |
2185 | enum machine_mode mode; | |
2186 | rtx x; | |
2187 | { | |
2188 | register int hash; | |
2189 | register struct constant_descriptor *desc; | |
2190 | char label[256]; | |
2191 | char *found = 0; | |
2192 | rtx def; | |
2193 | ||
2194 | /* If we want this CONST_DOUBLE in the same mode as it is in memory | |
2195 | (this will always be true for floating CONST_DOUBLEs that have been | |
2196 | placed in memory, but not for VOIDmode (integer) CONST_DOUBLEs), | |
2197 | use the previous copy. Otherwise, make a new one. Note that in | |
2198 | the unlikely event that this same CONST_DOUBLE is used in two different | |
2199 | modes in an alternating fashion, we will allocate a lot of different | |
2200 | memory locations, but this should be extremely rare. */ | |
2201 | ||
2202 | if (GET_CODE (x) == CONST_DOUBLE | |
2203 | && GET_CODE (CONST_DOUBLE_MEM (x)) == MEM | |
2204 | && GET_MODE (CONST_DOUBLE_MEM (x)) == mode) | |
2205 | return CONST_DOUBLE_MEM (x); | |
2206 | ||
2207 | /* Compute hash code of X. Search the descriptors for that hash code | |
2208 | to see if any of them describes X. If yes, the descriptor records | |
2209 | the label number already assigned. */ | |
2210 | ||
2211 | hash = const_hash_rtx (mode, x); | |
2212 | ||
2213 | for (desc = const_rtx_hash_table[hash]; desc; desc = desc->next) | |
2214 | if (compare_constant_rtx (mode, x, desc)) | |
2215 | { | |
2216 | found = desc->label; | |
2217 | break; | |
2218 | } | |
2219 | ||
2220 | if (found == 0) | |
2221 | { | |
2222 | register struct pool_constant *pool; | |
2223 | register struct pool_sym *sym; | |
2224 | int align; | |
2225 | ||
2226 | /* No constant equal to X is known to have been output. | |
2227 | Make a constant descriptor to enter X in the hash table. | |
2228 | Assign the label number and record it in the descriptor for | |
2229 | future calls to this function to find. */ | |
2230 | ||
2231 | desc = record_constant_rtx (mode, x); | |
2232 | desc->next = const_rtx_hash_table[hash]; | |
2233 | const_rtx_hash_table[hash] = desc; | |
2234 | ||
2235 | /* Align the location counter as required by EXP's data type. */ | |
2236 | align = (mode == VOIDmode) ? UNITS_PER_WORD : GET_MODE_SIZE (mode); | |
2237 | if (align > BIGGEST_ALIGNMENT / BITS_PER_UNIT) | |
2238 | align = BIGGEST_ALIGNMENT / BITS_PER_UNIT; | |
2239 | ||
2240 | pool_offset += align - 1; | |
2241 | pool_offset &= ~ (align - 1); | |
2242 | ||
2243 | /* Allocate a pool constant descriptor, fill it in, and chain it in. */ | |
2244 | ||
2245 | pool = (struct pool_constant *) oballoc (sizeof (struct pool_constant)); | |
2246 | pool->desc = desc; | |
2247 | pool->constant = x; | |
2248 | pool->mode = mode; | |
2249 | pool->labelno = const_labelno; | |
2250 | pool->align = align; | |
2251 | pool->offset = pool_offset; | |
2252 | pool->next = 0; | |
2253 | ||
2254 | if (last_pool == 0) | |
2255 | first_pool = pool; | |
2256 | else | |
2257 | last_pool->next = pool; | |
2258 | ||
2259 | last_pool = pool; | |
2260 | pool_offset += GET_MODE_SIZE (mode); | |
2261 | ||
2262 | /* Create a string containing the label name, in LABEL. */ | |
2263 | ASM_GENERATE_INTERNAL_LABEL (label, "LC", const_labelno); | |
2264 | ||
2265 | ++const_labelno; | |
2266 | ||
2267 | desc->label = found | |
2268 | = (char *) obstack_copy0 (saveable_obstack, label, strlen (label)); | |
2269 | ||
2270 | /* Add label to symbol hash table. */ | |
2271 | hash = SYMHASH (found); | |
2272 | sym = (struct pool_sym *) oballoc (sizeof (struct pool_sym)); | |
2273 | sym->label = found; | |
2274 | sym->pool = pool; | |
2275 | sym->next = const_rtx_sym_hash_table[hash]; | |
2276 | const_rtx_sym_hash_table[hash] = sym; | |
2277 | } | |
2278 | ||
2279 | /* We have a symbol name; construct the SYMBOL_REF and the MEM. */ | |
2280 | ||
2281 | def = gen_rtx (MEM, mode, gen_rtx (SYMBOL_REF, Pmode, found)); | |
2282 | ||
2283 | RTX_UNCHANGING_P (def) = 1; | |
2284 | /* Mark the symbol_ref as belonging to this constants pool. */ | |
2285 | CONSTANT_POOL_ADDRESS_P (XEXP (def, 0)) = 1; | |
2286 | current_function_uses_const_pool = 1; | |
2287 | ||
2288 | if (GET_CODE (x) == CONST_DOUBLE) | |
2289 | { | |
2290 | if (CONST_DOUBLE_MEM (x) == cc0_rtx) | |
2291 | { | |
2292 | CONST_DOUBLE_CHAIN (x) = const_double_chain; | |
2293 | const_double_chain = x; | |
2294 | } | |
2295 | CONST_DOUBLE_MEM (x) = def; | |
2296 | } | |
2297 | ||
2298 | return def; | |
2299 | } | |
2300 | \f | |
2301 | /* Given a SYMBOL_REF with CONSTANT_POOL_ADDRESS_P true, return a pointer to | |
2302 | the corresponding pool_constant structure. */ | |
2303 | ||
2304 | static struct pool_constant * | |
2305 | find_pool_constant (addr) | |
2306 | rtx addr; | |
2307 | { | |
2308 | struct pool_sym *sym; | |
2309 | char *label = XSTR (addr, 0); | |
2310 | ||
2311 | for (sym = const_rtx_sym_hash_table[SYMHASH (label)]; sym; sym = sym->next) | |
2312 | if (sym->label == label) | |
2313 | return sym->pool; | |
2314 | ||
2315 | abort (); | |
2316 | } | |
2317 | ||
2318 | /* Given a constant pool SYMBOL_REF, return the corresponding constant. */ | |
2319 | ||
2320 | rtx | |
2321 | get_pool_constant (addr) | |
2322 | rtx addr; | |
2323 | { | |
2324 | return (find_pool_constant (addr))->constant; | |
2325 | } | |
2326 | ||
2327 | /* Similar, return the mode. */ | |
2328 | ||
2329 | enum machine_mode | |
2330 | get_pool_mode (addr) | |
2331 | rtx addr; | |
2332 | { | |
2333 | return (find_pool_constant (addr))->mode; | |
2334 | } | |
2335 | ||
2336 | /* Similar, return the offset in the constant pool. */ | |
2337 | ||
2338 | int | |
2339 | get_pool_offset (addr) | |
2340 | rtx addr; | |
2341 | { | |
2342 | return (find_pool_constant (addr))->offset; | |
2343 | } | |
2344 | ||
2345 | /* Return the size of the constant pool. */ | |
2346 | ||
2347 | int | |
2348 | get_pool_size () | |
2349 | { | |
2350 | return pool_offset; | |
2351 | } | |
2352 | \f | |
2353 | /* Write all the constants in the constant pool. */ | |
2354 | ||
2355 | void | |
2356 | output_constant_pool (fnname, fndecl) | |
2357 | char *fnname; | |
2358 | tree fndecl; | |
2359 | { | |
2360 | struct pool_constant *pool; | |
2361 | rtx x; | |
2362 | union real_extract u; | |
2363 | ||
2364 | #ifdef ASM_OUTPUT_POOL_PROLOGUE | |
2365 | ASM_OUTPUT_POOL_PROLOGUE (asm_out_file, fnname, fndecl, pool_offset); | |
2366 | #endif | |
2367 | ||
2368 | for (pool = first_pool; pool; pool = pool->next) | |
2369 | { | |
2370 | x = pool->constant; | |
2371 | ||
2372 | /* See if X is a LABEL_REF (or a CONST referring to a LABEL_REF) | |
2373 | whose CODE_LABEL has been deleted. This can occur if a jump table | |
2374 | is eliminated by optimization. If so, write a constant of zero | |
2375 | instead. */ | |
2376 | if ((GET_CODE (x) == LABEL_REF && INSN_DELETED_P (XEXP (x, 0))) | |
2377 | || (GET_CODE (x) == CONST && GET_CODE (XEXP (x, 0)) == PLUS | |
2378 | && GET_CODE (XEXP (XEXP (x, 0), 0)) == LABEL_REF | |
2379 | && INSN_DELETED_P (XEXP (XEXP (XEXP (x, 0), 0), 0)))) | |
2380 | x = const0_rtx; | |
2381 | ||
2382 | /* First switch to correct section. */ | |
2383 | #ifdef SELECT_RTX_SECTION | |
2384 | SELECT_RTX_SECTION (pool->mode, x); | |
2385 | #else | |
2386 | readonly_data_section (); | |
2387 | #endif | |
2388 | ||
2389 | #ifdef ASM_OUTPUT_SPECIAL_POOL_ENTRY | |
2390 | ASM_OUTPUT_SPECIAL_POOL_ENTRY (asm_out_file, x, pool->mode, | |
2391 | pool->align, pool->labelno, done); | |
2392 | #endif | |
2393 | ||
2394 | if (pool->align > 1) | |
2395 | ASM_OUTPUT_ALIGN (asm_out_file, exact_log2 (pool->align)); | |
2396 | ||
2397 | /* Output the label. */ | |
2398 | ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "LC", pool->labelno); | |
2399 | ||
2400 | /* Output the value of the constant itself. */ | |
2401 | switch (GET_MODE_CLASS (pool->mode)) | |
2402 | { | |
2403 | case MODE_FLOAT: | |
2404 | if (GET_CODE (x) != CONST_DOUBLE) | |
2405 | abort (); | |
2406 | ||
2407 | bcopy (&CONST_DOUBLE_LOW (x), &u, sizeof u); | |
2408 | assemble_real (u.d, pool->mode); | |
2409 | break; | |
2410 | ||
2411 | case MODE_INT: | |
2412 | assemble_integer (x, GET_MODE_SIZE (pool->mode), 1); | |
2413 | break; | |
2414 | ||
2415 | default: | |
2416 | abort (); | |
2417 | } | |
2418 | ||
2419 | done: ; | |
2420 | } | |
2421 | ||
2422 | /* Done with this pool. */ | |
2423 | first_pool = last_pool = 0; | |
2424 | } | |
2425 | \f | |
2426 | /* Find all the constants whose addresses are referenced inside of EXP, | |
2427 | and make sure assembler code with a label has been output for each one. | |
2428 | Indicate whether an ADDR_EXPR has been encountered. */ | |
2429 | ||
2430 | int | |
2431 | output_addressed_constants (exp) | |
2432 | tree exp; | |
2433 | { | |
2434 | int reloc = 0; | |
2435 | ||
2436 | switch (TREE_CODE (exp)) | |
2437 | { | |
2438 | case ADDR_EXPR: | |
2439 | { | |
2440 | register tree constant = TREE_OPERAND (exp, 0); | |
2441 | ||
2442 | while (TREE_CODE (constant) == COMPONENT_REF) | |
2443 | { | |
2444 | constant = TREE_OPERAND (constant, 0); | |
2445 | } | |
2446 | ||
2447 | if (TREE_CODE_CLASS (TREE_CODE (constant)) == 'c' | |
2448 | || TREE_CODE (constant) == CONSTRUCTOR) | |
2449 | /* No need to do anything here | |
2450 | for addresses of variables or functions. */ | |
2451 | output_constant_def (constant); | |
2452 | } | |
2453 | reloc = 1; | |
2454 | break; | |
2455 | ||
2456 | case PLUS_EXPR: | |
2457 | case MINUS_EXPR: | |
2458 | reloc = output_addressed_constants (TREE_OPERAND (exp, 0)); | |
2459 | reloc |= output_addressed_constants (TREE_OPERAND (exp, 1)); | |
2460 | break; | |
2461 | ||
2462 | case NOP_EXPR: | |
2463 | case CONVERT_EXPR: | |
2464 | reloc = output_addressed_constants (TREE_OPERAND (exp, 0)); | |
2465 | break; | |
2466 | ||
2467 | case CONSTRUCTOR: | |
2468 | { | |
2469 | register tree link; | |
2470 | for (link = CONSTRUCTOR_ELTS (exp); link; link = TREE_CHAIN (link)) | |
2471 | if (TREE_VALUE (link) != 0) | |
2472 | reloc |= output_addressed_constants (TREE_VALUE (link)); | |
2473 | } | |
2474 | break; | |
2475 | ||
2476 | case ERROR_MARK: | |
2477 | break; | |
2478 | } | |
2479 | return reloc; | |
2480 | } | |
2481 | \f | |
2482 | /* Output assembler code for constant EXP to FILE, with no label. | |
2483 | This includes the pseudo-op such as ".int" or ".byte", and a newline. | |
2484 | Assumes output_addressed_constants has been done on EXP already. | |
2485 | ||
2486 | Generate exactly SIZE bytes of assembler data, padding at the end | |
2487 | with zeros if necessary. SIZE must always be specified. | |
2488 | ||
2489 | SIZE is important for structure constructors, | |
2490 | since trailing members may have been omitted from the constructor. | |
2491 | It is also important for initialization of arrays from string constants | |
2492 | since the full length of the string constant might not be wanted. | |
2493 | It is also needed for initialization of unions, where the initializer's | |
2494 | type is just one member, and that may not be as long as the union. | |
2495 | ||
2496 | There a case in which we would fail to output exactly SIZE bytes: | |
2497 | for a structure constructor that wants to produce more than SIZE bytes. | |
2498 | But such constructors will never be generated for any possible input. */ | |
2499 | ||
2500 | void | |
2501 | output_constant (exp, size) | |
2502 | register tree exp; | |
2503 | register int size; | |
2504 | { | |
2505 | register enum tree_code code = TREE_CODE (TREE_TYPE (exp)); | |
2506 | rtx x; | |
2507 | ||
2508 | if (size == 0) | |
2509 | return; | |
2510 | ||
fff9e713 MT |
2511 | /* Allow a constructor with no elements for any data type. |
2512 | This means to fill the space with zeros. */ | |
2513 | if (TREE_CODE (exp) == CONSTRUCTOR | |
2514 | && TREE_OPERAND (exp, 1) == 0) | |
2515 | { | |
2516 | assemble_zeros (size); | |
2517 | return; | |
2518 | } | |
2519 | ||
79e68feb RS |
2520 | /* Eliminate the NOP_EXPR that makes a cast not be an lvalue. |
2521 | That way we get the constant (we hope) inside it. */ | |
2522 | if (TREE_CODE (exp) == NOP_EXPR | |
2523 | && TREE_TYPE (exp) == TREE_TYPE (TREE_OPERAND (exp, 0))) | |
2524 | exp = TREE_OPERAND (exp, 0); | |
2525 | ||
2526 | switch (code) | |
2527 | { | |
2528 | case INTEGER_TYPE: | |
2529 | case ENUMERAL_TYPE: | |
2530 | case POINTER_TYPE: | |
2531 | case REFERENCE_TYPE: | |
2532 | /* ??? What about (int)((float)(int)&foo + 4) */ | |
2533 | while (TREE_CODE (exp) == NOP_EXPR || TREE_CODE (exp) == CONVERT_EXPR | |
2534 | || TREE_CODE (exp) == NON_LVALUE_EXPR) | |
2535 | exp = TREE_OPERAND (exp, 0); | |
2536 | ||
2537 | if (! assemble_integer (expand_expr (exp, 0, VOIDmode, | |
2538 | EXPAND_INITIALIZER), | |
2539 | size, 0)) | |
2540 | error ("initializer for integer value is too complicated"); | |
2541 | size = 0; | |
2542 | break; | |
2543 | ||
2544 | case REAL_TYPE: | |
2545 | if (TREE_CODE (exp) != REAL_CST) | |
2546 | error ("initializer for floating value is not a floating constant"); | |
2547 | ||
2548 | assemble_real (TREE_REAL_CST (exp), | |
2549 | mode_for_size (size * BITS_PER_UNIT, MODE_FLOAT, 0)); | |
2550 | size = 0; | |
2551 | break; | |
2552 | ||
2553 | case COMPLEX_TYPE: | |
2554 | output_constant (TREE_REALPART (exp), size / 2); | |
2555 | output_constant (TREE_IMAGPART (exp), size / 2); | |
2556 | size -= (size / 2) * 2; | |
2557 | break; | |
2558 | ||
2559 | case ARRAY_TYPE: | |
2560 | if (TREE_CODE (exp) == CONSTRUCTOR) | |
2561 | { | |
2562 | output_constructor (exp, size); | |
2563 | return; | |
2564 | } | |
2565 | else if (TREE_CODE (exp) == STRING_CST) | |
2566 | { | |
2567 | int excess = 0; | |
2568 | ||
2569 | if (size > TREE_STRING_LENGTH (exp)) | |
2570 | { | |
2571 | excess = size - TREE_STRING_LENGTH (exp); | |
2572 | size = TREE_STRING_LENGTH (exp); | |
2573 | } | |
2574 | ||
2575 | assemble_string (TREE_STRING_POINTER (exp), size); | |
2576 | size = excess; | |
2577 | } | |
2578 | else | |
2579 | abort (); | |
2580 | break; | |
2581 | ||
2582 | case RECORD_TYPE: | |
2583 | case UNION_TYPE: | |
2584 | if (TREE_CODE (exp) == CONSTRUCTOR) | |
2585 | output_constructor (exp, size); | |
2586 | else | |
2587 | abort (); | |
2588 | return; | |
2589 | } | |
2590 | ||
2591 | if (size > 0) | |
2592 | assemble_zeros (size); | |
2593 | } | |
2594 | \f | |
2595 | /* Subroutine of output_constant, used for CONSTRUCTORs | |
2596 | (aggregate constants). | |
2597 | Generate at least SIZE bytes, padding if necessary. */ | |
2598 | ||
2599 | void | |
2600 | output_constructor (exp, size) | |
2601 | tree exp; | |
2602 | int size; | |
2603 | { | |
2604 | register tree link, field = 0; | |
2605 | /* Number of bytes output or skipped so far. | |
2606 | In other words, current position within the constructor. */ | |
2607 | int total_bytes = 0; | |
2608 | /* Non-zero means BYTE contains part of a byte, to be output. */ | |
2609 | int byte_buffer_in_use = 0; | |
2610 | register int byte; | |
2611 | ||
2612 | if (HOST_BITS_PER_INT < BITS_PER_UNIT) | |
2613 | abort (); | |
2614 | ||
2615 | if (TREE_CODE (TREE_TYPE (exp)) == RECORD_TYPE) | |
2616 | field = TYPE_FIELDS (TREE_TYPE (exp)); | |
2617 | ||
2618 | /* As LINK goes through the elements of the constant, | |
2619 | FIELD goes through the structure fields, if the constant is a structure. | |
2620 | if the constant is a union, then we override this, | |
2621 | by getting the field from the TREE_LIST element. | |
2622 | But the constant could also be an array. Then FIELD is zero. */ | |
2623 | for (link = CONSTRUCTOR_ELTS (exp); | |
2624 | link; | |
2625 | link = TREE_CHAIN (link), | |
2626 | field = field ? TREE_CHAIN (field) : 0) | |
2627 | { | |
2628 | tree val = TREE_VALUE (link); | |
2629 | /* the element in a union constructor specifies the proper field. */ | |
2630 | if (TREE_PURPOSE (link) != 0) | |
2631 | field = TREE_PURPOSE (link); | |
2632 | ||
2633 | /* Eliminate the marker that makes a cast not be an lvalue. */ | |
2634 | if (val != 0 && TREE_CODE (val) == NON_LVALUE_EXPR) | |
2635 | val = TREE_OPERAND (val, 0); | |
2636 | ||
2637 | if (field == 0 || !DECL_BIT_FIELD (field)) | |
2638 | { | |
2639 | register int fieldsize; | |
2640 | /* Since this structure is static, | |
2641 | we know the positions are constant. */ | |
2642 | int bitpos = (field ? (TREE_INT_CST_LOW (DECL_FIELD_BITPOS (field)) | |
2643 | / BITS_PER_UNIT) | |
2644 | : 0); | |
2645 | ||
2646 | /* An element that is not a bit-field. | |
2647 | Output any buffered-up bit-fields preceding it. */ | |
2648 | if (byte_buffer_in_use) | |
2649 | { | |
2650 | ASM_OUTPUT_BYTE (asm_out_file, byte); | |
2651 | total_bytes++; | |
2652 | byte_buffer_in_use = 0; | |
2653 | } | |
2654 | ||
2655 | /* Advance to offset of this element. | |
2656 | Note no alignment needed in an array, since that is guaranteed | |
2657 | if each element has the proper size. */ | |
2658 | if (field != 0 && bitpos != total_bytes) | |
2659 | { | |
2660 | assemble_zeros (bitpos - total_bytes); | |
2661 | total_bytes = bitpos; | |
2662 | } | |
2663 | ||
2664 | /* Determine size this element should occupy. */ | |
2665 | if (field) | |
2666 | { | |
2667 | if (TREE_CODE (DECL_SIZE (field)) != INTEGER_CST) | |
2668 | abort (); | |
2669 | if (TREE_INT_CST_LOW (DECL_SIZE (field)) > 100000) | |
2670 | { | |
2671 | /* This avoids overflow trouble. */ | |
2672 | tree size_tree = size_binop (CEIL_DIV_EXPR, | |
2673 | DECL_SIZE (field), | |
2674 | size_int (BITS_PER_UNIT)); | |
2675 | fieldsize = TREE_INT_CST_LOW (size_tree); | |
2676 | } | |
2677 | else | |
2678 | { | |
2679 | fieldsize = TREE_INT_CST_LOW (DECL_SIZE (field)); | |
2680 | fieldsize = (fieldsize + BITS_PER_UNIT - 1) / BITS_PER_UNIT; | |
2681 | } | |
2682 | } | |
2683 | else | |
2684 | fieldsize = int_size_in_bytes (TREE_TYPE (TREE_TYPE (exp))); | |
2685 | ||
2686 | /* Output the element's initial value. */ | |
2687 | if (val == 0) | |
2688 | assemble_zeros (fieldsize); | |
2689 | else | |
2690 | output_constant (val, fieldsize); | |
2691 | ||
2692 | /* Count its size. */ | |
2693 | total_bytes += fieldsize; | |
2694 | } | |
2695 | else if (val != 0 && TREE_CODE (val) != INTEGER_CST) | |
2696 | error ("invalid initial value for member `%s'", | |
2697 | IDENTIFIER_POINTER (DECL_NAME (field))); | |
2698 | else | |
2699 | { | |
2700 | /* Element that is a bit-field. */ | |
2701 | ||
2702 | int next_offset = TREE_INT_CST_LOW (DECL_FIELD_BITPOS (field)); | |
2703 | int end_offset | |
2704 | = (next_offset + TREE_INT_CST_LOW (DECL_SIZE (field))); | |
2705 | ||
2706 | if (val == 0) | |
2707 | val = integer_zero_node; | |
2708 | ||
2709 | /* If this field does not start in this (or, next) byte, | |
2710 | skip some bytes. */ | |
2711 | if (next_offset / BITS_PER_UNIT != total_bytes) | |
2712 | { | |
2713 | /* Output remnant of any bit field in previous bytes. */ | |
2714 | if (byte_buffer_in_use) | |
2715 | { | |
2716 | ASM_OUTPUT_BYTE (asm_out_file, byte); | |
2717 | total_bytes++; | |
2718 | byte_buffer_in_use = 0; | |
2719 | } | |
2720 | ||
2721 | /* If still not at proper byte, advance to there. */ | |
2722 | if (next_offset / BITS_PER_UNIT != total_bytes) | |
2723 | { | |
2724 | assemble_zeros (next_offset / BITS_PER_UNIT - total_bytes); | |
2725 | total_bytes = next_offset / BITS_PER_UNIT; | |
2726 | } | |
2727 | } | |
2728 | ||
2729 | if (! byte_buffer_in_use) | |
2730 | byte = 0; | |
2731 | ||
2732 | /* We must split the element into pieces that fall within | |
2733 | separate bytes, and combine each byte with previous or | |
2734 | following bit-fields. */ | |
2735 | ||
b4ac57ab | 2736 | /* next_offset is the offset n fbits from the beginning of |
79e68feb RS |
2737 | the structure to the next bit of this element to be processed. |
2738 | end_offset is the offset of the first bit past the end of | |
2739 | this element. */ | |
2740 | while (next_offset < end_offset) | |
2741 | { | |
2742 | int this_time; | |
2743 | int shift, value; | |
2744 | int next_byte = next_offset / BITS_PER_UNIT; | |
2745 | int next_bit = next_offset % BITS_PER_UNIT; | |
2746 | ||
2747 | /* Advance from byte to byte | |
2748 | within this element when necessary. */ | |
2749 | while (next_byte != total_bytes) | |
2750 | { | |
2751 | ASM_OUTPUT_BYTE (asm_out_file, byte); | |
2752 | total_bytes++; | |
2753 | byte = 0; | |
2754 | } | |
2755 | ||
2756 | /* Number of bits we can process at once | |
2757 | (all part of the same byte). */ | |
2758 | this_time = MIN (end_offset - next_offset, | |
2759 | BITS_PER_UNIT - next_bit); | |
2760 | #if BYTES_BIG_ENDIAN | |
2761 | /* On big-endian machine, take the most significant bits | |
2762 | first (of the bits that are significant) | |
2763 | and put them into bytes from the most significant end. */ | |
2764 | shift = end_offset - next_offset - this_time; | |
2765 | /* Don't try to take a bunch of bits that cross | |
2766 | the word boundary in the INTEGER_CST. */ | |
2767 | if (shift < HOST_BITS_PER_INT | |
2768 | && shift + this_time > HOST_BITS_PER_INT) | |
2769 | { | |
2770 | this_time -= (HOST_BITS_PER_INT - shift); | |
2771 | shift = HOST_BITS_PER_INT; | |
2772 | } | |
2773 | ||
2774 | /* Now get the bits from the appropriate constant word. */ | |
2775 | if (shift < HOST_BITS_PER_INT) | |
2776 | { | |
2777 | value = TREE_INT_CST_LOW (val); | |
2778 | } | |
2779 | else if (shift < 2 * HOST_BITS_PER_INT) | |
2780 | { | |
2781 | value = TREE_INT_CST_HIGH (val); | |
2782 | shift -= HOST_BITS_PER_INT; | |
2783 | } | |
2784 | else | |
2785 | abort (); | |
2786 | byte |= (((value >> shift) & ((1 << this_time) - 1)) | |
2787 | << (BITS_PER_UNIT - this_time - next_bit)); | |
2788 | #else | |
2789 | /* On little-endian machines, | |
2790 | take first the least significant bits of the value | |
2791 | and pack them starting at the least significant | |
2792 | bits of the bytes. */ | |
2793 | shift = (next_offset | |
2794 | - TREE_INT_CST_LOW (DECL_FIELD_BITPOS (field))); | |
2795 | /* Don't try to take a bunch of bits that cross | |
2796 | the word boundary in the INTEGER_CST. */ | |
2797 | if (shift < HOST_BITS_PER_INT | |
2798 | && shift + this_time > HOST_BITS_PER_INT) | |
2799 | { | |
2800 | this_time -= (HOST_BITS_PER_INT - shift); | |
2801 | shift = HOST_BITS_PER_INT; | |
2802 | } | |
2803 | ||
2804 | /* Now get the bits from the appropriate constant word. */ | |
2805 | if (shift < HOST_BITS_PER_INT) | |
2806 | value = TREE_INT_CST_LOW (val); | |
2807 | else if (shift < 2 * HOST_BITS_PER_INT) | |
2808 | { | |
2809 | value = TREE_INT_CST_HIGH (val); | |
2810 | shift -= HOST_BITS_PER_INT; | |
2811 | } | |
2812 | else | |
2813 | abort (); | |
2814 | byte |= ((value >> shift) & ((1 << this_time) - 1)) << next_bit; | |
2815 | #endif | |
2816 | next_offset += this_time; | |
2817 | byte_buffer_in_use = 1; | |
2818 | } | |
2819 | } | |
2820 | } | |
2821 | if (byte_buffer_in_use) | |
2822 | { | |
2823 | ASM_OUTPUT_BYTE (asm_out_file, byte); | |
2824 | total_bytes++; | |
2825 | } | |
2826 | if (total_bytes < size) | |
2827 | assemble_zeros (size - total_bytes); | |
2828 | } |