home *** CD-ROM | disk | FTP | other *** search
/ OpenStep 4.2J (Developer) / os42jdev.iso / NextDeveloper / Source / GNU / gcc / config / m68k / m68k.c < prev    next >
C/C++ Source or Header  |  1996-06-12  |  70KB  |  2,658 lines

  1. /* Subroutines for insn-output.c for Motorola 68000 family.
  2.    Copyright (C) 1987, 1993, 1994, 1995 Free Software Foundation, Inc.
  3.  
  4. This file is part of GNU CC.
  5.  
  6. GNU CC is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 2, or (at your option)
  9. any later version.
  10.  
  11. GNU CC is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. GNU General Public License for more details.
  15.  
  16. You should have received a copy of the GNU General Public License
  17. along with GNU CC; see the file COPYING.  If not, write to
  18. the Free Software Foundation, 59 Temple Place - Suite 330,
  19. Boston, MA 02111-1307, USA.  */
  20.  
  21.  
  22. /* Some output-actions in m68k.md need these.  */
  23. #include <stdio.h>
  24. #include "config.h"
  25. #include "rtl.h"
  26. #ifdef NEXT_SEMANTICS
  27. #include "tree.h"
  28. #include "next/machopic.h"
  29. #endif
  30. #include "regs.h"
  31. #include "hard-reg-set.h"
  32. #include "real.h"
  33. #include "insn-config.h"
  34. #include "conditions.h"
  35. #include "insn-flags.h"
  36. #include "output.h"
  37. #include "insn-attr.h"
  38.  
  39. /* Needed for use_return_insn.  */
  40. #include "flags.h"
  41.  
  42. #ifdef SUPPORT_SUN_FPA
  43.  
  44. /* Index into this array by (register number >> 3) to find the
  45.    smallest class which contains that register.  */
  46. enum reg_class regno_reg_class[]
  47.   = { DATA_REGS, ADDR_REGS, FP_REGS,
  48.       LO_FPA_REGS, LO_FPA_REGS, FPA_REGS, FPA_REGS };
  49.  
  50. #endif /* defined SUPPORT_SUN_FPA */
  51.  
  52. /* This flag is used to communicate between movhi and ASM_OUTPUT_CASE_END,
  53.    if SGS_SWITCH_TABLE.  */
  54. int switch_table_difference_label_flag;
  55.  
  56. static rtx find_addr_reg ();
  57. rtx legitimize_pic_address ();
  58.  
  59.  
  60. /* Emit a (use pic_offset_table_rtx) if we used PIC relocation in the 
  61.    function at any time during the compilation process.  In the future 
  62.    we should try and eliminate the USE if we can easily determine that 
  63.    all PIC references were deleted from the current function.  That would 
  64.    save an address register */
  65.    
  66. void
  67. finalize_pic ()
  68. {
  69. #ifdef MACHO_PIC
  70.   if (const_double_used())
  71.     current_function_uses_pic_offset_table |= 1;
  72. #endif
  73.   if (flag_pic && current_function_uses_pic_offset_table)
  74.     {
  75.       rtx insn = gen_rtx (USE, VOIDmode, pic_offset_table_rtx);
  76.       emit_insn_after (insn, get_insns ());
  77.       emit_insn (insn);
  78.     }
  79. }
  80.  
  81.  
  82. /* This function generates the assembly code for function entry.
  83.    STREAM is a stdio stream to output the code to.
  84.    SIZE is an int: how many units of temporary storage to allocate.
  85.    Refer to the array `regs_ever_live' to determine which registers
  86.    to save; `regs_ever_live[I]' is nonzero if register number I
  87.    is ever used in the function.  This function is responsible for
  88.    knowing which registers should not be saved even if used.  */
  89.  
  90.  
  91. /* Note that the order of the bit mask for fmovem is the opposite
  92.    of the order for movem!  */
  93.  
  94.  
  95. void
  96. output_function_prologue (stream, size)
  97.      FILE *stream;
  98.      int size;
  99. {
  100.   register int regno;
  101.   register int mask = 0;
  102.   int num_saved_regs = 0;
  103.   extern char call_used_regs[];
  104.   int fsize = (size + 3) & -4;
  105.   
  106.  
  107.   if (frame_pointer_needed)
  108.     {
  109.       if (fsize == 0 && TARGET_68040)
  110.     {
  111.     /* on the 68040, pea + move is faster than link.w 0 */
  112. #ifdef MOTOROLA
  113.       asm_fprintf (stream, "\tpea (%s)\n\tmove.l %s,%s\n",
  114.            reg_names[FRAME_POINTER_REGNUM], reg_names[STACK_POINTER_REGNUM],
  115.            reg_names[FRAME_POINTER_REGNUM]);
  116. #else
  117.       asm_fprintf (stream, "\tpea %s@\n\tmovel %s,%s\n",
  118.            reg_names[FRAME_POINTER_REGNUM], reg_names[STACK_POINTER_REGNUM],
  119.            reg_names[FRAME_POINTER_REGNUM]);
  120. #endif
  121.     }
  122.       else if (fsize < 0x8000)
  123.     {
  124. #ifdef MOTOROLA
  125.       asm_fprintf (stream, "\tlink.w %s,%0I%d\n",
  126.                reg_names[FRAME_POINTER_REGNUM], -fsize);
  127. #else
  128.       asm_fprintf (stream, "\tlink %s,%0I%d\n",
  129.                reg_names[FRAME_POINTER_REGNUM], -fsize);
  130. #endif
  131.     }
  132.       else if (TARGET_68020)
  133.     {
  134. #ifdef MOTOROLA
  135.       asm_fprintf (stream, "\tlink.l %s,%0I%d\n",
  136.                reg_names[FRAME_POINTER_REGNUM], -fsize);
  137. #else
  138.       asm_fprintf (stream, "\tlink %s,%0I%d\n",
  139.                reg_names[FRAME_POINTER_REGNUM], -fsize);
  140. #endif
  141.     }
  142.       else
  143.     {
  144.       /* Adding negative number is faster on the 68040.  */
  145. #ifdef MOTOROLA
  146.       asm_fprintf (stream, "\tlink.w %s,%0I0\n\tadd.l %0I%d,%Rsp\n",
  147.                reg_names[FRAME_POINTER_REGNUM], -fsize);
  148. #else
  149.       asm_fprintf (stream, "\tlink %s,%0I0\n\taddl %0I%d,%Rsp\n",
  150.                reg_names[FRAME_POINTER_REGNUM], -fsize);
  151. #endif
  152.     }
  153.     }
  154.   else if (fsize)
  155.     {
  156.       /* Adding negative number is faster on the 68040.  */
  157.       if (fsize + 4 < 0x8000)
  158.     {
  159.     /* asm_fprintf() cannot handle %. */
  160. #ifdef MOTOROLA
  161.       asm_fprintf (stream, "\tadd.w %0I%d,%Rsp\n", - (fsize + 4));
  162. #else
  163.       asm_fprintf (stream, "\taddw %0I%d,%Rsp\n", - (fsize + 4));
  164. #endif
  165.     }
  166.       else
  167.     {
  168.     /* asm_fprintf() cannot handle %. */
  169. #ifdef MOTOROLA
  170.       asm_fprintf (stream, "\tadd.l %0I%d,%Rsp\n", - (fsize + 4));
  171. #else
  172.       asm_fprintf (stream, "\taddl %0I%d,%Rsp\n", - (fsize + 4));
  173. #endif
  174.     }
  175.     }
  176. #ifdef SUPPORT_SUN_FPA
  177.   for (regno = 24; regno < 56; regno++)
  178.     if (regs_ever_live[regno] && ! call_used_regs[regno])
  179.       {
  180. #ifdef MOTOROLA
  181.     asm_fprintf (stream, "\tfpmovd %s,-(%Rsp)\n",
  182.              reg_names[regno]);
  183. #else
  184.     asm_fprintf (stream, "\tfpmoved %s,%Rsp@-\n",
  185.              reg_names[regno]);
  186. #endif
  187.       }
  188. #endif
  189.   for (regno = 16; regno < 24; regno++)
  190.     if (regs_ever_live[regno] && ! call_used_regs[regno])
  191.        mask |= 1 << (regno - 16);
  192.   if ((mask & 0xff) != 0)
  193.     {
  194. #ifdef MOTOROLA
  195.       asm_fprintf (stream, "\tfmovm %0I0x%x,-(%Rsp)\n", mask & 0xff);
  196. #else
  197.       asm_fprintf (stream, "\tfmovem %0I0x%x,%Rsp@-\n", mask & 0xff);
  198. #endif
  199.     }
  200.   mask = 0;
  201.   for (regno = 0; regno < 16; regno++)
  202.     if (regs_ever_live[regno] && ! call_used_regs[regno])
  203.       {
  204.         mask |= 1 << (15 - regno);
  205.         num_saved_regs++;
  206.       }
  207.   if (frame_pointer_needed)
  208.     {
  209.       mask &= ~ (1 << (15 - FRAME_POINTER_REGNUM));
  210.       num_saved_regs--;
  211.     }
  212.  
  213. #if NEED_PROBE
  214.   fprintf (stream, "\ttstl sp@(%d)\n", NEED_PROBE - num_saved_regs * 4);
  215. #endif
  216.  
  217.   if (num_saved_regs <= 2)
  218.     {
  219.       /* Store each separately in the same order moveml uses.
  220.          Using two movel instructions instead of a single moveml
  221.          is about 15% faster for the 68020 and 68030 at no expense
  222.          in code size */
  223.  
  224.       int i;
  225.  
  226.       /* Undo the work from above. */
  227.       for (i = 0; i< 16; i++)
  228.         if (mask & (1 << i))
  229.           asm_fprintf (stream,
  230. #ifdef MOTOROLA
  231.                "\t%Omove.l %s,-(%Rsp)\n",
  232. #else
  233.                "\tmovel %s,%Rsp@-\n",
  234. #endif
  235.                reg_names[15 - i]);
  236.     }
  237.   else if (mask)
  238.     {
  239. #ifdef MOTOROLA
  240.       asm_fprintf (stream, "\tmovm.l %0I0x%x,-(%Rsp)\n", mask);
  241. #else
  242.       asm_fprintf (stream, "\tmoveml %0I0x%x,%Rsp@-\n", mask);
  243. #endif
  244.     }
  245.   if (flag_pic && current_function_uses_pic_offset_table)
  246.     {
  247. #ifdef MACHO_PIC
  248.       assemble_name (stream, machopic_function_base_name ());
  249.       asm_fprintf (stream, ":\n\tlea %Rpc@(-2),%s\n",
  250.            reg_names[PIC_OFFSET_TABLE_REGNUM]);
  251. #else
  252. #ifdef MOTOROLA
  253.       asm_fprintf (stream, "\t%Olea (%Rpc, %U_GLOBAL_OFFSET_TABLE_@GOTPC), %s\n",
  254.            reg_names[PIC_OFFSET_TABLE_REGNUM]);
  255. #else
  256.       asm_fprintf (stream, "\tmovel %0I__GLOBAL_OFFSET_TABLE_, %s\n",
  257.            reg_names[PIC_OFFSET_TABLE_REGNUM]);
  258.       asm_fprintf (stream, "\tlea %Rpc@(0,%s:l),%s\n",
  259.            reg_names[PIC_OFFSET_TABLE_REGNUM],
  260.            reg_names[PIC_OFFSET_TABLE_REGNUM]);
  261. #endif
  262. #endif
  263.     }
  264. }
  265.  
  266. /* Return true if this function's epilogue can be output as RTL.  */
  267.  
  268. int
  269. use_return_insn ()
  270. {
  271.   int regno;
  272.  
  273.   if (!reload_completed || frame_pointer_needed || get_frame_size () != 0)
  274.     return 0;
  275.   
  276.   /* Copied from output_function_epilogue ().  We should probably create a
  277.      separate layout routine to perform the common work.  */
  278.   
  279.   for (regno = 0 ; regno < FIRST_PSEUDO_REGISTER ; regno++)
  280.     if (regs_ever_live[regno] && ! call_used_regs[regno])
  281.       return 0;
  282.   
  283.   return 1;
  284. }
  285.  
  286. /* This function generates the assembly code for function exit,
  287.    on machines that need it.  Args are same as for FUNCTION_PROLOGUE.
  288.  
  289.    The function epilogue should not depend on the current stack pointer!
  290.    It should use the frame pointer only, if there is a frame pointer.
  291.    This is mandatory because of alloca; we also take advantage of it to
  292.    omit stack adjustments before returning.  */
  293.  
  294. void
  295. output_function_epilogue (stream, size)
  296.      FILE *stream;
  297.      int size;
  298. {
  299.   register int regno;
  300.   register int mask, fmask;
  301.   register int nregs;
  302.   int offset, foffset, fpoffset;
  303.   extern char call_used_regs[];
  304.   int fsize = (size + 3) & -4;
  305.   int big = 0;
  306.   rtx insn = get_last_insn ();
  307.   
  308.   /* If the last insn was a BARRIER, we don't have to write any code.  */
  309.   if (GET_CODE (insn) == NOTE)
  310.     insn = prev_nonnote_insn (insn);
  311.   if (insn && GET_CODE (insn) == BARRIER)
  312.     {
  313.       /* Output just a no-op so that debuggers don't get confused
  314.      about which function the pc is in at this address.  */
  315.       asm_fprintf (stream, "\tnop\n");
  316.       return;
  317.     }
  318.  
  319. #ifdef FUNCTION_EXTRA_EPILOGUE
  320.   FUNCTION_EXTRA_EPILOGUE (stream, size);
  321. #endif
  322.   nregs = 0;  fmask = 0; fpoffset = 0;
  323. #ifdef SUPPORT_SUN_FPA
  324.   for (regno = 24 ; regno < 56 ; regno++)
  325.     if (regs_ever_live[regno] && ! call_used_regs[regno])
  326.       nregs++;
  327.   fpoffset = nregs * 8;
  328. #endif
  329.   nregs = 0;
  330.   for (regno = 16; regno < 24; regno++)
  331.     if (regs_ever_live[regno] && ! call_used_regs[regno])
  332.       {
  333.         nregs++;
  334.     fmask |= 1 << (23 - regno);
  335.       }
  336.   foffset = fpoffset + nregs * 12;
  337.   nregs = 0;  mask = 0;
  338.   if (frame_pointer_needed)
  339.     regs_ever_live[FRAME_POINTER_REGNUM] = 0;
  340.   for (regno = 0; regno < 16; regno++)
  341.     if (regs_ever_live[regno] && ! call_used_regs[regno])
  342.       {
  343.         nregs++;
  344.     mask |= 1 << regno;
  345.       }
  346.   offset = foffset + nregs * 4;
  347.   if (offset + fsize >= 0x8000
  348.       && frame_pointer_needed
  349.       && (mask || fmask || fpoffset))
  350.     {
  351. #ifdef MOTOROLA
  352.       asm_fprintf (stream, "\t%Omove.l %0I%d,%Ra1\n", -fsize);
  353. #else
  354.       asm_fprintf (stream, "\tmovel %0I%d,%Ra1\n", -fsize);
  355. #endif
  356.       fsize = 0, big = 1;
  357.     }
  358.   if (nregs <= 2)
  359.     {
  360.       /* Restore each separately in the same order moveml does.
  361.          Using two movel instructions instead of a single moveml
  362.          is about 15% faster for the 68020 and 68030 at no expense
  363.          in code size. */
  364.  
  365.       int i;
  366.  
  367.       /* Undo the work from above. */
  368.       for (i = 0; i< 16; i++)
  369.         if (mask & (1 << i))
  370.           {
  371.             if (big)
  372.           {
  373. #ifdef MOTOROLA
  374.         asm_fprintf (stream, "\t%Omove.l -%d(%s,%Ra1.l),%s\n",
  375.                  offset + fsize,
  376.                  reg_names[FRAME_POINTER_REGNUM],
  377.                  reg_names[i]);
  378. #else
  379.         asm_fprintf (stream, "\tmovel %s@(-%d,%Ra1:l),%s\n",
  380.                  reg_names[FRAME_POINTER_REGNUM],
  381.                  offset + fsize, reg_names[i]);
  382. #endif
  383.           }
  384.             else if (! frame_pointer_needed)
  385.           {
  386. #ifdef MOTOROLA
  387.         asm_fprintf (stream, "\t%Omove.l (%Rsp)+,%s\n",
  388.                  reg_names[i]);
  389. #else
  390.         asm_fprintf (stream, "\tmovel %Rsp@+,%s\n",
  391.                  reg_names[i]);
  392. #endif
  393.           }
  394.             else
  395.           {
  396. #ifdef MOTOROLA
  397.         asm_fprintf (stream, "\t%Omove.l -%d(%s),%s\n",
  398.                  offset + fsize,
  399.                  reg_names[FRAME_POINTER_REGNUM],
  400.                  reg_names[i]);
  401. #else
  402.         asm_fprintf (stream, "\tmovel %s@(-%d),%s\n",
  403.                  reg_names[FRAME_POINTER_REGNUM],
  404.                  offset + fsize, reg_names[i]);
  405. #endif
  406.           }
  407.             offset = offset - 4;
  408.           }
  409.     }
  410.   else if (mask)
  411.     {
  412.       if (big)
  413.     {
  414. #ifdef MOTOROLA
  415.       asm_fprintf (stream, "\tmovm.l -%d(%s,%Ra1.l),%0I0x%x\n",
  416.                offset + fsize,
  417.                reg_names[FRAME_POINTER_REGNUM],
  418.                mask);
  419. #else
  420.       asm_fprintf (stream, "\tmoveml %s@(-%d,%Ra1:l),%0I0x%x\n",
  421.                reg_names[FRAME_POINTER_REGNUM],
  422.                offset + fsize, mask);
  423. #endif
  424.     }
  425.       else if (! frame_pointer_needed)
  426.     {
  427. #ifdef MOTOROLA
  428.       asm_fprintf (stream, "\tmovm.l (%Rsp)+,%0I0x%x\n", mask);
  429. #else
  430.       asm_fprintf (stream, "\tmoveml %Rsp@+,%0I0x%x\n", mask);
  431. #endif
  432.     }
  433.       else
  434.     {
  435. #ifdef MOTOROLA
  436.       asm_fprintf (stream, "\tmovm.l -%d(%s),%0I0x%x\n",
  437.                offset + fsize,
  438.                reg_names[FRAME_POINTER_REGNUM],
  439.                mask);
  440. #else
  441.       asm_fprintf (stream, "\tmoveml %s@(-%d),%0I0x%x\n",
  442.                reg_names[FRAME_POINTER_REGNUM],
  443.                offset + fsize, mask);
  444. #endif
  445.     }
  446.     }
  447.   if (fmask)
  448.     {
  449.       if (big)
  450.     {
  451. #ifdef MOTOROLA
  452.       asm_fprintf (stream, "\tfmovm -%d(%s,%Ra1.l),%0I0x%x\n",
  453.                foffset + fsize,
  454.                reg_names[FRAME_POINTER_REGNUM],
  455.                fmask);
  456. #else
  457.       asm_fprintf (stream, "\tfmovem %s@(-%d,%Ra1:l),%0I0x%x\n",
  458.                reg_names[FRAME_POINTER_REGNUM],
  459.                foffset + fsize, fmask);
  460. #endif
  461.     }
  462.       else if (! frame_pointer_needed)
  463.     {
  464. #ifdef MOTOROLA
  465.       asm_fprintf (stream, "\tfmovm (%Rsp)+,%0I0x%x\n", fmask);
  466. #else
  467.       asm_fprintf (stream, "\tfmovem %Rsp@+,%0I0x%x\n", fmask);
  468. #endif
  469.     }
  470.       else
  471.     {
  472. #ifdef MOTOROLA
  473.       asm_fprintf (stream, "\tfmovm -%d(%s),%0I0x%x\n",
  474.                foffset + fsize,
  475.                reg_names[FRAME_POINTER_REGNUM],
  476.                fmask);
  477. #else
  478.       asm_fprintf (stream, "\tfmovem %s@(-%d),%0I0x%x\n",
  479.                reg_names[FRAME_POINTER_REGNUM],
  480.                foffset + fsize, fmask);
  481. #endif
  482.     }
  483.     }
  484.   if (fpoffset != 0)
  485.     for (regno = 55; regno >= 24; regno--)
  486.       if (regs_ever_live[regno] && ! call_used_regs[regno])
  487.         {
  488.       if (big)
  489.         {
  490. #ifdef MOTOROLA
  491.           asm_fprintf (stream, "\tfpmovd -%d(%s,%Ra1.l), %s\n",
  492.                fpoffset + fsize,
  493.                reg_names[FRAME_POINTER_REGNUM],
  494.                reg_names[regno]);
  495. #else
  496.           asm_fprintf (stream, "\tfpmoved %s@(-%d,%Ra1:l), %s\n",
  497.                reg_names[FRAME_POINTER_REGNUM],
  498.                fpoffset + fsize, reg_names[regno]);
  499. #endif
  500.         }
  501.       else if (! frame_pointer_needed)
  502.         {
  503. #ifdef MOTOROLA
  504.           asm_fprintf (stream, "\tfpmovd (%Rsp)+,%s\n",
  505.                reg_names[regno]);
  506. #else
  507.           asm_fprintf (stream, "\tfpmoved %Rsp@+, %s\n",
  508.                reg_names[regno]);
  509. #endif
  510.         }
  511.       else
  512.         {
  513. #ifdef MOTOROLA
  514.           asm_fprintf (stream, "\tfpmovd -%d(%s), %s\n",
  515.                fpoffset + fsize,
  516.                reg_names[FRAME_POINTER_REGNUM],
  517.                reg_names[regno]);
  518. #else
  519.           asm_fprintf (stream, "\tfpmoved %s@(-%d), %s\n",
  520.                reg_names[FRAME_POINTER_REGNUM],
  521.                fpoffset + fsize, reg_names[regno]);
  522. #endif
  523.         }
  524.       fpoffset -= 8;
  525.     }
  526.   if (frame_pointer_needed)
  527.     fprintf (stream, "\tunlk %s\n",
  528.          reg_names[FRAME_POINTER_REGNUM]);
  529.   else if (fsize)
  530.     {
  531.       if (fsize + 4 < 0x8000)
  532.     {
  533.     /* asm_fprintf() cannot handle %. */
  534. #ifdef MOTOROLA
  535.       asm_fprintf (stream, "\tadd.w %0I%d,%Rsp\n", fsize + 4);
  536. #else
  537.       asm_fprintf (stream, "\taddw %0I%d,%Rsp\n", fsize + 4);
  538. #endif
  539.     }
  540.       else
  541.     {
  542.     /* asm_fprintf() cannot handle %. */
  543. #ifdef MOTOROLA
  544.       asm_fprintf (stream, "\tadd.l %0I%d,%Rsp\n", fsize + 4);
  545. #else
  546.       asm_fprintf (stream, "\taddl %0I%d,%Rsp\n", fsize + 4);
  547. #endif
  548.     }
  549.     }
  550.   if (current_function_pops_args)
  551.     asm_fprintf (stream, "\trtd %0I%d\n", current_function_pops_args);
  552.   else
  553.     fprintf (stream, "\trts\n");
  554. }
  555.  
  556. /* Similar to general_operand, but exclude stack_pointer_rtx.  */
  557.  
  558. int
  559. not_sp_operand (op, mode)
  560.      register rtx op;
  561.      enum machine_mode mode;
  562. {
  563.   return op != stack_pointer_rtx && general_operand (op, mode);
  564. }
  565.  
  566. /* Return TRUE if X is a valid comparison operator for the dbcc 
  567.    instruction.  
  568.  
  569.    Note it rejects floating point comparison operators.
  570.    (In the future we could use Fdbcc).
  571.  
  572.    It also rejects some comparisons when CC_NO_OVERFLOW is set.  */
  573.    
  574. int
  575. valid_dbcc_comparison_p (x, mode)
  576.      rtx x;
  577.      enum machine_mode mode;
  578. {
  579.   /* We could add support for these in the future */
  580.   if (cc_prev_status.flags & CC_IN_68881)
  581.     return 0;
  582.  
  583.   switch (GET_CODE (x))
  584.     {
  585.  
  586.       case EQ: case NE: case GTU: case LTU:
  587.       case GEU: case LEU:
  588.         return 1;
  589.  
  590.       /* Reject some when CC_NO_OVERFLOW is set.  This may be over
  591.          conservative */
  592.       case GT: case LT: case GE: case LE:
  593.         return ! (cc_prev_status.flags & CC_NO_OVERFLOW);
  594.       default:
  595.         return 0;
  596.     }
  597. }
  598.  
  599. /* Output a dbCC; jCC sequence.  Note we do not handle the 
  600.    floating point version of this sequence (Fdbcc).  We also
  601.    do not handle alternative conditions when CC_NO_OVERFLOW is
  602.    set.  It is assumed that valid_dbcc_comparison_p will kick
  603.    those out before we get here.  */
  604.  
  605. output_dbcc_and_branch (operands)
  606.      rtx *operands;
  607. {
  608.  
  609.   switch (GET_CODE (operands[3]))
  610.     {
  611.       case EQ:
  612. #ifdef MOTOROLA
  613.         output_asm_insn ("dbeq %0,%l1\n\tjbeq %l2", operands);
  614. #else
  615.         output_asm_insn ("dbeq %0,%l1\n\tjeq %l2", operands);
  616. #endif
  617.         break;
  618.  
  619.       case NE:
  620. #ifdef MOTOROLA
  621.         output_asm_insn ("dbne %0,%l1\n\tjbne %l2", operands);
  622. #else
  623.         output_asm_insn ("dbne %0,%l1\n\tjne %l2", operands);
  624. #endif
  625.         break;
  626.  
  627.       case GT:
  628. #ifdef MOTOROLA
  629.         output_asm_insn ("dbgt %0,%l1\n\tjbgt %l2", operands);
  630. #else
  631.         output_asm_insn ("dbgt %0,%l1\n\tjgt %l2", operands);
  632. #endif
  633.         break;
  634.  
  635.       case GTU:
  636. #ifdef MOTOROLA
  637.         output_asm_insn ("dbhi %0,%l1\n\tjbhi %l2", operands);
  638. #else
  639.         output_asm_insn ("dbhi %0,%l1\n\tjhi %l2", operands);
  640. #endif
  641.         break;
  642.  
  643.       case LT:
  644. #ifdef MOTOROLA
  645.         output_asm_insn ("dblt %0,%l1\n\tjblt %l2", operands);
  646. #else
  647.         output_asm_insn ("dblt %0,%l1\n\tjlt %l2", operands);
  648. #endif
  649.         break;
  650.  
  651.       case LTU:
  652. #ifdef MOTOROLA
  653.         output_asm_insn ("dbcs %0,%l1\n\tjbcs %l2", operands);
  654. #else
  655.         output_asm_insn ("dbcs %0,%l1\n\tjcs %l2", operands);
  656. #endif
  657.         break;
  658.  
  659.       case GE:
  660. #ifdef MOTOROLA
  661.         output_asm_insn ("dbge %0,%l1\n\tjbge %l2", operands);
  662. #else
  663.         output_asm_insn ("dbge %0,%l1\n\tjge %l2", operands);
  664. #endif
  665.         break;
  666.  
  667.       case GEU:
  668. #ifdef MOTOROLA
  669.         output_asm_insn ("dbcc %0,%l1\n\tjbcc %l2", operands);
  670. #else
  671.         output_asm_insn ("dbcc %0,%l1\n\tjcc %l2", operands);
  672. #endif
  673.         break;
  674.  
  675.       case LE:
  676. #ifdef MOTOROLA
  677.         output_asm_insn ("dble %0,%l1\n\tjble %l2", operands);
  678. #else
  679.         output_asm_insn ("dble %0,%l1\n\tjle %l2", operands);
  680. #endif
  681.         break;
  682.  
  683.       case LEU:
  684. #ifdef MOTOROLA
  685.         output_asm_insn ("dbls %0,%l1\n\tjbls %l2", operands);
  686. #else
  687.         output_asm_insn ("dbls %0,%l1\n\tjls %l2", operands);
  688. #endif
  689.         break;
  690.  
  691.       default:
  692.     abort ();
  693.     }
  694.  
  695.   /* If the decrement is to be done in SImode, then we have
  696.      to compensate for the fact that dbcc decrements in HImode. */
  697.   switch (GET_MODE (operands[0]))
  698.     {
  699.       case SImode:
  700. #ifdef MOTOROLA
  701.         output_asm_insn ("clr%.w %0\n\tsubq%.l %#1,%0\n\tjbpl %l1", operands);
  702. #else
  703.         output_asm_insn ("clr%.w %0\n\tsubq%.l %#1,%0\n\tjpl %l1", operands);
  704. #endif
  705.         break;
  706.  
  707.       case HImode:
  708.         break;
  709.  
  710.       default:
  711.         abort ();
  712.     }
  713. }
  714.  
  715. char *
  716. output_scc_di(op, operand1, operand2, dest)
  717.      rtx op;
  718.      rtx operand1;
  719.      rtx operand2;
  720.      rtx dest;
  721. {
  722.   rtx loperands[7];
  723.   enum rtx_code op_code = GET_CODE (op);
  724.  
  725.   /* The m68k cmp.l instruction requires operand1 to be a reg as used
  726.      below.  Swap the operands and change the op if these requirements
  727.      are not fulfilled.  */
  728.   if (GET_CODE (operand2) == REG && GET_CODE (operand1) != REG)
  729.     {
  730.       rtx tmp = operand1;
  731.  
  732.       operand1 = operand2;
  733.       operand2 = tmp;
  734.       op_code = swap_condition (op_code);
  735.     }
  736.   loperands[0] = operand1;
  737.   if (GET_CODE (operand1) == REG)
  738.     loperands[1] = gen_rtx (REG, SImode, REGNO (operand1) + 1);
  739.   else
  740.     loperands[1] = adj_offsettable_operand (operand1, 4);
  741.   if (operand2 != const0_rtx)
  742.     {
  743.       loperands[2] = operand2;
  744.       if (GET_CODE (operand2) == REG)
  745.     loperands[3] = gen_rtx (REG, SImode, REGNO (operand2) + 1);
  746.       else
  747.     loperands[3] = adj_offsettable_operand (operand2, 4);
  748.     }
  749.   loperands[4] = gen_label_rtx();
  750.   if (operand2 != const0_rtx)
  751. #ifdef MOTOROLA
  752. #ifdef SGS_CMP_ORDER
  753.     output_asm_insn ("cmp%.l %0,%2\n\tjbne %l4\n\tcmp%.l %1,%3", loperands);
  754. #else
  755.     output_asm_insn ("cmp%.l %2,%0\n\tjbne %l4\n\tcmp%.l %3,%1", loperands);
  756. #endif
  757. #else
  758. #ifdef SGS_CMP_ORDER
  759.     output_asm_insn ("cmp%.l %0,%2\n\tjne %l4\n\tcmp%.l %1,%3", loperands);
  760. #else
  761.     output_asm_insn ("cmp%.l %2,%0\n\tjne %l4\n\tcmp%.l %3,%1", loperands);
  762. #endif
  763. #endif
  764.   else
  765. #ifdef MOTOROLA
  766.     output_asm_insn ("tst%.l %0\n\tjbne %l4\n\ttst%.l %1", loperands);
  767. #else
  768.     output_asm_insn ("tst%.l %0\n\tjne %l4\n\ttst%.l %1", loperands);
  769. #endif
  770.   loperands[5] = dest;
  771.   
  772.   switch (op_code)
  773.     {
  774.       case EQ:
  775.         ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "L",
  776.                     CODE_LABEL_NUMBER (loperands[4]));
  777.         output_asm_insn ("seq %5", loperands);
  778.         break;
  779.  
  780.       case NE:
  781.         ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "L",
  782.                     CODE_LABEL_NUMBER (loperands[4]));
  783.         output_asm_insn ("sne %5", loperands);
  784.         break;
  785.  
  786.       case GT:
  787.         loperands[6] = gen_label_rtx();
  788. #ifdef MOTOROLA
  789.         output_asm_insn ("shi %5\n\tjbra %l6", loperands);
  790. #else
  791.         output_asm_insn ("shi %5\n\tjra %l6", loperands);
  792. #endif
  793.         ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "L",
  794.                     CODE_LABEL_NUMBER (loperands[4]));
  795.         output_asm_insn ("sgt %5", loperands);
  796.         ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "L",
  797.                     CODE_LABEL_NUMBER (loperands[6]));
  798.         break;
  799.  
  800.       case GTU:
  801.         ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "L",
  802.                     CODE_LABEL_NUMBER (loperands[4]));
  803.         output_asm_insn ("shi %5", loperands);
  804.         break;
  805.  
  806.       case LT:
  807.         loperands[6] = gen_label_rtx();
  808. #ifdef MOTOROLA
  809.         output_asm_insn ("scs %5\n\tjbra %l6", loperands);
  810. #else
  811.         output_asm_insn ("scs %5\n\tjra %l6", loperands);
  812. #endif
  813.         ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "L",
  814.                     CODE_LABEL_NUMBER (loperands[4]));
  815.         output_asm_insn ("slt %5", loperands);
  816.         ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "L",
  817.                     CODE_LABEL_NUMBER (loperands[6]));
  818.         break;
  819.  
  820.       case LTU:
  821.         ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "L",
  822.                     CODE_LABEL_NUMBER (loperands[4]));
  823.         output_asm_insn ("scs %5", loperands);
  824.         break;
  825.  
  826.       case GE:
  827.         loperands[6] = gen_label_rtx();
  828. #ifdef MOTOROLA
  829.         output_asm_insn ("scc %5\n\tjbra %l6", loperands);
  830. #else
  831.         output_asm_insn ("scc %5\n\tjra %l6", loperands);
  832. #endif
  833.         ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "L",
  834.                     CODE_LABEL_NUMBER (loperands[4]));
  835.         output_asm_insn ("sge %5", loperands);
  836.         ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "L",
  837.                     CODE_LABEL_NUMBER (loperands[6]));
  838.         break;
  839.  
  840.       case GEU:
  841.         ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "L",
  842.                     CODE_LABEL_NUMBER (loperands[4]));
  843.         output_asm_insn ("scc %5", loperands);
  844.         break;
  845.  
  846.       case LE:
  847.         loperands[6] = gen_label_rtx();
  848. #ifdef MOTOROLA
  849.         output_asm_insn ("sls %5\n\tjbra %l6", loperands);
  850. #else
  851.         output_asm_insn ("sls %5\n\tjra %l6", loperands);
  852. #endif
  853.         ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "L",
  854.                     CODE_LABEL_NUMBER (loperands[4]));
  855.         output_asm_insn ("sle %5", loperands);
  856.         ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "L",
  857.                     CODE_LABEL_NUMBER (loperands[6]));
  858.         break;
  859.  
  860.       case LEU:
  861.         ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "L",
  862.                     CODE_LABEL_NUMBER (loperands[4]));
  863.         output_asm_insn ("sls %5", loperands);
  864.         break;
  865.  
  866.       default:
  867.     abort ();
  868.     }
  869.   return "";
  870. }
  871.  
  872. char *
  873. output_btst (operands, countop, dataop, insn, signpos)
  874.      rtx *operands;
  875.      rtx countop, dataop;
  876.      rtx insn;
  877.      int signpos;
  878. {
  879.   operands[0] = countop;
  880.   operands[1] = dataop;
  881.  
  882.   if (GET_CODE (countop) == CONST_INT)
  883.     {
  884.       register int count = INTVAL (countop);
  885.       /* If COUNT is bigger than size of storage unit in use,
  886.      advance to the containing unit of same size.  */
  887.       if (count > signpos)
  888.     {
  889.       int offset = (count & ~signpos) / 8;
  890.       count = count & signpos;
  891.       operands[1] = dataop = adj_offsettable_operand (dataop, offset);
  892.     }
  893.       if (count == signpos)
  894.     cc_status.flags = CC_NOT_POSITIVE | CC_Z_IN_NOT_N;
  895.       else
  896.     cc_status.flags = CC_NOT_NEGATIVE | CC_Z_IN_NOT_N;
  897.  
  898.       /* These three statements used to use next_insns_test_no...
  899.      but it appears that this should do the same job.  */
  900.       if (count == 31
  901.       && next_insn_tests_no_inequality (insn))
  902.     return "tst%.l %1";
  903.       if (count == 15
  904.       && next_insn_tests_no_inequality (insn))
  905.     return "tst%.w %1";
  906.       if (count == 7
  907.       && next_insn_tests_no_inequality (insn))
  908.     return "tst%.b %1";
  909.  
  910.       cc_status.flags = CC_NOT_NEGATIVE;
  911.     }
  912.   return "btst %0,%1";
  913. }
  914.  
  915. /* Returns 1 if OP is either a symbol reference or a sum of a symbol
  916.    reference and a constant.  */
  917.  
  918. int
  919. symbolic_operand (op, mode)
  920.      register rtx op;
  921.      enum machine_mode mode;
  922. {
  923.   switch (GET_CODE (op))
  924.     {
  925.     case SYMBOL_REF:
  926.     case LABEL_REF:
  927.       return 1;
  928.  
  929.     case CONST:
  930.       op = XEXP (op, 0);
  931.       return ((GET_CODE (XEXP (op, 0)) == SYMBOL_REF
  932.            || GET_CODE (XEXP (op, 0)) == LABEL_REF)
  933. #ifdef NEXT_SEMANTICS
  934.           && GET_CODE (op) == PLUS
  935. #endif
  936.           && GET_CODE (XEXP (op, 1)) == CONST_INT);
  937.  
  938. #if 0 /* Deleted, with corresponding change in m68k.h,
  939.      so as to fit the specs.  No CONST_DOUBLE is ever symbolic.  */
  940.     case CONST_DOUBLE:
  941.       return GET_MODE (op) == mode;
  942. #endif
  943.  
  944.     default:
  945.       return 0;
  946.     }
  947. }
  948.  
  949. /* Check for sign_extend or zero_extend.  Used for bit-count operands. */
  950.  
  951. int
  952. extend_operator(x, mode)
  953.      rtx x;
  954.      enum machine_mode mode;
  955. {
  956.     if (mode != VOIDmode && GET_MODE(x) != mode)
  957.     return 0;
  958.     switch (GET_CODE(x))
  959.     {
  960.     case SIGN_EXTEND :
  961.     case ZERO_EXTEND :
  962.         return 1;
  963.     default :
  964.         return 0;
  965.     }
  966. }
  967.  
  968.  
  969. /* Legitimize PIC addresses.  If the address is already
  970.    position-independent, we return ORIG.  Newly generated
  971.    position-independent addresses go to REG.  If we need more
  972.    than one register, we lose.  
  973.  
  974.    An address is legitimized by making an indirect reference
  975.    through the Global Offset Table with the name of the symbol
  976.    used as an offset.  
  977.  
  978.    The assembler and linker are responsible for placing the 
  979.    address of the symbol in the GOT.  The function prologue
  980.    is responsible for initializing a5 to the starting address
  981.    of the GOT.
  982.  
  983.    The assembler is also responsible for translating a symbol name
  984.    into a constant displacement from the start of the GOT.  
  985.  
  986.    A quick example may make things a little clearer:
  987.  
  988.    When not generating PIC code to store the value 12345 into _foo
  989.    we would generate the following code:
  990.  
  991.     movel #12345, _foo
  992.  
  993.    When generating PIC two transformations are made.  First, the compiler
  994.    loads the address of foo into a register.  So the first transformation makes:
  995.  
  996.     lea    _foo, a0
  997.     movel   #12345, a0@
  998.  
  999.    The code in movsi will intercept the lea instruction and call this
  1000.    routine which will transform the instructions into:
  1001.  
  1002.     movel   a5@(_foo:w), a0
  1003.     movel   #12345, a0@
  1004.    
  1005.  
  1006.    That (in a nutshell) is how *all* symbol and label references are 
  1007.    handled.  */
  1008.  
  1009. rtx
  1010. legitimize_pic_address (orig, mode, reg)
  1011.      rtx orig, reg;
  1012.      enum machine_mode mode;
  1013. {
  1014.   rtx pic_ref = orig;
  1015.  
  1016. #ifdef MACHO_PIC
  1017.   return machopic_legitimize_pic_address (orig, mode, reg);
  1018. #endif
  1019.  
  1020.   /* First handle a simple SYMBOL_REF or LABEL_REF */
  1021.   if (GET_CODE (orig) == SYMBOL_REF || GET_CODE (orig) == LABEL_REF)
  1022.     {
  1023.       if (reg == 0)
  1024.     abort ();
  1025.  
  1026.       pic_ref = gen_rtx (MEM, Pmode,
  1027.              gen_rtx (PLUS, Pmode,
  1028.                   pic_offset_table_rtx, orig));
  1029.       current_function_uses_pic_offset_table = 1;
  1030.       RTX_UNCHANGING_P (pic_ref) = 1;
  1031.       emit_move_insn (reg, pic_ref);
  1032.       return reg;
  1033.     }
  1034.   else if (GET_CODE (orig) == CONST)
  1035.     {
  1036.       rtx base, offset;
  1037.  
  1038.       /* Make sure this is CONST has not already been legitimized */
  1039.       if (GET_CODE (XEXP (orig, 0)) == PLUS
  1040.       && XEXP (XEXP (orig, 0), 0) == pic_offset_table_rtx)
  1041.     return orig;
  1042.  
  1043.       if (reg == 0)
  1044.     abort ();
  1045.  
  1046.       /* legitimize both operands of the PLUS */
  1047.       if (GET_CODE (XEXP (orig, 0)) == PLUS)
  1048.     {
  1049.       base = legitimize_pic_address (XEXP (XEXP (orig, 0), 0), Pmode, reg);
  1050.       orig = legitimize_pic_address (XEXP (XEXP (orig, 0), 1), Pmode,
  1051.                      base == reg ? 0 : reg);
  1052.     }
  1053.       else abort ();
  1054.  
  1055.       if (GET_CODE (orig) == CONST_INT)
  1056.     return plus_constant_for_output (base, INTVAL (orig));
  1057.       pic_ref = gen_rtx (PLUS, Pmode, base, orig);
  1058.       /* Likewise, should we set special REG_NOTEs here?  */
  1059.     }
  1060.   return pic_ref;
  1061. }
  1062.  
  1063.  
  1064. typedef enum { MOVL, SWAP, NEGW, NOTW, NOTB, MOVQ } CONST_METHOD;
  1065.  
  1066. use_movq (i)
  1067.      int i;
  1068. {
  1069.   return (i >= -128 && i <= 127);
  1070. }
  1071.  
  1072. CONST_METHOD
  1073. const_method (constant)
  1074.      rtx constant;
  1075. {
  1076.   int i;
  1077.   unsigned u;
  1078.  
  1079.   i = INTVAL (constant);
  1080.   if (use_movq (i))
  1081.     return MOVQ;
  1082.   /* if -256 < N < 256 but N is not in range for a moveq
  1083.      N^ff will be, so use moveq #N^ff, dreg; not.b dreg. */
  1084.   if (use_movq (i ^ 0xff))
  1085.     return NOTB;
  1086.   /* Likewise, try with not.w */
  1087.   if (use_movq (i ^ 0xffff))
  1088.     return NOTW;
  1089.   /* This is the only value where neg.w is useful */
  1090.   if (i == -65408)
  1091.     return NEGW;
  1092.   /* Try also with swap */
  1093.   u = i;
  1094.   if (use_movq ((u >> 16) | (u << 16)))
  1095.     return SWAP;
  1096.   /* Otherwise, use move.l */
  1097.   return MOVL;
  1098. }
  1099.  
  1100. const_int_cost (constant)
  1101.      rtx constant;
  1102. {
  1103.   switch (const_method (constant))
  1104.     {
  1105.       case MOVQ :
  1106.       /* Constants between -128 and 127 are cheap due to moveq */
  1107.     return 0;
  1108.       case NOTB :
  1109.       case NOTW :
  1110.       case NEGW :
  1111.       case SWAP :
  1112.       /* Constants easily generated by moveq + not.b/not.w/neg.w/swap  */
  1113.         return 1;
  1114.       case MOVL :
  1115.     return 2;
  1116.       default :
  1117.         abort ();
  1118.     }
  1119. }
  1120.  
  1121. char *
  1122. output_move_const_into_data_reg (operands)
  1123.      rtx *operands;
  1124. {
  1125.   int i;
  1126.  
  1127.   i = INTVAL (operands[1]);
  1128.   switch (const_method (operands[1]))
  1129.     {
  1130.     case MOVQ :
  1131. #if defined (MOTOROLA) && !defined (CRDS)
  1132.       return "moveq%.l %1,%0";
  1133. #else
  1134.       return "moveq %1,%0";
  1135. #endif
  1136.     case NOTB :
  1137.       operands[1] = gen_rtx (CONST_INT, VOIDmode, i ^ 0xff);
  1138. #if defined (MOTOROLA) && !defined (CRDS)
  1139.       return "moveq%.l %1,%0\n\tnot%.b %0";
  1140. #else
  1141.       return "moveq %1,%0\n\tnot%.b %0";
  1142. #endif     
  1143.     case NOTW :
  1144.       operands[1] = gen_rtx (CONST_INT, VOIDmode, i ^ 0xffff);
  1145. #if defined (MOTOROLA) && !defined (CRDS)
  1146.       return "moveq%.l %1,%0\n\tnot%.w %0";
  1147. #else
  1148.       return "moveq %1,%0\n\tnot%.w %0";
  1149. #endif     
  1150.     case NEGW :
  1151. #if defined (MOTOROLA) && !defined (CRDS)
  1152.       return "moveq%.l %#-128,%0\n\tneg%.w %0";
  1153. #else
  1154.       return "moveq %#-128,%0\n\tneg%.w %0";
  1155. #endif     
  1156.     case SWAP :
  1157.       {
  1158.     unsigned u = i;
  1159.  
  1160.     operands[1] = gen_rtx (CONST_INT, VOIDmode, (u << 16) | (u >> 16));
  1161. #if defined (MOTOROLA) && !defined (CRDS)
  1162.     return "moveq%.l %1,%0\n\tswap %0";
  1163. #else
  1164.     return "moveq %1,%0\n\tswap %0";
  1165. #endif     
  1166.       }
  1167.     case MOVL :
  1168.     return "move%.l %1,%0";
  1169.     default :
  1170.     abort ();
  1171.     }
  1172. }
  1173.  
  1174. /* Return the best assembler insn template
  1175.    for moving operands[1] into operands[0] as a fullword.  */
  1176.  
  1177. static char *
  1178. singlemove_string (operands)
  1179.      rtx *operands;
  1180. {
  1181. #ifdef SUPPORT_SUN_FPA
  1182.   if (FPA_REG_P (operands[0]) || FPA_REG_P (operands[1]))
  1183.     return "fpmoves %1,%0";
  1184. #endif
  1185.   if (DATA_REG_P (operands[0])
  1186.       && GET_CODE (operands[1]) == CONST_INT)
  1187.       return output_move_const_into_data_reg (operands);
  1188.   if (operands[1] != const0_rtx)
  1189.     return "move%.l %1,%0";
  1190.   if (! ADDRESS_REG_P (operands[0]))
  1191.     return "clr%.l %0";
  1192.   return "sub%.l %0,%0";
  1193. }
  1194.  
  1195.  
  1196. /* Output assembler code to perform a doubleword move insn
  1197.    with operands OPERANDS.  */
  1198.  
  1199. char *
  1200. output_move_double (operands)
  1201.      rtx *operands;
  1202. {
  1203.   enum
  1204.     {
  1205.       REGOP, OFFSOP, MEMOP, PUSHOP, POPOP, CNSTOP, RNDOP
  1206.     } optype0, optype1;
  1207.   rtx latehalf[2];
  1208.   rtx middlehalf[2];
  1209.   rtx xops[2];
  1210.   rtx addreg0 = 0, addreg1 = 0;
  1211.   int dest_overlapped_low = 0;
  1212.   int size = GET_MODE_SIZE (GET_MODE (operands[0]));
  1213.  
  1214.   middlehalf[0] = 0;
  1215.   middlehalf[1] = 0;
  1216.  
  1217.   /* First classify both operands.  */
  1218.  
  1219.   if (REG_P (operands[0]))
  1220.     optype0 = REGOP;
  1221.   else if (offsettable_memref_p (operands[0]))
  1222.     optype0 = OFFSOP;
  1223.   else if (GET_CODE (XEXP (operands[0], 0)) == POST_INC)
  1224.     optype0 = POPOP;
  1225.   else if (GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
  1226.     optype0 = PUSHOP;
  1227.   else if (GET_CODE (operands[0]) == MEM)
  1228.     optype0 = MEMOP;
  1229.   else
  1230.     optype0 = RNDOP;
  1231.  
  1232.   if (REG_P (operands[1]))
  1233.     optype1 = REGOP;
  1234.   else if (CONSTANT_P (operands[1]))
  1235.     optype1 = CNSTOP;
  1236.   else if (offsettable_memref_p (operands[1]))
  1237.     optype1 = OFFSOP;
  1238.   else if (GET_CODE (XEXP (operands[1], 0)) == POST_INC)
  1239.     optype1 = POPOP;
  1240.   else if (GET_CODE (XEXP (operands[1], 0)) == PRE_DEC)
  1241.     optype1 = PUSHOP;
  1242.   else if (GET_CODE (operands[1]) == MEM)
  1243.     optype1 = MEMOP;
  1244.   else
  1245.     optype1 = RNDOP;
  1246.  
  1247.   /* Check for the cases that the operand constraints are not
  1248.      supposed to allow to happen.  Abort if we get one,
  1249.      because generating code for these cases is painful.  */
  1250.  
  1251.   if (optype0 == RNDOP || optype1 == RNDOP)
  1252.     abort ();
  1253.  
  1254.   /* If one operand is decrementing and one is incrementing
  1255.      decrement the former register explicitly
  1256.      and change that operand into ordinary indexing.  */
  1257.  
  1258.   if (optype0 == PUSHOP && optype1 == POPOP)
  1259.     {
  1260.       operands[0] = XEXP (XEXP (operands[0], 0), 0);
  1261.       if (size == 12)
  1262.         output_asm_insn ("sub%.l %#12,%0", operands);
  1263.       else
  1264.         output_asm_insn ("subq%.l %#8,%0", operands);
  1265.       if (GET_MODE (operands[1]) == XFmode)
  1266.     operands[0] = gen_rtx (MEM, XFmode, operands[0]);
  1267.       else if (GET_MODE (operands[0]) == DFmode)
  1268.     operands[0] = gen_rtx (MEM, DFmode, operands[0]);
  1269.       else
  1270.     operands[0] = gen_rtx (MEM, DImode, operands[0]);
  1271.       optype0 = OFFSOP;
  1272.     }
  1273.   if (optype0 == POPOP && optype1 == PUSHOP)
  1274.     {
  1275.       operands[1] = XEXP (XEXP (operands[1], 0), 0);
  1276.       if (size == 12)
  1277.         output_asm_insn ("sub%.l %#12,%1", operands);
  1278.       else
  1279.         output_asm_insn ("subq%.l %#8,%1", operands);
  1280.       if (GET_MODE (operands[1]) == XFmode)
  1281.     operands[1] = gen_rtx (MEM, XFmode, operands[1]);
  1282.       else if (GET_MODE (operands[1]) == DFmode)
  1283.     operands[1] = gen_rtx (MEM, DFmode, operands[1]);
  1284.       else
  1285.     operands[1] = gen_rtx (MEM, DImode, operands[1]);
  1286.       optype1 = OFFSOP;
  1287.     }
  1288.  
  1289.   /* If an operand is an unoffsettable memory ref, find a register
  1290.      we can increment temporarily to make it refer to the second word.  */
  1291.  
  1292.   if (optype0 == MEMOP)
  1293.     addreg0 = find_addr_reg (XEXP (operands[0], 0));
  1294.  
  1295.   if (optype1 == MEMOP)
  1296.     addreg1 = find_addr_reg (XEXP (operands[1], 0));
  1297.  
  1298.   /* Ok, we can do one word at a time.
  1299.      Normally we do the low-numbered word first,
  1300.      but if either operand is autodecrementing then we
  1301.      do the high-numbered word first.
  1302.  
  1303.      In either case, set up in LATEHALF the operands to use
  1304.      for the high-numbered word and in some cases alter the
  1305.      operands in OPERANDS to be suitable for the low-numbered word.  */
  1306.  
  1307.   if (size == 12)
  1308.     {
  1309.       if (optype0 == REGOP)
  1310.     {
  1311.       latehalf[0] = gen_rtx (REG, SImode, REGNO (operands[0]) + 2);
  1312.       middlehalf[0] = gen_rtx (REG, SImode, REGNO (operands[0]) + 1);
  1313.     }
  1314.       else if (optype0 == OFFSOP)
  1315.     {
  1316.       middlehalf[0] = adj_offsettable_operand (operands[0], 4);
  1317.       latehalf[0] = adj_offsettable_operand (operands[0], size - 4);
  1318.     }
  1319.       else
  1320.     {
  1321.       middlehalf[0] = operands[0];
  1322.       latehalf[0] = operands[0];
  1323.     }
  1324.  
  1325.       if (optype1 == REGOP)
  1326.     {
  1327.       latehalf[1] = gen_rtx (REG, SImode, REGNO (operands[1]) + 2);
  1328.       middlehalf[1] = gen_rtx (REG, SImode, REGNO (operands[1]) + 1);
  1329.     }
  1330.       else if (optype1 == OFFSOP)
  1331.     {
  1332.       middlehalf[1] = adj_offsettable_operand (operands[1], 4);
  1333.       latehalf[1] = adj_offsettable_operand (operands[1], size - 4);
  1334.     }
  1335.       else if (optype1 == CNSTOP)
  1336.     {
  1337.       if (GET_CODE (operands[1]) == CONST_DOUBLE)
  1338.         {
  1339.           REAL_VALUE_TYPE r;
  1340.           long l[3];
  1341.  
  1342.           REAL_VALUE_FROM_CONST_DOUBLE (r, operands[1]);
  1343.           REAL_VALUE_TO_TARGET_LONG_DOUBLE (r, l);
  1344.           operands[1] = GEN_INT (l[0]);
  1345.           middlehalf[1] = GEN_INT (l[1]);
  1346.           latehalf[1] = GEN_INT (l[2]);
  1347.         }
  1348.       else if (CONSTANT_P (operands[1]))
  1349.         {
  1350.           /* actually, no non-CONST_DOUBLE constant should ever
  1351.          appear here.  */
  1352.           abort ();
  1353.           if (GET_CODE (operands[1]) == CONST_INT && INTVAL (operands[1]) < 0)
  1354.         latehalf[1] = constm1_rtx;
  1355.           else
  1356.         latehalf[1] = const0_rtx;
  1357.         }
  1358.     }
  1359.       else
  1360.     {
  1361.       middlehalf[1] = operands[1];
  1362.       latehalf[1] = operands[1];
  1363.     }
  1364.     }
  1365.   else
  1366.     /* size is not 12: */
  1367.     {
  1368.       if (optype0 == REGOP)
  1369.     latehalf[0] = gen_rtx (REG, SImode, REGNO (operands[0]) + 1);
  1370.       else if (optype0 == OFFSOP)
  1371.     latehalf[0] = adj_offsettable_operand (operands[0], size - 4);
  1372.       else
  1373.     latehalf[0] = operands[0];
  1374.  
  1375.       if (optype1 == REGOP)
  1376.     latehalf[1] = gen_rtx (REG, SImode, REGNO (operands[1]) + 1);
  1377.       else if (optype1 == OFFSOP)
  1378.     latehalf[1] = adj_offsettable_operand (operands[1], size - 4);
  1379.       else if (optype1 == CNSTOP)
  1380.     split_double (operands[1], &operands[1], &latehalf[1]);
  1381.       else
  1382.     latehalf[1] = operands[1];
  1383.     }
  1384.  
  1385.   /* If insn is effectively movd N(sp),-(sp) then we will do the
  1386.      high word first.  We should use the adjusted operand 1 (which is N+4(sp))
  1387.      for the low word as well, to compensate for the first decrement of sp.  */
  1388.   if (optype0 == PUSHOP
  1389.       && REGNO (XEXP (XEXP (operands[0], 0), 0)) == STACK_POINTER_REGNUM
  1390.       && reg_overlap_mentioned_p (stack_pointer_rtx, operands[1]))
  1391.     operands[1] = middlehalf[1] = latehalf[1];
  1392.  
  1393.   /* For (set (reg:DI N) (mem:DI ... (reg:SI N) ...)),
  1394.      if the upper part of reg N does not appear in the MEM, arrange to
  1395.      emit the move late-half first.  Otherwise, compute the MEM address
  1396.      into the upper part of N and use that as a pointer to the memory
  1397.      operand.  */
  1398.   if (optype0 == REGOP
  1399.       && (optype1 == OFFSOP || optype1 == MEMOP))
  1400.     {
  1401.       rtx testlow = gen_rtx (REG, SImode, REGNO (operands[0]));
  1402.  
  1403.       if (reg_overlap_mentioned_p (testlow, XEXP (operands[1], 0))
  1404.       && reg_overlap_mentioned_p (latehalf[0], XEXP (operands[1], 0)))
  1405.     {
  1406.       /* If both halves of dest are used in the src memory address,
  1407.          compute the address into latehalf of dest.
  1408.          Note that this can't happen if the dest is two data regs.  */
  1409. compadr:
  1410.       xops[0] = latehalf[0];
  1411.       xops[1] = XEXP (operands[1], 0);
  1412.       output_asm_insn ("lea %a1,%0", xops);
  1413.       if( GET_MODE (operands[1]) == XFmode )
  1414.         {
  1415.           operands[1] = gen_rtx (MEM, XFmode, latehalf[0]);
  1416.           middlehalf[1] = adj_offsettable_operand (operands[1], size-8);
  1417.           latehalf[1] = adj_offsettable_operand (operands[1], size-4);
  1418.         }
  1419.       else
  1420.         {
  1421.           operands[1] = gen_rtx (MEM, DImode, latehalf[0]);
  1422.           latehalf[1] = adj_offsettable_operand (operands[1], size-4);
  1423.         }
  1424.     }
  1425.       else if (size == 12
  1426.            && reg_overlap_mentioned_p (middlehalf[0],
  1427.                        XEXP (operands[1], 0)))
  1428.     {
  1429.       /* Check for two regs used by both source and dest.
  1430.          Note that this can't happen if the dest is all data regs.
  1431.          It can happen if the dest is d6, d7, a0.
  1432.          But in that case, latehalf is an addr reg, so
  1433.          the code at compadr does ok.  */
  1434.  
  1435.       if (reg_overlap_mentioned_p (testlow, XEXP (operands[1], 0))
  1436.           || reg_overlap_mentioned_p (latehalf[0], XEXP (operands[1], 0)))
  1437.         goto compadr;
  1438.  
  1439.       /* JRV says this can't happen: */
  1440.       if (addreg0 || addreg1)
  1441.         abort ();
  1442.  
  1443.       /* Only the middle reg conflicts; simply put it last. */
  1444.       output_asm_insn (singlemove_string (operands), operands);
  1445.       output_asm_insn (singlemove_string (latehalf), latehalf);
  1446.       output_asm_insn (singlemove_string (middlehalf), middlehalf);
  1447.       return "";
  1448.     }
  1449.       else if (reg_overlap_mentioned_p (testlow, XEXP (operands[1], 0)))
  1450.     /* If the low half of dest is mentioned in the source memory
  1451.        address, the arrange to emit the move late half first.  */
  1452.     dest_overlapped_low = 1;
  1453.     }
  1454.  
  1455.   /* If one or both operands autodecrementing,
  1456.      do the two words, high-numbered first.  */
  1457.  
  1458.   /* Likewise,  the first move would clobber the source of the second one,
  1459.      do them in the other order.  This happens only for registers;
  1460.      such overlap can't happen in memory unless the user explicitly
  1461.      sets it up, and that is an undefined circumstance.  */
  1462.  
  1463.   if (optype0 == PUSHOP || optype1 == PUSHOP
  1464.       || (optype0 == REGOP && optype1 == REGOP
  1465.       && ((middlehalf[1] && REGNO (operands[0]) == REGNO (middlehalf[1]))
  1466.           || REGNO (operands[0]) == REGNO (latehalf[1])))
  1467.       || dest_overlapped_low)
  1468.     {
  1469.       /* Make any unoffsettable addresses point at high-numbered word.  */
  1470.       if (addreg0)
  1471.     {
  1472.       if (size == 12)
  1473.         output_asm_insn ("addq%.l %#8,%0", &addreg0);
  1474.       else
  1475.         output_asm_insn ("addq%.l %#4,%0", &addreg0);
  1476.     }
  1477.       if (addreg1)
  1478.     {
  1479.       if (size == 12)
  1480.         output_asm_insn ("addq%.l %#8,%0", &addreg1);
  1481.       else
  1482.         output_asm_insn ("addq%.l %#4,%0", &addreg1);
  1483.     }
  1484.  
  1485.       /* Do that word.  */
  1486.       output_asm_insn (singlemove_string (latehalf), latehalf);
  1487.  
  1488.       /* Undo the adds we just did.  */
  1489.       if (addreg0)
  1490.     output_asm_insn ("subq%.l %#4,%0", &addreg0);
  1491.       if (addreg1)
  1492.     output_asm_insn ("subq%.l %#4,%0", &addreg1);
  1493.  
  1494.       if (size == 12)
  1495.     {
  1496.       output_asm_insn (singlemove_string (middlehalf), middlehalf);
  1497.       if (addreg0)
  1498.         output_asm_insn ("subq%.l %#4,%0", &addreg0);
  1499.       if (addreg1)
  1500.         output_asm_insn ("subq%.l %#4,%0", &addreg1);
  1501.     }
  1502.  
  1503.       /* Do low-numbered word.  */
  1504.       return singlemove_string (operands);
  1505.     }
  1506.  
  1507.   /* Normal case: do the two words, low-numbered first.  */
  1508.  
  1509.   output_asm_insn (singlemove_string (operands), operands);
  1510.  
  1511.   /* Do the middle one of the three words for long double */
  1512.   if (size == 12)
  1513.     {
  1514.       if (addreg0)
  1515.     output_asm_insn ("addq%.l %#4,%0", &addreg0);
  1516.       if (addreg1)
  1517.     output_asm_insn ("addq%.l %#4,%0", &addreg1);
  1518.  
  1519.       output_asm_insn (singlemove_string (middlehalf), middlehalf);
  1520.     }
  1521.  
  1522.   /* Make any unoffsettable addresses point at high-numbered word.  */
  1523.   if (addreg0)
  1524.     output_asm_insn ("addq%.l %#4,%0", &addreg0);
  1525.   if (addreg1)
  1526.     output_asm_insn ("addq%.l %#4,%0", &addreg1);
  1527.  
  1528.   /* Do that word.  */
  1529.   output_asm_insn (singlemove_string (latehalf), latehalf);
  1530.  
  1531.   /* Undo the adds we just did.  */
  1532.   if (addreg0)
  1533.     {
  1534.       if (size == 12)
  1535.         output_asm_insn ("subq%.l %#8,%0", &addreg0);
  1536.       else
  1537.         output_asm_insn ("subq%.l %#4,%0", &addreg0);
  1538.     }
  1539.   if (addreg1)
  1540.     {
  1541.       if (size == 12)
  1542.         output_asm_insn ("subq%.l %#8,%0", &addreg1);
  1543.       else
  1544.         output_asm_insn ("subq%.l %#4,%0", &addreg1);
  1545.     }
  1546.  
  1547.   return "";
  1548. }
  1549.  
  1550. /* Return a REG that occurs in ADDR with coefficient 1.
  1551.    ADDR can be effectively incremented by incrementing REG.  */
  1552.  
  1553. static rtx
  1554. find_addr_reg (addr)
  1555.      rtx addr;
  1556. {
  1557.   while (GET_CODE (addr) == PLUS)
  1558.     {
  1559.       if (GET_CODE (XEXP (addr, 0)) == REG)
  1560.     addr = XEXP (addr, 0);
  1561.       else if (GET_CODE (XEXP (addr, 1)) == REG)
  1562.     addr = XEXP (addr, 1);
  1563.       else if (CONSTANT_P (XEXP (addr, 0)))
  1564.     addr = XEXP (addr, 1);
  1565.       else if (CONSTANT_P (XEXP (addr, 1)))
  1566.     addr = XEXP (addr, 0);
  1567.       else
  1568.     abort ();
  1569.     }
  1570.   if (GET_CODE (addr) == REG)
  1571.     return addr;
  1572.   abort ();
  1573. }
  1574.  
  1575. /* Store in cc_status the expressions that the condition codes will
  1576.    describe after execution of an instruction whose pattern is EXP.
  1577.    Do not alter them if the instruction would not alter the cc's.  */
  1578.  
  1579. /* On the 68000, all the insns to store in an address register fail to
  1580.    set the cc's.  However, in some cases these instructions can make it
  1581.    possibly invalid to use the saved cc's.  In those cases we clear out
  1582.    some or all of the saved cc's so they won't be used.  */
  1583.  
  1584. notice_update_cc (exp, insn)
  1585.      rtx exp;
  1586.      rtx insn;
  1587. {
  1588.   /* If the cc is being set from the fpa and the expression is not an
  1589.      explicit floating point test instruction (which has code to deal with
  1590.      this), reinit the CC.  */
  1591.   if (((cc_status.value1 && FPA_REG_P (cc_status.value1))
  1592.        || (cc_status.value2 && FPA_REG_P (cc_status.value2)))
  1593.       && !(GET_CODE (exp) == PARALLEL
  1594.        && GET_CODE (XVECEXP (exp, 0, 0)) == SET
  1595.        && XEXP (XVECEXP (exp, 0, 0), 0) == cc0_rtx))
  1596.     {
  1597.       CC_STATUS_INIT; 
  1598.     }
  1599.   else if (GET_CODE (exp) == SET)
  1600.     {
  1601.       if (GET_CODE (SET_SRC (exp)) == CALL)
  1602.     {
  1603.       CC_STATUS_INIT; 
  1604.     }
  1605.       else if (ADDRESS_REG_P (SET_DEST (exp)))
  1606.     {
  1607.       if (cc_status.value1
  1608.           && reg_overlap_mentioned_p (SET_DEST (exp), cc_status.value1))
  1609.         cc_status.value1 = 0;
  1610.       if (cc_status.value2
  1611.           && reg_overlap_mentioned_p (SET_DEST (exp), cc_status.value2))
  1612.         cc_status.value2 = 0; 
  1613.     }
  1614.       else if (!FP_REG_P (SET_DEST (exp))
  1615.            && SET_DEST (exp) != cc0_rtx
  1616.            && (FP_REG_P (SET_SRC (exp))
  1617.            || GET_CODE (SET_SRC (exp)) == FIX
  1618.            || GET_CODE (SET_SRC (exp)) == FLOAT_TRUNCATE
  1619.            || GET_CODE (SET_SRC (exp)) == FLOAT_EXTEND))
  1620.     {
  1621.       CC_STATUS_INIT; 
  1622.     }
  1623.       /* A pair of move insns doesn't produce a useful overall cc.  */
  1624.       else if (!FP_REG_P (SET_DEST (exp))
  1625.            && !FP_REG_P (SET_SRC (exp))
  1626.            && GET_MODE_SIZE (GET_MODE (SET_SRC (exp))) > 4
  1627.            && (GET_CODE (SET_SRC (exp)) == REG
  1628.            || GET_CODE (SET_SRC (exp)) == MEM
  1629.            || GET_CODE (SET_SRC (exp)) == CONST_DOUBLE))
  1630.     {
  1631.       CC_STATUS_INIT; 
  1632.     }
  1633.       else if (GET_CODE (SET_SRC (exp)) == CALL)
  1634.     {
  1635.       CC_STATUS_INIT; 
  1636.     }
  1637.       else if (XEXP (exp, 0) != pc_rtx)
  1638.     {
  1639.       cc_status.flags = 0;
  1640.       cc_status.value1 = XEXP (exp, 0);
  1641.       cc_status.value2 = XEXP (exp, 1);
  1642.     }
  1643.     }
  1644.   else if (GET_CODE (exp) == PARALLEL
  1645.        && GET_CODE (XVECEXP (exp, 0, 0)) == SET)
  1646.     {
  1647.       if (ADDRESS_REG_P (XEXP (XVECEXP (exp, 0, 0), 0)))
  1648.     CC_STATUS_INIT;
  1649.       else if (XEXP (XVECEXP (exp, 0, 0), 0) != pc_rtx)
  1650.     {
  1651.       cc_status.flags = 0;
  1652.       cc_status.value1 = XEXP (XVECEXP (exp, 0, 0), 0);
  1653.       cc_status.value2 = XEXP (XVECEXP (exp, 0, 0), 1);
  1654.     }
  1655.     }
  1656.   else
  1657.     CC_STATUS_INIT;
  1658.   if (cc_status.value2 != 0
  1659.       && ADDRESS_REG_P (cc_status.value2)
  1660.       && GET_MODE (cc_status.value2) == QImode)
  1661.     CC_STATUS_INIT;
  1662.   if (cc_status.value2 != 0
  1663.       && !(cc_status.value1 && FPA_REG_P (cc_status.value1)))
  1664.     switch (GET_CODE (cc_status.value2))
  1665.       {
  1666.       case PLUS: case MINUS: case MULT:
  1667.       case DIV: case UDIV: case MOD: case UMOD: case NEG:
  1668.       case ASHIFT: case ASHIFTRT: case LSHIFTRT:
  1669.       case ROTATE: case ROTATERT:
  1670.     if (GET_MODE (cc_status.value2) != VOIDmode)
  1671.       cc_status.flags |= CC_NO_OVERFLOW;
  1672.     break;
  1673.       case ZERO_EXTEND:
  1674.     /* (SET r1 (ZERO_EXTEND r2)) on this machine
  1675.        ends with a move insn moving r2 in r2's mode.
  1676.        Thus, the cc's are set for r2.
  1677.        This can set N bit spuriously. */
  1678.     cc_status.flags |= CC_NOT_NEGATIVE; 
  1679.       }
  1680.   if (cc_status.value1 && GET_CODE (cc_status.value1) == REG
  1681.       && cc_status.value2
  1682.       && reg_overlap_mentioned_p (cc_status.value1, cc_status.value2))
  1683.     cc_status.value2 = 0;
  1684.   if (((cc_status.value1 && FP_REG_P (cc_status.value1))
  1685.        || (cc_status.value2 && FP_REG_P (cc_status.value2)))
  1686.       && !((cc_status.value1 && FPA_REG_P (cc_status.value1))
  1687.        || (cc_status.value2 && FPA_REG_P (cc_status.value2))))
  1688.     cc_status.flags = CC_IN_68881;
  1689. }
  1690.  
  1691. char *
  1692. output_move_const_double (operands)
  1693.      rtx *operands;
  1694. {
  1695. #ifdef SUPPORT_SUN_FPA
  1696.   if (TARGET_FPA && FPA_REG_P (operands[0]))
  1697.     {
  1698.       int code = standard_sun_fpa_constant_p (operands[1]);
  1699.  
  1700.       if (code != 0)
  1701.     {
  1702.       static char buf[40];
  1703.  
  1704.       sprintf (buf, "fpmove%%.d %%%%%d,%%0", code & 0x1ff);
  1705.       return buf;
  1706.     }
  1707.       return "fpmove%.d %1,%0";
  1708.     }
  1709.   else
  1710. #endif
  1711.     {
  1712.       int code = standard_68881_constant_p (operands[1]);
  1713.  
  1714.       if (code != 0)
  1715.     {
  1716.       static char buf[40];
  1717.  
  1718.       sprintf (buf, "fmovecr %%#0x%x,%%0", code & 0xff);
  1719.       return buf;
  1720.     }
  1721.       return "fmove%.d %1,%0";
  1722.     }
  1723. }
  1724.  
  1725. char *
  1726. output_move_const_single (operands)
  1727.      rtx *operands;
  1728. {
  1729. #ifdef SUPPORT_SUN_FPA
  1730.   if (TARGET_FPA)
  1731.     {
  1732.       int code = standard_sun_fpa_constant_p (operands[1]);
  1733.  
  1734.       if (code != 0)
  1735.     {
  1736.       static char buf[40];
  1737.  
  1738.       sprintf (buf, "fpmove%%.s %%%%%d,%%0", code & 0x1ff);
  1739.       return buf;
  1740.     }
  1741.       return "fpmove%.s %1,%0";
  1742.     }
  1743.   else
  1744. #endif /* defined SUPPORT_SUN_FPA */
  1745.     {
  1746.       int code = standard_68881_constant_p (operands[1]);
  1747.  
  1748.       if (code != 0)
  1749.     {
  1750.       static char buf[40];
  1751.  
  1752.       sprintf (buf, "fmovecr %%#0x%x,%%0", code & 0xff);
  1753.       return buf;
  1754.     }
  1755.       return "fmove%.s %f1,%0";
  1756.     }
  1757. }
  1758.  
  1759. /* Return nonzero if X, a CONST_DOUBLE, has a value that we can get
  1760.    from the "fmovecr" instruction.
  1761.    The value, anded with 0xff, gives the code to use in fmovecr
  1762.    to get the desired constant.  */
  1763.  
  1764. /* This code has been fixed for cross-compilation. */
  1765.   
  1766. static int inited_68881_table = 0;
  1767.  
  1768. char *strings_68881[7] = {
  1769.   "0.0",
  1770.   "1.0",
  1771.   "10.0",
  1772.   "100.0",
  1773.   "10000.0",
  1774.   "1e8",
  1775.   "1e16"
  1776.   };
  1777.  
  1778. int codes_68881[7] = {
  1779.   0x0f,
  1780.   0x32,
  1781.   0x33,
  1782.   0x34,
  1783.   0x35,
  1784.   0x36,
  1785.   0x37
  1786.   };
  1787.  
  1788. REAL_VALUE_TYPE values_68881[7];
  1789.  
  1790. /* Set up values_68881 array by converting the decimal values
  1791.    strings_68881 to binary.   */
  1792.  
  1793. void
  1794. init_68881_table ()
  1795. {
  1796.   int i;
  1797.   REAL_VALUE_TYPE r;
  1798.   enum machine_mode mode;
  1799.  
  1800.   mode = DFmode;
  1801.   for (i = 0; i < 7; i++)
  1802.     {
  1803.       if (i == 6)
  1804.         mode = SFmode;
  1805.       r = REAL_VALUE_ATOF (strings_68881[i], mode);
  1806.       values_68881[i] = r;
  1807.     }
  1808.   inited_68881_table = 1;
  1809. }
  1810.  
  1811. int
  1812. standard_68881_constant_p (x)
  1813.      rtx x;
  1814. {
  1815.   REAL_VALUE_TYPE r;
  1816.   int i;
  1817.   enum machine_mode mode;
  1818.  
  1819. #ifdef NO_ASM_FMOVECR
  1820.   return 0;
  1821. #endif
  1822.  
  1823.   /* fmovecr must be emulated on the 68040, so it shouldn't be used at all. */
  1824.   if (TARGET_68040)
  1825.     return 0;
  1826.  
  1827. #ifndef REAL_ARITHMETIC
  1828. #if HOST_FLOAT_FORMAT != TARGET_FLOAT_FORMAT
  1829.   if (! flag_pretend_float)
  1830.     return 0;
  1831. #endif
  1832. #endif
  1833.  
  1834.   if (! inited_68881_table)
  1835.     init_68881_table ();
  1836.  
  1837.   REAL_VALUE_FROM_CONST_DOUBLE (r, x);
  1838.  
  1839.   for (i = 0; i < 6; i++)
  1840.     {
  1841.       if (REAL_VALUES_EQUAL (r, values_68881[i]))
  1842.         return (codes_68881[i]);
  1843.     }
  1844.   
  1845.   if (GET_MODE (x) == SFmode)
  1846.     return 0;
  1847.  
  1848.   if (REAL_VALUES_EQUAL (r, values_68881[6]))
  1849.     return (codes_68881[6]);
  1850.  
  1851.   /* larger powers of ten in the constants ram are not used
  1852.      because they are not equal to a `double' C constant.  */
  1853.   return 0;
  1854. }
  1855.  
  1856. /* If X is a floating-point constant, return the logarithm of X base 2,
  1857.    or 0 if X is not a power of 2.  */
  1858.  
  1859. int
  1860. floating_exact_log2 (x)
  1861.      rtx x;
  1862. {
  1863.   REAL_VALUE_TYPE r, r1;
  1864.   int i;
  1865.  
  1866. #ifndef REAL_ARITHMETIC
  1867. #if HOST_FLOAT_FORMAT != TARGET_FLOAT_FORMAT
  1868.   if (! flag_pretend_float)
  1869.     return 0;
  1870. #endif
  1871. #endif
  1872.  
  1873.   REAL_VALUE_FROM_CONST_DOUBLE (r, x);
  1874.  
  1875.   if (REAL_VALUES_LESS (r, dconst0))
  1876.     return 0;
  1877.  
  1878.   r1 = dconst1;
  1879.   i = 0;
  1880.   while (REAL_VALUES_LESS (r1, r))
  1881.     {
  1882.       r1 = REAL_VALUE_LDEXP (dconst1, i);
  1883.       if (REAL_VALUES_EQUAL (r1, r))
  1884.         return i;
  1885.       i = i + 1;
  1886.     }
  1887.   return 0;
  1888. }
  1889.  
  1890. #ifdef SUPPORT_SUN_FPA
  1891. /* Return nonzero if X, a CONST_DOUBLE, has a value that we can get
  1892.    from the Sun FPA's constant RAM.
  1893.    The value returned, anded with 0x1ff, gives the code to use in fpmove
  1894.    to get the desired constant. */
  1895.  
  1896. static int inited_FPA_table = 0;
  1897.  
  1898. char *strings_FPA[38] = {
  1899. /* small rationals */
  1900.   "0.0",
  1901.   "1.0",
  1902.   "0.5",
  1903.   "-1.0",
  1904.   "2.0",
  1905.   "3.0",
  1906.   "4.0",
  1907.   "8.0",
  1908.   "0.25",
  1909.   "0.125",
  1910.   "10.0",
  1911.   "-0.5",
  1912. /* Decimal equivalents of double precision values */
  1913.   "2.718281828459045091", /* D_E */
  1914.   "6.283185307179586477", /* 2 pi */
  1915.   "3.141592653589793116", /* D_PI */
  1916.   "1.570796326794896619", /* pi/2 */
  1917.   "1.414213562373095145", /* D_SQRT2 */
  1918.   "0.7071067811865475244", /* 1/sqrt(2) */
  1919.   "-1.570796326794896619", /* -pi/2 */
  1920.   "1.442695040888963387", /* D_LOG2ofE */
  1921.   "3.321928024887362182", /* D_LOG2of10 */
  1922.   "0.6931471805599452862", /* D_LOGEof2 */
  1923.   "2.302585092994045901", /* D_LOGEof10 */
  1924.   "0.3010299956639811980", /* D_LOG10of2 */
  1925.   "0.4342944819032518167", /* D_LOG10ofE */
  1926. /* Decimal equivalents of single precision values */
  1927.   "2.718281745910644531", /* S_E */
  1928.   "6.283185307179586477", /* 2 pi */
  1929.   "3.141592741012573242", /* S_PI */
  1930.   "1.570796326794896619", /* pi/2 */
  1931.   "1.414213538169860840", /* S_SQRT2 */
  1932.   "0.7071067811865475244", /* 1/sqrt(2) */
  1933.   "-1.570796326794896619", /* -pi/2 */
  1934.   "1.442695021629333496", /* S_LOG2ofE */
  1935.   "3.321928024291992188", /* S_LOG2of10 */
  1936.   "0.6931471824645996094", /* S_LOGEof2 */
  1937.   "2.302585124969482442", /* S_LOGEof10 */
  1938.   "0.3010300099849700928", /* S_LOG10of2 */
  1939.   "0.4342944920063018799", /* S_LOG10ofE */
  1940. };
  1941.  
  1942.  
  1943. int codes_FPA[38] = {
  1944. /* small rationals */
  1945.   0x200,
  1946.   0xe,
  1947.   0xf,
  1948.   0x10,
  1949.   0x11,
  1950.   0xb1,
  1951.   0x12,
  1952.   0x13,
  1953.   0x15,
  1954.   0x16,
  1955.   0x17,
  1956.   0x2e,
  1957. /* double precision */
  1958.   0x8,
  1959.   0x9,
  1960.   0xa,
  1961.   0xb,
  1962.   0xc,
  1963.   0xd,
  1964.   0x27,
  1965.   0x28,
  1966.   0x29,
  1967.   0x2a,
  1968.   0x2b,
  1969.   0x2c,
  1970.   0x2d,
  1971. /* single precision */
  1972.   0x8,
  1973.   0x9,
  1974.   0xa,
  1975.   0xb,
  1976.   0xc,
  1977.   0xd,
  1978.   0x27,
  1979.   0x28,
  1980.   0x29,
  1981.   0x2a,
  1982.   0x2b,
  1983.   0x2c,
  1984.   0x2d
  1985.   };
  1986.  
  1987. REAL_VALUE_TYPE values_FPA[38];
  1988.  
  1989. /* This code has been fixed for cross-compilation. */
  1990.  
  1991. void
  1992. init_FPA_table ()
  1993. {
  1994.   enum machine_mode mode;
  1995.   int i;
  1996.   REAL_VALUE_TYPE r;
  1997.  
  1998.   mode = DFmode;
  1999.   for (i = 0; i < 38; i++)
  2000.     {
  2001.       if (i == 25)
  2002.         mode = SFmode;
  2003.       r = REAL_VALUE_ATOF (strings_FPA[i], mode);
  2004.       values_FPA[i] = r;
  2005.     }
  2006.   inited_FPA_table = 1;
  2007. }
  2008.  
  2009.  
  2010. int
  2011. standard_sun_fpa_constant_p (x)
  2012.      rtx x;
  2013. {
  2014.   REAL_VALUE_TYPE r;
  2015.   int i;
  2016.  
  2017. #ifndef REAL_ARITHMETIC
  2018. #if HOST_FLOAT_FORMAT != TARGET_FLOAT_FORMAT
  2019.   if (! flag_pretend_float)
  2020.     return 0;
  2021. #endif
  2022. #endif
  2023.  
  2024.   if (! inited_FPA_table)
  2025.     init_FPA_table ();
  2026.  
  2027.   REAL_VALUE_FROM_CONST_DOUBLE (r, x);
  2028.  
  2029.   for (i=0; i<12; i++)
  2030.     {
  2031.       if (REAL_VALUES_EQUAL (r, values_FPA[i]))
  2032.         return (codes_FPA[i]);
  2033.     }
  2034.  
  2035.   if (GET_MODE (x) == SFmode)
  2036.     {
  2037.       for (i=25; i<38; i++)
  2038.         {
  2039.           if (REAL_VALUES_EQUAL (r, values_FPA[i]))
  2040.             return (codes_FPA[i]);
  2041.         }
  2042.     }
  2043.   else
  2044.     {
  2045.       for (i=12; i<25; i++)
  2046.         {
  2047.           if (REAL_VALUES_EQUAL (r, values_FPA[i]))
  2048.             return (codes_FPA[i]);
  2049.         }
  2050.     }
  2051.   return 0x0;
  2052. }
  2053. #endif /* define SUPPORT_SUN_FPA */
  2054.  
  2055. /* A C compound statement to output to stdio stream STREAM the
  2056.    assembler syntax for an instruction operand X.  X is an RTL
  2057.    expression.
  2058.  
  2059.    CODE is a value that can be used to specify one of several ways
  2060.    of printing the operand.  It is used when identical operands
  2061.    must be printed differently depending on the context.  CODE
  2062.    comes from the `%' specification that was used to request
  2063.    printing of the operand.  If the specification was just `%DIGIT'
  2064.    then CODE is 0; if the specification was `%LTR DIGIT' then CODE
  2065.    is the ASCII code for LTR.
  2066.  
  2067.    If X is a register, this macro should print the register's name.
  2068.    The names can be found in an array `reg_names' whose type is
  2069.    `char *[]'.  `reg_names' is initialized from `REGISTER_NAMES'.
  2070.  
  2071.    When the machine description has a specification `%PUNCT' (a `%'
  2072.    followed by a punctuation character), this macro is called with
  2073.    a null pointer for X and the punctuation character for CODE.
  2074.  
  2075.    The m68k specific codes are:
  2076.  
  2077.    '.' for dot needed in Motorola-style opcode names.
  2078.    '-' for an operand pushing on the stack:
  2079.        sp@-, -(sp) or -(%sp) depending on the style of syntax.
  2080.    '+' for an operand pushing on the stack:
  2081.        sp@+, (sp)+ or (%sp)+ depending on the style of syntax.
  2082.    '@' for a reference to the top word on the stack:
  2083.        sp@, (sp) or (%sp) depending on the style of syntax.
  2084.    '#' for an immediate operand prefix (# in MIT and Motorola syntax
  2085.        but & in SGS syntax).
  2086.    '!' for the cc register (used in an `and to cc' insn).
  2087.    '$' for the letter `s' in an op code, but only on the 68040.
  2088.    '&' for the letter `d' in an op code, but only on the 68040.
  2089.    '/' for register prefix needed by longlong.h.
  2090.  
  2091.    'b' for byte insn (no effect, on the Sun; this is for the ISI).
  2092.    'd' to force memory addressing to be absolute, not relative.
  2093.    'f' for float insn (print a CONST_DOUBLE as a float rather than in hex)
  2094.    'w' for FPA insn (print a CONST_DOUBLE as a SunFPA constant rather
  2095.        than directly).  Second part of 'y' below.
  2096.    'x' for float insn (print a CONST_DOUBLE as a float rather than in hex),
  2097.        or print pair of registers as rx:ry.
  2098.    'y' for a FPA insn (print pair of registers as rx:ry).  This also outputs
  2099.        CONST_DOUBLE's as SunFPA constant RAM registers if
  2100.        possible, so it should not be used except for the SunFPA.
  2101.  
  2102.    */
  2103.  
  2104. void
  2105. print_operand (file, op, letter)
  2106.      FILE *file;        /* file to write to */
  2107.      rtx op;            /* operand to print */
  2108.      int letter;        /* %<letter> or 0 */
  2109. {
  2110.   int i;
  2111.  
  2112.   if (letter == '.')
  2113.     {
  2114. #ifdef MOTOROLA
  2115.       asm_fprintf (file, ".");
  2116. #endif
  2117.     }
  2118.   else if (letter == '#')
  2119.     {
  2120.       asm_fprintf (file, "%0I");
  2121.     }
  2122.   else if (letter == '-')
  2123.     {
  2124. #ifdef MOTOROLA
  2125.       asm_fprintf (file, "-(%Rsp)");
  2126. #else
  2127.       asm_fprintf (file, "%Rsp@-");
  2128. #endif
  2129.     }
  2130.   else if (letter == '+')
  2131.     {
  2132. #ifdef MOTOROLA
  2133.       asm_fprintf (file, "(%Rsp)+");
  2134. #else
  2135.       asm_fprintf (file, "%Rsp@+");
  2136. #endif
  2137.     }
  2138.   else if (letter == '@')
  2139.     {
  2140. #ifdef MOTOROLA
  2141.       asm_fprintf (file, "(%Rsp)");
  2142. #else
  2143.       asm_fprintf (file, "%Rsp@");
  2144. #endif
  2145.     }
  2146.   else if (letter == '!')
  2147.     {
  2148.       asm_fprintf (file, "%Rfpcr");
  2149.     }
  2150.   else if (letter == '$')
  2151.     {
  2152.       if (TARGET_68040_ONLY)
  2153.     {
  2154.       fprintf (file, "s");
  2155.     }
  2156.     }
  2157.   else if (letter == '&')
  2158.     {
  2159.       if (TARGET_68040_ONLY)
  2160.     {
  2161.       fprintf (file, "d");
  2162.     }
  2163.     }
  2164.   else if (letter == '/')
  2165.     {
  2166.       asm_fprintf (file, "%R");
  2167.     }
  2168.   else if (GET_CODE (op) == REG)
  2169.     {
  2170. #ifdef SUPPORT_SUN_FPA
  2171.       if (REGNO (op) < 16
  2172.       && (letter == 'y' || letter == 'x')
  2173.       && GET_MODE (op) == DFmode)
  2174.     {
  2175.       fprintf (file, "%s:%s", reg_names[REGNO (op)],
  2176.            reg_names[REGNO (op)+1]);
  2177.     }
  2178.       else
  2179. #endif
  2180.     {
  2181.       if (letter == 'R')
  2182.         /* Print out the second register name of a register pair.
  2183.            I.e., R (6) => 7.  */
  2184.         fputs (reg_names[REGNO (op) + 1], file);
  2185.       else
  2186.         fputs (reg_names[REGNO (op)], file);
  2187.     }
  2188.     }
  2189.   else if (GET_CODE (op) == MEM)
  2190.     {
  2191.       output_address (XEXP (op, 0));
  2192.       if (letter == 'd' && ! TARGET_68020
  2193.       && CONSTANT_ADDRESS_P (XEXP (op, 0))
  2194.       && !(GET_CODE (XEXP (op, 0)) == CONST_INT
  2195.            && INTVAL (XEXP (op, 0)) < 0x8000
  2196.            && INTVAL (XEXP (op, 0)) >= -0x8000))
  2197.     {
  2198.       fprintf (file, ":l");
  2199.     }
  2200.     }
  2201. #ifdef SUPPORT_SUN_FPA
  2202.   else if ((letter == 'y' || letter == 'w')
  2203.        && GET_CODE (op) == CONST_DOUBLE
  2204.        && (i = standard_sun_fpa_constant_p (op)))
  2205.     {
  2206.       fprintf (file, "%%%d", i & 0x1ff);
  2207.     }
  2208. #endif
  2209.   else if (GET_CODE (op) == CONST_DOUBLE && GET_MODE (op) == SFmode)
  2210.     {
  2211.       REAL_VALUE_TYPE r;
  2212.       REAL_VALUE_FROM_CONST_DOUBLE (r, op);
  2213.       ASM_OUTPUT_FLOAT_OPERAND (letter, file, r);
  2214.     }
  2215.   else if (GET_CODE (op) == CONST_DOUBLE && GET_MODE (op) == XFmode)
  2216.     {
  2217.       REAL_VALUE_TYPE r;
  2218.       REAL_VALUE_FROM_CONST_DOUBLE (r, op);
  2219.       ASM_OUTPUT_LONG_DOUBLE_OPERAND (file, r);
  2220.     }
  2221.   else if (GET_CODE (op) == CONST_DOUBLE && GET_MODE (op) == DFmode)
  2222.     {
  2223.       REAL_VALUE_TYPE r;
  2224.       REAL_VALUE_FROM_CONST_DOUBLE (r, op);
  2225.       ASM_OUTPUT_DOUBLE_OPERAND (file, r);
  2226.     }
  2227.   else
  2228.     {
  2229.       asm_fprintf (file, "%0I"); output_addr_const (file, op);
  2230.     }
  2231. }
  2232.  
  2233.  
  2234. /* A C compound statement to output to stdio stream STREAM the
  2235.    assembler syntax for an instruction operand that is a memory
  2236.    reference whose address is ADDR.  ADDR is an RTL expression.
  2237.  
  2238.    Note that this contains a kludge that knows that the only reason
  2239.    we have an address (plus (label_ref...) (reg...)) when not generating
  2240.    PIC code is in the insn before a tablejump, and we know that m68k.md
  2241.    generates a label LInnn: on such an insn.
  2242.  
  2243.    It is possible for PIC to generate a (plus (label_ref...) (reg...))
  2244.    and we handle that just like we would a (plus (symbol_ref...) (reg...)).
  2245.  
  2246.    Some SGS assemblers have a bug such that "Lnnn-LInnn-2.b(pc,d0.l*2)"
  2247.    fails to assemble.  Luckily "Lnnn(pc,d0.l*2)" produces the results
  2248.    we want.  This difference can be accommodated by using an assembler
  2249.    define such "LDnnn" to be either "Lnnn-LInnn-2.b", "Lnnn", or any other
  2250.    string, as necessary.  This is accomplished via the ASM_OUTPUT_CASE_END
  2251.    macro.  See m68k/sgs.h for an example; for versions without the bug.
  2252.    Some assemblers refuse all the above solutions.  The workaround is to
  2253.    emit "K(pc,d0.l*2)" with K being a small constant known to give the
  2254.    right behaviour.
  2255.  
  2256.    They also do not like things like "pea 1.w", so we simple leave off
  2257.    the .w on small constants. 
  2258.  
  2259.    This routine is responsible for distinguishing between -fpic and -fPIC 
  2260.    style relocations in an address.  When generating -fpic code the
  2261.    offset is output in word mode (eg movel a5@(_foo:w), a0).  When generating
  2262.    -fPIC code the offset is output in long mode (eg movel a5@(_foo:l), a0) */
  2263.  
  2264. #ifndef ASM_OUTPUT_CASE_FETCH
  2265. #ifdef MOTOROLA
  2266. #ifdef SGS
  2267. #define ASM_OUTPUT_CASE_FETCH(file, labelno, regname)\
  2268.     asm_fprintf (file, "%LLD%d(%Rpc,%s.", labelno, regname)
  2269. #else
  2270. #define ASM_OUTPUT_CASE_FETCH(file, labelno, regname)\
  2271.     asm_fprintf (file, "%LL%d-%LLI%d.b(%Rpc,%s.", labelno, labelno, regname)
  2272. #endif
  2273. #else
  2274. #define ASM_OUTPUT_CASE_FETCH(file, labelno, regname)\
  2275.     asm_fprintf (file, "%Rpc@(%LL%d-%LLI%d-2:b,%s:", labelno, labelno, regname)
  2276. #endif
  2277. #endif /* ASM_OUTPUT_CASE_FETCH */
  2278.  
  2279. void
  2280. print_operand_address (file, addr)
  2281.      FILE *file;
  2282.      rtx addr;
  2283. {
  2284.   register rtx reg1, reg2, breg, ireg;
  2285.   rtx offset;
  2286.  
  2287.   switch (GET_CODE (addr))
  2288.     {
  2289.       case REG:
  2290. #ifdef MOTOROLA
  2291.     fprintf (file, "(%s)", reg_names[REGNO (addr)]);
  2292. #else
  2293.     fprintf (file, "%s@", reg_names[REGNO (addr)]);
  2294. #endif
  2295.     break;
  2296.       case PRE_DEC:
  2297. #ifdef MOTOROLA
  2298.     fprintf (file, "-(%s)", reg_names[REGNO (XEXP (addr, 0))]);
  2299. #else
  2300.     fprintf (file, "%s@-", reg_names[REGNO (XEXP (addr, 0))]);
  2301. #endif
  2302.     break;
  2303.       case POST_INC:
  2304. #ifdef MOTOROLA
  2305.     fprintf (file, "(%s)+", reg_names[REGNO (XEXP (addr, 0))]);
  2306. #else
  2307.     fprintf (file, "%s@+", reg_names[REGNO (XEXP (addr, 0))]);
  2308. #endif
  2309.     break;
  2310.       case PLUS:
  2311.     reg1 = reg2 = ireg = breg = offset = 0;
  2312.     if (CONSTANT_ADDRESS_P (XEXP (addr, 0)))
  2313.       {
  2314.         offset = XEXP (addr, 0);
  2315.         addr = XEXP (addr, 1);
  2316.       }
  2317.     else if (CONSTANT_ADDRESS_P (XEXP (addr, 1)))
  2318.       {
  2319.         offset = XEXP (addr, 1);
  2320.         addr = XEXP (addr, 0);
  2321.       }
  2322.     if (GET_CODE (addr) != PLUS)
  2323.       {
  2324.         ;
  2325.       }
  2326.     else if (GET_CODE (XEXP (addr, 0)) == SIGN_EXTEND)
  2327.       {
  2328.         reg1 = XEXP (addr, 0);
  2329.         addr = XEXP (addr, 1);
  2330.       }
  2331.     else if (GET_CODE (XEXP (addr, 1)) == SIGN_EXTEND)
  2332.       {
  2333.         reg1 = XEXP (addr, 1);
  2334.         addr = XEXP (addr, 0);
  2335.       }
  2336.     else if (GET_CODE (XEXP (addr, 0)) == MULT)
  2337.       {
  2338.         reg1 = XEXP (addr, 0);
  2339.         addr = XEXP (addr, 1);
  2340.       }
  2341.     else if (GET_CODE (XEXP (addr, 1)) == MULT)
  2342.       {
  2343.         reg1 = XEXP (addr, 1);
  2344.         addr = XEXP (addr, 0);
  2345.       }
  2346.     else if (GET_CODE (XEXP (addr, 0)) == REG)
  2347.       {
  2348.         reg1 = XEXP (addr, 0);
  2349.         addr = XEXP (addr, 1);
  2350.       }
  2351.     else if (GET_CODE (XEXP (addr, 1)) == REG)
  2352.       {
  2353.         reg1 = XEXP (addr, 1);
  2354.         addr = XEXP (addr, 0);
  2355.       }
  2356.     if (GET_CODE (addr) == REG || GET_CODE (addr) == MULT
  2357.         || GET_CODE (addr) == SIGN_EXTEND)
  2358.       {
  2359.         if (reg1 == 0)
  2360.           {
  2361.         reg1 = addr;
  2362.           }
  2363.         else
  2364.           {
  2365.         reg2 = addr;
  2366.           }
  2367.         addr = 0;
  2368.       }
  2369. #if 0    /* for OLD_INDEXING */
  2370.     else if (GET_CODE (addr) == PLUS)
  2371.       {
  2372.         if (GET_CODE (XEXP (addr, 0)) == REG)
  2373.           {
  2374.         reg2 = XEXP (addr, 0);
  2375.         addr = XEXP (addr, 1);
  2376.           }
  2377.         else if (GET_CODE (XEXP (addr, 1)) == REG)
  2378.           {
  2379.         reg2 = XEXP (addr, 1);
  2380.         addr = XEXP (addr, 0);
  2381.           }
  2382.       }
  2383. #endif
  2384.     if (offset != 0)
  2385.       {
  2386.         if (addr != 0)
  2387.           {
  2388.         abort ();
  2389.           }
  2390.         addr = offset;
  2391.       }
  2392.     if ((reg1 && (GET_CODE (reg1) == SIGN_EXTEND
  2393.               || GET_CODE (reg1) == MULT))
  2394.         || (reg2 != 0 && REGNO_OK_FOR_BASE_P (REGNO (reg2))))
  2395.       {
  2396.         breg = reg2;
  2397.         ireg = reg1;
  2398.       }
  2399.     else if (reg1 != 0 && REGNO_OK_FOR_BASE_P (REGNO (reg1)))
  2400.       {
  2401.         breg = reg1;
  2402.         ireg = reg2;
  2403.       }
  2404.     if (ireg != 0 && breg == 0 && GET_CODE (addr) == LABEL_REF
  2405.         && ! (flag_pic && ireg == pic_offset_table_rtx))
  2406.       {
  2407.         int scale = 1;
  2408.         if (GET_CODE (ireg) == MULT)
  2409.           {
  2410.         scale = INTVAL (XEXP (ireg, 1));
  2411.         ireg = XEXP (ireg, 0);
  2412.           }
  2413.         if (GET_CODE (ireg) == SIGN_EXTEND)
  2414.           {
  2415. #ifdef MACHO_PIC
  2416.         asm_fprintf (file, "%Ra5@(%LL%d-",
  2417.                  CODE_LABEL_NUMBER (XEXP (addr, 0)));
  2418.         assemble_name (file, machopic_function_base_name ());
  2419.         asm_fprintf (file, ",%s:", reg_names[REGNO (ireg)]);
  2420. #else
  2421.         ASM_OUTPUT_CASE_FETCH (file,
  2422.                  CODE_LABEL_NUMBER (XEXP (addr, 0)),
  2423.                  reg_names[REGNO (XEXP (ireg, 0))]);
  2424. #endif
  2425.         fprintf (file, "w");
  2426.           }
  2427.         else
  2428.           {
  2429. #ifdef MACHO_PIC
  2430.         asm_fprintf (file, "%Ra5@(%LL%d-",
  2431.                  CODE_LABEL_NUMBER (XEXP (addr, 0)));
  2432.         assemble_name (file, machopic_function_base_name ());
  2433.         asm_fprintf (file, ",%s:", reg_names[REGNO (ireg)]);
  2434. #else
  2435.         ASM_OUTPUT_CASE_FETCH (file,
  2436.                  CODE_LABEL_NUMBER (XEXP (addr, 0)),
  2437.                  reg_names[REGNO (ireg)]);
  2438. #endif
  2439.         fprintf (file, "l");
  2440.           }
  2441.         if (scale != 1)
  2442.           {
  2443. #ifdef MOTOROLA
  2444.         fprintf (file, "*%d", scale);
  2445. #else
  2446.         fprintf (file, ":%d", scale);
  2447. #endif
  2448.           }
  2449.         putc (')', file);
  2450.         break;
  2451.       }
  2452.     if (breg != 0 && ireg == 0 && GET_CODE (addr) == LABEL_REF
  2453.         && ! (flag_pic && breg == pic_offset_table_rtx))
  2454.       {
  2455.         ASM_OUTPUT_CASE_FETCH (file,
  2456.              CODE_LABEL_NUMBER (XEXP (addr, 0)),
  2457.              reg_names[REGNO (breg)]);
  2458.         fprintf (file, "l)");
  2459.         break;
  2460.       }
  2461.     if (ireg != 0 || breg != 0)
  2462.       {
  2463.         int scale = 1;
  2464.         if (breg == 0)
  2465.           {
  2466.         abort ();
  2467.           }
  2468.         if (! flag_pic && addr && GET_CODE (addr) == LABEL_REF)
  2469.           {
  2470.         abort ();
  2471.           }
  2472. #ifdef MOTOROLA
  2473.         if (addr != 0)
  2474.           {
  2475.         output_addr_const (file, addr);
  2476.             if (flag_pic && (breg == pic_offset_table_rtx))
  2477.               fprintf (file, "@GOT");
  2478.           }
  2479.         fprintf (file, "(%s", reg_names[REGNO (breg)]);
  2480.         if (ireg != 0)
  2481.           {
  2482.         putc (',', file);
  2483.           }
  2484. #else
  2485.         fprintf (file, "%s@(", reg_names[REGNO (breg)]);
  2486.         if (addr != 0)
  2487.           {
  2488.         output_addr_const (file, addr);
  2489. #ifndef MACHO_PIC
  2490.             if ((flag_pic == 1) && (breg == pic_offset_table_rtx))
  2491.               fprintf (file, ":w");
  2492.             if ((flag_pic == 2) && (breg == pic_offset_table_rtx))
  2493.               fprintf (file, ":l");
  2494. #endif
  2495.           }
  2496.         if (addr != 0 && ireg != 0)
  2497.           {
  2498.         putc (',', file);
  2499.           }
  2500. #endif
  2501.         if (ireg != 0 && GET_CODE (ireg) == MULT)
  2502.           {
  2503.         scale = INTVAL (XEXP (ireg, 1));
  2504.         ireg = XEXP (ireg, 0);
  2505.           }
  2506.         if (ireg != 0 && GET_CODE (ireg) == SIGN_EXTEND)
  2507.           {
  2508. #ifdef MOTOROLA
  2509.         fprintf (file, "%s.w", reg_names[REGNO (XEXP (ireg, 0))]);
  2510. #else
  2511.         fprintf (file, "%s:w", reg_names[REGNO (XEXP (ireg, 0))]);
  2512. #endif
  2513.           }
  2514.         else if (ireg != 0)
  2515.           {
  2516. #ifdef MOTOROLA
  2517.         fprintf (file, "%s.l", reg_names[REGNO (ireg)]);
  2518. #else
  2519.         fprintf (file, "%s:l", reg_names[REGNO (ireg)]);
  2520. #endif
  2521.           }
  2522.         if (scale != 1)
  2523.           {
  2524. #ifdef MOTOROLA
  2525.         fprintf (file, "*%d", scale);
  2526. #else
  2527.         fprintf (file, ":%d", scale);
  2528. #endif
  2529.           }
  2530.         putc (')', file);
  2531.         break;
  2532.       }
  2533.     else if (reg1 != 0 && GET_CODE (addr) == LABEL_REF
  2534.          && ! (flag_pic && reg1 == pic_offset_table_rtx))    
  2535.       {
  2536.         ASM_OUTPUT_CASE_FETCH (file,
  2537.              CODE_LABEL_NUMBER (XEXP (addr, 0)),
  2538.              reg_names[REGNO (reg1)]);
  2539.         fprintf (file, "l)");
  2540.         break;
  2541.       }
  2542.     /* FALL-THROUGH (is this really what we want? */
  2543.       default:
  2544.         if (GET_CODE (addr) == CONST_INT
  2545.         && INTVAL (addr) < 0x8000
  2546.         && INTVAL (addr) >= -0x8000)
  2547.       {
  2548. #ifdef MOTOROLA
  2549. #ifdef SGS
  2550.         /* Many SGS assemblers croak on size specifiers for constants. */
  2551.         fprintf (file, "%d", INTVAL (addr));
  2552. #else
  2553.         fprintf (file, "%d.w", INTVAL (addr));
  2554. #endif
  2555. #else
  2556.         fprintf (file, "%d:w", INTVAL (addr));
  2557. #endif
  2558.       }
  2559.     else
  2560.       {
  2561.         output_addr_const (file, addr);
  2562.       }
  2563.     break;
  2564.     }
  2565. }
  2566.  
  2567. /* Check for cases where a clr insns can be omitted from code using
  2568.    strict_low_part sets.  For example, the second clrl here is not needed:
  2569.    clrl d0; movw a0@+,d0; use d0; clrl d0; movw a0@+; use d0; ...
  2570.  
  2571.    MODE is the mode of this STRICT_LOW_PART set.  FIRST_INSN is the clear
  2572.    insn we are checking for redundancy.  TARGET is the register set by the
  2573.    clear insn.  */
  2574.  
  2575. int
  2576. strict_low_part_peephole_ok (mode, first_insn, target)
  2577.      enum machine_mode mode;
  2578.      rtx first_insn;
  2579.      rtx target;
  2580. {
  2581.   rtx p;
  2582.  
  2583.   p = prev_nonnote_insn (first_insn);
  2584.  
  2585.   while (p)
  2586.     {
  2587.       /* If it isn't an insn, then give up.  */
  2588.       if (GET_CODE (p) != INSN)
  2589.     return 0;
  2590.  
  2591.       if (reg_set_p (target, p))
  2592.     {
  2593.       rtx set = single_set (p);
  2594.       rtx dest;
  2595.  
  2596.       /* If it isn't an easy to recognize insn, then give up.  */
  2597.       if (! set)
  2598.         return 0;
  2599.  
  2600.       dest = SET_DEST (set);
  2601.  
  2602.       /* If this sets the entire target register to zero, then our
  2603.          first_insn is redundant.  */
  2604.       if (rtx_equal_p (dest, target)
  2605.           && SET_SRC (set) == const0_rtx)
  2606.         return 1;
  2607.       else if (GET_CODE (dest) == STRICT_LOW_PART
  2608.            && GET_CODE (XEXP (dest, 0)) == REG
  2609.            && REGNO (XEXP (dest, 0)) == REGNO (target)
  2610.            && (GET_MODE_SIZE (GET_MODE (XEXP (dest, 0)))
  2611.                <= GET_MODE_SIZE (mode)))
  2612.         /* This is a strict low part set which modifies less than
  2613.            we are using, so it is safe.  */
  2614.         ;
  2615.       else
  2616.         return 0;
  2617.     }
  2618.  
  2619.       p = prev_nonnote_insn (p);
  2620.  
  2621.     }
  2622.  
  2623.   return 0;
  2624. }
  2625.  
  2626. /* Accept integer operands in the range 0..0xffffffff.  We have to check the
  2627.    range carefully since this predicate is used in DImode contexts.  Also, we
  2628.    need some extra crud to make it work when hosted on 64-bit machines.  */
  2629.  
  2630. int
  2631. const_uint32_operand (op, mode)
  2632.      rtx op;
  2633.      enum machine_mode mode;
  2634. {
  2635. #if HOST_BITS_PER_WIDE_INT > 32
  2636.   /* All allowed constants will fit a CONST_INT.  */
  2637.   return (GET_CODE (op) == CONST_INT
  2638.       && (INTVAL (op) >= 0 && INTVAL (op) <= 0xffffffffL));
  2639. #else
  2640.   return ((GET_CODE (op) == CONST_INT && INTVAL (op) >= 0)
  2641.       || (GET_CODE (op) == CONST_DOUBLE && CONST_DOUBLE_HIGH (op) == 0));
  2642. #endif
  2643. }
  2644.  
  2645. /* Accept integer operands in the range -0x80000000..0x7fffffff.  We have
  2646.    to check the range carefully since this predicate is used in DImode
  2647.    contexts.  */
  2648.  
  2649. int
  2650. const_sint32_operand (op, mode)
  2651.      rtx op;
  2652.      enum machine_mode mode;
  2653. {
  2654.   /* All allowed constants will fit a CONST_INT.  */
  2655.   return (GET_CODE (op) == CONST_INT
  2656.       && (INTVAL (op) >= (-0x7fffffff - 1) && INTVAL (op) <= 0x7fffffff));
  2657. }
  2658.