Quick Search:

View

Revision:
Expand:  
Changeset: MAIN:ragge:20081130210024

Diff

Diff from 1.12 to:

Annotations

Annotate by Age | Author | Mixed | None
/fisheye/browse/pcc/pcc/arch/mips/order.c

Annotated File View

ragge
1.12
1 /*      $Id: order.c,v 1.12 2008/11/30 21:00:24 ragge Exp $     */
ragge
1.1
2 /*
3  * Copyright (c) 2003 Anders Magnusson (ragge@ludd.luth.se).
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 (janeno-1@student.ltu.se) and
31  * Simon Olsson (simols-1@student.ltu.se) 2005.
32  */
33
gmcgarry
1.4
34 #include "pass2.h"
ragge
1.1
35
gmcgarry
1.4
36 /*
37  * is it legal to make an OREG or NAME entry which has an offset of off,
38  * (from a register of r), if the resulting thing had type t
39  */
ragge
1.1
40 int
41 notoff(TWORD tint rCONSZ offchar *cp)
42 {
gmcgarry
1.10
43         /*
44          * although the hardware doesn't permit offsets greater
45          * than +/- 32K, the assembler fixes it for us.
46          */
gmcgarry
1.9
47         return 0;               /* YES */
ragge
1.1
48 }
49
50 /*
51  * Turn a UMUL-referenced node into OREG.
52  */
gmcgarry
1.2
53 void
gmcgarry
1.4
54 offstar(NODE * pint shape)
ragge
1.1
55 {
gmcgarry
1.4
56         if (x2debug)
57                 printf("offstar(%p)\n"p);
ragge
1.1
58
gmcgarry
1.4
59         if (p->n_op == PLUS || p->n_op == MINUS) {
60                 if (p->n_right->n_op == ICON) {
61                         if (isreg(p->n_left) == 0)
62                                 (void)geninsn(p->n_leftINAREG);
63                         /* Converted in ormake() */
64                         return;
65                 }
ragge
1.1
66         }
gmcgarry
1.4
67         (void)geninsn(pINAREG);
gmcgarry
1.2
68 }
69
70 /*
71  * Do the actual conversion of offstar-found OREGs into real OREGs.
72  */
73 void
gmcgarry
1.4
74 myormake(NODE * q)
gmcgarry
1.2
75 {
76         if (x2debug)
77                 printf("myormake(%p)\n"q);
ragge
1.1
78 }
79
80 /*
81  * Shape matches for UMUL.  Cooperates with offstar().
82  */
83 int
ragge
1.12
84 shumul(NODE *pint shape)
ragge
1.1
85 {
gmcgarry
1.4
86         if (x2debug)
87                 printf("shumul(%p)\n"p);
ragge
1.1
88
gmcgarry
1.4
89         /* Always turn it into OREG */
ragge
1.11
90         if (shape & SOREG)
91                 return SROREG;
92         return SRNOPE;
ragge
1.1
93 }
94
95 /*
96  * Rewrite operations on binary operators (like +, -, etc...).
97  * Called as a result of table lookup.
98  */
99 int
gmcgarry
1.4
100 setbin(NODE * p)
ragge
1.1
101 {
102
gmcgarry
1.4
103         if (x2debug)
104                 printf("setbin(%p)\n"p);
105         return 0;
ragge
1.1
106
107 }
108
109 /* setup for assignment operator */
110 int
gmcgarry
1.4
111 setasg(NODE * pint cookie)
ragge
1.1
112 {
gmcgarry
1.4
113         if (x2debug)
114                 printf("setasg(%p)\n"p);
115         return (0);
ragge
1.1
116 }
117
118 /* setup for unary operator */
119 int
gmcgarry
1.4
120 setuni(NODE * pint cookie)
ragge
1.1
121 {
gmcgarry
1.4
122         return 0;
ragge
1.1
123 }
124
125 /*
126  * Special handling of some instruction register allocation.
127  * - left is the register that left node wants.
128  * - right is the register that right node wants.
129  * - res is in which register the result will end up.
130  * - mask is registers that will be clobbered.
131  */
132 struct rspecial *
gmcgarry
1.4
133 nspecial(struct optab * q)
ragge
1.1
134 {
gmcgarry
1.4
135         switch (q->op) {
ragge
1.1
136
gmcgarry
1.7
137         case SCONV:
gmcgarry
1.8
138                 if (q->lshape == SBREG && q->rshape == SCREG) {
gmcgarry
1.7
139                         static struct rspecial s[] = {
140                                 { NLEFTA0A1 },
141                                 { NRESF0 },
142                                 { 0 }
143                         };
144                         return s;
gmcgarry
1.8
145                 } else if (q->lshape == SCREG && q->rshape == SBREG) {
146                         static struct rspecial s[] = {
147                                 { NLEFTF0 },
148                                 { NRESA0A1 },
149                                 { 0 }
150                         };
151                         return s;
152                 } else if (q->lshape == SAREG && q->rshape == SCREG) {
gmcgarry
1.7
153                         static struct rspecial s[] = {
154                                 { NLEFTA0 },
155                                 { NRESF0 },
156                                 { 0 }
157                         };
158                         return s;
159                 }
gmcgarry
1.8
160                 break;
gmcgarry
1.7
161
gmcgarry
1.4
162         case MOD:
163         case DIV:
gmcgarry
1.7
164                 if (q->lshape == SBREG) {
165                         static struct rspecial s[] = {
166                                 { NLEFTA0A1 },
167                                 { NRIGHTA2A3 },
168                                 { NRESV0V1 },
169                                 { 0 },
170                         };
171                         return s;
172                 } else if (q->lshape == SAREG) {
173                         static struct rspecial s[] = {
174                                 { NLEFTA0 },
175                                 { NRIGHTA1 },
176                                 { NRESV0 },
177                                 { 0 },
178                         };
179                         return s;
180                 }
181
gmcgarry
1.4
182         case RS:
183         case LS:
184                 if (q->lshape == SBREG) {
185                         static struct rspecial s[] = {
186                                 { NLEFTA0A1 },
gmcgarry
1.7
187                                 { NRIGHTA2 },
gmcgarry
1.4
188                                 { NRESV0V1 },
gmcgarry
1.7
189                                 { 0 },
190                         };
191                         return s;
192                 } else if (q->lshape == SAREG) {
193                         static struct rspecial s[] = {
194                                 { NLEFTA0 },
195                                 { NRIGHTA1 },
196                                 { NRESV0 },
gmcgarry
1.4
197                                 { 0 },
198                         };
199                         return s;
200                 }
201                 break;
202
gmcgarry
1.7
203         case STARG:
204                 {
205                         static struct rspecial s[] = {
206                                 { NEVERA0 },
207                                 { NLEFTA1 },
208                                 { NEVERA2 },
209                                 { 0 }
210                         };
211                         return s;
212                 }
213
gmcgarry
1.4
214         case STASG:
215                 {
216                         static struct rspecial s[] = {
217                                 { NEVERA0 },
218                                 { NRIGHTA1 },
219                                 { NEVERA2 },
gmcgarry
1.7
220                                 { 0 }
221                         };
gmcgarry
1.4
222                         return s;
223                 }
224         }
ragge
1.1
225
gmcgarry
1.4
226         comperr("nspecial entry %d: %s"q - tableq->cstring);
ragge
1.1
227
gmcgarry
1.4
228         return 0;               /* XXX gcc */
ragge
1.1
229 }
230
gmcgarry
1.2
231 /*
232  * Set evaluation order of a binary node if it differs from default.
233  */
234 int
gmcgarry
1.4
235 setorder(NODE * p)
gmcgarry
1.2
236 {
gmcgarry
1.4
237         return 0;               /* nothing differs */
gmcgarry
1.2
238 }
gmcgarry
1.8
239
ragge
1.3
240 /*
241  * Set registers "live" at function calls (like arguments in registers).
242  * This is for liveness analysis of registers.
243  */
244 int *
245 livecall(NODE *p)
246 {
247         static int r[1] = { -1 }; /* Terminate with -1 */
248
249         return &r[0];
250 }
251
gmcgarry
1.5
252 /*
253  * Signal whether the instruction is acceptable for this target.
254  */
255 int
256 acceptable(struct optab *op)
257 {
258         return 1;
259 }
FishEye: Open Source License registered to PCC.
Atlassian FishEye, CVS analysis. (Version:1.6.3 Build:build-336 2008-11-04) - Administration - Page generated 2014-12-18 06:50 +0100