Debian Codegraph @

arch/mips64/order.c

raw symbols SCIP
1 /* $Id: order.c,v 1.1 2016/07/06 07:49:48 ragge Exp $ */
2 /*
3 * Copyright (c) 2003 Anders Magnusson ([email protected]).
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29 /*
30 * MIPS port by Jan Enoksson ([email protected]) and
31 * Simon Olsson ([email protected]) 2005.
32 *
33 * Extended to MIPS64 by Brian Callahan <[email protected]> 2016.
34 */
35
36 #include "pass2.h"
37
38 /*
39 * is it legal to make an OREG or NAME entry which has an offset of off,
40 * (from a register of r), if the resulting thing had type t
41 */
42 int
43 notoff(TWORD t, int r, CONSZ off, char *cp)
44 {
45 /*
46 * although the hardware doesn't permit offsets greater
47 * than +/- 32K, the assembler fixes it for us.
48 */
49 return 0; /* YES */
50 }
51
52 /*
53 * Turn a UMUL-referenced node into OREG.
54 */
55 void
56 offstar(NODE * p, int shape)
57 {
58 if (x2debug)
59 printf("offstar(%p)\n", p);
60
61 if (p->n_op == PLUS || p->n_op == MINUS) {
62 if (p->n_right->n_op == ICON) {
63 if (isreg(p->n_left) == 0)
64 (void)geninsn(p->n_left, INAREG);
65 /* Converted in ormake() */
66 return;
67 }
68 }
69 (void)geninsn(p, INAREG);
70 }
71
72 /*
73 * Do the actual conversion of offstar-found OREGs into real OREGs.
74 */
75 void
76 myormake(NODE * q)
77 {
78 if (x2debug)
79 printf("myormake(%p)\n", q);
80 }
81
82 /*
83 * Shape matches for UMUL. Cooperates with offstar().
84 */
85 int
86 shumul(NODE *p, int shape)
87 {
88 if (x2debug)
89 printf("shumul(%p)\n", p);
90
91 /* Always turn it into OREG */
92 if (shape & SOREG)
93 return SROREG;
94 return SRNOPE;
95 }
96
97 /*
98 * Rewrite operations on binary operators (like +, -, etc...).
99 * Called as a result of table lookup.
100 */
101 int
102 setbin(NODE * p)
103 {
104
105 if (x2debug)
106 printf("setbin(%p)\n", p);
107 return 0;
108
109 }
110
111 /* setup for assignment operator */
112 int
113 setasg(NODE * p, int cookie)
114 {
115 if (x2debug)
116 printf("setasg(%p)\n", p);
117 return (0);
118 }
119
120 /* setup for unary operator */
121 int
122 setuni(NODE * p, int cookie)
123 {
124 return 0;
125 }
126
127 /*
128 * Special handling of some instruction register allocation.
129 * - left is the register that left node wants.
130 * - right is the register that right node wants.
131 * - res is in which register the result will end up.
132 * - mask is registers that will be clobbered.
133 */
134 struct rspecial *
135 nspecial(struct optab * q)
136 {
137 switch (q->op) {
138
139 case SCONV:
140 if (q->lshape == SBREG && q->rshape == SCREG) {
141 static struct rspecial s[] = {
142 { NLEFT, A0A1 },
143 { NRES, F0 },
144 { 0 }
145 };
146 return s;
147 } else if (q->lshape == SCREG && q->rshape == SBREG) {
148 static struct rspecial s[] = {
149 { NLEFT, F0 },
150 { NRES, A0A1 },
151 { 0 }
152 };
153 return s;
154 } else if (q->lshape == SAREG && q->rshape == SCREG) {
155 static struct rspecial s[] = {
156 { NLEFT, A0 },
157 { NRES, F0 },
158 { 0 }
159 };
160 return s;
161 }
162 break;
163
164 case MOD:
165 case DIV:
166 if (q->lshape == SBREG) {
167 static struct rspecial s[] = {
168 { NLEFT, A0A1 },
169 { NRIGHT, A2A3 },
170 { NRES, V0V1 },
171 { 0 },
172 };
173 return s;
174 } else if (q->lshape == SAREG) {
175 static struct rspecial s[] = {
176 { NLEFT, A0 },
177 { NRIGHT, A1 },
178 { NRES, V0 },
179 { 0 },
180 };
181 return s;
182 }
183
184 case RS:
185 case LS:
186 if (q->lshape == SBREG) {
187 static struct rspecial s[] = {
188 { NLEFT, A0A1 },
189 { NRIGHT, A2 },
190 { NRES, V0V1 },
191 { 0 },
192 };
193 return s;
194 } else if (q->lshape == SAREG) {
195 static struct rspecial s[] = {
196 { NLEFT, A0 },
197 { NRIGHT, A1 },
198 { NRES, V0 },
199 { 0 },
200 };
201 return s;
202 }
203 break;
204
205 case STARG:
206 {
207 static struct rspecial s[] = {
208 { NEVER, A0 },
209 { NLEFT, A1 },
210 { NEVER, A2 },
211 { 0 }
212 };
213 return s;
214 }
215
216 case STASG:
217 {
218 static struct rspecial s[] = {
219 { NEVER, A0 },
220 { NRIGHT, A1 },
221 { NEVER, A2 },
222 { 0 }
223 };
224 return s;
225 }
226 }
227
228 comperr("nspecial entry %d: %s", q - table, q->cstring);
229
230 return 0; /* XXX gcc */
231 }
232
233 /*
234 * Set evaluation order of a binary node if it differs from default.
235 */
236 int
237 setorder(NODE * p)
238 {
239 return 0; /* nothing differs */
240 }
241
242 /*
243 * Set registers "live" at function calls (like arguments in registers).
244 * This is for liveness analysis of registers.
245 */
246 int *
247 livecall(NODE *p)
248 {
249 static int r[1] = { -1 }; /* Terminate with -1 */
250
251 return &r[0];
252 }
253
254 /*
255 * Signal whether the instruction is acceptable for this target.
256 */
257 int
258 acceptable(struct optab *op)
259 {
260 return 1;
261 }