OSDN Git Service

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