home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 4 / FreshFish_May-June1994.bin / bbs / gnu / gcc-2.5.8-src.lha / src / amiga / gcc-2.5.8 / config / m68k / m68k.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-02-22  |  59.8 KB  |  2,339 lines

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