| 1 | # |
| 2 | # MicroBlaze instruction decode definitions. |
| 3 | # |
| 4 | # Copyright (c) 2020 Richard Henderson <rth@twiddle.net> |
| 5 | # |
| 6 | # This library is free software; you can redistribute it and/or |
| 7 | # modify it under the terms of the GNU Lesser General Public |
| 8 | # License as published by the Free Software Foundation; either |
| 9 | # version 2.1 of the License, or (at your option) any later version. |
| 10 | # |
| 11 | # This library is distributed in the hope that it will be useful, |
| 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 | # Lesser General Public License for more details. |
| 15 | # |
| 16 | # You should have received a copy of the GNU Lesser General Public |
| 17 | # License along with this library; if not, see <http://www.gnu.org/licenses/>. |
| 18 | # |
| 19 | |
| 20 | &typea0 rd ra |
| 21 | &typea rd ra rb |
| 22 | &typea_br rd rb |
| 23 | &typea_bc ra rb |
| 24 | &typeb rd ra imm |
| 25 | &typeb_br rd imm |
| 26 | &typeb_bc ra imm |
| 27 | &type_msr rd imm |
| 28 | |
| 29 | # Include any IMM prefix in the value reported. |
| 30 | %extimm 0:s16 !function=typeb_imm |
| 31 | |
| 32 | @typea ...... rd:5 ra:5 rb:5 ... .... .... &typea |
| 33 | @typeb ...... rd:5 ra:5 ................ &typeb imm=%extimm |
| 34 | |
| 35 | # Officially typea, but with rb==0, which is not used. |
| 36 | @typea0 ...... rd:5 ra:5 ................ &typea0 |
| 37 | |
| 38 | # Officially typea, but with ra as opcode. |
| 39 | @typea_br ...... rd:5 ..... rb:5 ........... &typea_br |
| 40 | |
| 41 | # Officially typea, but with rd as opcode. |
| 42 | @typea_bc ...... ..... ra:5 rb:5 ........... &typea_bc |
| 43 | |
| 44 | # Officially typeb, but any immediate extension is unused. |
| 45 | @typeb_bs ...... rd:5 ra:5 ..... ...... imm:5 &typeb |
| 46 | |
| 47 | # Officially typeb, but with ra as opcode. |
| 48 | @typeb_br ...... rd:5 ..... ................ &typeb_br imm=%extimm |
| 49 | |
| 50 | # Officially typeb, but with rd as opcode. |
| 51 | @typeb_bc ...... ..... ra:5 ................ &typeb_bc imm=%extimm |
| 52 | |
| 53 | # For convenience, extract the two imm_w/imm_s fields, then pack |
| 54 | # them back together as "imm". Doing this makes it easiest to |
| 55 | # match the required zero at bit 5. |
| 56 | %ieimm 6:5 0:5 |
| 57 | @typeb_ie ...... rd:5 ra:5 ..... ..... . ..... &typeb imm=%ieimm |
| 58 | |
| 59 | @type_msr ...... rd:5 ...... imm:15 &type_msr |
| 60 | |
| 61 | ### |
| 62 | |
| 63 | { |
| 64 | zero 000000 00000 00000 00000 000 0000 0000 |
| 65 | add 000000 ..... ..... ..... 000 0000 0000 @typea |
| 66 | } |
| 67 | addc 000010 ..... ..... ..... 000 0000 0000 @typea |
| 68 | addk 000100 ..... ..... ..... 000 0000 0000 @typea |
| 69 | addkc 000110 ..... ..... ..... 000 0000 0000 @typea |
| 70 | |
| 71 | addi 001000 ..... ..... ................ @typeb |
| 72 | addic 001010 ..... ..... ................ @typeb |
| 73 | addik 001100 ..... ..... ................ @typeb |
| 74 | addikc 001110 ..... ..... ................ @typeb |
| 75 | |
| 76 | and 100001 ..... ..... ..... 000 0000 0000 @typea |
| 77 | andi 101001 ..... ..... ................ @typeb |
| 78 | |
| 79 | andn 100011 ..... ..... ..... 000 0000 0000 @typea |
| 80 | andni 101011 ..... ..... ................ @typeb |
| 81 | |
| 82 | beq 100111 00000 ..... ..... 000 0000 0000 @typea_bc |
| 83 | bge 100111 00101 ..... ..... 000 0000 0000 @typea_bc |
| 84 | bgt 100111 00100 ..... ..... 000 0000 0000 @typea_bc |
| 85 | ble 100111 00011 ..... ..... 000 0000 0000 @typea_bc |
| 86 | blt 100111 00010 ..... ..... 000 0000 0000 @typea_bc |
| 87 | bne 100111 00001 ..... ..... 000 0000 0000 @typea_bc |
| 88 | |
| 89 | beqd 100111 10000 ..... ..... 000 0000 0000 @typea_bc |
| 90 | bged 100111 10101 ..... ..... 000 0000 0000 @typea_bc |
| 91 | bgtd 100111 10100 ..... ..... 000 0000 0000 @typea_bc |
| 92 | bled 100111 10011 ..... ..... 000 0000 0000 @typea_bc |
| 93 | bltd 100111 10010 ..... ..... 000 0000 0000 @typea_bc |
| 94 | bned 100111 10001 ..... ..... 000 0000 0000 @typea_bc |
| 95 | |
| 96 | beqi 101111 00000 ..... ................ @typeb_bc |
| 97 | bgei 101111 00101 ..... ................ @typeb_bc |
| 98 | bgti 101111 00100 ..... ................ @typeb_bc |
| 99 | blei 101111 00011 ..... ................ @typeb_bc |
| 100 | blti 101111 00010 ..... ................ @typeb_bc |
| 101 | bnei 101111 00001 ..... ................ @typeb_bc |
| 102 | |
| 103 | beqid 101111 10000 ..... ................ @typeb_bc |
| 104 | bgeid 101111 10101 ..... ................ @typeb_bc |
| 105 | bgtid 101111 10100 ..... ................ @typeb_bc |
| 106 | bleid 101111 10011 ..... ................ @typeb_bc |
| 107 | bltid 101111 10010 ..... ................ @typeb_bc |
| 108 | bneid 101111 10001 ..... ................ @typeb_bc |
| 109 | |
| 110 | br 100110 ..... 00000 ..... 000 0000 0000 @typea_br |
| 111 | bra 100110 ..... 01000 ..... 000 0000 0000 @typea_br |
| 112 | brd 100110 ..... 10000 ..... 000 0000 0000 @typea_br |
| 113 | brad 100110 ..... 11000 ..... 000 0000 0000 @typea_br |
| 114 | brld 100110 ..... 10100 ..... 000 0000 0000 @typea_br |
| 115 | brald 100110 ..... 11100 ..... 000 0000 0000 @typea_br |
| 116 | |
| 117 | bri 101110 ..... 00000 ................ @typeb_br |
| 118 | brai 101110 ..... 01000 ................ @typeb_br |
| 119 | brid 101110 ..... 10000 ................ @typeb_br |
| 120 | braid 101110 ..... 11000 ................ @typeb_br |
| 121 | brlid 101110 ..... 10100 ................ @typeb_br |
| 122 | bralid 101110 ..... 11100 ................ @typeb_br |
| 123 | |
| 124 | brk 100110 ..... 01100 ..... 000 0000 0000 @typea_br |
| 125 | brki 101110 ..... 01100 ................ @typeb_br |
| 126 | |
| 127 | bsrl 010001 ..... ..... ..... 000 0000 0000 @typea |
| 128 | bsra 010001 ..... ..... ..... 010 0000 0000 @typea |
| 129 | bsll 010001 ..... ..... ..... 100 0000 0000 @typea |
| 130 | |
| 131 | bsrli 011001 ..... ..... 00000 000000 ..... @typeb_bs |
| 132 | bsrai 011001 ..... ..... 00000 010000 ..... @typeb_bs |
| 133 | bslli 011001 ..... ..... 00000 100000 ..... @typeb_bs |
| 134 | |
| 135 | bsefi 011001 ..... ..... 01000 .....0 ..... @typeb_ie |
| 136 | bsifi 011001 ..... ..... 10000 .....0 ..... @typeb_ie |
| 137 | |
| 138 | clz 100100 ..... ..... 00000 000 1110 0000 @typea0 |
| 139 | |
| 140 | cmp 000101 ..... ..... ..... 000 0000 0001 @typea |
| 141 | cmpu 000101 ..... ..... ..... 000 0000 0011 @typea |
| 142 | |
| 143 | fadd 010110 ..... ..... ..... 0000 000 0000 @typea |
| 144 | frsub 010110 ..... ..... ..... 0001 000 0000 @typea |
| 145 | fmul 010110 ..... ..... ..... 0010 000 0000 @typea |
| 146 | fdiv 010110 ..... ..... ..... 0011 000 0000 @typea |
| 147 | fcmp_un 010110 ..... ..... ..... 0100 000 0000 @typea |
| 148 | fcmp_lt 010110 ..... ..... ..... 0100 001 0000 @typea |
| 149 | fcmp_eq 010110 ..... ..... ..... 0100 010 0000 @typea |
| 150 | fcmp_le 010110 ..... ..... ..... 0100 011 0000 @typea |
| 151 | fcmp_gt 010110 ..... ..... ..... 0100 100 0000 @typea |
| 152 | fcmp_ne 010110 ..... ..... ..... 0100 101 0000 @typea |
| 153 | fcmp_ge 010110 ..... ..... ..... 0100 110 0000 @typea |
| 154 | |
| 155 | # Note that flt and fint, unlike fsqrt, are documented as having the RB |
| 156 | # operand which is unused. So allow the field to be non-zero but discard |
| 157 | # the value and treat as 2-operand insns. |
| 158 | flt 010110 ..... ..... ----- 0101 000 0000 @typea0 |
| 159 | fint 010110 ..... ..... ----- 0110 000 0000 @typea0 |
| 160 | fsqrt 010110 ..... ..... 00000 0111 000 0000 @typea0 |
| 161 | |
| 162 | get 011011 rd:5 00000 0 ctrl:5 000000 imm:4 |
| 163 | getd 010011 rd:5 00000 rb:5 0 ctrl:5 00000 |
| 164 | |
| 165 | idiv 010010 ..... ..... ..... 000 0000 0000 @typea |
| 166 | idivu 010010 ..... ..... ..... 000 0000 0010 @typea |
| 167 | |
| 168 | imm 101100 00000 00000 imm:16 |
| 169 | |
| 170 | lbu 110000 ..... ..... ..... 0000 000 0000 @typea |
| 171 | lbur 110000 ..... ..... ..... 0100 000 0000 @typea |
| 172 | lbuea 110000 ..... ..... ..... 0001 000 0000 @typea |
| 173 | lbui 111000 ..... ..... ................ @typeb |
| 174 | |
| 175 | lhu 110001 ..... ..... ..... 0000 000 0000 @typea |
| 176 | lhur 110001 ..... ..... ..... 0100 000 0000 @typea |
| 177 | lhuea 110001 ..... ..... ..... 0001 000 0000 @typea |
| 178 | lhui 111001 ..... ..... ................ @typeb |
| 179 | |
| 180 | lw 110010 ..... ..... ..... 0000 000 0000 @typea |
| 181 | lwr 110010 ..... ..... ..... 0100 000 0000 @typea |
| 182 | lwea 110010 ..... ..... ..... 0001 000 0000 @typea |
| 183 | lwx 110010 ..... ..... ..... 1000 000 0000 @typea |
| 184 | lwi 111010 ..... ..... ................ @typeb |
| 185 | |
| 186 | mbar 101110 imm:5 00010 0000 0000 0000 0100 |
| 187 | |
| 188 | mfs 100101 rd:5 0 e:1 000 10 rs:14 |
| 189 | mts 100101 0 e:1 000 ra:5 11 rs:14 |
| 190 | |
| 191 | msrclr 100101 ..... 100010 ............... @type_msr |
| 192 | msrset 100101 ..... 100000 ............... @type_msr |
| 193 | |
| 194 | mul 010000 ..... ..... ..... 000 0000 0000 @typea |
| 195 | mulh 010000 ..... ..... ..... 000 0000 0001 @typea |
| 196 | mulhu 010000 ..... ..... ..... 000 0000 0011 @typea |
| 197 | mulhsu 010000 ..... ..... ..... 000 0000 0010 @typea |
| 198 | muli 011000 ..... ..... ................ @typeb |
| 199 | |
| 200 | or 100000 ..... ..... ..... 000 0000 0000 @typea |
| 201 | ori 101000 ..... ..... ................ @typeb |
| 202 | |
| 203 | pcmpbf 100000 ..... ..... ..... 100 0000 0000 @typea |
| 204 | pcmpeq 100010 ..... ..... ..... 100 0000 0000 @typea |
| 205 | pcmpne 100011 ..... ..... ..... 100 0000 0000 @typea |
| 206 | |
| 207 | put 011011 00000 ra:5 1 ctrl:5 000000 imm:4 |
| 208 | putd 010011 00000 ra:5 rb:5 1 ctrl:5 00000 |
| 209 | |
| 210 | rsub 000001 ..... ..... ..... 000 0000 0000 @typea |
| 211 | rsubc 000011 ..... ..... ..... 000 0000 0000 @typea |
| 212 | rsubk 000101 ..... ..... ..... 000 0000 0000 @typea |
| 213 | rsubkc 000111 ..... ..... ..... 000 0000 0000 @typea |
| 214 | |
| 215 | rsubi 001001 ..... ..... ................ @typeb |
| 216 | rsubic 001011 ..... ..... ................ @typeb |
| 217 | rsubik 001101 ..... ..... ................ @typeb |
| 218 | rsubikc 001111 ..... ..... ................ @typeb |
| 219 | |
| 220 | rtbd 101101 10010 ..... ................ @typeb_bc |
| 221 | rtid 101101 10001 ..... ................ @typeb_bc |
| 222 | rted 101101 10100 ..... ................ @typeb_bc |
| 223 | rtsd 101101 10000 ..... ................ @typeb_bc |
| 224 | |
| 225 | sb 110100 ..... ..... ..... 0000 000 0000 @typea |
| 226 | sbr 110100 ..... ..... ..... 0100 000 0000 @typea |
| 227 | sbea 110100 ..... ..... ..... 0001 000 0000 @typea |
| 228 | sbi 111100 ..... ..... ................ @typeb |
| 229 | |
| 230 | sh 110101 ..... ..... ..... 0000 000 0000 @typea |
| 231 | shr 110101 ..... ..... ..... 0100 000 0000 @typea |
| 232 | shea 110101 ..... ..... ..... 0001 000 0000 @typea |
| 233 | shi 111101 ..... ..... ................ @typeb |
| 234 | |
| 235 | sw 110110 ..... ..... ..... 0000 000 0000 @typea |
| 236 | swr 110110 ..... ..... ..... 0100 000 0000 @typea |
| 237 | swea 110110 ..... ..... ..... 0001 000 0000 @typea |
| 238 | swx 110110 ..... ..... ..... 1000 000 0000 @typea |
| 239 | swi 111110 ..... ..... ................ @typeb |
| 240 | |
| 241 | sext8 100100 ..... ..... 00000 000 0110 0000 @typea0 |
| 242 | sext16 100100 ..... ..... 00000 000 0110 0001 @typea0 |
| 243 | |
| 244 | sra 100100 ..... ..... 00000 000 0000 0001 @typea0 |
| 245 | src 100100 ..... ..... 00000 000 0010 0001 @typea0 |
| 246 | srl 100100 ..... ..... 00000 000 0100 0001 @typea0 |
| 247 | |
| 248 | swapb 100100 ..... ..... 00000 001 1110 0000 @typea0 |
| 249 | swaph 100100 ..... ..... 00000 001 1110 0010 @typea0 |
| 250 | |
| 251 | # Cache operations have no effect in qemu: discard the arguments. |
| 252 | wdic 100100 00000 ----- ----- -00 -11- 01-0 # wdc |
| 253 | wdic 100100 00000 ----- ----- 000 0110 1000 # wic |
| 254 | |
| 255 | xor 100010 ..... ..... ..... 000 0000 0000 @typea |
| 256 | xori 101010 ..... ..... ................ @typeb |