home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 8 / FreshFishVol8-CD1.bin / gnu / src / amiga / gcc-2.3.3-src.lha / gcc-2.3.3 / config / m68k.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-02-07  |  51.9 KB  |  2,001 lines

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