Quick Search:

View

Revision:
Expand:  
Changeset: MAIN:ragge:20130216170014

Diff

Diff from 1.51 to:

Annotations

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

Annotated File View

ragge
1.51
1 /*      $Id: table.c,v 1.51 2013/02/16 17:00:14 ragge Exp $     */
mickey
1.1
2 /*
3  * Copyright (c) 2008 Michael Shalayeff
ragge
1.12
4  * Copyright (c) 2008 Anders Magnusson (ragge@ludd.ltu.se).
mickey
1.1
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  * 3. The name of the author may not be used to endorse or promote products
16  *    derived from this software without specific prior written permission
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28  */
29
30
31 # include "pass2.h"
32
ragge
1.4
33 #define TLL TLONG|TULONG
mickey
1.1
34 # define ANYSIGNED TINT|TSHORT|TCHAR
35 # define ANYUSIGNED TUNSIGNED|TUSHORT|TUCHAR
36 # define ANYFIXED ANYSIGNED|ANYUSIGNED
37 # define TUWORD TUNSIGNED
38 # define TSWORD TINT
39 # define TWORD  TUWORD|TSWORD
ragge
1.3
40 #define TANYINT TLL|ANYFIXED
ragge
1.2
41 #define  SHINT  SAREG   /* Any integer */
mickey
1.1
42 #define  ININT  INAREG
ragge
1.18
43 #define  SHFL   SCREG   /* shape for long double */
44 #define  INFL   INCREG  /* shape for long double */
mickey
1.1
45
46 struct optab table[] = {
47 /* First entry must be an empty entry */
48 { -1FOREFFSANYTANYSANYTANY00"", },
49
50 /* PCONVs are usually not necessary */
51 PCONV,        INAREG,
ragge
1.9
52         SAREG,  TLL|TPOINT,
53         SAREG,  TLL|TPOINT,
mickey
1.1
54                 0,      RLEFT,
55                 "", },
56
ragge
1.20
57 PCONV,        INAREG,
ragge
1.50
58         SAREG|SOREG|SNAME,      TWORD,
ragge
1.20
59         SAREG,  TPOINT,
60                 NASL|NAREG,     RESC1,
61                 "       movl AL,Z1\n", },/* amd64 zero-extends 32-bit movl */
62         
63
mickey
1.1
64 /*
ragge
1.4
65  * On amd64 casts from larger to smaller integer type in register do nothing.
mickey
1.1
66  */
ragge
1.4
67 /* 64-bit to smaller */
68 SCONV,        INAREG,
69         SAREG,  TLL|TPOINT,
70         SAREG,  TANYINT,
71                 0,      RLEFT,
72                 "", },
mickey
1.1
73
ragge
1.4
74 /* 32-bit to smaller */
75 SCONV,        INAREG,
76         SAREG,  TWORD,
77         SAREG,  ANYFIXED,
mickey
1.1
78                 0,      RLEFT,
79                 "", },
80
ragge
1.4
81 /* 16-bit to smaller */
82 SCONV,        INAREG,
83         SAREG,  TSHORT|TUSHORT,
84         SAREG,  TUSHORT|TUCHAR|TSHORT|TCHAR,
mickey
1.1
85                 0,      RLEFT,
86                 "", },
87
ragge
1.4
88 /* 8-bit to 8-bit */
89 SCONV,        INAREG,
90         SAREG,  TCHAR|TUCHAR,
91         SAREG,  TUCHAR|TCHAR,
mickey
1.1
92                 0,      RLEFT,
93                 "", },
94
ragge
1.4
95 /*
96  * Casts from memory to same or smaller register is equally simple.
97  */
98 /* 64-bit to smaller */
99 SCONV,        INAREG,
100         SNAME|SOREG,    TLL|TPOINT,
101         SAREG,          TANYINT,
102                 NAREG,  RESC1,
103                 "       movZR AL,A1\n", },
104
105 /* 32-bit to smaller */
106 SCONV,        INAREG,
107         SNAME|SOREG,    TWORD,
108         SAREG,          ANYFIXED,
109                 NAREG,  RESC1,
110                 "       movZR AL,A1\n", },
111
112 /* 16-bit to smaller */
113 SCONV,        INAREG,
114         SNAME|SOREG,    TSHORT|TUSHORT,
115         SAREG,          TUSHORT|TUCHAR|TSHORT|TCHAR,
116                 NAREG,  RESC1,
117                 "       movZR AL,A1\n", },
118
119 /* 8-bit to 8-bit */
120 SCONV,        INAREG,
121         SNAME|SOREG,    TCHAR|TUCHAR,
122         SAREG,          TUCHAR|TCHAR,
123                 NAREG,  RESC1,
124                 "       movZR AL,A1\n", },
125
126
mickey
1.1
127 /* char to something */
128
129 /* convert char to (unsigned) short. */
130 SCONV,        ININT,
ragge
1.2
131         SAREG|SOREG|SNAME,      TCHAR,
mickey
1.1
132         SAREG,  TSHORT|TUSHORT,
133                 NASL|NAREG,     RESC1,
134                 "       movsbw AL,A1\n", },
135
136 /* convert unsigned char to (u)short. */
137 SCONV,        ININT,
ragge
1.2
138         SAREG|SOREG|SNAME,      TUCHAR,
mickey
1.1
139         SAREG,  TSHORT|TUSHORT,
140                 NASL|NAREG,     RESC1,
141                 "       movzbw AL,A1\n", },
142
143 /* convert signed char to int (or pointer). */
144 SCONV,        ININT,
ragge
1.2
145         SAREG|SOREG|SNAME,      TCHAR,
mickey
1.1
146         SAREG,  TWORD|TPOINT,
147                 NASL|NAREG,     RESC1,
148                 "       movsbl AL,A1\n", },
149
150 /* convert unsigned char to (u)int. */
151 SCONV,        ININT,
ragge
1.2
152         SAREG|SOREG|SNAME,      TUCHAR,
mickey
1.1
153         SAREG,  TWORD,
154                 NASL|NAREG,     RESC1,
155                 "       movzbl AL,A1\n", },
156
157 /* convert char to (u)long long */
ragge
1.2
158 SCONV,        INAREG,
159         SAREG|SOREG|SNAME,      TCHAR,
mickey
1.1
160         SANY,   TLL,
ragge
1.2
161                 NAREG|NASL,     RESC1,
mickey
1.1
162                 "       movsbq AL,A1\n", },
163
164 /* convert unsigned char to (u)long long */
ragge
1.2
165 SCONV,        INAREG,
166         SAREG|SOREG|SNAME,      TUCHAR,
mickey
1.1
167         SANY,                   TLL,
ragge
1.2
168                 NAREG|NASL,     RESC1,
mickey
1.1
169                 "       movzbq AL,A1\n", },
170
171 /* short to something */
172
173 /* convert short to (u)int. */
174 SCONV,        ININT,
175         SAREG|SOREG|SNAME,      TSHORT,
176         SAREG,  TWORD,
177                 NASL|NAREG,     RESC1,
178                 "       movswl AL,A1\n", },
179
180 /* convert unsigned short to (u)int. */
181 SCONV,        ININT,
182         SAREG|SOREG|SNAME,      TUSHORT,
183         SAREG,  TWORD,
184                 NASL|NAREG,     RESC1,
185                 "       movzwl AL,A1\n", },
186
187 /* convert short to (u)long long */
ragge
1.2
188 SCONV,        INAREG,
mickey
1.1
189         SAREG|SOREG|SNAME,      TSHORT,
ragge
1.2
190         SAREG,                  TLL,
191                 NAREG|NASL,     RESC1,
mickey
1.1
192                 "       movswq AL,A1\n", },
193
194 /* convert unsigned short to (u)long long */
ragge
1.2
195 SCONV,        INAREG,
mickey
1.1
196         SAREG|SOREG|SNAME,      TUSHORT,
ragge
1.2
197         SAREG,                  TLL,
198                 NAREG|NASL,     RESC1,
mickey
1.1
199                 "       movzwq AL,A1\n", },
200
201 /* int to something */
202
203 /* convert signed int to (u)long long */
ragge
1.2
204 SCONV,        INAREG,
ragge
1.3
205         SAREG,  TSWORD,
ragge
1.2
206         SAREG,  TLL,
ragge
1.9
207                 NASL|NAREG,     RESC1,
ragge
1.4
208                 "       movslq AL,A1\n", },
mickey
1.1
209
210 /* convert unsigned int to (u)long long */
ragge
1.2
211 SCONV,        INAREG,
ragge
1.7
212         SAREG|SOREG|SNAME,      TUWORD,
ragge
1.2
213         SAREG,  TLL,
214                 NASL|NAREG,     RESC1,
ragge
1.7
215                 "       movl AL,Z1\n", },/* amd64 zero-extends 32-bit movl */
mickey
1.1
216
ragge
1.4
217 /*
218  * Floating point casts.  amd64 uses xmm for float/double and x87
219  * for long double calculations.
220  *
221  * Types smaller than int are casted to int/(unsigned).
222  */
ragge
1.42
223 /* no casts */
224 SCONV,        INBREG,
225         SBREG,  TFLOAT,
226         SBREG,  TFLOAT,
227                 0,      RLEFT,
228                 "", },
229
230 SCONV,        INBREG,
231         SBREG,  TDOUBLE,
232         SBREG,  TDOUBLE,
233                 0,      RLEFT,
234                 "", },
235
236 SCONV,        INCREG,
237         SCREG,  TLDOUBLE,
238         SCREG,  TLDOUBLE,
239                 0,      RLEFT,
240                 "", },
241
ragge
1.4
242
243 /* convert int/long to float/double */
244 SCONV,        INBREG,
245         SAREG|SOREG|SNAME,      TINT|TLONG,
246         SBREG,                  TFLOAT|TDOUBLE,
ragge
1.2
247                 NBREG,  RESC1,
ragge
1.4
248                 "       cvtsi2sZfZq AL,A1\n", },
mickey
1.1
249
ragge
1.4
250 /* convert unsigned int to float/double */
251 SCONV,        INBREG,
252         SAREG|SOREG|SNAME,      TUNSIGNED,
253         SBREG,                  TFLOAT|TDOUBLE,
254                 NAREG|NBREG,    RESC2,
ragge
1.14
255                 "       movl AL,Z1\n    cvtsi2sZfq A1,A2\n", },
ragge
1.4
256
257 /* convert unsigned long to float/double */
258 SCONV,        INBREG,
259         SAREG|SOREG|SNAME,      TULONG,
260         SBREG,                  TFLOAT|TDOUBLE,
261                 NAREG*2|NASL|NBREG,     RESC3,
262                 "Zj", },
mickey
1.1
263
ragge
1.4
264 /* convert float/double to (u)char/(u)short/int */
ragge
1.2
265 SCONV,        INAREG,
ragge
1.4
266         SBREG|SOREG|SNAME,      TFLOAT|TDOUBLE,
267         SAREG,                  TCHAR|TUCHAR|TSHORT|TUSHORT|INT,
268                 NAREG,          RESC1,
269                 "       cvttsZg2si AL,A1\n", },
mickey
1.1
270
ragge
1.4
271 /* convert float/double to  unsigned int/long */
ragge
1.2
272 SCONV,        INAREG,
ragge
1.4
273         SBREG|SOREG|SNAME,      TFLOAT|TDOUBLE,
274         SAREG,                  TUNSIGNED|TLONG,
275                 NAREG,          RESC1,
ragge
1.12
276                 "       cvttsZg2siq AL,Z8\n", },
mickey
1.1
277
ragge
1.4
278 /* convert float to double */
279 SCONV,        INBREG,
280         SBREG|SNAME|SOREG,      TFLOAT,
281         SBREG,  TDOUBLE,
282                 NBREG|NBSL,     RESC1,
283                 "       cvtss2sd AL,A1\n", },
mickey
1.1
284
ragge
1.4
285 /* convert double to float */
286 SCONV,        INBREG,
ragge
1.5
287         SBREG|SNAME|SOREG,      TDOUBLE,
288         SBREG,  TFLOAT,
ragge
1.4
289                 NBREG|NBSL,     RESC1,
290                 "       cvtsd2ss AL,A1\n", },
mickey
1.1
291
ragge
1.18
292 /* x87 conversions */
ragge
1.19
293 /* float -> ldouble */
ragge
1.18
294 SCONV,        INCREG,
295         SBREG,  TFLOAT,
296         SCREG,  TLDOUBLE,
297                 NCREG,          RESC1,
298                 "\tsubq $4,%rsp\n\tmovss AL,(%rsp)\n"
299                 "\tflds (%rsp)\n\taddq $4,%rsp\n", },
300
ragge
1.19
301 /* double -> ldouble */
ragge
1.18
302 SCONV,        INCREG,
303         SBREG,  TDOUBLE,
304         SCREG,  TLDOUBLE,
305                 NCREG,          RESC1,
306                 "\tsubq $8,%rsp\n\tmovsd AL,(%rsp)\n"
307                 "\tfldl (%rsp)\n\taddq $8,%rsp\n", },
308
ragge
1.30
309 /* ldouble -> double */
ragge
1.19
310 SCONV,        INBREG,
311         SCREG,  TLDOUBLE,
312         SBREG,  TDOUBLE,
313                 NBREG,          RESC1,
314                 "\tsubq $8,%rsp\n\tfstpl (%rsp)\n"
315                 "\tmovsd (%rsp),A1\n\taddq $8,%rsp\n", },
316
ragge
1.30
317 /* ldouble -> float */
ragge
1.19
318 SCONV,        INBREG,
319         SCREG,  TLDOUBLE,
320         SBREG,  TFLOAT,
321                 NBREG,          RESC1,
322                 "\tsubq $4,%rsp\n\tfstps (%rsp)\n"
323                 "\tmovss (%rsp),A1\n\taddq $4,%rsp\n", },
324
ragge
1.27
325 /* convert int (in memory) to long double */
326 SCONV,        INCREG,
ragge
1.43
327         SOREG|SNAME,    TSWORD,
ragge
1.27
328         SCREG,   TLDOUBLE,
329                 NCREG,  RESC1,
330                 "       fildl AL\n", },
331
ragge
1.43
332 /* convert unsigned int to long double */
333 SCONV,        INCREG,
334         SAREG,  TUWORD,
335         SCREG,  TLDOUBLE,
336                 NAREG|NASL|NCREG,       RESC2,
337                 "       subq $16,%rsp\n"
338                 "       movl AL,Z1\n"
339                 "       movq A1,(%rsp)\n"
340                 "       fildll (%rsp)\n"
341                 "       addq $16,%rsp\n", },
342
ragge
1.28
343 /* convert int (in register) to long double */
ragge
1.27
344 SCONV,        INCREG,
ragge
1.43
345         SAREG,  TSWORD,
ragge
1.28
346         SCREG,  TLDOUBLE,
347                 NCREG,  RESC1,
ragge
1.37
348                 "       subq $4,%rsp\n"
349                 "       movl AL,(%rsp)\n"
350                 "       fildl (%rsp)\n"
351                 "       addq $4,%rsp\n", },
ragge
1.19
352
ragge
1.33
353 /* unsigned long (in reg) to long double */
ragge
1.28
354 SCONV,        INCREG,
ragge
1.33
355         SAREG,          TULONG,
356         SCREG,          TLDOUBLE,
357                 NCREG,  RESC1,
358                 "       subq $16,%rsp\n"
359                 "       movq AL,(%rsp)\n"
360                 "       fildll (%rsp)\n"
361                 "       cmpq $0,AL\n"
362                 "       jns 1f\n"
363                 "       movl $1602224128,(%rsp)\n"
364                 "       fadds (%rsp)\n"
365                 "       addq $16,%rsp\n"
366                 "1:\n", },
367
368 /* unsigned long (in mem) to long double */
369 SCONV,        INCREG,
370         SNAME|SOREG,    TULONG,
371         SCREG,          TLDOUBLE,
ragge
1.28
372                 NCREG,  RESC1,
373                 "       fildll AL\n"
374                 "       cmpq $0,AL\n"
375                 "       jns 1f\n"
376                 "       push $1602224128\n"
377                 "       fadds (%rsp)\n"
378                 "       addq $8,%rsp\n"
379                 "1:\n", },
380
ragge
1.29
381 /* convert float/double to  unsigned long */
382 SCONV,        INAREG,
383         SBREG,          TFLOAT|TDOUBLE,
384         SAREG,          TULONG,
385                 (NAREG*2)|NBREG,        RESC1,
386                 "Zb\n", },
387
ragge
1.28
388 /* long double to unsigned long */
389 SCONV,        INAREG,
390         SCREG|SNAME|SOREG,      TLDOUBLE,
391         SAREG,                  TULONG,
392                 NAREG,  RESC1,
393                 "ZB", },
394
ragge
1.31
395 /* ldouble -> long  XXX merge with int */
396 SCONV,        INAREG,
397         SCREG,  TLDOUBLE,
398         SAREG,  TLONG,
399                 NAREG,  RESC1,
ragge
1.32
400                 "       subq $16,%rsp\n"
401                 "       fnstcw (%rsp)\n"
402                 "       fnstcw 4(%rsp)\n"
403                 "       movb $12,1(%rsp)\n"
404                 "       fldcw (%rsp)\n"
405                 "       fistpll 8(%rsp)\n"
406                 "       movq 8(%rsp),A1\n"
407                 "       fldcw 4(%rsp)\n"
408                 "       addq $16,%rsp\n", },
ragge
1.31
409
ragge
1.30
410 /* ldouble -> (u)int */
411 SCONV,        INAREG,
412         SCREG,  TLDOUBLE,
413         SAREG,  TINT|TUNSIGNED,
414                 NAREG,  RESC1,
ragge
1.32
415                 "       subq $16,%rsp\n"
416                 "       fnstcw (%rsp)\n"
417                 "       fnstcw 4(%rsp)\n"
418                 "       movb $12,1(%rsp)\n"
419                 "       fldcw (%rsp)\n"
ragge
1.46
420                 "       fistpq 8(%rsp)\n"
ragge
1.32
421                 "       movl 8(%rsp),A1\n"
422                 "       fldcw 4(%rsp)\n"
423                 "       addq $16,%rsp\n", },
424
425 /* long (in mem) -> ldouble */
426 SCONV,        INCREG,
427         SNAME|SOREG,    TLONG,
428         SCREG,          TLDOUBLE,
429                 NCREG,  RESC1,
430                 "       fildll AL\n", },
431
432 /* long (in reg) -> ldouble */
433 SCONV,        INCREG,
434         SAREG,          TLONG,
435         SCREG,          TLDOUBLE,
436                 NCREG,  RESC1,
437                 "       subq $16,%rsp\n"
438                 "       movq AL,(%rsp)\n"
ragge
1.33
439                 "       fildll (%rsp)\n"
ragge
1.32
440                 "       addq $16,%rsp\n", },
441
ragge
1.30
442
443
mickey
1.1
444 /* slut sconv */
445
446 /*
447  * Subroutine calls.
448  */
449
450 CALL,         FOREFF,
451         SCON,   TANY,
452         SANY,   TANY,
453                 0,      0,
454                 "       call CL\nZC", },
455
456 UCALL,        FOREFF,
457         SCON,   TANY,
ragge
1.2
458         SANY,   TANY,
mickey
1.1
459                 0,      0,
460                 "       call CL\n", },
461
462 CALLINAREG,
463         SCON,   TANY,
ragge
1.2
464         SAREG,  TLL|ANYFIXED|TPOINT,
mickey
1.1
465                 NAREG|NASL,     RESC1,  /* should be 0 */
466                 "       call CL\nZC", },
467
468 UCALL,        INAREG,
469         SCON,   TANY,
ragge
1.2
470         SAREG,  TLL|ANYFIXED|TPOINT,
mickey
1.1
471                 NAREG|NASL,     RESC1,  /* should be 0 */
472                 "       call CL\n", },
473
474 CALLINBREG,
475         SCON,   TANY,
ragge
1.2
476         SBREG,  TANY,
477                 NBREG|NBSL,     RESC1,  /* should be 0 */
mickey
1.1
478                 "       call CL\nZC", },
479
480 UCALL,        INBREG,
481         SCON,   TANY,
ragge
1.2
482         SBREG,  TANY,
483                 NBREG|NBSL,     RESC1,  /* should be 0 */
mickey
1.1
484                 "       call CL\nZC", },
485
ragge
1.25
486 CALLINCREG,
487         SCON,   TANY,
488         SCREG,  TANY,
489                 NCREG|NCSL,     RESC1,  /* should be 0 */
490                 "       call CL\nZC", },
491
492 UCALL,        INCREG,
493         SCON,   TANY,
494         SCREG,  TANY,
495                 NCREG|NCSL,     RESC1,  /* should be 0 */
496                 "       call CL\nZC", },
mickey
1.1
497
498
499 CALL,         FOREFF,
500         SAREG,  TANY,
501         SANY,   TANY,
502                 0,      0,
503                 "       call *AL\nZC", },
504
505 UCALL,        FOREFF,
506         SAREG,  TANY,
507         SANY,   TANY,
508                 0,      0,
509                 "       call *AL\nZC", },
510
511 CALL,         INAREG,
512         SAREG,  TANY,
513         SANY,   TANY,
514                 NAREG|NASL,     RESC1,  /* should be 0 */
515                 "       call *AL\nZC", },
516
517 UCALL,        INAREG,
518         SAREG,  TANY,
519         SANY,   TANY,
520                 NAREG|NASL,     RESC1,  /* should be 0 */
521                 "       call *AL\nZC", },
522
523 CALL,         INBREG,
524         SAREG,  TANY,
525         SANY,   TANY,
526                 NBREG|NBSL,     RESC1,  /* should be 0 */
527                 "       call *AL\nZC", },
528
529 UCALL,        INBREG,
530         SAREG,  TANY,
531         SANY,   TANY,
532                 NBREG|NBSL,     RESC1,  /* should be 0 */
533                 "       call *AL\nZC", },
534
ragge
1.25
535 CALL,         INCREG,
536         SAREG,  TANY,
537         SANY,   TANY,
538                 NCREG|NCSL,     RESC1,  /* should be 0 */
539                 "       call *AL\nZC", },
540
541 UCALL,        INCREG,
542         SAREG,  TANY,
543         SANY,   TANY,
544                 NCREG|NCSL,     RESC1,  /* should be 0 */
545                 "       call *AL\nZC", },
546
mickey
1.1
547 /* struct return */
548 USTCALL,      FOREFF,
549         SCON,   TANY,
550         SANY,   TANY,
551                 NAREG|NASL,     0,
ragge
1.15
552                 "ZP     call CL\nZC", },
mickey
1.1
553
554 USTCALL,      INAREG,
555         SCON,   TANY,
556         SANY,   TANY,
557                 NAREG|NASL,     RESC1,  /* should be 0 */
ragge
1.15
558                 "ZP     call CL\nZC", },
mickey
1.1
559
560 USTCALL,      INAREG,
561         SNAME|SAREG,    TANY,
562         SANY,   TANY,
563                 NAREG|NASL,     RESC1,  /* should be 0 */
ragge
1.15
564                 "ZP     call *AL\nZC", },
mickey
1.1
565
566 STCALL,       FOREFF,
567         SCON,   TANY,
568         SANY,   TANY,
569                 NAREG|NASL,     0,
ragge
1.15
570                 "ZP     call CL\nZC", },
mickey
1.1
571
572 STCALL,       INAREG,
573         SCON,   TANY,
574         SANY,   TANY,
575                 NAREG|NASL,     RESC1,  /* should be 0 */
ragge
1.15
576                 "ZP     call CL\nZC", },
mickey
1.1
577
ragge
1.48
578 STCALL,       FOREFF,
579         SNAME|SAREG,    TANY,
580         SANY,   TANY,
581                 NAREG|NASL,     0,      /* should be 0 */
582                 "ZP     call *AL\nZC", },
583
mickey
1.1
584 STCALL,       INAREG,
585         SNAME|SAREG,    TANY,
586         SANY,   TANY,
587                 NAREG|NASL,     RESC1,  /* should be 0 */
ragge
1.15
588                 "ZP     call *AL\nZC", },
mickey
1.1
589
590 /*
591  * The next rules handle all binop-style operators.
592  */
ragge
1.5
593 /* floating point add */
594 PLUS,         INBREG,
595         SBREG,                  TFLOAT|TDOUBLE,
596         SBREG|SNAME|SOREG,      TFLOAT|TDOUBLE,
mickey
1.1
597                 0,      RLEFT,
ragge
1.5
598                 "       addsZf AR,AL\n", },
mickey
1.1
599
ragge
1.19
600 PLUS,         INCREG|FOREFF,
601         SHFL,   TLDOUBLE,
602         SHFL,   TLDOUBLE,
603                 0,      RLEFT,
604                 "       faddp\n", },
605
606
ragge
1.2
607 PLUS,         INAREG|FOREFF,
608         SAREG|SNAME|SOREG,      TLL|TPOINT,
mickey
1.1
609         SONE,   TANY,
610                 0,      RLEFT,
611                 "       incq AL\n", },
612
613 PLUS,         INAREG|FOREFF,
614         SAREG|SNAME|SOREG,      TWORD,
615         SONE,   TANY,
616                 0,      RLEFT,
617                 "       incl AL\n", },
618
ragge
1.2
619 PLUS,         INAREG,
620         SAREG,  TLL|TPOINT,
mickey
1.1
621         SCON,   TWORD,
ragge
1.2
622                 NAREG|NASL,     RESC1,
mickey
1.1
623                 "       leaq CR(AL),A1\n", },
624
ragge
1.34
625 #ifdef notdef
626 /* older binutils are missing leal */
mickey
1.1
627 PLUS,         INAREG,
628         SAREG,  TWORD,
629         SCON,   TANY,
630                 NAREG|NASL,     RESC1,
631                 "       leal CR(AL),A1\n", },
ragge
1.34
632 #endif
mickey
1.1
633
634 PLUS,         INAREG|FOREFF,
635         SAREG|SNAME|SOREG,      TSHORT|TUSHORT,
636         SONE,   TANY,
637                 0,      RLEFT,
638                 "       incw AL\n", },
639
ragge
1.2
640 PLUS,         INAREG|FOREFF,
641         SAREG|SNAME|SOREG,      TCHAR|TUCHAR,
mickey
1.1
642         SONE,   TANY,
643                 0,      RLEFT,
644                 "       incb AL\n", },
645
ragge
1.34
646 #ifdef notdef
647 /* older binutils are missing leal */
mickey
1.1
648 PLUS,         INAREG,
649         SAREG,  TWORD,
650         SAREG,  TWORD,
651                 NAREG|NASL|NASR,        RESC1,
652                 "       leal (AL,AR),A1\n", },
ragge
1.34
653 #endif
mickey
1.1
654
ragge
1.2
655 MINUS,        INAREG|FOREFF,
656         SAREG|SNAME|SOREG,      TLL|TPOINT,
mickey
1.1
657         SONE,                   TANY,
658                 0,      RLEFT,
659                 "       decq AL\n", },
660
661 MINUS,        INAREG|FOREFF,
662         SAREG|SNAME|SOREG,      TWORD,
663         SONE,                   TANY,
664                 0,      RLEFT,
665                 "       decl AL\n", },
666
667 MINUS,        INAREG|FOREFF,
668         SAREG|SNAME|SOREG,      TSHORT|TUSHORT,
669         SONE,                   TANY,
670                 0,      RLEFT,
671                 "       decw AL\n", },
672
ragge
1.2
673 MINUS,        INAREG|FOREFF,
674         SAREG|SNAME|SOREG,      TCHAR|TUCHAR,
mickey
1.1
675         SONE,   TANY,
676                 0,      RLEFT,
677                 "       decb AL\n", },
678
679 /* address as register offset, negative */
680 MINUS,        INAREG,
ragge
1.3
681         SAREG,  TLL|TPOINT,
mickey
1.1
682         SPCON,  TANY,
683                 NAREG|NASL,     RESC1,
ragge
1.3
684                 "       leaq -CR(AL),A1\n", },
mickey
1.1
685
ragge
1.5
686 MINUS,        INBREG|FOREFF,
687         SBREG,                  TDOUBLE|TFLOAT,
688         SBREG|SNAME|SOREG,      TDOUBLE|TFLOAT,
mickey
1.1
689                 0,      RLEFT,
ragge
1.11
690                 "       subsZf AR,AL\n", },
mickey
1.1
691
ragge
1.19
692 MINUS,        INCREG|FOREFF,
693         SHFL,   TLDOUBLE,
694         SHFL,   TLDOUBLE,
695                 0,      RLEFT,
696                 "       fsubZAp\n", },
697
mickey
1.1
698 /* Simple r/m->reg ops */
699 /* m/r |= r */
ragge
1.2
700 OPSIMP,       INAREG|FOREFF|FORCC,
701         SAREG|SNAME|SOREG,      TLL|TPOINT,
702         SAREG,                  TLL|TPOINT,
mickey
1.1
703                 0,      RLEFT|RESCC,
704                 "       Oq AR,AL\n", },
705
706 /* r |= r/m */
ragge
1.2
707 OPSIMP,       INAREG|FOREFF|FORCC,
708         SAREG,                  TLL|TPOINT,
709         SAREG|SNAME|SOREG,      TLL|TPOINT,
mickey
1.1
710                 0,      RLEFT|RESCC,
711                 "       Oq AR,AL\n", },
712
713 /* m/r |= r */
714 OPSIMP,       INAREG|FOREFF|FORCC,
715         SAREG|SNAME|SOREG,      TWORD,
716         SAREG,                  TWORD,
717                 0,      RLEFT|RESCC,
718                 "       Ol AR,AL\n", },
719
720 /* r |= r/m */
721 OPSIMP,       INAREG|FOREFF|FORCC,
ragge
1.3
722         SAREG,                  TWORD,
723         SAREG|SNAME|SOREG,      TWORD,
mickey
1.1
724                 0,      RLEFT|RESCC,
725                 "       Ol AR,AL\n", },
726
727 /* m/r |= r */
728 OPSIMP,       INAREG|FOREFF|FORCC,
729         SHINT|SNAME|SOREG,      TSHORT|TUSHORT,
730         SHINT,          TSHORT|TUSHORT,
731                 0,      RLEFT|RESCC,
732                 "       Ow AR,AL\n", },
733
734 /* r |= r/m */
735 OPSIMP,       INAREG|FOREFF|FORCC,
736         SHINT,          TSHORT|TUSHORT,
737         SHINT|SNAME|SOREG,      TSHORT|TUSHORT,
738                 0,      RLEFT|RESCC,
739                 "       Ow AR,AL\n", },
740
741 /* m/r |= r */
ragge
1.2
742 OPSIMP,       INAREG|FOREFF|FORCC,
743         SAREG,          TCHAR|TUCHAR,
744         SAREG|SNAME|SOREG,      TCHAR|TUCHAR,
mickey
1.1
745                 0,      RLEFT|RESCC,
746                 "       Ob AR,AL\n", },
747
748 /* r |= r/m */
ragge
1.2
749 OPSIMP,       INAREG|FOREFF|FORCC,
750         SAREG,          TCHAR|TUCHAR,
751         SAREG|SNAME|SOREG,      TCHAR|TUCHAR,
mickey
1.1
752                 0,      RLEFT|RESCC,
753                 "       Ob AR,AL\n", },
754
755 /* m/r |= const */
ragge
1.16
756 #ifdef notdef   /* amd64 lacks immediate 64-bit simple ops */
ragge
1.2
757 OPSIMP,       INAREG|FOREFF|FORCC,
ragge
1.4
758         SAREG|SNAME|SOREG,      TLL|TPOINT,
759         SCON,   TANY,
mickey
1.1
760                 0,      RLEFT|RESCC,
761                 "       Oq AR,AL\n", },
ragge
1.16
762 #endif
mickey
1.1
763
764 OPSIMP,       INAREG|FOREFF|FORCC,
765         SAREG|SNAME|SOREG,      TWORD,
ragge
1.4
766         SCON,   TANY,
mickey
1.1
767                 0,      RLEFT|RESCC,
768                 "       Ol AR,AL\n", },
769
770 OPSIMP,       INAREG|FOREFF|FORCC,
771         SHINT|SNAME|SOREG,      TSHORT|TUSHORT,
772         SCON,   TANY,
773                 0,      RLEFT|RESCC,
774                 "       Ow AR,AL\n", },
775
ragge
1.2
776 OPSIMP,       INAREG|FOREFF|FORCC,
777         SAREG|SNAME|SOREG,      TCHAR|TUCHAR,
mickey
1.1
778         SCON,   TANY,
779                 0,      RLEFT|RESCC,
780                 "       Ob AR,AL\n", },
781
782 /*
783  * The next rules handle all shift operators.
784  */
785 /* r/m <<= r */
ragge
1.2
786 LS,   INAREG|FOREFF,
787         SAREG|SNAME|SOREG,      TLL,
788         SAREG,          TCHAR|TUCHAR,
mickey
1.1
789                 NSPECIAL,       RLEFT,
790                 "       salq AR,AL\n", },
791
792 /* r/m <<= const */
ragge
1.2
793 LS,   INAREG|FOREFF,
794         SAREG|SNAME|SOREG,      TLL,
mickey
1.1
795         SCON,   TANY,
796                 0,      RLEFT,
797                 "       salq AR,AL\n", },
798
799 /* r/m <<= r */
800 LS,   INAREG|FOREFF,
801         SAREG|SNAME|SOREG,      TWORD,
ragge
1.2
802         SAREG,          TCHAR|TUCHAR,
mickey
1.1
803                 NSPECIAL,       RLEFT,
804                 "       sall AR,AL\n", },
805
806 /* r/m <<= const */
807 LS,   INAREG|FOREFF,
808         SAREG|SNAME|SOREG,      TWORD,
809         SCON,   TANY,
810                 0,      RLEFT,
811                 "       sall AR,AL\n", },
812
813 /* r/m <<= r */
814 LS,   INAREG|FOREFF,
815         SAREG|SNAME|SOREG,      TSHORT|TUSHORT,
ragge
1.2
816         SAREG,                  TCHAR|TUCHAR,
mickey
1.1
817                 NSPECIAL,       RLEFT,
818                 "       shlw AR,AL\n", },
819
820 /* r/m <<= const */
821 LS,   INAREG|FOREFF,
822         SAREG|SNAME|SOREG,      TSHORT|TUSHORT,
823         SCON,   TANY,
824                 0,      RLEFT,
825                 "       shlw AR,AL\n", },
826
ragge
1.2
827 LS,   INAREG|FOREFF,
828         SAREG|SNAME|SOREG,      TCHAR|TUCHAR,
829         SAREG,                  TCHAR|TUCHAR,
mickey
1.1
830                 NSPECIAL,       RLEFT,
831                 "       salb AR,AL\n", },
832
ragge
1.2
833 LS,   INAREG|FOREFF,
834         SAREG|SNAME|SOREG,      TCHAR|TUCHAR,
mickey
1.1
835         SCON,                   TANY,
836                 0,      RLEFT,
837                 "       salb AR,AL\n", },
838
ragge
1.2
839 RS,   INAREG|FOREFF,
840         SAREG|SNAME|SOREG,      TLONG|TLONGLONG,
841         SAREG,                  TCHAR|TUCHAR,
mickey
1.1
842                 NSPECIAL,       RLEFT,
843                 "       sarq AR,AL\n", },
844
ragge
1.2
845 RS,   INAREG|FOREFF,
846         SAREG|SNAME|SOREG,      TLONG|TLONGLONG,
mickey
1.1
847         SCON,                   TANY,
848                 0,              RLEFT,
849                 "       sarq AR,AL\n", },
850
ragge
1.2
851 RS,   INAREG|FOREFF,
852         SAREG|SNAME|SOREG,      TULONG|TULONGLONG,
853         SAREG,                  TCHAR|TUCHAR,
mickey
1.1
854                 NSPECIAL,       RLEFT,
855                 "       shrq AR,AL\n", },
856
ragge
1.2
857 RS,   INAREG|FOREFF,
858         SAREG|SNAME|SOREG,      TULONG|TULONGLONG,
mickey
1.1
859         SCON,                   TANY,
860                 0,              RLEFT,
861                 "       shrq AR,AL\n", },
862
863 RS,   INAREG|FOREFF,
864         SAREG|SNAME|SOREG,      TSWORD,
ragge
1.2
865         SAREG,                  TCHAR|TUCHAR,
mickey
1.1
866                 NSPECIAL,       RLEFT,
867                 "       sarl AR,AL\n", },
868
869 RS,   INAREG|FOREFF,
870         SAREG|SNAME|SOREG,      TSWORD,
871         SCON,                   TANY,
872                 0,              RLEFT,
873                 "       sarl AR,AL\n", },
874
875 RS,   INAREG|FOREFF,
876         SAREG|SNAME|SOREG,      TUWORD,
ragge
1.2
877         SAREG,                  TCHAR|TUCHAR,
mickey
1.1
878                 NSPECIAL,       RLEFT,
879                 "       shrl AR,AL\n", },
880
881 RS,   INAREG|FOREFF,
882         SAREG|SNAME|SOREG,      TUWORD,
883         SCON,                   TANY,
884                 0,              RLEFT,
885                 "       shrl AR,AL\n", },
886
887 RS,   INAREG|FOREFF,
888         SAREG|SNAME|SOREG,      TSHORT,
ragge
1.2
889         SAREG,                  TCHAR|TUCHAR,
mickey
1.1
890                 NSPECIAL,       RLEFT,
891                 "       sarw AR,AL\n", },
892
893 RS,   INAREG|FOREFF,
894         SAREG|SNAME|SOREG,      TSHORT,
895         SCON,                   TANY,
896                 0,              RLEFT,
897                 "       sarw AR,AL\n", },
898
899 RS,   INAREG|FOREFF,
900         SAREG|SNAME|SOREG,      TUSHORT,
ragge
1.2
901         SAREG,                  TCHAR|TUCHAR,
mickey
1.1
902                 NSPECIAL,       RLEFT,
903                 "       shrw AR,AL\n", },
904
905 RS,   INAREG|FOREFF,
906         SAREG|SNAME|SOREG,      TUSHORT,
907         SCON,                   TANY,
908                 0,              RLEFT,
909                 "       shrw AR,AL\n", },
910
ragge
1.2
911 RS,   INAREG|FOREFF,
912         SAREG|SNAME|SOREG,      TCHAR,
913         SAREG,                  TCHAR|TUCHAR,
mickey
1.1
914                 NSPECIAL,       RLEFT,
915                 "       sarb AR,AL\n", },
916
ragge
1.2
917 RS,   INAREG|FOREFF,
918         SAREG|SNAME|SOREG,      TCHAR,
mickey
1.1
919         SCON,                   TANY,
920                 0,              RLEFT,
921                 "       sarb AR,AL\n", },
922
ragge
1.2
923 RS,   INAREG|FOREFF,
924         SAREG|SNAME|SOREG,      TUCHAR,
925         SAREG,                  TCHAR|TUCHAR,
mickey
1.1
926                 NSPECIAL,       RLEFT,
927                 "       shrb AR,AL\n", },
928
ragge
1.2
929 RS,   INAREG|FOREFF,
930         SAREG|SNAME|SOREG,      TUCHAR,
mickey
1.1
931         SCON,                   TANY,
932                 0,              RLEFT,
933                 "       shrb AR,AL\n", },
934
935 /*
936  * The next rules takes care of assignments. "=".
937  */
ragge
1.2
938 ASSIGN,       FORCC|FOREFF|INAREG,
939         SAREG,          TLL|TPOINT,
mickey
1.1
940         SMIXOR,         TANY,
941                 0,      RDEST,
ragge
1.9
942                 "       xorq AL,AL\n", },
mickey
1.1
943
ragge
1.2
944 ASSIGN,       FOREFF|INAREG,
945         SAREG,          TLL|TPOINT,
mickey
1.1
946         SCON,           TANY,
947                 0,      RDEST,
948                 "       movabs AR,AL\n", },
949
950 ASSIGN,       FORCC|FOREFF|INAREG,
951         SAREG,          TWORD,
952         SMIXOR,         TANY,
953                 0,      RDEST,
954                 "       xorl AL,AL\n", },
955
956 ASSIGN,       FOREFF,
957         SAREG|SNAME|SOREG,      TWORD,
958         SCON,           TANY,
959                 0,      0,
960                 "       movl AR,AL\n", },
961
962 ASSIGN,       FOREFF|INAREG,
963         SAREG,  TWORD,
964         SCON,           TANY,
965                 0,      RDEST,
966                 "       movl AR,AL\n", },
967
968 ASSIGN,       FORCC|FOREFF|INAREG,
969         SAREG,  TSHORT|TUSHORT,
970         SMIXOR,         TANY,
971                 0,      RDEST,
972                 "       xorw AL,AL\n", },
973
974 ASSIGN,       FOREFF,
975         SAREG|SNAME|SOREG,      TSHORT|TUSHORT,
976         SCON,           TANY,
977                 0,      0,
978                 "       movw AR,AL\n", },
979
980 ASSIGN,       FOREFF|INAREG,
981         SAREG,  TSHORT|TUSHORT,
982         SCON,           TANY,
983                 0,      RDEST,
984                 "       movw AR,AL\n", },
985
986 ASSIGN,       FOREFF,
ragge
1.2
987         SAREG|SNAME|SOREG,      TCHAR|TUCHAR,
mickey
1.1
988         SCON,           TANY,
989                 0,      0,
990                 "       movb AR,AL\n", },
991
ragge
1.2
992 ASSIGN,       FOREFF|INAREG,
993         SAREG,          TCHAR|TUCHAR,
mickey
1.1
994         SCON,           TANY,
995                 0,      RDEST,
996                 "       movb AR,AL\n", },
997
ragge
1.2
998 ASSIGN,       FOREFF|INAREG,
ragge
1.3
999         SAREG|SNAME|SOREG,      TLL|TPOINT,
1000         SAREG,                  TLL|TPOINT,
mickey
1.1
1001                 0,      RDEST,
1002                 "       movq AR,AL\n", },
1003
1004 ASSIGN,       FOREFF|INAREG,
ragge
1.3
1005         SAREG|SNAME|SOREG,      TWORD,
1006         SAREG,          TWORD,
mickey
1.1
1007                 0,      RDEST,
1008                 "       movl AR,AL\n", },
1009
1010 ASSIGN,       FOREFF|INAREG,
ragge
1.3
1011         SAREG,                  TWORD,
1012         SAREG|SNAME|SOREG,      TWORD,
mickey
1.1
1013                 0,      RDEST,
1014                 "       movl AR,AL\n", },
1015
1016 ASSIGN,       FOREFF|INAREG,
ragge
1.3
1017         SAREG,                  TPOINT,
1018         SAREG|SNAME|SOREG,      TPOINT,
1019                 0,      RDEST,
1020                 "       movq AR,AL\n", },
1021
1022 ASSIGN,       FOREFF|INAREG,
mickey
1.1
1023         SAREG|SNAME|SOREG,      TSHORT|TUSHORT,
1024         SAREG,          TSHORT|TUSHORT,
1025                 0,      RDEST,
1026                 "       movw AR,AL\n", },
1027
ragge
1.2
1028 ASSIGN,       FOREFF|INAREG,
1029         SAREG|SNAME|SOREG,      TCHAR|TUCHAR,
1030         SAREG,          TCHAR|TUCHAR|TWORD,
mickey
1.1
1031                 0,      RDEST,
1032                 "       movb AR,AL\n", },
1033
ragge
1.2
1034 ASSIGN,       INBREG|FOREFF,
ragge
1.5
1035         SBREG,                  TFLOAT|TDOUBLE,
1036         SBREG|SOREG|SNAME,      TFLOAT|TDOUBLE,
mickey
1.1
1037                 0,      RDEST,
ragge
1.5
1038                 "       movsZf AR,AL\n", },
mickey
1.1
1039
ragge
1.5
1040 ASSIGN,       INBREG|FOREFF,
1041         SBREG|SOREG|SNAME,      TFLOAT|TDOUBLE,
1042         SBREG,                  TFLOAT|TDOUBLE,
mickey
1.1
1043                 0,      RDEST,
ragge
1.5
1044                 "       movsZf AR,AL\n", },
mickey
1.1
1045
ragge
1.18
1046 /* x87 entries */
1047