123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236 |
- /*
- * $Source$
- * $State$
- */
- operation
- : OP_BF_BFA CR ',' CR { emit4($1 | ($2<<23) | ($4<<18)); }
- | OP_BF_FRA_FRB CR ',' FPR ',' FPR { emit4($1 | ($2<<23) | ($4<<16) | ($6<<11)); }
- | OP_BF_L_RA_RB CR ',' u1 ',' GPR ',' GPR { emit4($1 | ($2<<23) | ($4<<21) | ($6<<16) | ($8<<11)); }
- | OP_BF_L_RA_SI CR ',' u1 ',' GPR ',' e16 { emit4($1 | ($2<<23) | ($4<<21) | ($6<<16) | $8); }
- | OP_BF_L_RA_UI CR ',' u1 ',' GPR ',' e16 { emit4($1 | ($2<<23) | ($4<<21) | ($6<<16) | $8); }
- | OP_BF_U_C c CR ',' u4 { emit4($1 | $2 | ($3<<23) | ($5<<12)); }
- | OP_BO_BI_BDA u5 ',' u5 ',' bda { emit4($1 | ($2<<21) | ($4<<16) | $6); }
- | OP_BO_BI_BDL u5 ',' u5 ',' bdl { emit4($1 | ($2<<21) | ($4<<16) | $6); }
- | OP_BO_BI_BH u5 ',' u5 ',' u2 { emit4($1 | ($2<<21) | ($4<<16) | ($6<<11)); }
- | OP_BT_BA_BB u5 ',' u5 ',' u5 { emit4($1 | ($2<<21) | ($4<<16) | ($6<<11)); }
- | OP_BT_C c u5 { emit4($1 | $2 | ($3<<21)); }
- | OP_FLM_FRB_C c u8 ',' FPR { emit4($1 | $2 | ($3<<17) | ($5<<11)); }
- | OP_FRS_RA_D FPR ',' e16 '(' GPR ')' { emit4($1 | ($2<<21) | ($6<<16) | $4); }
- | OP_FRS_RA_RB FPR ',' GPR ',' GPR { emit4($1 | ($2<<21) | ($4<<16) | ($6<<11)); }
- | OP_FRT_FRA_FRB_C c FPR ',' FPR ',' FPR { emit4($1 | $2 | ($3<<21) | ($5<<16) | ($7<<11)); }
- | OP_FRT_FRA_FRC_FRB_C c FPR ',' FPR ',' FPR ',' FPR { emit4($1 | $2 | ($3<<21) | ($5<<16) | ($9<<11) | ($7<<6)); }
- | OP_FRT_FRA_FRC_C c FPR ',' FPR ',' FPR { emit4($1 | $2 | ($3<<21) | ($5<<16) | ($7<<6)); }
- | OP_FRT_FRB_C c FPR ',' FPR { emit4($1 | $2 | ($3<<21) | ($5<<11)); }
- | OP_FRT_RA_D FPR ',' e16 '(' GPR ')' { emit4($1 | ($2<<21) | ($6<<16) | $4); }
- | OP_FRT_RA_RB FPR ',' GPR ',' GPR { emit4($1 | ($2<<21) | ($4<<16) | ($6<<11)); }
- | OP_FRT_C c FPR { emit4($1 | $2 | ($3<<21)); }
- | OP_RT GPR { emit4($1 | ($2<<21)); }
- | OP_RT_RA_C c GPR ',' GPR { emit4($1 | $2 | ($3<<21) | ($5<<16)); }
- | OP_RT_RA_D GPR ',' e16 '(' GPR ')' { emit4($1 | ($2<<21) | ($6<<16) | $4); }
- | OP_RT_RA_DS GPR ',' ds '(' GPR ')' { emit4($1 | ($2<<21) | ($6<<16) | $4); }
- | OP_RT_RA_NB GPR ',' GPR ',' nb { emit4($1 | ($2<<21) | ($4<<16) | ($6<<11)); }
- | OP_RT_RA_RB GPR ',' GPR ',' GPR { emit4($1 | ($2<<21) | ($4<<16) | ($6<<11)); }
- | OP_RT_RA_RB_C c GPR ',' GPR ',' GPR { emit4($1 | $2 | ($3<<21) | ($5<<16) | ($7<<11)); }
- | OP_RT_RA_SI GPR ',' GPR ',' e16 { emit4($1 | ($2<<21) | ($4<<16) | $6); }
- | OP_RT_RA_SI_addic c GPR ',' GPR ',' e16 { emit4($1 | ($2<<26) | ($3<<21) | ($5<<16) | $7); }
- | OP_RT_SPR GPR ',' SPR { emit4($1 | ($2<<21) | ($4<<11)); }
- | OP_RS_FXM u7 ',' GPR { emit4($1 | ($4<<21) | ($2<<12)); }
- | OP_RS_RA_C c GPR ',' GPR { emit4($1 | $2 | ($5<<21) | ($3<<16)); }
- | OP_RS_RA_D GPR ',' e16 '(' GPR ')' { emit4($1 | ($2<<21) | ($6<<16) | $4); }
- | OP_RS_RA_DS GPR ',' ds '(' GPR ')' { emit4($1 | ($2<<21) | ($6<<16) | $4); }
- | OP_RS_RA_NB GPR ',' GPR ',' nb { emit4($1 | ($2<<21) | ($4<<16) | ($6<<11)); }
- | OP_RS_RA_UI GPR ',' GPR ',' e16 { emit4($1 | ($4<<21) | ($2<<16) | $6); }
- | OP_RS_RA_UI_CC C GPR ',' GPR ',' e16 { emit4($1 | ($5<<21) | ($3<<16) | $7); }
- | OP_RS_RA_RB GPR ',' GPR ',' GPR { emit4($1 | ($2<<21) | ($4<<16) | ($6<<11)); }
- | OP_RS_RA_RB_C c GPR ',' GPR ',' GPR { emit4($1 | $2 | ($5<<21) | ($3<<16) | ($7<<11)); }
- | OP_RS_RA_RB_MB5_ME5_C c GPR ',' GPR ',' GPR ',' u5 ',' u5 { emit4($1 | $2 | ($5<<21) | ($3<<16) | ($7<<11) | ($9<<6) | ($11<<1)); }
- | OP_RS_RA_RB_MB6_C c GPR ',' GPR ',' GPR ',' u6 { emit4($1 | $2 | ($5<<21) | ($3<<16) | ($7<<11) | (($9&0x1F)<<6) | (($9&0x20)>>0)); }
- | OP_RS_RA_RB_ME6_C c GPR ',' GPR ',' GPR ',' u6 { emit4($1 | $2 | ($5<<21) | ($3<<16) | ($7<<11) | (($9&0x1F)<<6) | (($9&0x20)>>0)); }
- | OP_RS_RA_SH_MB5_ME5_C c GPR ',' GPR ',' u5 ',' u5 ',' u5 { emit4($1 | $2 | ($5<<21) | ($3<<16) | ($7<<11) | ($9<<6) | ($11<<1)); }
- | OP_RS_RA_SH_MB6_SH_C c GPR ',' GPR ',' u6 ',' u6 { emit4($1 | $2 | ($5<<21) | ($3<<16) | (($7&0x1F)<<11) | ($9<<6) | (($7&0x20)>>4)); }
- | OP_RS_RA_SH_ME6_SH_C c GPR ',' GPR ',' u6 ',' u6 { emit4($1 | $2 | ($5<<21) | ($3<<16) | (($7&0x1F)<<11) | ($9<<6) | (($7&0x20)>>4)); }
- | OP_RS_RA_SH5_C c GPR ',' GPR ',' u5 { emit4($1 | $2 | ($5<<21) | ($3<<16) | ($7<<11)); }
- | OP_RS_RA_SH6_C c GPR ',' GPR ',' u6 { emit4($1 | $2 | ($5<<21) | ($3<<16) | (($7&0x1F)<<11) | (($7&0x20)>>4)); }
- | OP_RS_SPR SPR ',' GPR { emit4($1 | ($4<<21) | ($2<<11)); }
- | OP_TO_RA_RB u5 ',' GPR ',' GPR { emit4($1 | ($2<<21) | ($4<<16) | ($6<<11)); }
- | OP_TO_RA_SI u5 ',' GPR ',' e16 { emit4($1 | ($2<<21) | ($4<<16) | $6); }
- | OP_LEV u7 { emit4($1 | ($2<<5)); }
- | OP_LIA lia { emit4($1 | $2); }
- | OP_LIL lil { emit4($1 | $2); }
- ;
- c
- : /* nothing */ { $$ = 0; }
- | C { $$ = 1; }
- ;
-
- e16
- : '<' expr
- {
- DOTVAL += 2;
- newrelo($2.typ, RELOH2 | FIXUPFLAGS);
- DOTVAL -= 2;
- $$ = ($2.val >> 16) & 0xFFFF;
- }
- | '>' expr
- {
- DOTVAL += 2;
- newrelo($2.typ, RELO2 | FIXUPFLAGS);
- DOTVAL -= 2;
- $$ = $2.val & 0xFFFF;
- }
- | expr
- {
- DOTVAL += 2;
- newrelo($1.typ, RELO2 | FIXUPFLAGS);
- DOTVAL -= 2;
- $$ = $1.val & 0xFFFF;
- }
- ;
-
- u8
- : absexp
- {
- if (($1 < 0) || ($1 > 0xFF))
- serror("8-bit unsigned value out of range");
- $$ = $1;
- }
- ;
-
- u7
- : absexp
- {
- if (($1 < 0) || ($1 > 0x7F))
- serror("7-bit unsigned value out of range");
- $$ = $1;
- }
- ;
-
- u6
- : absexp
- {
- if (($1 < 0) || ($1 > 0x3F))
- serror("6-bit unsigned value out of range");
- $$ = $1;
- }
- ;
-
- u5
- : absexp
- {
- if (($1 < 0) || ($1 > 0x1F))
- serror("5-bit unsigned value out of range");
- $$ = $1;
- }
- ;
-
- u4
- : absexp
- {
- if (($1 < 0) || ($1 > 0xF))
- serror("4-bit unsigned value out of range");
- $$ = $1;
- }
- ;
-
- u1
- : absexp
- {
- if (($1 < 0) || ($1 > 1))
- serror("1-bit unsigned value out of range");
- $$ = $1;
- }
- ;
-
- u2
- : absexp
- {
- if (($1 < 0) || ($1 > 0x3))
- serror("2-bit unsigned value out of range");
- $$ = $1;
- }
- ;
-
- ds
- : e16
- {
- if ($1 & 3)
- serror("value must be 4-aligned");
- $$ = $1;
- }
- ;
-
- nb
- : absexp
- {
- if (($1 < 1) || ($1 > 32))
- serror("register count must be in the range 1..32");
-
- if ($1 == 32)
- $$ = 0;
- else
- $$ = $1;
- }
- ;
-
- bdl
- : expr
- {
- int dist = $1.val - DOTVAL;
- fit(fitx(dist, 25));
-
- if (dist & 0x3)
- serror("jump targets must be 4-aligned");
- DOTVAL += 2;
- newrelo($1.typ, RELO2 | RELPC | FIXUPFLAGS);
- DOTVAL -= 2;
- $$ = dist & 0xFFFD;
- }
- ;
- bda
- : expr
- {
- int target = $1.val;
- fit(fitx(target, 16));
-
- if (target & 0x3)
- serror("jump targets must be 4-aligned");
- DOTVAL += 2;
- newrelo($1.typ, RELO2 | FIXUPFLAGS);
- DOTVAL -= 2;
- $$ = target & 0xFFFD;
- }
- ;
-
- lil
- : expr
- {
- int dist = $1.val - DOTVAL;
- fit(fitx(dist, 26));
-
- if (dist & 0x3)
- serror("jump targets must be 4-aligned");
- newrelo($1.typ, RELOPPC | RELPC | FIXUPFLAGS);
- $$ = dist & 0x03FFFFFD;
- }
- ;
-
- lia
- : expr
- {
- int target = $1.val;
- fit(fitx(target, 26));
-
- if (target & 0x3)
- serror("jump targets must be 4-aligned");
- newrelo($1.typ, RELOPPC | FIXUPFLAGS);
- $$ = target & 0x03FFFFFD;
- }
- ;
-
|