home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 9 / FreshFishVol9-CD2.bin / bbs / gnu / gcc-2.6.3-src.lha / gcc-2.6.3 / config / m68k / m68k.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-12-03  |  59.6 KB  |  2,327 lines

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