home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 6 / FreshFish_September1994.bin / bbs / gnu / gcc-2.6.0-src.lha / GNU / src / amiga / gcc-2.6.0 / config / arm / arm.c next >
Encoding:
C/C++ Source or Header  |  1994-07-12  |  93.0 KB  |  3,689 lines

  1. /* Output routines for GCC for ARM/RISCiX.
  2.    Copyright (C) 1991, 1993, 1994 Free Software Foundation, Inc.
  3.    Contributed by Pieter `Tiggr' Schoenmakers (rcpieter@win.tue.nl)
  4.              and Martin Simmons (@harleqn.co.uk).
  5.    More major hacks by Richard Earnshaw (rwe11@cl.cam.ac.uk)
  6.  
  7. This file is part of GNU CC.
  8.  
  9. GNU CC is free software; you can redistribute it and/or modify
  10. it under the terms of the GNU General Public License as published by
  11. the Free Software Foundation; either version 2, or (at your option)
  12. any later version.
  13.  
  14. GNU CC is distributed in the hope that it will be useful,
  15. but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  17. GNU General Public License for more details.
  18.  
  19. You should have received a copy of the GNU General Public License
  20. along with GNU CC; see the file COPYING.  If not, write to
  21. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  22.     
  23. #include <stdio.h>
  24. #include <string.h>
  25. #include "assert.h"
  26. #include "config.h"
  27. #include "rtl.h"
  28. #include "regs.h"
  29. #include "hard-reg-set.h"
  30. #include "real.h"
  31. #include "insn-config.h"
  32. #include "conditions.h"
  33. #include "insn-flags.h"
  34. #include "output.h"
  35. #include "insn-attr.h"
  36. #include "flags.h"
  37. #include "reload.h"
  38. #include "tree.h"
  39. #include "expr.h"
  40.  
  41. /* The maximum number of insns skipped which will be conditionalised if
  42.    possible.  */
  43. #define MAX_INSNS_SKIPPED  5
  44.  
  45. /* Some function declarations.  */
  46. extern FILE *asm_out_file;
  47. extern char *output_multi_immediate ();
  48. extern void arm_increase_location ();
  49.  
  50. HOST_WIDE_INT int_log2 PROTO ((HOST_WIDE_INT));
  51. static int get_prologue_size PROTO ((void));
  52.  
  53. /*  Define the information needed to generate branch insns.  This is
  54.    stored from the compare operation. */
  55.  
  56. rtx arm_compare_op0, arm_compare_op1;
  57. int arm_compare_fp;
  58.  
  59. /* What type of cpu are we compiling for? */
  60. enum processor_type arm_cpu;
  61.  
  62. /* Waht type of floating point are we compiling for? */
  63. enum floating_point_type arm_fpu;
  64.  
  65. /* In case of a PRE_INC, POST_INC, PRE_DEC, POST_DEC memory reference, we
  66.    must report the mode of the memory reference from PRINT_OPERAND to
  67.    PRINT_OPERAND_ADDRESS.  */
  68. enum machine_mode output_memory_reference_mode;
  69.  
  70. /* Nonzero if the prologue must setup `fp'.  */
  71. int current_function_anonymous_args;
  72.  
  73. /* Location counter of .text segment.  */
  74. int arm_text_location = 0;
  75.  
  76. /* Set to one if we think that lr is only saved because of subroutine calls,
  77.    but all of these can be `put after' return insns */
  78. int lr_save_eliminated;
  79.  
  80. /* A hash table is used to store text segment labels and their associated
  81.    offset from the start of the text segment.  */
  82. struct label_offset
  83. {
  84.   char *name;
  85.   int offset;
  86.   struct label_offset *cdr;
  87. };
  88.  
  89. #define LABEL_HASH_SIZE  257
  90.  
  91. static struct label_offset *offset_table[LABEL_HASH_SIZE];
  92.  
  93. /* Set to 1 when a return insn is output, this means that the epilogue
  94.    is not needed. */
  95.  
  96. static int return_used_this_function;
  97.  
  98. /* For an explanation of these variables, see final_prescan_insn below.  */
  99. int arm_ccfsm_state;
  100. int arm_current_cc;
  101. rtx arm_target_insn;
  102. int arm_target_label;
  103.  
  104. /* The condition codes of the ARM, and the inverse function.  */
  105. char *arm_condition_codes[] =
  106. {
  107.   "eq", "ne", "cs", "cc", "mi", "pl", "vs", "vc",
  108.   "hi", "ls", "ge", "lt", "gt", "le", "al", "nv"
  109. };
  110.  
  111. #define ARM_INVERSE_CONDITION_CODE(X)  ((X) ^ 1)
  112.  
  113. /* Return 1 if it is possible to return using a single instruction */
  114.  
  115. int
  116. use_return_insn ()
  117. {
  118.   int regno;
  119.  
  120.   if (!reload_completed ||current_function_pretend_args_size
  121.       || current_function_anonymous_args
  122.       || (get_frame_size () && !(TARGET_APCS || frame_pointer_needed)))
  123.     return 0;
  124.  
  125.   /* Can't be done if any of the FPU regs are pushed, since this also
  126.      requires an insn */
  127.   for (regno = 20; regno < 24; regno++)
  128.     if (regs_ever_live[regno])
  129.       return 0;
  130.  
  131.   return 1;
  132. }
  133.  
  134. /* Return TRUE if int I is a valid immediate ARM constant.  */
  135.  
  136. int
  137. const_ok_for_arm (i)
  138.      HOST_WIDE_INT i;
  139. {
  140.   unsigned HOST_WIDE_INT mask = ~0xFF;
  141.  
  142.   /* Fast return for 0 and powers of 2 */
  143.   if ((i & (i - 1)) == 0)
  144.     return TRUE;
  145.  
  146.   do
  147.     {
  148.       if ((i & mask & (unsigned HOST_WIDE_INT) 0xffffffff) == 0)
  149.         return TRUE;
  150.       mask =
  151.       (mask << 2) | ((mask & (unsigned HOST_WIDE_INT) 0xffffffff)
  152.              >> (32 - 2)) | ~((unsigned HOST_WIDE_INT) 0xffffffff);
  153.     } while (mask != ~0xFF);
  154.  
  155.   return FALSE;
  156. }
  157.  
  158. /* Return true if I is a valid constant for the operation CODE. */
  159. int
  160. const_ok_for_op (i, code, mode)
  161.      HOST_WIDE_INT i;
  162.      enum rtx_code code;
  163.      enum machine_mode mode;
  164. {
  165.   if (const_ok_for_arm (i))
  166.     return 1;
  167.  
  168.   switch (code)
  169.     {
  170.     case PLUS:
  171.       return const_ok_for_arm (ARM_SIGN_EXTEND (-i));
  172.  
  173.     case MINUS:        /* Should only occur with (MINUS I reg) => rsb */
  174.     case XOR:
  175.     case IOR:
  176.       return 0;
  177.  
  178.     case AND:
  179.       return const_ok_for_arm (ARM_SIGN_EXTEND (~i));
  180.  
  181.     default:
  182.       abort ();
  183.     }
  184. }
  185.  
  186. /* Emit a sequence of insns to handle a large constant.
  187.    CODE is the code of the operation required, it can be any of SET, PLUS,
  188.    IOR, AND, XOR, MINUS;
  189.    MODE is the mode in which the operation is being performed;
  190.    VAL is the integer to operate on;
  191.    SOURCE is the other operand (a register, or a null-pointer for SET);
  192.    SUBTARGETS means it is safe to create scratch registers if that will
  193.    either produce a simpler sequence, or we will want to cse the values. */
  194.  
  195. int
  196. arm_split_constant (code, mode, val, target, source, subtargets)
  197.      enum rtx_code code;
  198.      enum machine_mode mode;
  199.      HOST_WIDE_INT val;
  200.      rtx target;
  201.      rtx source;
  202.      int subtargets;
  203. {
  204.   int can_add = 0;
  205.   int can_invert = 0;
  206.   int can_negate = 0;
  207.   int can_negate_initial = 0;
  208.   int can_shift = 0;
  209.   int i;
  210.   int num_bits_set = 0;
  211.   int set_sign_bit_copies = 0;
  212.   int clear_sign_bit_copies = 0;
  213.   int clear_zero_bit_copies = 0;
  214.   int set_zero_bit_copies = 0;
  215.   int insns = 0;
  216.   rtx new_src;
  217.   unsigned HOST_WIDE_INT temp1, temp2;
  218.   unsigned HOST_WIDE_INT remainder = val & 0xffffffff;
  219.  
  220.   /* find out which operations are safe for a given CODE.  Also do a quick
  221.      check for degenerate cases; these can occur when DImode operations
  222.      are split.  */
  223.   switch (code)
  224.     {
  225.     case SET:
  226.       can_invert = 1;
  227.       can_shift = 1;
  228.       can_negate = 1;
  229.       break;
  230.  
  231.     case PLUS:
  232.       can_negate = 1;
  233.       can_negate_initial = 1;
  234.       break;
  235.  
  236.     case IOR:
  237.       if (remainder == 0xffffffff)
  238.     {
  239.       emit_insn (gen_rtx (SET, VOIDmode, target,
  240.                   GEN_INT (ARM_SIGN_EXTEND (val))));
  241.       return 1;
  242.     }
  243.       if (remainder == 0)
  244.     {
  245.       if (reload_completed && rtx_equal_p (target, source))
  246.         return 0;
  247.       emit_insn (gen_rtx (SET, VOIDmode, target, source));
  248.       return 1;
  249.     }
  250.       break;
  251.  
  252.     case AND:
  253.       if (remainder == 0)
  254.     {
  255.       emit_insn (gen_rtx (SET, VOIDmode, target, const0_rtx));
  256.       return 1;
  257.     }
  258.       if (remainder == 0xffffffff)
  259.     {
  260.       if (reload_completed && rtx_equal_p (target, source))
  261.         return 0;
  262.       emit_insn (gen_rtx (SET, VOIDmode, target, source));
  263.       return 1;
  264.     }
  265.       can_invert = 1;
  266.       break;
  267.  
  268.     case XOR:
  269.       if (remainder == 0)
  270.     {
  271.       if (reload_completed && rtx_equal_p (target, source))
  272.         return 0;
  273.       emit_insn (gen_rtx (SET, VOIDmode, target, source));
  274.       return 1;
  275.     }
  276.       if (remainder == 0xffffffff)
  277.     {
  278.       emit_insn (gen_rtx (SET, VOIDmode, target,
  279.                   gen_rtx (NOT, mode, source)));
  280.       return 1;
  281.     }
  282.  
  283.       /* We don't know how to handle this yet below.  */
  284.       abort ();
  285.  
  286.     case MINUS:
  287.       /* We treat MINUS as (val - source), since (source - val) is always
  288.      passed as (source + (-val)).  */
  289.       if (remainder == 0)
  290.     {
  291.       emit_insn (gen_rtx (SET, VOIDmode, target,
  292.                   gen_rtx (NEG, mode, source)));
  293.       return 1;
  294.     }
  295.       if (const_ok_for_arm (val))
  296.     {
  297.       emit_insn (gen_rtx (SET, VOIDmode, target, 
  298.                   gen_rtx (MINUS, mode, GEN_INT (val), source)));
  299.       return 1;
  300.     }
  301.       can_negate = 1;
  302.  
  303.       break;
  304.  
  305.     default:
  306.       abort ();
  307.     }
  308.  
  309.   /* If we can do it in one insn get out quickly */
  310.   if (const_ok_for_arm (val)
  311.       || (can_negate_initial && const_ok_for_arm (-val))
  312.       || (can_invert && const_ok_for_arm (~val)))
  313.     {
  314.       emit_insn (gen_rtx (SET, VOIDmode, target,
  315.               (source ? gen_rtx (code, mode, source,
  316.                          GEN_INT (val)) : GEN_INT (val))));
  317.       return 1;
  318.     }
  319.  
  320.  
  321.   /* Calculate a few attributes that may be useful for specific
  322.      optimizations. */
  323.  
  324.   for (i = 31; i >= 0; i--)
  325.     {
  326.       if ((remainder & (1 << i)) == 0)
  327.     clear_sign_bit_copies++;
  328.       else
  329.     break;
  330.     }
  331.  
  332.   for (i = 31; i >= 0; i--)
  333.     {
  334.       if ((remainder & (1 << i)) != 0)
  335.     set_sign_bit_copies++;
  336.       else
  337.     break;
  338.     }
  339.  
  340.   for (i = 0; i <= 31; i++)
  341.     {
  342.       if ((remainder & (1 << i)) == 0)
  343.     clear_zero_bit_copies++;
  344.       else
  345.     break;
  346.     }
  347.  
  348.   for (i = 0; i <= 31; i++)
  349.     {
  350.       if ((remainder & (1 << i)) != 0)
  351.     set_zero_bit_copies++;
  352.       else
  353.     break;
  354.     }
  355.  
  356.   switch (code)
  357.     {
  358.     case SET:
  359.       /* See if we can do this by sign_extending a constant that is known
  360.      to be negative.  This is a good, way of doing it, since the shift
  361.      may well merge into a subsequent insn.  */
  362.       if (set_sign_bit_copies > 1)
  363.     {
  364.       if (const_ok_for_arm
  365.           (temp1 = ARM_SIGN_EXTEND (remainder 
  366.                     << (set_sign_bit_copies - 1))))
  367.         {
  368.           new_src = subtargets ? gen_reg_rtx (mode) : target;
  369.           emit_insn (gen_rtx (SET, VOIDmode, new_src, GEN_INT (temp1)));
  370.           emit_insn (gen_ashrsi3 (target, new_src, 
  371.                       GEN_INT (set_sign_bit_copies - 1)));
  372.           return 2;
  373.         }
  374.       /* For an inverted constant, we will need to set the low bits,
  375.          these will be shifted out of harm's way.  */
  376.       temp1 |= (1 << (set_sign_bit_copies - 1)) - 1;
  377.       if (const_ok_for_arm (~temp1))
  378.         {
  379.           new_src = subtargets ? gen_reg_rtx (mode) : target;
  380.           emit_insn (gen_rtx (SET, VOIDmode, new_src, GEN_INT (temp1)));
  381.           emit_insn (gen_ashrsi3 (target, new_src, 
  382.                       GEN_INT (set_sign_bit_copies - 1)));
  383.           return 2;
  384.         }
  385.     }
  386.  
  387.       /* See if we can generate this by setting the bottom (or the top)
  388.      16 bits, and then shifting these into the other half of the
  389.      word.  We only look for the simplest cases, to do more would cost
  390.      too much.  Be careful, however, not to generate this when the
  391.      alternative would take fewer insns.  */
  392.       if (val & 0xffff0000)
  393.     {
  394.       temp1 = remainder & 0xffff0000;
  395.       temp2 = remainder & 0x0000ffff;
  396.  
  397.       /* Overlaps outside this range are best done using other methods. */
  398.       for (i = 9; i < 24; i++)
  399.         {
  400.           if ((((temp2 | (temp2 << i)) & 0xffffffff) == remainder)
  401.           && ! const_ok_for_arm (temp2))
  402.         {
  403.           insns
  404.             = arm_split_constant (code, mode, temp2,
  405.                       (new_src
  406.                        = subtargets ? gen_reg_rtx (mode)
  407.                        : target),
  408.                       source, subtargets);
  409.           source = new_src;
  410.           emit_insn (gen_rtx (SET, VOIDmode, target,
  411.                       gen_rtx (IOR, mode,
  412.                            gen_rtx (ASHIFT, mode, source,
  413.                             GEN_INT (i)),
  414.                            source)));
  415.           return insns + 1;
  416.         }
  417.         }
  418.  
  419.       /* Don't duplicate cases already considered. */
  420.       for (i = 17; i < 24; i++)
  421.         {
  422.           if (((temp1 | (temp1 >> i)) == remainder)
  423.           && ! const_ok_for_arm (temp1))
  424.         {
  425.           insns
  426.             = arm_split_constant (code, mode, temp1,
  427.                       (new_src
  428.                        = subtargets ? gen_reg_rtx (mode)
  429.                        : target),
  430.                       source, subtargets);
  431.           source = new_src;
  432.           emit_insn (gen_rtx (SET, VOIDmode, target,
  433.                       gen_rtx (IOR, mode,
  434.                            gen_rtx (LSHIFTRT, mode, source,
  435.                             GEN_INT (i)),
  436.                            source)));
  437.           return insns + 1;
  438.         }
  439.         }
  440.     }
  441.       break;
  442.  
  443.     case IOR:
  444.     case XOR:
  445.       /* If we have IOR or XOR, and the inverse of the constant can be loaded
  446.      in a single instruction, and we can find a temporary to put it in,
  447.      then this can be done in two instructions instead of 3-4.  */
  448.       if (subtargets
  449.       || (reload_completed && ! reg_mentioned_p (target, source)))
  450.     {
  451.       if (const_ok_for_arm (ARM_SIGN_EXTEND (~ val)))
  452.         {
  453.           rtx sub = subtargets ? gen_reg_rtx (mode) : target;
  454.  
  455.           emit_insn (gen_rtx (SET, VOIDmode, sub,
  456.                   GEN_INT (ARM_SIGN_EXTEND (~ val))));
  457.           emit_insn (gen_rtx (SET, VOIDmode, target, 
  458.                   gen_rtx (code, mode, source, sub)));
  459.           return 2;
  460.         }
  461.     }
  462.  
  463.       if (code == XOR)
  464.     break;
  465.  
  466.       if (set_sign_bit_copies > 8
  467.       && (val & (-1 << (32 - set_sign_bit_copies))) == val)
  468.     {
  469.       rtx sub = subtargets ? gen_reg_rtx (mode) : target;
  470.       rtx shift = GEN_INT (set_sign_bit_copies);
  471.  
  472.       emit_insn (gen_rtx (SET, VOIDmode, sub,
  473.                   gen_rtx (NOT, mode, 
  474.                        gen_rtx (ASHIFT, mode, source, 
  475.                         shift))));
  476.       emit_insn (gen_rtx (SET, VOIDmode, target,
  477.                   gen_rtx (NOT, mode,
  478.                        gen_rtx (LSHIFTRT, mode, sub,
  479.                         shift))));
  480.       return 2;
  481.     }
  482.  
  483.       if (set_zero_bit_copies > 8
  484.       && (remainder & ((1 << set_zero_bit_copies) - 1)) == remainder)
  485.     {
  486.       rtx sub = subtargets ? gen_reg_rtx (mode) : target;
  487.       rtx shift = GEN_INT (set_zero_bit_copies);
  488.       
  489.       emit_insn (gen_rtx (SET, VOIDmode, sub,
  490.                   gen_rtx (NOT, mode,
  491.                        gen_rtx (LSHIFTRT, mode, source,
  492.                         shift))));
  493.       emit_insn (gen_rtx (SET, VOIDmode, target,
  494.                   gen_rtx (NOT, mode,
  495.                        gen_rtx (ASHIFT, mode, sub,
  496.                         shift))));
  497.       return 2;
  498.     }
  499.  
  500.       if (const_ok_for_arm (temp1 = ARM_SIGN_EXTEND (~ val)))
  501.     {
  502.       rtx sub = subtargets ? gen_reg_rtx (mode) : target;
  503.       emit_insn (gen_rtx (SET, VOIDmode, sub,
  504.                   gen_rtx (NOT, mode, source)));
  505.       source = sub;
  506.       if (subtargets)
  507.         sub = gen_reg_rtx (mode);
  508.       emit_insn (gen_rtx (SET, VOIDmode, sub,
  509.                   gen_rtx (AND, mode, source, GEN_INT (temp1))));
  510.       emit_insn (gen_rtx (SET, VOIDmode, target,
  511.                   gen_rtx (NOT, mode, sub)));
  512.       return 3;
  513.     }
  514.       break;
  515.  
  516.     case AND:
  517.       /* See if two shifts will do 2 or more insn's worth of work.  */
  518.       if (clear_sign_bit_copies >= 16 && clear_sign_bit_copies < 24)
  519.     {
  520.       HOST_WIDE_INT shift_mask = ((0xffffffff 
  521.                        << (32 - clear_sign_bit_copies))
  522.                       & 0xffffffff);
  523.       rtx new_source;
  524.       rtx shift = GEN_INT (clear_sign_bit_copies);
  525.  
  526.       if ((remainder | shift_mask) != 0xffffffff)
  527.         {
  528.           new_source = subtargets ? gen_reg_rtx (mode) : target;
  529.           insns = arm_split_constant (AND, mode, remainder | shift_mask,
  530.                       new_source, source, subtargets);
  531.           source = new_source;
  532.         }
  533.  
  534.       new_source = subtargets ? gen_reg_rtx (mode) : target;
  535.       emit_insn (gen_ashlsi3 (new_source, source, shift));
  536.       emit_insn (gen_lshrsi3 (target, new_source, shift));
  537.       return insns + 2;
  538.     }
  539.  
  540.       if (clear_zero_bit_copies >= 16 && clear_zero_bit_copies < 24)
  541.     {
  542.       HOST_WIDE_INT shift_mask = (1 << clear_zero_bit_copies) - 1;
  543.       rtx new_source;
  544.       rtx shift = GEN_INT (clear_zero_bit_copies);
  545.       
  546.       if ((remainder | shift_mask) != 0xffffffff)
  547.         {
  548.           new_source = subtargets ? gen_reg_rtx (mode) : target;
  549.           insns = arm_split_constant (AND, mode, remainder | shift_mask,
  550.                       new_source, source, subtargets);
  551.           source = new_source;
  552.         }
  553.  
  554.       new_source = subtargets ? gen_reg_rtx (mode) : target;
  555.       emit_insn (gen_lshrsi3 (new_source, source, shift));
  556.       emit_insn (gen_ashlsi3 (target, new_source, shift));
  557.       return insns + 2;
  558.     }
  559.  
  560.       break;
  561.  
  562.     default:
  563.       break;
  564.     }
  565.  
  566.   for (i = 0; i < 32; i++)
  567.     if (remainder & (1 << i))
  568.       num_bits_set++;
  569.  
  570.   if (code == AND || (can_invert && num_bits_set > 16))
  571.     remainder = (~remainder) & 0xffffffff;
  572.   else if (code == PLUS && num_bits_set > 16)
  573.     remainder = (-remainder) & 0xffffffff;
  574.   else
  575.     {
  576.       can_invert = 0;
  577.       can_negate = 0;
  578.     }
  579.  
  580.   /* Now try and find a way of doing the job in either two or three
  581.      instructions.
  582.      We start by looking for the largest block of zeros that are aligned on
  583.      a 2-bit boundary, we then fill up the temps, wrapping around to the
  584.      top of the word when we drop off the bottom.
  585.      In the worst case this code should produce no more than four insns. */
  586.   {
  587.     int best_start = 0;
  588.     int best_consecutive_zeros = 0;
  589.  
  590.     for (i = 0; i < 32; i += 2)
  591.       {
  592.     int consecutive_zeros = 0;
  593.  
  594.     if (! (remainder & (3 << i)))
  595.       {
  596.         while ((i < 32) && ! (remainder & (3 << i)))
  597.           {
  598.         consecutive_zeros += 2;
  599.         i += 2;
  600.           }
  601.         if (consecutive_zeros > best_consecutive_zeros)
  602.           {
  603.         best_consecutive_zeros = consecutive_zeros;
  604.         best_start = i - consecutive_zeros;
  605.           }
  606.         i -= 2;
  607.       }
  608.       }
  609.  
  610.     /* Now start emitting the insns, starting with the one with the highest
  611.        bit set: we do this so that the smallest number will be emitted last;
  612.        this is more likely to be combinable with addressing insns. */
  613.     i = best_start;
  614.     do
  615.       {
  616.     int end;
  617.  
  618.     if (i <= 0)
  619.       i += 32;
  620.     if (remainder & (3 << (i - 2)))
  621.       {
  622.         end = i - 8;
  623.         if (end < 0)
  624.           end += 32;
  625.         temp1 = remainder & ((0x0ff << end)
  626.                  | ((i < end) ? (0xff >> (32 - end)) : 0));
  627.         remainder &= ~temp1;
  628.  
  629.         if (code == SET)
  630.           {
  631.         emit_insn (gen_rtx (SET, VOIDmode,
  632.                     new_src = (subtargets ? gen_reg_rtx (mode)
  633.                            : target),
  634.                     GEN_INT (can_invert ? ~temp1 : temp1)));
  635.         can_invert = 0;
  636.         code = PLUS;
  637.           }
  638.         else if (code == MINUS)
  639.           {
  640.         emit_insn (gen_rtx (SET, VOIDmode,
  641.                     new_src = (subtargets ? gen_reg_rtx (mode)
  642.                            : target),
  643.                     gen_rtx (code, mode, GEN_INT (temp1),
  644.                          source)));
  645.         code = PLUS;
  646.           }
  647.         else
  648.           {
  649.         emit_insn (gen_rtx (SET, VOIDmode,
  650.                     new_src = remainder ? (subtargets
  651.                                ? gen_reg_rtx (mode)
  652.                                : target) : target,
  653.                     gen_rtx (code, mode, source,
  654.                          GEN_INT (can_invert ? ~temp1
  655.                               : (can_negate
  656.                              ? -temp1 : temp1)))));
  657.           }
  658.  
  659.         insns++;
  660.         source = new_src;
  661.         i -= 6;
  662.       }
  663.     i -= 2;
  664.       } while (remainder);
  665.   }
  666.   return insns;
  667. }
  668.  
  669. #define REG_OR_SUBREG_REG(X)                        \
  670.   (GET_CODE (X) == REG                            \
  671.    || (GET_CODE (X) == SUBREG && GET_CODE (SUBREG_REG (X)) == REG))
  672.  
  673. #define REG_OR_SUBREG_RTX(X)            \
  674.    (GET_CODE (X) == REG ? (X) : SUBREG_REG (X))
  675.  
  676. #define ARM_FRAME_RTX(X)                \
  677.   ((X) == frame_pointer_rtx || (X) == stack_pointer_rtx    \
  678.    || (X) == arg_pointer_rtx)
  679.  
  680. int
  681. arm_rtx_costs (x, code, outer_code)
  682.      rtx x;
  683.      enum rtx_code code, outer_code;
  684. {
  685.   enum machine_mode mode = GET_MODE (x);
  686.   enum rtx_code subcode;
  687.   int extra_cost;
  688.  
  689.   switch (code)
  690.     {
  691.     case MEM:
  692.       /* Memory costs quite a lot for the first word, but subsequent words
  693.      load at the equivalent of a single insn each.  */
  694.       return (10 + 4 * ((GET_MODE_SIZE (mode) - 1) / UNITS_PER_WORD)
  695.           + (CONSTANT_POOL_ADDRESS_P (x) ? 4 : 0));
  696.  
  697.     case DIV:
  698.     case MOD:
  699.       return 100;
  700.  
  701.     case ROTATE:
  702.       if (mode == SImode && GET_CODE (XEXP (x, 1)) == REG)
  703.     return 4;
  704.       /* Fall through */
  705.     case ROTATERT:
  706.       if (mode != SImode)
  707.     return 8;
  708.       /* Fall through */
  709.     case ASHIFT: case LSHIFTRT: case ASHIFTRT:
  710.       if (mode == DImode)
  711.     return (8 + (GET_CODE (XEXP (x, 1)) == CONST_INT ? 0 : 8)
  712.         + ((GET_CODE (XEXP (x, 0)) == REG 
  713.             || (GET_CODE (XEXP (x, 0)) == SUBREG
  714.             && GET_CODE (SUBREG_REG (XEXP (x, 0))) == REG))
  715.            ? 0 : 8));
  716.       return (1 + ((GET_CODE (XEXP (x, 0)) == REG
  717.             || (GET_CODE (XEXP (x, 0)) == SUBREG
  718.             && GET_CODE (SUBREG_REG (XEXP (x, 0))) == REG))
  719.            ? 0 : 4)
  720.           + ((GET_CODE (XEXP (x, 1)) == REG
  721.           || (GET_CODE (XEXP (x, 1)) == SUBREG
  722.               && GET_CODE (SUBREG_REG (XEXP (x, 1))) == REG)
  723.           || (GET_CODE (XEXP (x, 1)) == CONST_INT))
  724.          ? 0 : 4));
  725.  
  726.     case MINUS:
  727.       if (mode == DImode)
  728.     return (4 + (REG_OR_SUBREG_REG (XEXP (x, 1)) ? 0 : 8)
  729.         + ((REG_OR_SUBREG_REG (XEXP (x, 0))
  730.             || (GET_CODE (XEXP (x, 0)) == CONST_INT
  731.                && const_ok_for_arm (INTVAL (XEXP (x, 0)))))
  732.            ? 0 : 8));
  733.  
  734.       if (GET_MODE_CLASS (mode) == MODE_FLOAT)
  735.     return (2 + ((REG_OR_SUBREG_REG (XEXP (x, 1))
  736.               || (GET_CODE (XEXP (x, 1)) == CONST_DOUBLE
  737.               && const_double_rtx_ok_for_fpu (XEXP (x, 1))))
  738.              ? 0 : 8)
  739.         + ((REG_OR_SUBREG_REG (XEXP (x, 0))
  740.             || (GET_CODE (XEXP (x, 0)) == CONST_DOUBLE
  741.             && const_double_rtx_ok_for_fpu (XEXP (x, 0))))
  742.            ? 0 : 8));
  743.  
  744.       if (((GET_CODE (XEXP (x, 0)) == CONST_INT
  745.         && const_ok_for_arm (INTVAL (XEXP (x, 0)))
  746.         && REG_OR_SUBREG_REG (XEXP (x, 1))))
  747.       || (((subcode = GET_CODE (XEXP (x, 1))) == ASHIFT
  748.            || subcode == ASHIFTRT || subcode == LSHIFTRT
  749.            || subcode == ROTATE || subcode == ROTATERT
  750.            || (subcode == MULT
  751.            && GET_CODE (XEXP (XEXP (x, 1), 1)) == CONST_INT
  752.            && ((INTVAL (XEXP (XEXP (x, 1), 1)) &
  753.             (INTVAL (XEXP (XEXP (x, 1), 1)) - 1)) == 0)))
  754.           && REG_OR_SUBREG_REG (XEXP (XEXP (x, 1), 0))
  755.           && (REG_OR_SUBREG_REG (XEXP (XEXP (x, 1), 1))
  756.           || GET_CODE (XEXP (XEXP (x, 1), 1)) == CONST_INT)
  757.           && REG_OR_SUBREG_REG (XEXP (x, 0))))
  758.     return 1;
  759.       /* Fall through */
  760.  
  761.     case PLUS: 
  762.       if (GET_MODE_CLASS (mode) == MODE_FLOAT)
  763.     return (2 + (REG_OR_SUBREG_REG (XEXP (x, 0)) ? 0 : 8)
  764.         + ((REG_OR_SUBREG_REG (XEXP (x, 1))
  765.             || (GET_CODE (XEXP (x, 1)) == CONST_DOUBLE
  766.             && const_double_rtx_ok_for_fpu (XEXP (x, 1))))
  767.            ? 0 : 8));
  768.  
  769.       /* Fall through */
  770.     case AND: case XOR: case IOR: 
  771.       extra_cost = 0;
  772.  
  773.       /* Normally the frame registers will be spilt into reg+const during
  774.      reload, so it is a bad idea to combine them with other instructions,
  775.      since then they might not be moved outside of loops.  As a compromise
  776.      we allow integration with ops that have a constant as their second
  777.      operand.  */
  778.       if ((REG_OR_SUBREG_REG (XEXP (x, 0))
  779.        && ARM_FRAME_RTX (REG_OR_SUBREG_RTX (XEXP (x, 0)))
  780.        && GET_CODE (XEXP (x, 1)) != CONST_INT)
  781.       || (REG_OR_SUBREG_REG (XEXP (x, 0))
  782.           && ARM_FRAME_RTX (REG_OR_SUBREG_RTX (XEXP (x, 0)))))
  783.     extra_cost = 4;
  784.  
  785.       if (mode == DImode)
  786.     return (4 + extra_cost + (REG_OR_SUBREG_REG (XEXP (x, 0)) ? 0 : 8)
  787.         + ((REG_OR_SUBREG_REG (XEXP (x, 1))
  788.             || (GET_CODE (XEXP (x, 1)) == CONST_INT
  789.             && const_ok_for_op (INTVAL (XEXP (x, 1)), code, mode)))
  790.            ? 0 : 8));
  791.  
  792.       if (REG_OR_SUBREG_REG (XEXP (x, 0)))
  793.     return (1 + (GET_CODE (XEXP (x, 1)) == CONST_INT ? 0 : extra_cost)
  794.         + ((REG_OR_SUBREG_REG (XEXP (x, 1))
  795.             || (GET_CODE (XEXP (x, 1)) == CONST_INT
  796.             && const_ok_for_op (INTVAL (XEXP (x, 1)), code, mode)))
  797.            ? 0 : 4));
  798.  
  799.       else if (REG_OR_SUBREG_REG (XEXP (x, 1)))
  800.     return (1 + extra_cost
  801.         + ((((subcode = GET_CODE (XEXP (x, 0))) == ASHIFT
  802.              || subcode == LSHIFTRT || subcode == ASHIFTRT
  803.              || subcode == ROTATE || subcode == ROTATERT
  804.              || (subcode == MULT
  805.              && GET_CODE (XEXP (XEXP (x, 0), 1)) == CONST_INT
  806.              && ((INTVAL (XEXP (XEXP (x, 0), 1)) &
  807.                   (INTVAL (XEXP (XEXP (x, 0), 1)) - 1)) == 0))
  808.             && (REG_OR_SUBREG_REG (XEXP (XEXP (x, 0), 0)))
  809.             && ((REG_OR_SUBREG_REG (XEXP (XEXP (x, 0), 1)))
  810.             || GET_CODE (XEXP (XEXP (x, 0), 1)) == CONST_INT)))
  811.            ? 0 : 4));
  812.  
  813.       return 8;
  814.  
  815.     case MULT:
  816.       if (GET_MODE_CLASS (mode) == MODE_FLOAT
  817.       || mode == DImode)
  818.     return 30;
  819.  
  820.       if (GET_CODE (XEXP (x, 1)) == CONST_INT)
  821.     {
  822.       HOST_WIDE_INT i = INTVAL (XEXP (x, 1)) & 0xffffffff;
  823.       int add_cost = const_ok_for_arm (i) ? 4 : 8;
  824.       int j;
  825.       
  826.       /* This will need adjusting for ARM's with fast multiplies */
  827.       for (j = 0; i && j < 32; j += 2)
  828.         {
  829.           i &= ~(3 << j);
  830.           add_cost += 2;
  831.         }
  832.  
  833.       return add_cost;
  834.     }
  835.  
  836.       return (30 + (REG_OR_SUBREG_REG (XEXP (x, 0)) ? 0 : 4)
  837.           + (REG_OR_SUBREG_REG (XEXP (x, 1)) ? 0 : 4));
  838.  
  839.     case NEG:
  840.       if (GET_MODE_CLASS (mode) == MODE_FLOAT)
  841.     return 4 + (REG_OR_SUBREG_REG (XEXP (x, 0)) ? 0 : 6);
  842.       /* Fall through */
  843.     case NOT:
  844.       if (mode == DImode)
  845.     return 4 + (REG_OR_SUBREG_REG (XEXP (x, 0)) ? 0 : 4);
  846.  
  847.       return 1 + (REG_OR_SUBREG_REG (XEXP (x, 0)) ? 0 : 4);
  848.  
  849.     case IF_THEN_ELSE:
  850.       if (GET_CODE (XEXP (x, 1)) == PC || GET_CODE (XEXP (x, 2)) == PC)
  851.     return 14;
  852.       return 2;
  853.  
  854.     case COMPARE:
  855.       return 1;
  856.  
  857.     case ABS:
  858.       return 4 + (mode == DImode ? 4 : 0);
  859.  
  860.     case SIGN_EXTEND:
  861.       if (GET_MODE (XEXP (x, 0)) == QImode)
  862.     return (4 + (mode == DImode ? 4 : 0)
  863.         + (GET_CODE (XEXP (x, 0)) == MEM ? 10 : 0));
  864.       /* Fall through */
  865.     case ZERO_EXTEND:
  866.       switch (GET_MODE (XEXP (x, 0)))
  867.     {
  868.     case QImode:
  869.       return (1 + (mode == DImode ? 4 : 0)
  870.           + (GET_CODE (XEXP (x, 0)) == MEM ? 10 : 0));
  871.  
  872.     case HImode:
  873.       return (4 + (mode == DImode ? 4 : 0)
  874.           + (GET_CODE (XEXP (x, 0)) == MEM ? 10 : 0));
  875.  
  876.     case SImode:
  877.       return (1 + (GET_CODE (XEXP (x, 0)) == MEM ? 10 : 0));
  878.     }
  879.       abort ();
  880.  
  881.     default:
  882.       return 99;
  883.     }
  884. }
  885.      
  886. /* This code has been fixed for cross compilation. */
  887.  
  888. static int fpa_consts_inited = 0;
  889.  
  890. char *strings_fpa[8] = {
  891.   "0.0",
  892.   "1.0",
  893.   "2.0",
  894.   "3.0",
  895.   "4.0",
  896.   "5.0",
  897.   "0.5",
  898.   "10.0"
  899.   };
  900.  
  901. static REAL_VALUE_TYPE values_fpa[8];
  902.  
  903. static void
  904. init_fpa_table ()
  905. {
  906.   int i;
  907.   REAL_VALUE_TYPE r;
  908.  
  909.   for (i = 0; i < 8; i++)
  910.     {
  911.       r = REAL_VALUE_ATOF (strings_fpa[i], DFmode);
  912.       values_fpa[i] = r;
  913.     }
  914.  
  915.   fpa_consts_inited = 1;
  916. }
  917.  
  918. /* Return TRUE if rtx X is a valid immediate FPU constant. */
  919.  
  920. int
  921. const_double_rtx_ok_for_fpu (x)
  922.      rtx x;
  923. {
  924.   REAL_VALUE_TYPE r;
  925.   int i;
  926.   
  927.   if (!fpa_consts_inited)
  928.     init_fpa_table ();
  929.   
  930.   REAL_VALUE_FROM_CONST_DOUBLE (r, x);
  931.   if (REAL_VALUE_MINUS_ZERO (r))
  932.     return 0;
  933.  
  934.   for (i = 0; i < 8; i++)
  935.     if (REAL_VALUES_EQUAL (r, values_fpa[i]))
  936.       return 1;
  937.  
  938.   return 0;
  939. }
  940.  
  941. /* Return TRUE if rtx X is a valid immediate FPU constant. */
  942.  
  943. int
  944. neg_const_double_rtx_ok_for_fpu (x)
  945.      rtx x;
  946. {
  947.   REAL_VALUE_TYPE r;
  948.   int i;
  949.   
  950.   if (!fpa_consts_inited)
  951.     init_fpa_table ();
  952.   
  953.   REAL_VALUE_FROM_CONST_DOUBLE (r, x);
  954.   r = REAL_VALUE_NEGATE (r);
  955.   if (REAL_VALUE_MINUS_ZERO (r))
  956.     return 0;
  957.  
  958.   for (i = 0; i < 8; i++)
  959.     if (REAL_VALUES_EQUAL (r, values_fpa[i]))
  960.       return 1;
  961.  
  962.   return 0;
  963. }
  964.  
  965. /* Predicates for `match_operand' and `match_operator'.  */
  966.  
  967. /* s_register_operand is the same as register_operand, but it doesn't accept
  968.    (SUBREG (MEM)...). */
  969.  
  970. int
  971. s_register_operand (op, mode)
  972.      register rtx op;
  973.      enum machine_mode mode;
  974. {
  975.   if (GET_MODE (op) != mode && mode != VOIDmode)
  976.     return 0;
  977.  
  978.   if (GET_CODE (op) == SUBREG)
  979.     op = SUBREG_REG (op);
  980.  
  981.   /* We don't consider registers whose class is NO_REGS
  982.      to be a register operand.  */
  983.   return (GET_CODE (op) == REG
  984.       && (REGNO (op) >= FIRST_PSEUDO_REGISTER
  985.           || REGNO_REG_CLASS (REGNO (op)) != NO_REGS));
  986. }
  987.  
  988. /* Only accept reg, subreg(reg), const_int.  */
  989.  
  990. int
  991. reg_or_int_operand (op, mode)
  992.      register rtx op;
  993.      enum machine_mode mode;
  994. {
  995.   if (GET_CODE (op) == CONST_INT)
  996.     return 1;
  997.  
  998.   if (GET_MODE (op) != mode && mode != VOIDmode)
  999.     return 0;
  1000.  
  1001.   if (GET_CODE (op) == SUBREG)
  1002.     op = SUBREG_REG (op);
  1003.  
  1004.   /* We don't consider registers whose class is NO_REGS
  1005.      to be a register operand.  */
  1006.   return (GET_CODE (op) == REG
  1007.       && (REGNO (op) >= FIRST_PSEUDO_REGISTER
  1008.           || REGNO_REG_CLASS (REGNO (op)) != NO_REGS));
  1009. }
  1010.  
  1011. /* Return 1 if OP is an item in memory, given that we are in reload.  */
  1012.  
  1013. int
  1014. reload_memory_operand (op, mode)
  1015.      rtx op;
  1016.      enum machine_mode mode;
  1017. {
  1018.   int regno = true_regnum (op);
  1019.  
  1020.   return (! CONSTANT_P (op)
  1021.       && (regno == -1
  1022.           || (GET_CODE (op) == REG
  1023.           && REGNO (op) >= FIRST_PSEUDO_REGISTER)));
  1024. }
  1025.  
  1026. /* Return TRUE for valid operands for the rhs of an ARM instruction.  */
  1027.  
  1028. int
  1029. arm_rhs_operand (op, mode)
  1030.      rtx op;
  1031.      enum machine_mode mode;
  1032. {
  1033.   return (s_register_operand (op, mode)
  1034.       || (GET_CODE (op) == CONST_INT && const_ok_for_arm (INTVAL (op))));
  1035. }
  1036.  
  1037. /* Return TRUE for valid operands for the rhs of an ARM instruction, or a load.
  1038.  */
  1039.  
  1040. int
  1041. arm_rhsm_operand (op, mode)
  1042.      rtx op;
  1043.      enum machine_mode mode;
  1044. {
  1045.   return (s_register_operand (op, mode)
  1046.       || (GET_CODE (op) == CONST_INT && const_ok_for_arm (INTVAL (op)))
  1047.       || memory_operand (op, mode));
  1048. }
  1049.  
  1050. /* Return TRUE for valid operands for the rhs of an ARM instruction, or if a
  1051.    constant that is valid when negated.  */
  1052.  
  1053. int
  1054. arm_add_operand (op, mode)
  1055.      rtx op;
  1056.      enum machine_mode mode;
  1057. {
  1058.   return (s_register_operand (op, mode)
  1059.       || (GET_CODE (op) == CONST_INT
  1060.           && (const_ok_for_arm (INTVAL (op))
  1061.           || const_ok_for_arm (-INTVAL (op)))));
  1062. }
  1063.  
  1064. int
  1065. arm_not_operand (op, mode)
  1066.      rtx op;
  1067.      enum machine_mode mode;
  1068. {
  1069.   return (s_register_operand (op, mode)
  1070.       || (GET_CODE (op) == CONST_INT
  1071.           && (const_ok_for_arm (INTVAL (op))
  1072.           || const_ok_for_arm (~INTVAL (op)))));
  1073. }
  1074.  
  1075. /* Return TRUE for valid operands for the rhs of an FPU instruction.  */
  1076.  
  1077. int
  1078. fpu_rhs_operand (op, mode)
  1079.      rtx op;
  1080.      enum machine_mode mode;
  1081. {
  1082.   if (s_register_operand (op, mode))
  1083.     return TRUE;
  1084.   else if (GET_CODE (op) == CONST_DOUBLE)
  1085.     return (const_double_rtx_ok_for_fpu (op));
  1086.  
  1087.   return FALSE;
  1088. }
  1089.  
  1090. int
  1091. fpu_add_operand (op, mode)
  1092.      rtx op;
  1093.      enum machine_mode mode;
  1094. {
  1095.   if (s_register_operand (op, mode))
  1096.     return TRUE;
  1097.   else if (GET_CODE (op) == CONST_DOUBLE)
  1098.     return (const_double_rtx_ok_for_fpu (op) 
  1099.         || neg_const_double_rtx_ok_for_fpu (op));
  1100.  
  1101.   return FALSE;
  1102. }
  1103.  
  1104. /* Return nonzero if OP is a constant power of two.  */
  1105.  
  1106. int
  1107. power_of_two_operand (op, mode)
  1108.      rtx op;
  1109.      enum machine_mode mode;
  1110. {
  1111.   if (GET_CODE (op) == CONST_INT)
  1112.     {
  1113.       HOST_WIDE_INT value = INTVAL(op);
  1114.       return value != 0  &&  (value & (value - 1)) == 0;
  1115.     }
  1116.   return FALSE;
  1117. }
  1118.  
  1119. /* Return TRUE for a valid operand of a DImode operation.
  1120.    Either: REG, CONST_DOUBLE or MEM(DImode_address).
  1121.    Note that this disallows MEM(REG+REG), but allows
  1122.    MEM(PRE/POST_INC/DEC(REG)).  */
  1123.  
  1124. int
  1125. di_operand (op, mode)
  1126.      rtx op;
  1127.      enum machine_mode mode;
  1128. {
  1129.   if (s_register_operand (op, mode))
  1130.     return TRUE;
  1131.  
  1132.   switch (GET_CODE (op))
  1133.     {
  1134.     case CONST_DOUBLE:
  1135.     case CONST_INT:
  1136.       return TRUE;
  1137.  
  1138.     case MEM:
  1139.       return memory_address_p (DImode, XEXP (op, 0));
  1140.  
  1141.     default:
  1142.       return FALSE;
  1143.     }
  1144. }
  1145.  
  1146. /* Return TRUE for valid index operands. */
  1147.  
  1148. int
  1149. index_operand (op, mode)
  1150.      rtx op;
  1151.      enum machine_mode mode;
  1152. {
  1153.   return (s_register_operand(op, mode)
  1154.       || (immediate_operand (op, mode)
  1155.           && INTVAL (op) < 4096 && INTVAL (op) > -4096));
  1156. }
  1157.  
  1158. /* Return TRUE for valid shifts by a constant. This also accepts any
  1159.    power of two on the (somewhat overly relaxed) assumption that the
  1160.    shift operator in this case was a mult. */
  1161.  
  1162. int
  1163. const_shift_operand (op, mode)
  1164.      rtx op;
  1165.      enum machine_mode mode;
  1166. {
  1167.   return (power_of_two_operand (op, mode)
  1168.       || (immediate_operand (op, mode)
  1169.           && (INTVAL (op) < 32 && INTVAL (op) > 0)));
  1170. }
  1171.  
  1172. /* Return TRUE for arithmetic operators which can be combined with a multiply
  1173.    (shift).  */
  1174.  
  1175. int
  1176. shiftable_operator (x, mode)
  1177.      rtx x;
  1178.      enum machine_mode mode;
  1179. {
  1180.   if (GET_MODE (x) != mode)
  1181.     return FALSE;
  1182.   else
  1183.     {
  1184.       enum rtx_code code = GET_CODE (x);
  1185.  
  1186.       return (code == PLUS || code == MINUS
  1187.           || code == IOR || code == XOR || code == AND);
  1188.     }
  1189. }
  1190.  
  1191. /* Return TRUE for shift operators. */
  1192.  
  1193. int
  1194. shift_operator (x, mode)
  1195.      rtx x;
  1196.      enum machine_mode mode;
  1197. {
  1198.   if (GET_MODE (x) != mode)
  1199.     return FALSE;
  1200.   else
  1201.     {
  1202.       enum rtx_code code = GET_CODE (x);
  1203.  
  1204.       if (code == MULT)
  1205.     return power_of_two_operand (XEXP (x, 1));
  1206.  
  1207.       return (code == ASHIFT || code == ASHIFTRT || code == LSHIFTRT
  1208.           || code == ROTATERT);
  1209.     }
  1210. }
  1211.  
  1212. int equality_operator (x, mode)
  1213.      rtx x;
  1214.      enum machine_mode mode;
  1215. {
  1216.   return GET_CODE (x) == EQ || GET_CODE (x) == NE;
  1217. }
  1218.  
  1219. /* Return TRUE for SMIN SMAX UMIN UMAX operators. */
  1220.  
  1221. int
  1222. minmax_operator (x, mode)
  1223.      rtx x;
  1224.      enum machine_mode mode;
  1225. {
  1226.   enum rtx_code code = GET_CODE (x);
  1227.  
  1228.   if (GET_MODE (x) != mode)
  1229.     return FALSE;
  1230.  
  1231.   return code == SMIN || code == SMAX || code == UMIN || code == UMAX;
  1232. }
  1233.  
  1234. /* return TRUE if x is EQ or NE */
  1235.  
  1236. /* Return TRUE if this is the condition code register, if we aren't given
  1237.    a mode, accept any class CCmode register */
  1238.  
  1239. int
  1240. cc_register (x, mode)
  1241.      rtx x;
  1242.      enum machine_mode mode;
  1243. {
  1244.   if (mode == VOIDmode)
  1245.     {
  1246.       mode = GET_MODE (x);
  1247.       if (GET_MODE_CLASS (mode) != MODE_CC)
  1248.     return FALSE;
  1249.     }
  1250.  
  1251.   if (mode == GET_MODE (x) && GET_CODE (x) == REG && REGNO (x) == 24)
  1252.     return TRUE;
  1253.  
  1254.   return FALSE;
  1255. }
  1256.  
  1257. /* Return TRUE if this is the condition code register, if we aren't given
  1258.    a mode, accept any mode in class CC_MODE that is reversible */
  1259.  
  1260. int
  1261. reversible_cc_register (x, mode)
  1262.      rtx x;
  1263.      enum machine_mode mode;
  1264. {
  1265.   if (mode == VOIDmode)
  1266.     {
  1267.       mode = GET_MODE (x);
  1268.       if (GET_MODE_CLASS (mode) != MODE_CC
  1269.       && GET_CODE (x) == REG && REGNO (x) == 24)
  1270.     abort ();
  1271.       if (GET_MODE_CLASS (mode) != MODE_CC
  1272.       || (! flag_fast_math && ! REVERSIBLE_CC_MODE (mode)))
  1273.     return FALSE;
  1274.     }
  1275.  
  1276.   if (mode == GET_MODE (x) && GET_CODE (x) == REG && REGNO (x) == 24)
  1277.     return TRUE;
  1278.  
  1279.   return FALSE;
  1280. }
  1281.  
  1282. enum rtx_code
  1283. minmax_code (x)
  1284.      rtx x;
  1285. {
  1286.   enum rtx_code code = GET_CODE (x);
  1287.  
  1288.   if (code == SMAX)
  1289.     return GE;
  1290.   else if (code == SMIN)
  1291.     return LE;
  1292.   else if (code == UMIN)
  1293.     return LEU;
  1294.   else if (code == UMAX)
  1295.     return GEU;
  1296.  
  1297.   abort ();
  1298. }
  1299.  
  1300. /* Return 1 if memory locations are adjacent */
  1301.  
  1302. int
  1303. adjacent_mem_locations (a, b)
  1304.      rtx a, b;
  1305. {
  1306.   int val0 = 0, val1 = 0;
  1307.   int reg0, reg1;
  1308.   
  1309.   if ((GET_CODE (XEXP (a, 0)) == REG
  1310.        || (GET_CODE (XEXP (a, 0)) == PLUS
  1311.        && GET_CODE (XEXP (XEXP (a, 0), 1)) == CONST_INT))
  1312.       && (GET_CODE (XEXP (b, 0)) == REG
  1313.       || (GET_CODE (XEXP (b, 0)) == PLUS
  1314.           && GET_CODE (XEXP (XEXP (b, 0), 1)) == CONST_INT)))
  1315.     {
  1316.       if (GET_CODE (XEXP (a, 0)) == PLUS)
  1317.         {
  1318.       reg0 = REGNO (XEXP (XEXP (a, 0), 0));
  1319.       val0 = INTVAL (XEXP (XEXP (a, 0), 1));
  1320.         }
  1321.       else
  1322.     reg0 = REGNO (XEXP (a, 0));
  1323.       if (GET_CODE (XEXP (b, 0)) == PLUS)
  1324.         {
  1325.       reg1 = REGNO (XEXP (XEXP (b, 0), 0));
  1326.       val1 = INTVAL (XEXP (XEXP (b, 0), 1));
  1327.         }
  1328.       else
  1329.     reg1 = REGNO (XEXP (b, 0));
  1330.       return (reg0 == reg1) && ((val1 - val0) == 4 || (val0 - val1) == 4);
  1331.     }
  1332.   return 0;
  1333. }
  1334.  
  1335. /* Return 1 if OP is a load multiple operation.  It is known to be
  1336.    parallel and the first section will be tested. */
  1337.  
  1338. int
  1339. load_multiple_operation (op, mode)
  1340.      rtx op;
  1341.      enum machine_mode mode;
  1342. {
  1343.   HOST_WIDE_INT count = XVECLEN (op, 0);
  1344.   int dest_regno;
  1345.   rtx src_addr;
  1346.   HOST_WIDE_INT i = 1, base = 0;
  1347.   rtx elt;
  1348.  
  1349.   if (count <= 1
  1350.       || GET_CODE (XVECEXP (op, 0, 0)) != SET)
  1351.     return 0;
  1352.  
  1353.   /* Check to see if this might be a write-back */
  1354.   if (GET_CODE (SET_SRC (elt = XVECEXP (op, 0, 0))) == PLUS)
  1355.     {
  1356.       i++;
  1357.       base = 1;
  1358.  
  1359.       /* Now check it more carefully */
  1360.       if (GET_CODE (SET_DEST (elt)) != REG
  1361.           || GET_CODE (XEXP (SET_SRC (elt), 0)) != REG
  1362.           || REGNO (XEXP (SET_SRC (elt), 0)) != REGNO (SET_DEST (elt))
  1363.           || GET_CODE (XEXP (SET_SRC (elt), 1)) != CONST_INT
  1364.           || INTVAL (XEXP (SET_SRC (elt), 1)) != (count - 2) * 4
  1365.           || GET_CODE (XVECEXP (op, 0, count - 1)) != CLOBBER
  1366.           || GET_CODE (XEXP (XVECEXP (op, 0, count - 1), 0)) != REG
  1367.           || REGNO (XEXP (XVECEXP (op, 0, count - 1), 0))
  1368.               != REGNO (SET_DEST (elt)))
  1369.         return 0;
  1370.  
  1371.       count--;
  1372.     }
  1373.  
  1374.   /* Perform a quick check so we don't blow up below.  */
  1375.   if (count <= i
  1376.       || GET_CODE (XVECEXP (op, 0, i - 1)) != SET
  1377.       || GET_CODE (SET_DEST (XVECEXP (op, 0, i - 1))) != REG
  1378.       || GET_CODE (SET_SRC (XVECEXP (op, 0, i - 1))) != MEM)
  1379.     return 0;
  1380.  
  1381.   dest_regno = REGNO (SET_DEST (XVECEXP (op, 0, i - 1)));
  1382.   src_addr = XEXP (SET_SRC (XVECEXP (op, 0, i - 1)), 0);
  1383.  
  1384.   for (; i < count; i++)
  1385.     {
  1386.       rtx elt = XVECEXP (op, 0, i);
  1387.  
  1388.       if (GET_CODE (elt) != SET
  1389.           || GET_CODE (SET_DEST (elt)) != REG
  1390.           || GET_MODE (SET_DEST (elt)) != SImode
  1391.           || REGNO (SET_DEST (elt)) != dest_regno + i - base
  1392.           || GET_CODE (SET_SRC (elt)) != MEM
  1393.           || GET_MODE (SET_SRC (elt)) != SImode
  1394.           || GET_CODE (XEXP (SET_SRC (elt), 0)) != PLUS
  1395.           || ! rtx_equal_p (XEXP (XEXP (SET_SRC (elt), 0), 0), src_addr)
  1396.           || GET_CODE (XEXP (XEXP (SET_SRC (elt), 0), 1)) != CONST_INT
  1397.           || INTVAL (XEXP (XEXP (SET_SRC (elt), 0), 1)) != (i - base) * 4)
  1398.         return 0;
  1399.     }
  1400.  
  1401.   return 1;
  1402. }
  1403.  
  1404. /* Return 1 if OP is a store multiple operation.  It is known to be
  1405.    parallel and the first section will be tested. */
  1406.  
  1407. int
  1408. store_multiple_operation (op, mode)
  1409.      rtx op;
  1410.      enum machine_mode mode;
  1411. {
  1412.   HOST_WIDE_INT count = XVECLEN (op, 0);
  1413.   int src_regno;
  1414.   rtx dest_addr;
  1415.   HOST_WIDE_INT i = 1, base = 0;
  1416.   rtx elt;
  1417.  
  1418.   if (count <= 1
  1419.       || GET_CODE (XVECEXP (op, 0, 0)) != SET)
  1420.     return 0;
  1421.  
  1422.   /* Check to see if this might be a write-back */
  1423.   if (GET_CODE (SET_SRC (elt = XVECEXP (op, 0, 0))) == PLUS)
  1424.     {
  1425.       i++;
  1426.       base = 1;
  1427.  
  1428.       /* Now check it more carefully */
  1429.       if (GET_CODE (SET_DEST (elt)) != REG
  1430.           || GET_CODE (XEXP (SET_SRC (elt), 0)) != REG
  1431.           || REGNO (XEXP (SET_SRC (elt), 0)) != REGNO (SET_DEST (elt))
  1432.           || GET_CODE (XEXP (SET_SRC (elt), 1)) != CONST_INT
  1433.           || INTVAL (XEXP (SET_SRC (elt), 1)) != (count - 2) * 4
  1434.           || GET_CODE (XVECEXP (op, 0, count - 1)) != CLOBBER
  1435.           || GET_CODE (XEXP (XVECEXP (op, 0, count - 1), 0)) != REG
  1436.           || REGNO (XEXP (XVECEXP (op, 0, count - 1), 0))
  1437.               != REGNO (SET_DEST (elt)))
  1438.         return 0;
  1439.  
  1440.       count--;
  1441.     }
  1442.  
  1443.   /* Perform a quick check so we don't blow up below.  */
  1444.   if (count <= i
  1445.       || GET_CODE (XVECEXP (op, 0, i - 1)) != SET
  1446.       || GET_CODE (SET_DEST (XVECEXP (op, 0, i - 1))) != MEM
  1447.       || GET_CODE (SET_SRC (XVECEXP (op, 0, i - 1))) != REG)
  1448.     return 0;
  1449.  
  1450.   src_regno = REGNO (SET_SRC (XVECEXP (op, 0, i - 1)));
  1451.   dest_addr = XEXP (SET_DEST (XVECEXP (op, 0, i - 1)), 0);
  1452.  
  1453.   for (; i < count; i++)
  1454.     {
  1455.       elt = XVECEXP (op, 0, i);
  1456.  
  1457.       if (GET_CODE (elt) != SET
  1458.           || GET_CODE (SET_SRC (elt)) != REG
  1459.           || GET_MODE (SET_SRC (elt)) != SImode
  1460.           || REGNO (SET_SRC (elt)) != src_regno + i - base
  1461.           || GET_CODE (SET_DEST (elt)) != MEM
  1462.           || GET_MODE (SET_DEST (elt)) != SImode
  1463.           || GET_CODE (XEXP (SET_DEST (elt), 0)) != PLUS
  1464.           || ! rtx_equal_p (XEXP (XEXP (SET_DEST (elt), 0), 0), dest_addr)
  1465.           || GET_CODE (XEXP (XEXP (SET_DEST (elt), 0), 1)) != CONST_INT
  1466.           || INTVAL (XEXP (XEXP (SET_DEST (elt), 0), 1)) != (i - base) * 4)
  1467.         return 0;
  1468.     }
  1469.  
  1470.   return 1;
  1471. }
  1472.  
  1473. int
  1474. multi_register_push (op, mode)
  1475.   rtx op;
  1476.   enum machine_mode mode;
  1477. {
  1478.   if (GET_CODE (op) != PARALLEL
  1479.       || (GET_CODE (XVECEXP (op, 0, 0)) != SET)
  1480.       || (GET_CODE (SET_SRC (XVECEXP (op, 0, 0))) != UNSPEC)
  1481.       || (XINT (SET_SRC (XVECEXP (op, 0, 0)), 1) != 2))
  1482.     return 0;
  1483.  
  1484.   return 1;
  1485. }
  1486.  
  1487.  
  1488. /* Routines for use with attributes */
  1489.  
  1490. int
  1491. const_pool_offset (symbol)
  1492.      rtx symbol;
  1493. {
  1494.   return get_pool_offset (symbol) - get_pool_size () - get_prologue_size ();
  1495. }
  1496.  
  1497. /* Routines for use in generating RTL */
  1498.  
  1499. rtx
  1500. arm_gen_load_multiple (base_regno, count, from, up, write_back)
  1501.      int base_regno;
  1502.      int count;
  1503.      rtx from;
  1504.      int up;
  1505.      int write_back;
  1506. {
  1507.   int i = 0, j;
  1508.   rtx result;
  1509.   int sign = up ? 1 : -1;
  1510.  
  1511.   result = gen_rtx (PARALLEL, VOIDmode,
  1512.                     rtvec_alloc (count + (write_back ? 2 : 0)));
  1513.   if (write_back)
  1514.     {
  1515.       XVECEXP (result, 0, 0)
  1516.     = gen_rtx (SET, GET_MODE (from), from,
  1517.            plus_constant (from, count * 4 * sign));
  1518.       i = 1;
  1519.       count++;
  1520.     }
  1521.  
  1522.   for (j = 0; i < count; i++, j++)
  1523.     {
  1524.       XVECEXP (result, 0, i)
  1525.     = gen_rtx (SET, VOIDmode, gen_rtx (REG, SImode, base_regno + j),
  1526.            gen_rtx (MEM, SImode,
  1527.                 plus_constant (from, j * 4 * sign)));
  1528.     }
  1529.  
  1530.   if (write_back)
  1531.     XVECEXP (result, 0, i) = gen_rtx (CLOBBER, SImode, from);
  1532.  
  1533.   return result;
  1534. }
  1535.  
  1536. rtx
  1537. arm_gen_store_multiple (base_regno, count, to, up, write_back)
  1538.      int base_regno;
  1539.      int count;
  1540.      rtx to;
  1541.      int up;
  1542.      int write_back;
  1543. {
  1544.   int i = 0, j;
  1545.   rtx result;
  1546.   int sign = up ? 1 : -1;
  1547.  
  1548.   result = gen_rtx (PARALLEL, VOIDmode,
  1549.                     rtvec_alloc (count + (write_back ? 2 : 0)));
  1550.   if (write_back)
  1551.     {
  1552.       XVECEXP (result, 0, 0)
  1553.     = gen_rtx (SET, GET_MODE (to), to,
  1554.            plus_constant (to, count * 4 * sign));
  1555.       i = 1;
  1556.       count++;
  1557.     }
  1558.  
  1559.   for (j = 0; i < count; i++, j++)
  1560.     {
  1561.       XVECEXP (result, 0, i)
  1562.     = gen_rtx (SET, VOIDmode,
  1563.            gen_rtx (MEM, SImode, plus_constant (to, j * 4 * sign)),
  1564.            gen_rtx (REG, SImode, base_regno + j));
  1565.     }
  1566.  
  1567.   if (write_back)
  1568.     XVECEXP (result, 0, i) = gen_rtx (CLOBBER, SImode, to);
  1569.  
  1570.   return result;
  1571. }
  1572.  
  1573. int
  1574. arm_gen_movstrqi (operands)
  1575.      rtx *operands;
  1576. {
  1577.   HOST_WIDE_INT in_words_to_go, out_words_to_go, last_bytes;
  1578.   int i, r;
  1579.   rtx const_sxteen = gen_rtx (CONST_INT, SImode, 16);
  1580.   rtx src, dst;
  1581.   rtx st_src, st_dst, end_src, end_dst, fin_src, fin_dst;
  1582.   rtx part_bytes_reg = NULL;
  1583.   extern int optimize;
  1584.  
  1585.   if (GET_CODE (operands[2]) != CONST_INT
  1586.       || GET_CODE (operands[3]) != CONST_INT
  1587.       || INTVAL (operands[2]) > 64
  1588.       || INTVAL (operands[3]) & 3)
  1589.     return 0;
  1590.  
  1591.   st_dst = XEXP (operands[0], 0);
  1592.   st_src = XEXP (operands[1], 0);
  1593.   fin_dst = dst = copy_to_mode_reg (SImode, st_dst);
  1594.   fin_src = src = copy_to_mode_reg (SImode, st_src);
  1595.  
  1596.   in_words_to_go = (INTVAL (operands[2]) + 3) / 4;
  1597.   out_words_to_go = INTVAL (operands[2]) / 4;
  1598.   last_bytes = INTVAL (operands[2]) & 3;
  1599.  
  1600.   if (out_words_to_go != in_words_to_go && ((in_words_to_go - 1) & 3) != 0)
  1601.     part_bytes_reg = gen_rtx (REG, SImode, (in_words_to_go - 1) & 3);
  1602.  
  1603.   for (i = 0; in_words_to_go >= 2; i+=4)
  1604.     {
  1605.       emit_insn (arm_gen_load_multiple (0, (in_words_to_go > 4 
  1606.                         ? 4 : in_words_to_go),
  1607.                                         src, TRUE, TRUE));
  1608.       if (out_words_to_go)
  1609.     {
  1610.       if (out_words_to_go != 1)
  1611.         emit_insn (arm_gen_store_multiple (0, (out_words_to_go > 4
  1612.                            ? 4 : out_words_to_go),
  1613.                            dst, TRUE, TRUE));
  1614.       else
  1615.         {
  1616.           emit_move_insn (gen_rtx (MEM, SImode, dst),
  1617.                   gen_rtx (REG, SImode, 0));
  1618.           emit_insn (gen_addsi3 (dst, dst, GEN_INT (4)));
  1619.         }
  1620.     }
  1621.  
  1622.       in_words_to_go -= in_words_to_go < 4 ? in_words_to_go : 4;
  1623.       out_words_to_go -= out_words_to_go < 4 ? out_words_to_go : 4;
  1624.     }
  1625.  
  1626.   /* OUT_WORDS_TO_GO will be zero here if there are byte stores to do.  */
  1627.   if (out_words_to_go)
  1628.   {
  1629.     rtx sreg;
  1630.  
  1631.     emit_move_insn (sreg = gen_reg_rtx (SImode), gen_rtx (MEM, SImode, src));
  1632.     emit_move_insn (fin_src = gen_reg_rtx (SImode), plus_constant (src, 4));
  1633.     emit_move_insn (gen_rtx (MEM, SImode, dst), sreg);
  1634.     emit_move_insn (fin_dst = gen_reg_rtx (SImode), plus_constant (dst, 4));
  1635.     in_words_to_go--;
  1636.  
  1637.     if (in_words_to_go)    /* Sanity check */
  1638.       abort ();
  1639.   }
  1640.  
  1641.   if (in_words_to_go)
  1642.     {
  1643.       if (in_words_to_go < 0)
  1644.     abort ();
  1645.  
  1646.       part_bytes_reg = copy_to_mode_reg (SImode, gen_rtx (MEM, SImode, src));
  1647.       emit_insn (gen_addsi3 (src, src, GEN_INT (4)));
  1648.     }
  1649.  
  1650.   if (BYTES_BIG_ENDIAN && last_bytes)
  1651.     {
  1652.       rtx tmp = gen_reg_rtx (SImode);
  1653.  
  1654.       if (part_bytes_reg == NULL)
  1655.     abort ();
  1656.  
  1657.       /* The bytes we want are in the top end of the word */
  1658.       emit_insn (gen_lshrsi3 (tmp, part_bytes_reg,
  1659.                   GEN_INT (8 * (4 - last_bytes))));
  1660.       part_bytes_reg = tmp;
  1661.       
  1662.       while (last_bytes)
  1663.     {
  1664.       emit_move_insn (gen_rtx (MEM, QImode, 
  1665.                    plus_constant (dst, last_bytes - 1)),
  1666.               gen_rtx (SUBREG, QImode, part_bytes_reg, 0));
  1667.       if (--last_bytes)
  1668.         {
  1669.           tmp = gen_reg_rtx (SImode);
  1670.           emit_insn (gen_lshrsi3 (tmp, part_bytes_reg, GEN_INT (8)));
  1671.           part_bytes_reg = tmp;
  1672.         }
  1673.     }
  1674.       
  1675.     }
  1676.   else
  1677.     {
  1678.       while (last_bytes)
  1679.     {
  1680.       if (part_bytes_reg == NULL)
  1681.         abort ();
  1682.  
  1683.       emit_move_insn (gen_rtx (MEM, QImode, dst),
  1684.               gen_rtx (SUBREG, QImode, part_bytes_reg, 0));
  1685.       emit_insn (gen_addsi3 (dst, dst, const1_rtx));
  1686.       if (--last_bytes)
  1687.         {
  1688.           rtx tmp = gen_reg_rtx (SImode);
  1689.           emit_insn (gen_lshrsi3 (tmp, part_bytes_reg, GEN_INT (8)));
  1690.           part_bytes_reg = tmp;
  1691.         }
  1692.     }
  1693.     }
  1694.  
  1695.   return 1;
  1696. }
  1697.  
  1698. /* X and Y are two things to compare using CODE.  Emit the compare insn and
  1699.    return the rtx for register 0 in the proper mode.  FP means this is a
  1700.    floating point compare: I don't think that it is needed on the arm.  */
  1701.  
  1702. rtx
  1703. gen_compare_reg (code, x, y, fp)
  1704.      enum rtx_code code;
  1705.      rtx x, y;
  1706. {
  1707.   enum machine_mode mode = SELECT_CC_MODE (code, x, y);
  1708.   rtx cc_reg = gen_rtx (REG, mode, 24);
  1709.  
  1710.   emit_insn (gen_rtx (SET, VOIDmode, cc_reg,
  1711.                       gen_rtx (COMPARE, mode, x, y)));
  1712.  
  1713.   return cc_reg;
  1714. }
  1715.  
  1716. void
  1717. arm_reload_out_hi (operands)
  1718.      rtx *operands;
  1719. {
  1720.   rtx base = find_replacement (&XEXP (operands[0], 0));
  1721.  
  1722.   if (BYTES_BIG_ENDIAN)
  1723.     {
  1724.       emit_insn (gen_movqi (gen_rtx (MEM, QImode, plus_constant (base, 1)),
  1725.                 gen_rtx (SUBREG, QImode, operands[1], 0)));
  1726.       emit_insn (gen_lshrsi3 (operands[2],
  1727.                   gen_rtx (SUBREG, SImode, operands[1], 0),
  1728.                   GEN_INT (8)));
  1729.       emit_insn (gen_movqi (gen_rtx (MEM, QImode, base),
  1730.                 gen_rtx (SUBREG, QImode, operands[2], 0)));
  1731.     }
  1732.   else
  1733.     {
  1734.       emit_insn (gen_movqi (gen_rtx (MEM, QImode, base),
  1735.                 gen_rtx (SUBREG, QImode, operands[1], 0)));
  1736.       emit_insn (gen_lshrsi3 (operands[2],
  1737.                   gen_rtx (SUBREG, SImode, operands[1], 0),
  1738.                   GEN_INT (8)));
  1739.       emit_insn (gen_movqi (gen_rtx (MEM, QImode, plus_constant (base, 1)),
  1740.                 gen_rtx (SUBREG, QImode, operands[2], 0)));
  1741.     }
  1742. }
  1743.  
  1744. /* Check to see if a branch is forwards or backwards.  Return TRUE if it
  1745.    is backwards.  */
  1746.  
  1747. int
  1748. arm_backwards_branch (from, to)
  1749.      int from, to;
  1750. {
  1751.   return insn_addresses[to] <= insn_addresses[from];
  1752. }
  1753.  
  1754. /* Check to see if a branch is within the distance that can be done using
  1755.    an arithmetic expression. */
  1756. int
  1757. short_branch (from, to)
  1758.      int from, to;
  1759. {
  1760.   int delta = insn_addresses[from] + 8 - insn_addresses[to];
  1761.  
  1762.   return abs (delta) < 980;    /* A small margin for safety */
  1763. }
  1764.  
  1765. /* Check to see that the insn isn't the target of the conditionalizing
  1766.    code */
  1767. int
  1768. arm_insn_not_targeted (insn)
  1769.      rtx insn;
  1770. {
  1771.   return insn != arm_target_insn;
  1772. }
  1773.  
  1774.  
  1775. /* Routines to output assembly language.  */
  1776.  
  1777. /* If the rtx is the correct value then return the string of the number.
  1778.    In this way we can ensure that valid double constants are generated even
  1779.    when cross compiling. */
  1780. char *
  1781. fp_immediate_constant (x)
  1782.      rtx x;
  1783. {
  1784.   REAL_VALUE_TYPE r;
  1785.   int i;
  1786.   
  1787.   if (!fpa_consts_inited)
  1788.     init_fpa_table ();
  1789.   
  1790.   REAL_VALUE_FROM_CONST_DOUBLE (r, x);
  1791.   for (i = 0; i < 8; i++)
  1792.     if (REAL_VALUES_EQUAL (r, values_fpa[i]))
  1793.       return strings_fpa[i];
  1794.  
  1795.   abort ();
  1796. }
  1797.  
  1798. /* As for fp_immediate_constant, but value is passed directly, not in rtx.  */
  1799. static char *
  1800. fp_const_from_val (r)
  1801.      REAL_VALUE_TYPE *r;
  1802. {
  1803.   int i;
  1804.  
  1805.   if (! fpa_consts_inited)
  1806.     init_fpa_table ();
  1807.  
  1808.   for (i = 0; i < 8; i++)
  1809.     if (REAL_VALUES_EQUAL (*r, values_fpa[i]))
  1810.       return strings_fpa[i];
  1811.  
  1812.   abort ();
  1813. }
  1814.  
  1815. /* Output the operands of a LDM/STM instruction to STREAM.
  1816.    MASK is the ARM register set mask of which only bits 0-15 are important.
  1817.    INSTR is the possibly suffixed base register.  HAT unequals zero if a hat
  1818.    must follow the register list.  */
  1819.  
  1820. void
  1821. print_multi_reg (stream, instr, mask, hat)
  1822.      FILE *stream;
  1823.      char *instr;
  1824.      int mask, hat;
  1825. {
  1826.   int i;
  1827.   int not_first = FALSE;
  1828.  
  1829.   fputc ('\t', stream);
  1830.   fprintf (stream, instr, ARM_REG_PREFIX);
  1831.   fputs (", {", stream);
  1832.   for (i = 0; i < 16; i++)
  1833.     if (mask & (1 << i))
  1834.       {
  1835.     if (not_first)
  1836.       fprintf (stream, ", ");
  1837.     fprintf (stream, "%s%s", ARM_REG_PREFIX, reg_names[i]);
  1838.     not_first = TRUE;
  1839.       }
  1840.  
  1841.   fprintf (stream, "}%s\n", hat ? "^" : "");
  1842. }
  1843.  
  1844. /* Output a 'call' insn. */
  1845.  
  1846. char *
  1847. output_call (operands)
  1848.      rtx *operands;
  1849. {
  1850.   /* Handle calls to lr using ip (which may be clobbered in subr anyway). */
  1851.  
  1852.   if (REGNO (operands[0]) == 14)
  1853.     {
  1854.       operands[0] = gen_rtx (REG, SImode, 12);
  1855.       output_asm_insn ("mov%?\t%0, %|lr", operands);
  1856.     }
  1857.   output_asm_insn ("mov%?\t%|lr, %|pc", operands);
  1858.   output_asm_insn ("mov%?\t%|pc, %0", operands);
  1859.   return "";
  1860. }
  1861.  
  1862. static int
  1863. eliminate_lr2ip (x)
  1864.      rtx *x;
  1865. {
  1866.   int something_changed = 0;
  1867.   rtx x0 = *x;
  1868.   int code = GET_CODE (x0);
  1869.   register int i, j;
  1870.   register char *fmt;
  1871.   
  1872.   switch (code)
  1873.     {
  1874.     case REG:
  1875.       if (REGNO (x0) == 14)
  1876.         {
  1877.       *x = gen_rtx (REG, SImode, 12);
  1878.       return 1;
  1879.         }
  1880.       return 0;
  1881.     default:
  1882.       /* Scan through the sub-elements and change any references there */
  1883.       fmt = GET_RTX_FORMAT (code);
  1884.       for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
  1885.     if (fmt[i] == 'e')
  1886.       something_changed |= eliminate_lr2ip (&XEXP (x0, i));
  1887.     else if (fmt[i] == 'E')
  1888.       for (j = 0; j < XVECLEN (x0, i); j++)
  1889.         something_changed |= eliminate_lr2ip (&XVECEXP (x0, i, j));
  1890.       return something_changed;
  1891.     }
  1892. }
  1893.   
  1894. /* Output a 'call' insn that is a reference in memory. */
  1895.  
  1896. char *
  1897. output_call_mem (operands)
  1898.      rtx *operands;
  1899. {
  1900.   operands[0] = copy_rtx (operands[0]); /* Be ultra careful */
  1901.   /* Handle calls using lr by using ip (which may be clobbered in subr anyway).
  1902.    */
  1903.   if (eliminate_lr2ip (&operands[0]))
  1904.     output_asm_insn ("mov%?\t%|ip, %|lr", operands);
  1905.  
  1906.   output_asm_insn ("mov%?\t%|lr, %|pc", operands);
  1907.   output_asm_insn ("ldr%?\t%|pc, %0", operands);
  1908.   return "";
  1909. }
  1910.  
  1911.  
  1912. /* Output a move from arm registers to an fpu registers.
  1913.    OPERANDS[0] is an fpu register.
  1914.    OPERANDS[1] is the first registers of an arm register pair.  */
  1915.  
  1916. char *
  1917. output_mov_long_double_fpu_from_arm (operands)
  1918.      rtx *operands;
  1919. {
  1920.   int arm_reg0 = REGNO (operands[1]);
  1921.   rtx ops[3];
  1922.  
  1923.   if (arm_reg0 == 12)
  1924.     abort();
  1925.  
  1926.   ops[0] = gen_rtx (REG, SImode, arm_reg0);
  1927.   ops[1] = gen_rtx (REG, SImode, 1 + arm_reg0);
  1928.   ops[2] = gen_rtx (REG, SImode, 2 + arm_reg0);
  1929.   
  1930.   output_asm_insn ("stm%?fd\t%|sp!, {%0, %1, %2}", ops);
  1931.   output_asm_insn ("ldf%?e\t%0, [%|sp], #12", operands);
  1932.   return "";
  1933. }
  1934.  
  1935. /* Output a move from an fpu register to arm registers.
  1936.    OPERANDS[0] is the first registers of an arm register pair.
  1937.    OPERANDS[1] is an fpu register.  */
  1938.  
  1939. char *
  1940. output_mov_long_double_arm_from_fpu (operands)
  1941.      rtx *operands;
  1942. {
  1943.   int arm_reg0 = REGNO (operands[0]);
  1944.   rtx ops[3];
  1945.  
  1946.   if (arm_reg0 == 12)
  1947.     abort();
  1948.  
  1949.   ops[0] = gen_rtx (REG, SImode, arm_reg0);
  1950.   ops[1] = gen_rtx (REG, SImode, 1 + arm_reg0);
  1951.   ops[2] = gen_rtx (REG, SImode, 2 + arm_reg0);
  1952.  
  1953.   output_asm_insn ("stf%?e\t%1, [%|sp, #-12]!", operands);
  1954.   output_asm_insn ("ldm%?fd\t%|sp!, {%0, %1, %2}", ops);
  1955.   return "";
  1956. }
  1957.  
  1958. /* Output a move from arm registers to arm registers of a long double
  1959.    OPERANDS[0] is the destination.
  1960.    OPERANDS[1] is the source.  */
  1961. char *
  1962. output_mov_long_double_arm_from_arm (operands)
  1963.      rtx *operands;
  1964. {
  1965.   /* We have to be careful here because the two might overlap */
  1966.   int dest_start = REGNO (operands[0]);
  1967.   int src_start = REGNO (operands[1]);
  1968.   rtx ops[2];
  1969.   int i;
  1970.  
  1971.   if (dest_start < src_start)
  1972.     {
  1973.       for (i = 0; i < 3; i++)
  1974.     {
  1975.       ops[0] = gen_rtx (REG, SImode, dest_start + i);
  1976.       ops[1] = gen_rtx (REG, SImode, src_start + i);
  1977.       output_asm_insn ("mov%?\t%0, %1", ops);
  1978.     }
  1979.     }
  1980.   else
  1981.     {
  1982.       for (i = 2; i >= 0; i--)
  1983.     {
  1984.       ops[0] = gen_rtx (REG, SImode, dest_start + i);
  1985.       ops[1] = gen_rtx (REG, SImode, src_start + i);
  1986.       output_asm_insn ("mov%?\t%0, %1", ops);
  1987.     }
  1988.     }
  1989.  
  1990.   return "";
  1991. }
  1992.  
  1993.  
  1994. /* Output a move from arm registers to an fpu registers.
  1995.    OPERANDS[0] is an fpu register.
  1996.    OPERANDS[1] is the first registers of an arm register pair.  */
  1997.  
  1998. char *
  1999. output_mov_double_fpu_from_arm (operands)
  2000.      rtx *operands;
  2001. {
  2002.   int arm_reg0 = REGNO (operands[1]);
  2003.   rtx ops[2];
  2004.  
  2005.   if (arm_reg0 == 12)
  2006.     abort();
  2007.   ops[0] = gen_rtx (REG, SImode, arm_reg0);
  2008.   ops[1] = gen_rtx (REG, SImode, 1 + arm_reg0);
  2009.   output_asm_insn ("stm%?fd\t%|sp!, {%0, %1}", ops);
  2010.   output_asm_insn ("ldf%?d\t%0, [%|sp], #8", operands);
  2011.   return "";
  2012. }
  2013.  
  2014. /* Output a move from an fpu register to arm registers.
  2015.    OPERANDS[0] is the first registers of an arm register pair.
  2016.    OPERANDS[1] is an fpu register.  */
  2017.  
  2018. char *
  2019. output_mov_double_arm_from_fpu (operands)
  2020.      rtx *operands;
  2021. {
  2022.   int arm_reg0 = REGNO (operands[0]);
  2023.   rtx ops[2];
  2024.  
  2025.   if (arm_reg0 == 12)
  2026.     abort();
  2027.  
  2028.   ops[0] = gen_rtx (REG, SImode, arm_reg0);
  2029.   ops[1] = gen_rtx (REG, SImode, 1 + arm_reg0);
  2030.   output_asm_insn ("stf%?d\t%1, [%|sp, #-8]!", operands);
  2031.   output_asm_insn ("ldm%?fd\t%|sp!, {%0, %1}", ops);
  2032.   return "";
  2033. }
  2034.  
  2035. /* Output a move between double words.
  2036.    It must be REG<-REG, REG<-CONST_DOUBLE, REG<-CONST_INT, REG<-MEM
  2037.    or MEM<-REG and all MEMs must be offsettable addresses.  */
  2038.  
  2039. char *
  2040. output_move_double (operands)
  2041.      rtx *operands;
  2042. {
  2043.   enum rtx_code code0 = GET_CODE (operands[0]);
  2044.   enum rtx_code code1 = GET_CODE (operands[1]);
  2045.   rtx otherops[2];
  2046.  
  2047.   if (code0 == REG)
  2048.     {
  2049.       int reg0 = REGNO (operands[0]);
  2050.  
  2051.       otherops[0] = gen_rtx (REG, SImode, 1 + reg0);
  2052.       if (code1 == REG)
  2053.     {
  2054.       int reg1 = REGNO (operands[1]);
  2055.       if (reg1 == 12)
  2056.         abort();
  2057.  
  2058.       otherops[1] = gen_rtx (REG, SImode, 1 + reg1);
  2059.  
  2060.       /* Ensure the second source is not overwritten */
  2061.       if (reg0 == 1 + reg1)
  2062.         {
  2063.           output_asm_insn("mov%?\t%0, %1", otherops);
  2064.           output_asm_insn("mov%?\t%0, %1", operands);
  2065.         }
  2066.       else
  2067.         {
  2068.           output_asm_insn("mov%?\t%0, %1", operands);
  2069.           output_asm_insn("mov%?\t%0, %1", otherops);
  2070.         }
  2071.     }
  2072.       else if (code1 == CONST_DOUBLE)
  2073.     {
  2074.       otherops[1] = gen_rtx (CONST_INT, VOIDmode,
  2075.                  CONST_DOUBLE_HIGH (operands[1]));
  2076.       operands[1] = gen_rtx (CONST_INT, VOIDmode,
  2077.                  CONST_DOUBLE_LOW (operands[1]));
  2078.       output_mov_immediate (operands, FALSE, "");
  2079.       output_mov_immediate (otherops, FALSE, "");
  2080.     }
  2081.       else if (code1 == CONST_INT)
  2082.     {
  2083.       otherops[1] = const0_rtx;
  2084.       /* sign extend the intval into the high-order word */
  2085.       /* Note: output_mov_immediate may clobber operands[1], so we
  2086.          put this out first */
  2087.       if (INTVAL (operands[1]) < 0)
  2088.         output_asm_insn ("mvn%?\t%0, %1", otherops);
  2089.       else
  2090.         output_asm_insn ("mov%?\t%0, %1", otherops);
  2091.       output_mov_immediate (operands, FALSE, "");
  2092.     }
  2093.       else if (code1 == MEM)
  2094.     {
  2095.       switch (GET_CODE (XEXP (operands[1], 0)))
  2096.         {
  2097.         case REG:
  2098.           /* Handle the simple case where address is [r, #0] more
  2099.          efficient.  */
  2100.           output_asm_insn ("ldm%?ia\t%m1, %M0", operands);
  2101.           break;
  2102.           case PRE_INC:
  2103.           output_asm_insn ("add%?\t%m1, %m1, #8", operands);
  2104.           output_asm_insn ("ldm%?ia\t%m1, %M0", operands);
  2105.           break;
  2106.         case PRE_DEC:
  2107.           output_asm_insn ("sub%?\t%m1, %m1, #8", operands);
  2108.           output_asm_insn ("ldm%?ia\t%m1, %M0", operands);
  2109.           break;
  2110.         case POST_INC:
  2111.           output_asm_insn ("ldm%?ia\t%m1!, %M0", operands);
  2112.           break;
  2113.         case POST_DEC:
  2114.           output_asm_insn ("ldm%?ia\t%m1, %M0", operands);
  2115.           output_asm_insn ("sub%?\t%m1, %m1, #8", operands);
  2116.           break;
  2117.         default:
  2118.           otherops[1] = adj_offsettable_operand (operands[1], 4);
  2119.           /* Take care of overlapping base/data reg.  */
  2120.           if (reg_mentioned_p (operands[0], operands[1]))
  2121.         {
  2122.           output_asm_insn ("ldr%?\t%0, %1", otherops);
  2123.           output_asm_insn ("ldr%?\t%0, %1", operands);
  2124.         }
  2125.           else
  2126.         {
  2127.           output_asm_insn ("ldr%?\t%0, %1", operands);
  2128.           output_asm_insn ("ldr%?\t%0, %1", otherops);
  2129.         }
  2130.         }
  2131.     }
  2132.       else abort();  /* Constraints should prevent this */
  2133.     }
  2134.   else if (code0 == MEM && code1 == REG)
  2135.     {
  2136.       if (REGNO (operands[1]) == 12)
  2137.     abort();
  2138.       switch (GET_CODE (XEXP (operands[0], 0)))
  2139.         {
  2140.     case REG:
  2141.       output_asm_insn ("stm%?ia\t%m0, %M1", operands);
  2142.       break;
  2143.         case PRE_INC:
  2144.       output_asm_insn ("add%?\t%m0, %m0, #8", operands);
  2145.       output_asm_insn ("stm%?ia\t%m0, %M1", operands);
  2146.       break;
  2147.         case PRE_DEC:
  2148.       output_asm_insn ("sub%?\t%m0, %m0, #8", operands);
  2149.       output_asm_insn ("stm%?ia\t%m0, %M1", operands);
  2150.       break;
  2151.         case POST_INC:
  2152.       output_asm_insn ("stm%?ia\t%m0!, %M1", operands);
  2153.       break;
  2154.         case POST_DEC:
  2155.       output_asm_insn ("stm%?ia\t%m0, %M1", operands);
  2156.       output_asm_insn ("sub%?\t%m0, %m0, #8", operands);
  2157.       break;
  2158.         default:
  2159.       otherops[0] = adj_offsettable_operand (operands[0], 4);
  2160.       otherops[1] = gen_rtx (REG, SImode, 1 + REGNO (operands[1]));
  2161.       output_asm_insn ("str%?\t%1, %0", operands);
  2162.       output_asm_insn ("str%?\t%1, %0", otherops);
  2163.     }
  2164.     }
  2165.   else abort();  /* Constraints should prevent this */
  2166.  
  2167.   return "";
  2168. }
  2169.  
  2170.  
  2171. /* Output an arbitrary MOV reg, #n.
  2172.    OPERANDS[0] is a register.  OPERANDS[1] is a const_int.  */
  2173.  
  2174. char *
  2175. output_mov_immediate (operands)
  2176.      rtx *operands;
  2177. {
  2178.   HOST_WIDE_INT n = INTVAL (operands[1]);
  2179.   int n_ones = 0;
  2180.   int i;
  2181.  
  2182.   /* Try to use one MOV */
  2183.   if (const_ok_for_arm (n))
  2184.     {
  2185.       output_asm_insn ("mov%?\t%0, %1", operands);
  2186.       return "";
  2187.     }
  2188.  
  2189.   /* Try to use one MVN */
  2190.   if (const_ok_for_arm (~n))
  2191.     {
  2192.       operands[1] = GEN_INT (~n);
  2193.       output_asm_insn ("mvn%?\t%0, %1", operands);
  2194.       return "";
  2195.     }
  2196.  
  2197.   /* If all else fails, make it out of ORRs or BICs as appropriate. */
  2198.  
  2199.   for (i=0; i < 32; i++)
  2200.     if (n & 1 << i)
  2201.       n_ones++;
  2202.  
  2203.   if (n_ones > 16)  /* Shorter to use MVN with BIC in this case. */
  2204.     output_multi_immediate(operands, "mvn%?\t%0, %1", "bic%?\t%0, %0, %1", 1,
  2205.                ~n);
  2206.   else
  2207.     output_multi_immediate(operands, "mov%?\t%0, %1", "orr%?\t%0, %0, %1", 1,
  2208.                n);
  2209.  
  2210.   return "";
  2211. }
  2212.  
  2213.  
  2214. /* Output an ADD r, s, #n where n may be too big for one instruction.  If
  2215.    adding zero to one register, output nothing.  */
  2216.  
  2217. char *
  2218. output_add_immediate (operands)
  2219.      rtx *operands;
  2220. {
  2221.   HOST_WIDE_INT n = INTVAL (operands[2]);
  2222.  
  2223.   if (n != 0 || REGNO (operands[0]) != REGNO (operands[1]))
  2224.     {
  2225.       if (n < 0)
  2226.     output_multi_immediate (operands,
  2227.                 "sub%?\t%0, %1, %2", "sub%?\t%0, %0, %2", 2,
  2228.                 -n);
  2229.       else
  2230.     output_multi_immediate (operands,
  2231.                 "add%?\t%0, %1, %2", "add%?\t%0, %0, %2", 2,
  2232.                 n);
  2233.     }
  2234.  
  2235.   return "";
  2236. }
  2237.  
  2238. /* Output a multiple immediate operation.
  2239.    OPERANDS is the vector of operands referred to in the output patterns.
  2240.    INSTR1 is the output pattern to use for the first constant.
  2241.    INSTR2 is the output pattern to use for subsequent constants.
  2242.    IMMED_OP is the index of the constant slot in OPERANDS.
  2243.    N is the constant value.  */
  2244.  
  2245. char *
  2246. output_multi_immediate (operands, instr1, instr2, immed_op, n)
  2247.      rtx *operands;
  2248.      char *instr1, *instr2;
  2249.      int immed_op;
  2250.      HOST_WIDE_INT n;
  2251. {
  2252. #if HOST_BITS_PER_WIDE_INT > 32
  2253.   n &= 0xffffffff;
  2254. #endif
  2255.  
  2256.   if (n == 0)
  2257.     {
  2258.       operands[immed_op] = const0_rtx;
  2259.       output_asm_insn (instr1, operands); /* Quick and easy output */
  2260.     }
  2261.   else
  2262.     {
  2263.       int i;
  2264.       char *instr = instr1;
  2265.  
  2266.       /* Note that n is never zero here (which would give no output) */
  2267.       for (i = 0; i < 32; i += 2)
  2268.     {
  2269.       if (n & (3 << i))
  2270.         {
  2271.           operands[immed_op] = GEN_INT (n & (255 << i));
  2272.           output_asm_insn (instr, operands);
  2273.           instr = instr2;
  2274.           i += 6;
  2275.         }
  2276.     }
  2277.     }
  2278.   return "";
  2279. }
  2280.  
  2281.  
  2282. /* Return the appropriate ARM instruction for the operation code.
  2283.    The returned result should not be overwritten.  OP is the rtx of the
  2284.    operation.  SHIFT_FIRST_ARG is TRUE if the first argument of the operator
  2285.    was shifted.  */
  2286.  
  2287. char *
  2288. arithmetic_instr (op, shift_first_arg)
  2289.      rtx op;
  2290.      int shift_first_arg;
  2291. {
  2292.   switch (GET_CODE (op))
  2293.     {
  2294.     case PLUS:
  2295.       return "add";
  2296.  
  2297.     case MINUS:
  2298.       return shift_first_arg ? "rsb" : "sub";
  2299.  
  2300.     case IOR:
  2301.       return "orr";
  2302.  
  2303.     case XOR:
  2304.       return "eor";
  2305.  
  2306.     case AND:
  2307.       return "and";
  2308.  
  2309.     default:
  2310.       abort ();
  2311.     }
  2312. }
  2313.  
  2314.  
  2315. /* Ensure valid constant shifts and return the appropriate shift mnemonic
  2316.    for the operation code.  The returned result should not be overwritten.
  2317.    OP is the rtx code of the shift.
  2318.    On exit, *AMOUNTP will be -1 if the shift is by a register, or a constant
  2319.    shift. */
  2320.  
  2321. static char *
  2322. shift_op (op, amountp)
  2323.      rtx op;
  2324.      HOST_WIDE_INT *amountp;
  2325. {
  2326.   char *mnem;
  2327.   enum rtx_code code = GET_CODE (op);
  2328.  
  2329.   if (GET_CODE (XEXP (op, 1)) == REG || GET_CODE (XEXP (op, 1)) == SUBREG)
  2330.     *amountp = -1;
  2331.   else if (GET_CODE (XEXP (op, 1)) == CONST_INT)
  2332.     *amountp = INTVAL (XEXP (op, 1));
  2333.   else
  2334.     abort ();
  2335.  
  2336.   switch (code)
  2337.     {
  2338.     case ASHIFT:
  2339.       mnem = "asl";
  2340.       break;
  2341.  
  2342.     case ASHIFTRT:
  2343.       mnem = "asr";
  2344.       break;
  2345.  
  2346.     case LSHIFTRT:
  2347.       mnem = "lsr";
  2348.       break;
  2349.  
  2350.     case ROTATERT:
  2351.       mnem = "ror";
  2352.       break;
  2353.  
  2354.     case MULT:
  2355.       /* We never have to worry about the amount being other than a
  2356.      power of 2, since this case can never be reloaded from a reg.  */
  2357.       if (*amountp != -1)
  2358.     *amountp = int_log2 (*amountp);
  2359.       else
  2360.     abort ();
  2361.       return "asl";
  2362.  
  2363.     default:
  2364.       abort ();
  2365.     }
  2366.  
  2367.   if (*amountp != -1)
  2368.     {
  2369.       /* This is not 100% correct, but follows from the desire to merge
  2370.      multiplication by a power of 2 with the recognizer for a
  2371.      shift.  >=32 is not a valid shift for "asl", so we must try and
  2372.      output a shift that produces the correct arithmetical result.
  2373.      Using lsr #32 is idendical except for the fact that the carry bit
  2374.      is not set correctly if we set the flags; but we never use the 
  2375.      carry bit from such an operation, so we can ignore that.  */
  2376.       if (code == ROTATERT)
  2377.     *amountp &= 31;        /* Rotate is just modulo 32 */
  2378.       else if (*amountp != (*amountp & 31))
  2379.     {
  2380.       if (code == ASHIFT)
  2381.         mnem = "lsr";
  2382.       *amountp = 32;
  2383.     }
  2384.  
  2385.       /* Shifts of 0 are no-ops.  */
  2386.       if (*amountp == 0)
  2387.     return NULL;
  2388.     }      
  2389.  
  2390.   return mnem;
  2391. }
  2392.  
  2393.  
  2394. /* Obtain the shift from the POWER of two. */
  2395.  
  2396. HOST_WIDE_INT
  2397. int_log2 (power)
  2398.      HOST_WIDE_INT power;
  2399. {
  2400.   HOST_WIDE_INT shift = 0;
  2401.  
  2402.   while (((1 << shift) & power) == 0)
  2403.     {
  2404.       if (shift > 31)
  2405.     abort ();
  2406.       shift++;
  2407.     }
  2408.  
  2409.   return shift;
  2410. }
  2411.  
  2412. /* Output a .ascii pseudo-op, keeping track of lengths.  This is because
  2413.    /bin/as is horribly restrictive.  */
  2414.  
  2415. void
  2416. output_ascii_pseudo_op (stream, p, len)
  2417.      FILE *stream;
  2418.      unsigned char *p;
  2419.      int len;
  2420. {
  2421.   int i;
  2422.   int len_so_far = 1000;
  2423.   int chars_so_far = 0;
  2424.  
  2425.   for (i = 0; i < len; i++)
  2426.     {
  2427.       register int c = p[i];
  2428.  
  2429.       if (len_so_far > 50)
  2430.     {
  2431.       if (chars_so_far)
  2432.         fputs ("\"\n", stream);
  2433.       fputs ("\t.ascii\t\"", stream);
  2434.       len_so_far = 0;
  2435.       arm_increase_location (chars_so_far);
  2436.       chars_so_far = 0;
  2437.     }
  2438.  
  2439.       if (c == '\"' || c == '\\')
  2440.     {
  2441.       putc('\\', stream);
  2442.       len_so_far++;
  2443.     }
  2444.  
  2445.       if (c >= ' ' && c < 0177)
  2446.     {
  2447.       putc (c, stream);
  2448.       len_so_far++;
  2449.     }
  2450.       else
  2451.     {
  2452.       fprintf (stream, "\\%03o", c);
  2453.       len_so_far +=4;
  2454.     }
  2455.  
  2456.       chars_so_far++;
  2457.     }
  2458.  
  2459.   fputs ("\"\n", stream);
  2460.   arm_increase_location (chars_so_far);
  2461. }
  2462.  
  2463.  
  2464. /* Try to determine whether a pattern really clobbers the link register.
  2465.    This information is useful when peepholing, so that lr need not be pushed
  2466.    if we combine a call followed by a return.
  2467.    NOTE: This code does not check for side-effect expressions in a SET_SRC:
  2468.    such a check should not be needed because these only update an existing
  2469.    value within a register; the register must still be set elsewhere within
  2470.    the function. */
  2471.  
  2472. static int
  2473. pattern_really_clobbers_lr (x)
  2474.      rtx x;
  2475. {
  2476.   int i;
  2477.   
  2478.   switch (GET_CODE (x))
  2479.     {
  2480.     case SET:
  2481.       switch (GET_CODE (SET_DEST (x)))
  2482.     {
  2483.     case REG:
  2484.       return REGNO (SET_DEST (x)) == 14;
  2485.  
  2486.         case SUBREG:
  2487.       if (GET_CODE (XEXP (SET_DEST (x), 0)) == REG)
  2488.         return REGNO (XEXP (SET_DEST (x), 0)) == 14;
  2489.  
  2490.       if (GET_CODE (XEXP (SET_DEST (x), 0)) == MEM)
  2491.         return 0;
  2492.       abort ();
  2493.  
  2494.         default:
  2495.       return 0;
  2496.         }
  2497.  
  2498.     case PARALLEL:
  2499.       for (i = 0; i < XVECLEN (x, 0); i++)
  2500.     if (pattern_really_clobbers_lr (XVECEXP (x, 0, i)))
  2501.       return 1;
  2502.       return 0;
  2503.  
  2504.     case CLOBBER:
  2505.       switch (GET_CODE (XEXP (x, 0)))
  2506.         {
  2507.     case REG:
  2508.       return REGNO (XEXP (x, 0)) == 14;
  2509.  
  2510.         case SUBREG:
  2511.       if (GET_CODE (XEXP (XEXP (x, 0), 0)) == REG)
  2512.         return REGNO (XEXP (XEXP (x, 0), 0)) == 14;
  2513.       abort ();
  2514.  
  2515.         default:
  2516.       return 0;
  2517.         }
  2518.  
  2519.     case UNSPEC:
  2520.       return 1;
  2521.  
  2522.     default:
  2523.       return 0;
  2524.     }
  2525. }
  2526.  
  2527. static int
  2528. function_really_clobbers_lr (first)
  2529.      rtx first;
  2530. {
  2531.   rtx insn, next;
  2532.   
  2533.   for (insn = first; insn; insn = next_nonnote_insn (insn))
  2534.     {
  2535.       switch (GET_CODE (insn))
  2536.         {
  2537.     case BARRIER:
  2538.     case NOTE:
  2539.     case CODE_LABEL:
  2540.     case JUMP_INSN:        /* Jump insns only change the PC (and conds) */
  2541.     case INLINE_HEADER:
  2542.       break;
  2543.  
  2544.         case INSN:
  2545.       if (pattern_really_clobbers_lr (PATTERN (insn)))
  2546.         return 1;
  2547.       break;
  2548.  
  2549.         case CALL_INSN:
  2550.       /* Don't yet know how to handle those calls that are not to a 
  2551.          SYMBOL_REF */
  2552.       if (GET_CODE (PATTERN (insn)) != PARALLEL)
  2553.         abort ();
  2554.  
  2555.       switch (GET_CODE (XVECEXP (PATTERN (insn), 0, 0)))
  2556.         {
  2557.         case CALL:
  2558.           if (GET_CODE (XEXP (XEXP (XVECEXP (PATTERN (insn), 0, 0), 0), 0))
  2559.           != SYMBOL_REF)
  2560.         return 1;
  2561.           break;
  2562.  
  2563.         case SET:
  2564.           if (GET_CODE (XEXP (XEXP (SET_SRC (XVECEXP (PATTERN (insn),
  2565.                               0, 0)), 0), 0))
  2566.           != SYMBOL_REF)
  2567.         return 1;
  2568.           break;
  2569.  
  2570.         default:    /* Don't recognize it, be safe */
  2571.           return 1;
  2572.         }
  2573.  
  2574.       /* A call can be made (by peepholing) not to clobber lr iff it is
  2575.          followed by a return.  There may, however, be a use insn iff
  2576.          we are returning the result of the call. 
  2577.          If we run off the end of the insn chain, then that means the
  2578.          call was at the end of the function.  Unfortunately we don't
  2579.          have a return insn for the peephole to recognize, so we
  2580.          must reject this.  (Can this be fixed by adding our own insn?) */
  2581.       if ((next = next_nonnote_insn (insn)) == NULL)
  2582.         return 1;
  2583.  
  2584.       if (GET_CODE (next) == INSN && GET_CODE (PATTERN (next)) == USE
  2585.           && (GET_CODE (XVECEXP (PATTERN (insn), 0, 0)) == SET)
  2586.           && (REGNO (SET_DEST (XVECEXP (PATTERN (insn), 0, 0)))
  2587.           == REGNO (XEXP (PATTERN (next), 0))))
  2588.         if ((next = next_nonnote_insn (next)) == NULL)
  2589.           return 1;
  2590.  
  2591.       if (GET_CODE (next) == JUMP_INSN
  2592.           && GET_CODE (PATTERN (next)) == RETURN)
  2593.         break;
  2594.       return 1;
  2595.  
  2596.         default:
  2597.       abort ();
  2598.         }
  2599.     }
  2600.  
  2601.   /* We have reached the end of the chain so lr was _not_ clobbered */
  2602.   return 0;
  2603. }
  2604.  
  2605. char *
  2606. output_return_instruction (operand, really_return)
  2607.      rtx operand;
  2608.      int really_return;
  2609. {
  2610.   char instr[100];
  2611.   int reg, live_regs = 0;
  2612.   int volatile_func = (optimize > 0 
  2613.                && TREE_THIS_VOLATILE (current_function_decl));
  2614.  
  2615.   return_used_this_function = 1;
  2616.  
  2617.   if (volatile_func)
  2618.     {
  2619.       rtx ops[2];
  2620.       /* If this function was declared non-returning, and we have found a tail 
  2621.      call, then we have to trust that the called function won't return. */
  2622.       if (! really_return)
  2623.     return "";
  2624.  
  2625.       /* Otherwise, trap an attempted return by aborting. */
  2626.       ops[0] = operand;
  2627.       ops[1] = gen_rtx (SYMBOL_REF, Pmode, "abort");
  2628.       output_asm_insn ("bl%d0\t%a1", ops);
  2629.       return "";
  2630.     }
  2631.       
  2632.   if (current_function_calls_alloca && ! really_return)
  2633.     abort();
  2634.     
  2635.   for (reg = 0; reg <= 10; reg++)
  2636.     if (regs_ever_live[reg] && ! call_used_regs[reg])
  2637.       live_regs++;
  2638.  
  2639.   if (live_regs || (regs_ever_live[14] && ! lr_save_eliminated))
  2640.     live_regs++;
  2641.  
  2642.   if (frame_pointer_needed)
  2643.     live_regs += 4;
  2644.  
  2645.   if (live_regs)
  2646.     {
  2647.       if (lr_save_eliminated || ! regs_ever_live[14])
  2648.         live_regs++;
  2649.  
  2650.       if (frame_pointer_needed)
  2651.         strcpy (instr, "ldm%?%d0ea\t%|fp, {");
  2652.       else
  2653.         strcpy (instr, "ldm%?%d0fd\t%|sp!, {");
  2654.  
  2655.       for (reg = 0; reg <= 10; reg++)
  2656.         if (regs_ever_live[reg] && ! call_used_regs[reg])
  2657.           {
  2658.         strcat (instr, "%|");
  2659.             strcat (instr, reg_names[reg]);
  2660.         if (--live_regs)
  2661.               strcat (instr, ", ");
  2662.           }
  2663.  
  2664.       if (frame_pointer_needed)
  2665.         {
  2666.       strcat (instr, "%|");
  2667.           strcat (instr, reg_names[11]);
  2668.           strcat (instr, ", ");
  2669.       strcat (instr, "%|");
  2670.           strcat (instr, reg_names[13]);
  2671.           strcat (instr, ", ");
  2672.       strcat (instr, "%|");
  2673.           strcat (instr, really_return ? reg_names[15] : reg_names[14]);
  2674.         }
  2675.       else
  2676.     {
  2677.       strcat (instr, "%|");
  2678.       strcat (instr, really_return ? reg_names[15] : reg_names[14]);
  2679.     }
  2680.       strcat (instr, (TARGET_6 || !really_return) ? "}" : "}^");
  2681.       output_asm_insn (instr, &operand);
  2682.     }
  2683.   else if (really_return)
  2684.     {
  2685.       strcpy (instr,
  2686.           TARGET_6 ? "mov%?%d0\t%|pc, lr" : "mov%?%d0s\t%|pc, %|lr");
  2687.       output_asm_insn (instr, &operand);
  2688.     }
  2689.  
  2690.   return "";
  2691. }
  2692.  
  2693. int
  2694. arm_volatile_func ()
  2695. {
  2696.   return (optimize > 0 && TREE_THIS_VOLATILE (current_function_decl));
  2697. }
  2698.  
  2699. /* Return the size of the prologue.  It's not too bad if we slightly 
  2700.    over-estimate.  */
  2701.  
  2702. static int
  2703. get_prologue_size ()
  2704. {
  2705.   return profile_flag ? 12 : 0;
  2706. }
  2707.  
  2708. /* The amount of stack adjustment that happens here, in output_return and in
  2709.    output_epilogue must be exactly the same as was calculated during reload,
  2710.    or things will point to the wrong place.  The only time we can safely
  2711.    ignore this constraint is when a function has no arguments on the stack,
  2712.    no stack frame requirement and no live registers execpt for `lr'.  If we
  2713.    can guarantee that by making all function calls into tail calls and that
  2714.    lr is not clobbered in any other way, then there is no need to push lr
  2715.    onto the stack. */
  2716.    
  2717. void
  2718. output_func_prologue (f, frame_size)
  2719.      FILE *f;
  2720.      int frame_size;
  2721. {
  2722.   int reg, live_regs_mask = 0;
  2723.   rtx operands[3];
  2724.   int volatile_func = (optimize > 0
  2725.                && TREE_THIS_VOLATILE (current_function_decl));
  2726.  
  2727.   /* Nonzero if we must stuff some register arguments onto the stack as if
  2728.      they were passed there.  */
  2729.   int store_arg_regs = 0;
  2730.  
  2731.   if (arm_ccfsm_state || arm_target_insn)
  2732.     abort ();                    /* Sanity check */
  2733.   
  2734.   return_used_this_function = 0;
  2735.   lr_save_eliminated = 0;
  2736.   
  2737.   fprintf (f, "\t%c args = %d, pretend = %d, frame = %d\n",
  2738.        ARM_COMMENT_CHAR, current_function_args_size,
  2739.        current_function_pretend_args_size, frame_size);
  2740.   fprintf (f, "\t%c frame_needed = %d, current_function_anonymous_args = %d\n",
  2741.        ARM_COMMENT_CHAR, frame_pointer_needed,
  2742.        current_function_anonymous_args);
  2743.  
  2744.   if (volatile_func)
  2745.     fprintf (f, "\t%c Volatile function.\n", ARM_COMMENT_CHAR);
  2746.  
  2747.   if (current_function_anonymous_args && current_function_pretend_args_size)
  2748.     store_arg_regs = 1;
  2749.  
  2750.   for (reg = 0; reg <= 10; reg++)
  2751.     if (regs_ever_live[reg] && ! call_used_regs[reg])
  2752.       live_regs_mask |= (1 << reg);
  2753.  
  2754.   if (frame_pointer_needed)
  2755.     live_regs_mask |= 0xD800;
  2756.   else if (regs_ever_live[14])
  2757.     {
  2758.       if (! current_function_args_size
  2759.       && ! function_really_clobbers_lr (get_insns ()))
  2760.     lr_save_eliminated = 1;
  2761.       else
  2762.         live_regs_mask |= 0x4000;
  2763.     }
  2764.  
  2765.   if (live_regs_mask)
  2766.     {
  2767.       /* if a di mode load/store multiple is used, and the base register
  2768.      is r3, then r4 can become an ever live register without lr
  2769.      doing so,  in this case we need to push lr as well, or we
  2770.      will fail to get a proper return. */
  2771.  
  2772.       live_regs_mask |= 0x4000;
  2773.       lr_save_eliminated = 0;
  2774.  
  2775.     }
  2776.  
  2777.   if (lr_save_eliminated)
  2778.     fprintf (f,"\t%c I don't think this function clobbers lr\n",
  2779.          ARM_COMMENT_CHAR);
  2780. }
  2781.  
  2782.  
  2783. void
  2784. output_func_epilogue (f, frame_size)
  2785.      FILE *f;
  2786.      int frame_size;
  2787. {
  2788.   int reg, live_regs_mask = 0, code_size = 0;
  2789.   /* If we need this then it will always be at lesat this much */
  2790.   int floats_offset = 24;
  2791.   rtx operands[3];
  2792.   int volatile_func = (optimize > 0
  2793.                && TREE_THIS_VOLATILE (current_function_decl));
  2794.  
  2795.   if (use_return_insn() && return_used_this_function)
  2796.     {
  2797.       if (frame_size && !(frame_pointer_needed || TARGET_APCS))
  2798.         {
  2799.           abort ();
  2800.         }
  2801.       goto epilogue_done;
  2802.     }
  2803.  
  2804.   /* A volatile function should never return.  Call abort.  */
  2805.   if (volatile_func)
  2806.     {
  2807.       rtx op = gen_rtx (SYMBOL_REF, Pmode, "abort");
  2808.       output_asm_insn ("bl\t%a0", &op);
  2809.       code_size = 4;
  2810.       goto epilogue_done;
  2811.     }
  2812.  
  2813.   for (reg = 0; reg <= 10; reg++)
  2814.     if (regs_ever_live[reg] && ! call_used_regs[reg])
  2815.       {
  2816.         live_regs_mask |= (1 << reg);
  2817.     floats_offset += 4;
  2818.       }
  2819.  
  2820.   if (frame_pointer_needed)
  2821.     {
  2822.       for (reg = 23; reg > 15; reg--)
  2823.     if (regs_ever_live[reg] && ! call_used_regs[reg])
  2824.       {
  2825.         fprintf (f, "\tldfe\t%s%s, [%sfp, #-%d]\n", ARM_REG_PREFIX,
  2826.              reg_names[reg], ARM_REG_PREFIX, floats_offset);
  2827.         floats_offset += 12;
  2828.         code_size += 4;
  2829.       }
  2830.  
  2831.       live_regs_mask |= 0xA800;
  2832.       print_multi_reg (f, "ldmea\t%sfp", live_regs_mask,
  2833.                TARGET_6 ? FALSE : TRUE);
  2834.       code_size += 4;
  2835.     }
  2836.   else
  2837.     {
  2838.       /* Restore stack pointer if necessary.  */
  2839.       if (frame_size)
  2840.     {
  2841.       operands[0] = operands[1] = stack_pointer_rtx;
  2842.       operands[2] = gen_rtx (CONST_INT, VOIDmode, frame_size);
  2843.       output_add_immediate (operands);
  2844.     }
  2845.  
  2846.       for (reg = 16; reg < 24; reg++)
  2847.     if (regs_ever_live[reg] && ! call_used_regs[reg])
  2848.       {
  2849.         fprintf (f, "\tldfe\t%s%s, [%ssp], #12\n", ARM_REG_PREFIX,
  2850.              reg_names[reg], ARM_REG_PREFIX);
  2851.         code_size += 4;
  2852.       }
  2853.       if (current_function_pretend_args_size == 0 && regs_ever_live[14])
  2854.     {
  2855.       print_multi_reg (f, "ldmfd\t%ssp!", live_regs_mask | 0x8000,
  2856.                TARGET_6 ? FALSE : TRUE);
  2857.       code_size += 4;
  2858.     }
  2859.       else
  2860.     {
  2861.       if (live_regs_mask || regs_ever_live[14])
  2862.         {
  2863.           live_regs_mask |= 0x4000;
  2864.           print_multi_reg (f, "ldmfd\t%ssp!", live_regs_mask, FALSE);
  2865.           code_size += 4;
  2866.         }
  2867.       if (current_function_pretend_args_size)
  2868.         {
  2869.           operands[0] = operands[1] = stack_pointer_rtx;
  2870.           operands[2] = gen_rtx (CONST_INT, VOIDmode,
  2871.                      current_function_pretend_args_size);
  2872.           output_add_immediate (operands);
  2873.         }
  2874.       fprintf (f,
  2875.            TARGET_6 ? "\tmov\t%spc, %slr\n" : "\tmovs\t%spc, %slr\n",
  2876.            ARM_REG_PREFIX, ARM_REG_PREFIX, f);
  2877.       code_size += 4;
  2878.     }
  2879.     }
  2880.  
  2881.  epilogue_done:
  2882.  
  2883.   /* insn_addresses isn't allocated when not optimizing */
  2884.  
  2885.   if (optimize > 0)
  2886.     arm_increase_location (code_size
  2887.                + insn_addresses[INSN_UID (get_last_insn ())]
  2888.                + get_prologue_size ());
  2889.  
  2890.   current_function_anonymous_args = 0;
  2891. }
  2892.  
  2893. static void
  2894. emit_multi_reg_push (mask)
  2895.      int mask;
  2896. {
  2897.   int num_regs = 0;
  2898.   int i, j;
  2899.   rtx par;
  2900.  
  2901.   for (i = 0; i < 16; i++)
  2902.     if (mask & (1 << i))
  2903.       num_regs++;
  2904.  
  2905.   if (num_regs == 0 || num_regs > 16)
  2906.     abort ();
  2907.  
  2908.   par = gen_rtx (PARALLEL, VOIDmode, rtvec_alloc (num_regs));
  2909.  
  2910.   for (i = 0; i < 16; i++)
  2911.     {
  2912.       if (mask & (1 << i))
  2913.     {
  2914.       XVECEXP (par, 0, 0)
  2915.         = gen_rtx (SET, VOIDmode, gen_rtx (MEM, BLKmode,
  2916.                            gen_rtx (PRE_DEC, BLKmode,
  2917.                             stack_pointer_rtx)),
  2918.                gen_rtx (UNSPEC, BLKmode,
  2919.                 gen_rtvec (1, gen_rtx (REG, SImode, i)),
  2920.                 2));
  2921.       break;
  2922.     }
  2923.     }
  2924.  
  2925.   for (j = 1, i++; j < num_regs; i++)
  2926.     {
  2927.       if (mask & (1 << i))
  2928.     {
  2929.       XVECEXP (par, 0, j)
  2930.         = gen_rtx (USE, VOIDmode, gen_rtx (REG, SImode, i));
  2931.       j++;
  2932.     }
  2933.     }
  2934.   emit_insn (par);
  2935. }
  2936.  
  2937. void
  2938. arm_expand_prologue ()
  2939. {
  2940.   int reg;
  2941.   rtx amount = GEN_INT (- get_frame_size ());
  2942.   rtx push_insn;
  2943.   int num_regs;
  2944.   int live_regs_mask = 0;
  2945.   int store_arg_regs = 0;
  2946.   int volatile_func = (optimize > 0
  2947.                && TREE_THIS_VOLATILE (current_function_decl));
  2948.  
  2949.   if (current_function_anonymous_args && current_function_pretend_args_size)
  2950.     store_arg_regs = 1;
  2951.  
  2952.   if (! volatile_func)
  2953.     for (reg = 0; reg <= 10; reg++)
  2954.       if (regs_ever_live[reg] && ! call_used_regs[reg])
  2955.     live_regs_mask |= 1 << reg;
  2956.  
  2957.   if (! volatile_func && regs_ever_live[14])
  2958.     live_regs_mask |= 0x4000;
  2959.  
  2960.   if (frame_pointer_needed)
  2961.     {
  2962.       live_regs_mask |= 0xD800;
  2963.       emit_insn (gen_movsi (gen_rtx (REG, SImode, 12),
  2964.                 stack_pointer_rtx));
  2965.     }
  2966.  
  2967.   if (current_function_pretend_args_size)
  2968.     {
  2969.       if (store_arg_regs)
  2970.     emit_multi_reg_push ((0xf0 >> (current_function_pretend_args_size / 4))
  2971.                  & 0xf);
  2972.       else
  2973.     emit_insn (gen_addsi3 (stack_pointer_rtx, stack_pointer_rtx, 
  2974.                    GEN_INT (-current_function_pretend_args_size)));
  2975.     }
  2976.  
  2977.   if (live_regs_mask)
  2978.     {
  2979.       /* If we have to push any regs, then we must push lr as well, or
  2980.      we won't get a propper return.  */
  2981.       live_regs_mask |= 0x4000;
  2982.       emit_multi_reg_push (live_regs_mask);
  2983.     }
  2984.       
  2985.   /* For now the integer regs are still pushed in output_func_epilogue ().  */
  2986.  
  2987.   if (! volatile_func)
  2988.     for (reg = 23; reg > 15; reg--)
  2989.       if (regs_ever_live[reg] && ! call_used_regs[reg])
  2990.     emit_insn (gen_rtx (SET, VOIDmode, 
  2991.                 gen_rtx (MEM, XFmode, 
  2992.                      gen_rtx (PRE_DEC, XFmode,
  2993.                           stack_pointer_rtx)),
  2994.                 gen_rtx (REG, XFmode, reg)));
  2995.  
  2996.   if (frame_pointer_needed)
  2997.     emit_insn (gen_addsi3 (hard_frame_pointer_rtx, gen_rtx (REG, SImode, 12),
  2998.                (GEN_INT
  2999.                 (-(4 + current_function_pretend_args_size)))));
  3000.  
  3001.   if (amount != const0_rtx)
  3002.     {
  3003.       emit_insn (gen_addsi3 (stack_pointer_rtx, stack_pointer_rtx, amount));
  3004.       emit_insn (gen_rtx (CLOBBER, VOIDmode, 
  3005.               gen_rtx (MEM, BLKmode, stack_pointer_rtx)));
  3006.     }
  3007.  
  3008.   /* If we are profiling, make sure no instructions are scheduled before
  3009.      the call to mcount.  */
  3010.   if (profile_flag || profile_block_flag)
  3011.     emit_insn (gen_blockage ());
  3012. }
  3013.   
  3014.  
  3015. /* If CODE is 'd', then the X is a condition operand and the instruction
  3016.    should only be executed if the condition is true.
  3017.    if CODE is 'D', then the X is a condition operand and the instruciton
  3018.    should only be executed if the condition is false: however, if the mode
  3019.    of the comparison is CCFPEmode, then always execute the instruction -- we
  3020.    do this because in these circumstances !GE does not necessarily imply LT;
  3021.    in these cases the instruction pattern will take care to make sure that
  3022.    an instruction containing %d will follow, thereby undoing the effects of
  3023.    doing this instrucion unconditionally.
  3024.    If CODE is 'N' then X is a floating point operand that must be negated
  3025.    before output.
  3026.    If CODE is 'B' then output a bitwise inverted value of X (a const int).
  3027.    If X is a REG and CODE is `M', output a ldm/stm style multi-reg.  */
  3028.  
  3029. void
  3030. arm_print_operand (stream, x, code)
  3031.      FILE *stream;
  3032.      rtx x;
  3033.      int code;
  3034. {
  3035.   switch (code)
  3036.     {
  3037.     case '@':
  3038.       fputc (ARM_COMMENT_CHAR, stream);
  3039.       return;
  3040.  
  3041.     case '|':
  3042.       fputs (ARM_REG_PREFIX, stream);
  3043.       return;
  3044.  
  3045.     case '?':
  3046.       if (arm_ccfsm_state == 3 || arm_ccfsm_state == 4)
  3047.     fputs (arm_condition_codes[arm_current_cc], stream);
  3048.       return;
  3049.  
  3050.     case 'N':
  3051.       {
  3052.     REAL_VALUE_TYPE r;
  3053.     REAL_VALUE_FROM_CONST_DOUBLE (r, x);
  3054.     r = REAL_VALUE_NEGATE (r);
  3055.     fprintf (stream, "%s", fp_const_from_val (&r));
  3056.       }
  3057.       return;
  3058.  
  3059.     case 'B':
  3060.       if (GET_CODE (x) == CONST_INT)
  3061.     fprintf (stream,
  3062. #if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_INT
  3063.          "%d",
  3064. #else
  3065.          "%ld",
  3066. #endif
  3067.          ARM_SIGN_EXTEND (~ INTVAL (x)));
  3068.       else
  3069.     {
  3070.       putc ('~', stream);
  3071.       output_addr_const (stream, x);
  3072.     }
  3073.       return;
  3074.  
  3075.     case 'i':
  3076.       fprintf (stream, "%s", arithmetic_instr (x, 1));
  3077.       return;
  3078.  
  3079.     case 'I':
  3080.       fprintf (stream, "%s", arithmetic_instr (x, 0));
  3081.       return;
  3082.  
  3083.     case 'S':
  3084.       {
  3085.     HOST_WIDE_INT val;
  3086.     char *shift = shift_op (x, &val);
  3087.  
  3088.     if (shift)
  3089.       {
  3090.         fprintf (stream, ", %s ", shift_op (x, &val));
  3091.         if (val == -1)
  3092.           arm_print_operand (stream, XEXP (x, 1), 0);
  3093.         else
  3094.           fprintf (stream,
  3095. #if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_INT
  3096.                "#%d",
  3097. #else
  3098.                "#%ld",
  3099. #endif
  3100.                val);
  3101.       }
  3102.       }
  3103.       return;
  3104.  
  3105.     case 'R':
  3106.       if (REGNO (x) > 15)
  3107.     abort ();
  3108.       fputs (ARM_REG_PREFIX, stream);
  3109.       fputs (reg_names[REGNO (x) + 1], stream);
  3110.       return;
  3111.  
  3112.     case 'm':
  3113.       fputs (ARM_REG_PREFIX, stream);
  3114.       if (GET_CODE (XEXP (x, 0)) == REG)
  3115.     fputs (reg_names[REGNO (XEXP (x, 0))], stream);
  3116.       else
  3117.     fputs (reg_names[REGNO (XEXP (XEXP (x, 0), 0))], stream);
  3118.       return;
  3119.  
  3120.     case 'M':
  3121.       fprintf (stream, "{%s%s-%s%s}", ARM_REG_PREFIX, reg_names[REGNO (x)],
  3122.            ARM_REG_PREFIX, reg_names[REGNO (x) - 1
  3123.                      + ((GET_MODE_SIZE (GET_MODE (x))
  3124.                          + GET_MODE_SIZE (SImode) - 1)
  3125.                         / GET_MODE_SIZE (SImode))]);
  3126.       return;
  3127.  
  3128.     case 'd':
  3129.       if (x)
  3130.         fputs (arm_condition_codes[get_arm_condition_code (x)],
  3131.            stream);
  3132.       return;
  3133.  
  3134.     case 'D':
  3135.       if (x && (flag_fast_math
  3136.         || GET_CODE (x) == EQ || GET_CODE (x) == NE
  3137.         || (GET_MODE (XEXP (x, 0)) != CCFPEmode
  3138.             && (GET_MODE_CLASS (GET_MODE (XEXP (x, 0)))
  3139.             != MODE_FLOAT))))
  3140.         fputs (arm_condition_codes[ARM_INVERSE_CONDITION_CODE
  3141.                    (get_arm_condition_code (x))],
  3142.            stream);
  3143.       return;
  3144.  
  3145.     default:
  3146.       if (x == 0)
  3147.     abort ();
  3148.  
  3149.       if (GET_CODE (x) == REG)
  3150.     {
  3151.       fputs (ARM_REG_PREFIX, stream);
  3152.       fputs (reg_names[REGNO (x)], stream);
  3153.     }
  3154.       else if (GET_CODE (x) == MEM)
  3155.     {
  3156.       output_memory_reference_mode = GET_MODE (x);
  3157.       output_address (XEXP (x, 0));
  3158.     }
  3159.       else if (GET_CODE (x) == CONST_DOUBLE)
  3160.     fprintf (stream, "#%s", fp_immediate_constant (x));
  3161.       else if (GET_CODE (x) == NEG)
  3162.     abort (); /* This should never happen now. */
  3163.       else
  3164.     {
  3165.       fputc ('#', stream);
  3166.       output_addr_const (stream, x);
  3167.     }
  3168.     }
  3169. }
  3170.  
  3171. /* Increase the `arm_text_location' by AMOUNT if we're in the text
  3172.    segment.  */
  3173.  
  3174. void
  3175. arm_increase_location (amount)
  3176.      int amount;
  3177. {
  3178.   if (in_text_section ())
  3179.     arm_text_location += amount;
  3180. }
  3181.  
  3182.  
  3183. /* Output a label definition.  If this label is within the .text segment, it
  3184.    is stored in OFFSET_TABLE, to be used when building `llc' instructions.
  3185.    Maybe GCC remembers names not starting with a `*' for a long time, but this
  3186.    is a minority anyway, so we just make a copy.  Do not store the leading `*'
  3187.    if the name starts with one.  */
  3188.  
  3189. void
  3190. arm_asm_output_label (stream, name)
  3191.      FILE *stream;
  3192.      char *name;
  3193. {
  3194.   char *real_name, *s;
  3195.   struct label_offset *cur;
  3196.   int hash = 0;
  3197.  
  3198.   assemble_name (stream, name);
  3199.   fputs (":\n", stream);
  3200.   if (! in_text_section ())
  3201.     return;
  3202.  
  3203.   if (name[0] == '*')
  3204.     {
  3205.       real_name = xmalloc (1 + strlen (&name[1]));
  3206.       strcpy (real_name, &name[1]);
  3207.     }
  3208.   else
  3209.     {
  3210.       real_name = xmalloc (2 + strlen (name));
  3211.       strcpy (real_name, "_");
  3212.       strcat (real_name, name);
  3213.     }
  3214.   for (s = real_name; *s; s++)
  3215.     hash += *s;
  3216.  
  3217.   hash = hash % LABEL_HASH_SIZE;
  3218.   cur = (struct label_offset *) xmalloc (sizeof (struct label_offset));
  3219.   cur->name = real_name;
  3220.   cur->offset = arm_text_location;
  3221.   cur->cdr = offset_table[hash];
  3222.   offset_table[hash] = cur;
  3223. }
  3224.  
  3225. /* Load a symbol that is known to be in the text segment into a register.
  3226.    This should never be called when not optimizing.  */
  3227.  
  3228. char *
  3229. output_load_symbol (insn, operands)
  3230.      rtx insn;
  3231.      rtx *operands;
  3232. {
  3233.   char *s;
  3234.   char *name = XSTR (operands[1], 0);
  3235.   struct label_offset *he;
  3236.   int hash = 0;
  3237.   int offset;
  3238.   unsigned int mask, never_mask = 0xffffffff;
  3239.   int shift, inst;
  3240.   char buffer[100];
  3241.  
  3242.   if (optimize == 0 || *name != '*')
  3243.     abort ();
  3244.  
  3245.   for (s = &name[1]; *s; s++)
  3246.     hash += *s;
  3247.  
  3248.   hash = hash % LABEL_HASH_SIZE;
  3249.   he = offset_table[hash];
  3250.   while (he && strcmp (he->name, &name[1]))
  3251.     he = he->cdr;
  3252.   
  3253.   if (!he)
  3254.     abort ();
  3255.   
  3256.   offset = (arm_text_location + insn_addresses[INSN_UID (insn)]
  3257.         + get_prologue_size () + 8 - he->offset);
  3258.   if (offset < 0)
  3259.     abort ();
  3260.  
  3261.   /* When generating the instructions, we never mask out the bits that we
  3262.      think will be always zero, then if a mistake has occured somewhere, the
  3263.      assembler will spot it and generate an error.  */
  3264.  
  3265.   /* If the symbol is word aligned then we might be able to reduce the
  3266.      number of loads.  */
  3267.   shift = ((offset & 3) == 0) ? 2 : 0;
  3268.  
  3269.   /* Clear the bits from NEVER_MASK that will be orred in with the individual
  3270.      instructions.  */
  3271.   for (; shift < 32; shift += 8)
  3272.     {
  3273.       mask = 0xff << shift;
  3274.       if ((offset & mask) || ((unsigned) offset) > mask)
  3275.     never_mask &= ~mask;
  3276.     }
  3277.  
  3278.   inst = 8;
  3279.   mask = 0xff << (shift - 32);
  3280.  
  3281.   while (mask && (never_mask & mask) == 0)
  3282.     {
  3283.       if (inst == 8)
  3284.     {
  3285.       strcpy (buffer, "sub%?\t%0, %|pc, #(8 + . -%a1)");
  3286.       if ((never_mask | mask) != 0xffffffff)
  3287.         sprintf (buffer + strlen (buffer), " & 0x%x", mask | never_mask);
  3288.     }
  3289.       else
  3290.     sprintf (buffer, "sub%%?\t%%0, %%0, #(%d + . -%%a1) & 0x%x",
  3291.          inst, mask | never_mask);
  3292.  
  3293.       output_asm_insn (buffer, operands);
  3294.       mask <<= 8;
  3295.       inst -= 4;
  3296.     }
  3297.  
  3298.   return "";
  3299. }
  3300.  
  3301. /* Output code resembling an .lcomm directive.  /bin/as doesn't have this
  3302.    directive hence this hack, which works by reserving some `.space' in the
  3303.    bss segment directly.
  3304.  
  3305.    XXX This is a severe hack, which is guaranteed NOT to work since it doesn't
  3306.    define STATIC COMMON space but merely STATIC BSS space.  */
  3307.  
  3308. void
  3309. output_lcomm_directive (stream, name, size, rounded)
  3310.      FILE *stream;
  3311.      char *name;
  3312.      int size, rounded;
  3313. {
  3314.   fprintf (stream, "\n\t.bss\t%c .lcomm\n", ARM_COMMENT_CHAR);
  3315.   assemble_name (stream, name);
  3316.   fprintf (stream, ":\t.space\t%d\n", rounded);
  3317.   if (in_text_section ())
  3318.     fputs ("\n\t.text\n", stream);
  3319.   else
  3320.     fputs ("\n\t.data\n", stream);
  3321. }
  3322.  
  3323. /* A finite state machine takes care of noticing whether or not instructions
  3324.    can be conditionally executed, and thus decrease execution time and code
  3325.    size by deleting branch instructions.  The fsm is controlled by
  3326.    final_prescan_insn, and controls the actions of ASM_OUTPUT_OPCODE.  */
  3327.  
  3328. /* The state of the fsm controlling condition codes are:
  3329.    0: normal, do nothing special
  3330.    1: make ASM_OUTPUT_OPCODE not output this instruction
  3331.    2: make ASM_OUTPUT_OPCODE not output this instruction
  3332.    3: make instructions conditional
  3333.    4: make instructions conditional
  3334.  
  3335.    State transitions (state->state by whom under condition):
  3336.    0 -> 1 final_prescan_insn if the `target' is a label
  3337.    0 -> 2 final_prescan_insn if the `target' is an unconditional branch
  3338.    1 -> 3 ASM_OUTPUT_OPCODE after not having output the conditional branch
  3339.    2 -> 4 ASM_OUTPUT_OPCODE after not having output the conditional branch
  3340.    3 -> 0 ASM_OUTPUT_INTERNAL_LABEL if the `target' label is reached
  3341.           (the target label has CODE_LABEL_NUMBER equal to arm_target_label).
  3342.    4 -> 0 final_prescan_insn if the `target' unconditional branch is reached
  3343.           (the target insn is arm_target_insn).
  3344.  
  3345.    If the jump clobbers the conditions then we use states 2 and 4.
  3346.  
  3347.    A similar thing can be done with conditional return insns.
  3348.  
  3349.    XXX In case the `target' is an unconditional branch, this conditionalising
  3350.    of the instructions always reduces code size, but not always execution
  3351.    time.  But then, I want to reduce the code size to somewhere near what
  3352.    /bin/cc produces.  */
  3353.  
  3354. /* Returns the index of the ARM condition code string in
  3355.    `arm_condition_codes'.  COMPARISON should be an rtx like
  3356.    `(eq (...) (...))'.  */
  3357.  
  3358. int
  3359. get_arm_condition_code (comparison)
  3360.      rtx comparison;
  3361. {
  3362.   switch (GET_CODE (comparison))
  3363.     {
  3364.     case NE: return (1);
  3365.     case EQ: return (0);
  3366.     case GE: return (10);
  3367.     case GT: return (12);
  3368.     case LE: return (13);
  3369.     case LT: return (11);
  3370.     case GEU: return (2);
  3371.     case GTU: return (8);
  3372.     case LEU: return (9);
  3373.     case LTU: return (3);
  3374.     default: abort ();
  3375.     }
  3376.   /*NOTREACHED*/
  3377.   return (42);
  3378. }
  3379.  
  3380.  
  3381. void
  3382. final_prescan_insn (insn, opvec, noperands)
  3383.      rtx insn;
  3384.      rtx *opvec;
  3385.      int noperands;
  3386. {
  3387.   /* BODY will hold the body of INSN.  */
  3388.   register rtx body = PATTERN (insn);
  3389.  
  3390.   /* This will be 1 if trying to repeat the trick, and things need to be
  3391.      reversed if it appears to fail.  */
  3392.   int reverse = 0;
  3393.  
  3394.   /* JUMP_CLOBBERS will be one implies that the conditions if a branch is
  3395.      taken are clobbered, even if the rtl suggests otherwise.  It also
  3396.      means that we have to grub around within the jump expression to find
  3397.      out what the conditions are when the jump isn't taken.  */
  3398.   int jump_clobbers = 0;
  3399.   
  3400.   /* If we start with a return insn, we only succeed if we find another one. */
  3401.   int seeking_return = 0;
  3402.   
  3403.   /* START_INSN will hold the insn from where we start looking.  This is the
  3404.      first insn after the following code_label if REVERSE is true.  */
  3405.   rtx start_insn = insn;
  3406.  
  3407.   /* If in state 4, check if the target branch is reached, in order to
  3408.      change back to state 0.  */
  3409.   if (arm_ccfsm_state == 4)
  3410.     {
  3411.       if (insn == arm_target_insn)
  3412.       {
  3413.     arm_target_insn = NULL;
  3414.     arm_ccfsm_state = 0;
  3415.       }
  3416.       return;
  3417.     }
  3418.  
  3419.   /* If in state 3, it is possible to repeat the trick, if this insn is an
  3420.      unconditional branch to a label, and immediately following this branch
  3421.      is the previous target label which is only used once, and the label this
  3422.      branch jumps to is not too far off.  */
  3423.   if (arm_ccfsm_state == 3)
  3424.     {
  3425.       if (simplejump_p (insn))
  3426.     {
  3427.       start_insn = next_nonnote_insn (start_insn);
  3428.       if (GET_CODE (start_insn) == BARRIER)
  3429.         {
  3430.           /* XXX Isn't this always a barrier?  */
  3431.           start_insn = next_nonnote_insn (start_insn);
  3432.         }
  3433.       if (GET_CODE (start_insn) == CODE_LABEL
  3434.           && CODE_LABEL_NUMBER (start_insn) == arm_target_label
  3435.           && LABEL_NUSES (start_insn) == 1)
  3436.         reverse = TRUE;
  3437.       else
  3438.         return;
  3439.     }
  3440.       else if (GET_CODE (body) == RETURN)
  3441.         {
  3442.       start_insn = next_nonnote_insn (start_insn);
  3443.       if (GET_CODE (start_insn) == BARRIER)
  3444.         start_insn = next_nonnote_insn (start_insn);
  3445.       if (GET_CODE (start_insn) == CODE_LABEL
  3446.           && CODE_LABEL_NUMBER (start_insn) == arm_target_label
  3447.           && LABEL_NUSES (start_insn) == 1)
  3448.         {
  3449.           reverse = TRUE;
  3450.           seeking_return = 1;
  3451.         }
  3452.       else
  3453.         return;
  3454.         }
  3455.       else
  3456.     return;
  3457.     }
  3458.  
  3459.   if (arm_ccfsm_state != 0 && !reverse)
  3460.     abort ();
  3461.   if (GET_CODE (insn) != JUMP_INSN)
  3462.     return;
  3463.  
  3464.   /* This jump might be paralled with a clobber of the condition codes 
  3465.      the jump should always come first */
  3466.   if (GET_CODE (body) == PARALLEL && XVECLEN (body, 0) > 0)
  3467.     body = XVECEXP (body, 0, 0);
  3468.  
  3469. #if 0  
  3470.   /* If this is a conditional return then we don't want to know */
  3471.   if (GET_CODE (body) == SET && GET_CODE (SET_DEST (body)) == PC
  3472.       && GET_CODE (SET_SRC (body)) == IF_THEN_ELSE
  3473.       && (GET_CODE (XEXP (SET_SRC (body), 1)) == RETURN
  3474.           || GET_CODE (XEXP (SET_SRC (body), 2)) == RETURN))
  3475.     return;
  3476. #endif
  3477.  
  3478.   if (reverse
  3479.       || (GET_CODE (body) == SET && GET_CODE (SET_DEST (body)) == PC
  3480.       && GET_CODE (SET_SRC (body)) == IF_THEN_ELSE))
  3481.     {
  3482.       int insns_skipped = 0, fail = FALSE, succeed = FALSE;
  3483.       /* Flag which part of the IF_THEN_ELSE is the LABEL_REF.  */
  3484.       int then_not_else = TRUE;
  3485.       rtx this_insn = start_insn, label = 0;
  3486.  
  3487.       if (get_attr_conds (insn) == CONDS_JUMP_CLOB)
  3488.     {
  3489.       /* The code below is wrong for these, and I haven't time to
  3490.          fix it now.  So we just do the safe thing and return.  This
  3491.          whole function needs re-writing anyway.  */
  3492.       jump_clobbers = 1;
  3493.       return;
  3494.     }
  3495.       
  3496.       /* Register the insn jumped to.  */
  3497.       if (reverse)
  3498.         {
  3499.       if (!seeking_return)
  3500.         label = XEXP (SET_SRC (body), 0);
  3501.         }
  3502.       else if (GET_CODE (XEXP (SET_SRC (body), 1)) == LABEL_REF)
  3503.     label = XEXP (XEXP (SET_SRC (body), 1), 0);
  3504.       else if (GET_CODE (XEXP (SET_SRC (body), 2)) == LABEL_REF)
  3505.     {
  3506.       label = XEXP (XEXP (SET_SRC (body), 2), 0);
  3507.       then_not_else = FALSE;
  3508.     }
  3509.       else if (GET_CODE (XEXP (SET_SRC (body), 1)) == RETURN)
  3510.     seeking_return = 1;
  3511.       else if (GET_CODE (XEXP (SET_SRC (body), 2)) == RETURN)
  3512.         {
  3513.       seeking_return = 1;
  3514.       then_not_else = FALSE;
  3515.         }
  3516.       else
  3517.     abort ();
  3518.  
  3519.       /* See how many insns this branch skips, and what kind of insns.  If all
  3520.      insns are okay, and the label or unconditional branch to the same
  3521.      label is not too far away, succeed.  */
  3522.       for (insns_skipped = 0;
  3523.        !fail && !succeed && insns_skipped < MAX_INSNS_SKIPPED;
  3524.        insns_skipped++)
  3525.     {
  3526.       rtx scanbody;
  3527.  
  3528.       this_insn = next_nonnote_insn (this_insn);
  3529.       if (!this_insn)
  3530.         break;
  3531.  
  3532.       scanbody = PATTERN (this_insn);
  3533.  
  3534.       switch (GET_CODE (this_insn))
  3535.         {
  3536.         case CODE_LABEL:
  3537.           /* Succeed if it is the target label, otherwise fail since
  3538.          control falls in from somewhere else.  */
  3539.           if (this_insn == label)
  3540.         {
  3541.           if (jump_clobbers)
  3542.             {
  3543.               arm_ccfsm_state = 2;
  3544.               this_insn = next_nonnote_insn (this_insn);
  3545.             }
  3546.           else
  3547.             arm_ccfsm_state = 1;
  3548.           succeed = TRUE;
  3549.         }
  3550.           else
  3551.         fail = TRUE;
  3552.           break;
  3553.  
  3554.         case BARRIER:
  3555.           /* Succeed if the following insn is the target label.
  3556.          Otherwise fail.  
  3557.          If return insns are used then the last insn in a function 
  3558.          will be a barrier. */
  3559.           this_insn = next_nonnote_insn (this_insn);
  3560.           if (this_insn && this_insn == label)
  3561.         {
  3562.           if (jump_clobbers)
  3563.             {
  3564.               arm_ccfsm_state = 2;
  3565.               this_insn = next_nonnote_insn (this_insn);
  3566.             }
  3567.           else
  3568.             arm_ccfsm_state = 1;
  3569.           succeed = TRUE;
  3570.         }
  3571.           else
  3572.         fail = TRUE;
  3573.           break;
  3574.  
  3575.         case CALL_INSN:
  3576.           /* The arm 6xx uses full 32 bit addresses so the cc is not 
  3577.          preserved over calls */
  3578.           if (TARGET_6)
  3579.         fail = TRUE;
  3580.           break;
  3581.         case JUMP_INSN:
  3582.                 /* If this is an unconditional branch to the same label, succeed.
  3583.          If it is to another label, do nothing.  If it is conditional,
  3584.          fail.  */
  3585.           /* XXX Probably, the test for the SET and the PC are unnecessary. */
  3586.  
  3587.           if (GET_CODE (scanbody) == SET
  3588.           && GET_CODE (SET_DEST (scanbody)) == PC)
  3589.         {
  3590.           if (GET_CODE (SET_SRC (scanbody)) == LABEL_REF
  3591.               && XEXP (SET_SRC (scanbody), 0) == label && !reverse)
  3592.             {
  3593.               arm_ccfsm_state = 2;
  3594.               succeed = TRUE;
  3595.             }
  3596.           else if (GET_CODE (SET_SRC (scanbody)) == IF_THEN_ELSE)
  3597.             fail = TRUE;
  3598.         }
  3599.           else if (GET_CODE (scanbody) == RETURN
  3600.                && seeking_return)
  3601.             {
  3602.           arm_ccfsm_state = 2;
  3603.           succeed = TRUE;
  3604.             }
  3605.           else if (GET_CODE (scanbody) == PARALLEL)
  3606.             {
  3607.           switch (get_attr_conds (this_insn))
  3608.             {
  3609.             case CONDS_NOCOND:
  3610.               break;
  3611.             default:
  3612.               fail = TRUE;
  3613.               break;
  3614.             }
  3615.         }
  3616.           break;
  3617.  
  3618.         case INSN:
  3619.           /* Instructions using or affecting the condition codes make it
  3620.          fail.  */
  3621.           if ((GET_CODE (scanbody) == SET
  3622.            || GET_CODE (scanbody) == PARALLEL)
  3623.           && get_attr_conds (this_insn) != CONDS_NOCOND)
  3624.         fail = TRUE;
  3625.           break;
  3626.  
  3627.         default:
  3628.           break;
  3629.         }
  3630.     }
  3631.       if (succeed)
  3632.     {
  3633.       if ((!seeking_return) && (arm_ccfsm_state == 1 || reverse))
  3634.         arm_target_label = CODE_LABEL_NUMBER (label);
  3635.       else if (seeking_return || arm_ccfsm_state == 2)
  3636.         {
  3637.           while (this_insn && GET_CODE (PATTERN (this_insn)) == USE)
  3638.             {
  3639.           this_insn = next_nonnote_insn (this_insn);
  3640.           if (this_insn && (GET_CODE (this_insn) == BARRIER
  3641.                     || GET_CODE (this_insn) == CODE_LABEL))
  3642.             abort ();
  3643.             }
  3644.           if (!this_insn)
  3645.             {
  3646.           /* Oh, dear! we ran off the end.. give up */
  3647.           recog (PATTERN (insn), insn, NULL_PTR);
  3648.           arm_ccfsm_state = 0;
  3649.           arm_target_insn = NULL;
  3650.           return;
  3651.             }
  3652.           arm_target_insn = this_insn;
  3653.         }
  3654.       else
  3655.         abort ();
  3656.       if (jump_clobbers)
  3657.         {
  3658.           if (reverse)
  3659.         abort ();
  3660.           arm_current_cc = 
  3661.           get_arm_condition_code (XEXP (XEXP (XEXP (SET_SRC (body),
  3662.                                 0), 0), 1));
  3663.           if (GET_CODE (XEXP (XEXP (SET_SRC (body), 0), 0)) == AND)
  3664.         arm_current_cc = ARM_INVERSE_CONDITION_CODE (arm_current_cc);
  3665.           if (GET_CODE (XEXP (SET_SRC (body), 0)) == NE)
  3666.         arm_current_cc = ARM_INVERSE_CONDITION_CODE (arm_current_cc);
  3667.         }
  3668.       else
  3669.         {
  3670.           /* If REVERSE is true, ARM_CURRENT_CC needs to be inverted from
  3671.          what it was.  */
  3672.           if (!reverse)
  3673.         arm_current_cc = get_arm_condition_code (XEXP (SET_SRC (body),
  3674.                                    0));
  3675.         }
  3676.  
  3677.       if (reverse || then_not_else)
  3678.         arm_current_cc = ARM_INVERSE_CONDITION_CODE (arm_current_cc);
  3679.     }
  3680.       /* restore recog_operand (getting the attributes of other insns can
  3681.      destroy this array, but final.c assumes that it remains intact
  3682.      accross this call; since the insn has been recognized already we
  3683.      call recog direct). */
  3684.       recog (PATTERN (insn), insn, NULL_PTR);
  3685.     }
  3686. }
  3687.  
  3688. /* EOF */
  3689.