OSDN Git Service

2009-05-14 Paolo Bonzini <bonzini@gnu.org>
[pf3gnuchains/gcc-fork.git] / gcc / config / crx / crx.c
1 /* Output routines for GCC for CRX.
2    Copyright (C) 1991, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
3    2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
4
5    This file is part of GCC.
6
7    GCC is free software; you can redistribute it and/or modify it
8    under the terms of the GNU General Public License as published
9    by the Free Software Foundation; either version 3, or (at your
10    option) any later version.
11
12    GCC is distributed in the hope that it will be useful, but WITHOUT
13    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14    or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
15    License for more details.
16
17    You should have received a copy of the GNU General Public License
18    along with GCC; see the file COPYING3.  If not see
19    <http://www.gnu.org/licenses/>.  */
20
21 /*****************************************************************************/
22 /* HEADER INCLUDES                                                           */
23 /*****************************************************************************/
24
25 #include "config.h"
26 #include "system.h"
27 #include "coretypes.h"
28 #include "tm.h"
29 #include "rtl.h"
30 #include "tree.h"
31 #include "tm_p.h"
32 #include "regs.h"
33 #include "hard-reg-set.h"
34 #include "real.h"
35 #include "insn-config.h"
36 #include "conditions.h"
37 #include "output.h"
38 #include "insn-codes.h"
39 #include "insn-attr.h"
40 #include "flags.h"
41 #include "except.h"
42 #include "function.h"
43 #include "recog.h"
44 #include "expr.h"
45 #include "optabs.h"
46 #include "toplev.h"
47 #include "basic-block.h"
48 #include "target.h"
49 #include "target-def.h"
50
51 /*****************************************************************************/
52 /* DEFINITIONS                                                               */
53 /*****************************************************************************/
54
55 /* Maximum number of register used for passing parameters.  */
56 #define MAX_REG_FOR_PASSING_ARGS 6
57
58 /* Minimum number register used for passing parameters.  */
59 #define MIN_REG_FOR_PASSING_ARGS 2
60
61 /* The maximum count of words supported in the assembly of the architecture in
62  * a push/pop instruction.  */
63 #define MAX_COUNT               8
64
65 /* Predicate is true if the current function is a 'noreturn' function, i.e. it
66  * is qualified as volatile.  */
67 #define FUNC_IS_NORETURN_P(decl) (TREE_THIS_VOLATILE (decl))
68
69 /* The following macros are used in crx_decompose_address () */
70
71 /* Returns the factor of a scaled index address or -1 if invalid. */
72 #define SCALE_FOR_INDEX_P(X)    \
73  (GET_CODE (X) == CONST_INT ?   \
74   (INTVAL (X) == 1 ? 1 :        \
75    INTVAL (X) == 2 ? 2 :        \
76    INTVAL (X) == 4 ? 4 :        \
77    INTVAL (X) == 8 ? 8 :        \
78    -1) :                        \
79   -1)
80
81 /* Nonzero if the rtx X is a signed const int of n bits */
82 #define RTX_SIGNED_INT_FITS_N_BITS(X,n)                 \
83  ((GET_CODE (X) == CONST_INT                            \
84    && SIGNED_INT_FITS_N_BITS (INTVAL (X), n)) ? 1 : 0)
85
86 /* Nonzero if the rtx X is an unsigned const int of n bits.  */
87 #define RTX_UNSIGNED_INT_FITS_N_BITS(X, n)              \
88  ((GET_CODE (X) == CONST_INT                            \
89    && UNSIGNED_INT_FITS_N_BITS (INTVAL (X), n)) ? 1 : 0)
90
91 /*****************************************************************************/
92 /* STATIC VARIABLES                                                          */
93 /*****************************************************************************/
94
95 /* Nonzero if the last param processed is passed in a register.  */
96 static int last_parm_in_reg;
97
98 /* Will hold the number of the last register the prologue saves, -1 if no
99  * register is saved. */
100 static int last_reg_to_save;
101
102 /* Each object in the array is a register number. Mark 1 for registers that
103  * need to be saved.  */
104 static int save_regs[FIRST_PSEUDO_REGISTER];
105
106 /* Number of bytes saved on the stack for non-scratch registers */
107 static int sum_regs = 0;
108
109 /* Number of bytes saved on the stack for local variables. */
110 static int local_vars_size;
111
112 /* The sum of 2 sizes: locals vars and padding byte for saving the registers.
113  * Used in expand_prologue () and expand_epilogue ().  */
114 static int size_for_adjusting_sp;
115
116 /* In case of a POST_INC or POST_DEC memory reference, we must report the mode
117  * of the memory reference from PRINT_OPERAND to PRINT_OPERAND_ADDRESS. */
118 static enum machine_mode output_memory_reference_mode;
119
120 /*****************************************************************************/
121 /* GLOBAL VARIABLES                                                          */
122 /*****************************************************************************/
123
124 /* Table of machine attributes.  */
125 const struct attribute_spec crx_attribute_table[];
126
127 /*****************************************************************************/
128 /* TARGETM FUNCTION PROTOTYPES                                               */
129 /*****************************************************************************/
130
131 static bool crx_fixed_condition_code_regs (unsigned int *, unsigned int *);
132 static rtx crx_struct_value_rtx (tree fntype ATTRIBUTE_UNUSED,
133                                  int incoming ATTRIBUTE_UNUSED);
134 static bool crx_return_in_memory (const_tree type, const_tree fntype ATTRIBUTE_UNUSED);
135 static int crx_address_cost (rtx, bool);
136 static bool crx_legitimate_address_p (enum machine_mode, rtx, bool);
137
138 /*****************************************************************************/
139 /* RTL VALIDITY                                                              */
140 /*****************************************************************************/
141
142 #undef TARGET_LEGITIMATE_ADDRESS_P
143 #define TARGET_LEGITIMATE_ADDRESS_P     crx_legitimate_address_p
144
145 /*****************************************************************************/
146 /* STACK LAYOUT AND CALLING CONVENTIONS                                      */
147 /*****************************************************************************/
148
149 #undef  TARGET_FIXED_CONDITION_CODE_REGS
150 #define TARGET_FIXED_CONDITION_CODE_REGS crx_fixed_condition_code_regs
151
152 #undef  TARGET_STRUCT_VALUE_RTX
153 #define TARGET_STRUCT_VALUE_RTX         crx_struct_value_rtx
154
155 #undef  TARGET_RETURN_IN_MEMORY
156 #define TARGET_RETURN_IN_MEMORY         crx_return_in_memory
157
158 /*****************************************************************************/
159 /* RELATIVE COSTS OF OPERATIONS                                              */
160 /*****************************************************************************/
161
162 #undef  TARGET_ADDRESS_COST
163 #define TARGET_ADDRESS_COST             crx_address_cost
164
165 /*****************************************************************************/
166 /* TARGET-SPECIFIC USES OF `__attribute__'                                   */
167 /*****************************************************************************/
168
169 #undef  TARGET_ATTRIBUTE_TABLE
170 #define TARGET_ATTRIBUTE_TABLE          crx_attribute_table
171
172 const struct attribute_spec crx_attribute_table[] = {
173   /* ISRs have special prologue and epilogue requirements. */
174   {"interrupt", 0, 0, false, true, true, NULL},
175   {NULL, 0, 0, false, false, false, NULL}
176 };
177
178
179 /* Initialize 'targetm' variable which contains pointers to functions and data
180  * relating to the target machine.  */
181
182 struct gcc_target targetm = TARGET_INITIALIZER;
183
184
185 /*****************************************************************************/
186 /* TARGET HOOK IMPLEMENTATIONS                                               */
187 /*****************************************************************************/
188
189 /* Return the fixed registers used for condition codes.  */
190
191 static bool
192 crx_fixed_condition_code_regs (unsigned int *p1, unsigned int *p2)
193 {
194     *p1 = CC_REGNUM;
195     *p2 = INVALID_REGNUM;
196     return true;
197 }
198
199 /* Implements hook TARGET_STRUCT_VALUE_RTX.  */
200
201 static rtx
202 crx_struct_value_rtx (tree fntype ATTRIBUTE_UNUSED,
203                       int incoming ATTRIBUTE_UNUSED)
204 {
205   return gen_rtx_REG (Pmode, CRX_STRUCT_VALUE_REGNUM);
206 }
207
208 /* Implements hook TARGET_RETURN_IN_MEMORY.  */
209
210 static bool
211 crx_return_in_memory (const_tree type, const_tree fntype ATTRIBUTE_UNUSED)
212 {
213   if (TYPE_MODE (type) == BLKmode)
214     {
215       HOST_WIDE_INT size = int_size_in_bytes (type);
216       return (size == -1 || size > 8);
217     }
218   else
219     return false;
220 }
221
222
223 /*****************************************************************************/
224 /* MACRO IMPLEMENTATIONS                                                     */
225 /*****************************************************************************/
226
227 /* STACK LAYOUT AND CALLING CONVENTIONS ROUTINES */
228 /* --------------------------------------------- */
229
230 /* Return nonzero if the current function being compiled is an interrupt
231  * function as specified by the "interrupt" attribute.  */
232
233 int
234 crx_interrupt_function_p (void)
235 {
236   tree attributes;
237
238   attributes = TYPE_ATTRIBUTES (TREE_TYPE (current_function_decl));
239   return lookup_attribute ("interrupt", attributes) != NULL_TREE;
240 }
241
242 /* Compute values for the array save_regs and the variable sum_regs.  The index
243  * of save_regs is numbers of register, each will get 1 if we need to save it
244  * in the current function, 0 if not. sum_regs is the total sum of the
245  * registers being saved. */
246
247 static void
248 crx_compute_save_regs (void)
249 {
250   unsigned int regno;
251
252   /* initialize here so in case the function is no-return it will be -1. */
253   last_reg_to_save = -1;
254
255   /* No need to save any registers if the function never returns.  */
256   if (FUNC_IS_NORETURN_P (current_function_decl))
257     return;
258
259   /* Initialize the number of bytes to be saved. */
260   sum_regs = 0;
261
262   for (regno = 0; regno < FIRST_PSEUDO_REGISTER; regno++)
263     {
264       if (fixed_regs[regno])
265         {
266           save_regs[regno] = 0;
267           continue;
268         }
269
270       /* If this reg is used and not call-used (except RA), save it. */
271       if (crx_interrupt_function_p ())
272         {
273           if (!current_function_is_leaf && call_used_regs[regno])
274             /* this is a volatile reg in a non-leaf interrupt routine - save it
275              * for the sake of its sons.  */
276             save_regs[regno] = 1;
277
278           else if (df_regs_ever_live_p (regno))
279             /* This reg is used - save it.  */
280             save_regs[regno] = 1;
281           else
282             /* This reg is not used, and is not a volatile - don't save. */
283             save_regs[regno] = 0;
284         }
285       else
286         {
287           /* If this reg is used and not call-used (except RA), save it. */
288           if (df_regs_ever_live_p (regno)
289               && (!call_used_regs[regno] || regno == RETURN_ADDRESS_REGNUM))
290             save_regs[regno] = 1;
291           else
292             save_regs[regno] = 0;
293         }
294     }
295
296   for (regno = 0; regno < FIRST_PSEUDO_REGISTER; regno++)
297     if (save_regs[regno] == 1)
298       {
299         last_reg_to_save = regno;
300         sum_regs += UNITS_PER_WORD;
301       }
302 }
303
304 /* Compute the size of the local area and the size to be adjusted by the
305  * prologue and epilogue. */
306
307 static void
308 crx_compute_frame (void)
309 {
310   /* For aligning the local variables. */
311   int stack_alignment = STACK_BOUNDARY / BITS_PER_UNIT;
312   int padding_locals;
313
314   /* Padding needed for each element of the frame.  */
315   local_vars_size = get_frame_size ();
316
317   /* Align to the stack alignment. */
318   padding_locals = local_vars_size % stack_alignment;
319   if (padding_locals)
320     padding_locals = stack_alignment - padding_locals;
321
322   local_vars_size += padding_locals;
323
324   size_for_adjusting_sp = local_vars_size + (ACCUMULATE_OUTGOING_ARGS ?
325                                      crtl->outgoing_args_size : 0);
326 }
327
328 /* Implements the macro INITIAL_ELIMINATION_OFFSET, return the OFFSET. */
329
330 int
331 crx_initial_elimination_offset (int from, int to)
332 {
333   /* Compute this since we need to use sum_regs.  */
334   crx_compute_save_regs ();
335
336   /* Compute this since we need to use local_vars_size.  */
337   crx_compute_frame ();
338
339   if ((from) == FRAME_POINTER_REGNUM && (to) == STACK_POINTER_REGNUM)
340     return (ACCUMULATE_OUTGOING_ARGS ?
341             crtl->outgoing_args_size : 0);
342   else if ((from) == ARG_POINTER_REGNUM && (to) == FRAME_POINTER_REGNUM)
343     return (sum_regs + local_vars_size);
344   else if ((from) == ARG_POINTER_REGNUM && (to) == STACK_POINTER_REGNUM)
345     return (sum_regs + local_vars_size +
346             (ACCUMULATE_OUTGOING_ARGS ?
347              crtl->outgoing_args_size : 0));
348   else
349     abort ();
350 }
351
352 /* REGISTER USAGE */
353 /* -------------- */
354
355 /* Return the class number of the smallest class containing reg number REGNO.
356  * This could be a conditional expression or could index an array. */
357
358 enum reg_class
359 crx_regno_reg_class (int regno)
360 {
361   if (regno >= 0 && regno < SP_REGNUM)
362     return NOSP_REGS;
363
364   if (regno == SP_REGNUM)
365     return GENERAL_REGS;
366
367   if (regno == LO_REGNUM)
368     return LO_REGS;
369   if (regno == HI_REGNUM)
370     return HI_REGS;
371
372   return NO_REGS;
373 }
374
375 /* Transfer between HILO_REGS and memory via secondary reloading. */
376
377 enum reg_class
378 crx_secondary_reload_class (enum reg_class rclass,
379                             enum machine_mode mode ATTRIBUTE_UNUSED,
380                             rtx x ATTRIBUTE_UNUSED)
381 {
382   if (reg_classes_intersect_p (rclass, HILO_REGS)
383       && true_regnum (x) == -1)
384     return GENERAL_REGS;
385
386   return NO_REGS;
387 }
388
389 /* Return 1 if hard register REGNO can hold a value of machine-mode MODE. */
390
391 int
392 crx_hard_regno_mode_ok (int regno, enum machine_mode mode)
393 {
394   /* CC can only hold CCmode values.  */
395   if (regno == CC_REGNUM)
396     return GET_MODE_CLASS (mode) == MODE_CC;
397   if (GET_MODE_CLASS (mode) == MODE_CC)
398     return 0;
399   /* HILO registers can only hold SImode and DImode */
400   if (HILO_REGNO_P (regno))
401     return mode == SImode || mode == DImode;
402   return 1;
403 }
404
405 /* PASSING FUNCTION ARGUMENTS */
406 /* -------------------------- */
407
408 /* If enough param regs are available for passing the param of type TYPE return
409  * the number of registers needed else 0.  */
410
411 static int
412 enough_regs_for_param (CUMULATIVE_ARGS * cum, tree type,
413                        enum machine_mode mode)
414 {
415   int type_size;
416   int remaining_size;
417
418   if (mode != BLKmode)
419     type_size = GET_MODE_BITSIZE (mode);
420   else
421     type_size = int_size_in_bytes (type) * BITS_PER_UNIT;
422
423   remaining_size =
424     BITS_PER_WORD * (MAX_REG_FOR_PASSING_ARGS -
425     (MIN_REG_FOR_PASSING_ARGS + cum->ints) + 1);
426
427   /* Any variable which is too big to pass in two registers, will pass on
428    * stack. */
429   if ((remaining_size >= type_size) && (type_size <= 2 * BITS_PER_WORD))
430     return (type_size + BITS_PER_WORD - 1) / BITS_PER_WORD;
431
432   return 0;
433 }
434
435 /* Implements the macro FUNCTION_ARG defined in crx.h.  */
436
437 rtx
438 crx_function_arg (CUMULATIVE_ARGS * cum, enum machine_mode mode, tree type,
439               int named ATTRIBUTE_UNUSED)
440 {
441   last_parm_in_reg = 0;
442
443   /* Function_arg () is called with this type just after all the args have had
444    * their registers assigned. The rtx that function_arg returns from this type
445    * is supposed to pass to 'gen_call' but currently it is not implemented (see
446    * macro GEN_CALL).  */
447   if (type == void_type_node)
448     return NULL_RTX;
449
450   if (targetm.calls.must_pass_in_stack (mode, type) || (cum->ints < 0))
451     return NULL_RTX;
452
453   if (mode == BLKmode)
454     {
455       /* Enable structures that need padding bytes at the end to pass to a
456        * function in registers. */
457       if (enough_regs_for_param (cum, type, mode) != 0)
458         {
459           last_parm_in_reg = 1;
460           return gen_rtx_REG (mode, MIN_REG_FOR_PASSING_ARGS + cum->ints);
461         }
462     }
463
464   if (MIN_REG_FOR_PASSING_ARGS + cum->ints > MAX_REG_FOR_PASSING_ARGS)
465     return NULL_RTX;
466   else
467     {
468       if (enough_regs_for_param (cum, type, mode) != 0)
469         {
470           last_parm_in_reg = 1;
471           return gen_rtx_REG (mode, MIN_REG_FOR_PASSING_ARGS + cum->ints);
472         }
473     }
474
475   return NULL_RTX;
476 }
477
478 /* Implements the macro INIT_CUMULATIVE_ARGS defined in crx.h.  */
479
480 void
481 crx_init_cumulative_args (CUMULATIVE_ARGS * cum, tree fntype,
482                       rtx libfunc ATTRIBUTE_UNUSED)
483 {
484   tree param, next_param;
485
486   cum->ints = 0;
487
488   /* Determine if this function has variable arguments.  This is indicated by
489    * the last argument being 'void_type_mode' if there are no variable
490    * arguments.  Change here for a different vararg.  */
491   for (param = (fntype) ? TYPE_ARG_TYPES (fntype) : 0;
492        param != (tree) 0; param = next_param)
493     {
494       next_param = TREE_CHAIN (param);
495       if (next_param == (tree) 0 && TREE_VALUE (param) != void_type_node)
496         {
497           cum->ints = -1;
498           return;
499         }
500     }
501 }
502
503 /* Implements the macro FUNCTION_ARG_ADVANCE defined in crx.h.  */
504
505 void
506 crx_function_arg_advance (CUMULATIVE_ARGS * cum, enum machine_mode mode,
507                       tree type, int named ATTRIBUTE_UNUSED)
508 {
509   /* l holds the number of registers required */
510   int l = GET_MODE_BITSIZE (mode) / BITS_PER_WORD;
511
512   /* If the parameter isn't passed on a register don't advance cum.  */
513   if (!last_parm_in_reg)
514     return;
515
516   if (targetm.calls.must_pass_in_stack (mode, type) || (cum->ints < 0))
517     return;
518
519   if (mode == SImode || mode == HImode || mode == QImode || mode == DImode)
520     {
521       if (l <= 1)
522         cum->ints += 1;
523       else
524         cum->ints += l;
525     }
526   else if (mode == SFmode || mode == DFmode)
527     cum->ints += l;
528   else if ((mode) == BLKmode)
529     {
530       if ((l = enough_regs_for_param (cum, type, mode)) != 0)
531         cum->ints += l;
532     }
533
534 }
535
536 /* Implements the macro FUNCTION_ARG_REGNO_P defined in crx.h.  Return nonzero
537  * if N is a register used for passing parameters.  */
538
539 int
540 crx_function_arg_regno_p (int n)
541 {
542   return (n <= MAX_REG_FOR_PASSING_ARGS && n >= MIN_REG_FOR_PASSING_ARGS);
543 }
544
545 /* ADDRESSING MODES */
546 /* ---------------- */
547
548 /* Implements the macro GO_IF_LEGITIMATE_ADDRESS defined in crx.h.
549  * The following addressing modes are supported on CRX:
550  *
551  * Relocations          --> const | symbol_ref | label_ref
552  * Absolute address     --> 32-bit absolute
553  * Post increment       --> reg + 12-bit disp.
554  * Post modify          --> reg + 12-bit disp.
555  * Register relative    --> reg | 32-bit disp. + reg | 4 bit + reg
556  * Scaled index         --> reg + reg | 22-bit disp. + reg + reg |
557  *                          22-disp. + reg + reg + (2 | 4 | 8) */
558
559 static int crx_addr_reg_p (rtx addr_reg)
560 {
561   rtx reg;
562
563   if (REG_P (addr_reg))
564     {
565       reg = addr_reg;
566     }
567   else if ((GET_CODE (addr_reg) == SUBREG
568            && REG_P (SUBREG_REG (addr_reg))
569            && GET_MODE_SIZE (GET_MODE (SUBREG_REG (addr_reg)))
570            <= UNITS_PER_WORD))
571     {
572       reg = SUBREG_REG (addr_reg);
573     }
574   else
575     return FALSE;
576
577   if (GET_MODE (addr_reg) != Pmode)
578     {
579       return FALSE;
580     }
581
582   return TRUE;
583 }
584
585 enum crx_addrtype
586 crx_decompose_address (rtx addr, struct crx_address *out)
587 {
588   rtx base = NULL_RTX, index = NULL_RTX, disp = NULL_RTX;
589   rtx scale_rtx = NULL_RTX, side_effect = NULL_RTX;
590   int scale = -1;
591   
592   enum crx_addrtype retval = CRX_INVALID;
593
594   switch (GET_CODE (addr))
595     {
596     case CONST_INT:
597       /* Absolute address (known at compile time) */
598       retval = CRX_ABSOLUTE;
599       disp = addr;
600       if (!UNSIGNED_INT_FITS_N_BITS (INTVAL (disp), GET_MODE_BITSIZE (Pmode)))
601         return CRX_INVALID;
602       break;
603       
604     case CONST:
605     case SYMBOL_REF:
606     case LABEL_REF:
607       /* Absolute address (known at link time) */
608       retval = CRX_ABSOLUTE;
609       disp = addr;
610       break;
611
612     case REG:
613     case SUBREG:
614       /* Register relative address */
615       retval = CRX_REG_REL;
616       base = addr;
617       break;
618
619     case PLUS:
620       switch (GET_CODE (XEXP (addr, 0)))
621         {
622         case REG:
623         case SUBREG:
624           if (REG_P (XEXP (addr, 1)))
625             {
626               /* Scaled index with scale = 1 and disp. = 0 */
627               retval = CRX_SCALED_INDX;
628               base = XEXP (addr, 1);
629               index = XEXP (addr, 0); 
630               scale = 1;
631             }
632           else if (RTX_SIGNED_INT_FITS_N_BITS (XEXP (addr, 1), 28))
633             {
634               /* Register relative address and <= 28-bit disp. */
635               retval = CRX_REG_REL;
636               base = XEXP (addr, 0);
637               disp = XEXP (addr, 1);
638             }
639           else
640             return CRX_INVALID;
641           break;
642
643         case PLUS:
644           /* Scaled index and <= 22-bit disp. */
645           retval = CRX_SCALED_INDX;
646           base = XEXP (XEXP (addr, 0), 1); 
647           disp = XEXP (addr, 1);
648           if (!RTX_SIGNED_INT_FITS_N_BITS (disp, 22))
649             return CRX_INVALID;
650           switch (GET_CODE (XEXP (XEXP (addr, 0), 0)))
651             {
652             case REG:
653               /* Scaled index with scale = 0 and <= 22-bit disp. */
654               index = XEXP (XEXP (addr, 0), 0); 
655               scale = 1;
656               break;
657               
658             case MULT:
659               /* Scaled index with scale >= 0 and <= 22-bit disp. */
660               index = XEXP (XEXP (XEXP (addr, 0), 0), 0); 
661               scale_rtx = XEXP (XEXP (XEXP (addr, 0), 0), 1); 
662               if ((scale = SCALE_FOR_INDEX_P (scale_rtx)) == -1)
663                 return CRX_INVALID;
664               break;
665
666             default:
667               return CRX_INVALID;
668             }
669           break;
670           
671         case MULT:
672           /* Scaled index with scale >= 0 */
673           retval = CRX_SCALED_INDX;
674           base = XEXP (addr, 1); 
675           index = XEXP (XEXP (addr, 0), 0); 
676           scale_rtx = XEXP (XEXP (addr, 0), 1); 
677           /* Scaled index with scale >= 0 and <= 22-bit disp. */
678           if ((scale = SCALE_FOR_INDEX_P (scale_rtx)) == -1)
679             return CRX_INVALID;
680           break;
681
682         default:
683           return CRX_INVALID;
684         }
685       break;
686
687     case POST_INC:
688     case POST_DEC:
689       /* Simple post-increment */
690       retval = CRX_POST_INC;
691       base = XEXP (addr, 0);
692       side_effect = addr;
693       break;
694
695     case POST_MODIFY:
696       /* Generic post-increment with <= 12-bit disp. */
697       retval = CRX_POST_INC;
698       base = XEXP (addr, 0);
699       side_effect = XEXP (addr, 1);
700       if (base != XEXP (side_effect, 0))
701         return CRX_INVALID;
702       switch (GET_CODE (side_effect))
703         {
704         case PLUS:
705         case MINUS:
706           disp = XEXP (side_effect, 1);
707           if (!RTX_SIGNED_INT_FITS_N_BITS (disp, 12))
708             return CRX_INVALID;
709           break;
710
711         default:
712           /* CRX only supports PLUS and MINUS */
713           return CRX_INVALID;
714         }
715       break;
716
717     default:
718       return CRX_INVALID;
719     }
720
721   if (base && !crx_addr_reg_p (base)) return CRX_INVALID;
722   if (index && !crx_addr_reg_p (index)) return CRX_INVALID;
723   
724   out->base = base;
725   out->index = index;
726   out->disp = disp;
727   out->scale = scale;
728   out->side_effect = side_effect;
729
730   return retval;
731 }
732
733 bool
734 crx_legitimate_address_p (enum machine_mode mode ATTRIBUTE_UNUSED,
735                           rtx addr, bool strict)
736 {
737   enum crx_addrtype addrtype;
738   struct crx_address address;
739                                                  
740   if (TARGET_DEBUG_ADDR)
741     {
742       fprintf (stderr,
743                "\n======\nGO_IF_LEGITIMATE_ADDRESS, mode = %s, strict = %d\n",
744                GET_MODE_NAME (mode), strict);
745       debug_rtx (addr);
746     }
747   
748   addrtype = crx_decompose_address (addr, &address);
749
750   if (addrtype == CRX_POST_INC && GET_MODE_SIZE (mode) > UNITS_PER_WORD)
751     return FALSE;
752
753   if (TARGET_DEBUG_ADDR)
754     {
755       const char *typestr;
756       switch (addrtype)
757         {
758         case CRX_INVALID:
759           typestr = "Invalid";
760           break;
761         case CRX_REG_REL:
762           typestr = "Register relative";
763           break;
764         case CRX_POST_INC:
765           typestr = "Post-increment";
766           break;
767         case CRX_SCALED_INDX:
768           typestr = "Scaled index";
769           break;
770         case CRX_ABSOLUTE:
771           typestr = "Absolute";
772           break;
773         default:
774           abort ();
775         }
776       fprintf (stderr, "CRX Address type: %s\n", typestr);
777     }
778   
779   if (addrtype == CRX_INVALID)
780     return FALSE;
781
782   if (strict)
783     {
784       if (address.base && !REGNO_OK_FOR_BASE_P (REGNO (address.base)))
785         {
786           if (TARGET_DEBUG_ADDR)
787             fprintf (stderr, "Base register not strict\n");
788           return FALSE;
789         }
790       if (address.index && !REGNO_OK_FOR_INDEX_P (REGNO (address.index)))
791         {
792           if (TARGET_DEBUG_ADDR)
793             fprintf (stderr, "Index register not strict\n");
794           return FALSE;
795         }
796     }
797
798   return TRUE;
799 }
800
801 /* ROUTINES TO COMPUTE COSTS */
802 /* ------------------------- */
803
804 /* Return cost of the memory address x. */
805
806 static int
807 crx_address_cost (rtx addr, bool speed ATTRIBUTE_UNUSED)
808 {
809   enum crx_addrtype addrtype;
810   struct crx_address address;
811                                                  
812   int cost = 2;
813   
814   addrtype = crx_decompose_address (addr, &address);
815   
816   gcc_assert (addrtype != CRX_INVALID);
817
818   /* An absolute address causes a 3-word instruction */
819   if (addrtype == CRX_ABSOLUTE)
820     cost+=2;
821   
822   /* Post-modifying addresses are more powerful.  */
823   if (addrtype == CRX_POST_INC)
824     cost-=2;
825
826   /* Attempt to minimize number of registers in the address. */
827   if (address.base)
828     cost++;
829   
830   if (address.index && address.scale == 1)
831     cost+=5;
832
833   if (address.disp && !INT_CST4 (INTVAL (address.disp)))
834     cost+=2;
835
836   if (TARGET_DEBUG_ADDR)
837     {
838       fprintf (stderr, "\n======\nTARGET_ADDRESS_COST = %d\n", cost);
839       debug_rtx (addr);
840     }
841   
842   return cost;
843 }
844
845 /* Return the cost of moving data of mode MODE between a register of class
846  * RCLASS and memory; IN is zero if the value is to be written to memory,
847  * nonzero if it is to be read in. This cost is relative to those in
848  * REGISTER_MOVE_COST.  */
849
850 int
851 crx_memory_move_cost (enum machine_mode mode,
852                   enum reg_class rclass ATTRIBUTE_UNUSED,
853                   int in ATTRIBUTE_UNUSED)
854 {
855   /* One LD or ST takes twice the time of a simple reg-reg move */
856   if (reg_classes_intersect_p (rclass, GENERAL_REGS))
857     {
858       /* printf ("GENERAL_REGS LD/ST = %d\n", 4 * HARD_REGNO_NREGS (0, mode));*/
859       return 4 * HARD_REGNO_NREGS (0, mode);
860     }   
861   else if (reg_classes_intersect_p (rclass, HILO_REGS))
862     {
863       /* HILO to memory and vice versa */
864       /* printf ("HILO_REGS %s = %d\n", in ? "LD" : "ST",
865              (REGISTER_MOVE_COST (mode,
866                                  in ? GENERAL_REGS : HILO_REGS,
867                                  in ? HILO_REGS : GENERAL_REGS) + 4)
868         * HARD_REGNO_NREGS (0, mode)); */
869       return (REGISTER_MOVE_COST (mode,
870                                  in ? GENERAL_REGS : HILO_REGS,
871                                  in ? HILO_REGS : GENERAL_REGS) + 4)
872         * HARD_REGNO_NREGS (0, mode);
873     }
874   else /* default (like in i386) */
875     {
876       /* printf ("ANYREGS = 100\n"); */
877       return 100;
878     }
879 }
880
881 /* INSTRUCTION OUTPUT */
882 /* ------------------ */
883
884 /* Check if a const_double is ok for crx store-immediate instructions */
885
886 int
887 crx_const_double_ok (rtx op)
888 {
889   if (GET_MODE (op) == DFmode)
890   {
891     REAL_VALUE_TYPE r;
892     long l[2];
893     REAL_VALUE_FROM_CONST_DOUBLE (r, op);
894     REAL_VALUE_TO_TARGET_DOUBLE (r, l);
895     return (UNSIGNED_INT_FITS_N_BITS (l[0], 4) &&
896             UNSIGNED_INT_FITS_N_BITS (l[1], 4)) ? 1 : 0;
897   }
898
899   if (GET_MODE (op) == SFmode)
900   {
901     REAL_VALUE_TYPE r;
902     long l;
903     REAL_VALUE_FROM_CONST_DOUBLE (r, op);
904     REAL_VALUE_TO_TARGET_SINGLE (r, l);
905     return UNSIGNED_INT_FITS_N_BITS (l, 4) ? 1 : 0;
906   }
907
908   return (UNSIGNED_INT_FITS_N_BITS (CONST_DOUBLE_LOW (op), 4) &&
909           UNSIGNED_INT_FITS_N_BITS (CONST_DOUBLE_HIGH (op), 4)) ? 1 : 0;
910 }
911
912 /* Implements the macro PRINT_OPERAND defined in crx.h.  */
913
914 void
915 crx_print_operand (FILE * file, rtx x, int code)
916 {
917   switch (code)
918     {
919     case 'p' :
920       if (GET_CODE (x) == REG) {
921         if (GET_MODE (x) == DImode || GET_MODE (x) == DFmode)
922           {
923             int regno = REGNO (x);
924             if (regno + 1 >= SP_REGNUM) abort ();
925             fprintf (file, "{%s, %s}", reg_names[regno], reg_names[regno + 1]);
926             return;
927           }
928         else
929           {
930             if (REGNO (x) >= SP_REGNUM) abort ();
931             fprintf (file, "%s", reg_names[REGNO (x)]);
932             return;
933           }
934       }
935
936     case 'd' :
937         {
938           const char *crx_cmp_str;
939           switch (GET_CODE (x))
940             { /* MD: compare (reg, reg or imm) but CRX: cmp (reg or imm, reg)
941                * -> swap all non symmetric ops */
942             case EQ  : crx_cmp_str = "eq"; break;
943             case NE  : crx_cmp_str = "ne"; break;
944             case GT  : crx_cmp_str = "lt"; break;
945             case GTU : crx_cmp_str = "lo"; break;
946             case LT  : crx_cmp_str = "gt"; break;
947             case LTU : crx_cmp_str = "hi"; break;
948             case GE  : crx_cmp_str = "le"; break;
949             case GEU : crx_cmp_str = "ls"; break;
950             case LE  : crx_cmp_str = "ge"; break;
951             case LEU : crx_cmp_str = "hs"; break;
952             default : abort ();
953             }
954           fprintf (file, "%s", crx_cmp_str);
955           return;
956         }
957
958     case 'H':
959       /* Print high part of a double precision value. */
960       switch (GET_CODE (x))
961         {
962         case CONST_DOUBLE:
963           if (GET_MODE (x) == SFmode) abort ();
964           if (GET_MODE (x) == DFmode)
965             {
966               /* High part of a DF const. */
967               REAL_VALUE_TYPE r;
968               long l[2];
969
970               REAL_VALUE_FROM_CONST_DOUBLE (r, x);
971               REAL_VALUE_TO_TARGET_DOUBLE (r, l);
972
973               fprintf (file, "$0x%lx", l[1]);
974               return;
975             }
976
977           /* -- Fallthrough to handle DI consts -- */
978
979         case CONST_INT:
980             {
981               rtx high, low;
982               split_double (x, &low, &high);
983               putc ('$', file);
984               output_addr_const (file, high);
985               return;
986             }
987
988         case REG:
989           if (REGNO (x) + 1 >= FIRST_PSEUDO_REGISTER) abort ();
990           fprintf (file, "%s", reg_names[REGNO (x) + 1]);
991           return;
992
993         case MEM:
994           /* Adjust memory address to high part.  */
995             {
996               rtx adj_mem = x;
997               adj_mem = adjust_address (adj_mem, GET_MODE (adj_mem), 4);
998
999               output_memory_reference_mode = GET_MODE (adj_mem);
1000               output_address (XEXP (adj_mem, 0));
1001               return;
1002             }
1003
1004         default:
1005           abort ();
1006         }
1007
1008     case 'L':
1009       /* Print low part of a double precision value. */
1010       switch (GET_CODE (x))
1011         {
1012         case CONST_DOUBLE:
1013           if (GET_MODE (x) == SFmode) abort ();
1014           if (GET_MODE (x) == DFmode)
1015             {
1016               /* High part of a DF const. */
1017               REAL_VALUE_TYPE r;
1018               long l[2];
1019
1020               REAL_VALUE_FROM_CONST_DOUBLE (r, x);
1021               REAL_VALUE_TO_TARGET_DOUBLE (r, l);
1022
1023               fprintf (file, "$0x%lx", l[0]);
1024               return;
1025             }
1026
1027           /* -- Fallthrough to handle DI consts -- */
1028
1029         case CONST_INT:
1030             {
1031               rtx high, low;
1032               split_double (x, &low, &high);
1033               putc ('$', file);
1034               output_addr_const (file, low);
1035               return;
1036             }
1037
1038         case REG:
1039           fprintf (file, "%s", reg_names[REGNO (x)]);
1040           return;
1041
1042         case MEM:
1043           output_memory_reference_mode = GET_MODE (x);
1044           output_address (XEXP (x, 0));
1045           return;
1046
1047         default:
1048           abort ();
1049         }
1050
1051     case 0 : /* default */
1052       switch (GET_CODE (x))
1053         {
1054         case REG:
1055           fprintf (file, "%s", reg_names[REGNO (x)]);
1056           return;
1057
1058         case MEM:
1059           output_memory_reference_mode = GET_MODE (x);
1060           output_address (XEXP (x, 0));
1061           return;
1062
1063         case CONST_DOUBLE:
1064             {
1065               REAL_VALUE_TYPE r;
1066               long l;
1067
1068               /* Always use H and L for double precision - see above */
1069               gcc_assert (GET_MODE (x) == SFmode);
1070
1071               REAL_VALUE_FROM_CONST_DOUBLE (r, x);
1072               REAL_VALUE_TO_TARGET_SINGLE (r, l);
1073
1074               fprintf (file, "$0x%lx", l);
1075               return;
1076             }
1077
1078         default:
1079           putc ('$', file);
1080           output_addr_const (file, x);
1081           return;
1082         }
1083
1084     default:
1085       output_operand_lossage ("invalid %%xn code");
1086     }
1087
1088   abort ();
1089 }
1090
1091 /* Implements the macro PRINT_OPERAND_ADDRESS defined in crx.h.  */
1092
1093 void
1094 crx_print_operand_address (FILE * file, rtx addr)
1095 {
1096   enum crx_addrtype addrtype;
1097   struct crx_address address;
1098
1099   int offset;
1100   
1101   addrtype = crx_decompose_address (addr, &address);
1102   
1103   if (address.disp)
1104     offset = INTVAL (address.disp);
1105   else
1106     offset = 0;
1107
1108   switch (addrtype)
1109     {
1110     case CRX_REG_REL:
1111       fprintf (file, "%d(%s)", offset, reg_names[REGNO (address.base)]);
1112       return;
1113       
1114     case CRX_POST_INC:
1115       switch (GET_CODE (address.side_effect))
1116         {
1117         case PLUS:
1118           break;
1119         case MINUS:
1120           offset = -offset;
1121           break;
1122         case POST_INC:
1123           offset = GET_MODE_SIZE (output_memory_reference_mode);
1124           break;
1125         case POST_DEC:
1126           offset = -GET_MODE_SIZE (output_memory_reference_mode);
1127           break;
1128         default:
1129           abort ();
1130         }
1131         fprintf (file, "%d(%s)+", offset, reg_names[REGNO (address.base)]);
1132       return;
1133       
1134     case CRX_SCALED_INDX:
1135       fprintf (file, "%d(%s, %s, %d)", offset, reg_names[REGNO (address.base)],
1136                reg_names[REGNO (address.index)], address.scale);
1137       return;
1138       
1139     case CRX_ABSOLUTE:
1140       output_addr_const (file, address.disp);
1141       return;
1142       
1143     default:
1144       abort ();
1145     }
1146 }
1147
1148
1149 /*****************************************************************************/
1150 /* MACHINE DESCRIPTION HELPER-FUNCTIONS                                      */
1151 /*****************************************************************************/
1152
1153 void crx_expand_movmem_single (rtx src, rtx srcbase, rtx dst, rtx dstbase,
1154                                rtx tmp_reg, unsigned HOST_WIDE_INT *offset_p)
1155 {
1156   rtx addr, mem;
1157   unsigned HOST_WIDE_INT offset = *offset_p;
1158
1159   /* Load */
1160   addr = plus_constant (src, offset);
1161   mem = adjust_automodify_address (srcbase, SImode, addr, offset);
1162   emit_move_insn (tmp_reg, mem);
1163
1164   /* Store */
1165   addr = plus_constant (dst, offset);
1166   mem = adjust_automodify_address (dstbase, SImode, addr, offset);
1167   emit_move_insn (mem, tmp_reg);
1168
1169   *offset_p = offset + 4;
1170 }
1171
1172 int
1173 crx_expand_movmem (rtx dstbase, rtx srcbase, rtx count_exp, rtx align_exp)
1174 {
1175   unsigned HOST_WIDE_INT count = 0, offset, si_moves, i;
1176   HOST_WIDE_INT align = 0;
1177
1178   rtx src, dst;
1179   rtx tmp_reg;
1180
1181   if (GET_CODE (align_exp) == CONST_INT)
1182     { /* Only if aligned */
1183       align = INTVAL (align_exp);
1184       if (align & 3)
1185         return 0;
1186     }
1187
1188   if (GET_CODE (count_exp) == CONST_INT)
1189     { /* No more than 16 SImode moves */
1190       count = INTVAL (count_exp);
1191       if (count > 64)
1192         return 0;
1193     }
1194
1195   tmp_reg = gen_reg_rtx (SImode);
1196
1197   /* Create psrs for the src and dest pointers */
1198   dst = copy_to_mode_reg (Pmode, XEXP (dstbase, 0));
1199   if (dst != XEXP (dstbase, 0))
1200     dstbase = replace_equiv_address_nv (dstbase, dst);
1201   src = copy_to_mode_reg (Pmode, XEXP (srcbase, 0));
1202   if (src != XEXP (srcbase, 0))
1203     srcbase = replace_equiv_address_nv (srcbase, src);
1204
1205   offset = 0;
1206
1207   /* Emit SImode moves */
1208   si_moves = count >> 2;
1209   for (i = 0; i < si_moves; i++)
1210     crx_expand_movmem_single (src, srcbase, dst, dstbase, tmp_reg, &offset);
1211
1212   /* Special cases */
1213   if (count & 3)
1214     {
1215       offset = count - 4;
1216       crx_expand_movmem_single (src, srcbase, dst, dstbase, tmp_reg, &offset);
1217     }
1218
1219   gcc_assert (offset == count);
1220
1221   return 1;
1222 }
1223
1224 static void
1225 mpushpop_str (char *stringbuffer, const char *mnemonic, char *mask)
1226 {
1227   if (strlen (mask) > 2 || crx_interrupt_function_p ()) /* needs 2-word instr. */
1228     sprintf (stringbuffer, "\n\t%s\tsp, {%s}", mnemonic, mask);
1229   else /* single word instruction */
1230     sprintf (stringbuffer, "\n\t%s\t%s", mnemonic, mask);
1231 }
1232
1233 /* Called from crx.md. The return value depends on the parameter push_or_pop:
1234  * When push_or_pop is zero -> string for push instructions of prologue.
1235  * When push_or_pop is nonzero -> string for pop/popret/retx in epilogue.
1236  * Relies on the assumptions:
1237  * 1. RA is the last register to be saved.
1238  * 2. The maximal value of the counter is MAX_COUNT. */
1239
1240 char *
1241 crx_prepare_push_pop_string (int push_or_pop)
1242 {
1243   /* j is the number of registers being saved, takes care that there won't be
1244    * more than 8 in one push/pop instruction */
1245
1246   /* For the register mask string */
1247   static char mask_str[50];
1248
1249   /* i is the index of save_regs[], going from 0 until last_reg_to_save */
1250   int i = 0;
1251
1252   int ra_in_bitmask = 0;
1253
1254   char *return_str;
1255
1256   /* For reversing on the push instructions if there are more than one. */
1257   char *temp_str;
1258
1259   return_str = (char *) xmalloc (120);
1260   temp_str = (char *) xmalloc (120);
1261
1262   /* Initialize */
1263   memset (return_str, 0, 3);
1264
1265   while (i <= last_reg_to_save)
1266     {
1267       /* Prepare mask for one instruction. */
1268       mask_str[0] = 0;
1269
1270       if (i <= SP_REGNUM)
1271         { /* Add regs unit full or SP register reached */
1272           int j = 0;
1273           while (j < MAX_COUNT && i <= SP_REGNUM)
1274             {
1275               if (save_regs[i])
1276                 {
1277                   /* TODO to use ra_in_bitmask for detecting last pop is not
1278                    * smart it prevents things like:  popret r5 */
1279                   if (i == RETURN_ADDRESS_REGNUM) ra_in_bitmask = 1;
1280                   if (j > 0) strcat (mask_str, ", ");
1281                   strcat (mask_str, reg_names[i]);
1282                   ++j;
1283                 }
1284               ++i;
1285             }
1286         }
1287       else
1288         {
1289           /* Handle hi/lo savings */
1290           while (i <= last_reg_to_save)
1291             {
1292               if (save_regs[i])
1293                 {
1294                   strcat (mask_str, "lo, hi");
1295                   i = last_reg_to_save + 1;
1296                   break;
1297                 }
1298               ++i;
1299             }
1300         }
1301
1302       if (strlen (mask_str) == 0) continue;
1303         
1304       if (push_or_pop == 1)
1305         {
1306           if (crx_interrupt_function_p ())
1307             mpushpop_str (temp_str, "popx", mask_str);
1308           else
1309             {
1310               if (ra_in_bitmask)
1311                 {
1312                   mpushpop_str (temp_str, "popret", mask_str);
1313                   ra_in_bitmask = 0;
1314                 }
1315               else mpushpop_str (temp_str, "pop", mask_str);
1316             }
1317
1318           strcat (return_str, temp_str);
1319         }
1320       else
1321         {
1322           /* push - We need to reverse the order of the instructions if there
1323            * are more than one. (since the pop will not be reversed in the
1324            * epilogue */
1325           if (crx_interrupt_function_p ())
1326             mpushpop_str (temp_str, "pushx", mask_str);
1327           else
1328             mpushpop_str (temp_str, "push", mask_str);
1329           strcat (temp_str, return_str);
1330           strcpy (strcat (return_str, "\t"), temp_str);
1331         }
1332
1333     }
1334
1335   if (push_or_pop == 1)
1336     {
1337       /* pop */
1338       if (crx_interrupt_function_p ())
1339         strcat (return_str, "\n\tretx\n");
1340
1341       else if (!FUNC_IS_NORETURN_P (current_function_decl)
1342                && !save_regs[RETURN_ADDRESS_REGNUM])
1343         strcat (return_str, "\n\tjump\tra\n");
1344     }
1345
1346   /* Skip the newline and the tab in the start of return_str. */
1347   return_str += 2;
1348   return return_str;
1349 }
1350
1351 /*  CompactRISC CRX Architecture stack layout:
1352
1353      0 +---------------------
1354         |
1355         .
1356         .
1357         |
1358         +==================== Sp(x)=Ap(x+1)
1359       A | Args for functions
1360       | | called by X and      Dynamically
1361       | | Dynamic allocations  allocated and
1362       | | (alloca, variable    deallocated
1363   Stack | length arrays).
1364   grows +-------------------- Fp(x)
1365   down| | Local variables of X
1366   ward| +--------------------
1367       | | Regs saved for X-1
1368       | +==================== Sp(x-1)=Ap(x)
1369         | Args for func X
1370         | pushed by X-1
1371         +-------------------- Fp(x-1)
1372         |
1373         |
1374         V
1375
1376 */
1377
1378 void
1379 crx_expand_prologue (void)
1380 {
1381   crx_compute_frame ();
1382   crx_compute_save_regs ();
1383
1384   /* If there is no need in push and adjustment to sp, return. */
1385   if (size_for_adjusting_sp + sum_regs == 0)
1386     return;
1387
1388   if (last_reg_to_save != -1)
1389     /* If there are registers to push.  */
1390     emit_insn (gen_push_for_prologue (GEN_INT (sum_regs)));
1391
1392   if (size_for_adjusting_sp > 0)
1393     emit_insn (gen_addsi3 (stack_pointer_rtx, stack_pointer_rtx,
1394                            GEN_INT (-size_for_adjusting_sp)));
1395
1396   if (frame_pointer_needed)
1397     /* Initialize the frame pointer with the value of the stack pointer
1398      * pointing now to the locals. */
1399     emit_move_insn (frame_pointer_rtx, stack_pointer_rtx);
1400 }
1401
1402 /* Generate insn that updates the stack for local variables and padding for
1403  * registers we save. - Generate the appropriate return insn. */
1404
1405 void
1406 crx_expand_epilogue (void)
1407 {
1408   rtx return_reg;
1409
1410   /* Nonzero if we need to return and pop only RA. This will generate a
1411    * different insn. This differentiate is for the peepholes for call as last
1412    * statement in function. */
1413   int only_popret_RA = (save_regs[RETURN_ADDRESS_REGNUM]
1414                         && (sum_regs == UNITS_PER_WORD));
1415
1416   /* Return register.  */
1417   return_reg = gen_rtx_REG (Pmode, RETURN_ADDRESS_REGNUM);
1418
1419   if (frame_pointer_needed)
1420     /* Restore the stack pointer with the frame pointers value */
1421     emit_move_insn (stack_pointer_rtx, frame_pointer_rtx);
1422
1423   if (size_for_adjusting_sp > 0)
1424     emit_insn (gen_addsi3 (stack_pointer_rtx, stack_pointer_rtx,
1425                            GEN_INT (size_for_adjusting_sp)));
1426
1427   if (crx_interrupt_function_p ())
1428     emit_jump_insn (gen_interrupt_return ());
1429   else if (last_reg_to_save == -1)
1430     /* Nothing to pop */
1431     /* Don't output jump for interrupt routine, only retx.  */
1432     emit_jump_insn (gen_indirect_jump_return ());
1433   else if (only_popret_RA)
1434     emit_jump_insn (gen_popret_RA_return ());
1435   else
1436     emit_jump_insn (gen_pop_and_popret_return (GEN_INT (sum_regs)));
1437 }
1438