Pristine Ack-5.5
[Ack-5.5.git] / mach / arm / as / mach4.c
1 /* $Id: mach4.c, v1.9 15-Mar-89 AJM */
2
3 operation       : BRANCH optlink expr
4                         {branch($1, $2, $3.val);}
5                 | DATA1 optcond opts optp REG ',' REG ',' operand
6                         {data($1,$2|$3|$4|$5<<12|$7<<16,$9.val,$9.typ);}
7                 | DATA2 optcond opts optp REG ',' operand
8                         {data($1,$2|$3|$4|$5<<12,$7.val,$7.typ);}
9                 | DATA3 optcond opts optp REG ',' operand
10                         {data($1,$2|$3|$4|$5<<16,$7.val,$7.typ);}
11                 | SDT optcond optb optt REG ',' address
12                         {strldr($1,$2|$3|$4|$5<<12,$7);}
13                 | BDT optcond REG optexc ',' reglist optpsr
14                         {emit4($1|$2|$3<<16|$4|$6|$7);}
15                 | SWI optcond expr
16                         {emit4($1|$2|$3.val);}
17                 | ADR optcond REG ',' expr
18                         {calcadr($2,$3,$5.val,$5.typ);}
19                 | MUL optcond REG ',' REG ',' REG
20                         {emit4($1|$2|$3<<16|$5|$7<<8);}
21                 | MLA optcond REG ',' REG ',' REG ',' REG
22                         {emit4($1|$2|$3<<16|$5|$7<<8|$9<<12);}
23                 ;
24
25 optlink         :       {$$=0;}
26                 | LINK
27                         {$$=$1;}
28                 ;
29
30 optcond         :       {$$=0xE0000000;}
31                 | COND
32                         {$$=$1;}
33                 ;
34
35 opts            :       {$$=0;}
36                 | SET
37                         {$$=$1;}
38                 ;
39
40 optt            :       {$$=0;}
41                 | TRANS
42                         {$$=$1;}
43                 ;
44
45 optp            :       {$$=0;}
46                 | PEE
47                         {$$=$1;}
48                 ;
49
50 optb            :       {$$=0;}
51                 | BYTE
52                         {$$=$1;}
53                 ;
54
55 optexc          :       {$$=0;}
56                 | '<'
57                         {$$=0x00200000;}
58                 ;
59
60 optpsr          :       {$$=0;}
61                 | '^'
62                         {$$=0x00400000;}
63                 ;
64
65 operand         : REG optshift
66                         {$$.val = $1|$2; $$.typ = S_REG;}
67                 | '#'expr
68                         {$$ = $2;}
69                 ;
70
71 optshift        : ',' SHIFT shftcnt
72                         {$$ = $2|$3;}
73                 | ',' RRX
74                         {$$ = $2;}
75                 |
76                         {$$ = 0;}
77                 ;
78
79 aoptshift       : ',' SHIFT '#' expr
80                         {$$ = $2|calcshft($4.val, $4.typ, $<y_word>0);}
81                 | ',' RRX
82                         {$$ = $2;}
83                 |
84                         {$$ = 0;}
85                 ;
86
87 shftcnt         : '#' expr
88                         {$$ = calcshft($2.val, $2.typ, $<y_word>0);}
89                 | REG
90                         {$$ = $1<<8|0x10;}
91                 ;
92
93 address         : expr
94                         {success = 0; $$ = $1.val;}
95                 | '[' REG ']'
96                         {success = 1; $$ = 0x01000000|$2<<16;}
97                 | '[' REG ',' offset ']' optexc
98                         {success = 1; $$ = $2<<16|$4|$6|0x01000000;}
99                 | '[' REG ']' ',' offset
100                         {success = 1; $$ = $2<<16|$5;}
101                 ;
102
103 offset          : '#' expr
104                         {$$ = calcoffset($2.val);}
105                 | optsign REG aoptshift
106                         {$$ = 0x02000000|$1|$2|$3;}
107                 ;
108         
109 optsign         :       {$$ = 0x00800000;}
110                 | '+'
111                         {$$ = 0x00800000;}
112                 | '-'   
113                         {$$ = 0x0;}
114                 ;
115
116 reglist         : '{' rlist '}'
117                         {$$ = $2;}
118                 ;
119
120 rlist           : REG
121                         {$$ = 1<<$1;}
122                 | rlist ',' REG
123                         {$$ = $1|1<<$3;}
124                 | REG '-' REG
125                         {
126                                for ($$ = 0; $1 <= $3; $1++)
127                                        $$ |= (1<<$1);
128                         }
129                 ;