Quick Search:

View

Revision:
Expand:  
Changeset: MAIN:ragge:20100919135441

Diff

Diff from 1.14 to:

Annotations

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

Annotated File View

ragge
1.14
1 /*      $Id: table.c,v 1.14 2010/09/19 13:54:41 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.
gmcgarry
1.2
32  *
33  * It appears that the target machine was big endian.  The original
34  * code contained many endian aspects which are now handled in
35  * machine-independent code.
36  * 
gmcgarry
1.3
37  * On MIPS, the assembler does an amazing amount of work for us.
38  * We don't have to worry about PIC, nor about finding the address
39  * of SNAMES.  Whenever possible, we defer the work to the assembler.
ragge
1.1
40  */
41
gmcgarry
1.3
42 #include "pass2.h"
43
44 #define TUWORD TUNSIGNED|TULONG
45 #define TSWORD TINT|TLONG
46 #define TWORD TUWORD|TSWORD
ragge
1.1
47
48 struct optab table[] = {
49 /* First entry must be an empty entry */
50 { -1FOREFFSANYTANYSANYTANY00"", },
51
gmcgarry
1.9
52 /* PCONVs are usually not necessary */
53 PCONV,        INAREG,
54         SAREG,  TWORD|TPOINT,
55         SAREG,  TWORD|TPOINT,
56                 0,      RLEFT,
57                 "       # convert between word and pointer", },
58
ragge
1.1
59 /*
gmcgarry
1.8
60  * Conversions of integral<->integral types
ragge
1.1
61  */
62
gmcgarry
1.2
63 SCONV,        INAREG,
ragge
1.1
64         SOREG,  TCHAR,
gmcgarry
1.9
65         SAREG,  TSWORD|TSHORT,
66                 NAREG,  RESC1,
67                 "       lb A1,AL        # convert oreg char to short/int\n"
68                 "       nop\n", },
69
70 SCONV,        INAREG,
71         SOREG,  TCHAR,
72         SAREG,  TUWORD|TUSHORT|TUCHAR,
ragge
1.1
73                 NAREG,  RESC1,
gmcgarry
1.12
74                 "       lbu A1,AL       # convert oreg char to uchar/ushort/uint\n"
gmcgarry
1.2
75                 "       nop\n", },
ragge
1.1
76
gmcgarry
1.2
77 SCONV,        INAREG,
ragge
1.1
78         SOREG,  TUCHAR,
gmcgarry
1.3
79         SAREG,  TWORD|TSHORT|TUSHORT,
ragge
1.1
80                 NAREG,  RESC1,
gmcgarry
1.9
81                 "       lbu A1,AL       # convert oreg uchar to (u)short/(u)int\n"
gmcgarry
1.2
82                 "       nop\n", },
ragge
1.1
83
gmcgarry
1.2
84 SCONV,        INBREG,
ragge
1.1
85         SOREG,  TCHAR,
gmcgarry
1.9
86         SBREG,  TLONGLONG,
gmcgarry
1.2
87                 NBREG,  RESC1,
gmcgarry
1.9
88                 "       lb A1,AL        # convert oreg char to longlong\n"
ragge
1.1
89                 "       nop\n"
gmcgarry
1.9
90                 "       sra U1,A1,31\n", },
91
92 /* chor -> ulonglong handled later */
ragge
1.1
93
gmcgarry
1.2
94 SCONV,        INBREG,
ragge
1.1
95         SOREG,  TUCHAR,
gmcgarry
1.9
96         SBREG,  TLONGLONG|TULONGLONG,
gmcgarry
1.2
97                 NBREG,  RESC1,
gmcgarry
1.9
98                 "       lbu A1,AL       # convert oreg uchar to (u)longlong\n"
99                 "       move U1,$zero\n", },
ragge
1.1
100
gmcgarry
1.2
101 SCONV,        INAREG,
ragge
1.1
102         SOREG,  TSHORT|TUSHORT,
103         SAREG,  TCHAR,
104                 NAREG,  RESC1,
gmcgarry
1.3
105                 "       lb A1,AL        # convert oreg (u)short to char (endianness problem?)\n"
gmcgarry
1.2
106                 "       nop\n", },
ragge
1.1
107
gmcgarry
1.2
108 SCONV,        INAREG,
ragge
1.1
109         SOREG,  TSHORT|TUSHORT,
110         SAREG,  TUCHAR,
111                 NAREG,  RESC1,
gmcgarry
1.3
112                 "       lbu A1,AL       # convert oreg (u)short to uchar (endianness problem?)\n"
gmcgarry
1.2
113                 "       nop\n", },
ragge
1.1
114
gmcgarry
1.2
115 SCONV,        INAREG,
ragge
1.1
116         SOREG,  TSHORT,
gmcgarry
1.9
117         SAREG,  TSWORD,
118                 NAREG,  RESC1,
119                 "       lh A1,AL        # convert oreg short to int\n"
120                 "       nop\n", },
121
122 SCONV,        INAREG,
123         SOREG,  TSHORT,
124         SAREG,  TUWORD,
ragge
1.1
125                 NAREG,  RESC1,
gmcgarry
1.9
126                 "       lhu A1,AL       # convert oreg short to uint\n"
gmcgarry
1.2
127                 "       nop\n", },
ragge
1.1
128
gmcgarry
1.2
129 SCONV,        INAREG,
ragge
1.1
130         SOREG,  TUSHORT,
131         SAREG,  TWORD,
132                 NAREG,  RESC1,
gmcgarry
1.2
133                 "       lhu A1,AL       # convert oreg ushort to (u)int\n"
134                 "       nop\n", },
ragge
1.1
135
gmcgarry
1.2
136 SCONV,        INBREG,
ragge
1.1
137         SOREG,  TSHORT,
gmcgarry
1.9
138         SBREG,  TLONGLONG,
139                 NBREG,  RESC1,
140                 "       lh A1,AL        # convert oreg short to longlong\n"
141                 "       nop\n"
142                 "       sra U1,A1,31\n", },
143
144 SCONV,        INBREG,
145         SOREG,  TSHORT,
146         SBREG,  TULONGLONG,
gmcgarry
1.2
147                 NBREG,  RESC1,
gmcgarry
1.9
148                 "       lhu A1,AL       # convert oreg short to ulonglong\n"
ragge
1.1
149                 "       nop\n"
gmcgarry
1.9
150                 "       move U1,$zero\n", },
ragge
1.1
151
gmcgarry
1.2
152 SCONV,        INBREG,
ragge
1.1
153         SOREG,  TUSHORT,
gmcgarry
1.9
154         SBREG,  TLONGLONG|TULONGLONG,
gmcgarry
1.2
155                 NBREG,  RESC1,
gmcgarry
1.9
156                 "       lhu A1,AL       # convert oreg ushort to (u)longlong\n"
157                 "       move U1,$zero\n", },
ragge
1.1
158
gmcgarry
1.2
159 SCONV,        INAREG,
ragge
1.1
160         SOREG,  TWORD,
161         SAREG,  TCHAR,
162                 NAREG,  RESC1,
gmcgarry
1.3
163                 "       lb A1,AL        # convert oreg word to char (endianness problem here?)\n"
gmcgarry
1.2
164                 "       nop\n", },
ragge
1.1
165
gmcgarry
1.2
166 SCONV,        INAREG,
ragge
1.1
167         SOREG,  TWORD,
168         SAREG,  TUCHAR,
169                 NAREG,  RESC1,
gmcgarry
1.4
170                 "       lbu A1,AL       # convert oreg word to uchar (endianness problem here?)\n"
gmcgarry
1.2
171                 "       nop\n", },
ragge
1.1
172     
gmcgarry
1.2
173 SCONV,        INAREG,
ragge
1.1
174         SOREG,  TWORD,
175         SAREG,  TSHORT,
176                 NAREG,  RESC1,
gmcgarry
1.4
177                 "       lh A1,AL        # convert oreg word to short (endianness problem here?)\n"
gmcgarry
1.2
178                 "       nop\n", },
ragge
1.1
179
180 /* convert (u)long to ushort */
gmcgarry
1.2
181 SCONV,        INAREG,
ragge
1.1
182         SOREG,  TWORD,
183         SAREG,  TUSHORT,
184                 NAREG,  RESC1,
gmcgarry
1.4
185                 "       lhu A1,AL       # convert oreg word to ushort (endianness problem here?)\n"
gmcgarry
1.2
186                 "       nop\n", },
ragge
1.1
187
gmcgarry
1.2
188 SCONV,        INBREG,
ragge
1.1
189         SOREG,  TSWORD,
gmcgarry
1.9
190         SBREG,  TLONGLONG|TULONGLONG,
gmcgarry
1.2
191                 NBREG,  RESC1,
gmcgarry
1.3
192                 "       lw A1,AL        # convert oreg int/long to (u)llong (endianness problem here?)\n"
ragge
1.1
193                 "       nop\n"
gmcgarry
1.9
194                 "       sra U1,A1,31\n" },
ragge
1.1
195
gmcgarry
1.2
196 SCONV,        INBREG,
ragge
1.1
197         SOREG,  TUWORD,
gmcgarry
1.9
198         SBREG,  TLONGLONG|TULONGLONG,
gmcgarry
1.2
199                 NBREG,  RESC1,
gmcgarry
1.3
200                 "       lw A1,AL        # convert oreg (u)int to (u)llong (endianness problem here?)\n"
gmcgarry
1.5
201                 "       move U1,$zero\n", },
ragge
1.1
202
gmcgarry
1.2
203 SCONV,        INAREG,
gmcgarry
1.9
204         SOREG,  TLONGLONG|TULONGLONG,
ragge
1.1
205         SAREG,  TCHAR,
206                 NAREG,  RESC1,
gmcgarry
1.3
207                 "       lb A1,AL        # convert oreg (u)llong to char (endianness problem here?)\n"
gmcgarry
1.2
208                 "       nop\n", },
ragge
1.1
209
gmcgarry
1.2
210 SCONV,        INAREG,
gmcgarry
1.9
211         SOREG,  TLONGLONG|TULONGLONG,
ragge
1.1
212         SAREG,  TUCHAR,
213                 NAREG,  RESC1,
gmcgarry
1.3
214                 "       lbu A1,AL       # convert oreg (u)llong to uchar (endianness problem?)\n"
gmcgarry
1.2
215                 "       nop\n", },
ragge
1.1
216     
gmcgarry
1.2
217 SCONV,        INAREG,
gmcgarry
1.9
218         SOREG,  TLONGLONG|TULONGLONG,
ragge
1.1
219         SAREG,  TSHORT,
220                 NAREG,  RESC1,
gmcgarry
1.3
221                 "       lh A1,AL        # convert oreg (u)llong to short (endianness problem?)\n"
gmcgarry
1.2
222                 "       nop\n", },
ragge
1.1
223
gmcgarry
1.2
224 SCONV,        INAREG,
gmcgarry
1.9
225         SOREG,  TLONGLONG|TULONGLONG,
ragge
1.1
226         SAREG,  TUSHORT,
227                 NAREG,  RESC1,
gmcgarry
1.3
228                 "       lhu A1,AL       # convert oreg (u)llong to ushort (endianness problem here?)\n"
gmcgarry
1.2
229                 "       nop\n", },
ragge
1.1
230
gmcgarry
1.2
231 SCONV,        INAREG,
gmcgarry
1.9
232         SOREG,  TLONGLONG|TULONGLONG,
233         SAREG,  TWORD,
ragge
1.1
234                 NAREG,  RESC1,
gmcgarry
1.9
235                 "       lw A1,AL        # convert oreg (u)llong to (u)int (endianness problem here?)\n"
gmcgarry
1.2
236                 "       nop\n", },
ragge
1.1
237
gmcgarry
1.9
238 /*
239  * Conversions of integral types (register-register)
240  *
241  * For each deunsigned type, they look something like this:
242  *
243  * signed -> bigger signed      - nothing to do
244  * signed -> bigger unsigned    - clear the top bits (of source type)
245  *
246  * signed -> smaller signed     - sign-extend the bits (to dest type)
247  * signed -> smaller unsigned   - clear the top bits (of dest type)
248  * unsigned -> smaller signed   - sign-extend top bits (to dest type)
249  * unsigned -> smaller unsigned - clear the top bits (of dest type)
250  *
251  * unsigned -> bigger           - nothing to do
252  */
253
254 SCONV,        INAREG,
255         SAREG,  TPOINT|TWORD,
256         SAREG,  TPOINT|TWORD,
257                 0,      RLEFT,
258                 "       # convert int to int\n", },
259
260 SCONV,        INBREG,
261         SBREG,  TLONGLONG|TULONGLONG,
262         SBREG,  TLONGLONG|TULONGLONG,
263                 0,      RLEFT,
264                 "       # convert (u)longlong to (u)longlong", },
265
266 SCONV,        INAREG,
267         SAREG,  TCHAR,
268         SAREG,  TSWORD|TSHORT,
269                 0,      RLEFT,
270                 "       # convert char to short/int\n", },
271
272 SCONV,        INAREG,
273         SAREG,  TCHAR,
274         SAREG,  TUWORD|TUSHORT|TUCHAR,
275                 NAREG|NASL,     RESC1,
276                 "       andi A1,AL,255  # convert char to uchar/ushort/uint\n", },
277
278 SCONV,        INAREG,
279         SAREG,  TUCHAR,
280         SAREG,  TCHAR,
281                 NAREG|NASL,     RESC1,
282                 "       sll A1,AL,24    # convert uchar to char\n"
283                 "       sra A1,A1,24\n", },
284
285 SCONV,        INAREG,
286         SAREG,  TUCHAR,
287         SAREG,  TWORD|TSHORT|TUSHORT,
288                 0,      RLEFT,
289                 "       # convert uchar to (u)short/(u)int\n", },
290
291 SCONV,        INAREG,
292         SAREG,  TSHORT,
293         SAREG,  TCHAR,
294                 NAREG|NASL,     RESC1,
295                 "       sll A1,AL,24    # convert short to char\n"
296                 "       sra A1,A1,24\n", },
297
298 SCONV,        INAREG,
299         SAREG,  TSHORT,
300         SAREG,  TUCHAR,
301                 NAREG|NASL,     RESC1,
302                 "       andi A1,AL,255  # convert short to uchar\n", },
303
304 SCONV,        INAREG,
305         SAREG,  TSHORT,
306         SAREG,  TUWORD|TUSHORT,
307                 NAREG|NASL,     RESC1,
308                 "       andi A1,AL,65535        # convert short to ushort\n", },
309
310 SCONV,        INAREG,
311         SAREG,  TSHORT,
312         SAREG,  TSWORD,
313                 NAREG|NASL,     RESC1,
314                 "       sll A1,AL,16    # convert short to ushort\n"
315                 "       sra A1,A1,16\n", },
316
317 SCONV,        INAREG,
318         SAREG,  TUSHORT,
319         SAREG,  TCHAR,
320                 NAREG|NASL,     RESC1,
321                 "       sll A1,AL,24    # convert short to char\n"
322                 "       sra A1,A1,24\n", },
323
324 SCONV,        INAREG,
325         SAREG,  TUSHORT,
326         SAREG,  TUCHAR,
327                 NAREG|NASL,     RESC1,
328                 "       andi A1,AL,255  # convert ushort to char\n", },
329
330 SCONV,        INAREG,
331         SAREG,  TUSHORT,
332         SAREG,  TSHORT,
333                 NAREG|NASL,     RESC1,
334                 "       sll A1,AL,16    # convert short to ushort\n"
335                 "       sra A1,A1,16\n", },
336
337 SCONV,        INAREG,
338         SAREG,  TUSHORT,
339         SAREG,  TWORD,
340                 0,      RDEST,
341                 "       # convert ushort to (u)int\n", },
342
343 SCONV,        INAREG,
344         SAREG,  TSWORD,
345         SAREG,  TCHAR,
346                 NAREG|NASL,     RESC1,
347                 "       sll A1,AL,8     # convert int to char\n"
348                 "       sra A1,A1,8\n", },
349
350 SCONV,        INAREG,
351         SAREG,  TSWORD,
352         SAREG,  TUCHAR,
353                 NAREG|NASL,     RESC1,
354                 "       andi A1,AL,255  # convert int to uchar\n", },
355
356 SCONV,        INAREG,
357         SAREG,  TSWORD,
358         SAREG,  TSHORT,
359                 NAREG|NASL,     RESC1,
360                 "       sll A1,AL,16    # convert int to short\n"
361                 "       sra A1,A1,16\n", },
362
363 SCONV,        INAREG,
364         SAREG,  TSWORD,
365         SAREG,  TUSHORT,
366                 NAREG|NASL,     RESC1,
367                 "       andi A1,AL,65535        # convert int to ushort\n", },
368
gmcgarry
1.2
369 SCONV,        INAREG,
ragge
1.1
370         SAREG,  TUWORD,
gmcgarry
1.9
371         SAREG,  TCHAR,
372                 NAREG|NASL,     RESC1,
373                 "       sll A1,AL,24    # convert int to char\n"
374                 "       sra A1,A1,24\n", },
375
376 SCONV,        INAREG,
377         SAREG,  TUWORD,
378         SAREG,  TUCHAR,
379                 NAREG|NASL,     RESC1,
380                 "       andi A1,AL,255  # convert int to uchar\n", },
381
382 SCONV,        INAREG,
383         SAREG,  TUWORD,
384         SAREG,  TSHORT,
385                 NAREG|NASL,     RESC1,
386                 "       sll A1,AL,16    # convert int to short\n"
387                 "       sra A1,A1,16\n", },
ragge
1.1
388
gmcgarry
1.9
389 SCONV,        INAREG,
390         SAREG,  TUWORD,
391         SAREG,  TUSHORT,
392                 NAREG|NASL,     RESC1,
393                 "       andi A1,AL,65535        # convert int to ushort\n", },
ragge
1.1
394
gmcgarry
1.2
395 SCONV,        INBREG,
gmcgarry
1.9
396         SAREG,  TSWORD|TSHORT|TCHAR,
397         SBREG,  TLONGLONG,
398                 NBREG,  RESC1,
399                 "       move A1,AL      # convert int/short/char to longlong\n"
400                 "       sra U1,AL,31\n", },
401
402 SCONV,        INBREG,
403         SAREG,  TSWORD|TSHORT|TCHAR,
404         SBREG,  TULONGLONG,
405                 NBREG,  RESC1,
406                 "       move A1,AL      # convert int/short/char to ulonglong\n"
407                 "       move U1,$zero\n", },
ragge
1.1
408
gmcgarry
1.2
409 SCONV,        INBREG,
gmcgarry
1.9
410         SAREG,  TWORD|TUSHORT|TSHORT|TUCHAR|TCHAR,
411         SBREG,  TLONGLONG|TULONGLONG,
gmcgarry
1.4
412                 NBREG,  RESC1,
gmcgarry
1.9
413                 "       move A1,AL      # convert (u)int/(u)short/(u)char to ulonglong\n"
414                 "       move U1,$zero\n", },
ragge
1.1
415
gmcgarry
1.2
416 SCONV,        INAREG,
gmcgarry
1.9
417         SBREG,  TLONGLONG|TULONGLONG,
418         SAREG,  TWORD,
gmcgarry
1.4
419                 NAREG,  RESC1,
gmcgarry
1.9
420                 "       move A1,AL      # convert (u)longlong to int\n", },
421
422 SCONV,        INAREG,
423         SBREG,  TLONGLONG|TULONGLONG,
424         SAREG,  TSHORT,
425                 NAREG,  RESC1,
426                 "       sll A1,AL,16    # convert (u)longlong to short\n"
gmcgarry
1.12
427                 "       sra A1,A1,16\n", },
gmcgarry
1.9
428
429 SCONV,        INAREG,
430         SBREG,  TLONGLONG|TULONGLONG,
431         SAREG,  TCHAR,
432                 NAREG,  RESC1,
433                 "       sll A1,AL,24    # convert (u)longlong to char\n"
gmcgarry
1.12
434                 "       sra A1,A1,24\n", },
gmcgarry
1.9
435
436 SCONV,        INAREG,
437         SBREG,  TLONGLONG|TULONGLONG,
438         SAREG,  TUSHORT,
439                 NAREG,  RESC1,
440                 "       andi A1,AL,65535        # convert (u)longlong to ushort\n", },
ragge
1.1
441
gmcgarry
1.2
442 SCONV,        INAREG,
gmcgarry
1.9
443         SBREG,  TLONGLONG|TULONGLONG,
444         SAREG,  TUCHAR,
445                 NAREG,  RESC1,
446                 "       andi A1,AL,255  # convert (u)longlong to uchar\n", },
gmcgarry
1.4
447
448 SCONV,        INCREG,
449         SCREG,  TFLOAT,
450         SCREG,  TDOUBLE|TLDOUBLE,
451                 NCREG,  RESC1,
452                 "       cvt.d.s A1,AL   # convert float to (l)double\n", },
453
454 SCONV,        INCREG,
455         SCREG,  TDOUBLE|TLDOUBLE,
456         SCREG,  TFLOAT,
457                 NCREG,  RESC1,
458                 "       cvt.s.d A1,AL   # convert (l)double to float\n", },
459
460 SCONV,        INCREG,
461         SAREG,  TWORD,
462         SCREG,  TFLOAT,
463                 NCREG,  RESC1,
gmcgarry
1.8
464                 "       mtc1 AL,A1      # convert (u)int to float\n"
465                 "       nop\n"
466                 "       cvt.s.w A1,A1\n", },
467
468 SCONV,        INCREG,
469         SOREG,  TWORD,
470         SCREG,  TFLOAT,
471                 NCREG,  RESC1,
472                 "       l.s A1,AL       # convert (u)int to float\n"
473                 "       nop\n"
474                 "       cvt.s.w A1,A1\n", },
gmcgarry
1.4
475
476 SCONV,        INCREG,
477         SAREG,  TWORD,
478         SCREG,  TDOUBLE|TLDOUBLE,
479                 NCREG,  RESC1,
gmcgarry
1.8
480                 "       mtc1 AL,A1      # convert (u)int to (l)double\n"
481                 "       nop\n"
482                 "       cvt.d.w A1,A1\n", },
483
484 SCONV,        INCREG,
485         SOREG,  TWORD,
486         SCREG,  TDOUBLE|TLDOUBLE,
487                 NCREG,  RESC1,
488                 "       l.d A1,AL       # convert (u)int to (l)double\n"
489                 "       nop\n"
490                 "       cvt.d.w A1,A1\n", },
gmcgarry
1.4
491
492 SCONV,        INAREG,
493         SCREG,  TFLOAT,
494         SAREG,  TWORD,
gmcgarry
1.8
495                 NCREG|NAREG,    RESC1,
496                 "       cvt.w.s A2,AL   # convert float to (u)int\n"
497                 "       mfc1 A1,A2\n"
498                 "       nop\n", },
499
500 SCONV,        FOREFF,
501         SCREG,  TFLOAT,
502         SOREG,  TWORD,
503                 NCREG,  RDEST,
504                 "       cvt.w.s A1,AL   # convert float to (u)int\n"
505                 "       s.s A1,AR\n"
506                 "       nop\n", },
gmcgarry
1.4
507
508 SCONV,        INAREG,
509         SCREG,  TDOUBLE|TLDOUBLE,
510         SAREG,  TWORD,
gmcgarry
1.8
511                 NCREG|NAREG,    RESC1,
512                 "       cvt.w.d A2,AL   # convert (l)double to (u)int\n"
513                 "       mfc1 A1,A2\n"
514                 "       nop\n", },
gmcgarry
1.4
515
516 SCONV,        INCREG,
517         SCREG,  TDOUBLE|TLDOUBLE,
518         SCREG,  TDOUBLE|TLDOUBLE,
gmcgarry
1.5
519                 0,      RLEFT,
gmcgarry
1.4
520                 "       # convert between double and ldouble\n", },
521
522 SCONV,        INCREG,
gmcgarry
1.9
523         SBREG,  TLONGLONG|TULONGLONG,
gmcgarry
1.4
524         SCREG,  TFLOAT,
gmcgarry
1.7
525                 NSPECIAL|NCREGRESC1,
gmcgarry
1.4
526                 "ZF", },
527
528 SCONV,        INCREG,
gmcgarry
1.9
529         SBREG,  TLONGLONG|TULONGLONG,
gmcgarry
1.4
530         SCREG,  TDOUBLE|TLDOUBLE,
gmcgarry
1.7
531                 NSPECIAL|NCREGRESC1,
gmcgarry
1.4
532                 "ZF", },
533
534 SCONV,        INBREG,
535         SCREG,  TDOUBLE|TLDOUBLE,
gmcgarry
1.9
536         SBREG,  TLONGLONG|TULONGLONG,
gmcgarry
1.7
537                 NSPECIAL|NBREG,         RESC1,
gmcgarry
1.4
538                 "ZF", },
539
540 SCONV,        INBREG,
541         SCREG,  TFLOAT,
gmcgarry
1.9
542         SBREG,  TLONGLONG|TULONGLONG,
gmcgarry
1.7
543                 NSPECIAL|NBREG,         RESC1,
gmcgarry
1.4
544                 "ZF", },
ragge
1.1
545
546 /*
547  * Multiplication and division
548  */
549
gmcgarry
1.2
550 MUL,  INAREG,
gmcgarry
1.8
551         SAREG,  TUWORD|TUSHORT|TUCHAR,
552         SAREG,  TUWORD|TUSHORT|TUCHAR,
ragge
1.1
553                 NAREG|NASR|NASL,        RESC1,
gmcgarry
1.8
554                 "       multu AL,AR     # unsigned multiply\n"
gmcgarry
1.2
555                 "       mflo A1\n"
556                 "       nop\n"
557                 "       nop\n", },
ragge
1.1
558
gmcgarry
1.8
559 /* this previous will match on unsigned/unsigned multiplication first */
gmcgarry
1.2
560 MUL,  INAREG,
gmcgarry
1.8
561         SAREG,  TWORD|TUSHORT|TSHORT|TUCHAR|TCHAR,
562         SAREG,  TWORD|TUSHORT|TSHORT|TUCHAR|TCHAR,
ragge
1.1
563                 NAREG|NASR|NASL,        RESC1,
gmcgarry
1.8
564                 "       mult AL,AR      # signed multiply\n"
gmcgarry
1.2
565                 "       mflo A1\n"
566                 "       nop\n"
567                 "       nop\n", },
ragge
1.1
568
gmcgarry
1.5
569 MUL,  INBREG,
gmcgarry
1.9
570         SBREG,  TLONGLONG|TULONGLONG,
571         SBREG,  TLONGLONG|TULONGLONG,
gmcgarry
1.8
572                 2*NBREG,        RESC1,
gmcgarry
1.5
573                 "       multu AL,AR\n"
574                 "       mfhi U1\n"
575                 "       mflo A1\n"
gmcgarry
1.8
576                 "       mult AL,UR\n"
577                 "       mflo A2\n"
gmcgarry
1.5
578                 "       nop\n"
579                 "       nop\n"
gmcgarry
1.8
580                 "       addu A2,U1,A2\n"
gmcgarry
1.5
581                 "       mult UL,AR\n"
582                 "       mflo U2\n"
583                 "       nop\n"
584                 "       nop\n"
585                 "       addu U1,A2,U2\n", },
586
gmcgarry
1.3
587 MUL,  INCREG,
588         SCREG,  TFLOAT,
589         SCREG,  TFLOAT,
590                 NCREG,  RESC1,
gmcgarry
1.4
591                 "       mul.s A1,AL,AR          # floating-point multiply\n", },
gmcgarry
1.3
592
593 MUL,  INCREG,
gmcgarry
1.4
594         SCREG,  TDOUBLE|TLDOUBLE,
595         SCREG,  TDOUBLE|TLDOUBLE,
gmcgarry
1.3
596                 NCREG,  RESC1
597                 "       mul.d   A1,AL,AR        # double-floating-point multiply\n", },
598
gmcgarry
1.2
599 DIV,  INAREG,
gmcgarry
1.8
600         SAREG,  TUWORD|TUSHORT|TUCHAR,
601         SAREG,  TUWORD|TUSHORT|TUCHAR,
ragge
1.1
602                 NAREG|NASR|NASL,        RESC1,
gmcgarry
1.8
603                 "       divu AL,AR      # unsigned division\n"
gmcgarry
1.2
604                 "       mflo A1\n"
605                 "       nop\n"
606                 "       nop\n", },
ragge
1.1
607
gmcgarry
1.8
608 /* the previous rule will match unsigned/unsigned first */
gmcgarry
1.2
609 DIV,  INAREG,
gmcgarry
1.8
610         SAREG,  TWORD|TUSHORT|TSHORT|TUCHAR|TCHAR,
611         SAREG,  TWORD|TUSHORT|TSHORT|TUCHAR|TCHAR,
ragge
1.1
612                 NAREG|NASR|NASL,        RESC1,
gmcgarry
1.8
613                 "       div AL,AR       # signed division\n"
gmcgarry
1.2
614                 "       mflo A1\n"
615                 "       nop\n"
616                 "       nop\n", },
ragge
1.1
617
gmcgarry
1.3
618 DIVINBREG,
gmcgarry
1.9
619         SBREG,  TLONGLONG|TULONGLONG,
620         SBREG,  TLONGLONG|TULONGLONG,
gmcgarry
1.8
621                 NSPECIAL|NBREGRESC1,
gmcgarry
1.3
622                 "ZE", },
623
gmcgarry
1.4
624 DIV,  INCREG,
625         SCREG,  TFLOAT,
626         SCREG,  TFLOAT,
627                 NCREG,  RESC1,
628                 "       div.s A1,AL,AR          # floating-point division\n", },
629
630 DIV,  INCREG,
631         SCREG,  TDOUBLE|TLDOUBLE,
632         SCREG,  TDOUBLE|TLDOUBLE,
633                 NCREG,  RESC1
634                 "       div.d   A1,AL,AR        # double-floating-point division\n", },
635
gmcgarry
1.3
636 MOD,  INAREG,
gmcgarry
1.8
637         SAREG,  TUWORD|TUSHORT|TUCHAR,
638         SAREG,  TUWORD|TUSHORT|TUCHAR,
gmcgarry
1.3
639                 NAREG,  RESC1,
gmcgarry
1.8
640                 "       divu AL,AR      # signed modulo\n"
gmcgarry
1.3
641                 "       mfhi A1\n"
642                 "       nop\n"
gmcgarry
1.8
643                 "       nop\n", },
gmcgarry
1.3
644
gmcgarry
1.8
645 /* the previous rule will match unsigned%unsigned first */
gmcgarry
1.3
646 MOD,  INAREG,
gmcgarry
1.8
647         SAREG,  TWORD|TUSHORT|TSHORT|TUCHAR|TCHAR,
648         SAREG,  TWORD|TUSHORT|TSHORT|TUCHAR|TCHAR,
gmcgarry
1.3
649                 NAREG,  RESC1,
gmcgarry
1.8
650                 "       div AL,AR       # signed modulo\n"
gmcgarry
1.3
651                 "       mfhi A1\n"
652                 "       nop\n"
gmcgarry
1.8
653                 "       nop\n", },
gmcgarry
1.3
654
655 MOD,  INBREG,
gmcgarry
1.9
656         SBREG,  TLONGLONG|TULONGLONG,
657         SBREG,  TLONGLONG|TULONGLONG,
gmcgarry
1.3
658                 NSPECIAL|NBREG,  RESC1,
659                 "ZE", },
660     
ragge
1.1
661 /*
662  * Templates for unsigned values needs to come before OPSIMP 
663  */
664
gmcgarry
1.2
665 PLUSINBREG,
gmcgarry
1.8
666         SBREG,  TULONGLONG|TLONGLONG,
667         SBREG,  TULONGLONG|TLONGLONG,
668                 2*NBREG,        RESC1,
669                 "       addu A1,AL,AR   # 64-bit addition\n"
gmcgarry
1.2
670                 "       sltu A2,A1,AR\n"
gmcgarry
1.3
671                 "       addu U1,UL,UR\n"
672                 "       addu U1,U1,A2\n", },
673
674 PLUSINAREG,
675         SAREG,  TSWORD|TSHORT|TCHAR,
gmcgarry
1.12
676         SSCON,  TANY,
gmcgarry
1.9
677                 NAREG|NASL,     RESC1,
gmcgarry
1.12
678                 "       addi A1,AL,AR\n", },
gmcgarry
1.3
679
680 PLUSINAREG,
gmcgarry
1.12
681         SAREG,  TUWORD|TPOINT|TUSHORT|TUCHAR,
682         SSCON,  TANY,
gmcgarry
1.3
683                 NAREG|NASL,     RESC1,
gmcgarry
1.12
684                 "       addiu A1,AL,AR\n", },
gmcgarry
1.2
685
686 PLUSINAREG,
gmcgarry
1.12
687         SAREG,  TUWORD|TPOINT|TUSHORT|TUCHAR,
ragge
1.1
688         SAREG,  TUWORD|TUSHORT|TUCHAR,
gmcgarry
1.3
689                 NAREG|NASL,     RESC1,
gmcgarry
1.12
690                 "       addu A1,AL,AR\n", },
gmcgarry
1.4
691
gmcgarry
1.9
692 PLUSINAREG,
gmcgarry
1.12
693         SAREG,  TSWORD|TSHORT|TCHAR,
694         SAREG,  TSWORD|TSHORT|TCHAR,
gmcgarry
1.9
695                 NAREG|NASL,     RESC1,
gmcgarry
1.12
696                 "       add A1,AL,AR\n", },
gmcgarry
1.9
697
gmcgarry
1.4
698 PLUSINCREG,
699         SCREG,  TFLOAT,
700         SCREG,  TFLOAT,
701                 NCREG|NCSL,     RESC1,
702                 "       add.s A1,AL,AR\n", },
703
704 PLUSINCREG,
705         SCREG,  TDOUBLE|TLDOUBLE,
706         SCREG,  TDOUBLE|TLDOUBLE,
707                 NCREG|NCSL,     RESC1,
708                 "       add.d A1,AL,AR\n", },
gmcgarry
1.3
709
710 MINUS,        INBREG,
gmcgarry
1.8
711         SBREG,  TLONGLONG|TULONGLONG,
712         SBREG,  TLONGLONG|TULONGLONG,
713                 2*NBREG,        RESC1,
714                 "       sltu A2,AL,AR   # 64-bit subtraction\n"
gmcgarry
1.3
715                 "       subu A1,AL,AR\n"
716                 "       subu U1,UL,UR\n"
717                 "       subu U1,U1,A2\n", },
718
719 MINUS,        INAREG,
gmcgarry
1.12
720         SAREG,  TUWORD|TPOINT|TUSHORT|TUCHAR,
721         SSCON,  TANY,
gmcgarry
1.9
722                 NAREG|NASL,     RESC1,
gmcgarry
1.12
723                 "       subu A1,AL,AR\n", },
gmcgarry
1.3
724
gmcgarry
1.2
725 MINUS,        INAREG,
gmcgarry
1.12
726         SAREG,  TSWORD|TSHORT|TCHAR,
727         SSCON,  TANY,
gmcgarry
1.9
728                 NAREG|NASL,     RESC1,
gmcgarry
1.12
729                 "       sub A1,AL,AR\n", },
ragge
1.1
730
gmcgarry
1.2
731 MINUS,        INAREG,
gmcgarry
1.12
732         SAREG,  TSWORD|TSHORT|TCHAR,
733         SAREG,  TSWORD|TSHORT|TCHAR,
gmcgarry
1.3
734                 NAREG|NASL,     RESC1,
gmcgarry
1.12
735                 "       sub A1,AL,AR\n", },
gmcgarry
1.4
736
737 MINUS,        INCREG,
738         SCREG,  TFLOAT,
739         SCREG,  TFLOAT,
740                 NCREG|NCSL,     RESC1,
741                 "       sub.s A1,AL,AR\n", },
742
743 MINUS,        INCREG,
744         SCREG,  TDOUBLE|TLDOUBLE,
745         SCREG,  TDOUBLE|TLDOUBLE,
746                 NCREG|NCSL,     RESC1,
747                 "       sub.d A1,AL,AR\n", },
ragge
1.1
748
gmcgarry
1.2
749 UMINUS,       INAREG,
ragge
1.1
750         SAREG,  TWORD|TPOINT|TSHORT|TUSHORT|TCHAR|TUCHAR,
751         SANY,   TANY,
752                 NAREG|NASL,     RESC1,
gmcgarry
1.3
753                 "       neg A1,AL\n", },
754
755 UMINUS,       INBREG,
gmcgarry
1.9
756         SBREG,  TLONGLONG|TULONGLONG,
gmcgarry
1.3
757         SANY,   TANY,
gmcgarry
1.13
758                 NBREG|NAREG|NBSL,       RESC2,
gmcgarry
1.5
759                 "       subu A1,$zero,AL\n"
760                 "       subu U1,$zero,UL\n"
761                 "       sltu A2,$zero,A1\n"
gmcgarry
1.3
762                 "       subu U1,U1,A2\n", },
ragge
1.1
763
gmcgarry
1.4
764 UMINUS,       INCREG,
765         SCREG,  TFLOAT,
766         SCREG,  TFLOAT,
767                 NCREG|NCSL,     RESC1,
768                 "       neg.s A1,AL\n", },
769
770 UMINUS,       INCREG,
771         SCREG,  TDOUBLE|TLDOUBLE,
772         SCREG,  TDOUBLE|TLDOUBLE,
773                 NCREG|NCSL,     RESC1,
774                 "       neg.d A1,AL\n", },
775
ragge
1.1
776 /* Simple 'op rd, rs, rt' or 'op rt, rs, imm' operations */
777
david
1.11
778 OPSIMP,       INBREG,
779         SBREG,  TLONGLONG|TULONGLONG,
780         SBREG,  TLONGLONG|TULONGLONG,
781                 NBREG|NBSR|NBSL,        RESC1,
782                 "       O A1,AL,AR\n"
783                 "       O U1,UL,UR\n", },
784     
gmcgarry
1.2
785 OPSIMP,       INAREG,
david
1.11
786         SAREG,  TWORD|TPOINT|TSHORT|TUSHORT|TUCHAR|TCHAR,
787         SAREG,  TWORD|TPOINT|TSHORT|TUSHORT|TUCHAR|TCHAR,
ragge
1.1
788                 NAREG|NASR|NASL,        RESC1,
gmcgarry
1.2
789                 "       O A1,AL,AR\n", },
ragge
1.1
790
gmcgarry
1.2
791 OPSIMP,       INAREG,
ragge
1.1
792         SAREG,  TWORD|TPOINT|TSHORT|TUSHORT|TUCHAR|TCHAR,
gmcgarry
1.12
793         SPCON,  TANY,
gmcgarry
1.3
794                 NAREG|NASL,     RESC1,
gmcgarry
1.2
795                 "       Oi A1,AL,AR\n", },
ragge
1.1
796
797 /*
798  * Shift instructions
799  */
800
gmcgarry
1.2
801 RS,   INAREG,
gmcgarry
1.8
802         SAREG,  TSWORD|TSHORT|TCHAR,
803         SCON,   TWORD|TSHORT|TUSHORT|TCHAR|TUCHAR,
804                 NAREG|NASL,     RESC1,
805                 "       sra A1,AL,AR    # shift right by constant\n", },
806
807 RS,   INAREG,
808         SAREG,  TUWORD|TUSHORT|TUCHAR,
ragge
1.1
809         SCON,   TWORD|TSHORT|TUSHORT|TCHAR|TUCHAR,
810                 NAREG|NASL,     RESC1,
gmcgarry
1.3
811                 "       srl A1,AL,AR    # shift right by constant\n", },
ragge
1.1
812
gmcgarry
1.2
813 LS,   INAREG,
gmcgarry
1.9
814         SAREG,  TWORD|TSHORT|TUSHORT|TCHAR|TUCHAR,
ragge
1.1
815         SCON,   TWORD|TSHORT|TUSHORT|TCHAR|TUCHAR,
816                 NAREG|NASL,     RESC1,
gmcgarry
1.3
817                 "       sll A1,AL,AR    # shift left by constant\n", },
ragge
1.1
818     
gmcgarry
1.2
819 RS,   INAREG,
gmcgarry
1.9
820         SAREG,  TSWORD|TSHORT|TCHAR,
ragge
1.1
821         SAREG,  TWORD|TSHORT|TUSHORT|TCHAR|TUCHAR,
gmcgarry
1.9
822                 NAREG|NASL,     RESC1,
823                 "       srav A1,AL,AR   # shift right by register\n", },
824
825 RS,   INAREG,
826         SAREG,  TUWORD|TUSHORT|TUCHAR,
ragge
1.1
827         SAREG,  TWORD|TSHORT|TUSHORT|TCHAR|TUCHAR,
828                 NAREG|NASL,     RESC1,
gmcgarry
1.3
829                 "       srlv A1,AL,AR   # shift right by register\n", },
ragge
1.1
830
gmcgarry
1.2
831 LS,   INAREG,
ragge
1.1
832         SAREG,  TWORD|TSHORT|TUSHORT|TCHAR|TUCHAR,
833         SAREG,  TWORD|TSHORT|TUSHORT|TCHAR|TUCHAR,
834                 NAREG|NASL,     RESC1,
gmcgarry
1.3
835                 "       sllv A1,AL,AR   # shift left by register\n", }, 
836
837 RS,   INBREG,
gmcgarry
1.9
838         SBREG,  TLONGLONG|TULONGLONG,
gmcgarry
1.3
839         SCON,   TWORD|TSHORT|TUSHORT|TCHAR|TUCHAR,
gmcgarry
1.8
840                 NBREG,  RESC1,
gmcgarry
1.3
841                 "ZO", },
842
843 LS,   INBREG,
gmcgarry
1.9
844         SBREG,  TLONGLONG|TULONGLONG,
gmcgarry
1.3
845         SCON,   TWORD|TSHORT|TUSHORT|TCHAR|TUCHAR,
gmcgarry
1.8
846                 NBREG,  RESC1,
gmcgarry
1.3
847                 "ZO", },
848
849 RS,   INBREG,
gmcgarry
1.9
850         SBREG,  TLONGLONG|TULONGLONG,
gmcgarry
1.3
851         SAREG,  TWORD|TSHORT|TUSHORT|TCHAR|TUCHAR,
852                 NSPECIAL|NBREGRESC1,
853                 "ZE", },
854
855 LS,   INBREG,
gmcgarry
1.9
856         SBREG,  TLONGLONG|TULONGLONG,
gmcgarry
1.3
857         SAREG,  TWORD|TSHORT|TUSHORT|TCHAR|TUCHAR,
858                 NSPECIAL|NBREGRESC1,
859                 "ZE", },
ragge
1.1
860
861 /*
862  * Rule for unary one's complement
863  */
864
gmcgarry
1.2
865 COMPL,        INAREG,
ragge
1.1
866         SAREG,  TWORD|TSHORT|TUSHORT|TCHAR|TUCHAR,
867         SANY,   TANY,
868                 NAREG|NASL,   RESC1,
gmcgarry
1.9
869                 "       nor A1,$zero,AL # complement\n", },
gmcgarry
1.3
870     
871 COMPL,        INBREG,
gmcgarry
1.9
872         SBREG,  TLONGLONG|TULONGLONG,
gmcgarry
1.3
873         SANY,   TANY,
874                 NBREG|NBSL,   RESC1,
gmcgarry
1.9
875                 "       nor A1,$zero,AL # complement\n"
876                 "       nor U1,$zero,UL\n", },
ragge
1.1
877     
878 /*
879  * The next rules takes care of assignments. "=".
880  */
881
gmcgarry
1.2
882 ASSIGN,       FOREFF|INAREG,
gmcgarry
1.3
883         SOREG|SNAME,    TWORD|TPOINT,
884         SAREG,          TWORD|TPOINT,
gmcgarry
1.2
885                 0,      RDEST,
gmcgarry
1.8
886                 "       sw AR,AL                # store (u)int/(u)long\n"
gmcgarry
1.2
887                 "       nop\n", },
ragge
1.1
888
gmcgarry
1.2
889 ASSIGN,       FOREFF|INAREG,
gmcgarry
1.3
890         SOREG|SNAME,    TSHORT|TUSHORT,
891         SAREG,          TSHORT|TUSHORT,
gmcgarry
1.2
892                 0,      RDEST,
gmcgarry
1.3
893                 "       sh AR,AL                # store (u)short\n"
894                 "       nop\n", },      
ragge
1.1
895
gmcgarry
1.2
896 ASSIGN,       FOREFF|INAREG,
gmcgarry
1.3
897         SOREG|SNAME,    TCHAR|TUCHAR,
898         SAREG,          TCHAR|TUCHAR,
gmcgarry
1.2
899                 0,      RDEST,
gmcgarry
1.3
900                 "       sb AR,AL                # store (u)char\n"
901                 "       nop\n", },      
ragge
1.1
902
gmcgarry
1.2
903 ASSIGN,       FOREFF|INBREG,
gmcgarry
1.9
904         SOREG|SNAME,    TLONGLONG|TULONGLONG,
905         SBREG,          TLONGLONG|TULONGLONG,
gmcgarry
1.2
906                 0,      RDEST,
907                 "       sw UR,UL                # store (u)longlong\n"
gmcgarry
1.3
908                 "       nop\n"
909                 "       sw AR,AL\n"
910                 "       nop\n", },
ragge
1.1
911
gmcgarry
1.2
912 ASSIGN,       FOREFF|INBREG,
gmcgarry
1.9
913         SBREG,          TLONGLONG|TULONGLONG,
914         SBREG,          TLONGLONG|TULONGLONG,
gmcgarry
1.2
915                 0,      RDEST,
gmcgarry
1.3
916                 "       move UL,UR              # register move\n"
917                 "       move AL,AR\n", },
ragge
1.1
918     
gmcgarry
1.2
919 ASSIGN,       FOREFF|INAREG,
ragge
1.1
920         SAREG,  TANY,
921         SAREG,  TANY,
gmcgarry
1.2
922                 0,      RDEST,
923                 "       move AL,AR              # register move\n", },
ragge
1.1
924
gmcgarry
1.3
925 ASSIGN,       FOREFF|INCREG,
gmcgarry
1.8
926         SCREG,  TFLOAT,
927         SCREG,  TFLOAT,
928                 0,      RDEST,
929                 "       mov.s AL,AR             # register move\n", },
930
931 ASSIGN,       FOREFF|INCREG,
932         SCREG,  TDOUBLE|TLDOUBLE,
933         SCREG,  TDOUBLE|TLDOUBLE,
934                 0,      RDEST,
935                 "       mov.d AL,AR             # register move\n", },
936
937 ASSIGN,       FOREFF|INCREG,
gmcgarry
1.5
938         SNAME|SOREG,    TFLOAT,
gmcgarry
1.3
939         SCREG,          TFLOAT,
940                 0,      RDEST,
gmcgarry
1.9
941                 "       s.s AR,AL               # store floating-point reg to oreg/sname\n"
gmcgarry
1.8
942                 "       nop\n", },
gmcgarry
1.3
943
944 ASSIGN,       FOREFF|INCREG,
gmcgarry
1.5
945         SNAME|SOREG,    TDOUBLE|TLDOUBLE,
gmcgarry
1.4
946         SCREG,          TDOUBLE|TLDOUBLE,
gmcgarry
1.3
947                 0,      RDEST,
gmcgarry
1.9
948                 "       s.d AR,AL               # store double floating-point reg to oreg/sname\n"
gmcgarry
1.8
949