1272957Srodrigc/* Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2005, 2006 2272957Srodrigc Free Software Foundation, Inc. 3272957Srodrigc Contributed by David Mosberger-Tang <davidm@hpl.hp.com> 4272957Srodrigc 5272957SrodrigcThis file is part of BFD, the Binary File Descriptor library. 6272957Srodrigc 7272957SrodrigcThis program is free software; you can redistribute it and/or modify 8272957Srodrigcit under the terms of the GNU General Public License as published by 9272957Srodrigcthe Free Software Foundation; either version 2 of the License, or 10272957Srodrigc(at your option) any later version. 11272957Srodrigc 12272957SrodrigcThis program is distributed in the hope that it will be useful, 13272957Srodrigcbut WITHOUT ANY WARRANTY; without even the implied warranty of 14272957SrodrigcMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15272957SrodrigcGNU General Public License for more details. 16272957Srodrigc 17272957SrodrigcYou should have received a copy of the GNU General Public License 18272957Srodrigcalong with this program; if not, write to the Free Software 19272957SrodrigcFoundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ 20272957Srodrigc 21272955Srodrigc/* Logically, this code should be part of libopcode but since some of 22272955Srodrigc the operand insertion/extraction functions help bfd to implement 23272955Srodrigc relocations, this code is included as part of cpu-ia64.c. This 24272955Srodrigc avoids circular dependencies between libopcode and libbfd and also 25272955Srodrigc obviates the need for applications to link in libopcode when all 26272955Srodrigc they really want is libbfd. 27272955Srodrigc 28272955Srodrigc --davidm Mon Apr 13 22:14:02 1998 */ 29272955Srodrigc 30272955Srodrigc#include "../opcodes/ia64-opc.h" 31272955Srodrigc 32272955Srodrigc#define NELEMS(a) ((int) (sizeof (a) / sizeof ((a)[0]))) 33272955Srodrigc 34272955Srodrigcstatic const char* 35272955Srodrigcins_rsvd (const struct ia64_operand *self ATTRIBUTE_UNUSED, 36272955Srodrigc ia64_insn value ATTRIBUTE_UNUSED, ia64_insn *code ATTRIBUTE_UNUSED) 37272955Srodrigc{ 38272955Srodrigc return "internal error---this shouldn't happen"; 39272955Srodrigc} 40272955Srodrigc 41272955Srodrigcstatic const char* 42272955Srodrigcext_rsvd (const struct ia64_operand *self ATTRIBUTE_UNUSED, 43272955Srodrigc ia64_insn code ATTRIBUTE_UNUSED, ia64_insn *valuep ATTRIBUTE_UNUSED) 44272955Srodrigc{ 45272955Srodrigc return "internal error---this shouldn't happen"; 46272955Srodrigc} 47272955Srodrigc 48272955Srodrigcstatic const char* 49272955Srodrigcins_const (const struct ia64_operand *self ATTRIBUTE_UNUSED, 50272955Srodrigc ia64_insn value ATTRIBUTE_UNUSED, ia64_insn *code ATTRIBUTE_UNUSED) 51272955Srodrigc{ 52272955Srodrigc return 0; 53272955Srodrigc} 54272955Srodrigc 55272955Srodrigcstatic const char* 56272955Srodrigcext_const (const struct ia64_operand *self ATTRIBUTE_UNUSED, 57272955Srodrigc ia64_insn code ATTRIBUTE_UNUSED, ia64_insn *valuep ATTRIBUTE_UNUSED) 58272955Srodrigc{ 59272955Srodrigc return 0; 60272955Srodrigc} 61272955Srodrigc 62272955Srodrigcstatic const char* 63272955Srodrigcins_reg (const struct ia64_operand *self, ia64_insn value, ia64_insn *code) 64272955Srodrigc{ 65272955Srodrigc if (value >= 1u << self->field[0].bits) 66272955Srodrigc return "register number out of range"; 67272955Srodrigc 68272955Srodrigc *code |= value << self->field[0].shift; 69272955Srodrigc return 0; 70272955Srodrigc} 71272955Srodrigc 72272955Srodrigcstatic const char* 73272955Srodrigcext_reg (const struct ia64_operand *self, ia64_insn code, ia64_insn *valuep) 74272955Srodrigc{ 75272955Srodrigc *valuep = ((code >> self->field[0].shift) 76272955Srodrigc & ((1u << self->field[0].bits) - 1)); 77272955Srodrigc return 0; 78272955Srodrigc} 79272955Srodrigc 80272955Srodrigcstatic const char* 81272955Srodrigcins_immu (const struct ia64_operand *self, ia64_insn value, ia64_insn *code) 82272955Srodrigc{ 83272955Srodrigc ia64_insn new = 0; 84272955Srodrigc int i; 85272955Srodrigc 86272955Srodrigc for (i = 0; i < NELEMS (self->field) && self->field[i].bits; ++i) 87272955Srodrigc { 88272955Srodrigc new |= ((value & ((((ia64_insn) 1) << self->field[i].bits) - 1)) 89272955Srodrigc << self->field[i].shift); 90272955Srodrigc value >>= self->field[i].bits; 91272955Srodrigc } 92272955Srodrigc if (value) 93272955Srodrigc return "integer operand out of range"; 94272955Srodrigc 95272955Srodrigc *code |= new; 96272955Srodrigc return 0; 97272955Srodrigc} 98272955Srodrigc 99272955Srodrigcstatic const char* 100272955Srodrigcext_immu (const struct ia64_operand *self, ia64_insn code, ia64_insn *valuep) 101272955Srodrigc{ 102272955Srodrigc BFD_HOST_U_64_BIT value = 0; 103272955Srodrigc int i, bits = 0, total = 0; 104272955Srodrigc 105272955Srodrigc for (i = 0; i < NELEMS (self->field) && self->field[i].bits; ++i) 106272955Srodrigc { 107272955Srodrigc bits = self->field[i].bits; 108272955Srodrigc value |= ((code >> self->field[i].shift) 109272955Srodrigc & ((((BFD_HOST_U_64_BIT) 1) << bits) - 1)) << total; 110272955Srodrigc total += bits; 111272955Srodrigc } 112272955Srodrigc *valuep = value; 113272955Srodrigc return 0; 114272955Srodrigc} 115272955Srodrigc 116272955Srodrigcstatic const char* 117272955Srodrigcins_immu5b (const struct ia64_operand *self, ia64_insn value, 118272954Srodrigc ia64_insn *code) 119272954Srodrigc{ 120272955Srodrigc if (value < 32 || value > 63) 121272954Srodrigc return "value must be between 32 and 63"; 122272954Srodrigc return ins_immu (self, value - 32, code); 123272954Srodrigc} 124272955Srodrigc 125272955Srodrigcstatic const char* 126272955Srodrigcext_immu5b (const struct ia64_operand *self, ia64_insn code, 127272955Srodrigc ia64_insn *valuep) 128272955Srodrigc{ 129272955Srodrigc const char *result; 130272955Srodrigc 131272955Srodrigc result = ext_immu (self, code, valuep); 132272955Srodrigc if (result) 133272955Srodrigc return result; 134272955Srodrigc 135272955Srodrigc *valuep = *valuep + 32; 136272955Srodrigc return 0; 137272955Srodrigc} 138272955Srodrigc 139272955Srodrigcstatic const char* 140272955Srodrigcins_immus8 (const struct ia64_operand *self, ia64_insn value, ia64_insn *code) 141272955Srodrigc{ 142272955Srodrigc if (value & 0x7) 143272953Srodrigc return "value not an integer multiple of 8"; 144272953Srodrigc return ins_immu (self, value >> 3, code); 145272953Srodrigc} 146272953Srodrigc 147272953Srodrigcstatic const char* 148272953Srodrigcext_immus8 (const struct ia64_operand *self, ia64_insn code, ia64_insn *valuep) 149272953Srodrigc{ 150272953Srodrigc const char *result; 151272953Srodrigc 152272953Srodrigc result = ext_immu (self, code, valuep); 153272953Srodrigc if (result) 154272953Srodrigc return result; 155272953Srodrigc 156272953Srodrigc *valuep = *valuep << 3; 157272953Srodrigc return 0; 158272953Srodrigc} 159272953Srodrigc 160272953Srodrigcstatic const char* 161272953Srodrigcins_imms_scaled (const struct ia64_operand *self, ia64_insn value, 162272953Srodrigc ia64_insn *code, int scale) 163272953Srodrigc{ 164272953Srodrigc BFD_HOST_64_BIT svalue = value, sign_bit = 0; 165272953Srodrigc ia64_insn new = 0; 166272953Srodrigc int i; 167272953Srodrigc 168272953Srodrigc svalue >>= scale; 169272953Srodrigc 170272953Srodrigc for (i = 0; i < NELEMS (self->field) && self->field[i].bits; ++i) 171272953Srodrigc { 172272953Srodrigc new |= ((svalue & ((((ia64_insn) 1) << self->field[i].bits) - 1)) 173272953Srodrigc << self->field[i].shift); 174272953Srodrigc sign_bit = (svalue >> (self->field[i].bits - 1)) & 1; 175272953Srodrigc svalue >>= self->field[i].bits; 176272953Srodrigc } 177272953Srodrigc if ((!sign_bit && svalue != 0) || (sign_bit && svalue != -1)) 178268899Sbapt return "integer operand out of range"; 179268899Sbapt 180268899Sbapt *code |= new; 181268899Sbapt return 0; 182268899Sbapt} 183268899Sbapt 184268899Sbaptstatic const char* 185268899Sbaptext_imms_scaled (const struct ia64_operand *self, ia64_insn code, 186268899Sbapt ia64_insn *valuep, int scale) 187268899Sbapt{ 188268899Sbapt int i, bits = 0, total = 0; 189268899Sbapt BFD_HOST_64_BIT val = 0, sign; 190268899Sbapt 191268899Sbapt for (i = 0; i < NELEMS (self->field) && self->field[i].bits; ++i) 192268899Sbapt { 193268899Sbapt bits = self->field[i].bits; 194268899Sbapt val |= ((code >> self->field[i].shift) 195268899Sbapt & ((((BFD_HOST_U_64_BIT) 1) << bits) - 1)) << total; 196268899Sbapt total += bits; 197268899Sbapt } 198268899Sbapt /* sign extend: */ 199268899Sbapt sign = (BFD_HOST_64_BIT) 1 << (total - 1); 200268899Sbapt val = (val ^ sign) - sign; 201268899Sbapt 202268899Sbapt *valuep = (val << scale); 203268899Sbapt return 0; 204268899Sbapt} 205268899Sbapt 206268899Sbaptstatic const char* 207268899Sbaptins_imms (const struct ia64_operand *self, ia64_insn value, ia64_insn *code) 208268899Sbapt{ 209268899Sbapt return ins_imms_scaled (self, value, code, 0); 210268899Sbapt} 211268899Sbapt 212268899Sbaptstatic const char* 213268899Sbaptins_immsu4 (const struct ia64_operand *self, ia64_insn value, ia64_insn *code) 214268899Sbapt{ 215268899Sbapt value = ((value & 0xffffffff) ^ 0x80000000) - 0x80000000; 216268899Sbapt 217268899Sbapt return ins_imms_scaled (self, value, code, 0); 218268899Sbapt} 219268899Sbapt 220268899Sbaptstatic const char* 221268899Sbaptext_imms (const struct ia64_operand *self, ia64_insn code, ia64_insn *valuep) 222268899Sbapt{ 223268899Sbapt return ext_imms_scaled (self, code, valuep, 0); 224268899Sbapt} 225268899Sbapt 226268899Sbaptstatic const char* 227268899Sbaptins_immsm1 (const struct ia64_operand *self, ia64_insn value, ia64_insn *code) 228268899Sbapt{ 229268899Sbapt --value; 230268899Sbapt return ins_imms_scaled (self, value, code, 0); 231268899Sbapt} 232268899Sbapt 233268899Sbaptstatic const char* 234268899Sbaptins_immsm1u4 (const struct ia64_operand *self, ia64_insn value, 235268899Sbapt ia64_insn *code) 236268899Sbapt{ 237268899Sbapt value = ((value & 0xffffffff) ^ 0x80000000) - 0x80000000; 238268899Sbapt 239268899Sbapt --value; 240268899Sbapt return ins_imms_scaled (self, value, code, 0); 241268899Sbapt} 242268899Sbapt 243268899Sbaptstatic const char* 244268899Sbaptext_immsm1 (const struct ia64_operand *self, ia64_insn code, ia64_insn *valuep) 245268899Sbapt{ 246268899Sbapt const char *res = ext_imms_scaled (self, code, valuep, 0); 247268899Sbapt 248268899Sbapt ++*valuep; 249268899Sbapt return res; 250268899Sbapt} 251268899Sbapt 252268899Sbaptstatic const char* 253268899Sbaptins_imms1 (const struct ia64_operand *self, ia64_insn value, ia64_insn *code) 254268899Sbapt{ 255268899Sbapt return ins_imms_scaled (self, value, code, 1); 256268899Sbapt} 257268899Sbapt 258268899Sbaptstatic const char* 259268899Sbaptext_imms1 (const struct ia64_operand *self, ia64_insn code, ia64_insn *valuep) 260268899Sbapt{ 261268899Sbapt return ext_imms_scaled (self, code, valuep, 1); 262268899Sbapt} 263268899Sbapt 264268899Sbaptstatic const char* 265268899Sbaptins_imms4 (const struct ia64_operand *self, ia64_insn value, ia64_insn *code) 266268899Sbapt{ 267268899Sbapt return ins_imms_scaled (self, value, code, 4); 268268899Sbapt} 269268899Sbapt 270268899Sbaptstatic const char* 271268899Sbaptext_imms4 (const struct ia64_operand *self, ia64_insn code, ia64_insn *valuep) 272268899Sbapt{ 273268899Sbapt return ext_imms_scaled (self, code, valuep, 4); 274268899Sbapt} 275268899Sbapt 276268899Sbaptstatic const char* 277268899Sbaptins_imms16 (const struct ia64_operand *self, ia64_insn value, ia64_insn *code) 278268899Sbapt{ 279268899Sbapt return ins_imms_scaled (self, value, code, 16); 280268899Sbapt} 281268899Sbapt 282268899Sbaptstatic const char* 283268899Sbaptext_imms16 (const struct ia64_operand *self, ia64_insn code, ia64_insn *valuep) 284268899Sbapt{ 285268899Sbapt return ext_imms_scaled (self, code, valuep, 16); 286268899Sbapt} 287268899Sbapt 288268899Sbaptstatic const char* 289268899Sbaptins_cimmu (const struct ia64_operand *self, ia64_insn value, ia64_insn *code) 290268899Sbapt{ 291268899Sbapt ia64_insn mask = (((ia64_insn) 1) << self->field[0].bits) - 1; 292268899Sbapt return ins_immu (self, value ^ mask, code); 293268899Sbapt} 294268899Sbapt 295268899Sbaptstatic const char* 296268899Sbaptext_cimmu (const struct ia64_operand *self, ia64_insn code, ia64_insn *valuep) 297268899Sbapt{ 298268899Sbapt const char *result; 299268899Sbapt ia64_insn mask; 300268899Sbapt 301268899Sbapt mask = (((ia64_insn) 1) << self->field[0].bits) - 1; 302268899Sbapt result = ext_immu (self, code, valuep); 303268899Sbapt if (!result) 304268899Sbapt { 305268899Sbapt mask = (((ia64_insn) 1) << self->field[0].bits) - 1; 306268899Sbapt *valuep ^= mask; 307268899Sbapt } 308268899Sbapt return result; 309268899Sbapt} 310268899Sbapt 311268899Sbaptstatic const char* 312268899Sbaptins_cnt (const struct ia64_operand *self, ia64_insn value, ia64_insn *code) 313268899Sbapt{ 314268899Sbapt --value; 315268899Sbapt if (value >= ((BFD_HOST_U_64_BIT) 1) << self->field[0].bits) 316268899Sbapt return "count out of range"; 317268899Sbapt 318268899Sbapt *code |= value << self->field[0].shift; 319268899Sbapt return 0; 320268899Sbapt} 321268899Sbapt 322268899Sbaptstatic const char* 323268899Sbaptext_cnt (const struct ia64_operand *self, ia64_insn code, ia64_insn *valuep) 324268899Sbapt{ 325268899Sbapt *valuep = ((code >> self->field[0].shift) 326268899Sbapt & ((((BFD_HOST_U_64_BIT) 1) << self->field[0].bits) - 1)) + 1; 327268899Sbapt return 0; 328268899Sbapt} 329268899Sbapt 330268899Sbaptstatic const char* 331268899Sbaptins_cnt2b (const struct ia64_operand *self, ia64_insn value, ia64_insn *code) 332268899Sbapt{ 333268899Sbapt --value; 334268899Sbapt 335268899Sbapt if (value > 2) 336268899Sbapt return "count must be in range 1..3"; 337268899Sbapt 338268899Sbapt *code |= value << self->field[0].shift; 339268899Sbapt return 0; 340268899Sbapt} 341268899Sbapt 342268899Sbaptstatic const char* 343268899Sbaptext_cnt2b (const struct ia64_operand *self, ia64_insn code, ia64_insn *valuep) 344268899Sbapt{ 345268899Sbapt *valuep = ((code >> self->field[0].shift) & 0x3) + 1; 346268899Sbapt return 0; 347268899Sbapt} 348268899Sbapt 349268899Sbaptstatic const char* 350268899Sbaptins_cnt2c (const struct ia64_operand *self, ia64_insn value, ia64_insn *code) 351268899Sbapt{ 352268899Sbapt switch (value) 353268899Sbapt { 354268899Sbapt case 0: value = 0; break; 355268899Sbapt case 7: value = 1; break; 356268899Sbapt case 15: value = 2; break; 357268899Sbapt case 16: value = 3; break; 358268899Sbapt default: return "count must be 0, 7, 15, or 16"; 359268899Sbapt } 360268899Sbapt *code |= value << self->field[0].shift; 361268899Sbapt return 0; 362268899Sbapt} 363268899Sbapt 364268899Sbaptstatic const char* 365268899Sbaptext_cnt2c (const struct ia64_operand *self, ia64_insn code, ia64_insn *valuep) 366268899Sbapt{ 367268899Sbapt ia64_insn value; 368268899Sbapt 369268899Sbapt value = (code >> self->field[0].shift) & 0x3; 370268899Sbapt switch (value) 371268899Sbapt { 372268899Sbapt case 0: value = 0; break; 373268899Sbapt case 1: value = 7; break; 374268899Sbapt case 2: value = 15; break; 375268899Sbapt case 3: value = 16; break; 376268899Sbapt } 377268899Sbapt *valuep = value; 378268899Sbapt return 0; 379268899Sbapt} 380268899Sbapt 381268899Sbaptstatic const char* 382268899Sbaptins_inc3 (const struct ia64_operand *self, ia64_insn value, ia64_insn *code) 383268899Sbapt{ 384268899Sbapt BFD_HOST_64_BIT val = value; 385268899Sbapt BFD_HOST_U_64_BIT sign = 0; 386268899Sbapt 387268899Sbapt if (val < 0) 388268899Sbapt { 389268899Sbapt sign = 0x4; 390268899Sbapt value = -value; 391268899Sbapt } 392268899Sbapt switch (value) 393268899Sbapt { 394268899Sbapt case 1: value = 3; break; 395268899Sbapt case 4: value = 2; break; 396268899Sbapt case 8: value = 1; break; 397268899Sbapt case 16: value = 0; break; 398268899Sbapt default: return "count must be +/- 1, 4, 8, or 16"; 399268899Sbapt } 400268899Sbapt *code |= (sign | value) << self->field[0].shift; 401268899Sbapt return 0; 402268899Sbapt} 403268899Sbapt 404268899Sbaptstatic const char* 405268899Sbaptext_inc3 (const struct ia64_operand *self, ia64_insn code, ia64_insn *valuep) 406268899Sbapt{ 407268899Sbapt BFD_HOST_64_BIT val; 408268899Sbapt int negate; 409268899Sbapt 410268899Sbapt val = (code >> self->field[0].shift) & 0x7; 411268899Sbapt negate = val & 0x4; 412268899Sbapt switch (val & 0x3) 413268899Sbapt { 414268899Sbapt case 0: val = 16; break; 415268899Sbapt case 1: val = 8; break; 416268899Sbapt case 2: val = 4; break; 417268899Sbapt case 3: val = 1; break; 418268899Sbapt } 419268899Sbapt if (negate) 420268899Sbapt val = -val; 421268899Sbapt 422268899Sbapt *valuep = val; 423268899Sbapt return 0; 424268899Sbapt} 425268899Sbapt 426268899Sbapt#define CST IA64_OPND_CLASS_CST 427268899Sbapt#define REG IA64_OPND_CLASS_REG 428268899Sbapt#define IND IA64_OPND_CLASS_IND 429268899Sbapt#define ABS IA64_OPND_CLASS_ABS 430268899Sbapt#define REL IA64_OPND_CLASS_REL 431268899Sbapt 432268899Sbapt#define SDEC IA64_OPND_FLAG_DECIMAL_SIGNED 433268899Sbapt#define UDEC IA64_OPND_FLAG_DECIMAL_UNSIGNED 434268899Sbapt 435268899Sbaptconst struct ia64_operand elf64_ia64_operands[IA64_OPND_COUNT] = 436268899Sbapt { 437268899Sbapt /* constants: */ 438268899Sbapt { CST, ins_const, ext_const, "NIL", {{ 0, 0}}, 0, "<none>" }, 439268899Sbapt { CST, ins_const, ext_const, "ar.csd", {{ 0, 0}}, 0, "ar.csd" }, 440268899Sbapt { CST, ins_const, ext_const, "ar.ccv", {{ 0, 0}}, 0, "ar.ccv" }, 441268899Sbapt { CST, ins_const, ext_const, "ar.pfs", {{ 0, 0}}, 0, "ar.pfs" }, 442268899Sbapt { CST, ins_const, ext_const, "1", {{ 0, 0}}, 0, "1" }, 443268899Sbapt { CST, ins_const, ext_const, "8", {{ 0, 0}}, 0, "8" }, 444268899Sbapt { CST, ins_const, ext_const, "16", {{ 0, 0}}, 0, "16" }, 445268899Sbapt { CST, ins_const, ext_const, "r0", {{ 0, 0}}, 0, "r0" }, 446268899Sbapt { CST, ins_const, ext_const, "ip", {{ 0, 0}}, 0, "ip" }, 447268899Sbapt { CST, ins_const, ext_const, "pr", {{ 0, 0}}, 0, "pr" }, 448268899Sbapt { CST, ins_const, ext_const, "pr.rot", {{ 0, 0}}, 0, "pr.rot" }, 449268899Sbapt { CST, ins_const, ext_const, "psr", {{ 0, 0}}, 0, "psr" }, 450268899Sbapt { CST, ins_const, ext_const, "psr.l", {{ 0, 0}}, 0, "psr.l" }, 451268899Sbapt { CST, ins_const, ext_const, "psr.um", {{ 0, 0}}, 0, "psr.um" }, 452268899Sbapt 453268899Sbapt /* register operands: */ 454268899Sbapt { REG, ins_reg, ext_reg, "ar", {{ 7, 20}}, 0, /* AR3 */ 455268899Sbapt "an application register" }, 456268899Sbapt { REG, ins_reg, ext_reg, "b", {{ 3, 6}}, 0, /* B1 */ 457268899Sbapt "a branch register" }, 458268899Sbapt { REG, ins_reg, ext_reg, "b", {{ 3, 13}}, 0, /* B2 */ 459268899Sbapt "a branch register"}, 460268899Sbapt { REG, ins_reg, ext_reg, "cr", {{ 7, 20}}, 0, /* CR */ 461268899Sbapt "a control register"}, 462268899Sbapt { REG, ins_reg, ext_reg, "f", {{ 7, 6}}, 0, /* F1 */ 463268899Sbapt "a floating-point register" }, 464268899Sbapt { REG, ins_reg, ext_reg, "f", {{ 7, 13}}, 0, /* F2 */ 465268899Sbapt "a floating-point register" }, 466268899Sbapt { REG, ins_reg, ext_reg, "f", {{ 7, 20}}, 0, /* F3 */ 467268899Sbapt "a floating-point register" }, 468268899Sbapt { REG, ins_reg, ext_reg, "f", {{ 7, 27}}, 0, /* F4 */ 469268899Sbapt "a floating-point register" }, 470268899Sbapt { REG, ins_reg, ext_reg, "p", {{ 6, 6}}, 0, /* P1 */ 471268899Sbapt "a predicate register" }, 472268899Sbapt { REG, ins_reg, ext_reg, "p", {{ 6, 27}}, 0, /* P2 */ 473268899Sbapt "a predicate register" }, 474268899Sbapt { REG, ins_reg, ext_reg, "r", {{ 7, 6}}, 0, /* R1 */ 475268899Sbapt "a general register" }, 476268899Sbapt { REG, ins_reg, ext_reg, "r", {{ 7, 13}}, 0, /* R2 */ 477268899Sbapt "a general register" }, 478268899Sbapt { REG, ins_reg, ext_reg, "r", {{ 7, 20}}, 0, /* R3 */ 479268899Sbapt "a general register" }, 480268899Sbapt { REG, ins_reg, ext_reg, "r", {{ 2, 20}}, 0, /* R3_2 */ 481268899Sbapt "a general register r0-r3" }, 482268899Sbapt 483268899Sbapt /* memory operands: */ 484268899Sbapt { IND, ins_reg, ext_reg, "", {{7, 20}}, 0, /* MR3 */ 485268899Sbapt "a memory address" }, 486268899Sbapt 487268899Sbapt /* indirect operands: */ 488268899Sbapt { IND, ins_reg, ext_reg, "cpuid", {{7, 20}}, 0, /* CPUID_R3 */ 489268899Sbapt "a cpuid register" }, 490268899Sbapt { IND, ins_reg, ext_reg, "dbr", {{7, 20}}, 0, /* DBR_R3 */ 491268899Sbapt "a dbr register" }, 492268899Sbapt { IND, ins_reg, ext_reg, "dtr", {{7, 20}}, 0, /* DTR_R3 */ 493268899Sbapt "a dtr register" }, 494268899Sbapt { IND, ins_reg, ext_reg, "itr", {{7, 20}}, 0, /* ITR_R3 */ 495268899Sbapt "an itr register" }, 496268899Sbapt { IND, ins_reg, ext_reg, "ibr", {{7, 20}}, 0, /* IBR_R3 */ 497268899Sbapt "an ibr register" }, 498268899Sbapt { IND, ins_reg, ext_reg, "msr", {{7, 20}}, 0, /* MSR_R3 */ 499268899Sbapt "an msr register" }, 500268899Sbapt { IND, ins_reg, ext_reg, "pkr", {{7, 20}}, 0, /* PKR_R3 */ 501268899Sbapt "a pkr register" }, 502268899Sbapt { IND, ins_reg, ext_reg, "pmc", {{7, 20}}, 0, /* PMC_R3 */ 503268899Sbapt "a pmc register" }, 504268899Sbapt { IND, ins_reg, ext_reg, "pmd", {{7, 20}}, 0, /* PMD_R3 */ 505268899Sbapt "a pmd register" }, 506268899Sbapt { IND, ins_reg, ext_reg, "rr", {{7, 20}}, 0, /* RR_R3 */ 507268899Sbapt "an rr register" }, 508268899Sbapt 509268899Sbapt /* immediate operands: */ 510268899Sbapt { ABS, ins_cimmu, ext_cimmu, 0, {{ 5, 20 }}, UDEC, /* CCNT5 */ 511268899Sbapt "a 5-bit count (0-31)" }, 512268899Sbapt { ABS, ins_cnt, ext_cnt, 0, {{ 2, 27 }}, UDEC, /* CNT2a */ 513268899Sbapt "a 2-bit count (1-4)" }, 514268899Sbapt { ABS, ins_cnt2b, ext_cnt2b, 0, {{ 2, 27 }}, UDEC, /* CNT2b */ 515268899Sbapt "a 2-bit count (1-3)" }, 516268899Sbapt { ABS, ins_cnt2c, ext_cnt2c, 0, {{ 2, 30 }}, UDEC, /* CNT2c */ 517268899Sbapt "a count (0, 7, 15, or 16)" }, 518268899Sbapt { ABS, ins_immu, ext_immu, 0, {{ 5, 14}}, UDEC, /* CNT5 */ 519268899Sbapt "a 5-bit count (0-31)" }, 520268899Sbapt { ABS, ins_immu, ext_immu, 0, {{ 6, 27}}, UDEC, /* CNT6 */ 521268899Sbapt "a 6-bit count (0-63)" }, 522268899Sbapt { ABS, ins_cimmu, ext_cimmu, 0, {{ 6, 20}}, UDEC, /* CPOS6a */ 523268899Sbapt "a 6-bit bit pos (0-63)" }, 524268899Sbapt { ABS, ins_cimmu, ext_cimmu, 0, {{ 6, 14}}, UDEC, /* CPOS6b */ 525268899Sbapt "a 6-bit bit pos (0-63)" }, 526268899Sbapt { ABS, ins_cimmu, ext_cimmu, 0, {{ 6, 31}}, UDEC, /* CPOS6c */ 527268899Sbapt "a 6-bit bit pos (0-63)" }, 528268899Sbapt { ABS, ins_imms, ext_imms, 0, {{ 1, 36}}, SDEC, /* IMM1 */ 529268899Sbapt "a 1-bit integer (-1, 0)" }, 530268899Sbapt { ABS, ins_immu, ext_immu, 0, {{ 2, 13}}, UDEC, /* IMMU2 */ 531268899Sbapt "a 2-bit unsigned (0-3)" }, 532268899Sbapt { ABS, ins_immu5b, ext_immu5b, 0, {{ 5, 14}}, UDEC, /* IMMU5b */ 533268899Sbapt "a 5-bit unsigned (32 + (0-31))" }, 534268899Sbapt { ABS, ins_immu, ext_immu, 0, {{ 7, 13}}, 0, /* IMMU7a */ 535268899Sbapt "a 7-bit unsigned (0-127)" }, 536268899Sbapt { ABS, ins_immu, ext_immu, 0, {{ 7, 20}}, 0, /* IMMU7b */ 537268899Sbapt "a 7-bit unsigned (0-127)" }, 538268899Sbapt { ABS, ins_immu, ext_immu, 0, {{ 7, 13}}, UDEC, /* SOF */ 539268899Sbapt "a frame size (register count)" }, 540268899Sbapt { ABS, ins_immu, ext_immu, 0, {{ 7, 20}}, UDEC, /* SOL */ 541268899Sbapt "a local register count" }, 542268899Sbapt { ABS, ins_immus8,ext_immus8,0, {{ 4, 27}}, UDEC, /* SOR */ 543268899Sbapt "a rotating register count (integer multiple of 8)" }, 544268899Sbapt { ABS, ins_imms, ext_imms, 0, /* IMM8 */ 545268899Sbapt {{ 7, 13}, { 1, 36}}, SDEC, 546268899Sbapt "an 8-bit integer (-128-127)" }, 547268899Sbapt { ABS, ins_immsu4, ext_imms, 0, /* IMM8U4 */ 548268899Sbapt {{ 7, 13}, { 1, 36}}, SDEC, 549268899Sbapt "an 8-bit signed integer for 32-bit unsigned compare (-128-127)" }, 550268899Sbapt { ABS, ins_immsm1, ext_immsm1, 0, /* IMM8M1 */ 551268899Sbapt {{ 7, 13}, { 1, 36}}, SDEC, 552268899Sbapt "an 8-bit integer (-127-128)" }, 553268899Sbapt { ABS, ins_immsm1u4, ext_immsm1, 0, /* IMM8M1U4 */ 554268899Sbapt {{ 7, 13}, { 1, 36}}, SDEC, 555268899Sbapt "an 8-bit integer for 32-bit unsigned compare (-127-(-1),1-128,0x100000000)" }, 556268899Sbapt { ABS, ins_immsm1, ext_immsm1, 0, /* IMM8M1U8 */ 557268899Sbapt {{ 7, 13}, { 1, 36}}, SDEC, 558268899Sbapt "an 8-bit integer for 64-bit unsigned compare (-127-(-1),1-128,0x10000000000000000)" }, 559268899Sbapt { ABS, ins_immu, ext_immu, 0, {{ 2, 33}, { 7, 20}}, 0, /* IMMU9 */ 560268899Sbapt "a 9-bit unsigned (0-511)" }, 561268899Sbapt { ABS, ins_imms, ext_imms, 0, /* IMM9a */ 562268899Sbapt {{ 7, 6}, { 1, 27}, { 1, 36}}, SDEC, 563268899Sbapt "a 9-bit integer (-256-255)" }, 564268899Sbapt { ABS, ins_imms, ext_imms, 0, /* IMM9b */ 565268899Sbapt {{ 7, 13}, { 1, 27}, { 1, 36}}, SDEC, 566268899Sbapt "a 9-bit integer (-256-255)" }, 567268899Sbapt { ABS, ins_imms, ext_imms, 0, /* IMM14 */ 568268899Sbapt {{ 7, 13}, { 6, 27}, { 1, 36}}, SDEC, 569268899Sbapt "a 14-bit integer (-8192-8191)" }, 570268899Sbapt { ABS, ins_imms1, ext_imms1, 0, /* IMM17 */ 571268899Sbapt {{ 7, 6}, { 8, 24}, { 1, 36}}, 0, 572268899Sbapt "a 17-bit integer (-65536-65535)" }, 573268899Sbapt { ABS, ins_immu, ext_immu, 0, {{20, 6}, { 1, 36}}, 0, /* IMMU21 */ 574268899Sbapt "a 21-bit unsigned" }, 575268899Sbapt { ABS, ins_imms, ext_imms, 0, /* IMM22 */ 576268899Sbapt {{ 7, 13}, { 9, 27}, { 5, 22}, { 1, 36}}, SDEC, 577268899Sbapt "a 22-bit signed integer" }, 578268899Sbapt { ABS, ins_immu, ext_immu, 0, /* IMMU24 */ 579268899Sbapt {{21, 6}, { 2, 31}, { 1, 36}}, 0, 580268899Sbapt "a 24-bit unsigned" }, 581268899Sbapt { ABS, ins_imms16,ext_imms16,0, {{27, 6}, { 1, 36}}, 0, /* IMM44 */ 582268899Sbapt "a 44-bit unsigned (least 16 bits ignored/zeroes)" }, 583268899Sbapt { ABS, ins_rsvd, ext_rsvd, 0, {{0, 0}}, 0, /* IMMU62 */ 584268899Sbapt "a 62-bit unsigned" }, 585268899Sbapt { ABS, ins_rsvd, ext_rsvd, 0, {{0, 0}}, 0, /* IMMU64 */ 586268899Sbapt "a 64-bit unsigned" }, 587268899Sbapt { ABS, ins_inc3, ext_inc3, 0, {{ 3, 13}}, SDEC, /* INC3 */ 588268899Sbapt "an increment (+/- 1, 4, 8, or 16)" }, 589268899Sbapt { ABS, ins_cnt, ext_cnt, 0, {{ 4, 27}}, UDEC, /* LEN4 */ 590268899Sbapt "a 4-bit length (1-16)" }, 591268899Sbapt { ABS, ins_cnt, ext_cnt, 0, {{ 6, 27}}, UDEC, /* LEN6 */ 592268899Sbapt "a 6-bit length (1-64)" }, 593268899Sbapt { ABS, ins_immu, ext_immu, 0, {{ 4, 20}}, 0, /* MBTYPE4 */ 594268899Sbapt "a mix type (@rev, @mix, @shuf, @alt, or @brcst)" }, 595268899Sbapt { ABS, ins_immu, ext_immu, 0, {{ 8, 20}}, 0, /* MBTYPE8 */ 596268899Sbapt "an 8-bit mix type" }, 597268899Sbapt { ABS, ins_immu, ext_immu, 0, {{ 6, 14}}, UDEC, /* POS6 */ 598268899Sbapt "a 6-bit bit pos (0-63)" }, 599268899Sbapt { REL, ins_imms4, ext_imms4, 0, {{ 7, 6}, { 2, 33}}, 0, /* TAG13 */ 600268899Sbapt "a branch tag" }, 601268899Sbapt { REL, ins_imms4, ext_imms4, 0, {{ 9, 24}}, 0, /* TAG13b */ 602268899Sbapt "a branch tag" }, 603268899Sbapt { REL, ins_imms4, ext_imms4, 0, {{20, 6}, { 1, 36}}, 0, /* TGT25 */ 604268899Sbapt "a branch target" }, 605268899Sbapt { REL, ins_imms4, ext_imms4, 0, /* TGT25b */ 606268899Sbapt {{ 7, 6}, {13, 20}, { 1, 36}}, 0, 607268899Sbapt "a branch target" }, 608268899Sbapt { REL, ins_imms4, ext_imms4, 0, {{20, 13}, { 1, 36}}, 0, /* TGT25c */ 609268899Sbapt "a branch target" }, 610268899Sbapt { REL, ins_rsvd, ext_rsvd, 0, {{0, 0}}, 0, /* TGT64 */ 611268899Sbapt "a branch target" }, 612268899Sbapt 613268899Sbapt { ABS, ins_const, ext_const, 0, {{0, 0}}, 0, /* LDXMOV */ 614268899Sbapt "ldxmov target" }, 615268899Sbapt }; 616268899Sbapt