Quick Search:

View

Revision:
Expand:  
Changeset: MAIN:gmcgarry:20140604064349

Diff

Diff from 1.139 to:

Annotations

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

Annotated File View

gmcgarry
1.139
1 /*      $Id: table.c,v 1.139 2014/06/04 06:43:49 gmcgarry 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 # include "pass2.h"
31
32 # define TLL TLONGLONG|TULONGLONG
33 # define ANYSIGNED TINT|TLONG|TSHORT|TCHAR
34 # define ANYUSIGNED TUNSIGNED|TULONG|TUSHORT|TUCHAR
35 # define ANYFIXED ANYSIGNED|ANYUSIGNED
36 # define TUWORD TUNSIGNED|TULONG
37 # define TSWORD TINT|TLONG
38 # define TWORD TUWORD|TSWORD
ragge
1.50
39 #define  SHINT  SAREG   /* short and int */
40 #define  ININT  INAREG
41 #define  SHCH   SBREG   /* shape for char */
42 #define  INCH   INBREG
43 #define  SHLL   SCREG   /* shape for long long */
44 #define  INLL   INCREG
45 #define  SHFL   SDREG   /* shape for float/double */
46 #define  INFL   INDREG  /* shape for float/double */
ragge
1.1
47
48 struct optab table[] = {
ragge
1.12
49 /* First entry must be an empty entry */
50 { -1FOREFFSANYTANYSANYTANY00"", },
ragge
1.1
51
ragge
1.83
52 /* PCONVs are usually not necessary */
53 PCONV,        INAREG,
54         SAREG,  TWORD|TPOINT,
55         SAREG,  TWORD|TPOINT,
56                 0,      RLEFT,
57                 "", },
58
ragge
1.1
59 /*
60  * A bunch conversions of integral<->integral types
ragge
1.59
61  * There are lots of them, first in table conversions to itself
62  * and then conversions from each type to the others.
ragge
1.1
63  */
64
ragge
1.59
65 /* itself to itself, including pointers */
66
ragge
1.55
67 /* convert (u)char to (u)char. */
68 SCONV,        INCH,
69         SHCH,   TCHAR|TUCHAR,
70         SHCH,   TCHAR|TUCHAR,
71                 0,      RLEFT,
72                 "", },
73
ragge
1.6
74 /* convert pointers to int. */
ragge
1.50
75 SCONV,        ININT,
76         SHINT,  TPOINT|TWORD,
ragge
1.1
77         SANY,   TWORD,
78                 0,      RLEFT,
79                 "", },
80
ragge
1.29
81 /* convert (u)longlong to (u)longlong. */
ragge
1.50
82 SCONV,        INLL,
83         SHLL,   TLL,
84         SHLL,   TLL,
ragge
1.29
85                 0,      RLEFT,
86                 "", },
87
ragge
1.117
88 /* convert between float/double/long double. */
ragge
1.59
89 SCONV,        INFL,
90         SHFL,   TLDOUBLE|TDOUBLE|TFLOAT,
91         SHFL,   TLDOUBLE|TDOUBLE|TFLOAT,
ragge
1.27
92                 0,      RLEFT,
ragge
1.117
93                 "ZI", },
ragge
1.27
94
ragge
1.72
95 /* convert pointers to pointers. */
96 SCONV,        ININT,
97         SHINT,  TPOINT,
98         SANY,   TPOINT,
99                 0,      RLEFT,
100                 "", },
101
ragge
1.59
102 /* char to something */
ragge
1.15
103
ragge
1.65
104 /* convert char to (unsigned) short. */
ragge
1.50
105 SCONV,        ININT,
ragge
1.65
106         SBREG|SOREG|SNAME,      TCHAR,
107         SAREG,  TSHORT|TUSHORT,
ragge
1.29
108                 NASL|NAREG,     RESC1,
ragge
1.65
109                 "       movsbw AL,A1\n", },
ragge
1.29
110
ragge
1.59
111 /* convert unsigned char to (u)short. */
112 SCONV,        ININT,
113         SHCH|SOREG|SNAME,       TUCHAR,
114         SAREG,  TSHORT|TUSHORT,
115                 NASL|NAREG,     RESC1,
ragge
1.65
116                 "       movzbw AL,A1\n", },
ragge
1.59
117
118 /* convert signed char to int (or pointer). */
119 SCONV,        ININT,
120         SHCH|SOREG|SNAME,       TCHAR,
121         SAREG,  TWORD|TPOINT,
122                 NASL|NAREG,     RESC1,
123                 "       movsbl AL,A1\n", },
124
ragge
1.15
125 /* convert unsigned char to (u)int. */
ragge
1.50
126 SCONV,        ININT,
ragge
1.62
127         SHCH|SOREG|SNAME,       TUCHAR,
ragge
1.49
128         SAREG,  TWORD,
ragge
1.15
129                 NASL|NAREG,     RESC1,
ragge
1.62
130                 "       movzbl AL,A1\n", },
ragge
1.15
131
ragge
1.59
132 /* convert char to (u)long long */
133 SCONV,        INLL,
134         SHCH|SOREG|SNAME,       TCHAR,
135         SANY,   TLL,
ragge
1.102
136                 NSPECIAL|NCREG|NCSL,    RESC1,
ragge
1.65
137                 "       movsbl AL,%eax\n        cltd\n", },
ragge
1.59
138
139 /* convert unsigned char to (u)long long */
140 SCONV,        INLL,
141         SHCH|SOREG|SNAME,       TUCHAR,
142         SANY,                   TLL,
ragge
1.68
143                 NCREG|NCSL,     RESC1,
144                 "       movzbl AL,A1\n  xorl U1,U1\n", },
ragge
1.59
145
146 /* convert char (in register) to double XXX - use NTEMP */
ragge
1.64
147 SCONV,        INFL,
148         SHCH|SOREG|SNAME,       TCHAR,
149         SHFL,                   TLDOUBLE|TDOUBLE|TFLOAT,
ragge
1.65
150                 NAREG|NASL|NDREG,       RESC2,
151                 "       movsbl AL,A1\n  pushl A1\n"
ragge
1.59
152                 "       fildl (%esp)\n  addl $4,%esp\n", },
153
154 /* convert (u)char (in register) to double XXX - use NTEMP */
ragge
1.64
155 SCONV,        INFL,
156         SHCH|SOREG|SNAME,       TUCHAR,
157         SHFL,                   TLDOUBLE|TDOUBLE|TFLOAT,
ragge
1.65
158                 NAREG|NASL|NDREG,       RESC2,
159                 "       movzbl AL,A1\n  pushl A1\n"
ragge
1.59
160                 "       fildl (%esp)\n  addl $4,%esp\n", },
161
162 /* short to something */
163
ragge
1.132
164 /* convert (u)short to (u)short. */
165 SCONV,        INAREG,
166         SAREG,  TSHORT|TUSHORT,
167         SAREG,  TSHORT|TUSHORT,
168                 0,      RLEFT,
169                 "", },
170
ragge
1.65
171 /* convert short (in memory) to char */
172 SCONV,        INCH,
173         SNAME|SOREG,    TSHORT|TUSHORT,
174         SHCH,           TCHAR|TUCHAR,
175                 NBREG|NBSL,     RESC1,
176                 "       movb AL,A1\n", },
177
178 /* convert short (in reg) to char. */
ragge
1.59
179 SCONV,        INCH,
ragge
1.65
180         SAREG|SNAME|SOREG,      TSHORT|TUSHORT,
181         SHCH,                   TCHAR|TUCHAR,
182                 NSPECIAL|NBREG|NBSL,    RESC1,
183                 "ZM", },
ragge
1.59
184
ragge
1.16
185 /* convert short to (u)int. */
ragge
1.50
186 SCONV,        ININT,
ragge
1.49
187         SAREG|SOREG|SNAME,      TSHORT,
188         SAREG,  TWORD,
ragge
1.16
189                 NASL|NAREG,     RESC1,
ragge
1.62
190                 "       movswl AL,A1\n", },
ragge
1.16
191
ragge
1.26
192 /* convert unsigned short to (u)int. */
ragge
1.50
193 SCONV,        ININT,
ragge
1.49
194         SAREG|SOREG|SNAME,      TUSHORT,
195         SAREG,  TWORD,
ragge
1.16
196                 NASL|NAREG,     RESC1,
ragge
1.62
197                 "       movzwl AL,A1\n", },
ragge
1.16
198
ragge
1.59
199 /* convert short to (u)long long */
200 SCONV,        INLL,
201         SAREG|SOREG|SNAME,      TSHORT,
ragge
1.65
202         SHLL,                   TLL,
203                 NSPECIAL|NCREG|NCSL,    RESC1,
204                 "       movswl AL,%eax\n        cltd\n", },
ragge
1.26
205
206 /* convert unsigned short to (u)long long */
ragge
1.50
207 SCONV,        INLL,
ragge
1.49
208         SAREG|SOREG|SNAME,      TUSHORT,
ragge
1.65
209         SHLL,                   TLL,
210                 NCREG|NCSL,     RESC1,
211                 "       movzwl AL,A1\n  xorl U1,U1\n", },
ragge
1.26
212
ragge
1.59
213 /* convert short (in memory) to float/double */
ragge
1.64
214 SCONV,        INFL,
ragge
1.59
215         SOREG|SNAME,    TSHORT,
ragge
1.64
216         SDREG,  TLDOUBLE|TDOUBLE|TFLOAT,
217                 NDREG,  RESC1,
ragge
1.59
218                 "       fild AL\n", },
219
220 /* convert short (in register) to float/double */
ragge
1.64
221 SCONV,        INFL,
ragge
1.59
222         SAREG,  TSHORT,
ragge
1.64
223         SDREG,  TLDOUBLE|TDOUBLE|TFLOAT,
224                 NTEMP|NDREG,    RESC1,
ragge
1.68
225                 "       pushw AL\n      fild (%esp)\n   addl $2,%esp\n", },
ragge
1.59
226
227 /* convert unsigned short to double XXX - use NTEMP */
ragge
1.64
228 SCONV,        INFL,
ragge
1.59
229         SAREG|SOREG|SNAME,      TUSHORT,
ragge
1.64
230         SHFL,                   TLDOUBLE|TDOUBLE|TFLOAT,
ragge
1.68
231                 NAREG|NASL|NDREG|NTEMPRESC2,
232                 "       movzwl AL,A1\n  pushl A1\n"
ragge
1.59
233                 "       fildl (%esp)\n  addl $4,%esp\n", },
ragge
1.27
234
ragge
1.59
235 /* int to something */
ragge
1.27
236
ragge
1.59
237 /* convert int to char. This is done when register is loaded */
238 SCONV,        INCH,
gmcgarry
1.105
239         SAREG,  TWORD|TPOINT,
ragge
1.59
240         SANY,   TCHAR|TUCHAR,
ragge
1.61
241                 NSPECIAL|NBREG|NBSL,    RESC1,
ragge
1.59
242                 "ZM", },
ragge
1.29
243
ragge
1.61
244 /* convert int to short. Nothing to do */
245 SCONV,        INAREG,
246         SAREG,  TWORD,
247         SANY,   TSHORT|TUSHORT,
248                 0,      RLEFT,
249                 "", },
250
ragge
1.98
251 /* convert signed int to (u)long long */
ragge
1.50
252 SCONV,        INLL,
ragge
1.98
253         SHINT,  TSWORD,
254         SHLL,   TLL,
ragge
1.59
255                 NSPECIAL|NCREG|NCSL,    RESC1,
ragge
1.18
256                 "       cltd\n", },
257
ragge
1.98
258 /* convert unsigned int to (u)long long */
ragge
1.59
259 SCONV,        INLL,
ragge
1.98
260         SHINT|SOREG|SNAME,      TUWORD|TPOINT,
261         SHLL,   TLL,
ragge
1.59
262                 NCSL|NCREG,     RESC1,
263                 "       movl AL,A1\n    xorl U1,U1\n", },
264
ragge
1.129
265 /* convert signed int (in memory) to double */
ragge
1.59
266 SCONV,        INFL,
ragge
1.129
267         SOREG|SNAME,    TSWORD,
ragge
1.59
268         SHFL,   TLDOUBLE|TDOUBLE|TFLOAT,
269                 NDREG,  RESC1,
270                 "       fildl AL\n", },
271
ragge
1.129
272 /* convert signed int (in register) to double */
ragge
1.59
273 SCONV,        INFL,
ragge
1.129
274         SAREG,  TSWORD,
ragge
1.59
275         SHFL,   TLDOUBLE|TDOUBLE|TFLOAT,
ragge
1.129
276                 NDREG,  RESC1,
ragge
1.59
277                 "       pushl AL\n      fildl (%esp)\n  addl $4,%esp\n", },
278
ragge
1.129
279 /* convert unsigned int (reg&mem) to double */
280 SCONV,       INFL,
281         SOREG|SNAME|SAREG,      TUWORD,
282         SHFL,   TLDOUBLE|TDOUBLE|TFLOAT,
283                 NDREG,  RESC1,
ragge
1.130
284                 "       pushl $0\n"
ragge
1.129
285                 "       pushl AL\n"
286                 "       fildq (%esp)\n"
287                 "       addl $8,%esp\n", },
288
ragge
1.59
289 /* long long to something */
290
291 /* convert (u)long long to (u)char (mem->reg) */
292 SCONV,        INCH,
ragge
1.37
293         SOREG|SNAME,    TLL,
ragge
1.59
294         SANY,   TCHAR|TUCHAR,
ragge
1.102
295                 NBREG|NBSL,     RESC1,
ragge
1.89
296                 "       movb AL,A1\n", },
ragge
1.26
297
ragge
1.75
298 /* convert (u)long long to (u)char (reg->reg, hopefully nothing) */
ragge
1.59
299 SCONV,        INCH,
300         SHLL,   TLL,
301         SANY,   TCHAR|TUCHAR,
ragge
1.137
302                 NBREG|NBSL|NTEMP,       RESC1,
ragge
1.75
303                 "ZS", },
ragge
1.37
304
305 /* convert (u)long long to (u)short (mem->reg) */
ragge
1.50
306 SCONV,        INAREG,
ragge
1.37
307         SOREG|SNAME,    TLL,
ragge
1.49
308         SAREG,  TSHORT|TUSHORT,
ragge
1.29
309                 NAREG|NASL,     RESC1,
ragge
1.89
310                 "       movw AL,A1\n", },
ragge
1.29
311
ragge
1.75
312 /* convert (u)long long to (u)short (reg->reg, hopefully nothing) */
ragge
1.50
313 SCONV,        INAREG,
314         SHLL|SOREG|SNAME,       TLL,
ragge
1.49
315         SAREG,  TSHORT|TUSHORT,
ragge
1.137
316                 NAREG|NASL|NTEMP,       RESC1,
ragge
1.75
317                 "ZS", },
ragge
1.37
318
ragge
1.59
319 /* convert long long to int (mem->reg) */
320 SCONV,        INAREG,
ragge
1.37
321         SOREG|SNAME,    TLL,
ragge
1.59
322         SAREG,  TWORD|TPOINT,
ragge
1.29
323                 NAREG|NASL,     RESC1,
ragge
1.59
324                 "       movl AL,A1\n", },
ragge
1.29
325
ragge
1.75
326 /* convert long long to int (reg->reg, hopefully nothing) */
ragge
1.59
327 SCONV,        INAREG,
328         SHLL|SOREG|SNAME,       TLL,
329         SAREG,  TWORD|TPOINT,
ragge
1.137
330                 NAREG|NASL|NTEMP,       RESC1,
ragge
1.75
331                 "ZS", },
ragge
1.37
332
ragge
1.33
333 /* convert long long (in memory) to floating */
ragge
1.64
334 SCONV,        INFL,
ragge
1.33
335         SOREG|SNAME,    TLONGLONG,
ragge
1.64
336         SHFL,   TLDOUBLE|TDOUBLE|TFLOAT,
337                 NDREG,  RESC1,
ragge
1.26
338                 "       fildq AL\n", },
339
ragge
1.34
340 /* convert long long (in register) to floating */
ragge
1.64
341 SCONV,        INFL,
342         SHLL,   TLONGLONG,
343         SHFL,   TLDOUBLE|TDOUBLE|TFLOAT,
344                 NTEMP|NDREG,    RESC1,
ragge
1.34
345                 "       pushl UL\n      pushl AL\n"
346                 "       fildq (%esp)\n  addl $8,%esp\n", },
347
ragge
1.59
348 /* convert unsigned long long to floating */
ragge
1.64
349 SCONV,        INFL,
ragge
1.69
350         SCREG,  TULONGLONG,
351         SDREG,  TLDOUBLE|TDOUBLE|TFLOAT,
352                 NDREG,  RESC1,
353                 "ZJ", },
ragge
1.25
354
ragge
1.59
355 /* float to something */
ragge
1.27
356
ragge
1.65
357 #if 0 /* go via int by adding an extra sconv in clocal() */
358 /* convert float/double to (u) char. XXX should use NTEMP here */
359 SCONV,        INCH,
360         SHFL,   TLDOUBLE|TDOUBLE|TFLOAT,
361         SHCH,   TWORD|TSHORT|TUSHORT|TCHAR|TUCHAR,
362                 NBREG,  RESC1,
363                 "       subl $4,%esp\n  fistpl (%esp)\n popl A1\n", },
364
ragge
1.59
365 /* convert float/double to (u) int/short/char. XXX should use NTEMP here */
366 SCONV,        INCH,
367         SHFL,   TLDOUBLE|TDOUBLE|TFLOAT,
368         SHCH,   TWORD|TSHORT|TUSHORT|TCHAR|TUCHAR,
ragge
1.65
369                 NCREG,  RESC1,
370                 "       subl $4,%esp\n  fistpl (%esp)\n popl A1\n", },
371 #endif
372
ragge
1.130
373 /* convert float/double to int. XXX should use NTEMP here */
ragge
1.65
374 SCONV,        INAREG,
375         SHFL,   TLDOUBLE|TDOUBLE|TFLOAT,
ragge
1.131
376         SAREG,  TSWORD,
ragge
1.59
377                 NAREG,  RESC1,
ragge
1.100
378                 "       subl $12,%esp\n"
379                 "       fnstcw (%esp)\n"
380                 "       fnstcw 4(%esp)\n"
381                 "       movb $12,1(%esp)\n"
382                 "       fldcw (%esp)\n"
383                 "       fistpl 8(%esp)\n"
384                 "       movl 8(%esp),A1\n"
385                 "       fldcw 4(%esp)\n"
386                 "       addl $12,%esp\n", },
ragge
1.29
387
ragge
1.131
388 /* convert float/double to unsigned int. XXX should use NTEMP here */
389 SCONV,       INAREG,
390         SHFL,   TLDOUBLE|TDOUBLE|TFLOAT,
391         SAREG,  TUWORD,
392                 NAREG,  RESC1,
393                 "       subl $16,%esp\n"
394                 "       fnstcw (%esp)\n"
395                 "       fnstcw 4(%esp)\n"
396                 "       movb $12,1(%esp)\n"
397                 "       fldcw (%esp)\n"
398                 "       fistpq 8(%esp)\n"
399                 "       movl 8(%esp),A1\n"
400                 "       fldcw 4(%esp)\n"
401                 "       addl $16,%esp\n", },
402
403 /* convert float/double (in register) to long long */
404 SCONV,        INLL,
405         SHFL,   TLDOUBLE|TDOUBLE|TFLOAT,
406         SHLL,   TLONGLONG,
407                 NCREG,  RESC1,
408                 "       subl $16,%esp\n"
409                 "       fnstcw (%esp)\n"
410                 "       fnstcw 4(%esp)\n"
411                 "       movb $12,1(%esp)\n"
412                 "       fldcw (%esp)\n"
413                 "       fistpq 8(%esp)\n"
414                 "       movl 8(%esp),A1\n"
415                 "       movl 12(%esp),U1\n"
416                 "       fldcw 4(%esp)\n"
417                 "       addl $16,%esp\n", },
418
419 /* convert float/double (in register) to unsigned long long */
ragge
1.59
420 SCONV,        INLL,
421         SHFL,   TLDOUBLE|TDOUBLE|TFLOAT,
ragge
1.131
422         SHLL,   TULONGLONG,
ragge
1.65
423                 NCREG,  RESC1,
ragge
1.100
424                 "       subl $16,%esp\n"
425                 "       fnstcw (%esp)\n"
426                 "       fnstcw 4(%esp)\n"
ragge
1.134
427                 "       movb $15,1(%esp)\n"     /* 64-bit prec */
ragge
1.100
428                 "       fldcw (%esp)\n"
ragge
1.134
429                 "       movl $0x5f000000, 8(%esp)\n"    /* (float)(1<<63) */
430                 "       fsubs 8(%esp)\n"        /* keep in range of fistpq */
ragge
1.100
431                 "       fistpq 8(%esp)\n"
ragge
1.131
432                 "       xorb $0x80,15(%esp)\n"  /* addq $1>>63 to 8(%esp) */
ragge
1.100
433                 "       movl 8(%esp),A1\n"
434                 "       movl 12(%esp),U1\n"
435                 "       fldcw 4(%esp)\n"
436                 "       addl $16,%esp\n", },
ragge
1.131
437  
438
ragge
1.29
439
ragge
1.59
440 /* slut sconv */
ragge
1.29
441
ragge
1.1
442 /*
443  * Subroutine calls.
444  */
445
gmcgarry
1.113
446 UCALL,        FOREFF,
447         SCON,   TANY,
448         SANY,   TANY,
449                 0,      0,
ragge
1.119
450                 "       call CL\nZC", },
gmcgarry
1.113
451
ragge
1.67
452 CALL,         FOREFF,
453         SCON,   TANY,
454         SANY,   TANY,
455                 0,      0,
456                 "       call CL\nZC", },
457
ragge
1.64
458 UCALL,        FOREFF,
459         SCON,   TANY,
460         SAREG,  TWORD|TPOINT,
461                 0,      0,
ragge
1.119
462                 "       call CL\nZC", },
ragge
1.68
463
464 CALLINAREG,
465         SCON,   TANY,
ragge
1.99
466         SAREG,  TSHORT|TUSHORT|TWORD|TPOINT,
ragge
1.68
467                 NAREG|NASL,     RESC1,  /* should be 0 */
ragge
1.64
468                 "       call CL\nZC", },
469
470 UCALL,        INAREG,
ragge
1.1
471         SCON,   TANY,
ragge
1.99
472         SAREG,  TSHORT|TUSHORT|TWORD|TPOINT,
ragge
1.1
473                 NAREG|NASL,     RESC1,  /* should be 0 */
ragge
1.119
474                 "       call CL\nZC", },
ragge
1.68
475
476 CALLINBREG,
477         SCON,   TANY,
478         SBREG,  TCHAR|TUCHAR,
479                 NBREG,  RESC1,  /* should be 0 */
ragge
1.12
480                 "       call CL\nZC", },
ragge
1.1
481
ragge
1.64
482 UCALL,        INBREG,
ragge
1.55
483         SCON,   TANY,
ragge
1.57
484         SBREG,  TCHAR|TUCHAR,
ragge
1.68
485                 NBREG,  RESC1,  /* should be 0 */
ragge
1.119
486                 "       call CL\nZC", },
ragge
1.68
487
488 CALL,         INCREG,
489         SCON,   TANY,
490         SCREG,  TANY,
491                 NCREG|NCSL,     RESC1,  /* should be 0 */
ragge
1.55
492                 "       call CL\nZC", },
493
ragge
1.64
494 UCALL,        INCREG,
ragge
1.55
495         SCON,   TANY,
496         SCREG,  TANY,
ragge
1.58
497                 NCREG|NCSL,     RESC1,  /* should be 0 */
ragge
1.119
498                 "       call CL\nZC", },
ragge
1.68
499
500 CALLINDREG,
501         SCON,   TANY,
502         SDREG,  TANY,
503                 NDREG|NDSL,     RESC1,  /* should be 0 */
ragge
1.55
504                 "       call CL\nZC", },
505
ragge
1.64
506 UCALL,        INDREG,
ragge
1.45
507         SCON,   TANY,
ragge
1.55
508         SDREG,  TANY,
ragge
1.58
509                 NDREG|NDSL,     RESC1,  /* should be 0 */
ragge
1.45
510                 "       call CL\nZC", },
511
ragge
1.68
512 CALL,         FOREFF,
513         SAREG,  TANY,
514         SANY,   TANY,
515                 0,      0,
516                 "       call *AL\nZC", },
517
ragge
1.64
518 UCALL,        FOREFF,
519         SAREG,  TANY,
520         SANY,   TANY,
521                 0,      0,
522                 "       call *AL\nZC", },
523
ragge
1.84
524 CALL,         INAREG,
525         SAREG,  TANY,
526         SANY,   TANY,
527                 NAREG|NASL,     RESC1,  /* should be 0 */
528                 "       call *AL\nZC", },
529
530 UCALL,        INAREG,
531         SAREG,  TANY,
532         SANY,   TANY,
533                 NAREG|NASL,     RESC1,  /* should be 0 */
534                 "       call *AL\nZC", },
535
ragge
1.92
536 CALL,         INBREG,
537         SAREG,  TANY,
538         SANY,   TANY,
539                 NBREG|NBSL,     RESC1,  /* should be 0 */
540                 "       call *AL\nZC", },
541
ragge
1.84
542 UCALL,        INBREG,
ragge
1.68
543         SAREG,  TANY,
544         SANY,   TANY,
ragge
1.84
545                 NBREG|NBSL,     RESC1,  /* should be 0 */
ragge
1.68
546                 "       call *AL\nZC", },
547
ragge
1.84
548 CALL,         INCREG,
ragge
1.68
549         SAREG,  TANY,
550         SANY,   TANY,
551                 NCREG|NCSL,     RESC1,  /* should be 0 */
552                 "       call *AL\nZC", },
553
ragge
1.84
554 UCALL,        INCREG,
ragge
1.68
555         SAREG,  TANY,
556         SANY,   TANY,
ragge
1.84
557                 NCREG|NCSL,     RESC1,  /* should be 0 */
ragge
1.68
558                 "       call *AL\nZC", },
559
ragge
1.84
560 CALL,         INDREG,
ragge
1.49
561         SAREG,  TANY,
ragge
1.25
562         SANY,   TANY,
ragge
1.84
563                 NDREG|NDSL,     RESC1,  /* should be 0 */
ragge
1.12
564                 "       call *AL\nZC", },
ragge
1.9
565
ragge
1.84
566 UCALL,        INDREG,
ragge
1.49
567         SAREG,  TANY,
ragge
1.45
568         SANY,   TANY,
ragge
1.84
569                 NDREG|NDSL,     RESC1,  /* should be 0 */
ragge
1.45
570                 "       call *AL\nZC", },
571
ragge
1.69
572 STCALL,       FOREFF,
573         SCON,   TANY,
574         SANY,   TANY,
ragge
1.83
575                 NAREG|NASL,     0,
ragge
1.138
576                 "       call CL\nZC", },
ragge
1.69
577
578 STCALL,       INAREG,
579         SCON,   TANY,
580         SANY,   TANY,
581                 NAREG|NASL,     RESC1,  /* should be 0 */
ragge
1.138
582                 "       call CL\nZC", },
ragge
1.69
583
584 STCALL,       INAREG,
585         SNAME|SAREG,    TANY,
586         SANY,   TANY,
587                 NAREG|NASL,     RESC1,  /* should be 0 */
ragge
1.138
588                 "       call *AL\nZC", },
ragge
1.29
589
ragge
1.1
590 /*
ragge
1.12
591  * The next rules handle all binop-style operators.
ragge
1.1
592  */
ragge
1.17
593 /* Special treatment for long long */
ragge
1.60
594 PLUS,         INLL|FOREFF,
ragge
1.49
595         SHLL,           TLL,
596         SHLL|SNAME|SOREG,       TLL,
ragge
1.17
597                 0,      RLEFT,
598                 "       addl AR,AL\n    adcl UR,UL\n", },
599
gmcgarry
1.114
600 PLUS,         INLL|FOREFF,
601         SHLL|SNAME|SOREG,       TLL,
gmcgarry
1.115
602         SHLL|SCON,              TLL,
gmcgarry
1.114
603                 0,      RLEFT,
604                 "       addl AR,AL\n    adcl UR,UL\n", },
605
ragge
1.29
606 /* Special treatment for long long  XXX - fix commutative check */
ragge
1.60
607 PLUS,         INLL|FOREFF,
ragge
1.49
608         SHLL|SNAME|SOREG,       TLL,
609         SHLL,                   TLL,
ragge
1.29
610                 0,      RRIGHT,
611                 "       addl AL,AR\n    adcl UL,UR\n", },
612
ragge
1.60
613 PLUS,         INFL,
ragge
1.49
614         SHFL,           TDOUBLE,
ragge
1.25
615         SNAME|SOREG,    TDOUBLE,
616                 0,      RLEFT,
617                 "       faddl AR\n", },
618
ragge
1.80
619 PLUS,         INFL|FOREFF,
ragge
1.60
620         SHFL,   TLDOUBLE|TDOUBLE|TFLOAT,
ragge
1.49
621         SHFL,   TLDOUBLE|TDOUBLE|TFLOAT,
ragge
1.26
622                 0,      RLEFT,
ragge
1.88
623                 "       faddp\n", },
ragge
1.26
624
ragge
1.96
625 PLUS,         INAREG|FOREFF,
ragge
1.87
626         SAREG|SNAME|SOREG,      TWORD|TPOINT,
627         SONE,   TANY,
628                 0,      RLEFT,
629                 "       incl AL\n", },
630
mickey
1.110
631 PLUS,         INAREG|FOREFF,
632         SAREG|SNAME|SOREG,      TSHORT|TUSHORT,
633         SONE,   TANY,
634                 0,      RLEFT,
635                 "       incw AL\n", },
636
ragge
1.96
637 PLUS,         INCH|FOREFF,
ragge
1.49
638         SHCH|SNAME|SOREG,       TCHAR|TUCHAR,
ragge
1.48
639         SONE,   TANY,
ragge
1.60
640                 0,      RLEFT,
ragge
1.48
641                 "       incb AL\n", },
642
ragge
1.87
643 PLUS,         INAREG,
644         SAREG,  TWORD,
645         SAREG,  TWORD,
646                 NAREG|NASL|NASR,        RESC1,
647                 "       leal (AL,AR),A1\n", },
648
ragge
1.96
649 MINUS,        INAREG|FOREFF,
650         SAREG|SNAME|SOREG,      TWORD|TPOINT,
651         SONE,                   TANY,
652                 0,      RLEFT,
653                 "       decl AL\n", },
654
mickey
1.110
655 MINUS,        INAREG|FOREFF,
656         SAREG|SNAME|SOREG,      TSHORT|TUSHORT,
657         SONE,                   TANY,
658                 0,      RLEFT,
659                 "       decw AL\n", },
660
ragge
1.96
661 MINUS,        INCH|FOREFF,
662         SHCH|SNAME|SOREG,       TCHAR|TUCHAR,
663         SONE,   TANY,
664                 0,      RLEFT,
665                 "       decb AL\n", },
ragge
1.87
666
ragge
1.30
667 /* address as register offset, negative */
ragge
1.60
668 MINUS,        INLL|FOREFF,
669         SHLL,   TLL,
ragge
1.49
670         SHLL|SNAME|SOREG,       TLL,
ragge
1.17
671                 0,      RLEFT,
672                 "       subl AR,AL\n    sbbl UR,UL\n", },
673
gmcgarry
1.112
674 MINUS,        INLL|FOREFF,
675         SHLL|SNAME|SOREG,       TLL,
676         SHLL|SCON,      TLL,
677                 0,      RLEFT,
678                 "       subl AR,AL\n    sbbl UR,UL\n", },
679
ragge
1.60
680 MINUS,        INFL,
681         SHFL,   TDOUBLE,
ragge
1.25
682         SNAME|SOREG,    TDOUBLE,
683                 0,      RLEFT,
684                 "       fsubl AR\n", },
685
ragge
1.80
686 MINUS,        INFL|FOREFF,
ragge
1.60
687         SHFL,   TLDOUBLE|TDOUBLE|TFLOAT,
688         SHFL,   TLDOUBLE|TDOUBLE|TFLOAT,
ragge
1.25
689                 0,      RLEFT,
ragge
1.88
690                 "       fsubZAp\n", },
ragge
1.25
691
ragge
1.19
692 /* Simple r/m->reg ops */
ragge
1.107
693 /* m/r |= r */
ragge
1.109
694 OPSIMP,       INAREG|FOREFF|FORCC,
ragge
1.107
695         SAREG|SNAME|SOREG,      TWORD|TPOINT,
696         SAREG,                  TWORD|TPOINT,
ragge
1.109
697                 0,      RLEFT|RESCC,
ragge
1.107
698                 "       Ol AR,AL\n", },
699
700 /* r |= r/m */
ragge
1.109
701 OPSIMP,       INAREG|FOREFF|FORCC,
ragge
1.49
702         SAREG,                  TWORD|TPOINT,
703         SAREG|SNAME|SOREG,      TWORD|TPOINT,
ragge
1.109
704                 0,      RLEFT|RESCC,
ragge
1.10
705                 "       Ol AR,AL\n", },
706
ragge
1.107
707 /* m/r |= r */
ragge
1.109
708 OPSIMP,       INAREG|FOREFF|FORCC,
ragge
1.107
709         SHINT|SNAME|SOREG,      TSHORT|TUSHORT,
710         SHINT,          TSHORT|TUSHORT,
ragge
1.109
711                 0,      RLEFT|RESCC,
ragge
1.107
712                 "       Ow AR,AL\n", },
713
714 /* r |= r/m */
ragge
1.109
715 OPSIMP,       INAREG|FOREFF|FORCC,
ragge
1.50
716         SHINT,          TSHORT|TUSHORT,
717         SHINT|SNAME|SOREG,      TSHORT|TUSHORT,
ragge
1.109
718                 0,      RLEFT|RESCC,
ragge
1.61
719                 "       Ow AR,AL\n", },
ragge
1.19
720
ragge
1.107
721 /* m/r |= r */
ragge
1.109
722 OPSIMP,       INCH|FOREFF|FORCC,
ragge
1.49
723         SHCH,           TCHAR|TUCHAR,
724         SHCH|SNAME|SOREG,       TCHAR|TUCHAR,
ragge
1.109
725                 0,      RLEFT|RESCC,
ragge
1.65
726                 "       Ob AR,AL\n", },
ragge
1.19
727
ragge
1.107
728 /* r |= r/m */
ragge
1.109
729 OPSIMP,       INCH|FOREFF|FORCC,
ragge
1.107
730         SHCH,           TCHAR|TUCHAR,
731         SHCH|SNAME|SOREG,       TCHAR|TUCHAR,
ragge
1.109
732                 0,      RLEFT|RESCC,
ragge
1.107
733                 "       Ob AR,AL\n", },
734
735 /* m/r |= const */
ragge
1.109
736 OPSIMP,       INAREG|FOREFF|FORCC,
ragge
1.107
737         SAREG|SNAME|SOREG,      TWORD|TPOINT,
ragge
1.20
738         SCON,   TWORD|TPOINT,
ragge
1.109
739                 0,      RLEFT|RESCC,
ragge
1.5
740                 "       Ol AR,AL\n", },
ragge
1.1
741
ragge
1.109
742 OPSIMP,       INAREG|FOREFF|FORCC,
ragge
1.50
743         SHINT|SNAME|SOREG,      TSHORT|TUSHORT,
ragge
1.19
744         SCON,   TANY,
ragge
1.109
745                 0,      RLEFT|RESCC,
ragge
1.61
746                 "       Ow AR,AL\n", },
ragge
1.19
747
ragge
1.109
748 OPSIMP,       INCH|FOREFF|FORCC,
ragge
1.49
749         SHCH|SNAME|SOREG,       TCHAR|TUCHAR,
ragge
1.15
750         SCON,   TANY,
ragge
1.109
751                 0,      RLEFT|RESCC,
ragge
1.68
752                 "       Ob AR,AL\n", },
ragge
1.15
753
gmcgarry
1.112
754 /* r |= r/m */
755 OPSIMP,       INLL|FOREFF,
756         SHLL,   TLL,
757         SHLL|SNAME|SOREG,       TLL,
758                 0,      RLEFT,
759                 "       Ol AR,AL\n      Ol UR,UL\n", },
760
761 /* m/r |= r/const */
762 OPSIMP,       INLL|FOREFF,
763         SHLL|SNAME|SOREG,       TLL,
764         SHLL|SCON,      TLL,
765                 0,      RLEFT,
766                 "       Ol AR,AL\n      Ol UR,UL\n", },
767
ragge
1.120
768 /* Try use-reg instructions first */
769 PLUS,         INAREG,
770         SAREG,  TWORD|TPOINT,
771         SCON,   TANY,
772                 NAREG|NASL,     RESC1,
773                 "       leal CR(AL),A1\n", },
774
775 MINUS,        INAREG,
776         SAREG,  TWORD|TPOINT,
777         SPCON,  TANY,
778                 NAREG|NASL,     RESC1,
779                 "       leal -CR(AL),A1\n", },
780
gmcgarry
1.112
781
ragge
1.5
782 /*
783  * The next rules handle all shift operators.
784  */
ragge
1.68
785 /* (u)longlong left shift is emulated */
786 LS,   INCREG,
ragge
1.127
787         SCREG,  TLL,
788         SHCH,   TCHAR|TUCHAR,
789                 NSPECIAL,       RLEFT,
ragge
1.68
790                 "ZO", },
791
ragge
1.108
792 /* r/m <<= r */
ragge
1.56
793 LS,   INAREG|FOREFF,
ragge
1.49
794         SAREG|SNAME|SOREG,      TWORD,
ragge
1.80
795         SHCH,           TCHAR|TUCHAR,
ragge
1.56
796                 NSPECIAL,       RLEFT,
ragge
1.80
797                 "       sall AR,AL\n", },
ragge
1.1
798
ragge
1.108
799 /* r/m <<= const */
ragge
1.56
800 LS,   INAREG|FOREFF,
ragge
1.108
801         SAREG|SNAME|SOREG,      TWORD,
ragge
1.29
802         SCON,   TANY,
803                 0,      RLEFT,
ragge
1.80
804                 "       sall AR,AL\n", },
ragge
1.29
805
ragge
1.108
806 /* r/m <<= r */
ragge
1.56
807 LS,   INAREG|FOREFF,
808         SAREG|SNAME|SOREG,      TSHORT|TUSHORT,
ragge
1.80
809         SHCH,                   TCHAR|TUCHAR,
ragge
1.56
810                 NSPECIAL,       RLEFT,
ragge
1.80
811                 "       shlw AR,AL\n", },
ragge
1.56
812
ragge
1.108
813 /* r/m <<= const */
ragge
1.56
814 LS,   INAREG|FOREFF,
ragge
1.49
815         SAREG|SNAME|SOREG,      TSHORT|TUSHORT,
ragge
1.26
816         SCON,   TANY,
817                 0,      RLEFT,
ragge
1.80
818                 "       shlw AR,AL\n", },
ragge
1.26
819
ragge
1.56
820 LS,   INCH|FOREFF,
821         SHCH|SNAME|SOREG,       TCHAR|TUCHAR,
ragge
1.80
822         SHCH,                   TCHAR|TUCHAR,
ragge
1.56
823                 NSPECIAL,       RLEFT,
ragge
1.80
824                 "       salb AR,AL\n", },
ragge
1.30
825
ragge
1.56
826 LS,   INCH|FOREFF,
827         SHCH|SNAME|SOREG,       TCHAR|TUCHAR,
828         SCON,                   TANY,
ragge
1.30
829                 0,      RLEFT,
ragge
1.80
830                 "       salb AR,AL\n", },
ragge
1.68
831
832 /* (u)longlong right shift is emulated */
833 RS,   INCREG,
ragge
1.127
834         SCREG,  TLL,
835         SHCH,   TCHAR|TUCHAR,
836                 NSPECIAL,       RLEFT,
ragge
1.68
837                 "ZO", },
ragge
1.30
838
ragge
1.56
839 RS,   INAREG|FOREFF,
840         SAREG|SNAME|SOREG,      TSWORD,
ragge
1.80
841         SHCH,                   TCHAR|TUCHAR,
ragge
1.56
842                 NSPECIAL,       RLEFT,
ragge
1.80
843                 "       sarl AR,AL\n", },
ragge
1.23
844
ragge
1.56
845 RS,   INAREG|FOREFF,
ragge
1.49
846         SAREG|SNAME|SOREG,      TSWORD,
ragge
1.108
847         SCON,                   TANY,
ragge
1.56
848                 0,              RLEFT,
ragge
1.80
849                 "       sarl AR,AL\n", },
ragge
1.1
850
ragge
1.56
851 RS,   INAREG|FOREFF,
ragge
1.49
852         SAREG|SNAME|SOREG,      TUWORD,
ragge
1.80
853         SHCH,                   TCHAR|TUCHAR,
ragge
1.56
854                 NSPECIAL,       RLEFT,
ragge
1.80
855                 "       shrl AR,AL\n", },
ragge
1.1
856
ragge
1.56
857 RS,   INAREG|FOREFF,
858         SAREG|SNAME|SOREG,      TUWORD,
ragge
1.108
859         SCON,                   TANY,
ragge
1.56
860                 0,              RLEFT,
ragge
1.80
861                 "       shrl AR,AL\n", },
ragge
1.26
862
ragge
1.56
863 RS,   INAREG|FOREFF,
864         SAREG|SNAME|SOREG,      TSHORT,
ragge
1.80
865         SHCH,                   TCHAR|TUCHAR,
ragge
1.56
866                 NSPECIAL,       RLEFT,
ragge
1.80
867                 "       sarw AR,AL\n", },
ragge
1.29
868
ragge
1.56
869 RS,   INAREG|FOREFF,
ragge
1.49
870         SAREG|SNAME|SOREG,      TSHORT,
ragge
1.56
871         SCON,                   TANY,
872                 0,              RLEFT,
ragge
1.68
873                 "       sarw AR,AL\n", },
ragge
1.29
874
ragge
1.56
875 RS,   INAREG|FOREFF,
876         SAREG|SNAME|SOREG,      TUSHORT,
ragge
1.80
877         SHCH,                   TCHAR|TUCHAR,
ragge
1.56
878                 NSPECIAL,       RLEFT,
ragge
1.80
879                 "       shrw AR,AL\n", },
ragge
1.29
880
ragge
1.56
881 RS,   INAREG|FOREFF,
882         SAREG|SNAME|SOREG,      TUSHORT,
883         SCON,                   TANY,
884                 0,              RLEFT,
ragge
1.68
885                 "       shrw AR,AL\n", },