41b33631efa6fe17136e6299711f2c5be1b802b4
[gcc.git] / gcc / config / elxsi / elxsi.c
1 /* Subroutines for insn-output.c for GNU compiler. Elxsi version.
2 Copyright (C) 1987, 1992, 1998, 1999, 2000 Free Software Foundation, Inc
3 Contributrd 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 2, 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 "config.h"
25 #include "system.h"
26 #include "rtl.h"
27 #include "function.h"
28 #include "output.h"
29 #include "tm_p.h"
30 #include "target.h"
31 #include "target-def.h"
32
33 extern const char *reg_names[];
34 rtx cmp_op0=0, cmp_op1=0;
35
36 /* table of relations for compares and branches */
37 static const char *const cmp_tab[] = {
38 "gt", "gt", "eq", "eq", "ge", "ge", "lt", "lt", "ne", "ne",
39 "le", "le" };
40 \f
41 /* Initialize the GCC target structure. */
42
43 struct gcc_target target = TARGET_INITIALIZER;
44 \f
45 /* type is the index into the above table */
46 /* s is "" for signed, or "u" for unsigned */
47 const char *
48 cmp_jmp (s, type, where)
49 const char *s;
50 int type;
51 rtx where;
52 {
53 rtx br_ops[3];
54 char template[50];
55 const char *f = "";
56 const char *bits = "64";
57 if (GET_MODE (cmp_op0) == SFmode) f = "f", bits = "32";
58 if (GET_MODE (cmp_op0) == DFmode) f = "f";
59 br_ops[0] = where;
60 br_ops[1] = cmp_op0;
61 br_ops[2] = cmp_op1;
62 if (cmp_op1)
63 sprintf(template, "%scmp%s.br.%s\t%%1,%%2:j%s\t%%l0",
64 f, s, bits, cmp_tab[type]);
65 else if (*f)
66 sprintf(template, "fcmp.br.%s\t%%1,=0:j%s\t%%l0",
67 bits, cmp_tab[type]);
68 else if (*s) /* can turn the below in to a jmp ... */
69 sprintf(template, "cmpu.br.64\t%%1,=0:j%s\t%%l0", s);
70 else
71 sprintf(template, "jmp.%s\t%%1,%%l0", cmp_tab[type+1]);
72 output_asm_insn(template, br_ops);
73 return "";
74 }
75
76 const char *
77 cmp_set (s, type, reg)
78 const char *s, *type;
79 rtx reg;
80 {
81 rtx br_ops[3];
82 char template[50];
83 const char *f = "";
84 const char *bits = "64";
85 if (GET_MODE (cmp_op0) == SFmode) f = "f", bits = "32";
86 else if (GET_MODE (cmp_op0) == DFmode) f = "f";
87 else if (GET_MODE (cmp_op0) == SImode) bits = "32";
88 else if (GET_MODE (cmp_op0) == HImode) bits = "16";
89 else if (GET_MODE (cmp_op0) == QImode) bits = "8";
90 br_ops[0] = reg;
91 br_ops[1] = cmp_op0;
92 br_ops[2] = cmp_op1;
93 if (cmp_op1)
94 sprintf(template, "%scmp%s.%s\t%%0,%%1,%%2:%s",
95 f, s, bits, type);
96 else
97 sprintf(template, "%scmp%s.%s\t%%0,%%1,=0:%s",
98 f, s, bits, type);
99 output_asm_insn(template, br_ops);
100 return "";
101 }
102
103 void
104 print_operand_address (file, addr)
105 FILE *file;
106 register rtx addr;
107 {
108 register rtx reg1, reg2, breg, ireg;
109 rtx offset;
110
111 switch (GET_CODE (addr))
112 {
113
114 case MEM:
115 if (GET_CODE (XEXP (addr, 0)) == REG)
116 fprintf (file, "%s", reg_names[REGNO (addr)]);
117 else abort();
118 break;
119
120 case REG:
121 fprintf (file, "[%s]", reg_names[REGNO (addr)]);
122 break;
123
124 case PLUS:
125 reg1 = 0; reg2 = 0;
126 ireg = 0; breg = 0;
127 offset = 0;
128 if (GET_CODE (XEXP (addr, 0)) == REG)
129 {
130 offset = XEXP (addr, 1);
131 addr = XEXP (addr, 0);
132 }
133 else if (GET_CODE (XEXP (addr, 1)) == REG)
134 {
135 offset = XEXP (addr, 0);
136 addr = XEXP (addr, 1);
137 }
138 fprintf (file, "[%s]", reg_names[REGNO (addr)]);
139 output_address (offset);
140 break;
141
142 default:
143 output_addr_const (file, addr);
144 }
145 }