1 1.1 christos /* TILE-Gx opcode information. 2 1.1 christos * 3 1.1.1.9 christos * Copyright (C) 2011-2024 Free Software Foundation, Inc. 4 1.1 christos * 5 1.1 christos * This program is free software; you can redistribute it and/or modify 6 1.1 christos * it under the terms of the GNU General Public License as published by 7 1.1 christos * the Free Software Foundation; either version 3 of the License, or 8 1.1 christos * (at your option) any later version. 9 1.1 christos * 10 1.1 christos * This program is distributed in the hope that it will be useful, 11 1.1 christos * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 1.1 christos * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 1.1 christos * GNU General Public License for more details. 14 1.1 christos * 15 1.1 christos * You should have received a copy of the GNU General Public License 16 1.1 christos * along with this program; if not, write to the Free Software 17 1.1 christos * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, 18 1.1 christos * MA 02110-1301, USA. 19 1.1 christos */ 20 1.1 christos 21 1.1 christos #ifndef opcode_tile_h 22 1.1 christos #define opcode_tile_h 23 1.1 christos 24 1.1.1.3 christos #ifdef __cplusplus 25 1.1.1.3 christos extern "C" { 26 1.1.1.3 christos #endif 27 1.1.1.3 christos 28 1.1 christos typedef unsigned long long tilegx_bundle_bits; 29 1.1 christos 30 1.1 christos 31 1.1 christos enum 32 1.1 christos { 33 1.1 christos TILEGX_MAX_OPERANDS = 4 /* bfexts */ 34 1.1 christos }; 35 1.1 christos 36 1.1 christos typedef enum 37 1.1 christos { 38 1.1 christos TILEGX_OPC_BPT, 39 1.1 christos TILEGX_OPC_INFO, 40 1.1 christos TILEGX_OPC_INFOL, 41 1.1 christos TILEGX_OPC_LD4S_TLS, 42 1.1 christos TILEGX_OPC_LD_TLS, 43 1.1 christos TILEGX_OPC_MOVE, 44 1.1 christos TILEGX_OPC_MOVEI, 45 1.1 christos TILEGX_OPC_MOVELI, 46 1.1 christos TILEGX_OPC_PREFETCH, 47 1.1 christos TILEGX_OPC_PREFETCH_ADD_L1, 48 1.1 christos TILEGX_OPC_PREFETCH_ADD_L1_FAULT, 49 1.1 christos TILEGX_OPC_PREFETCH_ADD_L2, 50 1.1 christos TILEGX_OPC_PREFETCH_ADD_L2_FAULT, 51 1.1 christos TILEGX_OPC_PREFETCH_ADD_L3, 52 1.1 christos TILEGX_OPC_PREFETCH_ADD_L3_FAULT, 53 1.1 christos TILEGX_OPC_PREFETCH_L1, 54 1.1 christos TILEGX_OPC_PREFETCH_L1_FAULT, 55 1.1 christos TILEGX_OPC_PREFETCH_L2, 56 1.1 christos TILEGX_OPC_PREFETCH_L2_FAULT, 57 1.1 christos TILEGX_OPC_PREFETCH_L3, 58 1.1 christos TILEGX_OPC_PREFETCH_L3_FAULT, 59 1.1 christos TILEGX_OPC_RAISE, 60 1.1 christos TILEGX_OPC_ADD, 61 1.1 christos TILEGX_OPC_ADDI, 62 1.1 christos TILEGX_OPC_ADDLI, 63 1.1 christos TILEGX_OPC_ADDX, 64 1.1 christos TILEGX_OPC_ADDXI, 65 1.1 christos TILEGX_OPC_ADDXLI, 66 1.1 christos TILEGX_OPC_ADDXSC, 67 1.1 christos TILEGX_OPC_AND, 68 1.1 christos TILEGX_OPC_ANDI, 69 1.1 christos TILEGX_OPC_BEQZ, 70 1.1 christos TILEGX_OPC_BEQZT, 71 1.1 christos TILEGX_OPC_BFEXTS, 72 1.1 christos TILEGX_OPC_BFEXTU, 73 1.1 christos TILEGX_OPC_BFINS, 74 1.1 christos TILEGX_OPC_BGEZ, 75 1.1 christos TILEGX_OPC_BGEZT, 76 1.1 christos TILEGX_OPC_BGTZ, 77 1.1 christos TILEGX_OPC_BGTZT, 78 1.1 christos TILEGX_OPC_BLBC, 79 1.1 christos TILEGX_OPC_BLBCT, 80 1.1 christos TILEGX_OPC_BLBS, 81 1.1 christos TILEGX_OPC_BLBST, 82 1.1 christos TILEGX_OPC_BLEZ, 83 1.1 christos TILEGX_OPC_BLEZT, 84 1.1 christos TILEGX_OPC_BLTZ, 85 1.1 christos TILEGX_OPC_BLTZT, 86 1.1 christos TILEGX_OPC_BNEZ, 87 1.1 christos TILEGX_OPC_BNEZT, 88 1.1 christos TILEGX_OPC_CLZ, 89 1.1 christos TILEGX_OPC_CMOVEQZ, 90 1.1 christos TILEGX_OPC_CMOVNEZ, 91 1.1 christos TILEGX_OPC_CMPEQ, 92 1.1 christos TILEGX_OPC_CMPEQI, 93 1.1 christos TILEGX_OPC_CMPEXCH, 94 1.1 christos TILEGX_OPC_CMPEXCH4, 95 1.1 christos TILEGX_OPC_CMPLES, 96 1.1 christos TILEGX_OPC_CMPLEU, 97 1.1 christos TILEGX_OPC_CMPLTS, 98 1.1 christos TILEGX_OPC_CMPLTSI, 99 1.1 christos TILEGX_OPC_CMPLTU, 100 1.1 christos TILEGX_OPC_CMPLTUI, 101 1.1 christos TILEGX_OPC_CMPNE, 102 1.1 christos TILEGX_OPC_CMUL, 103 1.1 christos TILEGX_OPC_CMULA, 104 1.1 christos TILEGX_OPC_CMULAF, 105 1.1 christos TILEGX_OPC_CMULF, 106 1.1 christos TILEGX_OPC_CMULFR, 107 1.1 christos TILEGX_OPC_CMULH, 108 1.1 christos TILEGX_OPC_CMULHR, 109 1.1 christos TILEGX_OPC_CRC32_32, 110 1.1 christos TILEGX_OPC_CRC32_8, 111 1.1 christos TILEGX_OPC_CTZ, 112 1.1 christos TILEGX_OPC_DBLALIGN, 113 1.1 christos TILEGX_OPC_DBLALIGN2, 114 1.1 christos TILEGX_OPC_DBLALIGN4, 115 1.1 christos TILEGX_OPC_DBLALIGN6, 116 1.1 christos TILEGX_OPC_DRAIN, 117 1.1 christos TILEGX_OPC_DTLBPR, 118 1.1 christos TILEGX_OPC_EXCH, 119 1.1 christos TILEGX_OPC_EXCH4, 120 1.1 christos TILEGX_OPC_FDOUBLE_ADD_FLAGS, 121 1.1 christos TILEGX_OPC_FDOUBLE_ADDSUB, 122 1.1 christos TILEGX_OPC_FDOUBLE_MUL_FLAGS, 123 1.1 christos TILEGX_OPC_FDOUBLE_PACK1, 124 1.1 christos TILEGX_OPC_FDOUBLE_PACK2, 125 1.1 christos TILEGX_OPC_FDOUBLE_SUB_FLAGS, 126 1.1 christos TILEGX_OPC_FDOUBLE_UNPACK_MAX, 127 1.1 christos TILEGX_OPC_FDOUBLE_UNPACK_MIN, 128 1.1 christos TILEGX_OPC_FETCHADD, 129 1.1 christos TILEGX_OPC_FETCHADD4, 130 1.1 christos TILEGX_OPC_FETCHADDGEZ, 131 1.1 christos TILEGX_OPC_FETCHADDGEZ4, 132 1.1 christos TILEGX_OPC_FETCHAND, 133 1.1 christos TILEGX_OPC_FETCHAND4, 134 1.1 christos TILEGX_OPC_FETCHOR, 135 1.1 christos TILEGX_OPC_FETCHOR4, 136 1.1 christos TILEGX_OPC_FINV, 137 1.1 christos TILEGX_OPC_FLUSH, 138 1.1 christos TILEGX_OPC_FLUSHWB, 139 1.1 christos TILEGX_OPC_FNOP, 140 1.1 christos TILEGX_OPC_FSINGLE_ADD1, 141 1.1 christos TILEGX_OPC_FSINGLE_ADDSUB2, 142 1.1 christos TILEGX_OPC_FSINGLE_MUL1, 143 1.1 christos TILEGX_OPC_FSINGLE_MUL2, 144 1.1 christos TILEGX_OPC_FSINGLE_PACK1, 145 1.1 christos TILEGX_OPC_FSINGLE_PACK2, 146 1.1 christos TILEGX_OPC_FSINGLE_SUB1, 147 1.1 christos TILEGX_OPC_ICOH, 148 1.1 christos TILEGX_OPC_ILL, 149 1.1 christos TILEGX_OPC_INV, 150 1.1 christos TILEGX_OPC_IRET, 151 1.1 christos TILEGX_OPC_J, 152 1.1 christos TILEGX_OPC_JAL, 153 1.1 christos TILEGX_OPC_JALR, 154 1.1 christos TILEGX_OPC_JALRP, 155 1.1 christos TILEGX_OPC_JR, 156 1.1 christos TILEGX_OPC_JRP, 157 1.1 christos TILEGX_OPC_LD, 158 1.1 christos TILEGX_OPC_LD1S, 159 1.1 christos TILEGX_OPC_LD1S_ADD, 160 1.1 christos TILEGX_OPC_LD1U, 161 1.1 christos TILEGX_OPC_LD1U_ADD, 162 1.1 christos TILEGX_OPC_LD2S, 163 1.1 christos TILEGX_OPC_LD2S_ADD, 164 1.1 christos TILEGX_OPC_LD2U, 165 1.1 christos TILEGX_OPC_LD2U_ADD, 166 1.1 christos TILEGX_OPC_LD4S, 167 1.1 christos TILEGX_OPC_LD4S_ADD, 168 1.1 christos TILEGX_OPC_LD4U, 169 1.1 christos TILEGX_OPC_LD4U_ADD, 170 1.1 christos TILEGX_OPC_LD_ADD, 171 1.1 christos TILEGX_OPC_LDNA, 172 1.1 christos TILEGX_OPC_LDNA_ADD, 173 1.1 christos TILEGX_OPC_LDNT, 174 1.1 christos TILEGX_OPC_LDNT1S, 175 1.1 christos TILEGX_OPC_LDNT1S_ADD, 176 1.1 christos TILEGX_OPC_LDNT1U, 177 1.1 christos TILEGX_OPC_LDNT1U_ADD, 178 1.1 christos TILEGX_OPC_LDNT2S, 179 1.1 christos TILEGX_OPC_LDNT2S_ADD, 180 1.1 christos TILEGX_OPC_LDNT2U, 181 1.1 christos TILEGX_OPC_LDNT2U_ADD, 182 1.1 christos TILEGX_OPC_LDNT4S, 183 1.1 christos TILEGX_OPC_LDNT4S_ADD, 184 1.1 christos TILEGX_OPC_LDNT4U, 185 1.1 christos TILEGX_OPC_LDNT4U_ADD, 186 1.1 christos TILEGX_OPC_LDNT_ADD, 187 1.1 christos TILEGX_OPC_LNK, 188 1.1 christos TILEGX_OPC_MF, 189 1.1 christos TILEGX_OPC_MFSPR, 190 1.1 christos TILEGX_OPC_MM, 191 1.1 christos TILEGX_OPC_MNZ, 192 1.1 christos TILEGX_OPC_MTSPR, 193 1.1 christos TILEGX_OPC_MUL_HS_HS, 194 1.1 christos TILEGX_OPC_MUL_HS_HU, 195 1.1 christos TILEGX_OPC_MUL_HS_LS, 196 1.1 christos TILEGX_OPC_MUL_HS_LU, 197 1.1 christos TILEGX_OPC_MUL_HU_HU, 198 1.1 christos TILEGX_OPC_MUL_HU_LS, 199 1.1 christos TILEGX_OPC_MUL_HU_LU, 200 1.1 christos TILEGX_OPC_MUL_LS_LS, 201 1.1 christos TILEGX_OPC_MUL_LS_LU, 202 1.1 christos TILEGX_OPC_MUL_LU_LU, 203 1.1 christos TILEGX_OPC_MULA_HS_HS, 204 1.1 christos TILEGX_OPC_MULA_HS_HU, 205 1.1 christos TILEGX_OPC_MULA_HS_LS, 206 1.1 christos TILEGX_OPC_MULA_HS_LU, 207 1.1 christos TILEGX_OPC_MULA_HU_HU, 208 1.1 christos TILEGX_OPC_MULA_HU_LS, 209 1.1 christos TILEGX_OPC_MULA_HU_LU, 210 1.1 christos TILEGX_OPC_MULA_LS_LS, 211 1.1 christos TILEGX_OPC_MULA_LS_LU, 212 1.1 christos TILEGX_OPC_MULA_LU_LU, 213 1.1 christos TILEGX_OPC_MULAX, 214 1.1 christos TILEGX_OPC_MULX, 215 1.1 christos TILEGX_OPC_MZ, 216 1.1 christos TILEGX_OPC_NAP, 217 1.1 christos TILEGX_OPC_NOP, 218 1.1 christos TILEGX_OPC_NOR, 219 1.1 christos TILEGX_OPC_OR, 220 1.1 christos TILEGX_OPC_ORI, 221 1.1 christos TILEGX_OPC_PCNT, 222 1.1 christos TILEGX_OPC_REVBITS, 223 1.1 christos TILEGX_OPC_REVBYTES, 224 1.1 christos TILEGX_OPC_ROTL, 225 1.1 christos TILEGX_OPC_ROTLI, 226 1.1 christos TILEGX_OPC_SHL, 227 1.1 christos TILEGX_OPC_SHL16INSLI, 228 1.1 christos TILEGX_OPC_SHL1ADD, 229 1.1 christos TILEGX_OPC_SHL1ADDX, 230 1.1 christos TILEGX_OPC_SHL2ADD, 231 1.1 christos TILEGX_OPC_SHL2ADDX, 232 1.1 christos TILEGX_OPC_SHL3ADD, 233 1.1 christos TILEGX_OPC_SHL3ADDX, 234 1.1 christos TILEGX_OPC_SHLI, 235 1.1 christos TILEGX_OPC_SHLX, 236 1.1 christos TILEGX_OPC_SHLXI, 237 1.1 christos TILEGX_OPC_SHRS, 238 1.1 christos TILEGX_OPC_SHRSI, 239 1.1 christos TILEGX_OPC_SHRU, 240 1.1 christos TILEGX_OPC_SHRUI, 241 1.1 christos TILEGX_OPC_SHRUX, 242 1.1 christos TILEGX_OPC_SHRUXI, 243 1.1 christos TILEGX_OPC_SHUFFLEBYTES, 244 1.1 christos TILEGX_OPC_ST, 245 1.1 christos TILEGX_OPC_ST1, 246 1.1 christos TILEGX_OPC_ST1_ADD, 247 1.1 christos TILEGX_OPC_ST2, 248 1.1 christos TILEGX_OPC_ST2_ADD, 249 1.1 christos TILEGX_OPC_ST4, 250 1.1 christos TILEGX_OPC_ST4_ADD, 251 1.1 christos TILEGX_OPC_ST_ADD, 252 1.1 christos TILEGX_OPC_STNT, 253 1.1 christos TILEGX_OPC_STNT1, 254 1.1 christos TILEGX_OPC_STNT1_ADD, 255 1.1 christos TILEGX_OPC_STNT2, 256 1.1 christos TILEGX_OPC_STNT2_ADD, 257 1.1 christos TILEGX_OPC_STNT4, 258 1.1 christos TILEGX_OPC_STNT4_ADD, 259 1.1 christos TILEGX_OPC_STNT_ADD, 260 1.1 christos TILEGX_OPC_SUB, 261 1.1 christos TILEGX_OPC_SUBX, 262 1.1 christos TILEGX_OPC_SUBXSC, 263 1.1 christos TILEGX_OPC_SWINT0, 264 1.1 christos TILEGX_OPC_SWINT1, 265 1.1 christos TILEGX_OPC_SWINT2, 266 1.1 christos TILEGX_OPC_SWINT3, 267 1.1 christos TILEGX_OPC_TBLIDXB0, 268 1.1 christos TILEGX_OPC_TBLIDXB1, 269 1.1 christos TILEGX_OPC_TBLIDXB2, 270 1.1 christos TILEGX_OPC_TBLIDXB3, 271 1.1 christos TILEGX_OPC_V1ADD, 272 1.1 christos TILEGX_OPC_V1ADDI, 273 1.1 christos TILEGX_OPC_V1ADDUC, 274 1.1 christos TILEGX_OPC_V1ADIFFU, 275 1.1 christos TILEGX_OPC_V1AVGU, 276 1.1 christos TILEGX_OPC_V1CMPEQ, 277 1.1 christos TILEGX_OPC_V1CMPEQI, 278 1.1 christos TILEGX_OPC_V1CMPLES, 279 1.1 christos TILEGX_OPC_V1CMPLEU, 280 1.1 christos TILEGX_OPC_V1CMPLTS, 281 1.1 christos TILEGX_OPC_V1CMPLTSI, 282 1.1 christos TILEGX_OPC_V1CMPLTU, 283 1.1 christos TILEGX_OPC_V1CMPLTUI, 284 1.1 christos TILEGX_OPC_V1CMPNE, 285 1.1 christos TILEGX_OPC_V1DDOTPU, 286 1.1 christos TILEGX_OPC_V1DDOTPUA, 287 1.1 christos TILEGX_OPC_V1DDOTPUS, 288 1.1 christos TILEGX_OPC_V1DDOTPUSA, 289 1.1 christos TILEGX_OPC_V1DOTP, 290 1.1 christos TILEGX_OPC_V1DOTPA, 291 1.1 christos TILEGX_OPC_V1DOTPU, 292 1.1 christos TILEGX_OPC_V1DOTPUA, 293 1.1 christos TILEGX_OPC_V1DOTPUS, 294 1.1 christos TILEGX_OPC_V1DOTPUSA, 295 1.1 christos TILEGX_OPC_V1INT_H, 296 1.1 christos TILEGX_OPC_V1INT_L, 297 1.1 christos TILEGX_OPC_V1MAXU, 298 1.1 christos TILEGX_OPC_V1MAXUI, 299 1.1 christos TILEGX_OPC_V1MINU, 300 1.1 christos TILEGX_OPC_V1MINUI, 301 1.1 christos TILEGX_OPC_V1MNZ, 302 1.1 christos TILEGX_OPC_V1MULTU, 303 1.1 christos TILEGX_OPC_V1MULU, 304 1.1 christos TILEGX_OPC_V1MULUS, 305 1.1 christos TILEGX_OPC_V1MZ, 306 1.1 christos TILEGX_OPC_V1SADAU, 307 1.1 christos TILEGX_OPC_V1SADU, 308 1.1 christos TILEGX_OPC_V1SHL, 309 1.1 christos TILEGX_OPC_V1SHLI, 310 1.1 christos TILEGX_OPC_V1SHRS, 311 1.1 christos TILEGX_OPC_V1SHRSI, 312 1.1 christos TILEGX_OPC_V1SHRU, 313 1.1 christos TILEGX_OPC_V1SHRUI, 314 1.1 christos TILEGX_OPC_V1SUB, 315 1.1 christos TILEGX_OPC_V1SUBUC, 316 1.1 christos TILEGX_OPC_V2ADD, 317 1.1 christos TILEGX_OPC_V2ADDI, 318 1.1 christos TILEGX_OPC_V2ADDSC, 319 1.1 christos TILEGX_OPC_V2ADIFFS, 320 1.1 christos TILEGX_OPC_V2AVGS, 321 1.1 christos TILEGX_OPC_V2CMPEQ, 322 1.1 christos TILEGX_OPC_V2CMPEQI, 323 1.1 christos TILEGX_OPC_V2CMPLES, 324 1.1 christos TILEGX_OPC_V2CMPLEU, 325 1.1 christos TILEGX_OPC_V2CMPLTS, 326 1.1 christos TILEGX_OPC_V2CMPLTSI, 327 1.1 christos TILEGX_OPC_V2CMPLTU, 328 1.1 christos TILEGX_OPC_V2CMPLTUI, 329 1.1 christos TILEGX_OPC_V2CMPNE, 330 1.1 christos TILEGX_OPC_V2DOTP, 331 1.1 christos TILEGX_OPC_V2DOTPA, 332 1.1 christos TILEGX_OPC_V2INT_H, 333 1.1 christos TILEGX_OPC_V2INT_L, 334 1.1 christos TILEGX_OPC_V2MAXS, 335 1.1 christos TILEGX_OPC_V2MAXSI, 336 1.1 christos TILEGX_OPC_V2MINS, 337 1.1 christos TILEGX_OPC_V2MINSI, 338 1.1 christos TILEGX_OPC_V2MNZ, 339 1.1 christos TILEGX_OPC_V2MULFSC, 340 1.1 christos TILEGX_OPC_V2MULS, 341 1.1 christos TILEGX_OPC_V2MULTS, 342 1.1 christos TILEGX_OPC_V2MZ, 343 1.1 christos TILEGX_OPC_V2PACKH, 344 1.1 christos TILEGX_OPC_V2PACKL, 345 1.1 christos TILEGX_OPC_V2PACKUC, 346 1.1 christos TILEGX_OPC_V2SADAS, 347 1.1 christos TILEGX_OPC_V2SADAU, 348 1.1 christos TILEGX_OPC_V2SADS, 349 1.1 christos TILEGX_OPC_V2SADU, 350 1.1 christos TILEGX_OPC_V2SHL, 351 1.1 christos TILEGX_OPC_V2SHLI, 352 1.1 christos TILEGX_OPC_V2SHLSC, 353 1.1 christos TILEGX_OPC_V2SHRS, 354 1.1 christos TILEGX_OPC_V2SHRSI, 355 1.1 christos TILEGX_OPC_V2SHRU, 356 1.1 christos TILEGX_OPC_V2SHRUI, 357 1.1 christos TILEGX_OPC_V2SUB, 358 1.1 christos TILEGX_OPC_V2SUBSC, 359 1.1 christos TILEGX_OPC_V4ADD, 360 1.1 christos TILEGX_OPC_V4ADDSC, 361 1.1 christos TILEGX_OPC_V4INT_H, 362 1.1 christos TILEGX_OPC_V4INT_L, 363 1.1 christos TILEGX_OPC_V4PACKSC, 364 1.1 christos TILEGX_OPC_V4SHL, 365 1.1 christos TILEGX_OPC_V4SHLSC, 366 1.1 christos TILEGX_OPC_V4SHRS, 367 1.1 christos TILEGX_OPC_V4SHRU, 368 1.1 christos TILEGX_OPC_V4SUB, 369 1.1 christos TILEGX_OPC_V4SUBSC, 370 1.1 christos TILEGX_OPC_WH64, 371 1.1 christos TILEGX_OPC_XOR, 372 1.1 christos TILEGX_OPC_XORI, 373 1.1 christos TILEGX_OPC_NONE 374 1.1 christos } tilegx_mnemonic; 375 1.1 christos 376 1.1 christos /* 64-bit pattern for a { bpt ; nop } bundle. */ 377 1.1 christos #define TILEGX_BPT_BUNDLE 0x286a44ae51485000ULL 378 1.1 christos 379 1.1 christos 380 1.1 christos 381 1.1 christos static __inline unsigned int 382 1.1 christos get_BFEnd_X0(tilegx_bundle_bits num) 383 1.1 christos { 384 1.1 christos const unsigned int n = (unsigned int)num; 385 1.1 christos return (((n >> 12)) & 0x3f); 386 1.1 christos } 387 1.1 christos 388 1.1 christos static __inline unsigned int 389 1.1 christos get_BFOpcodeExtension_X0(tilegx_bundle_bits num) 390 1.1 christos { 391 1.1 christos const unsigned int n = (unsigned int)num; 392 1.1 christos return (((n >> 24)) & 0xf); 393 1.1 christos } 394 1.1 christos 395 1.1 christos static __inline unsigned int 396 1.1 christos get_BFStart_X0(tilegx_bundle_bits num) 397 1.1 christos { 398 1.1 christos const unsigned int n = (unsigned int)num; 399 1.1 christos return (((n >> 18)) & 0x3f); 400 1.1 christos } 401 1.1 christos 402 1.1 christos static __inline unsigned int 403 1.1 christos get_BrOff_X1(tilegx_bundle_bits n) 404 1.1 christos { 405 1.1 christos return (((unsigned int)(n >> 31)) & 0x0000003f) | 406 1.1 christos (((unsigned int)(n >> 37)) & 0x0001ffc0); 407 1.1 christos } 408 1.1 christos 409 1.1 christos static __inline unsigned int 410 1.1 christos get_BrType_X1(tilegx_bundle_bits n) 411 1.1 christos { 412 1.1 christos return (((unsigned int)(n >> 54)) & 0x1f); 413 1.1 christos } 414 1.1 christos 415 1.1 christos static __inline unsigned int 416 1.1 christos get_Dest_Imm8_X1(tilegx_bundle_bits n) 417 1.1 christos { 418 1.1 christos return (((unsigned int)(n >> 31)) & 0x0000003f) | 419 1.1 christos (((unsigned int)(n >> 43)) & 0x000000c0); 420 1.1 christos } 421 1.1 christos 422 1.1 christos static __inline unsigned int 423 1.1 christos get_Dest_X0(tilegx_bundle_bits num) 424 1.1 christos { 425 1.1 christos const unsigned int n = (unsigned int)num; 426 1.1 christos return (((n >> 0)) & 0x3f); 427 1.1 christos } 428 1.1 christos 429 1.1 christos static __inline unsigned int 430 1.1 christos get_Dest_X1(tilegx_bundle_bits n) 431 1.1 christos { 432 1.1 christos return (((unsigned int)(n >> 31)) & 0x3f); 433 1.1 christos } 434 1.1 christos 435 1.1 christos static __inline unsigned int 436 1.1 christos get_Dest_Y0(tilegx_bundle_bits num) 437 1.1 christos { 438 1.1 christos const unsigned int n = (unsigned int)num; 439 1.1 christos return (((n >> 0)) & 0x3f); 440 1.1 christos } 441 1.1 christos 442 1.1 christos static __inline unsigned int 443 1.1 christos get_Dest_Y1(tilegx_bundle_bits n) 444 1.1 christos { 445 1.1 christos return (((unsigned int)(n >> 31)) & 0x3f); 446 1.1 christos } 447 1.1 christos 448 1.1 christos static __inline unsigned int 449 1.1 christos get_Imm16_X0(tilegx_bundle_bits num) 450 1.1 christos { 451 1.1 christos const unsigned int n = (unsigned int)num; 452 1.1 christos return (((n >> 12)) & 0xffff); 453 1.1 christos } 454 1.1 christos 455 1.1 christos static __inline unsigned int 456 1.1 christos get_Imm16_X1(tilegx_bundle_bits n) 457 1.1 christos { 458 1.1 christos return (((unsigned int)(n >> 43)) & 0xffff); 459 1.1 christos } 460 1.1 christos 461 1.1 christos static __inline unsigned int 462 1.1 christos get_Imm8OpcodeExtension_X0(tilegx_bundle_bits num) 463 1.1 christos { 464 1.1 christos const unsigned int n = (unsigned int)num; 465 1.1 christos return (((n >> 20)) & 0xff); 466 1.1 christos } 467 1.1 christos 468 1.1 christos static __inline unsigned int 469 1.1 christos get_Imm8OpcodeExtension_X1(tilegx_bundle_bits n) 470 1.1 christos { 471 1.1 christos return (((unsigned int)(n >> 51)) & 0xff); 472 1.1 christos } 473 1.1 christos 474 1.1 christos static __inline unsigned int 475 1.1 christos get_Imm8_X0(tilegx_bundle_bits num) 476 1.1 christos { 477 1.1 christos const unsigned int n = (unsigned int)num; 478 1.1 christos return (((n >> 12)) & 0xff); 479 1.1 christos } 480 1.1 christos 481 1.1 christos static __inline unsigned int 482 1.1 christos get_Imm8_X1(tilegx_bundle_bits n) 483 1.1 christos { 484 1.1 christos return (((unsigned int)(n >> 43)) & 0xff); 485 1.1 christos } 486 1.1 christos 487 1.1 christos static __inline unsigned int 488 1.1 christos get_Imm8_Y0(tilegx_bundle_bits num) 489 1.1 christos { 490 1.1 christos const unsigned int n = (unsigned int)num; 491 1.1 christos return (((n >> 12)) & 0xff); 492 1.1 christos } 493 1.1 christos 494 1.1 christos static __inline unsigned int 495 1.1 christos get_Imm8_Y1(tilegx_bundle_bits n) 496 1.1 christos { 497 1.1 christos return (((unsigned int)(n >> 43)) & 0xff); 498 1.1 christos } 499 1.1 christos 500 1.1 christos static __inline unsigned int 501 1.1 christos get_JumpOff_X1(tilegx_bundle_bits n) 502 1.1 christos { 503 1.1 christos return (((unsigned int)(n >> 31)) & 0x7ffffff); 504 1.1 christos } 505 1.1 christos 506 1.1 christos static __inline unsigned int 507 1.1 christos get_JumpOpcodeExtension_X1(tilegx_bundle_bits n) 508 1.1 christos { 509 1.1 christos return (((unsigned int)(n >> 58)) & 0x1); 510 1.1 christos } 511 1.1 christos 512 1.1 christos static __inline unsigned int 513 1.1 christos get_MF_Imm14_X1(tilegx_bundle_bits n) 514 1.1 christos { 515 1.1 christos return (((unsigned int)(n >> 37)) & 0x3fff); 516 1.1 christos } 517 1.1 christos 518 1.1 christos static __inline unsigned int 519 1.1 christos get_MT_Imm14_X1(tilegx_bundle_bits n) 520 1.1 christos { 521 1.1 christos return (((unsigned int)(n >> 31)) & 0x0000003f) | 522 1.1 christos (((unsigned int)(n >> 37)) & 0x00003fc0); 523 1.1 christos } 524 1.1 christos 525 1.1 christos static __inline unsigned int 526 1.1 christos get_Mode(tilegx_bundle_bits n) 527 1.1 christos { 528 1.1 christos return (((unsigned int)(n >> 62)) & 0x3); 529 1.1 christos } 530 1.1 christos 531 1.1 christos static __inline unsigned int 532 1.1 christos get_Opcode_X0(tilegx_bundle_bits num) 533 1.1 christos { 534 1.1 christos const unsigned int n = (unsigned int)num; 535 1.1 christos return (((n >> 28)) & 0x7); 536 1.1 christos } 537 1.1 christos 538 1.1 christos static __inline unsigned int 539 1.1 christos get_Opcode_X1(tilegx_bundle_bits n) 540 1.1 christos { 541 1.1 christos return (((unsigned int)(n >> 59)) & 0x7); 542 1.1 christos } 543 1.1 christos 544 1.1 christos static __inline unsigned int 545 1.1 christos get_Opcode_Y0(tilegx_bundle_bits num) 546 1.1 christos { 547 1.1 christos const unsigned int n = (unsigned int)num; 548 1.1 christos return (((n >> 27)) & 0xf); 549 1.1 christos } 550 1.1 christos 551 1.1 christos static __inline unsigned int 552 1.1 christos get_Opcode_Y1(tilegx_bundle_bits n) 553 1.1 christos { 554 1.1 christos return (((unsigned int)(n >> 58)) & 0xf); 555 1.1 christos } 556 1.1 christos 557 1.1 christos static __inline unsigned int 558 1.1 christos get_Opcode_Y2(tilegx_bundle_bits n) 559 1.1 christos { 560 1.1 christos return (((n >> 26)) & 0x00000001) | 561 1.1 christos (((unsigned int)(n >> 56)) & 0x00000002); 562 1.1 christos } 563 1.1 christos 564 1.1 christos static __inline unsigned int 565 1.1 christos get_RRROpcodeExtension_X0(tilegx_bundle_bits num) 566 1.1 christos { 567 1.1 christos const unsigned int n = (unsigned int)num; 568 1.1 christos return (((n >> 18)) & 0x3ff); 569 1.1 christos } 570 1.1 christos 571 1.1 christos static __inline unsigned int 572 1.1 christos get_RRROpcodeExtension_X1(tilegx_bundle_bits n) 573 1.1 christos { 574 1.1 christos return (((unsigned int)(n >> 49)) & 0x3ff); 575 1.1 christos } 576 1.1 christos 577 1.1 christos static __inline unsigned int 578 1.1 christos get_RRROpcodeExtension_Y0(tilegx_bundle_bits num) 579 1.1 christos { 580 1.1 christos const unsigned int n = (unsigned int)num; 581 1.1 christos return (((n >> 18)) & 0x3); 582 1.1 christos } 583 1.1 christos 584 1.1 christos static __inline unsigned int 585 1.1 christos get_RRROpcodeExtension_Y1(tilegx_bundle_bits n) 586 1.1 christos { 587 1.1 christos return (((unsigned int)(n >> 49)) & 0x3); 588 1.1 christos } 589 1.1 christos 590 1.1 christos static __inline unsigned int 591 1.1 christos get_ShAmt_X0(tilegx_bundle_bits num) 592 1.1 christos { 593 1.1 christos const unsigned int n = (unsigned int)num; 594 1.1 christos return (((n >> 12)) & 0x3f); 595 1.1 christos } 596 1.1 christos 597 1.1 christos static __inline unsigned int 598 1.1 christos get_ShAmt_X1(tilegx_bundle_bits n) 599 1.1 christos { 600 1.1 christos return (((unsigned int)(n >> 43)) & 0x3f); 601 1.1 christos } 602 1.1 christos 603 1.1 christos static __inline unsigned int 604 1.1 christos get_ShAmt_Y0(tilegx_bundle_bits num) 605 1.1 christos { 606 1.1 christos const unsigned int n = (unsigned int)num; 607 1.1 christos return (((n >> 12)) & 0x3f); 608 1.1 christos } 609 1.1 christos 610 1.1 christos static __inline unsigned int 611 1.1 christos get_ShAmt_Y1(tilegx_bundle_bits n) 612 1.1 christos { 613 1.1 christos return (((unsigned int)(n >> 43)) & 0x3f); 614 1.1 christos } 615 1.1 christos 616 1.1 christos static __inline unsigned int 617 1.1 christos get_ShiftOpcodeExtension_X0(tilegx_bundle_bits num) 618 1.1 christos { 619 1.1 christos const unsigned int n = (unsigned int)num; 620 1.1 christos return (((n >> 18)) & 0x3ff); 621 1.1 christos } 622 1.1 christos 623 1.1 christos static __inline unsigned int 624 1.1 christos get_ShiftOpcodeExtension_X1(tilegx_bundle_bits n) 625 1.1 christos { 626 1.1 christos return (((unsigned int)(n >> 49)) & 0x3ff); 627 1.1 christos } 628 1.1 christos 629 1.1 christos static __inline unsigned int 630 1.1 christos get_ShiftOpcodeExtension_Y0(tilegx_bundle_bits num) 631 1.1 christos { 632 1.1 christos const unsigned int n = (unsigned int)num; 633 1.1 christos return (((n >> 18)) & 0x3); 634 1.1 christos } 635 1.1 christos 636 1.1 christos static __inline unsigned int 637 1.1 christos get_ShiftOpcodeExtension_Y1(tilegx_bundle_bits n) 638 1.1 christos { 639 1.1 christos return (((unsigned int)(n >> 49)) & 0x3); 640 1.1 christos } 641 1.1 christos 642 1.1 christos static __inline unsigned int 643 1.1 christos get_SrcA_X0(tilegx_bundle_bits num) 644 1.1 christos { 645 1.1 christos const unsigned int n = (unsigned int)num; 646 1.1 christos return (((n >> 6)) & 0x3f); 647 1.1 christos } 648 1.1 christos 649 1.1 christos static __inline unsigned int 650 1.1 christos get_SrcA_X1(tilegx_bundle_bits n) 651 1.1 christos { 652 1.1 christos return (((unsigned int)(n >> 37)) & 0x3f); 653 1.1 christos } 654 1.1 christos 655 1.1 christos static __inline unsigned int 656 1.1 christos get_SrcA_Y0(tilegx_bundle_bits num) 657 1.1 christos { 658 1.1 christos const unsigned int n = (unsigned int)num; 659 1.1 christos return (((n >> 6)) & 0x3f); 660 1.1 christos } 661 1.1 christos 662 1.1 christos static __inline unsigned int 663 1.1 christos get_SrcA_Y1(tilegx_bundle_bits n) 664 1.1 christos { 665 1.1 christos return (((unsigned int)(n >> 37)) & 0x3f); 666 1.1 christos } 667 1.1 christos 668 1.1 christos static __inline unsigned int 669 1.1 christos get_SrcA_Y2(tilegx_bundle_bits num) 670 1.1 christos { 671 1.1 christos const unsigned int n = (unsigned int)num; 672 1.1 christos return (((n >> 20)) & 0x3f); 673 1.1 christos } 674 1.1 christos 675 1.1 christos static __inline unsigned int 676 1.1 christos get_SrcBDest_Y2(tilegx_bundle_bits n) 677 1.1 christos { 678 1.1 christos return (((unsigned int)(n >> 51)) & 0x3f); 679 1.1 christos } 680 1.1 christos 681 1.1 christos static __inline unsigned int 682 1.1 christos get_SrcB_X0(tilegx_bundle_bits num) 683 1.1 christos { 684 1.1 christos const unsigned int n = (unsigned int)num; 685 1.1 christos return (((n >> 12)) & 0x3f); 686 1.1 christos } 687 1.1 christos 688 1.1 christos static __inline unsigned int 689 1.1 christos get_SrcB_X1(tilegx_bundle_bits n) 690 1.1 christos { 691 1.1 christos return (((unsigned int)(n >> 43)) & 0x3f); 692 1.1 christos } 693 1.1 christos 694 1.1 christos static __inline unsigned int 695 1.1 christos get_SrcB_Y0(tilegx_bundle_bits num) 696 1.1 christos { 697 1.1 christos const unsigned int n = (unsigned int)num; 698 1.1 christos return (((n >> 12)) & 0x3f); 699 1.1 christos } 700 1.1 christos 701 1.1 christos static __inline unsigned int 702 1.1 christos get_SrcB_Y1(tilegx_bundle_bits n) 703 1.1 christos { 704 1.1 christos return (((unsigned int)(n >> 43)) & 0x3f); 705 1.1 christos } 706 1.1 christos 707 1.1 christos static __inline unsigned int 708 1.1 christos get_UnaryOpcodeExtension_X0(tilegx_bundle_bits num) 709 1.1 christos { 710 1.1 christos const unsigned int n = (unsigned int)num; 711 1.1 christos return (((n >> 12)) & 0x3f); 712 1.1 christos } 713 1.1 christos 714 1.1 christos static __inline unsigned int 715 1.1 christos get_UnaryOpcodeExtension_X1(tilegx_bundle_bits n) 716 1.1 christos { 717 1.1 christos return (((unsigned int)(n >> 43)) & 0x3f); 718 1.1 christos } 719 1.1 christos 720 1.1 christos static __inline unsigned int 721 1.1 christos get_UnaryOpcodeExtension_Y0(tilegx_bundle_bits num) 722 1.1 christos { 723 1.1 christos const unsigned int n = (unsigned int)num; 724 1.1 christos return (((n >> 12)) & 0x3f); 725 1.1 christos } 726 1.1 christos 727 1.1 christos static __inline unsigned int 728 1.1 christos get_UnaryOpcodeExtension_Y1(tilegx_bundle_bits n) 729 1.1 christos { 730 1.1 christos return (((unsigned int)(n >> 43)) & 0x3f); 731 1.1 christos } 732 1.1 christos 733 1.1 christos 734 1.1 christos static __inline int 735 1.1 christos sign_extend(int n, int num_bits) 736 1.1 christos { 737 1.1 christos int shift = (int)(sizeof(int) * 8 - num_bits); 738 1.1 christos return (n << shift) >> shift; 739 1.1 christos } 740 1.1 christos 741 1.1 christos 742 1.1 christos 743 1.1 christos static __inline tilegx_bundle_bits 744 1.1 christos create_BFEnd_X0(int num) 745 1.1 christos { 746 1.1 christos const unsigned int n = (unsigned int)num; 747 1.1 christos return ((n & 0x3f) << 12); 748 1.1 christos } 749 1.1 christos 750 1.1 christos static __inline tilegx_bundle_bits 751 1.1 christos create_BFOpcodeExtension_X0(int num) 752 1.1 christos { 753 1.1 christos const unsigned int n = (unsigned int)num; 754 1.1 christos return ((n & 0xf) << 24); 755 1.1 christos } 756 1.1 christos 757 1.1 christos static __inline tilegx_bundle_bits 758 1.1 christos create_BFStart_X0(int num) 759 1.1 christos { 760 1.1 christos const unsigned int n = (unsigned int)num; 761 1.1 christos return ((n & 0x3f) << 18); 762 1.1 christos } 763 1.1 christos 764 1.1 christos static __inline tilegx_bundle_bits 765 1.1 christos create_BrOff_X1(int num) 766 1.1 christos { 767 1.1 christos const unsigned int n = (unsigned int)num; 768 1.1 christos return (((tilegx_bundle_bits)(n & 0x0000003f)) << 31) | 769 1.1 christos (((tilegx_bundle_bits)(n & 0x0001ffc0)) << 37); 770 1.1 christos } 771 1.1 christos 772 1.1 christos static __inline tilegx_bundle_bits 773 1.1 christos create_BrType_X1(int num) 774 1.1 christos { 775 1.1 christos const unsigned int n = (unsigned int)num; 776 1.1 christos return (((tilegx_bundle_bits)(n & 0x1f)) << 54); 777 1.1 christos } 778 1.1 christos 779 1.1 christos static __inline tilegx_bundle_bits 780 1.1 christos create_Dest_Imm8_X1(int num) 781 1.1 christos { 782 1.1 christos const unsigned int n = (unsigned int)num; 783 1.1 christos return (((tilegx_bundle_bits)(n & 0x0000003f)) << 31) | 784 1.1 christos (((tilegx_bundle_bits)(n & 0x000000c0)) << 43); 785 1.1 christos } 786 1.1 christos 787 1.1 christos static __inline tilegx_bundle_bits 788 1.1 christos create_Dest_X0(int num) 789 1.1 christos { 790 1.1 christos const unsigned int n = (unsigned int)num; 791 1.1 christos return ((n & 0x3f) << 0); 792 1.1 christos } 793 1.1 christos 794 1.1 christos static __inline tilegx_bundle_bits 795 1.1 christos create_Dest_X1(int num) 796 1.1 christos { 797 1.1 christos const unsigned int n = (unsigned int)num; 798 1.1 christos return (((tilegx_bundle_bits)(n & 0x3f)) << 31); 799 1.1 christos } 800 1.1 christos 801 1.1 christos static __inline tilegx_bundle_bits 802 1.1 christos create_Dest_Y0(int num) 803 1.1 christos { 804 1.1 christos const unsigned int n = (unsigned int)num; 805 1.1 christos return ((n & 0x3f) << 0); 806 1.1 christos } 807 1.1 christos 808 1.1 christos static __inline tilegx_bundle_bits 809 1.1 christos create_Dest_Y1(int num) 810 1.1 christos { 811 1.1 christos const unsigned int n = (unsigned int)num; 812 1.1 christos return (((tilegx_bundle_bits)(n & 0x3f)) << 31); 813 1.1 christos } 814 1.1 christos 815 1.1 christos static __inline tilegx_bundle_bits 816 1.1 christos create_Imm16_X0(int num) 817 1.1 christos { 818 1.1 christos const unsigned int n = (unsigned int)num; 819 1.1 christos return ((n & 0xffff) << 12); 820 1.1 christos } 821 1.1 christos 822 1.1 christos static __inline tilegx_bundle_bits 823 1.1 christos create_Imm16_X1(int num) 824 1.1 christos { 825 1.1 christos const unsigned int n = (unsigned int)num; 826 1.1 christos return (((tilegx_bundle_bits)(n & 0xffff)) << 43); 827 1.1 christos } 828 1.1 christos 829 1.1 christos static __inline tilegx_bundle_bits 830 1.1 christos create_Imm8OpcodeExtension_X0(int num) 831 1.1 christos { 832 1.1 christos const unsigned int n = (unsigned int)num; 833 1.1 christos return ((n & 0xff) << 20); 834 1.1 christos } 835 1.1 christos 836 1.1 christos static __inline tilegx_bundle_bits 837 1.1 christos create_Imm8OpcodeExtension_X1(int num) 838 1.1 christos { 839 1.1 christos const unsigned int n = (unsigned int)num; 840 1.1 christos return (((tilegx_bundle_bits)(n & 0xff)) << 51); 841 1.1 christos } 842 1.1 christos 843 1.1 christos static __inline tilegx_bundle_bits 844 1.1 christos create_Imm8_X0(int num) 845 1.1 christos { 846 1.1 christos const unsigned int n = (unsigned int)num; 847 1.1 christos return ((n & 0xff) << 12); 848 1.1 christos } 849 1.1 christos 850 1.1 christos static __inline tilegx_bundle_bits 851 1.1 christos create_Imm8_X1(int num) 852 1.1 christos { 853 1.1 christos const unsigned int n = (unsigned int)num; 854 1.1 christos return (((tilegx_bundle_bits)(n & 0xff)) << 43); 855 1.1 christos } 856 1.1 christos 857 1.1 christos static __inline tilegx_bundle_bits 858 1.1 christos create_Imm8_Y0(int num) 859 1.1 christos { 860 1.1 christos const unsigned int n = (unsigned int)num; 861 1.1 christos return ((n & 0xff) << 12); 862 1.1 christos } 863 1.1 christos 864 1.1 christos static __inline tilegx_bundle_bits 865 1.1 christos create_Imm8_Y1(int num) 866 1.1 christos { 867 1.1 christos const unsigned int n = (unsigned int)num; 868 1.1 christos return (((tilegx_bundle_bits)(n & 0xff)) << 43); 869 1.1 christos } 870 1.1 christos 871 1.1 christos static __inline tilegx_bundle_bits 872 1.1 christos create_JumpOff_X1(int num) 873 1.1 christos { 874 1.1 christos const unsigned int n = (unsigned int)num; 875 1.1 christos return (((tilegx_bundle_bits)(n & 0x7ffffff)) << 31); 876 1.1 christos } 877 1.1 christos 878 1.1 christos static __inline tilegx_bundle_bits 879 1.1 christos create_JumpOpcodeExtension_X1(int num) 880 1.1 christos { 881 1.1 christos const unsigned int n = (unsigned int)num; 882 1.1 christos return (((tilegx_bundle_bits)(n & 0x1)) << 58); 883 1.1 christos } 884 1.1 christos 885 1.1 christos static __inline tilegx_bundle_bits 886 1.1 christos create_MF_Imm14_X1(int num) 887 1.1 christos { 888 1.1 christos const unsigned int n = (unsigned int)num; 889 1.1 christos return (((tilegx_bundle_bits)(n & 0x3fff)) << 37); 890 1.1 christos } 891 1.1 christos 892 1.1 christos static __inline tilegx_bundle_bits 893 1.1 christos create_MT_Imm14_X1(int num) 894 1.1 christos { 895 1.1 christos const unsigned int n = (unsigned int)num; 896 1.1 christos return (((tilegx_bundle_bits)(n & 0x0000003f)) << 31) | 897 1.1 christos (((tilegx_bundle_bits)(n & 0x00003fc0)) << 37); 898 1.1 christos } 899 1.1 christos 900 1.1 christos static __inline tilegx_bundle_bits 901 1.1 christos create_Mode(int num) 902 1.1 christos { 903 1.1 christos const unsigned int n = (unsigned int)num; 904 1.1 christos return (((tilegx_bundle_bits)(n & 0x3)) << 62); 905 1.1 christos } 906 1.1 christos 907 1.1 christos static __inline tilegx_bundle_bits 908 1.1 christos create_Opcode_X0(int num) 909 1.1 christos { 910 1.1 christos const unsigned int n = (unsigned int)num; 911 1.1 christos return ((n & 0x7) << 28); 912 1.1 christos } 913 1.1 christos 914 1.1 christos static __inline tilegx_bundle_bits 915 1.1 christos create_Opcode_X1(int num) 916 1.1 christos { 917 1.1 christos const unsigned int n = (unsigned int)num; 918 1.1 christos return (((tilegx_bundle_bits)(n & 0x7)) << 59); 919 1.1 christos } 920 1.1 christos 921 1.1 christos static __inline tilegx_bundle_bits 922 1.1 christos create_Opcode_Y0(int num) 923 1.1 christos { 924 1.1 christos const unsigned int n = (unsigned int)num; 925 1.1 christos return ((n & 0xf) << 27); 926 1.1 christos } 927 1.1 christos 928 1.1 christos static __inline tilegx_bundle_bits 929 1.1 christos create_Opcode_Y1(int num) 930 1.1 christos { 931 1.1 christos const unsigned int n = (unsigned int)num; 932 1.1 christos return (((tilegx_bundle_bits)(n & 0xf)) << 58); 933 1.1 christos } 934 1.1 christos 935 1.1 christos static __inline tilegx_bundle_bits 936 1.1 christos create_Opcode_Y2(int num) 937 1.1 christos { 938 1.1 christos const unsigned int n = (unsigned int)num; 939 1.1 christos return ((n & 0x00000001) << 26) | 940 1.1 christos (((tilegx_bundle_bits)(n & 0x00000002)) << 56); 941 1.1 christos } 942 1.1 christos 943 1.1 christos static __inline tilegx_bundle_bits 944 1.1 christos create_RRROpcodeExtension_X0(int num) 945 1.1 christos { 946 1.1 christos const unsigned int n = (unsigned int)num; 947 1.1 christos return ((n & 0x3ff) << 18); 948 1.1 christos } 949 1.1 christos 950 1.1 christos static __inline tilegx_bundle_bits 951 1.1 christos create_RRROpcodeExtension_X1(int num) 952 1.1 christos { 953 1.1 christos const unsigned int n = (unsigned int)num; 954 1.1 christos return (((tilegx_bundle_bits)(n & 0x3ff)) << 49); 955 1.1 christos } 956 1.1 christos 957 1.1 christos static __inline tilegx_bundle_bits 958 1.1 christos create_RRROpcodeExtension_Y0(int num) 959 1.1 christos { 960 1.1 christos const unsigned int n = (unsigned int)num; 961 1.1 christos return ((n & 0x3) << 18); 962 1.1 christos } 963 1.1 christos 964 1.1 christos static __inline tilegx_bundle_bits 965 1.1 christos create_RRROpcodeExtension_Y1(int num) 966 1.1 christos { 967 1.1 christos const unsigned int n = (unsigned int)num; 968 1.1 christos return (((tilegx_bundle_bits)(n & 0x3)) << 49); 969 1.1 christos } 970 1.1 christos 971 1.1 christos static __inline tilegx_bundle_bits 972 1.1 christos create_ShAmt_X0(int num) 973 1.1 christos { 974 1.1 christos const unsigned int n = (unsigned int)num; 975 1.1 christos return ((n & 0x3f) << 12); 976 1.1 christos } 977 1.1 christos 978 1.1 christos static __inline tilegx_bundle_bits 979 1.1 christos create_ShAmt_X1(int num) 980 1.1 christos { 981 1.1 christos const unsigned int n = (unsigned int)num; 982 1.1 christos return (((tilegx_bundle_bits)(n & 0x3f)) << 43); 983 1.1 christos } 984 1.1 christos 985 1.1 christos static __inline tilegx_bundle_bits 986 1.1 christos create_ShAmt_Y0(int num) 987 1.1 christos { 988 1.1 christos const unsigned int n = (unsigned int)num; 989 1.1 christos return ((n & 0x3f) << 12); 990 1.1 christos } 991 1.1 christos 992 1.1 christos static __inline tilegx_bundle_bits 993 1.1 christos create_ShAmt_Y1(int num) 994 1.1 christos { 995 1.1 christos const unsigned int n = (unsigned int)num; 996 1.1 christos return (((tilegx_bundle_bits)(n & 0x3f)) << 43); 997 1.1 christos } 998 1.1 christos 999 1.1 christos static __inline tilegx_bundle_bits 1000 1.1 christos create_ShiftOpcodeExtension_X0(int num) 1001 1.1 christos { 1002 1.1 christos const unsigned int n = (unsigned int)num; 1003 1.1 christos return ((n & 0x3ff) << 18); 1004 1.1 christos } 1005 1.1 christos 1006 1.1 christos static __inline tilegx_bundle_bits 1007 1.1 christos create_ShiftOpcodeExtension_X1(int num) 1008 1.1 christos { 1009 1.1 christos const unsigned int n = (unsigned int)num; 1010 1.1 christos return (((tilegx_bundle_bits)(n & 0x3ff)) << 49); 1011 1.1 christos } 1012 1.1 christos 1013 1.1 christos static __inline tilegx_bundle_bits 1014 1.1 christos create_ShiftOpcodeExtension_Y0(int num) 1015 1.1 christos { 1016 1.1 christos const unsigned int n = (unsigned int)num; 1017 1.1 christos return ((n & 0x3) << 18); 1018 1.1 christos } 1019 1.1 christos 1020 1.1 christos static __inline tilegx_bundle_bits 1021 1.1 christos create_ShiftOpcodeExtension_Y1(int num) 1022 1.1 christos { 1023 1.1 christos const unsigned int n = (unsigned int)num; 1024 1.1 christos return (((tilegx_bundle_bits)(n & 0x3)) << 49); 1025 1.1 christos } 1026 1.1 christos 1027 1.1 christos static __inline tilegx_bundle_bits 1028 1.1 christos create_SrcA_X0(int num) 1029 1.1 christos { 1030 1.1 christos const unsigned int n = (unsigned int)num; 1031 1.1 christos return ((n & 0x3f) << 6); 1032 1.1 christos } 1033 1.1 christos 1034 1.1 christos static __inline tilegx_bundle_bits 1035 1.1 christos create_SrcA_X1(int num) 1036 1.1 christos { 1037 1.1 christos const unsigned int n = (unsigned int)num; 1038 1.1 christos return (((tilegx_bundle_bits)(n & 0x3f)) << 37); 1039 1.1 christos } 1040 1.1 christos 1041 1.1 christos static __inline tilegx_bundle_bits 1042 1.1 christos create_SrcA_Y0(int num) 1043 1.1 christos { 1044 1.1 christos const unsigned int n = (unsigned int)num; 1045 1.1 christos return ((n & 0x3f) << 6); 1046 1.1 christos } 1047 1.1 christos 1048 1.1 christos static __inline tilegx_bundle_bits 1049 1.1 christos create_SrcA_Y1(int num) 1050 1.1 christos { 1051 1.1 christos const unsigned int n = (unsigned int)num; 1052 1.1 christos return (((tilegx_bundle_bits)(n & 0x3f)) << 37); 1053 1.1 christos } 1054 1.1 christos 1055 1.1 christos static __inline tilegx_bundle_bits 1056 1.1 christos create_SrcA_Y2(int num) 1057 1.1 christos { 1058 1.1 christos const unsigned int n = (unsigned int)num; 1059 1.1 christos return ((n & 0x3f) << 20); 1060 1.1 christos } 1061 1.1 christos 1062 1.1 christos static __inline tilegx_bundle_bits 1063 1.1 christos create_SrcBDest_Y2(int num) 1064 1.1 christos { 1065 1.1 christos const unsigned int n = (unsigned int)num; 1066 1.1 christos return (((tilegx_bundle_bits)(n & 0x3f)) << 51); 1067 1.1 christos } 1068 1.1 christos 1069 1.1 christos static __inline tilegx_bundle_bits 1070 1.1 christos create_SrcB_X0(int num) 1071 1.1 christos { 1072 1.1 christos const unsigned int n = (unsigned int)num; 1073 1.1 christos return ((n & 0x3f) << 12); 1074 1.1 christos } 1075 1.1 christos 1076 1.1 christos static __inline tilegx_bundle_bits 1077 1.1 christos create_SrcB_X1(int num) 1078 1.1 christos { 1079 1.1 christos const unsigned int n = (unsigned int)num; 1080 1.1 christos return (((tilegx_bundle_bits)(n & 0x3f)) << 43); 1081 1.1 christos } 1082 1.1 christos 1083 1.1 christos static __inline tilegx_bundle_bits 1084 1.1 christos create_SrcB_Y0(int num) 1085 1.1 christos { 1086 1.1 christos const unsigned int n = (unsigned int)num; 1087 1.1 christos return ((n & 0x3f) << 12); 1088 1.1 christos } 1089 1.1 christos 1090 1.1 christos static __inline tilegx_bundle_bits 1091 1.1 christos create_SrcB_Y1(int num) 1092 1.1 christos { 1093 1.1 christos const unsigned int n = (unsigned int)num; 1094 1.1 christos return (((tilegx_bundle_bits)(n & 0x3f)) << 43); 1095 1.1 christos } 1096 1.1 christos 1097 1.1 christos static __inline tilegx_bundle_bits 1098 1.1 christos create_UnaryOpcodeExtension_X0(int num) 1099 1.1 christos { 1100 1.1 christos const unsigned int n = (unsigned int)num; 1101 1.1 christos return ((n & 0x3f) << 12); 1102 1.1 christos } 1103 1.1 christos 1104 1.1 christos static __inline tilegx_bundle_bits 1105 1.1 christos create_UnaryOpcodeExtension_X1(int num) 1106 1.1 christos { 1107 1.1 christos const unsigned int n = (unsigned int)num; 1108 1.1 christos return (((tilegx_bundle_bits)(n & 0x3f)) << 43); 1109 1.1 christos } 1110 1.1 christos 1111 1.1 christos static __inline tilegx_bundle_bits 1112 1.1 christos create_UnaryOpcodeExtension_Y0(int num) 1113 1.1 christos { 1114 1.1 christos const unsigned int n = (unsigned int)num; 1115 1.1 christos return ((n & 0x3f) << 12); 1116 1.1 christos } 1117 1.1 christos 1118 1.1 christos static __inline tilegx_bundle_bits 1119 1.1 christos create_UnaryOpcodeExtension_Y1(int num) 1120 1.1 christos { 1121 1.1 christos const unsigned int n = (unsigned int)num; 1122 1.1 christos return (((tilegx_bundle_bits)(n & 0x3f)) << 43); 1123 1.1 christos } 1124 1.1 christos 1125 1.1 christos 1126 1.1 christos typedef enum 1127 1.1 christos { 1128 1.1 christos TILEGX_PIPELINE_X0, 1129 1.1 christos TILEGX_PIPELINE_X1, 1130 1.1 christos TILEGX_PIPELINE_Y0, 1131 1.1 christos TILEGX_PIPELINE_Y1, 1132 1.1 christos TILEGX_PIPELINE_Y2, 1133 1.1.1.4 christos TILEGX_NUM_PIPELINE_ENCODINGS = 5, 1134 1.1 christos } tilegx_pipeline; 1135 1.1 christos 1136 1.1 christos #define tilegx_is_x_pipeline(p) ((int)(p) <= (int)TILEGX_PIPELINE_X1) 1137 1.1 christos 1138 1.1 christos typedef enum 1139 1.1 christos { 1140 1.1 christos TILEGX_OP_TYPE_REGISTER, 1141 1.1 christos TILEGX_OP_TYPE_IMMEDIATE, 1142 1.1 christos TILEGX_OP_TYPE_ADDRESS, 1143 1.1 christos TILEGX_OP_TYPE_SPR 1144 1.1 christos } tilegx_operand_type; 1145 1.1 christos 1146 1.1 christos /* These are the bits that determine if a bundle is in the X encoding. */ 1147 1.1 christos #define TILEGX_BUNDLE_MODE_MASK ((tilegx_bundle_bits)3 << 62) 1148 1.1 christos 1149 1.1 christos enum 1150 1.1 christos { 1151 1.1 christos /* Maximum number of instructions in a bundle (2 for X, 3 for Y). */ 1152 1.1 christos TILEGX_MAX_INSTRUCTIONS_PER_BUNDLE = 3, 1153 1.1 christos 1154 1.1 christos /* Log base 2 of TILEGX_BUNDLE_SIZE_IN_BYTES. */ 1155 1.1 christos TILEGX_LOG2_BUNDLE_SIZE_IN_BYTES = 3, 1156 1.1 christos 1157 1.1 christos /* Instructions take this many bytes. */ 1158 1.1 christos TILEGX_BUNDLE_SIZE_IN_BYTES = 1 << TILEGX_LOG2_BUNDLE_SIZE_IN_BYTES, 1159 1.1 christos 1160 1.1 christos /* Log base 2 of TILEGX_BUNDLE_ALIGNMENT_IN_BYTES. */ 1161 1.1 christos TILEGX_LOG2_BUNDLE_ALIGNMENT_IN_BYTES = 3, 1162 1.1 christos 1163 1.1 christos /* Bundles should be aligned modulo this number of bytes. */ 1164 1.1 christos TILEGX_BUNDLE_ALIGNMENT_IN_BYTES = 1165 1.1 christos (1 << TILEGX_LOG2_BUNDLE_ALIGNMENT_IN_BYTES), 1166 1.1 christos 1167 1.1 christos /* Number of registers (some are magic, such as network I/O). */ 1168 1.1 christos TILEGX_NUM_REGISTERS = 64, 1169 1.1 christos }; 1170 1.1 christos 1171 1.1 christos 1172 1.1 christos struct tilegx_operand 1173 1.1 christos { 1174 1.1 christos /* Is this operand a register, immediate or address? */ 1175 1.1 christos tilegx_operand_type type; 1176 1.1 christos 1177 1.1 christos /* The default relocation type for this operand. */ 1178 1.1 christos signed int default_reloc : 16; 1179 1.1 christos 1180 1.1 christos /* How many bits is this value? (used for range checking) */ 1181 1.1 christos unsigned int num_bits : 5; 1182 1.1 christos 1183 1.1 christos /* Is the value signed? (used for range checking) */ 1184 1.1 christos unsigned int is_signed : 1; 1185 1.1 christos 1186 1.1 christos /* Is this operand a source register? */ 1187 1.1 christos unsigned int is_src_reg : 1; 1188 1.1 christos 1189 1.1 christos /* Is this operand written? (i.e. is it a destination register) */ 1190 1.1 christos unsigned int is_dest_reg : 1; 1191 1.1 christos 1192 1.1 christos /* Is this operand PC-relative? */ 1193 1.1 christos unsigned int is_pc_relative : 1; 1194 1.1 christos 1195 1.1 christos /* By how many bits do we right shift the value before inserting? */ 1196 1.1 christos unsigned int rightshift : 2; 1197 1.1 christos 1198 1.1 christos /* Return the bits for this operand to be ORed into an existing bundle. */ 1199 1.1 christos tilegx_bundle_bits (*insert) (int op); 1200 1.1 christos 1201 1.1 christos /* Extract this operand and return it. */ 1202 1.1 christos unsigned int (*extract) (tilegx_bundle_bits bundle); 1203 1.1 christos }; 1204 1.1 christos 1205 1.1 christos 1206 1.1 christos extern const struct tilegx_operand tilegx_operands[]; 1207 1.1 christos 1208 1.1 christos /* One finite-state machine per pipe for rapid instruction decoding. */ 1209 1.1 christos extern const unsigned short * const 1210 1.1 christos tilegx_bundle_decoder_fsms[TILEGX_NUM_PIPELINE_ENCODINGS]; 1211 1.1 christos 1212 1.1 christos 1213 1.1 christos struct tilegx_opcode 1214 1.1 christos { 1215 1.1 christos /* The opcode mnemonic, e.g. "add" */ 1216 1.1 christos const char *name; 1217 1.1 christos 1218 1.1 christos /* The enum value for this mnemonic. */ 1219 1.1 christos tilegx_mnemonic mnemonic; 1220 1.1 christos 1221 1.1 christos /* A bit mask of which of the five pipes this instruction 1222 1.1 christos is compatible with: 1223 1.1 christos X0 0x01 1224 1.1 christos X1 0x02 1225 1.1 christos Y0 0x04 1226 1.1 christos Y1 0x08 1227 1.1 christos Y2 0x10 */ 1228 1.1 christos unsigned char pipes; 1229 1.1 christos 1230 1.1 christos /* How many operands are there? */ 1231 1.1 christos unsigned char num_operands; 1232 1.1 christos 1233 1.1 christos /* Which register does this write implicitly, or TREG_ZERO if none? */ 1234 1.1 christos unsigned char implicitly_written_register; 1235 1.1 christos 1236 1.1 christos /* Can this be bundled with other instructions (almost always true). */ 1237 1.1 christos unsigned char can_bundle; 1238 1.1 christos 1239 1.1 christos /* The description of the operands. Each of these is an 1240 1.1 christos * index into the tilegx_operands[] table. */ 1241 1.1 christos unsigned char operands[TILEGX_NUM_PIPELINE_ENCODINGS][TILEGX_MAX_OPERANDS]; 1242 1.1 christos 1243 1.1 christos #if !defined(__KERNEL__) && !defined(_LIBC) 1244 1.1 christos /* A mask of which bits have predefined values for each pipeline. 1245 1.1 christos * This is useful for disassembly. */ 1246 1.1 christos tilegx_bundle_bits fixed_bit_masks[TILEGX_NUM_PIPELINE_ENCODINGS]; 1247 1.1 christos 1248 1.1 christos /* For each bit set in fixed_bit_masks, what the value is for this 1249 1.1 christos * instruction. */ 1250 1.1 christos tilegx_bundle_bits fixed_bit_values[TILEGX_NUM_PIPELINE_ENCODINGS]; 1251 1.1 christos #endif 1252 1.1 christos }; 1253 1.1 christos 1254 1.1 christos extern const struct tilegx_opcode tilegx_opcodes[]; 1255 1.1 christos 1256 1.1 christos /* Used for non-textual disassembly into structs. */ 1257 1.1 christos struct tilegx_decoded_instruction 1258 1.1 christos { 1259 1.1 christos const struct tilegx_opcode *opcode; 1260 1.1 christos const struct tilegx_operand *operands[TILEGX_MAX_OPERANDS]; 1261 1.1 christos long long operand_values[TILEGX_MAX_OPERANDS]; 1262 1.1 christos }; 1263 1.1 christos 1264 1.1 christos 1265 1.1 christos /* Disassemble a bundle into a struct for machine processing. */ 1266 1.1 christos extern int parse_insn_tilegx(tilegx_bundle_bits bits, 1267 1.1 christos unsigned long long pc, 1268 1.1 christos struct tilegx_decoded_instruction 1269 1.1 christos decoded[TILEGX_MAX_INSTRUCTIONS_PER_BUNDLE]); 1270 1.1 christos 1271 1.1 christos 1272 1.1 christos #if !defined(__KERNEL__) && !defined(_LIBC) 1273 1.1 christos /* Canonical names of all the registers. */ 1274 1.1 christos /* ISSUE: This table lives in "tile-dis.c" */ 1275 1.1 christos extern const char * const tilegx_register_names[]; 1276 1.1 christos 1277 1.1 christos /* Descriptor for a special-purpose register. */ 1278 1.1 christos struct tilegx_spr 1279 1.1 christos { 1280 1.1 christos /* The number */ 1281 1.1 christos int number; 1282 1.1 christos 1283 1.1 christos /* The name */ 1284 1.1 christos const char *name; 1285 1.1 christos }; 1286 1.1 christos 1287 1.1 christos /* List of all the SPRs; ordered by increasing number. */ 1288 1.1 christos extern const struct tilegx_spr tilegx_sprs[]; 1289 1.1 christos 1290 1.1 christos /* Number of special-purpose registers. */ 1291 1.1 christos extern const int tilegx_num_sprs; 1292 1.1 christos 1293 1.1 christos extern const char * 1294 1.1 christos get_tilegx_spr_name (int num); 1295 1.1 christos #endif /* !__KERNEL__ && !_LIBC */ 1296 1.1 christos 1297 1.1 christos /* Make a few "tile_" variables to simply common code between 1298 1.1 christos architectures. */ 1299 1.1 christos 1300 1.1 christos typedef tilegx_bundle_bits tile_bundle_bits; 1301 1.1 christos #define TILE_BUNDLE_SIZE_IN_BYTES TILEGX_BUNDLE_SIZE_IN_BYTES 1302 1.1 christos #define TILE_BUNDLE_ALIGNMENT_IN_BYTES TILEGX_BUNDLE_ALIGNMENT_IN_BYTES 1303 1.1 christos #define TILE_LOG2_BUNDLE_ALIGNMENT_IN_BYTES \ 1304 1.1 christos TILEGX_LOG2_BUNDLE_ALIGNMENT_IN_BYTES 1305 1.1 christos 1306 1.1.1.3 christos #ifdef __cplusplus 1307 1.1.1.3 christos } 1308 1.1.1.3 christos #endif 1309 1.1.1.3 christos 1310 1.1 christos #endif /* opcode_tilegx_h */ 1311