|
|
1.1 root 1: /* Convert RTL to assembler code and output it, for GNU compiler.
1.1.1.2 root 2: Copyright (C) 1987, 1988 Free Software Foundation, Inc.
1.1 root 3:
4: This file is part of GNU CC.
5:
6: GNU CC is distributed in the hope that it will be useful,
7: but WITHOUT ANY WARRANTY. No author or distributor
8: accepts responsibility to anyone for the consequences of using it
9: or for whether it serves any particular purpose or works at all,
10: unless he says so in writing. Refer to the GNU CC General Public
11: License for full details.
12:
13: Everyone is granted permission to copy, modify and redistribute
14: GNU CC, but only under the conditions described in the
15: GNU CC General Public License. A copy of this license is
16: supposed to have been given to you along with GNU CC so you
17: can know your rights and responsibilities. It should be in a
18: file named COPYING. Among other things, the copyright notice
19: and this notice must be preserved on all copies. */
20:
21:
22: /* This is the final pass of the compiler.
23: It looks at the rtl code for a function and outputs assembler code.
24:
1.1.1.2 root 25: Call `final_start_function' to output the assembler code for function entry,
26: `final' to output assembler code for some RTL code,
27: `final_end_function' to output assembler code for function exit.
28: If a function is compiled in several pieces, each piece is
29: output separately with `final'.
1.1 root 30:
31: Some optimizations are also done at this level.
32: Move instructions that were made unnecessary by good register allocation
1.1.1.2 root 33: are detected and omitted from the output. (Though most of these
34: are removed by the last jump pass.)
35:
1.1 root 36: Instructions to set the condition codes are omitted when it can be
37: seen that the condition codes already had the desired values.
1.1.1.2 root 38:
1.1 root 39: In some cases it is sufficient if the inherited condition codes
40: have related values, but this may require the following insn
41: (the one that tests the condition codes) to be modified.
42:
43: The code for the function prologue and epilogue are generated
44: directly as assembler code by the macros FUNCTION_PROLOGUE and
45: FUNCTION_EPILOGUE. Those instructions never exist as rtl. */
46:
47: #include <stdio.h>
48: #include "config.h"
49: #include "rtl.h"
50: #include "regs.h"
51: #include "insn-config.h"
52: #include "recog.h"
53: #include "conditions.h"
1.1.1.2 root 54: #include "gdbfiles.h"
1.1.1.4 root 55: #include "flags.h"
1.1.1.2 root 56:
1.1.1.3 root 57: /* Get N_SLINE and N_SOL from stab.h if we can expect the file to exist. */
1.1.1.4 root 58: #ifdef DBX_DEBUGGING_INFO
1.1.1.3 root 59: #include <stab.h>
60: #endif
61:
1.1.1.2 root 62: /* .stabd code for line number. */
63: #ifndef N_SLINE
64: #define N_SLINE 0x44
65: #endif
66:
67: /* .stabs code for included file name. */
68: #ifndef N_SOL
69: #define N_SOL 0x84
70: #endif
1.1 root 71:
72: #define min(A,B) ((A) < (B) ? (A) : (B))
73:
74: void output_asm_insn ();
1.1.1.6 root 75: static rtx alter_subreg ();
1.1 root 76: static int alter_cond ();
1.1.1.3 root 77: void output_asm_label ();
1.1 root 78: static void output_operand ();
1.1.1.2 root 79: void output_address ();
1.1 root 80: void output_addr_const ();
1.1.1.2 root 81: static void output_source_line ();
1.1 root 82:
1.1.1.4 root 83: /* the sdb debugger needs the line given as an offset from the beginning
84: of the current function -wfs*/
85:
86: extern int sdb_begin_function_line;
87:
88: /* Line number of last NOTE. */
89: static int last_linenum;
90:
1.1.1.9 ! root 91: /* Nonzero while outputting an `asm' with operands.
! 92: This means that inconsistencies are the user's fault, so don't abort. */
! 93: static int this_is_asm_operands;
! 94:
! 95: /* Number of operands of this insn, for an `asm' with operands. */
! 96: static int insn_noperands;
! 97:
1.1.1.4 root 98: /* Indexed by hard register, the name of the register for assembler code. */
99:
1.1 root 100: static char *reg_name[] = REGISTER_NAMES;
101:
102: /* File in which assembler code is being written. */
103:
1.1.1.2 root 104: extern FILE *asm_out_file;
1.1 root 105:
106: /* All the symbol-blocks (levels of scoping) in the compilation
107: are assigned sequence numbers in order of appearance of the
108: beginnings of the symbol-blocks. Both final and dbxout do this,
109: and assume that they will both give the same number to each block.
110: Final uses these sequence numbers to generate assembler label names
111: LBBnnn and LBEnnn for the beginning and end of the symbol-block.
112: Dbxout uses the sequence nunbers to generate references to the same labels
1.1.1.4 root 113: from the dbx debugging information.
114:
115: Sdb records this level at the beginning
116: of each function, so that when it recurses down the declarations, it may
117: find the current level, since it outputs the block beginning and endings
118: at the point in the asm file, where the blocks would begin and end. */
1.1 root 119:
1.1.1.4 root 120: int next_block_index;
1.1 root 121:
1.1.1.2 root 122: /* Chain of all `struct gdbfile's. */
123:
124: struct gdbfile *gdbfiles;
125:
126: /* `struct gdbfile' for the last file we wrote a line number for. */
127:
128: static struct gdbfile *current_gdbfile;
129:
130: /* Filenum to assign to the next distinct source file encountered. */
131:
132: static int next_gdb_filenum;
133:
1.1 root 134: /* This variable contains machine-dependent flags (defined in tm-...h)
135: set and examined by output routines
136: that describe how to interpret the condition codes properly. */
137:
138: CC_STATUS cc_status;
139:
1.1.1.2 root 140: /* During output of an insn, this contains a copy of cc_status
141: from before the insn. */
142:
143: CC_STATUS cc_prev_status;
144:
1.1 root 145: /* Last source file name mentioned in a NOTE insn. */
146:
147: static char *lastfile;
148:
149: /* Indexed by hardware reg number, is 1 if that register is ever
150: used in the current function.
151:
152: In life_analysis, or in stupid_life_analysis, this is set
153: up to record the hard regs used explicitly. Reload adds
154: in the hard regs used for holding pseudo regs. Final uses
155: it to generate the code in the function prologue and epilogue
156: to save and restore registers as needed. */
157:
158: char regs_ever_live[FIRST_PSEUDO_REGISTER];
159:
1.1.1.2 root 160: /* Nonzero means current function must be given a frame pointer.
161: Set in stmt.c if anything is allocated on the stack there.
162: Set in reload1.c if anything is allocated on the stack there. */
163:
164: int frame_pointer_needed;
165:
166: /* Assign unique numbers to labels generated for profiling. */
167:
168: int profile_label_no;
169:
170: /* Length so far allocated in PENDING_BLOCKS. */
171:
172: static int max_block_depth;
173:
174: /* Stack of sequence numbers of symbol-blocks of which we have seen the
175: beginning but not yet the end. Sequence numbers are assigned at
176: the beginning; this stack allows us to find the sequence number
177: of a block that is ending. */
1.1 root 178:
1.1.1.2 root 179: static int *pending_blocks;
180:
181: /* Number of elements currently in use in PENDING_BLOCKS. */
182:
183: static int block_depth;
184:
185: /* Nonzero if have enabled APP processing of our assembler output. */
186:
187: static int app_on;
1.1 root 188:
189: /* Initialize data in final at the beginning of a compilation. */
190:
191: void
192: init_final (filename)
193: char *filename;
194: {
195: next_block_index = 2;
196: lastfile = filename;
1.1.1.2 root 197: app_on = 0;
198: max_block_depth = 20;
199: pending_blocks = (int *) xmalloc (20 * sizeof *pending_blocks);
200: gdbfiles = 0;
201: next_gdb_filenum = 0;
1.1 root 202: }
203:
1.1.1.2 root 204: /* Enable APP processing of subsequent output.
205: Used before the output from an `asm' statement. */
206:
207: void
208: app_enable ()
209: {
210: if (! app_on)
211: {
212: fprintf (asm_out_file, ASM_APP_ON);
213: app_on = 1;
214: }
215: }
216:
217: /* Enable APP processing of subsequent output.
218: Called from varasm.c before most kinds of output. */
219:
220: void
221: app_disable ()
222: {
223: if (app_on)
224: {
225: fprintf (asm_out_file, ASM_APP_OFF);
226: app_on = 0;
227: }
228: }
229:
230: /* Output assembler code for the start of a function,
231: and initialize some of the variables in this file
232: for the new function. The label for the function and associated
233: assembler pseudo-ops have already been output in `assemble_function'.
234:
1.1 root 235: FIRST is the first insn of the rtl for the function being compiled.
236: FILE is the file to write assembler code to.
1.1.1.4 root 237: WRITE_SYMBOLS says which kind of debugging info to write (or none).
1.1 root 238: OPTIMIZE is nonzero if we should eliminate redundant
239: test and compare insns. */
240:
241: void
1.1.1.2 root 242: final_start_function (first, file, write_symbols, optimize)
1.1 root 243: rtx first;
244: FILE *file;
1.1.1.4 root 245: enum debugger write_symbols;
1.1 root 246: int optimize;
247: {
1.1.1.2 root 248: block_depth = 0;
1.1 root 249:
1.1.1.9 ! root 250: this_is_asm_operands = 0;
! 251:
1.1 root 252: /* Record beginning of the symbol-block that's the entire function. */
253:
1.1.1.4 root 254: if (write_symbols == GDB_DEBUG)
1.1 root 255: {
1.1.1.2 root 256: pending_blocks[block_depth++] = next_block_index;
1.1 root 257: fprintf (file, "\t.gdbbeg %d\n", next_block_index++);
258: }
259:
260: /* Initial line number is supposed to be output
261: before the function's prologue and label
262: so that the function's address will not appear to be
263: in the last statement of the preceding function. */
264: if (NOTE_LINE_NUMBER (first) != NOTE_INSN_DELETED)
1.1.1.2 root 265: output_source_line (file, first, write_symbols);
1.1 root 266:
267: #ifdef FUNCTION_PROLOGUE
268: /* First output the function prologue: code to set up the stack frame. */
269: FUNCTION_PROLOGUE (file, get_frame_size ());
270: #endif
271:
1.1.1.4 root 272: #ifdef SDB_DEBUGGING_INFO
273: next_block_index = 1;
274: if (write_symbols == SDB_DEBUG)
275: sdbout_begin_function (last_linenum);
276: #endif
277:
1.1.1.2 root 278: if (profile_flag)
1.1.1.4 root 279: {
1.1.1.2 root 280: int align = min (BIGGEST_ALIGNMENT, BITS_PER_WORD);
1.1.1.8 root 281: extern int current_function_returns_struct;
282: extern int current_function_needs_context;
283: int sval = current_function_returns_struct;
284: int cxt = current_function_needs_context;
1.1.1.6 root 285: data_section ();
1.1.1.2 root 286: ASM_OUTPUT_ALIGN (file, floor_log2 (align / BITS_PER_UNIT));
287: ASM_OUTPUT_INTERNAL_LABEL (file, "LP", profile_label_no);
288: assemble_integer_zero ();
1.1.1.6 root 289: text_section ();
1.1.1.8 root 290:
291: #ifdef STRUCT_VALUE_INCOMING_REGNUM
292: if (sval)
293: ASM_OUTPUT_REG_PUSH (file, STRUCT_VALUE_INCOMING_REGNUM);
294: #else
295: #ifdef STRUCT_VALUE_REGNUM
296: if (sval)
297: ASM_OUTPUT_REG_PUSH (file, STRUCT_VALUE_REGNUM);
298: #endif
299: #endif
300:
301: #if 0
302: #ifdef STATIC_CHAIN_INCOMING_REGNUM
303: if (cxt)
304: ASM_OUTPUT_REG_PUSH (file, STATIC_CHAIN_INCOMING_REGNUM);
305: #else
306: #ifdef STATIC_CHAIN_REGNUM
307: if (cxt)
308: ASM_OUTPUT_REG_PUSH (file, STATIC_CHAIN_REGNUM);
309: #endif
310: #endif
311: #endif /* 0 */
312:
1.1.1.2 root 313: FUNCTION_PROFILER (file, profile_label_no);
314: profile_label_no++;
315:
1.1.1.8 root 316: #if 0
317: #ifdef STATIC_CHAIN_INCOMING_REGNUM
318: if (cxt)
319: ASM_OUTPUT_REG_POP (file, STATIC_CHAIN_INCOMING_REGNUM);
320: #else
321: #ifdef STATIC_CHAIN_REGNUM
322: if (cxt)
323: ASM_OUTPUT_REG_POP (file, STATIC_CHAIN_REGNUM);
324: #endif
325: #endif
326: #endif /* 0 */
327:
328: #ifdef STRUCT_VALUE_INCOMING_REGNUM
329: if (sval)
330: ASM_OUTPUT_REG_POP (file, STRUCT_VALUE_INCOMING_REGNUM);
331: #else
332: #ifdef STRUCT_VALUE_REGNUM
333: if (sval)
334: ASM_OUTPUT_REG_POP (file, STRUCT_VALUE_REGNUM);
335: #endif
336: #endif
337: }
1.1.1.2 root 338: }
339:
340: /* Output assembler code for the end of a function.
341: For clarity, args are same as those of `final_start_function'
342: even though not all of them are needed. */
343:
344: void
345: final_end_function (first, file, write_symbols, optimize)
346: rtx first;
347: FILE *file;
1.1.1.4 root 348: enum debugger write_symbols;
1.1.1.2 root 349: int optimize;
350: {
351: if (app_on)
352: {
353: fprintf (file, ASM_APP_OFF);
354: app_on = 0;
355: }
356:
1.1.1.4 root 357: if (write_symbols == GDB_DEBUG)
1.1.1.2 root 358: fprintf (file, "\t.gdbend %d\n", pending_blocks[0]);
359:
1.1.1.4 root 360: #ifdef SDB_DEBUGGING_INFO
361: if (write_symbols == SDB_DEBUG)
362: sdbout_end_function (last_linenum);
363: #endif
364:
1.1.1.2 root 365: #ifdef FUNCTION_EPILOGUE
366: /* Finally, output the function epilogue:
367: code to restore the stack frame and return to the caller. */
368: FUNCTION_EPILOGUE (file, get_frame_size ());
369: #endif
370:
1.1.1.6 root 371: #ifdef SDB_DEBUGGING_INFO
372: if (write_symbols == SDB_DEBUG)
373: sdbout_end_epilogue ();
374: #endif
375:
1.1.1.2 root 376: /* If FUNCTION_EPILOGUE is not defined, then the function body
377: itself contains return instructions wherever needed. */
378: }
379:
380: /* Output assembler code for some insns: all or part of a function.
1.1.1.8 root 381: For description of args, see `final_start_function', above.
382:
383: PRESCAN is 1 if we are not really outputting,
384: just scanning as if we were outputting.
385: Prescanning deletes and rearranges insns just like ordinary output.
386: PRESCAN is -2 if we are outputting after having prescanned.
387: In this case, don't try to delete or rearrange insns
388: because that has already been done.
389: Prescanning is done only on certain machines. */
1.1.1.2 root 390:
391: void
1.1.1.8 root 392: final (first, file, write_symbols, optimize, prescan)
1.1.1.2 root 393: rtx first;
394: FILE *file;
1.1.1.4 root 395: enum debugger write_symbols;
1.1.1.2 root 396: int optimize;
1.1.1.8 root 397: int prescan;
1.1.1.2 root 398: {
399: register rtx insn;
400: register int i;
1.1 root 401:
1.1.1.8 root 402: init_recog ();
403:
404: CC_STATUS_INIT;
405:
1.1 root 406: for (insn = NEXT_INSN (first); insn; insn = NEXT_INSN (insn))
407: {
408: switch (GET_CODE (insn))
409: {
410: case NOTE:
1.1.1.8 root 411: if (prescan > 0)
412: break;
1.1.1.4 root 413: if (write_symbols == NO_DEBUG)
1.1 root 414: break;
415: if (NOTE_LINE_NUMBER (insn) == NOTE_INSN_FUNCTION_BEG)
416: abort (); /* Obsolete; shouldn't appear */
417: if (NOTE_LINE_NUMBER (insn) == NOTE_INSN_LOOP_BEG
418: || NOTE_LINE_NUMBER (insn) == NOTE_INSN_LOOP_END)
419: break;
420: if (NOTE_LINE_NUMBER (insn) == NOTE_INSN_DELETED)
421: break; /* An insn that was "deleted" */
1.1.1.2 root 422: if (app_on)
423: {
424: fprintf (file, ASM_APP_OFF);
425: app_on = 0;
426: }
1.1 root 427: if (NOTE_LINE_NUMBER (insn) == NOTE_INSN_BLOCK_BEG)
428: {
429: /* Beginning of a symbol-block. Assign it a sequence number
430: and push the number onto the stack PENDING_BLOCKS. */
431:
1.1.1.2 root 432: if (block_depth == max_block_depth)
1.1 root 433: {
434: /* PENDING_BLOCKS is full; make it longer. */
1.1.1.2 root 435: max_block_depth *= 2;
436: pending_blocks
437: = (int *) xrealloc (pending_blocks,
438: max_block_depth * sizeof (int));
1.1 root 439: }
1.1.1.2 root 440: pending_blocks[block_depth++] = next_block_index;
1.1 root 441:
442: /* Output debugging info about the symbol-block beginning. */
443:
1.1.1.4 root 444: #ifdef SDB_DEBUGGING_INFO
445: if (write_symbols == SDB_DEBUG)
446: sdbout_begin_block (file, last_linenum, next_block_index);
447: #endif
448: #ifdef DBX_DEBUGGING_INFO
449: if (write_symbols == DBX_DEBUG)
1.1.1.2 root 450: ASM_OUTPUT_INTERNAL_LABEL (file, "LBB", next_block_index);
1.1.1.4 root 451: #endif
452: if (write_symbols == GDB_DEBUG)
1.1.1.2 root 453: fprintf (file, "\t.gdbbeg %d\n", next_block_index);
1.1.1.4 root 454:
1.1.1.2 root 455: next_block_index++;
1.1 root 456: }
457: else if (NOTE_LINE_NUMBER (insn) == NOTE_INSN_BLOCK_END)
458: {
459: /* End of a symbol-block. Pop its sequence number off
460: PENDING_BLOCKS and output debugging info based on that. */
461:
1.1.1.4 root 462: --block_depth;
463:
464: #ifdef DBX_DEBUGGING_INFO
465: if (write_symbols == DBX_DEBUG && block_depth >= 0)
466: ASM_OUTPUT_INTERNAL_LABEL (file, "LBE",
467: pending_blocks[block_depth]);
468: #endif
469:
470: #ifdef SDB_DEBUGGING_INFO
471: if (write_symbols == SDB_DEBUG && block_depth >= 0)
472: sdbout_end_block (file, last_linenum);
473: #endif
474:
475: if (write_symbols == GDB_DEBUG)
476: fprintf (file, "\t.gdbend %d\n", pending_blocks[block_depth]);
1.1 root 477: }
1.1.1.2 root 478: else if (NOTE_LINE_NUMBER (insn) > 0)
1.1 root 479: /* This note is a line-number. */
1.1.1.2 root 480: output_source_line (file, insn, write_symbols);
1.1 root 481: break;
482:
483: case BARRIER:
484: break;
485:
486: case CODE_LABEL:
1.1.1.8 root 487: CC_STATUS_INIT;
488: if (prescan > 0)
489: break;
1.1.1.2 root 490: if (app_on)
491: {
492: fprintf (file, ASM_APP_OFF);
493: app_on = 0;
494: }
495: #ifdef ASM_OUTPUT_CASE_LABEL
496: if (NEXT_INSN (insn) != 0
497: && GET_CODE (NEXT_INSN (insn)) == JUMP_INSN)
498: {
499: rtx nextbody = PATTERN (NEXT_INSN (insn));
500:
501: /* If this label is followed by a jump-table,
502: output the two of them together in a special way. */
503:
504: if (GET_CODE (nextbody) == ADDR_VEC
505: || GET_CODE (nextbody) == ADDR_DIFF_VEC)
506: {
507: ASM_OUTPUT_CASE_LABEL (file, "L", CODE_LABEL_NUMBER (insn),
508: NEXT_INSN (insn));
509: break;
510: }
511: }
512: #endif
513:
514: ASM_OUTPUT_INTERNAL_LABEL (file, "L", CODE_LABEL_NUMBER (insn));
1.1 root 515: break;
516:
517: default:
518: {
519: register rtx body = PATTERN (insn);
520: int insn_code_number;
521: char *template;
522:
523: /* An INSN, JUMP_INSN or CALL_INSN.
1.1.1.2 root 524: First check for special kinds that recog doesn't recognize. */
1.1.1.4 root 525:
1.1 root 526: if (GET_CODE (body) == USE /* These are just declarations */
527: || GET_CODE (body) == CLOBBER)
528: break;
529: if (GET_CODE (body) == ASM_INPUT)
530: {
1.1.1.8 root 531: /* There's no telling what that did to the condition codes. */
532: CC_STATUS_INIT;
533: if (prescan > 0)
534: break;
1.1.1.2 root 535: if (! app_on)
536: {
537: fprintf (file, ASM_APP_ON);
538: app_on = 1;
539: }
540: fprintf (asm_out_file, "\t%s\n", XSTR (body, 0));
1.1 root 541: break;
542: }
543:
1.1.1.2 root 544: /* Detect `asm' construct with operands. */
545: if (asm_noperands (body) > 0)
546: {
547: int noperands = asm_noperands (body);
1.1.1.8 root 548: rtx *ops;
1.1.1.2 root 549: char *string;
550:
1.1.1.8 root 551: /* There's no telling what that did to the condition codes. */
552: CC_STATUS_INIT;
553: if (prescan > 0)
554: break;
555:
556: /* alloca won't do here, since only return from `final'
557: would free it. */
558: ops = (rtx *) malloc (noperands * sizeof (rtx));
559:
1.1.1.2 root 560: if (! app_on)
561: {
562: fprintf (file, ASM_APP_ON);
563: app_on = 1;
564: }
565:
566: /* Get out the operand values. */
567: string = decode_asm_operands (body, ops, 0, 0, 0);
1.1.1.9 ! root 568: /* Inhibit aborts on what would otherwise be compiler bugs. */
! 569: insn_noperands = noperands;
! 570: this_is_asm_operands = 1;
1.1.1.2 root 571: /* Output the insn using them. */
572: output_asm_insn (string, ops);
1.1.1.9 ! root 573: this_is_asm_operands = 0;
1.1.1.8 root 574: free (ops);
1.1.1.2 root 575: break;
576: }
577:
1.1.1.8 root 578: if (prescan <= 0 && app_on)
1.1.1.2 root 579: {
580: fprintf (file, ASM_APP_OFF);
581: app_on = 0;
582: }
583:
1.1 root 584: /* Detect insns that are really jump-tables
585: and output them as such. */
586:
587: if (GET_CODE (body) == ADDR_VEC)
588: {
589: register int vlen, idx;
1.1.1.8 root 590:
591: if (prescan > 0)
592: break;
593:
1.1 root 594: vlen = XVECLEN (body, 0);
595: for (idx = 0; idx < vlen; idx++)
1.1.1.4 root 596: ASM_OUTPUT_ADDR_VEC_ELT (file,
1.1 root 597: CODE_LABEL_NUMBER (XEXP (XVECEXP (body, 0, idx), 0)));
1.1.1.4 root 598: #ifdef ASM_OUTPUT_CASE_END
599: ASM_OUTPUT_CASE_END (file,
600: CODE_LABEL_NUMBER (PREV_INSN (insn)),
601: insn);
602: #endif
1.1 root 603: break;
604: }
605: if (GET_CODE (body) == ADDR_DIFF_VEC)
606: {
607: register int vlen, idx;
1.1.1.8 root 608:
609: if (prescan > 0)
610: break;
611:
1.1 root 612: vlen = XVECLEN (body, 1);
613: for (idx = 0; idx < vlen; idx++)
1.1.1.4 root 614: ASM_OUTPUT_ADDR_DIFF_ELT (file,
1.1 root 615: CODE_LABEL_NUMBER (XEXP (XVECEXP (body, 1, idx), 0)),
616: CODE_LABEL_NUMBER (XEXP (XEXP (body, 0), 0)));
1.1.1.4 root 617: #ifdef ASM_OUTPUT_CASE_END
1.1.1.7 root 618: ASM_OUTPUT_CASE_END (file,
619: CODE_LABEL_NUMBER (PREV_INSN (insn)),
620: insn);
1.1.1.4 root 621: #endif
1.1 root 622: break;
623: }
624:
625: /* We have a real machine instruction as rtl. */
626:
627: body = PATTERN (insn);
628:
1.1.1.4 root 629: /* Check for redundant test and compare instructions
1.1 root 630: (when the condition codes are already set up as desired).
631: This is done only when optimizing; if not optimizing,
632: it should be possible for the user to alter a variable
633: with the debugger in between statements
634: and the next statement should reexamine the variable
635: to compute the condition codes. */
636:
637: if (optimize
638: && GET_CODE (body) == SET
639: && GET_CODE (SET_DEST (body)) == CC0)
640: {
641: if (GET_CODE (SET_SRC (body)) == SUBREG)
1.1.1.6 root 642: SET_SRC (body) = alter_subreg (SET_SRC (body));
1.1 root 643: if ((cc_status.value1 != 0
644: && rtx_equal_p (SET_SRC (body), cc_status.value1))
645: || (cc_status.value2 != 0
646: && rtx_equal_p (SET_SRC (body), cc_status.value2)))
1.1.1.2 root 647: {
648: /* Don't delete insn if has an addressing side-effect */
1.1.1.6 root 649: if (! find_reg_note (insn, REG_INC, 0)
650: /* or if anything in it is volatile. */
651: && ! volatile_refs_p (PATTERN (insn)))
1.1.1.8 root 652: /* We don't really delete the insn; just ignore it. */
1.1.1.2 root 653: break;
654: }
1.1 root 655: }
656:
657: /* If this is a conditional branch, maybe modify it
658: if the cc's are in a nonstandard state
659: so that it accomplishes the same thing that it would
660: do straightforwardly if the cc's were set up normally. */
661:
662: if (cc_status.flags != 0
663: && GET_CODE (insn) == JUMP_INSN
664: && GET_CODE (body) == SET
665: && SET_DEST (body) == pc_rtx
1.1.1.8 root 666: && GET_CODE (SET_SRC (body)) == IF_THEN_ELSE
667: /* This is done during prescan; it is not done again
668: in final scan when prescan has been done. */
669: && prescan >= 0)
1.1 root 670: {
671: /* This function may alter the contents of its argument
672: and clear some of the cc_status.flags bits.
673: It may also return 1 meaning condition now always true
674: or -1 meaning condition now always false
675: or 2 meaning condition nontrivial but altered. */
676: register int result = alter_cond (XEXP (SET_SRC (body), 0));
677: /* If condition now has fixed value, replace the IF_THEN_ELSE
678: with its then-operand or its else-operand. */
679: if (result == 1)
680: SET_SRC (body) = XEXP (SET_SRC (body), 1);
681: if (result == -1)
682: SET_SRC (body) = XEXP (SET_SRC (body), 2);
683: /* The jump is now either unconditional or a no-op.
684: If it has become a no-op, don't try to output it.
685: (It would not be recognized.) */
686: if (SET_SRC (body) == pc_rtx)
1.1.1.8 root 687: {
688: PUT_CODE (insn, NOTE);
689: NOTE_LINE_NUMBER (insn) = NOTE_INSN_DELETED;
690: NOTE_SOURCE_FILE (insn) = 0;
691: break;
692: }
1.1 root 693: /* Rerecognize the instruction if it has changed. */
694: if (result != 0)
695: INSN_CODE (insn) = -1;
696: }
697:
1.1.1.8 root 698: #ifdef STORE_FLAG_VALUE
1.1 root 699: /* Make same adjustments to instructions that examine the
1.1.1.8 root 700: condition codes without jumping (if this machine has them). */
1.1 root 701:
702: if (cc_status.flags != 0
703: && GET_CODE (body) == SET)
704: switch (GET_CODE (SET_SRC (body)))
705: {
706: case GTU:
707: case GT:
708: case LTU:
709: case LT:
710: case GEU:
711: case GE:
712: case LEU:
713: case LE:
714: case EQ:
715: case NE:
716: {
1.1.1.8 root 717: register int result;
718: if (GET_CODE (XEXP (SET_SRC (body), 0)) != CC0)
719: break;
720: result = alter_cond (SET_SRC (body));
1.1 root 721: if (result == 1)
1.1.1.8 root 722: SET_SRC (body) = gen_rtx (CONST_INT, VOIDmode,
723: STORE_FLAG_VALUE);
1.1 root 724: if (result == -1)
725: SET_SRC (body) = const0_rtx;
726: if (result != 0)
727: INSN_CODE (insn) = -1;
728: }
729: }
1.1.1.8 root 730: #endif /* STORE_FLAG_VALUE */
1.1 root 731:
732: /* Try to recognize the instruction.
733: If successful, verify that the operands satisfy the
734: constraints for the instruction. Crash if they don't,
735: since `reload' should have changed them so that they do. */
736:
737: insn_code_number = recog_memoized (insn);
738: insn_extract (insn);
739: for (i = 0; i < insn_n_operands[insn_code_number]; i++)
740: if (GET_CODE (recog_operand[i]) == SUBREG)
1.1.1.6 root 741: recog_operand[i] = alter_subreg (recog_operand[i]);
1.1 root 742:
743: #ifdef REGISTER_CONSTRAINTS
744: if (! constrain_operands (insn_code_number))
745: abort ();
746: #endif
747:
1.1.1.4 root 748: /* Some target machines need to prescan each insn before
749: it is output. */
750:
751: #ifdef FINAL_PRESCAN_INSN
752: FINAL_PRESCAN_INSN (insn, recog_operand,
753: insn_n_operands[insn_code_number]);
754: #endif
755:
1.1.1.2 root 756: cc_prev_status = cc_status;
757:
1.1 root 758: /* Update `cc_status' for this instruction.
759: The instruction's output routine may change it further.
760: This should be a no-op for jump instructions
761: because their output routines may need to examine `cc_status',
762: below. That's ok since jump insns don't normally alter
763: the condition codes. */
764:
1.1.1.8 root 765: NOTICE_UPDATE_CC (body, insn);
1.1 root 766:
767: /* If the proper template needs to be chosen by some C code,
1.1.1.2 root 768: run that code and get the real template. */
1.1 root 769:
770: template = insn_template[insn_code_number];
771: if (template == 0)
1.1.1.5 root 772: template = (*insn_outfun[insn_code_number]) (recog_operand, insn);
1.1 root 773:
1.1.1.8 root 774: if (prescan > 0)
775: break;
776:
1.1 root 777: /* Output assembler code from the template. */
778:
779: output_asm_insn (template, recog_operand);
780: }
781: }
782: }
1.1.1.2 root 783: }
784:
785: /* Set up FILENAME as the current file for GDB line-number output. */
1.1 root 786:
1.1.1.2 root 787: void
788: set_current_gdbfile (filename)
789: char *filename;
790: {
791: register struct gdbfile *f;
792: for (f = gdbfiles; f; f = f->next)
793: if (!strcmp (f->name, filename))
794: break;
1.1 root 795:
1.1.1.2 root 796: if (!f)
797: {
798: f = (struct gdbfile *) permalloc (sizeof (struct gdbfile));
799: f->next = gdbfiles;
800: gdbfiles = f;
801: f->name = filename;
802: f->filenum = next_gdb_filenum++;
803: f->nlines = 0;
804: }
805: current_gdbfile = f;
806: lastfile = filename;
1.1 root 807: }
808:
1.1.1.2 root 809: /* Output debugging info to the assembler file FILE
810: based on the NOTE-insn INSN, assumed to be a line number. */
1.1 root 811:
1.1.1.2 root 812: static void
813: output_source_line (file, insn, write_symbols)
1.1 root 814: FILE *file;
815: rtx insn;
1.1.1.4 root 816: enum debugger write_symbols;
1.1 root 817: {
818: register char *filename = NOTE_SOURCE_FILE (insn);
1.1.1.4 root 819:
820: last_linenum = NOTE_LINE_NUMBER (insn);
821:
822: if (write_symbols == GDB_DEBUG)
1.1.1.2 root 823: {
824: /* Output GDB-format line number info. */
1.1 root 825:
1.1.1.2 root 826: /* If this is not the same source file as last time,
827: find or assign a GDB-file-number to this file. */
828: if (filename && (lastfile == 0 || strcmp (filename, lastfile)
829: || current_gdbfile == 0))
830: set_current_gdbfile (filename);
831:
832: ++current_gdbfile->nlines;
833: fprintf (file, "\t.gdbline %d,%d\n",
834: current_gdbfile->filenum, NOTE_LINE_NUMBER (insn));
835: }
1.1.1.4 root 836:
1.1.1.6 root 837: if (write_symbols == SDB_DEBUG || write_symbols == DBX_DEBUG)
1.1.1.4 root 838: {
1.1.1.6 root 839: #ifdef SDB_DEBUGGING_INFO
840: if (write_symbols == SDB_DEBUG
841: /* COFF can't handle multiple source files--lose, lose. */
842: && !strcmp (filename, main_input_filename))
843: {
1.1.1.4 root 844: #ifdef ASM_OUTPUT_SOURCE_LINE
1.1.1.6 root 845: ASM_OUTPUT_SOURCE_LINE (file, last_linenum);
1.1.1.4 root 846: #else
1.1.1.6 root 847: fprintf (file, "\t.ln\t%d\n",
848: (sdb_begin_function_line
849: ? last_linenum - sdb_begin_function_line : 1));
1.1.1.4 root 850: #endif
1.1.1.6 root 851: }
1.1.1.4 root 852: #endif
853:
854: #ifdef DBX_DEBUGGING_INFO
1.1.1.6 root 855: if (write_symbols == DBX_DEBUG)
1.1.1.4 root 856: {
1.1.1.6 root 857: /* Write DBX line number data. */
858:
859: if (filename && (lastfile == 0 || strcmp (filename, lastfile)))
860: {
1.1.1.2 root 861: #ifdef ASM_OUTPUT_SOURCE_FILENAME
1.1.1.6 root 862: ASM_OUTPUT_SOURCE_FILENAME (file, filename);
1.1.1.2 root 863: #else
1.1.1.6 root 864: fprintf (file, "\t.stabs \"%s\",%d,0,0,Ltext\n",
865: filename, N_SOL);
1.1.1.2 root 866: #endif
1.1.1.6 root 867: lastfile = filename;
868: }
1.1.1.4 root 869: }
1.1.1.2 root 870:
871: #ifdef ASM_OUTPUT_SOURCE_LINE
872: ASM_OUTPUT_SOURCE_LINE (file, NOTE_LINE_NUMBER (insn));
873: #else
874: fprintf (file, "\t.stabd %d,0,%d\n",
875: N_SLINE, NOTE_LINE_NUMBER (insn));
876: #endif
1.1.1.4 root 877: #endif /* DBX_DEBUGGING_INFO */
1.1.1.2 root 878: }
1.1 root 879: }
880:
1.1.1.2 root 881: /* If X is a SUBREG, replace it with a REG or a MEM,
882: based on the thing it is a subreg of. */
1.1 root 883:
1.1.1.6 root 884: static rtx
1.1 root 885: alter_subreg (x)
886: register rtx x;
887: {
888: register rtx y = SUBREG_REG (x);
889: if (GET_CODE (y) == SUBREG)
1.1.1.6 root 890: y = alter_subreg (y);
1.1 root 891:
892: if (GET_CODE (y) == REG)
893: {
894: /* If the containing reg really gets a hard reg, so do we. */
895: PUT_CODE (x, REG);
896: REGNO (x) = REGNO (y) + SUBREG_WORD (x);
897: }
898: else if (GET_CODE (y) == MEM)
899: {
1.1.1.2 root 900: register int offset = SUBREG_WORD (x) * UNITS_PER_WORD;
1.1 root 901: #ifdef BYTES_BIG_ENDIAN
1.1.1.2 root 902: offset -= (min (UNITS_PER_WORD, GET_MODE_SIZE (GET_MODE (x)))
903: - min (UNITS_PER_WORD, GET_MODE_SIZE (GET_MODE (y))));
1.1 root 904: #endif
905: PUT_CODE (x, MEM);
906: XEXP (x, 0) = plus_constant (XEXP (y, 0), offset);
907: }
1.1.1.6 root 908: else if (GET_CODE (y) == CONST_DOUBLE)
909: return y;
910:
911: return x;
1.1 root 912: }
913:
1.1.1.2 root 914: /* Do alter_subreg on all the SUBREGs contained in X. */
1.1 root 915:
1.1.1.2 root 916: static rtx
917: walk_alter_subreg (x)
918: rtx x;
919: {
920: switch (GET_CODE (x))
1.1 root 921: {
1.1.1.2 root 922: case PLUS:
923: case MULT:
924: XEXP (x, 0) = walk_alter_subreg (XEXP (x, 0));
925: XEXP (x, 1) = walk_alter_subreg (XEXP (x, 1));
926: break;
927:
928: case MEM:
929: XEXP (x, 0) = walk_alter_subreg (XEXP (x, 0));
930: break;
931:
932: case SUBREG:
1.1.1.6 root 933: return alter_subreg (x);
1.1 root 934: }
935:
1.1.1.2 root 936: return x;
1.1 root 937: }
938:
939: /* Given BODY, the body of a jump instruction, alter the jump condition
940: as required by the bits that are set in cc_status.flags.
941: Not all of the bits there can be handled at this level in all cases.
942:
943: The value is normally 0.
944: 1 means that the condition has become always true.
1.1.1.8 root 945: -1 means that the condition has become always false.
946: 2 means that COND has been altered. */
1.1 root 947:
948: static int
949: alter_cond (cond)
950: register rtx cond;
951: {
952: int value = 0;
953:
954: if (cc_status.flags & CC_REVERSED)
955: {
956: value = 2;
957: switch (GET_CODE (cond))
958: {
959: case LE:
960: PUT_CODE (cond, GE);
961: break;
962: case GE:
963: PUT_CODE (cond, LE);
964: break;
965: case LT:
966: PUT_CODE (cond, GT);
967: break;
968: case GT:
969: PUT_CODE (cond, LT);
970: break;
971: case LEU:
972: PUT_CODE (cond, GEU);
973: break;
974: case GEU:
975: PUT_CODE (cond, LEU);
976: break;
977: case LTU:
978: PUT_CODE (cond, GTU);
979: break;
980: case GTU:
981: PUT_CODE (cond, LTU);
982: break;
983: }
984: }
985:
1.1.1.8 root 986: if (cc_status.flags & CC_NOT_POSITIVE)
1.1 root 987: switch (GET_CODE (cond))
988: {
989: case LE:
990: case LEU:
991: case GEU:
992: /* Jump becomes unconditional. */
993: return 1;
994:
995: case GT:
996: case GTU:
997: case LTU:
998: /* Jump becomes no-op. */
999: return -1;
1000:
1001: case GE:
1002: PUT_CODE (cond, EQ);
1003: value = 2;
1004: break;
1005:
1006: case LT:
1007: PUT_CODE (cond, NE);
1008: value = 2;
1009: break;
1010: }
1011:
1.1.1.8 root 1012: if (cc_status.flags & CC_NOT_NEGATIVE)
1.1 root 1013: switch (GET_CODE (cond))
1014: {
1015: case GE:
1016: case GEU:
1017: /* Jump becomes unconditional. */
1018: return 1;
1019:
1020: case LT:
1021: case LTU:
1022: /* Jump becomes no-op. */
1023: return -1;
1024:
1025: case LE:
1026: case LEU:
1027: PUT_CODE (cond, EQ);
1028: value = 2;
1029: break;
1030:
1031: case GT:
1032: case GTU:
1033: PUT_CODE (cond, NE);
1034: value = 2;
1035: break;
1036: }
1037:
1.1.1.8 root 1038: if (cc_status.flags & CC_NO_OVERFLOW)
1.1 root 1039: switch (GET_CODE (cond))
1040: {
1041: case GEU:
1042: /* Jump becomes unconditional. */
1043: return 1;
1044:
1045: case LEU:
1046: PUT_CODE (cond, EQ);
1047: value = 2;
1048: break;
1049:
1050: case GTU:
1051: PUT_CODE (cond, NE);
1052: value = 2;
1053: break;
1054:
1055: case LTU:
1056: /* Jump becomes no-op. */
1057: return -1;
1058: }
1059:
1.1.1.8 root 1060: if (cc_status.flags & (CC_Z_IN_NOT_N | CC_Z_IN_N))
1061: switch (GET_CODE (cond))
1062: {
1063: case LE:
1064: case LEU:
1065: case GE:
1066: case GEU:
1067: case LT:
1068: case LTU:
1069: case GT:
1070: case GTU:
1071: abort ();
1072:
1073: case NE:
1074: PUT_CODE (cond, cc_status.flags & CC_Z_IN_N ? GE : LT);
1075: value = 2;
1076: break;
1077:
1078: case EQ:
1079: PUT_CODE (cond, cc_status.flags & CC_Z_IN_N ? LT : GE);
1080: value = 2;
1081: break;
1082: }
1083:
1.1 root 1084: return value;
1085: }
1086:
1.1.1.9 ! root 1087: /* Report inconsistency between the assembler template and the operands.
! 1088: In an `asm', it's the user's fault; otherwise, the compiler's fault. */
! 1089:
! 1090: static void
! 1091: output_operand_lossage (str)
! 1092: char *str;
! 1093: {
! 1094: if (this_is_asm_operands)
! 1095: {
! 1096: error ("invalid `asm' above: %s", str);
! 1097: fprintf (asm_out_file, "!!error here!!");
! 1098: }
! 1099: else
! 1100: abort ();
! 1101: }
! 1102:
1.1 root 1103: /* Output of assembler code from a template, and its subroutines. */
1104:
1105: /* Output text from TEMPLATE to the assembler output file,
1106: obeying %-directions to substitute operands taken from
1107: the vector OPERANDS.
1108:
1109: %N (for N a digit) means print operand N in usual manner.
1110: %lN means require operand N to be a CODE_LABEL or LABEL_REF
1111: and print the label name with no punctuation.
1112: %cN means require operand N to be a constant
1113: and print the constant expression with no punctuation.
1114: %aN means expect operand N to be a memory address
1115: (not a memory reference!) and print a reference
1116: to that address.
1117: %nN means expect operand N to be a constant
1118: and print a constant expression for minus the value
1119: of the operand, with no other punctuation. */
1120:
1121: void
1122: output_asm_insn (template, operands)
1123: char *template;
1124: rtx *operands;
1125: {
1126: register char *p;
1127: register int c;
1128:
1.1.1.2 root 1129: /* An insn may return a null string template
1130: in a case where no assembler code is needed. */
1131: if (*template == 0)
1132: return;
1133:
1.1 root 1134: p = template;
1.1.1.2 root 1135: putc ('\t', asm_out_file);
1136:
1137: #ifdef ASM_OUTPUT_OPCODE
1138: ASM_OUTPUT_OPCODE (asm_out_file, p);
1139: #endif
1140:
1.1 root 1141: while (c = *p++)
1142: {
1.1.1.2 root 1143: #ifdef ASM_OUTPUT_OPCODE
1144: if (c == '\n')
1.1 root 1145: {
1.1.1.2 root 1146: putc (c, asm_out_file);
1147: while ((c = *p) == '\t')
1.1 root 1148: {
1.1.1.2 root 1149: putc (c, asm_out_file);
1150: p++;
1.1 root 1151: }
1.1.1.2 root 1152: ASM_OUTPUT_OPCODE (asm_out_file, p);
1153: }
1154: else
1155: #endif
1156: if (c != '%')
1157: putc (c, asm_out_file);
1158: else
1159: {
1160: /* %% outputs a single %. */
1161: if (*p == '%')
1.1 root 1162: {
1.1.1.2 root 1163: p++;
1164: putc (c, asm_out_file);
1.1 root 1165: }
1.1.1.2 root 1166: /* % followed by a letter and some digits
1167: outputs an operand in a special way depending on the letter.
1168: Letters `acln' are implemented here.
1169: Other letters are passed to `output_operand' so that
1170: the PRINT_OPERAND macro can define them. */
1171: else if ((*p >= 'a' && *p <= 'z')
1172: || (*p >= 'A' && *p <= 'Z'))
1.1 root 1173: {
1.1.1.2 root 1174: int letter = *p++;
1175: c = atoi (p);
1176:
1.1.1.9 ! root 1177: if (this_is_asm_operands
! 1178: && c >= (unsigned) insn_noperands && *p >= '0' && *p <= '9')
! 1179: output_operand_lossage ("operand number out of range");
! 1180: else if (letter == 'l')
1.1.1.2 root 1181: output_asm_label (operands[c]);
1182: else if (letter == 'a')
1183: output_address (operands[c]);
1184: else if (letter == 'c')
1185: {
1186: if (CONSTANT_ADDRESS_P (operands[c]))
1187: output_addr_const (asm_out_file, operands[c]);
1188: else
1189: output_operand (operands[c], 'c');
1190: }
1191: else if (letter == 'n')
1.1 root 1192: {
1.1.1.2 root 1193: if (GET_CODE (operands[c]) == CONST_INT)
1194: fprintf (asm_out_file, "%d", - INTVAL (operands[c]));
1195: else
1196: {
1197: putc ('-', asm_out_file);
1198: output_addr_const (asm_out_file, operands[c]);
1199: }
1.1 root 1200: }
1.1.1.2 root 1201: else if (*p >= '0' && *p <= '9')
1202: output_operand (operands[c], letter);
1203: else
1204: /* No operand-number follows the letter. */
1205: output_operand (0, letter);
1206:
1207: while ((c = *p) >= '0' && c <= '9') p++;
1.1 root 1208: }
1.1.1.2 root 1209: /* % followed by a digit outputs an operand the default way. */
1210: else if (*p >= '0' && *p <= '9')
1.1 root 1211: {
1212: c = atoi (p);
1.1.1.9 ! root 1213: if (this_is_asm_operands && c >= (unsigned) insn_noperands)
! 1214: output_operand_lossage ("operand number out of range");
! 1215: else
! 1216: output_operand (operands[c], 0);
1.1.1.2 root 1217: while ((c = *p) >= '0' && c <= '9') p++;
1.1 root 1218: }
1.1.1.2 root 1219: /* % followed by punctuation: output something for that
1220: punctuation character alone, with no operand.
1221: The PRINT_OPERAND macro decides what is actually done. */
1222: else
1223: output_operand (0, *p++);
1.1 root 1224: }
1225: }
1226:
1.1.1.2 root 1227: putc ('\n', asm_out_file);
1.1 root 1228: }
1.1.1.9 ! root 1229:
1.1.1.3 root 1230: /* Output a LABEL_REF, or a bare CODE_LABEL, as an assembler symbol. */
1231:
1232: void
1.1 root 1233: output_asm_label (x)
1234: rtx x;
1235: {
1.1.1.2 root 1236: char buf[20];
1237:
1.1 root 1238: if (GET_CODE (x) == LABEL_REF)
1.1.1.2 root 1239: ASM_GENERATE_INTERNAL_LABEL (buf, "L", CODE_LABEL_NUMBER (XEXP (x, 0)));
1.1 root 1240: else if (GET_CODE (x) == CODE_LABEL)
1.1.1.2 root 1241: ASM_GENERATE_INTERNAL_LABEL (buf, "L", CODE_LABEL_NUMBER (x));
1.1 root 1242: else
1.1.1.9 ! root 1243: output_operand_lossage ("`%l' operand isn't a label");
1.1.1.2 root 1244:
1245: assemble_name (asm_out_file, buf);
1.1 root 1246: }
1247:
1248: /* Print operand X using machine-dependent assembler syntax.
1.1.1.2 root 1249: The macro PRINT_OPERAND is defined just to control this function.
1250: CODE is a non-digit that preceded the operand-number in the % spec,
1251: such as 'z' if the spec was `%z3'. CODE is 0 if there was no char
1252: between the % and the digits.
1253: When CODE is a non-letter, X is 0.
1254:
1255: The meanings of the letters are machine-dependent and controlled
1256: by PRINT_OPERAND. */
1.1 root 1257:
1258: static void
1.1.1.2 root 1259: output_operand (x, code)
1.1 root 1260: rtx x;
1.1.1.2 root 1261: int code;
1.1 root 1262: {
1.1.1.2 root 1263: if (x && GET_CODE (x) == SUBREG)
1.1.1.6 root 1264: x = alter_subreg (x);
1.1.1.2 root 1265: PRINT_OPERAND (asm_out_file, x, code);
1.1 root 1266: }
1267:
1268: /* Print a memory reference operand for address X
1269: using machine-dependent assembler syntax.
1270: The macro PRINT_OPERAND_ADDRESS exists just to control this function. */
1271:
1.1.1.2 root 1272: void
1.1 root 1273: output_address (x)
1274: rtx x;
1275: {
1.1.1.2 root 1276: walk_alter_subreg (x);
1277: PRINT_OPERAND_ADDRESS (asm_out_file, x);
1.1 root 1278: }
1279:
1280: /* Print an integer constant expression in assembler syntax.
1281: Addition and subtraction are the only arithmetic
1282: that may appear in these expressions. */
1283:
1284: void
1285: output_addr_const (file, x)
1286: FILE *file;
1287: rtx x;
1288: {
1.1.1.2 root 1289: char buf[20];
1290:
1.1 root 1291: restart:
1292: switch (GET_CODE (x))
1293: {
1294: case SYMBOL_REF:
1.1.1.2 root 1295: assemble_name (file, XSTR (x, 0));
1.1 root 1296: break;
1297:
1298: case LABEL_REF:
1.1.1.2 root 1299: ASM_GENERATE_INTERNAL_LABEL (buf, "L", CODE_LABEL_NUMBER (XEXP (x, 0)));
1300: assemble_name (asm_out_file, buf);
1.1 root 1301: break;
1302:
1303: case CODE_LABEL:
1.1.1.2 root 1304: ASM_GENERATE_INTERNAL_LABEL (buf, "L", CODE_LABEL_NUMBER (x));
1305: assemble_name (asm_out_file, buf);
1.1 root 1306: break;
1307:
1308: case CONST_INT:
1309: fprintf (file, "%d", INTVAL (x));
1310: break;
1311:
1312: case CONST:
1313: x = XEXP (x, 0);
1314: goto restart;
1315:
1.1.1.8 root 1316: case CONST_DOUBLE:
1317: if (GET_MODE (x) == DImode)
1318: {
1319: /* We can use %d if the number is <32 bits and positive. */
1320: if (XINT (x, 1) || XINT (x, 0) < 0)
1321: fprintf (file, "0x%x%08x", XINT (x, 1), XINT (x, 0));
1322: else
1323: fprintf (file, "%d", XINT (x, 0));
1324: }
1325: else
1326: /* We can't handle floating point constants;
1327: PRINT_OPERAND must handle them. */
1.1.1.9 ! root 1328: output_operand_lossage ("floating constant misused");
1.1.1.8 root 1329: break;
1330:
1.1 root 1331: case PLUS:
1.1.1.4 root 1332: /* Some assemblers need integer constants to appear last (eg masm). */
1333: if (GET_CODE (XEXP (x, 0)) == CONST_INT)
1334: {
1335: output_addr_const (file, XEXP (x, 1));
1336: fprintf (file, "+");
1337: output_addr_const (file, XEXP (x, 0));
1338: }
1339: else
1340: {
1341: output_addr_const (file, XEXP (x, 0));
1342: fprintf (file, "+");
1343: output_addr_const (file, XEXP (x, 1));
1344: }
1.1 root 1345: break;
1346:
1347: case MINUS:
1348: output_addr_const (file, XEXP (x, 0));
1349: fprintf (file, "-");
1350: output_addr_const (file, XEXP (x, 1));
1351: break;
1352:
1353: default:
1.1.1.9 ! root 1354: output_operand_lossage ("invalid expression as operand");
1.1 root 1355: }
1356: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.