Quick Search:

View

Revision:
Expand:  
Changeset: MAIN:ragge:20050917075840

Diff

Diff from 1.49 to:

Annotations

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

Annotated File View

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