OSDN Git Service

* target.h (targetm.calls.arg_partial_bytes): New.
[pf3gnuchains/gcc-fork.git] / gcc / config / cris / cris.c
1 /* Definitions for GCC.  Part of the machine description for CRIS.
2    Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004
3    Free Software Foundation, Inc.
4    Contributed by Axis Communications.  Written by Hans-Peter Nilsson.
5
6 This file is part of GCC.
7
8 GCC is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
11 any later version.
12
13 GCC is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING.  If not, write to
20 the Free Software Foundation, 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA.  */
22
23 #include "config.h"
24 #include "system.h"
25 #include "coretypes.h"
26 #include "tm.h"
27 #include "rtl.h"
28 #include "regs.h"
29 #include "hard-reg-set.h"
30 #include "real.h"
31 #include "insn-config.h"
32 #include "conditions.h"
33 #include "insn-attr.h"
34 #include "flags.h"
35 #include "tree.h"
36 #include "expr.h"
37 #include "except.h"
38 #include "function.h"
39 #include "toplev.h"
40 #include "recog.h"
41 #include "tm_p.h"
42 #include "debug.h"
43 #include "output.h"
44 #include "target.h"
45 #include "target-def.h"
46 #include "ggc.h"
47 #include "optabs.h"
48
49 /* Usable when we have an amount to add or subtract, and want the
50    optimal size of the insn.  */
51 #define ADDITIVE_SIZE_MODIFIER(size) \
52  ((size) <= 63 ? "q" : (size) <= 255 ? "u.b" : (size) <= 65535 ? "u.w" : ".d")
53
54 #define ASSERT_PLT_UNSPEC(x)                                    \
55   do                                                            \
56     {                                                           \
57       if (XEXP (x, 1) != NULL_RTX                               \
58           || (GET_CODE (XVECEXP (x, 0, 0)) != SYMBOL_REF        \
59               && GET_CODE (XVECEXP (x, 0, 0)) != LABEL_REF))    \
60         abort ();                                               \
61     } while (0)
62
63 #define LOSE_AND_RETURN(msgid, x)                       \
64   do                                            \
65     {                                           \
66       cris_operand_lossage (msgid, x);          \
67       return;                                   \
68     } while (0)
69
70 /* Per-function machine data.  */
71 struct machine_function GTY(())
72  {
73    int needs_return_address_on_stack;
74  };
75
76 /* This little fix suppresses the 'u' or 's' when '%e' in assembly
77    pattern.  */
78 static char cris_output_insn_is_bound = 0;
79
80 /* This one suppresses printing out the "rPIC+" in
81    "rPIC+sym:GOTOFF+offset" when doing PIC.  For a PLT symbol, it
82    suppresses outputting it as [rPIC+sym:GOTPLT] and outputs similarly
83    just the "sym:GOTOFF" part.  */
84 static int cris_pic_sympart_only = 0;
85
86 /* Fix for reg_overlap_mentioned_p.  */
87 static int cris_reg_overlap_mentioned_p (rtx, rtx);
88
89 static void cris_print_base (rtx, FILE *);
90
91 static void cris_print_index (rtx, FILE *);
92
93 static struct machine_function * cris_init_machine_status (void);
94
95 static rtx cris_struct_value_rtx (tree, int);
96
97 static void cris_setup_incoming_varargs (CUMULATIVE_ARGS *, enum machine_mode,
98                                          tree type, int *, int);
99
100 static int cris_initial_frame_pointer_offset (void);
101
102 static int saved_regs_mentioned (rtx);
103
104 static void cris_target_asm_function_prologue (FILE *, HOST_WIDE_INT);
105
106 static void cris_target_asm_function_epilogue (FILE *, HOST_WIDE_INT);
107
108 static void cris_operand_lossage (const char *, rtx);
109
110 static void cris_asm_output_mi_thunk
111   (FILE *, tree, HOST_WIDE_INT, HOST_WIDE_INT, tree);
112
113 static void cris_file_start (void);
114 static void cris_init_libfuncs (void);
115
116 static bool cris_rtx_costs (rtx, int, int, int *);
117 static int cris_address_cost (rtx);
118 static bool cris_pass_by_reference (CUMULATIVE_ARGS *, enum machine_mode,
119                                     tree, bool);
120 static int cris_arg_partial_bytes (CUMULATIVE_ARGS *, enum machine_mode,
121                                    tree, bool);
122
123 /* The function cris_target_asm_function_epilogue puts the last insn to
124    output here.  It always fits; there won't be a symbol operand.  Used in
125    delay_slots_for_epilogue and function_epilogue.  */
126 static char save_last[80];
127
128 /* This is the argument from the "-max-stack-stackframe=" option.  */
129 const char *cris_max_stackframe_str;
130
131 /* This is the argument from the "-march=" option.  */
132 const char *cris_cpu_str;
133
134 /* This is the argument from the "-mtune=" option.  */
135 const char *cris_tune_str;
136
137 /* This is the argument from the "-melinux-stacksize=" option.  */
138 const char *cris_elinux_stacksize_str;
139
140 /* This is the parsed result of the "-max-stack-stackframe=" option.  If
141    it (still) is zero, then there was no such option given.  */
142 int cris_max_stackframe = 0;
143
144 /* This is the parsed result of the "-march=" option, if given.  */
145 int cris_cpu_version = CRIS_DEFAULT_CPU_VERSION;
146
147 #undef TARGET_ASM_ALIGNED_HI_OP
148 #define TARGET_ASM_ALIGNED_HI_OP "\t.word\t"
149 #undef TARGET_ASM_ALIGNED_SI_OP
150 #define TARGET_ASM_ALIGNED_SI_OP "\t.dword\t"
151 #undef TARGET_ASM_ALIGNED_DI_OP
152 #define TARGET_ASM_ALIGNED_DI_OP "\t.quad\t"
153
154 /* We need to define these, since the 2byte, 4byte, 8byte op:s are only
155    available in ELF.  These "normal" pseudos do not have any alignment
156    constraints or side-effects.  */
157 #undef TARGET_ASM_UNALIGNED_HI_OP
158 #define TARGET_ASM_UNALIGNED_HI_OP TARGET_ASM_ALIGNED_HI_OP
159
160 #undef TARGET_ASM_UNALIGNED_SI_OP
161 #define TARGET_ASM_UNALIGNED_SI_OP TARGET_ASM_ALIGNED_SI_OP
162
163 #undef TARGET_ASM_UNALIGNED_DI_OP
164 #define TARGET_ASM_UNALIGNED_DI_OP TARGET_ASM_ALIGNED_DI_OP
165
166 #undef TARGET_ASM_FUNCTION_PROLOGUE
167 #define TARGET_ASM_FUNCTION_PROLOGUE cris_target_asm_function_prologue
168
169 #undef TARGET_ASM_FUNCTION_EPILOGUE
170 #define TARGET_ASM_FUNCTION_EPILOGUE cris_target_asm_function_epilogue
171
172 #undef TARGET_ASM_OUTPUT_MI_THUNK
173 #define TARGET_ASM_OUTPUT_MI_THUNK cris_asm_output_mi_thunk
174 #undef TARGET_ASM_CAN_OUTPUT_MI_THUNK
175 #define TARGET_ASM_CAN_OUTPUT_MI_THUNK default_can_output_mi_thunk_no_vcall
176
177 #undef TARGET_ASM_FILE_START
178 #define TARGET_ASM_FILE_START cris_file_start
179
180 #undef TARGET_INIT_LIBFUNCS
181 #define TARGET_INIT_LIBFUNCS cris_init_libfuncs
182
183 #undef TARGET_RTX_COSTS
184 #define TARGET_RTX_COSTS cris_rtx_costs
185 #undef TARGET_ADDRESS_COST
186 #define TARGET_ADDRESS_COST cris_address_cost
187
188 #undef TARGET_PROMOTE_FUNCTION_ARGS
189 #define TARGET_PROMOTE_FUNCTION_ARGS hook_bool_tree_true
190 #undef TARGET_STRUCT_VALUE_RTX
191 #define TARGET_STRUCT_VALUE_RTX cris_struct_value_rtx
192 #undef TARGET_SETUP_INCOMING_VARARGS
193 #define TARGET_SETUP_INCOMING_VARARGS cris_setup_incoming_varargs
194 #undef TARGET_PASS_BY_REFERENCE
195 #define TARGET_PASS_BY_REFERENCE cris_pass_by_reference
196 #undef TARGET_ARG_PARTIAL_BYTES
197 #define TARGET_ARG_PARTIAL_BYTES cris_arg_partial_bytes
198
199 struct gcc_target targetm = TARGET_INITIALIZER;
200
201 /* Predicate functions.  */
202
203 /* This checks a part of an address, the one that is not a plain register
204    for an addressing mode using BDAP.
205    Allowed operands is either:
206    a) a register
207    b) a CONST operand (but not a symbol when generating PIC)
208    c) a [r] or [r+] in SImode, or sign-extend from HI or QI.  */
209
210 int
211 cris_bdap_operand (rtx op, enum machine_mode mode)
212 {
213   register enum rtx_code code = GET_CODE (op);
214
215   if (mode != SImode && (mode != VOIDmode || GET_MODE (op) != VOIDmode))
216     return 0;
217
218   /* Just return whether this is a simple register or constant.  */
219   if (register_operand (op, mode)
220       || (CONSTANT_P (op) && !(flag_pic && cris_symbol (op))))
221     return 1;
222
223   /* Is it a [r] or possibly a [r+]?  */
224   if (code == MEM)
225     {
226       rtx tem = XEXP (op, 0);
227
228       if (mode == SImode
229           && (register_operand (tem, SImode)
230               || (GET_CODE (tem) == POST_INC
231                   && register_operand (XEXP (tem, 0), SImode))))
232         return 1;
233       else
234         return 0;
235     }
236
237   /* Perhaps a sign-extended mem: [r].(b|w) or [r+].(b|w)?  */
238   if (code == SIGN_EXTEND)
239     {
240       rtx tem = XEXP (op, 0);
241
242       if (GET_CODE (tem) != MEM)
243         return 0;
244
245       tem = XEXP (tem, 0);
246       if (mode == SImode
247           && (register_operand (tem, SImode)
248               || (GET_CODE (tem) == POST_INC
249                   && register_operand (XEXP (tem, 0), SImode))))
250         return 1;
251       else
252         return 0;
253     }
254
255   return 0;
256 }
257
258 /* This is similar to cris_bdap_operand:
259    It checks a part of an address, the one that is not a plain register
260    for an addressing mode using BDAP *or* BIAP.
261    Allowed operands is either:
262    a) a register
263    b) a CONST operand (but not a symbol when generating PIC)
264    c) a mult of (1, 2 or 4) and a register
265    d) a [r] or [r+] in SImode, or sign-extend from HI or QI.  */
266
267 int
268 cris_bdap_biap_operand (rtx op, enum machine_mode mode)
269 {
270   register enum rtx_code code = GET_CODE (op);
271   rtx reg;
272   rtx val;
273
274   /* Check for bdap operand.  */
275   if (cris_bdap_operand (op, mode))
276     return 1;
277
278   if (mode != SImode && (mode != VOIDmode || GET_MODE (op) != VOIDmode))
279     return 0;
280
281   /* Check that we're looking at a BIAP operand.  */
282   if (code != MULT)
283     return 0;
284
285   /* Canonicalize register and multiplicand.  */
286   if (GET_CODE (XEXP (op, 0)) == CONST_INT)
287     {
288       val = XEXP (op, 0);
289       reg = XEXP (op, 1);
290     }
291   else
292     {
293       val = XEXP (op, 1);
294       reg = XEXP (op, 0);
295     }
296
297   /* Check that the operands are correct after canonicalization.  */
298   if (! register_operand (reg, SImode) || GET_CODE (val) != CONST_INT)
299     return 0;
300
301   /* Check that the multiplicand has a valid value.  */
302   if ((code == MULT
303        && (INTVAL (val) == 1 || INTVAL (val) == 2 || INTVAL (val) == 4)))
304     return 1;
305
306   return 0;
307 }
308
309 /* Check if MODE is same as mode for X, and X is PLUS, MINUS, IOR or
310    AND or UMIN.  */
311
312 int
313 cris_orthogonal_operator (rtx x, enum machine_mode mode)
314 {
315   enum rtx_code code = GET_CODE (x);
316
317   if (mode == VOIDmode)
318     mode = GET_MODE (x);
319
320   return (GET_MODE (x) == mode
321           && (code == PLUS || code == MINUS
322               || code == IOR || code == AND || code == UMIN));
323 }
324
325 /* Check if MODE is same as mode for X, and X is PLUS, IOR or AND or
326    UMIN.  */
327
328 int
329 cris_commutative_orth_op (rtx x, enum machine_mode mode)
330 {
331   enum rtx_code code = GET_CODE (x);
332
333   if (mode == VOIDmode)
334     mode = GET_MODE (x);
335
336   return (GET_MODE (x) == mode &&
337           (code == PLUS
338            || code == IOR || code == AND || code == UMIN));
339 }
340
341 /* Check if MODE is same as mode for X, and X is PLUS or MINUS or UMIN.
342    By the name, you might think we should include MULT.  We don't because
343    it doesn't accept the same addressing modes as the others (ony
344    registers) and there's also the problem of handling TARGET_MUL_BUG.  */
345
346 int
347 cris_operand_extend_operator (rtx x, enum machine_mode mode)
348 {
349   enum rtx_code code = GET_CODE (x);
350
351   if (mode == VOIDmode)
352     mode = GET_MODE (x);
353
354   return (GET_MODE (x) == mode
355           && (code == PLUS || code == MINUS || code == UMIN));
356 }
357
358 /* Check if MODE is same as mode for X, and X is PLUS or MINUS.  */
359
360 int
361 cris_additive_operand_extend_operator (rtx x, enum machine_mode mode)
362 {
363   enum rtx_code code = GET_CODE (x);
364
365   if (mode == VOIDmode)
366     mode = GET_MODE (x);
367
368   return (GET_MODE (x) == mode
369           && (code == PLUS || code == MINUS));
370 }
371
372 /* Check to see if MODE is same as mode for X, and X is SIGN_EXTEND or
373    ZERO_EXTEND.  */
374
375 int
376 cris_extend_operator (rtx x, enum machine_mode mode)
377 {
378   enum rtx_code code = GET_CODE (x);
379
380   if (mode == VOIDmode)
381     mode = GET_MODE (x);
382
383   return
384     (GET_MODE (x) == mode && (code == SIGN_EXTEND || code == ZERO_EXTEND));
385 }
386
387 /* Check to see if MODE is same as mode for X, and X is PLUS or BOUND.  */
388
389 int
390 cris_plus_or_bound_operator (rtx x, enum machine_mode mode)
391 {
392   enum rtx_code code = GET_CODE (x);
393
394   if (mode == VOIDmode)
395     mode = GET_MODE (x);
396
397   return
398     (GET_MODE (x) == mode && (code == UMIN || code == PLUS));
399 }
400
401 /* Used as an operator to get a handle on a already-known-valid MEM rtx:es
402    (no need to validate the address), where some address expression parts
403    have their own match_operand.  */
404
405 int
406 cris_mem_op (rtx x, enum machine_mode mode)
407 {
408   if (mode == VOIDmode)
409     mode = GET_MODE (x);
410
411   return GET_MODE (x) == mode && GET_CODE (x) == MEM;
412 }
413
414 /* Since with -fPIC, not all symbols are valid PIC symbols or indeed
415    general_operands, we have to have a predicate that matches it for the
416    "movsi" expander.  */
417
418 int
419 cris_general_operand_or_symbol (rtx op, enum machine_mode mode)
420 {
421   return general_operand (op, mode)
422     || (CONSTANT_P (op) && cris_symbol (op));
423 }
424
425 /* Since a PIC symbol without a GOT entry is not a general_operand, we
426    have to have a predicate that matches it.  We use this in the expanded
427    "movsi" anonymous pattern for PIC symbols.  */
428
429 int
430 cris_general_operand_or_gotless_symbol (rtx op, enum machine_mode mode)
431 {
432   return general_operand (op, mode)
433     || (CONSTANT_P (op) && cris_gotless_symbol (op));
434 }
435
436 /* Since a PLT symbol is not a general_operand, we have to have a
437    predicate that matches it when we need it.  We use this in the expanded
438    "call" and "call_value" anonymous patterns.  */
439
440 int
441 cris_general_operand_or_plt_symbol (rtx op, enum machine_mode mode)
442 {
443   return general_operand (op, mode)
444     || (GET_CODE (op) == CONST
445         && GET_CODE (XEXP (op, 0)) == UNSPEC
446         && !TARGET_AVOID_GOTPLT);
447 }
448
449 /* This matches a (MEM (general_operand)) or
450    (MEM (cris_general_operand_or_symbol)).  The second one isn't a valid
451    memory_operand, so we need this predicate to recognize call
452    destinations before we change them to a PLT operand (by wrapping in
453    UNSPEC 0).  */
454
455 int
456 cris_mem_call_operand (rtx op, enum machine_mode mode)
457 {
458   rtx xmem;
459
460   if (GET_CODE (op) != MEM)
461     return 0;
462
463   if (memory_operand (op, mode))
464     return 1;
465
466   xmem = XEXP (op, 0);
467
468   return cris_general_operand_or_symbol (xmem, GET_MODE (op));
469 }
470
471 /* The CONDITIONAL_REGISTER_USAGE worker.  */
472
473 void
474 cris_conditional_register_usage (void)
475 {
476   /* FIXME: This isn't nice.  We should be able to use that register for
477      something else if the PIC table isn't needed.  */
478   if (flag_pic)
479     fixed_regs[PIC_OFFSET_TABLE_REGNUM]
480       = call_used_regs[PIC_OFFSET_TABLE_REGNUM] = 1;
481 }
482
483 /* Return current_function_uses_pic_offset_table.  For use in cris.md,
484    since some generated files do not include function.h.  */
485
486 int
487 cris_cfun_uses_pic_table (void)
488 {
489   return current_function_uses_pic_offset_table;
490 }
491
492 /* Given an rtx, return the text string corresponding to the CODE of X.
493    Intended for use in the assembly language output section of a
494    define_insn.  */
495
496 const char *
497 cris_op_str (rtx x)
498 {
499   cris_output_insn_is_bound = 0;
500   switch (GET_CODE (x))
501     {
502     case PLUS:
503       return "add";
504       break;
505
506     case MINUS:
507       return "sub";
508       break;
509
510     case MULT:
511       /* This function is for retrieving a part of an instruction name for
512          an operator, for immediate output.  If that ever happens for
513          MULT, we need to apply TARGET_MUL_BUG in the caller.  Make sure
514          we notice.  */
515       abort ();
516       break;
517
518     case DIV:
519       return "div";
520       break;
521
522     case AND:
523       return "and";
524       break;
525
526     case IOR:
527       return "or";
528       break;
529
530     case XOR:
531       return "xor";
532       break;
533
534     case NOT:
535       return "not";
536       break;
537
538     case ASHIFT:
539       return "lsl";
540       break;
541
542     case LSHIFTRT:
543       return "lsr";
544       break;
545
546     case ASHIFTRT:
547       return "asr";
548       break;
549
550     case UMIN:
551       /* Used to control the sign/zero-extend character for the 'e' modifier.
552          BOUND has none.  */
553       cris_output_insn_is_bound = 1;
554       return "bound";
555       break;
556
557     default:
558       return "Unknown operator";
559       break;
560   }
561 }
562
563 /* Emit an error message when we're in an asm, and a fatal error for
564    "normal" insns.  Formatted output isn't easily implemented, since we
565    use output_operand_lossage to output the actual message and handle the
566    categorization of the error.  */
567
568 static void
569 cris_operand_lossage (const char *msgid, rtx op)
570 {
571   debug_rtx (op);
572   output_operand_lossage ("%s", msgid);
573 }
574
575 /* Print an index part of an address to file.  */
576
577 static void
578 cris_print_index (rtx index, FILE *file)
579 {
580   rtx inner = XEXP (index, 0);
581
582   /* Make the index "additive" unless we'll output a negative number, in
583      which case the sign character is free (as in free beer).  */
584   if (GET_CODE (index) != CONST_INT || INTVAL (index) >= 0)
585     putc ('+', file);
586
587   if (REG_P (index))
588     fprintf (file, "$%s.b", reg_names[REGNO (index)]);
589   else if (CONSTANT_P (index))
590     cris_output_addr_const (file, index);
591   else if (GET_CODE (index) == MULT)
592     {
593       fprintf (file, "$%s.",
594                reg_names[REGNO (XEXP (index, 0))]);
595
596       putc (INTVAL (XEXP (index, 1)) == 2 ? 'w' : 'd', file);
597     }
598   else if (GET_CODE (index) == SIGN_EXTEND &&
599            GET_CODE (inner) == MEM)
600     {
601       rtx inner_inner = XEXP (inner, 0);
602
603       if (GET_CODE (inner_inner) == POST_INC)
604         {
605           fprintf (file, "[$%s+].",
606                    reg_names[REGNO (XEXP (inner_inner, 0))]);
607           putc (GET_MODE (inner) == HImode ? 'w' : 'b', file);
608         }
609       else
610         {
611           fprintf (file, "[$%s].", reg_names[REGNO (inner_inner)]);
612
613           putc (GET_MODE (inner) == HImode ? 'w' : 'b', file);
614         }
615     }
616   else if (GET_CODE (index) == MEM)
617     {
618       if (GET_CODE (inner) == POST_INC)
619         fprintf (file, "[$%s+].d", reg_names[REGNO (XEXP (inner, 0))]);
620       else
621         fprintf (file, "[$%s].d", reg_names[REGNO (inner)]);
622     }
623   else
624     cris_operand_lossage ("unexpected index-type in cris_print_index",
625                           index);
626 }
627
628 /* Print a base rtx of an address to file.  */
629
630 static void
631 cris_print_base (rtx base, FILE *file)
632 {
633   if (REG_P (base))
634     fprintf (file, "$%s", reg_names[REGNO (base)]);
635   else if (GET_CODE (base) == POST_INC)
636     fprintf (file, "$%s+", reg_names[REGNO (XEXP (base, 0))]);
637   else
638     cris_operand_lossage ("unexpected base-type in cris_print_base",
639                           base);
640 }
641
642 /* Usable as a guard in expressions.  */
643
644 int
645 cris_fatal (char *arg)
646 {
647   internal_error (arg);
648
649   /* We'll never get here; this is just to appease compilers.  */
650   return 0;
651 }
652
653 /* Textual function prologue.  */
654
655 static void
656 cris_target_asm_function_prologue (FILE *file, HOST_WIDE_INT size)
657 {
658   int regno;
659
660   /* Shorten the used name for readability.  */
661   int cfoa_size = current_function_outgoing_args_size;
662   int last_movem_reg = -1;
663   int doing_dwarf = dwarf2out_do_frame ();
664   int framesize;
665   int faked_args_size = 0;
666   int cfa_write_offset = 0;
667   char *cfa_label = NULL;
668   int return_address_on_stack
669     = regs_ever_live[CRIS_SRP_REGNUM]
670     || cfun->machine->needs_return_address_on_stack != 0;
671
672   /* Don't do anything if no prologues or epilogues are wanted.  */
673   if (!TARGET_PROLOGUE_EPILOGUE)
674     return;
675
676   if (size < 0)
677     abort ();
678
679   /* Align the size to what's best for the CPU model.  */
680   if (TARGET_STACK_ALIGN)
681     size = TARGET_ALIGN_BY_32 ? (size + 3) & ~3 : (size + 1) & ~1;
682
683   if (current_function_pretend_args_size)
684     {
685       int pretend = current_function_pretend_args_size;
686       for (regno = CRIS_FIRST_ARG_REG + CRIS_MAX_ARGS_IN_REGS - 1;
687            pretend > 0;
688            regno--, pretend -= 4)
689         {
690           fprintf (file, "\tpush $%s\n", reg_names[regno]);
691           faked_args_size += 4;
692         }
693     }
694
695   framesize = faked_args_size;
696
697   if (doing_dwarf)
698     {
699       /* FIXME: Slightly redundant calculation, as we do the same in
700          pieces below.  This offset must be the total adjustment of the
701          stack-pointer.  We can then def_cfa call at the end of this
702          function with the current implementation of execute_cfa_insn, but
703          that wouldn't really be clean.  */
704
705       int cfa_offset
706         = faked_args_size
707         + (return_address_on_stack ? 4 : 0)
708         + (frame_pointer_needed ? 4 : 0);
709
710       int cfa_reg;
711
712       if (frame_pointer_needed)
713         cfa_reg = FRAME_POINTER_REGNUM;
714       else
715         {
716           cfa_reg = STACK_POINTER_REGNUM;
717           cfa_offset += cris_initial_frame_pointer_offset ();
718         }
719
720       cfa_label = dwarf2out_cfi_label ();
721       dwarf2out_def_cfa (cfa_label, cfa_reg, cfa_offset);
722
723       cfa_write_offset = - faked_args_size - 4;
724     }
725
726   /* Save SRP if not a leaf function.  */
727   if (return_address_on_stack)
728     {
729       fprintf (file, "\tPush $srp\n");
730       framesize += 4;
731
732       if (doing_dwarf)
733         {
734           dwarf2out_return_save (cfa_label, cfa_write_offset);
735           cfa_write_offset -= 4;
736         }
737     }
738
739   /* Set up frame pointer if needed.  */
740   if (frame_pointer_needed)
741     {
742       fprintf (file, "\tpush $%s\n\tmove.d $sp,$%s\n",
743                reg_names[FRAME_POINTER_REGNUM],
744                reg_names[FRAME_POINTER_REGNUM]);
745       framesize += 4;
746
747       if (doing_dwarf)
748         {
749           dwarf2out_reg_save (cfa_label, FRAME_POINTER_REGNUM,
750                               cfa_write_offset);
751           cfa_write_offset -= 4;
752         }
753     }
754
755   /* Local vars are located above saved regs.  */
756   cfa_write_offset -= size;
757
758   /* Get a contiguous sequence of registers, starting with r0, that need
759      to be saved.  */
760   for (regno = 0; regno < FIRST_PSEUDO_REGISTER; regno++)
761     {
762       if ((((regs_ever_live[regno]
763              && !call_used_regs[regno])
764             || (regno == (int) PIC_OFFSET_TABLE_REGNUM
765                 && (current_function_uses_pic_offset_table
766                     /* It is saved anyway, if there would be a gap.  */
767                     || (flag_pic
768                         && regs_ever_live[regno + 1]
769                         && !call_used_regs[regno + 1]))))
770            && (regno != FRAME_POINTER_REGNUM || !frame_pointer_needed)
771            && regno != CRIS_SRP_REGNUM)
772           || (current_function_calls_eh_return
773               && (regno == EH_RETURN_DATA_REGNO (0)
774                   || regno == EH_RETURN_DATA_REGNO (1)
775                   || regno == EH_RETURN_DATA_REGNO (2)
776                   || regno == EH_RETURN_DATA_REGNO (3))))
777         {
778           /* Check if movem may be used for registers so far.  */
779           if (regno == last_movem_reg + 1)
780             /* Yes, update next expected register.  */
781             last_movem_reg++;
782           else
783             {
784               /* We cannot use movem for all registers.  We have to flush
785                  any movem:ed registers we got so far.  */
786               if (last_movem_reg != -1)
787                 {
788                   /* It is a win to use a side-effect assignment for
789                      64 <= size <= 128.  But side-effect on movem was
790                      not usable for CRIS v0..3.  Also only do it if
791                      side-effects insns are allowed.  */
792                   if ((last_movem_reg + 1) * 4 + size >= 64
793                       && (last_movem_reg + 1) * 4 + size <= 128
794                       && cris_cpu_version >= CRIS_CPU_SVINTO
795                       && TARGET_SIDE_EFFECT_PREFIXES)
796                     fprintf (file, "\tmovem $%s,[$sp=$sp-"HOST_WIDE_INT_PRINT_DEC"]\n",
797                              reg_names[last_movem_reg],
798                              (last_movem_reg + 1) * 4 + size);
799                   else
800                     {
801                       /* Avoid printing multiple subsequent sub:s for sp.  */
802                       fprintf (file, "\tsub%s "HOST_WIDE_INT_PRINT_DEC",$sp\n",
803                                ADDITIVE_SIZE_MODIFIER ((last_movem_reg + 1)
804                                                        * 4 + size),
805                                (last_movem_reg + 1) * 4 + size);
806
807                       fprintf (file, "\tmovem $%s,[$sp]\n",
808                                reg_names[last_movem_reg]);
809                     }
810
811                   framesize += (last_movem_reg + 1) * 4 + size;
812
813                   if (TARGET_PDEBUG)
814                     fprintf (file, "; frame "HOST_WIDE_INT_PRINT_DEC
815                              ", #regs %d, bytes %d args %d\n",
816                              size,
817                              last_movem_reg + 1,
818                              (last_movem_reg + 1) * 4,
819                              current_function_args_size);
820
821                   last_movem_reg = -1;
822                   size = 0;
823                 }
824               else if (size > 0)
825                 {
826                   /* Local vars on stack, but there are no movem:s.
827                      Just allocate space.  */
828                   fprintf (file, "\tSub%s "HOST_WIDE_INT_PRINT_DEC",$sp\n",
829                            ADDITIVE_SIZE_MODIFIER (size),
830                            size);
831                   framesize += size;
832                   size = 0;
833                 }
834
835               fprintf (file, "\tPush $%s\n", reg_names[regno]);
836               framesize += 4;
837             }
838
839           if (doing_dwarf)
840             {
841               /* Registers are stored lowest numbered at highest address,
842                  which matches the loop order; we just need to update the
843                  write-offset.  */
844               dwarf2out_reg_save (cfa_label, regno, cfa_write_offset);
845               cfa_write_offset -= 4;
846             }
847         }
848     }
849
850   /* Check after, if we can movem all registers.  This is the normal
851      case.  */
852   if (last_movem_reg != -1)
853     {
854       /* Side-effect assignment on movem was not supported for CRIS v0..3,
855          and don't do it if we're asked not to.
856
857          The movem is already accounted for, for unwind.  */
858
859       if ((last_movem_reg + 1) * 4 + size >= 64
860           && (last_movem_reg + 1) * 4 + size <= 128
861           && cris_cpu_version >= CRIS_CPU_SVINTO
862           && TARGET_SIDE_EFFECT_PREFIXES)
863         fprintf (file, "\tmovem $%s,[$sp=$sp-"HOST_WIDE_INT_PRINT_DEC"]\n",
864                  reg_names[last_movem_reg],
865                  (last_movem_reg+1) * 4 + size);
866       else
867         {
868           /* Avoid printing multiple subsequent sub:s for sp.  FIXME:
869              Clean up the conditional expression.  */
870           fprintf (file, "\tsub%s "HOST_WIDE_INT_PRINT_DEC",$sp\n",
871                    ADDITIVE_SIZE_MODIFIER ((last_movem_reg + 1) * 4 + size),
872                    (last_movem_reg + 1) * 4 + size);
873           /* To be compatible with v0..v3 means we do not use an assignment
874              addressing mode with movem.  We normally don't need that
875              anyway.  It would only be slightly more efficient for 64..128
876              bytes frame size.  */
877           fprintf (file, "\tmovem $%s,[$sp]\n", reg_names[last_movem_reg]);
878         }
879
880       framesize += (last_movem_reg + 1) * 4 + size;
881
882       if (TARGET_PDEBUG)
883         fprintf (file, "; frame "HOST_WIDE_INT_PRINT_DEC
884                  ", #regs %d, bytes %d args %d\n",
885                  size,
886                  last_movem_reg + 1,
887                  (last_movem_reg + 1) * 4,
888                  current_function_args_size);
889
890       /* We have to put outgoing argument space after regs.  */
891       if (cfoa_size)
892         {
893           /* This does not need to be accounted for, for unwind.  */
894
895           fprintf (file, "\tSub%s %d,$sp\n",
896                    ADDITIVE_SIZE_MODIFIER (cfoa_size),
897                    cfoa_size);
898           framesize += cfoa_size;
899         }
900     }
901   else if ((size + cfoa_size) > 0)
902     {
903       /* This does not need to be accounted for, for unwind.  */
904
905       /* Local vars on stack, and we could not use movem.  Add a sub here.  */
906       fprintf (file, "\tSub%s "HOST_WIDE_INT_PRINT_DEC",$sp\n",
907                ADDITIVE_SIZE_MODIFIER (size + cfoa_size),
908                cfoa_size + size);
909       framesize += size + cfoa_size;
910     }
911
912   /* Set up the PIC register.  */
913   if (current_function_uses_pic_offset_table)
914     fprintf (file, "\tmove.d $pc,$%s\n\tsub.d .:GOTOFF,$%s\n",
915              reg_names[PIC_OFFSET_TABLE_REGNUM],
916              reg_names[PIC_OFFSET_TABLE_REGNUM]);
917
918   if (TARGET_PDEBUG)
919     fprintf (file,
920              "; parm #%d @ %d; frame " HOST_WIDE_INT_PRINT_DEC
921              ", FP-SP is %d; leaf: %s%s; fp %s, outg: %d arg %d\n",
922              CRIS_MAX_ARGS_IN_REGS + 1, FIRST_PARM_OFFSET (0),
923              get_frame_size (),
924              cris_initial_frame_pointer_offset (),
925              leaf_function_p () ? "yes" : "no",
926              return_address_on_stack ? "no" :"yes",
927              frame_pointer_needed ? "yes" : "no",
928              cfoa_size, current_function_args_size);
929
930   if (cris_max_stackframe && framesize > cris_max_stackframe)
931     warning ("stackframe too big: %d bytes", framesize);
932 }
933
934 /* Return nonzero if there are regs mentioned in the insn that are not all
935    in the call_used regs.  This is part of the decision whether an insn
936    can be put in the epilogue.  */
937
938 static int
939 saved_regs_mentioned (rtx x)
940 {
941   int i;
942   const char *fmt;
943   RTX_CODE code;
944
945   /* Mainly stolen from refers_to_regno_p in rtlanal.c.  */
946
947   code = GET_CODE (x);
948
949   switch (code)
950     {
951     case REG:
952       i = REGNO (x);
953       return !call_used_regs[i];
954
955     case SUBREG:
956       /* If this is a SUBREG of a hard reg, we can see exactly which
957          registers are being modified.  Otherwise, handle normally.  */
958       i = REGNO (SUBREG_REG (x));
959       return !call_used_regs[i];
960
961     default:
962       ;
963     }
964
965   fmt = GET_RTX_FORMAT (code);
966   for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
967     {
968       if (fmt[i] == 'e')
969         {
970           if (saved_regs_mentioned (XEXP (x, i)))
971             return 1;
972         }
973       else if (fmt[i] == 'E')
974         {
975           int j;
976           for (j = XVECLEN (x, i) - 1; j >=0; j--)
977             if (saved_regs_mentioned (XEXP (x, i)))
978               return 1;
979         }
980     }
981
982   return 0;
983 }
984
985 /* Figure out if the insn may be put in the epilogue.  */
986
987 int
988 cris_eligible_for_epilogue_delay (rtx insn)
989 {
990   /* First of all, it must be as slottable as for a delayed branch insn.  */
991   if (get_attr_slottable (insn) != SLOTTABLE_YES)
992     return 0;
993
994   /* It must not refer to the stack pointer (may be valid for some cases
995      that I can't think of).  */
996   if (reg_mentioned_p (stack_pointer_rtx, PATTERN (insn)))
997     return 0;
998
999   /* The frame pointer will be restored in the epilogue, before the
1000      "ret", so it can't be referred to.  */
1001   if (frame_pointer_needed
1002       && reg_mentioned_p (frame_pointer_rtx, PATTERN (insn)))
1003     return 0;
1004
1005   /* All saved regs are restored before the delayed insn.
1006      This means that we cannot have any instructions that mention the
1007      registers that are restored by the epilogue.  */
1008   if (saved_regs_mentioned (PATTERN (insn)))
1009     return 0;
1010
1011   /* It seems to be ok.  */
1012   return 1;
1013 }
1014
1015 /* Return the number of delay-slots in the epilogue: return 1 if it
1016    contains "ret", else 0.  */
1017
1018 int
1019 cris_delay_slots_for_epilogue (void)
1020 {
1021   /* Check if we use a return insn, which we only do for leaf functions.
1022      Else there is no slot to fill.  */
1023   if (regs_ever_live[CRIS_SRP_REGNUM]
1024       || cfun->machine->needs_return_address_on_stack != 0)
1025     return 0;
1026
1027   /* By calling function_epilogue with the same parameters as from gcc
1028      we can get info about if the epilogue can fill the delay-slot by itself.
1029      If it is filled from the epilogue, then the corresponding string
1030      is in save_last.
1031       This depends on that the "size" argument to function_epilogue
1032      always is get_frame_size.
1033      FIXME:  Kludgy.  At least make it a separate function that is not
1034      misnamed or abuses the stream parameter.  */
1035   cris_target_asm_function_epilogue (NULL, get_frame_size ());
1036
1037   if (*save_last)
1038     return 1;
1039   return 0;
1040 }
1041
1042 /* Textual function epilogue.  When file is NULL, it serves doubly as
1043    a test for whether the epilogue can fill any "ret" delay-slots by
1044    itself by storing the delay insn in save_last.  */
1045
1046 static void
1047 cris_target_asm_function_epilogue (FILE *file, HOST_WIDE_INT size)
1048 {
1049   int regno;
1050   int last_movem_reg = -1;
1051   rtx insn = get_last_insn ();
1052   int argspace_offset = current_function_outgoing_args_size;
1053   int pretend =  current_function_pretend_args_size;
1054   int return_address_on_stack
1055     = regs_ever_live[CRIS_SRP_REGNUM]
1056     || cfun->machine->needs_return_address_on_stack != 0;
1057
1058   save_last[0] = 0;
1059
1060   if (file && !TARGET_PROLOGUE_EPILOGUE)
1061     return;
1062
1063   if (TARGET_PDEBUG && file)
1064     fprintf (file, ";;\n");
1065
1066   /* Align byte count of stack frame.  */
1067   if (TARGET_STACK_ALIGN)
1068     size = TARGET_ALIGN_BY_32 ? (size + 3) & ~3 : (size + 1) & ~1;
1069
1070   /* If the last insn was a BARRIER, we don't have to write any code,
1071      then all returns were covered by "return" insns.  */
1072   if (GET_CODE (insn) == NOTE)
1073     insn = prev_nonnote_insn (insn);
1074   if (insn
1075       && (GET_CODE (insn) == BARRIER
1076           /* We must make sure that the insn really is a "return" and
1077              not a conditional branch.  Try to match the return exactly,
1078              and if it doesn't match, assume it is a conditional branch
1079              (and output an epilogue).  */
1080           || (GET_CODE (insn) == JUMP_INSN
1081               && GET_CODE (PATTERN (insn)) == RETURN)))
1082     {
1083       if (TARGET_PDEBUG && file)
1084         fprintf (file, ";;;;;\n");
1085       return;
1086     }
1087
1088   /* Check how many saved regs we can movem.  They start at r0 and must
1089      be contiguous.  */
1090   for (regno = 0;
1091        regno < FIRST_PSEUDO_REGISTER;
1092        regno++)
1093     if ((((regs_ever_live[regno]
1094            && !call_used_regs[regno])
1095           || (regno == (int) PIC_OFFSET_TABLE_REGNUM
1096               && (current_function_uses_pic_offset_table
1097                   /* It is saved anyway, if there would be a gap.  */
1098                   || (flag_pic
1099                       && regs_ever_live[regno + 1]
1100                       && !call_used_regs[regno + 1]))))
1101          && (regno != FRAME_POINTER_REGNUM || !frame_pointer_needed)
1102          && regno != CRIS_SRP_REGNUM)
1103         || (current_function_calls_eh_return
1104             && (regno == EH_RETURN_DATA_REGNO (0)
1105                 || regno == EH_RETURN_DATA_REGNO (1)
1106                 || regno == EH_RETURN_DATA_REGNO (2)
1107                 || regno == EH_RETURN_DATA_REGNO (3))))
1108
1109       {
1110         if (regno == last_movem_reg + 1)
1111           last_movem_reg++;
1112         else
1113           break;
1114       }
1115
1116   for (regno = FIRST_PSEUDO_REGISTER - 1;
1117        regno > last_movem_reg;
1118        regno--)
1119     if ((((regs_ever_live[regno]
1120            && !call_used_regs[regno])
1121           || (regno == (int) PIC_OFFSET_TABLE_REGNUM
1122               && (current_function_uses_pic_offset_table
1123                   /* It is saved anyway, if there would be a gap.  */
1124                   || (flag_pic
1125                       && regs_ever_live[regno + 1]
1126                       && !call_used_regs[regno + 1]))))
1127          && (regno != FRAME_POINTER_REGNUM || !frame_pointer_needed)
1128          && regno != CRIS_SRP_REGNUM)
1129         || (current_function_calls_eh_return
1130             && (regno == EH_RETURN_DATA_REGNO (0)
1131                 || regno == EH_RETURN_DATA_REGNO (1)
1132                 || regno == EH_RETURN_DATA_REGNO (2)
1133                 || regno == EH_RETURN_DATA_REGNO (3))))
1134       {
1135         if (argspace_offset)
1136           {
1137             /* There is an area for outgoing parameters located before
1138                the saved registers.  We have to adjust for that.  */
1139             if (file)
1140               fprintf (file, "\tAdd%s %d,$sp\n",
1141                        ADDITIVE_SIZE_MODIFIER (argspace_offset),
1142                        argspace_offset);
1143
1144             /* Make sure we only do this once.  */
1145             argspace_offset = 0;
1146           }
1147
1148         /* Flush previous non-movem:ed registers.  */
1149         if (*save_last && file)
1150           fprintf (file, save_last);
1151         sprintf (save_last, "\tPop $%s\n", reg_names[regno]);
1152       }
1153
1154   if (last_movem_reg != -1)
1155     {
1156       if (argspace_offset)
1157         {
1158           /* Adjust for the outgoing parameters area, if that's not
1159              handled yet.  */
1160           if (*save_last && file)
1161             {
1162               fprintf (file, save_last);
1163               *save_last = 0;
1164             }
1165
1166           if (file)
1167             fprintf (file, "\tAdd%s %d,$sp\n",
1168                      ADDITIVE_SIZE_MODIFIER (argspace_offset),
1169                      argspace_offset);
1170           argspace_offset = 0;
1171         }
1172       /* Flush previous non-movem:ed registers.  */
1173       else if (*save_last && file)
1174         fprintf (file, save_last);
1175       sprintf (save_last, "\tmovem [$sp+],$%s\n", reg_names[last_movem_reg]);
1176     }
1177
1178   /* Restore frame pointer if necessary.  */
1179   if (frame_pointer_needed)
1180     {
1181       if (*save_last && file)
1182         fprintf (file, save_last);
1183
1184       if (file)
1185         fprintf (file, "\tmove.d $%s,$sp\n",
1186                  reg_names[FRAME_POINTER_REGNUM]);
1187       sprintf (save_last, "\tPop $%s\n",
1188                reg_names[FRAME_POINTER_REGNUM]);
1189     }
1190   else
1191     {
1192       /* If there was no frame-pointer to restore sp from, we must
1193          explicitly deallocate local variables.  */
1194
1195       /* Handle space for outgoing parameters that hasn't been handled
1196          yet.  */
1197       size += argspace_offset;
1198
1199       if (size)
1200         {
1201           if (*save_last && file)
1202             fprintf (file, save_last);
1203
1204           sprintf (save_last, "\tadd%s "HOST_WIDE_INT_PRINT_DEC",$sp\n",
1205                    ADDITIVE_SIZE_MODIFIER (size), size);
1206         }
1207
1208       /* If the size was not in the range for a "quick", we must flush
1209          it here.  */
1210       if (size > 63)
1211         {
1212           if (file)
1213             fprintf (file, save_last);
1214           *save_last = 0;
1215         }
1216     }
1217
1218   /* If this function has no pushed register parameters
1219      (stdargs/varargs), and if it is not a leaf function, then we can
1220      just jump-return here.  */
1221   if (return_address_on_stack && pretend == 0)
1222     {
1223       if (*save_last && file)
1224         fprintf (file, save_last);
1225       *save_last = 0;
1226
1227       if (file)
1228         {
1229           if (current_function_calls_eh_return)
1230             {
1231               /* The installed EH-return address is in *this* frame, so we
1232                  need to pop it before we return.  */
1233               fprintf (file, "\tpop $srp\n");
1234               fprintf (file, "\tret\n");
1235               fprintf (file, "\tadd.d $%s,$sp\n", reg_names[CRIS_STACKADJ_REG]);
1236             }
1237           else
1238             fprintf (file, "\tJump [$sp+]\n");
1239
1240           /* Do a sanity check to avoid generating invalid code.  */
1241           if (current_function_epilogue_delay_list)
1242             internal_error ("allocated but unused delay list in epilogue");
1243         }
1244       return;
1245     }
1246
1247   /* Rather than add current_function_calls_eh_return conditions
1248      everywhere in the following code (and not be able to test it
1249      thoroughly), assert the assumption that all usage of
1250      __builtin_eh_return are handled above.  */
1251   if (current_function_calls_eh_return)
1252     internal_error ("unexpected function type needing stack adjustment for\
1253  __builtin_eh_return");
1254
1255   /* If we pushed some register parameters, then adjust the stack for
1256      them.  */
1257   if (pretend)
1258     {
1259       /* Since srp is stored on the way, we need to restore it first.  */
1260       if (return_address_on_stack)
1261         {
1262           if (*save_last && file)
1263             fprintf (file, save_last);
1264           *save_last = 0;
1265
1266           if (file)
1267             fprintf (file, "\tpop $srp\n");
1268         }
1269
1270       if (*save_last && file)
1271         fprintf (file, save_last);
1272
1273       sprintf (save_last, "\tadd%s %d,$sp\n",
1274                ADDITIVE_SIZE_MODIFIER (pretend), pretend);
1275     }
1276
1277   /* Here's where we have a delay-slot we need to fill.  */
1278   if (file && current_function_epilogue_delay_list)
1279     {
1280       /* If gcc has allocated an insn for the epilogue delay slot, but
1281          things were arranged so we now thought we could do it
1282          ourselves, don't forget to flush that insn.  */
1283       if (*save_last)
1284         fprintf (file, save_last);
1285
1286       fprintf (file, "\tRet\n");
1287
1288       /* Output the delay-slot-insn the mandated way.  */
1289       final_scan_insn (XEXP (current_function_epilogue_delay_list, 0),
1290                        file, 1, -2, 1, NULL);
1291     }
1292   else if (file)
1293     {
1294       fprintf (file, "\tRet\n");
1295
1296       /* If the GCC did not do it, we have to use whatever insn we have,
1297          or a nop.  */
1298       if (*save_last)
1299         fprintf (file, save_last);
1300       else
1301         fprintf (file, "\tnOp\n");
1302     }
1303 }
1304
1305 /* The PRINT_OPERAND worker.  */
1306
1307 void
1308 cris_print_operand (FILE *file, rtx x, int code)
1309 {
1310   rtx operand = x;
1311
1312   /* Size-strings corresponding to MULT expressions.  */
1313   static const char *const mults[] = { "BAD:0", ".b", ".w", "BAD:3", ".d" };
1314
1315   /* New code entries should just be added to the switch below.  If
1316      handling is finished, just return.  If handling was just a
1317      modification of the operand, the modified operand should be put in
1318      "operand", and then do a break to let default handling
1319      (zero-modifier) output the operand.  */
1320
1321   switch (code)
1322     {
1323     case 'b':
1324       /* Print the unsigned supplied integer as if it were signed
1325          and < 0, i.e print 255 or 65535 as -1, 254, 65534 as -2, etc.  */
1326       if (GET_CODE (x) != CONST_INT
1327           || ! CONST_OK_FOR_LETTER_P (INTVAL (x), 'O'))
1328         LOSE_AND_RETURN ("invalid operand for 'b' modifier", x);
1329       fprintf (file, HOST_WIDE_INT_PRINT_DEC,
1330                INTVAL (x)| (INTVAL (x) <= 255 ? ~255 : ~65535));
1331       return;
1332
1333     case 'x':
1334       /* Print assembler code for operator.  */
1335       fprintf (file, "%s", cris_op_str (operand));
1336       return;
1337
1338     case 'v':
1339       /* Print the operand without the PIC register.  */
1340       if (! flag_pic || ! CONSTANT_P (x) || ! cris_gotless_symbol (x))
1341         LOSE_AND_RETURN ("invalid operand for 'v' modifier", x);
1342       cris_pic_sympart_only++;
1343       cris_output_addr_const (file, x);
1344       cris_pic_sympart_only--;
1345       return;
1346
1347     case 'P':
1348       /* Print the PIC register.  Applied to a GOT-less PIC symbol for
1349          sanity.  */
1350       if (! flag_pic || ! CONSTANT_P (x) || ! cris_gotless_symbol (x))
1351         LOSE_AND_RETURN ("invalid operand for 'P' modifier", x);
1352       fprintf (file, "$%s", reg_names [PIC_OFFSET_TABLE_REGNUM]);
1353       return;
1354
1355     case 'p':
1356       /* Adjust a power of two to its log2.  */
1357       if (GET_CODE (x) != CONST_INT || exact_log2 (INTVAL (x)) < 0 )
1358         LOSE_AND_RETURN ("invalid operand for 'p' modifier", x);
1359       fprintf (file, "%d", exact_log2 (INTVAL (x)));
1360       return;
1361
1362     case 's':
1363       /* For an integer, print 'b' or 'w' if <= 255 or <= 65535
1364          respectively.  This modifier also terminates the inhibiting
1365          effects of the 'x' modifier.  */
1366       cris_output_insn_is_bound = 0;
1367       if (GET_MODE (x) == VOIDmode && GET_CODE (x) == CONST_INT)
1368         {
1369           if (INTVAL (x) >= 0)
1370             {
1371               if (INTVAL (x) <= 255)
1372                 putc ('b', file);
1373               else if (INTVAL (x) <= 65535)
1374                 putc ('w', file);
1375               else
1376                 putc ('d', file);
1377             }
1378           else
1379             putc ('d', file);
1380           return;
1381         }
1382
1383       /* For a non-integer, print the size of the operand.  */
1384       putc ((GET_MODE (x) == SImode || GET_MODE (x) == SFmode)
1385             ? 'd' : GET_MODE (x) == HImode ? 'w'
1386             : GET_MODE (x) == QImode ? 'b'
1387             /* If none of the above, emit an erroneous size letter.  */
1388             : 'X',
1389             file);
1390       return;
1391
1392     case 'z':
1393       /* Const_int: print b for -127 <= x <= 255,
1394          w for -32768 <= x <= 65535, else abort.  */
1395       if (GET_CODE (x) != CONST_INT
1396           || INTVAL (x) < -32768 || INTVAL (x) > 65535)
1397         LOSE_AND_RETURN ("invalid operand for 'z' modifier", x);
1398       putc (INTVAL (x) >= -128 && INTVAL (x) <= 255 ? 'b' : 'w', file);
1399       return;
1400
1401     case '#':
1402       /* Output a 'nop' if there's nothing for the delay slot.
1403          This method stolen from the sparc files.  */
1404       if (dbr_sequence_length () == 0)
1405         fputs ("\n\tnop", file);
1406       return;
1407
1408     case '!':
1409       /* Output directive for alignment padded with "nop" insns.
1410          Optimizing for size, it's plain 4-byte alignment, otherwise we
1411          align the section to a cache-line (32 bytes) and skip at max 2
1412          bytes, i.e. we skip if it's the last insn on a cache-line.  The
1413          latter is faster by a small amount (for two test-programs 99.6%
1414          and 99.9%) and larger by a small amount (ditto 100.1% and
1415          100.2%).  This is supposed to be the simplest yet performance-
1416          wise least intrusive way to make sure the immediately following
1417          (supposed) muls/mulu insn isn't located at the end of a
1418          cache-line.  */
1419       if (TARGET_MUL_BUG)
1420         fputs (optimize_size
1421                ? ".p2alignw 2,0x050f\n\t"
1422                : ".p2alignw 5,0x050f,2\n\t", file);
1423       return;
1424
1425     case 'H':
1426       /* Print high (most significant) part of something.  */
1427       switch (GET_CODE (operand))
1428         {
1429         case CONST_INT:
1430           if (HOST_BITS_PER_WIDE_INT == 32)
1431             /* Sign-extension from a normal int to a long long.  */
1432             fprintf (file, INTVAL (operand) < 0 ? "-1" : "0");
1433           else
1434             fprintf (file, "0x%x", (unsigned int)(INTVAL (x) >> 31 >> 1));
1435           return;
1436
1437         case CONST_DOUBLE:
1438           /* High part of a long long constant.  */
1439           if (GET_MODE (operand) == VOIDmode)
1440             {
1441               fprintf (file, HOST_WIDE_INT_PRINT_HEX, CONST_DOUBLE_HIGH (x));
1442               return;
1443             }
1444           else
1445             LOSE_AND_RETURN ("invalid operand for 'H' modifier", x);
1446
1447         case REG:
1448           /* Print reg + 1.  Check that there's not an attempt to print
1449              high-parts of registers like stack-pointer or higher.  */
1450           if (REGNO (operand) > STACK_POINTER_REGNUM - 2)
1451             LOSE_AND_RETURN ("bad register", operand);
1452           fprintf (file, "$%s", reg_names[REGNO (operand) + 1]);
1453           return;
1454
1455         case MEM:
1456           /* Adjust memory address to high part.  */
1457           {
1458             rtx adj_mem = operand;
1459             int size
1460               = GET_MODE_BITSIZE (GET_MODE (operand)) / BITS_PER_UNIT;
1461
1462             /* Adjust so we can use two SImode in DImode.
1463                Calling adj_offsettable_operand will make sure it is an
1464                offsettable address.  Don't do this for a postincrement
1465                though; it should remain as it was.  */
1466             if (GET_CODE (XEXP (adj_mem, 0)) != POST_INC)
1467               adj_mem
1468                 = adjust_address (adj_mem, GET_MODE (adj_mem), size / 2);
1469
1470             output_address (XEXP (adj_mem, 0));
1471             return;
1472           }
1473
1474         default:
1475           LOSE_AND_RETURN ("invalid operand for 'H' modifier", x);
1476         }
1477
1478     case 'L':
1479       /* Strip the MEM expression.  */
1480       operand = XEXP (operand, 0);
1481       break;
1482
1483     case 'e':
1484       /* Print 's' if operand is SIGN_EXTEND or 'u' if ZERO_EXTEND unless
1485          cris_output_insn_is_bound is nonzero.  */
1486       if (GET_CODE (operand) != SIGN_EXTEND
1487           && GET_CODE (operand) != ZERO_EXTEND
1488           && GET_CODE (operand) != CONST_INT)
1489         LOSE_AND_RETURN ("invalid operand for 'e' modifier", x);
1490
1491       if (cris_output_insn_is_bound)
1492         {
1493           cris_output_insn_is_bound = 0;
1494           return;
1495         }
1496
1497       putc (GET_CODE (operand) == SIGN_EXTEND
1498             || (GET_CODE (operand) == CONST_INT && INTVAL (operand) < 0)
1499             ? 's' : 'u', file);
1500       return;
1501
1502     case 'm':
1503       /* Print the size letter of the inner element.  We can do it by
1504          calling ourselves with the 's' modifier.  */
1505       if (GET_CODE (operand) != SIGN_EXTEND && GET_CODE (operand) != ZERO_EXTEND)
1506         LOSE_AND_RETURN ("invalid operand for 'm' modifier", x);
1507       cris_print_operand (file, XEXP (operand, 0), 's');
1508       return;
1509
1510     case 'M':
1511       /* Print the least significant part of operand.  */
1512       if (GET_CODE (operand) == CONST_DOUBLE)
1513         {
1514           fprintf (file, HOST_WIDE_INT_PRINT_HEX, CONST_DOUBLE_LOW (x));
1515           return;
1516         }
1517       else if (HOST_BITS_PER_WIDE_INT > 32 && GET_CODE (operand) == CONST_INT)
1518         {
1519           fprintf (file, HOST_WIDE_INT_PRINT_HEX,
1520                    INTVAL (x) & ((unsigned int) 0x7fffffff * 2 + 1));
1521           return;
1522         }
1523       /* Otherwise the least significant part equals the normal part,
1524          so handle it normally.  */
1525       break;
1526
1527     case 'A':
1528       /* When emitting an add for the high part of a DImode constant, we
1529          want to use addq for 0 and adds.w for -1.  */
1530       if (GET_CODE (operand) != CONST_INT)
1531         LOSE_AND_RETURN ("invalid operand for 'A' modifier", x);
1532       fprintf (file, INTVAL (operand) < 0 ? "adds.w" : "addq");
1533       return;
1534
1535     case 'D':
1536       /* When emitting an sub for the high part of a DImode constant, we
1537          want to use subq for 0 and subs.w for -1.  */
1538       if (GET_CODE (operand) != CONST_INT)
1539         LOSE_AND_RETURN ("invalid operand for 'D' modifier", x);
1540       fprintf (file, INTVAL (operand) < 0 ? "subs.w" : "subq");
1541       return;
1542
1543     case 'S':
1544       /* Print the operand as the index-part of an address.
1545          Easiest way out is to use cris_print_index.  */
1546       cris_print_index (operand, file);
1547       return;
1548
1549     case 'T':
1550       /* Print the size letter for an operand to a MULT, which must be a
1551          const_int with a suitable value.  */
1552       if (GET_CODE (operand) != CONST_INT || INTVAL (operand) > 4)
1553         LOSE_AND_RETURN ("invalid operand for 'T' modifier", x);
1554       fprintf (file, "%s", mults[INTVAL (operand)]);
1555       return;
1556
1557     case 0:
1558       /* No code, print as usual.  */
1559       break;
1560
1561     default:
1562       LOSE_AND_RETURN ("invalid operand modifier letter", x);
1563     }
1564
1565   /* Print an operand as without a modifier letter.  */
1566   switch (GET_CODE (operand))
1567     {
1568     case REG:
1569       if (REGNO (operand) > 15)
1570         internal_error ("internal error: bad register: %d", REGNO (operand));
1571       fprintf (file, "$%s", reg_names[REGNO (operand)]);
1572       return;
1573
1574     case MEM:
1575       output_address (XEXP (operand, 0));
1576       return;
1577
1578     case CONST_DOUBLE:
1579       if (GET_MODE (operand) == VOIDmode)
1580         /* A long long constant.  */
1581         output_addr_const (file, operand);
1582       else
1583         {
1584           /* Only single precision is allowed as plain operands the
1585              moment.  FIXME:  REAL_VALUE_FROM_CONST_DOUBLE isn't
1586              documented.  */
1587           REAL_VALUE_TYPE r;
1588           long l;
1589
1590           /* FIXME:  Perhaps check overflow of the "single".  */
1591           REAL_VALUE_FROM_CONST_DOUBLE (r, operand);
1592           REAL_VALUE_TO_TARGET_SINGLE (r, l);
1593
1594           fprintf (file, "0x%lx", l);
1595         }
1596       return;
1597
1598     case UNSPEC:
1599       ASSERT_PLT_UNSPEC (operand);
1600       /* Fall through.  */
1601
1602     case CONST:
1603       cris_output_addr_const (file, operand);
1604       return;
1605
1606     case MULT:
1607     case ASHIFT:
1608       {
1609         /* For a (MULT (reg X) const_int) we output "rX.S".  */
1610         int i = GET_CODE (XEXP (operand, 1)) == CONST_INT
1611           ? INTVAL (XEXP (operand, 1)) : INTVAL (XEXP (operand, 0));
1612         rtx reg = GET_CODE (XEXP (operand, 1)) == CONST_INT
1613           ? XEXP (operand, 0) : XEXP (operand, 1);
1614
1615         if (GET_CODE (reg) != REG
1616             || (GET_CODE (XEXP (operand, 0)) != CONST_INT
1617                 && GET_CODE (XEXP (operand, 1)) != CONST_INT))
1618           LOSE_AND_RETURN ("unexpected multiplicative operand", x);
1619
1620         cris_print_base (reg, file);
1621         fprintf (file, ".%c",
1622                  i == 0 || (i == 1 && GET_CODE (operand) == MULT) ? 'b'
1623                  : i == 4 ? 'd'
1624                  : (i == 2 && GET_CODE (operand) == MULT) || i == 1 ? 'w'
1625                  : 'd');
1626         return;
1627       }
1628
1629     default:
1630       /* No need to handle all strange variants, let output_addr_const
1631          do it for us.  */
1632       if (CONSTANT_P (operand))
1633         {
1634           cris_output_addr_const (file, operand);
1635           return;
1636         }
1637
1638       LOSE_AND_RETURN ("unexpected operand", x);
1639     }
1640 }
1641
1642 /* The PRINT_OPERAND_ADDRESS worker.  */
1643
1644 void
1645 cris_print_operand_address (FILE *file, rtx x)
1646 {
1647   /* All these were inside MEM:s so output indirection characters.  */
1648   putc ('[', file);
1649
1650   if (CONSTANT_ADDRESS_P (x))
1651     cris_output_addr_const (file, x);
1652   else if (BASE_OR_AUTOINCR_P (x))
1653     cris_print_base (x, file);
1654   else if (GET_CODE (x) == PLUS)
1655     {
1656       rtx x1, x2;
1657
1658       x1 = XEXP (x, 0);
1659       x2 = XEXP (x, 1);
1660       if (BASE_P (x1))
1661         {
1662           cris_print_base (x1, file);
1663           cris_print_index (x2, file);
1664         }
1665       else if (BASE_P (x2))
1666         {
1667           cris_print_base (x2, file);
1668           cris_print_index (x1, file);
1669         }
1670       else
1671         LOSE_AND_RETURN ("unrecognized address", x);
1672     }
1673   else if (GET_CODE (x) == MEM)
1674     {
1675       /* A DIP.  Output more indirection characters.  */
1676       putc ('[', file);
1677       cris_print_base (XEXP (x, 0), file);
1678       putc (']', file);
1679     }
1680   else
1681     LOSE_AND_RETURN ("unrecognized address", x);
1682
1683   putc (']', file);
1684 }
1685
1686 /* The RETURN_ADDR_RTX worker.
1687    We mark that the return address is used, either by EH or
1688    __builtin_return_address, for use by the function prologue and
1689    epilogue.  FIXME: This isn't optimal; we just use the mark in the
1690    prologue and epilogue to say that the return address is to be stored
1691    in the stack frame.  We could return SRP for leaf-functions and use the
1692    initial-value machinery.  */
1693
1694 rtx
1695 cris_return_addr_rtx (int count, rtx frameaddr ATTRIBUTE_UNUSED)
1696 {
1697   cfun->machine->needs_return_address_on_stack = 1;
1698
1699   /* The return-address is stored just above the saved frame-pointer (if
1700      present).  Apparently we can't eliminate from the frame-pointer in
1701      that direction, so use the incoming args (maybe pretended) pointer.  */
1702   return count == 0
1703     ? gen_rtx_MEM (Pmode, plus_constant (virtual_incoming_args_rtx, -4))
1704     : NULL_RTX;
1705 }
1706
1707 /* Accessor used in cris.md:return because cfun->machine isn't available
1708    there.  */
1709
1710 int
1711 cris_return_address_on_stack ()
1712 {
1713   return cfun->machine->needs_return_address_on_stack;
1714 }
1715
1716 /* This used to be the INITIAL_FRAME_POINTER_OFFSET worker; now only
1717    handles FP -> SP elimination offset.  */
1718
1719 static int
1720 cris_initial_frame_pointer_offset (void)
1721 {
1722   int regno;
1723
1724   /* Initial offset is 0 if we don't have a frame pointer.  */
1725   int offs = 0;
1726
1727   /* And 4 for each register pushed.  */
1728   for (regno = 0; regno < FIRST_PSEUDO_REGISTER; regno++)
1729     if ((((regs_ever_live[regno]
1730            && !call_used_regs[regno])
1731           || (regno == (int) PIC_OFFSET_TABLE_REGNUM
1732               && (current_function_uses_pic_offset_table
1733                   /* It is saved anyway, if there would be a gap.  */
1734                   || (flag_pic
1735                       && regs_ever_live[regno + 1]
1736                       && !call_used_regs[regno + 1]))))
1737          && (regno != FRAME_POINTER_REGNUM || !frame_pointer_needed)
1738          && regno != CRIS_SRP_REGNUM)
1739         || (current_function_calls_eh_return
1740             && (regno == EH_RETURN_DATA_REGNO (0)
1741                 || regno == EH_RETURN_DATA_REGNO (1)
1742                 || regno == EH_RETURN_DATA_REGNO (2)
1743                 || regno == EH_RETURN_DATA_REGNO (3))))
1744       offs += 4;
1745
1746   /* And then, last, we add the locals allocated.  */
1747   offs += get_frame_size ();
1748
1749   /* And more; the accumulated args size.  */
1750   offs += current_function_outgoing_args_size;
1751
1752   /* Then round it off, in case we use aligned stack.  */
1753   if (TARGET_STACK_ALIGN)
1754     offs = TARGET_ALIGN_BY_32 ? (offs + 3) & ~3 : (offs + 1) & ~1;
1755
1756   return offs;
1757 }
1758
1759 /* The INITIAL_ELIMINATION_OFFSET worker.
1760    Calculate the difference between imaginary registers such as frame
1761    pointer and the stack pointer.  Used to eliminate the frame pointer
1762    and imaginary arg pointer.  */
1763
1764 int
1765 cris_initial_elimination_offset (int fromreg, int toreg)
1766 {
1767   int fp_sp_offset
1768     = cris_initial_frame_pointer_offset ();
1769
1770   /* We should be able to use regs_ever_live and related prologue
1771      information here, or alpha should not as well.  */
1772   int return_address_on_stack
1773     = regs_ever_live[CRIS_SRP_REGNUM]
1774     || cfun->machine->needs_return_address_on_stack != 0;
1775
1776   /* Here we act as if the frame-pointer were needed.  */
1777   int ap_fp_offset = 4 + (return_address_on_stack ? 4 : 0);
1778
1779   if (fromreg == ARG_POINTER_REGNUM
1780       && toreg == FRAME_POINTER_REGNUM)
1781     return ap_fp_offset;
1782
1783   /* Between the frame pointer and the stack are only "normal" stack
1784      variables and saved registers.  */
1785   if (fromreg == FRAME_POINTER_REGNUM
1786       && toreg == STACK_POINTER_REGNUM)
1787     return fp_sp_offset;
1788
1789   /* We need to balance out the frame pointer here.  */
1790   if (fromreg == ARG_POINTER_REGNUM
1791       && toreg == STACK_POINTER_REGNUM)
1792     return ap_fp_offset + fp_sp_offset - 4;
1793
1794   abort ();
1795 }
1796
1797 /*  This function looks into the pattern to see how this insn affects
1798     condition codes.
1799
1800     Used when to eliminate test insns before a condition-code user,
1801     such as a "scc" insn or a conditional branch.  This includes
1802     checking if the entities that cc was updated by, are changed by the
1803     operation.
1804
1805     Currently a jumble of the old peek-inside-the-insn and the newer
1806     check-cc-attribute methods.  */
1807
1808 void
1809 cris_notice_update_cc (rtx exp, rtx insn)
1810 {
1811   /* Check if user specified "-mcc-init" as a bug-workaround.  FIXME:
1812      TARGET_CCINIT does not work; we must set CC_REVERSED as below.
1813      Several testcases will otherwise fail, for example
1814      gcc.c-torture/execute/20000217-1.c -O0 and -O1.  */
1815   if (TARGET_CCINIT)
1816     {
1817       CC_STATUS_INIT;
1818       return;
1819     }
1820
1821   /* Slowly, we're converting to using attributes to control the setting
1822      of condition-code status.  */
1823   switch (get_attr_cc (insn))
1824     {
1825     case CC_NONE:
1826       /* Even if it is "none", a setting may clobber a previous
1827          cc-value, so check.  */
1828       if (GET_CODE (exp) == SET)
1829         {
1830           if (cc_status.value1
1831               && cris_reg_overlap_mentioned_p (SET_DEST (exp),
1832                                              cc_status.value1))
1833             cc_status.value1 = 0;
1834
1835           if (cc_status.value2
1836               && cris_reg_overlap_mentioned_p (SET_DEST (exp),
1837                                              cc_status.value2))
1838             cc_status.value2 = 0;
1839         }
1840       return;
1841
1842     case CC_CLOBBER:
1843       CC_STATUS_INIT;
1844       break;
1845
1846     case CC_NORMAL:
1847       /* Which means, for:
1848          (set (cc0) (...)):
1849          CC is (...).
1850
1851          (set (reg) (...)):
1852          CC is (reg) and (...) - unless (...) is 0, then CC does not change.
1853          CC_NO_OVERFLOW unless (...) is reg or mem.
1854
1855          (set (mem) (...)):
1856          CC does not change.
1857
1858          (set (pc) (...)):
1859          CC does not change.
1860
1861          (parallel
1862           (set (reg1) (mem (bdap/biap)))
1863           (set (reg2) (bdap/biap))):
1864          CC is (reg1) and (mem (reg2))
1865
1866          (parallel
1867           (set (mem (bdap/biap)) (reg1)) [or 0]
1868           (set (reg2) (bdap/biap))):
1869          CC does not change.
1870
1871          (where reg and mem includes strict_low_parts variants thereof)
1872
1873          For all others, assume CC is clobbered.
1874          Note that we do not have to care about setting CC_NO_OVERFLOW,
1875          since the overflow flag is set to 0 (i.e. right) for
1876          instructions where it does not have any sane sense, but where
1877          other flags have meanings.  (This includes shifts; the carry is
1878          not set by them).
1879
1880          Note that there are other parallel constructs we could match,
1881          but we don't do that yet.  */
1882
1883       if (GET_CODE (exp) == SET)
1884         {
1885           /* FIXME: Check when this happens.  It looks like we should
1886              actually do a CC_STATUS_INIT here to be safe.  */
1887           if (SET_DEST (exp) == pc_rtx)
1888             return;
1889
1890           /* Record CC0 changes, so we do not have to output multiple
1891              test insns.  */
1892           if (SET_DEST (exp) == cc0_rtx)
1893             {
1894               cc_status.value1 = SET_SRC (exp);
1895               cc_status.value2 = 0;
1896
1897               /* Handle flags for the special btstq on one bit.  */
1898               if (GET_CODE (SET_SRC (exp)) == ZERO_EXTRACT
1899                   && XEXP (SET_SRC (exp), 1) == const1_rtx)
1900                 {
1901                   if (GET_CODE (XEXP (SET_SRC (exp), 0)) == CONST_INT)
1902                     /* Using cmpq.  */
1903                     cc_status.flags = CC_INVERTED;
1904                   else
1905                     /* A one-bit btstq.  */
1906                     cc_status.flags = CC_Z_IN_NOT_N;
1907                 }
1908               else
1909                 cc_status.flags = 0;
1910
1911               if (GET_CODE (SET_SRC (exp)) == COMPARE)
1912                 {
1913                   if (!REG_P (XEXP (SET_SRC (exp), 0))
1914                       && XEXP (SET_SRC (exp), 1) != const0_rtx)
1915                     /* For some reason gcc will not canonicalize compare
1916                        operations, reversing the sign by itself if
1917                        operands are in wrong order.  */
1918                     /* (But NOT inverted; eq is still eq.) */
1919                     cc_status.flags = CC_REVERSED;
1920
1921                   /* This seems to be overlooked by gcc.  FIXME: Check again.
1922                      FIXME:  Is it really safe?  */
1923                   cc_status.value2
1924                     = gen_rtx_MINUS (GET_MODE (SET_SRC (exp)),
1925                                      XEXP (SET_SRC (exp), 0),
1926                                      XEXP (SET_SRC (exp), 1));
1927                 }
1928               return;
1929             }
1930           else if (REG_P (SET_DEST (exp))
1931                    || (GET_CODE (SET_DEST (exp)) == STRICT_LOW_PART
1932                        && REG_P (XEXP (SET_DEST (exp), 0))))
1933             {
1934               /* A register is set; normally CC is set to show that no
1935                  test insn is needed.  Catch the exceptions.  */
1936
1937               /* If not to cc0, then no "set"s in non-natural mode give
1938                  ok cc0...  */
1939               if (GET_MODE_SIZE (GET_MODE (SET_DEST (exp))) > UNITS_PER_WORD
1940                   || GET_MODE_CLASS (GET_MODE (SET_DEST (exp))) == MODE_FLOAT)
1941                 {
1942                   /* ... except add:s and sub:s in DImode.  */
1943                   if (GET_MODE (SET_DEST (exp)) == DImode
1944                       && (GET_CODE (SET_SRC (exp)) == PLUS
1945                           || GET_CODE (SET_SRC (exp)) == MINUS))
1946                     {
1947                       cc_status.flags = 0;
1948                       cc_status.value1 = SET_DEST (exp);
1949                       cc_status.value2 = SET_SRC (exp);
1950
1951                       if (cris_reg_overlap_mentioned_p (cc_status.value1,
1952                                                         cc_status.value2))
1953                         cc_status.value2 = 0;
1954
1955                       /* Add and sub may set V, which gets us
1956                          unoptimizable results in "gt" and "le" condition
1957                          codes.  */
1958                       cc_status.flags |= CC_NO_OVERFLOW;
1959
1960                       return;
1961                     }
1962                 }
1963               else if (SET_SRC (exp) == const0_rtx)
1964                 {
1965                   /* There's no CC0 change when clearing a register or
1966                      memory.  Just check for overlap.  */
1967                   if ((cc_status.value1
1968                        && cris_reg_overlap_mentioned_p (SET_DEST (exp),
1969                                                         cc_status.value1)))
1970                     cc_status.value1 = 0;
1971
1972                   if ((cc_status.value2
1973                        && cris_reg_overlap_mentioned_p (SET_DEST (exp),
1974                                                         cc_status.value2)))
1975                     cc_status.value2 = 0;
1976
1977                   return;
1978                 }
1979               else
1980                 {
1981                   cc_status.flags = 0;
1982                   cc_status.value1 = SET_DEST (exp);
1983                   cc_status.value2 = SET_SRC (exp);
1984
1985                   if (cris_reg_overlap_mentioned_p (cc_status.value1,
1986                                                     cc_status.value2))
1987                     cc_status.value2 = 0;
1988
1989                   /* Some operations may set V, which gets us
1990                      unoptimizable results in "gt" and "le" condition
1991                      codes.  */
1992                   if (GET_CODE (SET_SRC (exp)) == PLUS
1993                       || GET_CODE (SET_SRC (exp)) == MINUS
1994                       || GET_CODE (SET_SRC (exp)) == NEG)
1995                     cc_status.flags |= CC_NO_OVERFLOW;
1996
1997                   return;
1998                 }
1999             }
2000           else if (GET_CODE (SET_DEST (exp)) == MEM
2001                    || (GET_CODE (SET_DEST (exp)) == STRICT_LOW_PART
2002                        && GET_CODE (XEXP (SET_DEST (exp), 0)) == MEM))
2003             {
2004               /* When SET to MEM, then CC is not changed (except for
2005                  overlap).  */
2006               if ((cc_status.value1
2007                    && cris_reg_overlap_mentioned_p (SET_DEST (exp),
2008                                                     cc_status.value1)))
2009                 cc_status.value1 = 0;
2010
2011               if ((cc_status.value2
2012                    && cris_reg_overlap_mentioned_p (SET_DEST (exp),
2013                                                     cc_status.value2)))
2014                 cc_status.value2 = 0;
2015
2016               return;
2017             }
2018         }
2019       else if (GET_CODE (exp) == PARALLEL)
2020         {
2021           if (GET_CODE (XVECEXP (exp, 0, 0)) == SET
2022               && GET_CODE (XVECEXP (exp, 0, 1)) == SET
2023               && REG_P (XEXP (XVECEXP (exp, 0, 1), 0)))
2024             {
2025               if (REG_P (XEXP (XVECEXP (exp, 0, 0), 0))
2026                   && GET_CODE (XEXP (XVECEXP (exp, 0, 0), 1)) == MEM)
2027                 {
2028                   /* For "move.S [rx=ry+o],rz", say CC reflects
2029                      value1=rz and value2=[rx] */
2030                   cc_status.value1 = XEXP (XVECEXP (exp, 0, 0), 0);
2031                   cc_status.value2
2032                     = replace_equiv_address (XEXP (XVECEXP (exp, 0, 0), 1),
2033                                              XEXP (XVECEXP (exp, 0, 1), 0));
2034                   cc_status.flags = 0;
2035
2036                   /* Huh?  A side-effect cannot change the destination
2037                      register.  */
2038                   if (cris_reg_overlap_mentioned_p (cc_status.value1,
2039                                                     cc_status.value2))
2040                     internal_error ("internal error: sideeffect-insn affecting main effect");
2041                   return;
2042                 }
2043               else if ((REG_P (XEXP (XVECEXP (exp, 0, 0), 1))
2044                         || XEXP (XVECEXP (exp, 0, 0), 1) == const0_rtx)
2045                        && GET_CODE (XEXP (XVECEXP (exp, 0, 0), 0)) == MEM)
2046                 {
2047                   /* For "move.S rz,[rx=ry+o]" and "clear.S [rx=ry+o]",
2048                      say flags are not changed, except for overlap.  */
2049                   if (cc_status.value1
2050                       && cris_reg_overlap_mentioned_p (XEXP
2051                                                        (XVECEXP
2052                                                         (exp, 0, 0), 0),
2053                                                        cc_status.value1))
2054                     cc_status.value1 = 0;
2055
2056                   if (cc_status.value1
2057                       && cris_reg_overlap_mentioned_p (XEXP
2058                                                        (XVECEXP
2059                                                         (exp, 0, 1), 0),
2060                                                        cc_status.value1))
2061                     cc_status.value1 = 0;
2062
2063                   if (cc_status.value2
2064                       && cris_reg_overlap_mentioned_p (XEXP
2065                                                        (XVECEXP
2066                                                         (exp, 0, 0), 0),
2067                                                        cc_status.value2))
2068                     cc_status.value2 = 0;
2069
2070                   if (cc_status.value2
2071                       && cris_reg_overlap_mentioned_p (XEXP
2072                                                        (XVECEXP
2073                                                         (exp, 0, 1), 0),
2074                                                        cc_status.value2))
2075                     cc_status.value2 = 0;
2076
2077                   return;
2078                 }
2079             }
2080         }
2081       break;
2082
2083     default:
2084       /* Unknown cc_attr value.  */
2085       abort ();
2086     }
2087
2088   CC_STATUS_INIT;
2089 }
2090
2091 /* Return != 0 if the return sequence for the current function is short,
2092    like "ret" or "jump [sp+]".  Prior to reloading, we can't tell how
2093    many registers must be saved, so return 0 then.  */
2094
2095 int
2096 cris_simple_epilogue (void)
2097 {
2098   int regno;
2099   int reglimit = STACK_POINTER_REGNUM;
2100   int lastreg = -1;
2101
2102   if (! reload_completed
2103       || frame_pointer_needed
2104       || get_frame_size () != 0
2105       || current_function_pretend_args_size
2106       || current_function_args_size
2107       || current_function_outgoing_args_size
2108       || current_function_calls_eh_return
2109
2110       /* If we're not supposed to emit prologue and epilogue, we must
2111          not emit return-type instructions.  */
2112       || !TARGET_PROLOGUE_EPILOGUE)
2113     return 0;
2114
2115   /* We allow a "movem [sp+],rN" to sit in front if the "jump [sp+]" or
2116      in the delay-slot of the "ret".  */
2117   for (regno = 0; regno < reglimit; regno++)
2118     if ((regs_ever_live[regno] && ! call_used_regs[regno])
2119         || (regno == (int) PIC_OFFSET_TABLE_REGNUM
2120             && (current_function_uses_pic_offset_table
2121                 /* It is saved anyway, if there would be a gap.  */
2122                 || (flag_pic
2123                     && regs_ever_live[regno + 1]
2124                     && !call_used_regs[regno + 1]))))
2125       {
2126         if (lastreg != regno - 1)
2127           return 0;
2128         lastreg = regno;
2129       }
2130
2131   return 1;
2132 }
2133
2134 /* Compute a (partial) cost for rtx X.  Return true if the complete
2135    cost has been computed, and false if subexpressions should be
2136    scanned.  In either case, *TOTAL contains the cost result.  */
2137
2138 static bool
2139 cris_rtx_costs (rtx x, int code, int outer_code, int *total)
2140 {
2141   switch (code)
2142     {
2143     case CONST_INT:
2144       {
2145         HOST_WIDE_INT val = INTVAL (x);
2146         if (val == 0)
2147           *total = 0;
2148         else if (val < 32 && val >= -32)
2149           *total = 1;
2150         /* Eight or 16 bits are a word and cycle more expensive.  */
2151         else if (val <= 32767 && val >= -32768)
2152           *total = 2;
2153         /* A 32 bit constant (or very seldom, unsigned 16 bits) costs
2154            another word.  FIXME: This isn't linear to 16 bits.  */
2155         else
2156           *total = 4;
2157         return true;
2158       }
2159
2160     case LABEL_REF:
2161       *total = 6;
2162       return true;
2163
2164     case CONST:
2165     case SYMBOL_REF:
2166       /* For PIC, we need a prefix (if it isn't already there),
2167          and the PIC register.  For a global PIC symbol, we also
2168          need a read of the GOT.  */
2169       if (flag_pic)
2170         {
2171           if (cris_got_symbol (x))
2172             *total = 2 + 4 + 6;
2173           else
2174             *total = 2 + 6;
2175         }
2176       else
2177         *total = 6;
2178       return true;
2179
2180     case CONST_DOUBLE:
2181       if (x != CONST0_RTX (GET_MODE (x) == VOIDmode ? DImode : GET_MODE (x)))
2182         *total = 12;
2183       else
2184         /* Make 0.0 cheap, else test-insns will not be used.  */
2185         *total = 0;
2186       return true;
2187
2188     case MULT:
2189       /* Identify values that are no powers of two.  Powers of 2 are
2190          taken care of already and those values should not be changed.  */
2191       if (GET_CODE (XEXP (x, 1)) != CONST_INT
2192           || exact_log2 (INTVAL (XEXP (x, 1)) < 0))
2193         {
2194           /* If we have a multiply insn, then the cost is between
2195              1 and 2 "fast" instructions.  */
2196           if (TARGET_HAS_MUL_INSNS)
2197             {
2198               *total = COSTS_N_INSNS (1) + COSTS_N_INSNS (1) / 2;
2199               return true;
2200             }
2201
2202           /* Estimate as 4 + 4 * #ofbits.  */
2203           *total = COSTS_N_INSNS (132);
2204           return true;
2205         }
2206       return false;
2207
2208     case UDIV:
2209     case MOD:
2210     case UMOD:
2211     case DIV:
2212       if (GET_CODE (XEXP (x, 1)) != CONST_INT
2213           || exact_log2 (INTVAL (XEXP (x, 1)) < 0))
2214         {
2215           /* Estimate this as 4 + 8 * #of bits.  */
2216           *total = COSTS_N_INSNS (260);
2217           return true;
2218         }
2219       return false;
2220
2221     case AND:
2222       if (GET_CODE (XEXP (x, 1)) == CONST_INT
2223           /* Two constants may actually happen before optimization.  */
2224           && GET_CODE (XEXP (x, 0)) != CONST_INT
2225           && !CONST_OK_FOR_LETTER_P (INTVAL (XEXP (x, 1)), 'I'))
2226         {
2227           *total = (rtx_cost (XEXP (x, 0), outer_code) + 2
2228                     + 2 * GET_MODE_NUNITS (GET_MODE (XEXP (x, 0))));
2229           return true;
2230         }
2231       return false;
2232
2233     case ZERO_EXTEND: case SIGN_EXTEND:
2234       *total = rtx_cost (XEXP (x, 0), outer_code);
2235       return true;
2236
2237     default:
2238       return false;
2239     }
2240 }
2241
2242 /* The ADDRESS_COST worker.  */
2243
2244 static int
2245 cris_address_cost (rtx x)
2246 {
2247   /* The metric to use for the cost-macros is unclear.
2248      The metric used here is (the number of cycles needed) / 2,
2249      where we consider equal a cycle for a word of code and a cycle to
2250      read memory.  */
2251
2252   /* The cheapest addressing modes get 0, since nothing extra is needed.  */
2253   if (BASE_OR_AUTOINCR_P (x))
2254     return 0;
2255
2256   /* An indirect mem must be a DIP.  This means two bytes extra for code,
2257      and 4 bytes extra for memory read, i.e.  (2 + 4) / 2.  */
2258   if (GET_CODE (x) == MEM)
2259     return (2 + 4) / 2;
2260
2261   /* Assume (2 + 4) / 2 for a single constant; a dword, since it needs
2262      an extra DIP prefix and 4 bytes of constant in most cases.
2263      For PIC and a symbol with a GOT entry, we double the cost since we
2264      add a [rPIC+...] offset.  A GOT-less symbol uses a BDAP prefix
2265      equivalent to the DIP prefix for non-PIC, hence the same cost.  */
2266   if (CONSTANT_P (x))
2267     return flag_pic && cris_got_symbol (x) ? 2 * (2 + 4) / 2 : (2 + 4) / 2;
2268
2269   /* Handle BIAP and BDAP prefixes.  */
2270   if (GET_CODE (x) == PLUS)
2271     {
2272       rtx tem1 = XEXP (x, 0);
2273       rtx tem2 = XEXP (x, 1);
2274
2275     /* A BIAP is 2 extra bytes for the prefix insn, nothing more.  We
2276        recognize the typical MULT which is always in tem1 because of
2277        insn canonicalization.  */
2278     if ((GET_CODE (tem1) == MULT && BIAP_INDEX_P (tem1))
2279         || REG_P (tem1))
2280       return 2 / 2;
2281
2282     /* A BDAP (quick) is 2 extra bytes.  Any constant operand to the
2283        PLUS is always found in tem2.  */
2284     if (GET_CODE (tem2) == CONST_INT
2285         && INTVAL (tem2) < 128 && INTVAL (tem2) >= -128)
2286       return 2 / 2;
2287
2288     /* A BDAP -32768 .. 32767 is like BDAP quick, but with 2 extra
2289        bytes.  */
2290     if (GET_CODE (tem2) == CONST_INT
2291         && CONST_OK_FOR_LETTER_P (INTVAL (tem2), 'L'))
2292       return (2 + 2) / 2;
2293
2294     /* A BDAP with some other constant is 2 bytes extra.  */
2295     if (CONSTANT_P (tem2))
2296       return (2 + 2 + 2) / 2;
2297
2298     /* BDAP with something indirect should have a higher cost than
2299        BIAP with register.   FIXME: Should it cost like a MEM or more?  */
2300     /* Don't need to check it, it's the only one left.
2301        FIXME:  There was a REG test missing, perhaps there are others.
2302        Think more.  */
2303     return (2 + 2 + 2) / 2;
2304   }
2305
2306   /* What else?  Return a high cost.  It matters only for valid
2307      addressing modes.  */
2308   return 10;
2309 }
2310
2311 /* Check various objections to the side-effect.  Used in the test-part
2312    of an anonymous insn describing an insn with a possible side-effect.
2313    Returns nonzero if the implied side-effect is ok.
2314
2315    code     : PLUS or MULT
2316    ops      : An array of rtx:es. lreg, rreg, rval,
2317               The variables multop and other_op are indexes into this,
2318               or -1 if they are not applicable.
2319    lreg     : The register that gets assigned in the side-effect.
2320    rreg     : One register in the side-effect expression
2321    rval     : The other register, or an int.
2322    multop   : An integer to multiply rval with.
2323    other_op : One of the entities of the main effect,
2324               whose mode we must consider.  */
2325
2326 int
2327 cris_side_effect_mode_ok (enum rtx_code code, rtx *ops,
2328                           int lreg, int rreg, int rval,
2329                           int multop, int other_op)
2330 {
2331   /* Find what value to multiply with, for rx =ry + rz * n.  */
2332   int mult = multop < 0 ? 1 : INTVAL (ops[multop]);
2333
2334   rtx reg_rtx = ops[rreg];
2335   rtx val_rtx = ops[rval];
2336
2337   /* The operands may be swapped.  Canonicalize them in reg_rtx and
2338      val_rtx, where reg_rtx always is a reg (for this constraint to
2339      match).  */
2340   if (! BASE_P (reg_rtx))
2341     reg_rtx = val_rtx, val_rtx = ops[rreg];
2342
2343   /* Don't forget to check that reg_rtx really is a reg.  If it isn't,
2344      we have no business.  */
2345   if (! BASE_P (reg_rtx))
2346     return 0;
2347
2348   /* Don't do this when -mno-split.  */
2349   if (!TARGET_SIDE_EFFECT_PREFIXES)
2350     return 0;
2351
2352   /* The mult expression may be hidden in lreg.  FIXME:  Add more
2353      commentary about that.  */
2354   if (GET_CODE (val_rtx) == MULT)
2355     {
2356       mult = INTVAL (XEXP (val_rtx, 1));
2357       val_rtx = XEXP (val_rtx, 0);
2358       code = MULT;
2359     }
2360
2361   /* First check the "other operand".  */
2362   if (other_op >= 0)
2363     {
2364       if (GET_MODE_SIZE (GET_MODE (ops[other_op])) > UNITS_PER_WORD)
2365         return 0;
2366
2367       /* Check if the lvalue register is the same as the "other
2368          operand".  If so, the result is undefined and we shouldn't do
2369          this.  FIXME:  Check again.  */
2370       if ((BASE_P (ops[lreg])
2371            && BASE_P (ops[other_op])
2372            && REGNO (ops[lreg]) == REGNO (ops[other_op]))
2373           || rtx_equal_p (ops[other_op], ops[lreg]))
2374       return 0;
2375     }
2376
2377   /* Do not accept frame_pointer_rtx as any operand.  */
2378   if (ops[lreg] == frame_pointer_rtx || ops[rreg] == frame_pointer_rtx
2379       || ops[rval] == frame_pointer_rtx
2380       || (other_op >= 0 && ops[other_op] == frame_pointer_rtx))
2381     return 0;
2382
2383   if (code == PLUS
2384       && ! BASE_P (val_rtx))
2385     {
2386
2387       /* Do not allow rx = rx + n if a normal add or sub with same size
2388          would do.  */
2389       if (rtx_equal_p (ops[lreg], reg_rtx)
2390           && GET_CODE (val_rtx) == CONST_INT
2391           && (INTVAL (val_rtx) <= 63 && INTVAL (val_rtx) >= -63))
2392         return 0;
2393
2394       /* Check allowed cases, like [r(+)?].[bwd] and const.
2395          A symbol is not allowed with PIC.  */
2396       if (CONSTANT_P (val_rtx))
2397         return flag_pic == 0 || cris_symbol (val_rtx) == 0;
2398
2399       if (GET_CODE (val_rtx) == MEM
2400           && BASE_OR_AUTOINCR_P (XEXP (val_rtx, 0)))
2401         return 1;
2402
2403       if (GET_CODE (val_rtx) == SIGN_EXTEND
2404           && GET_CODE (XEXP (val_rtx, 0)) == MEM
2405           && BASE_OR_AUTOINCR_P (XEXP (XEXP (val_rtx, 0), 0)))
2406         return 1;
2407
2408       /* If we got here, it's not a valid addressing mode.  */
2409       return 0;
2410     }
2411   else if (code == MULT
2412            || (code == PLUS && BASE_P (val_rtx)))
2413     {
2414       /* Do not allow rx = rx + ry.S, since it doesn't give better code.  */
2415       if (rtx_equal_p (ops[lreg], reg_rtx)
2416           || (mult == 1 && rtx_equal_p (ops[lreg], val_rtx)))
2417         return 0;
2418
2419       /* Do not allow bad multiply-values.  */
2420       if (mult != 1 && mult != 2 && mult != 4)
2421         return 0;
2422
2423       /* Only allow  r + ...  */
2424       if (! BASE_P (reg_rtx))
2425         return 0;
2426
2427       /* If we got here, all seems ok.
2428          (All checks need to be done above).  */
2429       return 1;
2430     }
2431
2432   /* If we get here, the caller got its initial tests wrong.  */
2433   internal_error ("internal error: cris_side_effect_mode_ok with bad operands");
2434 }
2435
2436 /* The function reg_overlap_mentioned_p in CVS (still as of 2001-05-16)
2437    does not handle the case where the IN operand is strict_low_part; it
2438    does handle it for X.  Test-case in Axis-20010516.  This function takes
2439    care of that for THIS port.  FIXME: strict_low_part is going away
2440    anyway.  */
2441
2442 static int
2443 cris_reg_overlap_mentioned_p (rtx x, rtx in)
2444 {
2445   /* The function reg_overlap_mentioned now handles when X is
2446      strict_low_part, but not when IN is a STRICT_LOW_PART.  */
2447   if (GET_CODE (in) == STRICT_LOW_PART)
2448     in = XEXP (in, 0);
2449
2450   return reg_overlap_mentioned_p (x, in);
2451 }
2452
2453 /* The TARGET_ASM_NAMED_SECTION worker.
2454    We just dispatch to the functions for ELF and a.out.  */
2455
2456 void
2457 cris_target_asm_named_section (const char *name, unsigned int flags,
2458                                tree decl)
2459 {
2460   if (! TARGET_ELF)
2461     default_no_named_section (name, flags, decl);
2462   else
2463     default_elf_asm_named_section (name, flags, decl);
2464 }
2465
2466 /* The LEGITIMATE_PIC_OPERAND_P worker.  */
2467
2468 int
2469 cris_legitimate_pic_operand (rtx x)
2470 {
2471   /* The PIC representation of a symbol with a GOT entry will be (for
2472      example; relocations differ):
2473       sym => [rPIC+sym:GOT]
2474      and for a GOT-less symbol it will be (for example, relocation differ):
2475       sym => rPIC+sym:GOTOFF
2476      so only a symbol with a GOT is by itself a valid operand, and it
2477      can't be a sum of a symbol and an offset.  */
2478   return ! cris_symbol (x) || cris_got_symbol (x);
2479 }
2480
2481 /* Return nonzero if there's a SYMBOL_REF or LABEL_REF hiding inside this
2482    CONSTANT_P.  */
2483
2484 int
2485 cris_symbol (rtx x)
2486 {
2487   switch (GET_CODE (x))
2488     {
2489     case SYMBOL_REF:
2490     case LABEL_REF:
2491       return 1;
2492
2493     case UNSPEC:
2494       /* A PLT reference.  */
2495       ASSERT_PLT_UNSPEC (x);
2496       return 1;
2497
2498     case CONST:
2499       return cris_symbol (XEXP (x, 0));
2500
2501     case PLUS:
2502     case MINUS:
2503       return cris_symbol (XEXP (x, 0)) || cris_symbol (XEXP (x, 1));
2504
2505     case CONST_INT:
2506     case CONST_DOUBLE:
2507       return 0;
2508
2509     default:
2510       fatal_insn ("unrecognized supposed constant", x);
2511     }
2512
2513   return 1;
2514 }
2515
2516 /* Return nonzero if there's a SYMBOL_REF or LABEL_REF hiding inside this
2517    CONSTANT_P, and the symbol does not need a GOT entry.  Also set
2518    current_function_uses_pic_offset_table if we're generating PIC and ever
2519    see something that would need one.  */
2520
2521 int
2522 cris_gotless_symbol (rtx x)
2523 {
2524 #ifdef ENABLE_CHECKING
2525   if (!flag_pic)
2526     abort ();
2527 #endif
2528
2529   switch (GET_CODE (x))
2530     {
2531     case UNSPEC:
2532       ASSERT_PLT_UNSPEC (x);
2533       return 1;
2534
2535     case SYMBOL_REF:
2536       if (cfun != NULL)
2537         current_function_uses_pic_offset_table = 1;
2538       return SYMBOL_REF_LOCAL_P (x);
2539
2540     case LABEL_REF:
2541       /* We don't set current_function_uses_pic_offset_table for
2542          LABEL_REF:s in here, since they are almost always originating
2543          from some branch.  The only time it does not come from a label is
2544          when GCC does something like __builtin_setjmp.  Then we get the
2545          LABEL_REF from the movsi expander, so we mark it there as a
2546          special case.  */
2547       return 1;
2548
2549     case CONST:
2550       return cris_gotless_symbol (XEXP (x, 0));
2551
2552     case PLUS:
2553     case MINUS:
2554       {
2555         int x0 = cris_gotless_symbol (XEXP (x, 0)) != 0;
2556         int x1 = cris_gotless_symbol (XEXP (x, 1)) != 0;
2557
2558         /* One and only one of them must be a local symbol.  Neither must
2559            be some other, more general kind of symbol.  */
2560         return
2561           (x0 ^ x1)
2562           && ! (x0 == 0 && cris_symbol (XEXP (x, 0)))
2563           && ! (x1 == 0 && cris_symbol (XEXP (x, 1)));
2564       }
2565
2566     case CONST_INT:
2567     case CONST_DOUBLE:
2568       return 0;
2569
2570     default:
2571       fatal_insn ("unrecognized supposed constant", x);
2572     }
2573
2574   return 1;
2575 }
2576
2577 /* Return nonzero if there's a SYMBOL_REF or LABEL_REF hiding inside this
2578    CONSTANT_P, and the symbol needs a GOT entry.  */
2579
2580 int
2581 cris_got_symbol (rtx x)
2582 {
2583 #ifdef ENABLE_CHECKING
2584   if (!flag_pic)
2585     abort ();
2586 #endif
2587
2588   switch (GET_CODE (x))
2589     {
2590     case UNSPEC:
2591       ASSERT_PLT_UNSPEC (x);
2592       return 0;
2593
2594     case SYMBOL_REF:
2595       if (cfun != NULL)
2596         current_function_uses_pic_offset_table = 1;
2597       return ! SYMBOL_REF_LOCAL_P (x);
2598
2599     case CONST:
2600       return cris_got_symbol (XEXP (x, 0));
2601
2602     case LABEL_REF:
2603       /* A LABEL_REF is never visible as a symbol outside the local
2604          function.  */
2605     case PLUS:
2606     case MINUS:
2607       /* Nope, can't access the GOT for "symbol + offset".  */
2608       return 0;
2609
2610     case CONST_INT:
2611     case CONST_DOUBLE:
2612       return 0;
2613
2614     default:
2615       fatal_insn ("unrecognized supposed constant in cris_global_pic_symbol",
2616                   x);
2617     }
2618
2619   return 1;
2620 }
2621
2622 /* The OVERRIDE_OPTIONS worker.
2623    As is the norm, this also parses -mfoo=bar type parameters.  */
2624
2625 void
2626 cris_override_options (void)
2627 {
2628   if (cris_max_stackframe_str)
2629     {
2630       cris_max_stackframe = atoi (cris_max_stackframe_str);
2631
2632       /* Do some sanity checking.  */
2633       if (cris_max_stackframe < 0 || cris_max_stackframe > 0x20000000)
2634         internal_error ("-max-stackframe=%d is not usable, not between 0 and %d",
2635                         cris_max_stackframe, 0x20000000);
2636     }
2637
2638   /* Let "-metrax4" and "-metrax100" change the cpu version.  */
2639   if (TARGET_SVINTO && cris_cpu_version < CRIS_CPU_SVINTO)
2640     cris_cpu_version = CRIS_CPU_SVINTO;
2641   else if (TARGET_ETRAX4_ADD && cris_cpu_version < CRIS_CPU_ETRAX4)
2642     cris_cpu_version = CRIS_CPU_ETRAX4;
2643
2644   /* Parse -march=... and its synonym, the deprecated -mcpu=...  */
2645   if (cris_cpu_str)
2646     {
2647       cris_cpu_version
2648         = (*cris_cpu_str == 'v' ? atoi (cris_cpu_str + 1) : -1);
2649
2650       if (strcmp ("etrax4", cris_cpu_str) == 0)
2651         cris_cpu_version = 3;
2652
2653       if (strcmp ("svinto", cris_cpu_str) == 0
2654           || strcmp ("etrax100", cris_cpu_str) == 0)
2655         cris_cpu_version = 8;
2656
2657       if (strcmp ("ng", cris_cpu_str) == 0
2658           || strcmp ("etrax100lx", cris_cpu_str) == 0)
2659         cris_cpu_version = 10;
2660
2661       if (cris_cpu_version < 0 || cris_cpu_version > 10)
2662         error ("unknown CRIS version specification in -march= or -mcpu= : %s",
2663                cris_cpu_str);
2664
2665       /* Set the target flags.  */
2666       if (cris_cpu_version >= CRIS_CPU_ETRAX4)
2667         target_flags |= TARGET_MASK_ETRAX4_ADD;
2668
2669       /* If this is Svinto or higher, align for 32 bit accesses.  */
2670       if (cris_cpu_version >= CRIS_CPU_SVINTO)
2671         target_flags
2672           |= (TARGET_MASK_SVINTO | TARGET_MASK_ALIGN_BY_32
2673               | TARGET_MASK_STACK_ALIGN | TARGET_MASK_CONST_ALIGN
2674               | TARGET_MASK_DATA_ALIGN);
2675
2676       /* Note that we do not add new flags when it can be completely
2677          described with a macro that uses -mcpu=X.  So
2678          TARGET_HAS_MUL_INSNS is (cris_cpu_version >= CRIS_CPU_NG).  */
2679     }
2680
2681   if (cris_tune_str)
2682     {
2683       int cris_tune
2684         = (*cris_tune_str == 'v' ? atoi (cris_tune_str + 1) : -1);
2685
2686       if (strcmp ("etrax4", cris_tune_str) == 0)
2687         cris_tune = 3;
2688
2689       if (strcmp ("svinto", cris_tune_str) == 0
2690           || strcmp ("etrax100", cris_tune_str) == 0)
2691         cris_tune = 8;
2692
2693       if (strcmp ("ng", cris_tune_str) == 0
2694           || strcmp ("etrax100lx", cris_tune_str) == 0)
2695         cris_tune = 10;
2696
2697       if (cris_tune < 0 || cris_tune > 10)
2698         error ("unknown CRIS cpu version specification in -mtune= : %s",
2699                cris_tune_str);
2700
2701       if (cris_tune >= CRIS_CPU_SVINTO)
2702         /* We have currently nothing more to tune than alignment for
2703            memory accesses.  */
2704         target_flags
2705           |= (TARGET_MASK_STACK_ALIGN | TARGET_MASK_CONST_ALIGN
2706               | TARGET_MASK_DATA_ALIGN | TARGET_MASK_ALIGN_BY_32);
2707     }
2708
2709   if (flag_pic)
2710     {
2711       /* Use error rather than warning, so invalid use is easily
2712          detectable.  Still change to the values we expect, to avoid
2713          further errors.  */
2714       if (! TARGET_LINUX)
2715         {
2716           error ("-fPIC and -fpic are not supported in this configuration");
2717           flag_pic = 0;
2718         }
2719
2720       /* Turn off function CSE.  We need to have the addresses reach the
2721          call expanders to get PLT-marked, as they could otherwise be
2722          compared against zero directly or indirectly.  After visiting the
2723          call expanders they will then be cse:ed, as the call expanders
2724          force_reg the addresses, effectively forcing flag_no_function_cse
2725          to 0.  */
2726       flag_no_function_cse = 1;
2727     }
2728
2729   if (write_symbols == DWARF2_DEBUG && ! TARGET_ELF)
2730     {
2731       warning ("that particular -g option is invalid with -maout and -melinux");
2732       write_symbols = DBX_DEBUG;
2733     }
2734
2735   /* Set the per-function-data initializer.  */
2736   init_machine_status = cris_init_machine_status;
2737 }
2738
2739 /* The TARGET_ASM_OUTPUT_MI_THUNK worker.  */
2740
2741 static void
2742 cris_asm_output_mi_thunk (FILE *stream,
2743                           tree thunkdecl ATTRIBUTE_UNUSED,
2744                           HOST_WIDE_INT delta,
2745                           HOST_WIDE_INT vcall_offset ATTRIBUTE_UNUSED,
2746                           tree funcdecl)
2747 {
2748   if (delta > 0)
2749     fprintf (stream, "\tadd%s " HOST_WIDE_INT_PRINT_DEC ",$%s\n",
2750              ADDITIVE_SIZE_MODIFIER (delta), delta,
2751              reg_names[CRIS_FIRST_ARG_REG]);
2752   else if (delta < 0)
2753     fprintf (stream, "\tsub%s " HOST_WIDE_INT_PRINT_DEC ",$%s\n",
2754              ADDITIVE_SIZE_MODIFIER (-delta), -delta,
2755              reg_names[CRIS_FIRST_ARG_REG]);
2756
2757   if (flag_pic)
2758     {
2759       const char *name = XSTR (XEXP (DECL_RTL (funcdecl), 0), 0);
2760
2761       name = (* targetm.strip_name_encoding) (name);
2762       fprintf (stream, "add.d ");
2763       assemble_name (stream, name);
2764       fprintf (stream, "%s,$pc\n", CRIS_PLT_PCOFFSET_SUFFIX);
2765     }
2766   else
2767     {
2768       fprintf (stream, "jump ");
2769       assemble_name (stream, XSTR (XEXP (DECL_RTL (funcdecl), 0), 0));
2770       fprintf (stream, "\n");
2771     }
2772 }
2773
2774 /* Boilerplate emitted at start of file.  
2775
2776    NO_APP *only at file start* means faster assembly.  It also means
2777    comments are not allowed.  In some cases comments will be output
2778    for debugging purposes.  Make sure they are allowed then.
2779
2780    We want a .file directive only if TARGET_ELF.  */
2781 static void
2782 cris_file_start (void)
2783 {
2784   /* These expressions can vary at run time, so we cannot put
2785      them into TARGET_INITIALIZER.  */
2786   targetm.file_start_app_off = !(TARGET_PDEBUG || flag_print_asm_name);
2787   targetm.file_start_file_directive = TARGET_ELF;
2788
2789   default_file_start ();
2790 }
2791
2792 /* Rename the function calls for integer multiply and divide.  */
2793 static void
2794 cris_init_libfuncs (void)
2795 {
2796   set_optab_libfunc (smul_optab, SImode, "__Mul");
2797   set_optab_libfunc (sdiv_optab, SImode, "__Div");
2798   set_optab_libfunc (udiv_optab, SImode, "__Udiv");
2799   set_optab_libfunc (smod_optab, SImode, "__Mod");
2800   set_optab_libfunc (umod_optab, SImode, "__Umod");
2801 }
2802
2803 /* The INIT_EXPANDERS worker sets the per-function-data initializer and
2804    mark functions.  */
2805
2806 void
2807 cris_init_expanders (void)
2808 {
2809   /* Nothing here at the moment.  */
2810 }
2811
2812 /* Zero initialization is OK for all current fields.  */
2813
2814 static struct machine_function *
2815 cris_init_machine_status (void)
2816 {
2817   return ggc_alloc_cleared (sizeof (struct machine_function));
2818 }
2819
2820 /* Split a 2 word move (DI or presumably DF) into component parts.
2821    Originally a copy of gen_split_move_double in m32r.c.  */
2822
2823 rtx
2824 cris_split_movdx (rtx *operands)
2825 {
2826   enum machine_mode mode = GET_MODE (operands[0]);
2827   rtx dest = operands[0];
2828   rtx src  = operands[1];
2829   rtx val;
2830
2831   /* We used to have to handle (SUBREG (MEM)) here, but that should no
2832      longer happen; after reload there are no SUBREGs any more, and we're
2833      only called after reload.  */
2834   if (GET_CODE (dest) == SUBREG || GET_CODE (src) == SUBREG)
2835     abort ();
2836
2837   start_sequence ();
2838   if (GET_CODE (dest) == REG)
2839     {
2840       int dregno = REGNO (dest);
2841
2842       /* Reg-to-reg copy.  */
2843       if (GET_CODE (src) == REG)
2844         {
2845           int sregno = REGNO (src);
2846
2847           int reverse = (dregno == sregno + 1);
2848
2849           /* We normally copy the low-numbered register first.  However, if
2850              the first register operand 0 is the same as the second register of
2851              operand 1, we must copy in the opposite order.  */
2852           emit_insn (gen_rtx_SET (VOIDmode,
2853                                   operand_subword (dest, reverse, TRUE, mode),
2854                                   operand_subword (src, reverse, TRUE, mode)));
2855
2856           emit_insn (gen_rtx_SET (VOIDmode,
2857                                   operand_subword (dest, !reverse, TRUE, mode),
2858                                   operand_subword (src, !reverse, TRUE, mode)));
2859         }
2860       /* Constant-to-reg copy.  */
2861       else if (GET_CODE (src) == CONST_INT || GET_CODE (src) == CONST_DOUBLE)
2862         {
2863           rtx words[2];
2864           split_double (src, &words[0], &words[1]);
2865           emit_insn (gen_rtx_SET (VOIDmode,
2866                                   operand_subword (dest, 0, TRUE, mode),
2867                                   words[0]));
2868
2869           emit_insn (gen_rtx_SET (VOIDmode,
2870                                   operand_subword (dest, 1, TRUE, mode),
2871                                   words[1]));
2872         }
2873       /* Mem-to-reg copy.  */
2874       else if (GET_CODE (src) == MEM)
2875         {
2876           /* If the high-address word is used in the address, we must load it
2877              last.  Otherwise, load it first.  */
2878           rtx addr = XEXP (src, 0);
2879           int reverse
2880             = (refers_to_regno_p (dregno, dregno + 1, addr, NULL) != 0);
2881
2882           /* The original code implies that we can't do
2883              move.x [rN+],rM  move.x [rN],rM+1
2884              when rN is dead, because of REG_NOTES damage.  That is
2885              consistent with what I've seen, so don't try it.
2886
2887              We have two different cases here; if the addr is POST_INC,
2888              just pass it through, otherwise add constants.  */
2889
2890           if (GET_CODE (addr) == POST_INC)
2891             {
2892               emit_insn (gen_rtx_SET (VOIDmode,
2893                                       operand_subword (dest, 0, TRUE, mode),
2894                                       change_address (src, SImode, addr)));
2895               emit_insn (gen_rtx_SET (VOIDmode,
2896                                       operand_subword (dest, 1, TRUE, mode),
2897                                       change_address (src, SImode, addr)));
2898             }
2899           else
2900             {
2901               /* Make sure we don't get any other addresses with
2902                  embedded postincrements.  They should be stopped in
2903                  GO_IF_LEGITIMATE_ADDRESS, but we're here for your
2904                  safety.  */
2905               if (side_effects_p (addr))
2906                 fatal_insn ("unexpected side-effects in address", addr);
2907
2908               emit_insn (gen_rtx_SET
2909                          (VOIDmode,
2910                           operand_subword (dest, reverse, TRUE, mode),
2911                           change_address
2912                           (src, SImode,
2913                            plus_constant (addr,
2914                                           reverse * UNITS_PER_WORD))));
2915               emit_insn (gen_rtx_SET
2916                          (VOIDmode,
2917                           operand_subword (dest, ! reverse, TRUE, mode),
2918                           change_address
2919                           (src, SImode,
2920                            plus_constant (addr,
2921                                           (! reverse) *
2922                                           UNITS_PER_WORD))));
2923             }
2924         }
2925       else
2926         abort ();
2927     }
2928   /* Reg-to-mem copy or clear mem.  */
2929   else if (GET_CODE (dest) == MEM
2930            && (GET_CODE (src) == REG
2931                || src == const0_rtx
2932                || src == CONST0_RTX (DFmode)))
2933     {
2934       rtx addr = XEXP (dest, 0);
2935
2936       if (GET_CODE (addr) == POST_INC)
2937         {
2938           emit_insn (gen_rtx_SET (VOIDmode,
2939                                   change_address (dest, SImode, addr),
2940                                   operand_subword (src, 0, TRUE, mode)));
2941           emit_insn (gen_rtx_SET (VOIDmode,
2942                                   change_address (dest, SImode, addr),
2943                                   operand_subword (src, 1, TRUE, mode)));
2944         }
2945       else
2946         {
2947           /* Make sure we don't get any other addresses with embedded
2948              postincrements.  They should be stopped in
2949              GO_IF_LEGITIMATE_ADDRESS, but we're here for your safety.  */
2950           if (side_effects_p (addr))
2951             fatal_insn ("unexpected side-effects in address", addr);
2952
2953           emit_insn (gen_rtx_SET
2954                      (VOIDmode,
2955                       change_address (dest, SImode, addr),
2956                       operand_subword (src, 0, TRUE, mode)));
2957
2958           emit_insn (gen_rtx_SET
2959                      (VOIDmode,
2960                       change_address (dest, SImode,
2961                                       plus_constant (addr,
2962                                                      UNITS_PER_WORD)),
2963                       operand_subword (src, 1, TRUE, mode)));
2964         }
2965     }
2966
2967   else
2968     abort ();
2969
2970   val = get_insns ();
2971   end_sequence ();
2972   return val;
2973 }
2974
2975 /* This is in essence a copy of output_addr_const altered to output
2976    symbolic operands as PIC.
2977
2978    FIXME: Add hooks similar to ASM_OUTPUT_SYMBOL_REF to get this effect in
2979    the "real" output_addr_const.  All we need is one for LABEL_REF (and
2980    one for CODE_LABEL?).  */
2981
2982 void
2983 cris_output_addr_const (FILE *file, rtx x)
2984 {
2985   int is_plt = 0;
2986
2987 restart:
2988   switch (GET_CODE (x))
2989     {
2990     case UNSPEC:
2991       ASSERT_PLT_UNSPEC (x);
2992       x = XVECEXP (x, 0, 0);
2993       is_plt = 1;
2994
2995       /* Fall through.  */
2996     case SYMBOL_REF:
2997       if (flag_pic)
2998         {
2999           const char *origstr = XSTR (x, 0);
3000           const char *str;
3001
3002           str = (* targetm.strip_name_encoding) (origstr);
3003
3004           if (is_plt)
3005             {
3006               if (cris_pic_sympart_only)
3007                 {
3008                   assemble_name (file, str);
3009                   fprintf (file, ":PLTG");
3010                 }
3011               else
3012                 {
3013                   if (TARGET_AVOID_GOTPLT)
3014                     /* We shouldn't get here.  */
3015                     abort ();
3016
3017                   fprintf (file, "[$%s+", reg_names [PIC_OFFSET_TABLE_REGNUM]);
3018                   assemble_name (file, XSTR (x, 0));
3019
3020                   if (flag_pic == 1)
3021                     fprintf (file, ":GOTPLT16]");
3022                   else
3023                     fprintf (file, ":GOTPLT]");
3024                 }
3025             }
3026           else if (cris_gotless_symbol (x))
3027             {
3028               if (! cris_pic_sympart_only)
3029                 fprintf (file, "$%s+", reg_names [PIC_OFFSET_TABLE_REGNUM]);
3030               assemble_name (file, str);
3031               fprintf (file, ":GOTOFF");
3032             }
3033           else if (cris_got_symbol (x))
3034             {
3035               if (cris_pic_sympart_only)
3036                 abort ();
3037               fprintf (file, "[$%s+", reg_names [PIC_OFFSET_TABLE_REGNUM]);
3038               assemble_name (file, XSTR (x, 0));
3039
3040               if (flag_pic == 1)
3041                 fprintf (file, ":GOT16]");
3042               else
3043                 fprintf (file, ":GOT]");
3044             }
3045           else
3046             LOSE_AND_RETURN ("unexpected PIC symbol", x);
3047
3048           /* Sanity check.  */
3049           if (! current_function_uses_pic_offset_table)
3050             output_operand_lossage ("PIC register isn't set up");
3051         }
3052       else
3053         assemble_name (file, XSTR (x, 0));
3054       break;
3055
3056     case LABEL_REF:
3057       /* If we get one of those here, it should be dressed as PIC.  Branch
3058          labels are normally output with the 'l' specifier, which means it
3059          will go directly to output_asm_label and not end up here.  */
3060       if (GET_CODE (XEXP (x, 0)) != CODE_LABEL
3061           && (GET_CODE (XEXP (x, 0)) != NOTE
3062               || NOTE_LINE_NUMBER (XEXP (x, 0)) != NOTE_INSN_DELETED_LABEL))
3063         fatal_insn ("unexpected address expression", x);
3064
3065       if (flag_pic)
3066         {
3067           if (cris_gotless_symbol (x))
3068             {
3069               if (! cris_pic_sympart_only)
3070                 fprintf (file, "$%s+", reg_names [PIC_OFFSET_TABLE_REGNUM]);
3071               cris_output_addr_const (file, XEXP (x, 0));
3072
3073               fprintf (file, ":GOTOFF");
3074             }
3075           else
3076             /* Labels are never marked as global symbols.  */
3077             fatal_insn ("unexpected PIC symbol", x);
3078
3079           /* Sanity check.  */
3080           if (! current_function_uses_pic_offset_table)
3081             internal_error ("emitting PIC operand, but PIC register isn't set up");
3082           break;
3083         }
3084
3085       output_addr_const (file, x);
3086       break;
3087
3088     case NOTE:
3089       if (NOTE_LINE_NUMBER (x) != NOTE_INSN_DELETED_LABEL)
3090         fatal_insn ("unexpected NOTE as addr_const:", x);
3091     case CODE_LABEL:
3092     case CONST_INT:
3093     case CONST_DOUBLE:
3094     case ZERO_EXTEND:
3095     case SIGN_EXTEND:
3096       output_addr_const (file, x);
3097       break;
3098
3099     case CONST:
3100       /* This used to output parentheses around the expression,
3101          but that does not work on the 386 (either ATT or BSD assembler).  */
3102       cris_output_addr_const (file, XEXP (x, 0));
3103       break;
3104
3105     case PLUS:
3106       /* Some assemblers need integer constants to appear last (e.g. masm).  */
3107       if (GET_CODE (XEXP (x, 0)) == CONST_INT)
3108         {
3109           cris_output_addr_const (file, XEXP (x, 1));
3110           if (INTVAL (XEXP (x, 0)) >= 0)
3111             fprintf (file, "+");
3112           output_addr_const (file, XEXP (x, 0));
3113         }
3114       else
3115         {
3116           cris_output_addr_const (file, XEXP (x, 0));
3117           if (GET_CODE (XEXP (x, 1)) != CONST_INT
3118               || INTVAL (XEXP (x, 1)) >= 0)
3119             fprintf (file, "+");
3120           cris_output_addr_const (file, XEXP (x, 1));
3121         }
3122       break;
3123
3124     case MINUS:
3125       /* Avoid outputting things like x-x or x+5-x,
3126          since some assemblers can't handle that.  */
3127       x = simplify_subtraction (x);
3128       if (GET_CODE (x) != MINUS)
3129         goto restart;
3130
3131       cris_output_addr_const (file, XEXP (x, 0));
3132       fprintf (file, "-");
3133       if ((GET_CODE (XEXP (x, 1)) == CONST_INT
3134            && INTVAL (XEXP (x, 1)) < 0)
3135           || GET_CODE (XEXP (x, 1)) != CONST_INT)
3136         {
3137           fprintf (file, "%s", targetm.asm_out.open_paren);
3138           cris_output_addr_const (file, XEXP (x, 1));
3139           fprintf (file, "%s", targetm.asm_out.close_paren);
3140         }
3141       else
3142         output_addr_const (file, XEXP (x, 1));
3143       break;
3144
3145     default:
3146       LOSE_AND_RETURN ("unexpected address expression", x);
3147     }
3148 }
3149
3150 /* Worker function for TARGET_STRUCT_VALUE_RTX.  */
3151
3152 static rtx
3153 cris_struct_value_rtx (tree fntype ATTRIBUTE_UNUSED,
3154                        int incoming ATTRIBUTE_UNUSED)
3155 {
3156   return gen_rtx_REG (Pmode, CRIS_STRUCT_VALUE_REGNUM);
3157 }
3158
3159 /* Worker function for TARGET_SETUP_INCOMING_VARARGS.  */
3160
3161 static void
3162 cris_setup_incoming_varargs (CUMULATIVE_ARGS *ca,
3163                              enum machine_mode mode ATTRIBUTE_UNUSED,
3164                              tree type ATTRIBUTE_UNUSED,
3165                              int *pretend_arg_size,
3166                              int second_time)
3167 {
3168   if (ca->regs < CRIS_MAX_ARGS_IN_REGS)
3169     *pretend_arg_size = (CRIS_MAX_ARGS_IN_REGS - ca->regs) * 4;
3170   if (TARGET_PDEBUG)
3171     {
3172       fprintf (asm_out_file,
3173                "\n; VA:: ANSI: %d args before, anon @ #%d, %dtime\n",
3174                ca->regs, *pretend_arg_size, second_time);
3175     }
3176 }
3177
3178 /* Return true if TYPE must be passed by invisible reference.
3179    For cris, we pass <= 8 bytes by value, others by reference.  */
3180
3181 static bool
3182 cris_pass_by_reference (CUMULATIVE_ARGS *ca ATTRIBUTE_UNUSED,
3183                         enum machine_mode mode, tree type,
3184                         bool named ATTRIBUTE_UNUSED)
3185 {
3186   return (targetm.calls.must_pass_in_stack (mode, type)
3187           || CRIS_FUNCTION_ARG_SIZE (mode, type) > 8);
3188 }
3189
3190
3191 static int
3192 cris_arg_partial_bytes (CUMULATIVE_ARGS *ca, enum machine_mode mode,
3193                         tree type, bool named ATTRIBUTE_UNUSED)
3194 {
3195   if (ca->regs == CRIS_MAX_ARGS_IN_REGS - 1
3196       && !targetm.calls.must_pass_in_stack (mode, type)
3197       && CRIS_FUNCTION_ARG_SIZE (mode, type) > 4
3198       && CRIS_FUNCTION_ARG_SIZE (mode, type) <= 8)
3199     return UNITS_PER_WORD;
3200   else
3201     return 0;
3202 }
3203
3204
3205 #if 0
3206 /* Various small functions to replace macros.  Only called from a
3207    debugger.  They might collide with gcc functions or system functions,
3208    so only emit them when '#if 1' above.  */
3209
3210 enum rtx_code Get_code (rtx);
3211
3212 enum rtx_code
3213 Get_code (rtx x)
3214 {
3215   return GET_CODE (x);
3216 }
3217
3218 const char *Get_mode (rtx);
3219
3220 const char *
3221 Get_mode (rtx x)
3222 {
3223   return GET_MODE_NAME (GET_MODE (x));
3224 }
3225
3226 rtx Xexp (rtx, int);
3227
3228 rtx
3229 Xexp (rtx x, int n)
3230 {
3231   return XEXP (x, n);
3232 }
3233
3234 rtx Xvecexp (rtx, int, int);
3235
3236 rtx
3237 Xvecexp (rtx x, int n, int m)
3238 {
3239   return XVECEXP (x, n, m);
3240 }
3241
3242 int Get_rtx_len (rtx);
3243
3244 int
3245 Get_rtx_len (rtx x)
3246 {
3247   return GET_RTX_LENGTH (GET_CODE (x));
3248 }
3249
3250 /* Use upper-case to distinguish from local variables that are sometimes
3251    called next_insn and prev_insn.  */
3252
3253 rtx Next_insn (rtx);
3254
3255 rtx
3256 Next_insn (rtx insn)
3257 {
3258   return NEXT_INSN (insn);
3259 }
3260
3261 rtx Prev_insn (rtx);
3262
3263 rtx
3264 Prev_insn (rtx insn)
3265 {
3266   return PREV_INSN (insn);
3267 }
3268 #endif
3269
3270 #include "gt-cris.h"
3271
3272 /*
3273  * Local variables:
3274  * eval: (c-set-style "gnu")
3275  * indent-tabs-mode: t
3276  * End:
3277  */