home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-dist / gcc-2.7.2.1-base.tgz / gcc-2.7.2.1-base.tar / fsf / gcc / config / elxsi / elxsi.c next >
C/C++ Source or Header  |  1995-06-15  |  4KB  |  128 lines

  1. /* Subroutines for insn-output.c for GNU compiler.  Elxsi version.
  2.    Copyright (C) 1987, 1992 Free Software Foundation, Inc
  3.    This port, done by Mike Stump <mrs@cygnus.com> in 1988, and is the first
  4.    64 bit port of GNU CC.
  5.    Based upon the VAX port.
  6.  
  7. This file is part of GNU CC.
  8.  
  9. GNU CC is free software; you can redistribute it and/or modify
  10. it under the terms of the GNU General Public License as published by
  11. the Free Software Foundation; either version 1, or (at your option)
  12. any later version.
  13.  
  14. GNU CC is distributed in the hope that it will be useful,
  15. but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  17. GNU General Public License for more details.
  18.  
  19. You should have received a copy of the GNU General Public License
  20. along with GNU CC; see the file COPYING.  If not, write to
  21. the Free Software Foundation, 59 Temple Place - Suite 330,
  22. Boston, MA 02111-1307, USA.  */
  23.  
  24. #include <stdio.h>
  25. #include "config.h"
  26. #include "rtl.h"
  27.  
  28. extern char *reg_names[];
  29. rtx cmp_op0=0, cmp_op1=0;
  30.  
  31. /* table of relations for compares and branches */
  32. char *cmp_tab[] = {
  33.     "gt", "gt", "eq", "eq", "ge", "ge", "lt", "lt", "ne", "ne",
  34.     "le", "le" };
  35.  
  36. /* type is the index into the above table */
  37. /* s is "" for signed, or "u" for unsigned */
  38. char *cmp_jmp(s, type, where) char *s; rtx where; {
  39.     rtx br_ops[3];
  40.     char template[50];
  41.     char *f = "";
  42.     char *bits = "64";
  43.     if (GET_MODE (cmp_op0) == SFmode) f = "f", bits = "32";
  44.     if (GET_MODE (cmp_op0) == DFmode) f = "f";
  45.     br_ops[0] = where;
  46.     br_ops[1] = cmp_op0;
  47.     br_ops[2] = cmp_op1;
  48.     if (cmp_op1)
  49.     sprintf(template, "%scmp%s.br.%s\t%%1,%%2:j%s\t%%l0",
  50.         f, s, bits, cmp_tab[type]);
  51.     else if (*f)
  52.     sprintf(template, "fcmp.br.%s\t%%1,=0:j%s\t%%l0",
  53.         bits, cmp_tab[type]);
  54.     else if (*s) /* can turn the below in to a jmp ... */
  55.     sprintf(template, "cmpu.br.64\t%%1,=0:j%s\t%%l0", s, cmp_tab[type]);
  56.     else
  57.     sprintf(template, "jmp.%s\t%%1,%%l0", cmp_tab[type+1]);
  58.     output_asm_insn(template, br_ops);
  59.     return "";
  60. }
  61.  
  62. char *cmp_set(s, type, reg) char *s, *type; rtx reg; {
  63.     rtx br_ops[3];
  64.     char template[50];
  65.     char *f = "";
  66.     char *bits = "64";
  67.     if (GET_MODE (cmp_op0) == SFmode) f = "f", bits = "32";
  68.     else if (GET_MODE (cmp_op0) == DFmode) f = "f";
  69.     else if (GET_MODE (cmp_op0) == SImode) bits = "32";
  70.     else if (GET_MODE (cmp_op0) == HImode) bits = "16";
  71.     else if (GET_MODE (cmp_op0) == QImode) bits = "8";
  72.     br_ops[0] = reg;
  73.     br_ops[1] = cmp_op0;
  74.     br_ops[2] = cmp_op1;
  75.     if (cmp_op1)
  76.     sprintf(template, "%scmp%s.%s\t%%0,%%1,%%2:%s",
  77.         f, s, bits, type);
  78.     else
  79.     sprintf(template, "%scmp%s.%s\t%%0,%%1,=0:%s",
  80.         f, s, bits, type);
  81.     output_asm_insn(template, br_ops);
  82.     return "";
  83. }
  84.  
  85. print_operand_address (file, addr)
  86.      FILE *file;
  87.      register rtx addr;
  88. {
  89.   register rtx reg1, reg2, breg, ireg;
  90.   rtx offset;
  91.  
  92.  retry:
  93.   switch (GET_CODE (addr))
  94.     {
  95.  
  96.     case MEM:
  97.       if (GET_CODE (XEXP (addr, 0)) == REG)
  98.         fprintf (file, "%s", reg_names[REGNO (addr)]);
  99.       else abort();
  100.       break;
  101.  
  102.     case REG:
  103.       fprintf (file, "[%s]", reg_names[REGNO (addr)]);
  104.       break;
  105.  
  106.     case PLUS:
  107.       reg1 = 0;    reg2 = 0;
  108.       ireg = 0;    breg = 0;
  109.       offset = 0;
  110.       if (GET_CODE (XEXP (addr, 0)) == REG)
  111.     {
  112.       offset = XEXP (addr, 1);
  113.       addr = XEXP (addr, 0);
  114.     }
  115.       else if (GET_CODE (XEXP (addr, 1)) == REG)
  116.     {
  117.       offset = XEXP (addr, 0);
  118.       addr = XEXP (addr, 1);
  119.     }
  120.       fprintf (file, "[%s]", reg_names[REGNO (addr)]);
  121.       output_address (offset);
  122.       break;
  123.  
  124.     default:
  125.       output_addr_const (file, addr);
  126.     }
  127. }
  128.