18 %token <lval> LMOVW LMOVD LMOVB LSWAP LADDW LCMP
19 %token <lval> LBRA LFMOV LFCONV LFADD LCPOP LTRAP LJMPL LXORW
20 %token <lval> LNOP LEND LRETT LUNIMP LTEXT LDATA LRETRN
21 %token <lval> LCONST LSP LSB LFP LPC LCREG LFLUSH
22 %token <lval> LREG LFREG LR LC LF
23 %token <lval> LFSR LFPQ LPSR LSCHED
26 %token <sym> LNAME LLAB LVAR
27 %type <lval> con expr pointer offset sreg
28 %type <gen> addr rreg name psr creg freg
29 %type <gen> imm ximm fimm rel fsr fpq
38 yyerror("redeclaration of %s", $1->name);
56 yyerror("redeclaration of %s", $1->name);
69 * B.1 load integer instructions
73 outcode($1, &$2, NREG, &$4);
77 outcode($1, &$2, NREG, &$4);
81 outcode($1, &$2, NREG, &$4);
85 outcode($1, &$2, NREG, &$4);
89 outcode($1, &$2, NREG, &$4);
92 * B.2 load floating instructions
97 outcode($1, &$2, NREG, &$4);
101 outcode($1, &$2, NREG, &$4);
103 | LFMOV fimm ',' freg
105 outcode($1, &$2, NREG, &$4);
107 | LFMOV freg ',' freg
109 outcode($1, &$2, NREG, &$4);
111 | LFMOV freg ',' addr
113 outcode($1, &$2, NREG, &$4);
117 outcode($1, &$2, NREG, &$4);
120 * B.3 load coprocessor instructions
123 | LMOVW addr ',' creg
125 outcode($1, &$2, NREG, &$4);
127 | LMOVD addr ',' creg
129 outcode($1, &$2, NREG, &$4);
132 * B.4 store integer instructions
134 | LMOVW rreg ',' addr
136 outcode($1, &$2, NREG, &$4);
141 yyerror("constant must be zero");
142 outcode($1, &$2, NREG, &$4);
144 | LMOVD rreg ',' addr
146 outcode($1, &$2, NREG, &$4);
148 | LMOVB rreg ',' addr
150 outcode($1, &$2, NREG, &$4);
155 yyerror("constant must be zero");
156 outcode($1, &$2, NREG, &$4);
159 * B.5 store floating instructions
160 * includes CSR and CQ
162 | LMOVW freg ',' addr
164 outcode($1, &$2, NREG, &$4);
166 | LMOVD freg ',' addr
168 outcode($1, &$2, NREG, &$4);
172 outcode($1, &$2, NREG, &$4);
176 outcode($1, &$2, NREG, &$4);
179 * B.6 store coprocessor instructions
180 * excludes CSR and CQ
182 | LMOVW creg ',' addr
184 outcode($1, &$2, NREG, &$4);
186 | LMOVD creg ',' addr
188 outcode($1, &$2, NREG, &$4);
191 * B.7 atomic load unsigned byte (TAS)
194 | LSWAP addr ',' rreg
196 outcode($1, &$2, NREG, &$4);
199 * B.9 add instructions
200 * B.10 tagged add instructions
201 * B.11 subtract instructions
202 * B.12 tagged subtract instructions
203 * B.13 multiply step instruction
204 * B.14 logical instructions
205 * B.15 shift instructions
208 | LADDW rreg ',' sreg ',' rreg
210 outcode($1, &$2, $4, &$6);
212 | LADDW imm ',' sreg ',' rreg
214 outcode($1, &$2, $4, &$6);
216 | LADDW rreg ',' rreg
218 outcode($1, &$2, NREG, &$4);
222 outcode($1, &$2, NREG, &$4);
224 | LXORW rreg ',' sreg ',' rreg
226 outcode($1, &$2, $4, &$6);
228 | LXORW imm ',' sreg ',' rreg
230 outcode($1, &$2, $4, &$6);
232 | LXORW rreg ',' rreg
234 outcode($1, &$2, NREG, &$4);
238 outcode($1, &$2, NREG, &$4);
246 outcode($1, &$2, NREG, &$4);
250 outcode($1, &$2, NREG, &$4);
252 | LMOVW ximm ',' rreg
254 outcode($1, &$2, NREG, &$4);
256 | LMOVD ximm ',' rreg
258 outcode($1, &$2, NREG, &$4);
261 * B.18 branch on integer condition
262 * B.19 floating point branch on condition
263 * B.20 coprocessor branch on condition
267 outcode($1, &nullgen, NREG, &$3);
270 * B.21 call instruction
271 * B.22 jump and link instruction
275 outcode($1, &nullgen, NREG, &$3);
279 outcode($1, &nullgen, NREG, &$3);
281 | LJMPL comma sreg ',' rel
283 outcode($1, &nullgen, $3, &$5);
285 | LJMPL comma sreg ',' addr
287 outcode($1, &nullgen, $3, &$5);
290 * B.23 return from trap
292 | LRETT rreg ',' rreg
294 outcode($1, &$2, NREG, &$4);
297 * B.28 instruction cache flush
301 outcode($1, &$2, NREG, &nullgen);
305 outcode($1, &$2, NREG, &nullgen);
308 * B.24 trap on condition
310 | LTRAP rreg ',' sreg
312 outcode($1, &$2, $4, &nullgen);
316 outcode($1, &$2, $4, &nullgen);
320 outcode($1, &$2, NREG, &nullgen);
324 outcode($1, &nullgen, NREG, &nullgen);
327 * B.25 read state register instructions
331 outcode($1, &$2, NREG, &$4);
334 * B.26 write state register instructions BOTCH XOR
338 outcode($1, &$2, NREG, &$4);
342 outcode($1, &$2, NREG, &$4);
344 | LXORW rreg ',' sreg ',' psr
346 outcode($1, &$2, $4, &$6);
348 | LXORW imm ',' sreg ',' psr
350 outcode($1, &$2, $4, &$6);
353 * B.27 unimplemented trap
357 outcode($1, &nullgen, NREG, &nullgen);
361 outcode($1, &$2, NREG, &nullgen);
364 * B.29 floating point operate
366 | LFCONV freg ',' freg
368 outcode($1, &$2, NREG, &$4);
370 | LFADD freg ',' freg
372 outcode($1, &$2, NREG, &$4);
374 | LFADD freg ',' freg ',' freg
376 outcode($1, &$2, $4.reg, &$6);
379 * B.30 coprocessor operate
381 | LCPOP creg ',' creg
383 outcode($1, &$2, NREG, &$4);
385 | LCPOP creg ',' creg ',' creg
387 outcode($1, &$2, $4.reg, &$6);
394 outcode($1, &$2, NREG, &$4);
398 outcode($1, &$2, NREG, &$4);
405 outcode($1, &nullgen, NREG, &nullgen);
409 outcode($1, &$2, NREG, &nullgen);
413 outcode($1, &$2, NREG, &nullgen);
417 outcode($1, &nullgen, NREG, &$3);
421 outcode($1, &nullgen, NREG, &$3);
428 outcode($1, &nullgen, NREG, &nullgen);
435 outcode($1, &$2, NREG, &$4);
437 | LTEXT name ',' con ',' imm
439 outcode($1, &$2, $4, &$6);
444 | LDATA name '/' con ',' imm
446 outcode($1, &$2, $4, &$6);
448 | LDATA name '/' con ',' ximm
450 outcode($1, &$2, $4, &$6);
452 | LDATA name '/' con ',' fimm
454 outcode($1, &$2, $4, &$6);
461 outcode($1, &nullgen, NREG, &nullgen);
475 yyerror("undefined label: %s", $1->name);
485 $$.offset = $1->value + $2;
558 memcpy($$.sval, $2, sizeof($$.sval));
586 if($$ < 0 || $$ >= NREG)
587 print("register value out of range\n");
599 | '(' sreg ',' con ')'
606 | '(' sreg '+' sreg ')'
632 | LNAME offset '(' pointer ')'
640 | LNAME '<' '>' offset '(' LSB ')'