18c2ecf20Sopenharmony_ci/* ppc.h -- Header file for PowerPC opcode table 28c2ecf20Sopenharmony_ci Copyright (C) 1994-2016 Free Software Foundation, Inc. 38c2ecf20Sopenharmony_ci Written by Ian Lance Taylor, Cygnus Support 48c2ecf20Sopenharmony_ci 58c2ecf20Sopenharmony_ciThis file is part of GDB, GAS, and the GNU binutils. 68c2ecf20Sopenharmony_ci 78c2ecf20Sopenharmony_ciGDB, GAS, and the GNU binutils are free software; you can redistribute 88c2ecf20Sopenharmony_cithem and/or modify them under the terms of the GNU General Public 98c2ecf20Sopenharmony_ciLicense as published by the Free Software Foundation; either version 108c2ecf20Sopenharmony_ci1, or (at your option) any later version. 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_ciGDB, GAS, and the GNU binutils are distributed in the hope that they 138c2ecf20Sopenharmony_ciwill be useful, but WITHOUT ANY WARRANTY; without even the implied 148c2ecf20Sopenharmony_ciwarranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See 158c2ecf20Sopenharmony_cithe GNU General Public License for more details. 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_ciYou should have received a copy of the GNU General Public License 188c2ecf20Sopenharmony_cialong with this file; see the file COPYING. If not, write to the Free 198c2ecf20Sopenharmony_ciSoftware Foundation, 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ 208c2ecf20Sopenharmony_ci 218c2ecf20Sopenharmony_ci#ifndef PPC_H 228c2ecf20Sopenharmony_ci#define PPC_H 238c2ecf20Sopenharmony_ci 248c2ecf20Sopenharmony_ci#ifdef __cplusplus 258c2ecf20Sopenharmony_ciextern "C" { 268c2ecf20Sopenharmony_ci#endif 278c2ecf20Sopenharmony_ci 288c2ecf20Sopenharmony_citypedef uint64_t ppc_cpu_t; 298c2ecf20Sopenharmony_ci 308c2ecf20Sopenharmony_ci/* The opcode table is an array of struct powerpc_opcode. */ 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_cistruct powerpc_opcode 338c2ecf20Sopenharmony_ci{ 348c2ecf20Sopenharmony_ci /* The opcode name. */ 358c2ecf20Sopenharmony_ci const char *name; 368c2ecf20Sopenharmony_ci 378c2ecf20Sopenharmony_ci /* The opcode itself. Those bits which will be filled in with 388c2ecf20Sopenharmony_ci operands are zeroes. */ 398c2ecf20Sopenharmony_ci unsigned long opcode; 408c2ecf20Sopenharmony_ci 418c2ecf20Sopenharmony_ci /* The opcode mask. This is used by the disassembler. This is a 428c2ecf20Sopenharmony_ci mask containing ones indicating those bits which must match the 438c2ecf20Sopenharmony_ci opcode field, and zeroes indicating those bits which need not 448c2ecf20Sopenharmony_ci match (and are presumably filled in by operands). */ 458c2ecf20Sopenharmony_ci unsigned long mask; 468c2ecf20Sopenharmony_ci 478c2ecf20Sopenharmony_ci /* One bit flags for the opcode. These are used to indicate which 488c2ecf20Sopenharmony_ci specific processors support the instructions. The defined values 498c2ecf20Sopenharmony_ci are listed below. */ 508c2ecf20Sopenharmony_ci ppc_cpu_t flags; 518c2ecf20Sopenharmony_ci 528c2ecf20Sopenharmony_ci /* One bit flags for the opcode. These are used to indicate which 538c2ecf20Sopenharmony_ci specific processors no longer support the instructions. The defined 548c2ecf20Sopenharmony_ci values are listed below. */ 558c2ecf20Sopenharmony_ci ppc_cpu_t deprecated; 568c2ecf20Sopenharmony_ci 578c2ecf20Sopenharmony_ci /* An array of operand codes. Each code is an index into the 588c2ecf20Sopenharmony_ci operand table. They appear in the order which the operands must 598c2ecf20Sopenharmony_ci appear in assembly code, and are terminated by a zero. */ 608c2ecf20Sopenharmony_ci unsigned char operands[8]; 618c2ecf20Sopenharmony_ci}; 628c2ecf20Sopenharmony_ci 638c2ecf20Sopenharmony_ci/* The table itself is sorted by major opcode number, and is otherwise 648c2ecf20Sopenharmony_ci in the order in which the disassembler should consider 658c2ecf20Sopenharmony_ci instructions. */ 668c2ecf20Sopenharmony_ciextern const struct powerpc_opcode powerpc_opcodes[]; 678c2ecf20Sopenharmony_ciextern const int powerpc_num_opcodes; 688c2ecf20Sopenharmony_ciextern const struct powerpc_opcode vle_opcodes[]; 698c2ecf20Sopenharmony_ciextern const int vle_num_opcodes; 708c2ecf20Sopenharmony_ci 718c2ecf20Sopenharmony_ci/* Values defined for the flags field of a struct powerpc_opcode. */ 728c2ecf20Sopenharmony_ci 738c2ecf20Sopenharmony_ci/* Opcode is defined for the PowerPC architecture. */ 748c2ecf20Sopenharmony_ci#define PPC_OPCODE_PPC 1 758c2ecf20Sopenharmony_ci 768c2ecf20Sopenharmony_ci/* Opcode is defined for the POWER (RS/6000) architecture. */ 778c2ecf20Sopenharmony_ci#define PPC_OPCODE_POWER 2 788c2ecf20Sopenharmony_ci 798c2ecf20Sopenharmony_ci/* Opcode is defined for the POWER2 (Rios 2) architecture. */ 808c2ecf20Sopenharmony_ci#define PPC_OPCODE_POWER2 4 818c2ecf20Sopenharmony_ci 828c2ecf20Sopenharmony_ci/* Opcode is supported by the Motorola PowerPC 601 processor. The 601 838c2ecf20Sopenharmony_ci is assumed to support all PowerPC (PPC_OPCODE_PPC) instructions, 848c2ecf20Sopenharmony_ci but it also supports many additional POWER instructions. */ 858c2ecf20Sopenharmony_ci#define PPC_OPCODE_601 8 868c2ecf20Sopenharmony_ci 878c2ecf20Sopenharmony_ci/* Opcode is supported in both the Power and PowerPC architectures 888c2ecf20Sopenharmony_ci (ie, compiler's -mcpu=common or assembler's -mcom). More than just 898c2ecf20Sopenharmony_ci the intersection of PPC_OPCODE_PPC with the union of PPC_OPCODE_POWER 908c2ecf20Sopenharmony_ci and PPC_OPCODE_POWER2 because many instructions changed mnemonics 918c2ecf20Sopenharmony_ci between POWER and POWERPC. */ 928c2ecf20Sopenharmony_ci#define PPC_OPCODE_COMMON 0x10 938c2ecf20Sopenharmony_ci 948c2ecf20Sopenharmony_ci/* Opcode is supported for any Power or PowerPC platform (this is 958c2ecf20Sopenharmony_ci for the assembler's -many option, and it eliminates duplicates). */ 968c2ecf20Sopenharmony_ci#define PPC_OPCODE_ANY 0x20 978c2ecf20Sopenharmony_ci 988c2ecf20Sopenharmony_ci/* Opcode is only defined on 64 bit architectures. */ 998c2ecf20Sopenharmony_ci#define PPC_OPCODE_64 0x40 1008c2ecf20Sopenharmony_ci 1018c2ecf20Sopenharmony_ci/* Opcode is supported as part of the 64-bit bridge. */ 1028c2ecf20Sopenharmony_ci#define PPC_OPCODE_64_BRIDGE 0x80 1038c2ecf20Sopenharmony_ci 1048c2ecf20Sopenharmony_ci/* Opcode is supported by Altivec Vector Unit */ 1058c2ecf20Sopenharmony_ci#define PPC_OPCODE_ALTIVEC 0x100 1068c2ecf20Sopenharmony_ci 1078c2ecf20Sopenharmony_ci/* Opcode is supported by PowerPC 403 processor. */ 1088c2ecf20Sopenharmony_ci#define PPC_OPCODE_403 0x200 1098c2ecf20Sopenharmony_ci 1108c2ecf20Sopenharmony_ci/* Opcode is supported by PowerPC BookE processor. */ 1118c2ecf20Sopenharmony_ci#define PPC_OPCODE_BOOKE 0x400 1128c2ecf20Sopenharmony_ci 1138c2ecf20Sopenharmony_ci/* Opcode is supported by PowerPC 440 processor. */ 1148c2ecf20Sopenharmony_ci#define PPC_OPCODE_440 0x800 1158c2ecf20Sopenharmony_ci 1168c2ecf20Sopenharmony_ci/* Opcode is only supported by Power4 architecture. */ 1178c2ecf20Sopenharmony_ci#define PPC_OPCODE_POWER4 0x1000 1188c2ecf20Sopenharmony_ci 1198c2ecf20Sopenharmony_ci/* Opcode is only supported by Power7 architecture. */ 1208c2ecf20Sopenharmony_ci#define PPC_OPCODE_POWER7 0x2000 1218c2ecf20Sopenharmony_ci 1228c2ecf20Sopenharmony_ci/* Opcode is only supported by e500x2 Core. */ 1238c2ecf20Sopenharmony_ci#define PPC_OPCODE_SPE 0x4000 1248c2ecf20Sopenharmony_ci 1258c2ecf20Sopenharmony_ci/* Opcode is supported by e500x2 Integer select APU. */ 1268c2ecf20Sopenharmony_ci#define PPC_OPCODE_ISEL 0x8000 1278c2ecf20Sopenharmony_ci 1288c2ecf20Sopenharmony_ci/* Opcode is an e500 SPE floating point instruction. */ 1298c2ecf20Sopenharmony_ci#define PPC_OPCODE_EFS 0x10000 1308c2ecf20Sopenharmony_ci 1318c2ecf20Sopenharmony_ci/* Opcode is supported by branch locking APU. */ 1328c2ecf20Sopenharmony_ci#define PPC_OPCODE_BRLOCK 0x20000 1338c2ecf20Sopenharmony_ci 1348c2ecf20Sopenharmony_ci/* Opcode is supported by performance monitor APU. */ 1358c2ecf20Sopenharmony_ci#define PPC_OPCODE_PMR 0x40000 1368c2ecf20Sopenharmony_ci 1378c2ecf20Sopenharmony_ci/* Opcode is supported by cache locking APU. */ 1388c2ecf20Sopenharmony_ci#define PPC_OPCODE_CACHELCK 0x80000 1398c2ecf20Sopenharmony_ci 1408c2ecf20Sopenharmony_ci/* Opcode is supported by machine check APU. */ 1418c2ecf20Sopenharmony_ci#define PPC_OPCODE_RFMCI 0x100000 1428c2ecf20Sopenharmony_ci 1438c2ecf20Sopenharmony_ci/* Opcode is only supported by Power5 architecture. */ 1448c2ecf20Sopenharmony_ci#define PPC_OPCODE_POWER5 0x200000 1458c2ecf20Sopenharmony_ci 1468c2ecf20Sopenharmony_ci/* Opcode is supported by PowerPC e300 family. */ 1478c2ecf20Sopenharmony_ci#define PPC_OPCODE_E300 0x400000 1488c2ecf20Sopenharmony_ci 1498c2ecf20Sopenharmony_ci/* Opcode is only supported by Power6 architecture. */ 1508c2ecf20Sopenharmony_ci#define PPC_OPCODE_POWER6 0x800000 1518c2ecf20Sopenharmony_ci 1528c2ecf20Sopenharmony_ci/* Opcode is only supported by PowerPC Cell family. */ 1538c2ecf20Sopenharmony_ci#define PPC_OPCODE_CELL 0x1000000 1548c2ecf20Sopenharmony_ci 1558c2ecf20Sopenharmony_ci/* Opcode is supported by CPUs with paired singles support. */ 1568c2ecf20Sopenharmony_ci#define PPC_OPCODE_PPCPS 0x2000000 1578c2ecf20Sopenharmony_ci 1588c2ecf20Sopenharmony_ci/* Opcode is supported by Power E500MC */ 1598c2ecf20Sopenharmony_ci#define PPC_OPCODE_E500MC 0x4000000 1608c2ecf20Sopenharmony_ci 1618c2ecf20Sopenharmony_ci/* Opcode is supported by PowerPC 405 processor. */ 1628c2ecf20Sopenharmony_ci#define PPC_OPCODE_405 0x8000000 1638c2ecf20Sopenharmony_ci 1648c2ecf20Sopenharmony_ci/* Opcode is supported by Vector-Scalar (VSX) Unit */ 1658c2ecf20Sopenharmony_ci#define PPC_OPCODE_VSX 0x10000000 1668c2ecf20Sopenharmony_ci 1678c2ecf20Sopenharmony_ci/* Opcode is supported by A2. */ 1688c2ecf20Sopenharmony_ci#define PPC_OPCODE_A2 0x20000000 1698c2ecf20Sopenharmony_ci 1708c2ecf20Sopenharmony_ci/* Opcode is supported by PowerPC 476 processor. */ 1718c2ecf20Sopenharmony_ci#define PPC_OPCODE_476 0x40000000 1728c2ecf20Sopenharmony_ci 1738c2ecf20Sopenharmony_ci/* Opcode is supported by AppliedMicro Titan core */ 1748c2ecf20Sopenharmony_ci#define PPC_OPCODE_TITAN 0x80000000 1758c2ecf20Sopenharmony_ci 1768c2ecf20Sopenharmony_ci/* Opcode which is supported by the e500 family */ 1778c2ecf20Sopenharmony_ci#define PPC_OPCODE_E500 0x100000000ull 1788c2ecf20Sopenharmony_ci 1798c2ecf20Sopenharmony_ci/* Opcode is supported by Extended Altivec Vector Unit */ 1808c2ecf20Sopenharmony_ci#define PPC_OPCODE_ALTIVEC2 0x200000000ull 1818c2ecf20Sopenharmony_ci 1828c2ecf20Sopenharmony_ci/* Opcode is supported by Power E6500 */ 1838c2ecf20Sopenharmony_ci#define PPC_OPCODE_E6500 0x400000000ull 1848c2ecf20Sopenharmony_ci 1858c2ecf20Sopenharmony_ci/* Opcode is supported by Thread management APU */ 1868c2ecf20Sopenharmony_ci#define PPC_OPCODE_TMR 0x800000000ull 1878c2ecf20Sopenharmony_ci 1888c2ecf20Sopenharmony_ci/* Opcode which is supported by the VLE extension. */ 1898c2ecf20Sopenharmony_ci#define PPC_OPCODE_VLE 0x1000000000ull 1908c2ecf20Sopenharmony_ci 1918c2ecf20Sopenharmony_ci/* Opcode is only supported by Power8 architecture. */ 1928c2ecf20Sopenharmony_ci#define PPC_OPCODE_POWER8 0x2000000000ull 1938c2ecf20Sopenharmony_ci 1948c2ecf20Sopenharmony_ci/* Opcode which is supported by the Hardware Transactional Memory extension. */ 1958c2ecf20Sopenharmony_ci/* Currently, this is the same as the POWER8 mask. If another cpu comes out 1968c2ecf20Sopenharmony_ci that isn't a superset of POWER8, we can define this to its own mask. */ 1978c2ecf20Sopenharmony_ci#define PPC_OPCODE_HTM PPC_OPCODE_POWER8 1988c2ecf20Sopenharmony_ci 1998c2ecf20Sopenharmony_ci/* Opcode is supported by ppc750cl. */ 2008c2ecf20Sopenharmony_ci#define PPC_OPCODE_750 0x4000000000ull 2018c2ecf20Sopenharmony_ci 2028c2ecf20Sopenharmony_ci/* Opcode is supported by ppc7450. */ 2038c2ecf20Sopenharmony_ci#define PPC_OPCODE_7450 0x8000000000ull 2048c2ecf20Sopenharmony_ci 2058c2ecf20Sopenharmony_ci/* Opcode is supported by ppc821/850/860. */ 2068c2ecf20Sopenharmony_ci#define PPC_OPCODE_860 0x10000000000ull 2078c2ecf20Sopenharmony_ci 2088c2ecf20Sopenharmony_ci/* Opcode is only supported by Power9 architecture. */ 2098c2ecf20Sopenharmony_ci#define PPC_OPCODE_POWER9 0x20000000000ull 2108c2ecf20Sopenharmony_ci 2118c2ecf20Sopenharmony_ci/* Opcode is supported by Vector-Scalar (VSX) Unit from ISA 2.08. */ 2128c2ecf20Sopenharmony_ci#define PPC_OPCODE_VSX3 0x40000000000ull 2138c2ecf20Sopenharmony_ci 2148c2ecf20Sopenharmony_ci /* Opcode is supported by e200z4. */ 2158c2ecf20Sopenharmony_ci#define PPC_OPCODE_E200Z4 0x80000000000ull 2168c2ecf20Sopenharmony_ci 2178c2ecf20Sopenharmony_ci/* A macro to extract the major opcode from an instruction. */ 2188c2ecf20Sopenharmony_ci#define PPC_OP(i) (((i) >> 26) & 0x3f) 2198c2ecf20Sopenharmony_ci 2208c2ecf20Sopenharmony_ci/* A macro to determine if the instruction is a 2-byte VLE insn. */ 2218c2ecf20Sopenharmony_ci#define PPC_OP_SE_VLE(m) ((m) <= 0xffff) 2228c2ecf20Sopenharmony_ci 2238c2ecf20Sopenharmony_ci/* A macro to extract the major opcode from a VLE instruction. */ 2248c2ecf20Sopenharmony_ci#define VLE_OP(i,m) (((i) >> ((m) <= 0xffff ? 10 : 26)) & 0x3f) 2258c2ecf20Sopenharmony_ci 2268c2ecf20Sopenharmony_ci/* A macro to convert a VLE opcode to a VLE opcode segment. */ 2278c2ecf20Sopenharmony_ci#define VLE_OP_TO_SEG(i) ((i) >> 1) 2288c2ecf20Sopenharmony_ci 2298c2ecf20Sopenharmony_ci/* The operands table is an array of struct powerpc_operand. */ 2308c2ecf20Sopenharmony_ci 2318c2ecf20Sopenharmony_cistruct powerpc_operand 2328c2ecf20Sopenharmony_ci{ 2338c2ecf20Sopenharmony_ci /* A bitmask of bits in the operand. */ 2348c2ecf20Sopenharmony_ci unsigned int bitm; 2358c2ecf20Sopenharmony_ci 2368c2ecf20Sopenharmony_ci /* The shift operation to be applied to the operand. No shift 2378c2ecf20Sopenharmony_ci is made if this is zero. For positive values, the operand 2388c2ecf20Sopenharmony_ci is shifted left by SHIFT. For negative values, the operand 2398c2ecf20Sopenharmony_ci is shifted right by -SHIFT. Use PPC_OPSHIFT_INV to indicate 2408c2ecf20Sopenharmony_ci that BITM and SHIFT cannot be used to determine where the 2418c2ecf20Sopenharmony_ci operand goes in the insn. */ 2428c2ecf20Sopenharmony_ci int shift; 2438c2ecf20Sopenharmony_ci 2448c2ecf20Sopenharmony_ci /* Insertion function. This is used by the assembler. To insert an 2458c2ecf20Sopenharmony_ci operand value into an instruction, check this field. 2468c2ecf20Sopenharmony_ci 2478c2ecf20Sopenharmony_ci If it is NULL, execute 2488c2ecf20Sopenharmony_ci if (o->shift >= 0) 2498c2ecf20Sopenharmony_ci i |= (op & o->bitm) << o->shift; 2508c2ecf20Sopenharmony_ci else 2518c2ecf20Sopenharmony_ci i |= (op & o->bitm) >> -o->shift; 2528c2ecf20Sopenharmony_ci (i is the instruction which we are filling in, o is a pointer to 2538c2ecf20Sopenharmony_ci this structure, and op is the operand value). 2548c2ecf20Sopenharmony_ci 2558c2ecf20Sopenharmony_ci If this field is not NULL, then simply call it with the 2568c2ecf20Sopenharmony_ci instruction and the operand value. It will return the new value 2578c2ecf20Sopenharmony_ci of the instruction. If the ERRMSG argument is not NULL, then if 2588c2ecf20Sopenharmony_ci the operand value is illegal, *ERRMSG will be set to a warning 2598c2ecf20Sopenharmony_ci string (the operand will be inserted in any case). If the 2608c2ecf20Sopenharmony_ci operand value is legal, *ERRMSG will be unchanged (most operands 2618c2ecf20Sopenharmony_ci can accept any value). */ 2628c2ecf20Sopenharmony_ci unsigned long (*insert) 2638c2ecf20Sopenharmony_ci (unsigned long instruction, long op, ppc_cpu_t dialect, const char **errmsg); 2648c2ecf20Sopenharmony_ci 2658c2ecf20Sopenharmony_ci /* Extraction function. This is used by the disassembler. To 2668c2ecf20Sopenharmony_ci extract this operand type from an instruction, check this field. 2678c2ecf20Sopenharmony_ci 2688c2ecf20Sopenharmony_ci If it is NULL, compute 2698c2ecf20Sopenharmony_ci if (o->shift >= 0) 2708c2ecf20Sopenharmony_ci op = (i >> o->shift) & o->bitm; 2718c2ecf20Sopenharmony_ci else 2728c2ecf20Sopenharmony_ci op = (i << -o->shift) & o->bitm; 2738c2ecf20Sopenharmony_ci if ((o->flags & PPC_OPERAND_SIGNED) != 0) 2748c2ecf20Sopenharmony_ci sign_extend (op); 2758c2ecf20Sopenharmony_ci (i is the instruction, o is a pointer to this structure, and op 2768c2ecf20Sopenharmony_ci is the result). 2778c2ecf20Sopenharmony_ci 2788c2ecf20Sopenharmony_ci If this field is not NULL, then simply call it with the 2798c2ecf20Sopenharmony_ci instruction value. It will return the value of the operand. If 2808c2ecf20Sopenharmony_ci the INVALID argument is not NULL, *INVALID will be set to 2818c2ecf20Sopenharmony_ci non-zero if this operand type can not actually be extracted from 2828c2ecf20Sopenharmony_ci this operand (i.e., the instruction does not match). If the 2838c2ecf20Sopenharmony_ci operand is valid, *INVALID will not be changed. */ 2848c2ecf20Sopenharmony_ci long (*extract) (unsigned long instruction, ppc_cpu_t dialect, int *invalid); 2858c2ecf20Sopenharmony_ci 2868c2ecf20Sopenharmony_ci /* One bit syntax flags. */ 2878c2ecf20Sopenharmony_ci unsigned long flags; 2888c2ecf20Sopenharmony_ci}; 2898c2ecf20Sopenharmony_ci 2908c2ecf20Sopenharmony_ci/* Elements in the table are retrieved by indexing with values from 2918c2ecf20Sopenharmony_ci the operands field of the powerpc_opcodes table. */ 2928c2ecf20Sopenharmony_ci 2938c2ecf20Sopenharmony_ciextern const struct powerpc_operand powerpc_operands[]; 2948c2ecf20Sopenharmony_ciextern const unsigned int num_powerpc_operands; 2958c2ecf20Sopenharmony_ci 2968c2ecf20Sopenharmony_ci/* Use with the shift field of a struct powerpc_operand to indicate 2978c2ecf20Sopenharmony_ci that BITM and SHIFT cannot be used to determine where the operand 2988c2ecf20Sopenharmony_ci goes in the insn. */ 2998c2ecf20Sopenharmony_ci#define PPC_OPSHIFT_INV (-1U << 31) 3008c2ecf20Sopenharmony_ci 3018c2ecf20Sopenharmony_ci/* Values defined for the flags field of a struct powerpc_operand. */ 3028c2ecf20Sopenharmony_ci 3038c2ecf20Sopenharmony_ci/* This operand takes signed values. */ 3048c2ecf20Sopenharmony_ci#define PPC_OPERAND_SIGNED (0x1) 3058c2ecf20Sopenharmony_ci 3068c2ecf20Sopenharmony_ci/* This operand takes signed values, but also accepts a full positive 3078c2ecf20Sopenharmony_ci range of values when running in 32 bit mode. That is, if bits is 3088c2ecf20Sopenharmony_ci 16, it takes any value from -0x8000 to 0xffff. In 64 bit mode, 3098c2ecf20Sopenharmony_ci this flag is ignored. */ 3108c2ecf20Sopenharmony_ci#define PPC_OPERAND_SIGNOPT (0x2) 3118c2ecf20Sopenharmony_ci 3128c2ecf20Sopenharmony_ci/* This operand does not actually exist in the assembler input. This 3138c2ecf20Sopenharmony_ci is used to support extended mnemonics such as mr, for which two 3148c2ecf20Sopenharmony_ci operands fields are identical. The assembler should call the 3158c2ecf20Sopenharmony_ci insert function with any op value. The disassembler should call 3168c2ecf20Sopenharmony_ci the extract function, ignore the return value, and check the value 3178c2ecf20Sopenharmony_ci placed in the valid argument. */ 3188c2ecf20Sopenharmony_ci#define PPC_OPERAND_FAKE (0x4) 3198c2ecf20Sopenharmony_ci 3208c2ecf20Sopenharmony_ci/* The next operand should be wrapped in parentheses rather than 3218c2ecf20Sopenharmony_ci separated from this one by a comma. This is used for the load and 3228c2ecf20Sopenharmony_ci store instructions which want their operands to look like 3238c2ecf20Sopenharmony_ci reg,displacement(reg) 3248c2ecf20Sopenharmony_ci */ 3258c2ecf20Sopenharmony_ci#define PPC_OPERAND_PARENS (0x8) 3268c2ecf20Sopenharmony_ci 3278c2ecf20Sopenharmony_ci/* This operand may use the symbolic names for the CR fields, which 3288c2ecf20Sopenharmony_ci are 3298c2ecf20Sopenharmony_ci lt 0 gt 1 eq 2 so 3 un 3 3308c2ecf20Sopenharmony_ci cr0 0 cr1 1 cr2 2 cr3 3 3318c2ecf20Sopenharmony_ci cr4 4 cr5 5 cr6 6 cr7 7 3328c2ecf20Sopenharmony_ci These may be combined arithmetically, as in cr2*4+gt. These are 3338c2ecf20Sopenharmony_ci only supported on the PowerPC, not the POWER. */ 3348c2ecf20Sopenharmony_ci#define PPC_OPERAND_CR_BIT (0x10) 3358c2ecf20Sopenharmony_ci 3368c2ecf20Sopenharmony_ci/* This operand names a register. The disassembler uses this to print 3378c2ecf20Sopenharmony_ci register names with a leading 'r'. */ 3388c2ecf20Sopenharmony_ci#define PPC_OPERAND_GPR (0x20) 3398c2ecf20Sopenharmony_ci 3408c2ecf20Sopenharmony_ci/* Like PPC_OPERAND_GPR, but don't print a leading 'r' for r0. */ 3418c2ecf20Sopenharmony_ci#define PPC_OPERAND_GPR_0 (0x40) 3428c2ecf20Sopenharmony_ci 3438c2ecf20Sopenharmony_ci/* This operand names a floating point register. The disassembler 3448c2ecf20Sopenharmony_ci prints these with a leading 'f'. */ 3458c2ecf20Sopenharmony_ci#define PPC_OPERAND_FPR (0x80) 3468c2ecf20Sopenharmony_ci 3478c2ecf20Sopenharmony_ci/* This operand is a relative branch displacement. The disassembler 3488c2ecf20Sopenharmony_ci prints these symbolically if possible. */ 3498c2ecf20Sopenharmony_ci#define PPC_OPERAND_RELATIVE (0x100) 3508c2ecf20Sopenharmony_ci 3518c2ecf20Sopenharmony_ci/* This operand is an absolute branch address. The disassembler 3528c2ecf20Sopenharmony_ci prints these symbolically if possible. */ 3538c2ecf20Sopenharmony_ci#define PPC_OPERAND_ABSOLUTE (0x200) 3548c2ecf20Sopenharmony_ci 3558c2ecf20Sopenharmony_ci/* This operand is optional, and is zero if omitted. This is used for 3568c2ecf20Sopenharmony_ci example, in the optional BF field in the comparison instructions. The 3578c2ecf20Sopenharmony_ci assembler must count the number of operands remaining on the line, 3588c2ecf20Sopenharmony_ci and the number of operands remaining for the opcode, and decide 3598c2ecf20Sopenharmony_ci whether this operand is present or not. The disassembler should 3608c2ecf20Sopenharmony_ci print this operand out only if it is not zero. */ 3618c2ecf20Sopenharmony_ci#define PPC_OPERAND_OPTIONAL (0x400) 3628c2ecf20Sopenharmony_ci 3638c2ecf20Sopenharmony_ci/* This flag is only used with PPC_OPERAND_OPTIONAL. If this operand 3648c2ecf20Sopenharmony_ci is omitted, then for the next operand use this operand value plus 3658c2ecf20Sopenharmony_ci 1, ignoring the next operand field for the opcode. This wretched 3668c2ecf20Sopenharmony_ci hack is needed because the Power rotate instructions can take 3678c2ecf20Sopenharmony_ci either 4 or 5 operands. The disassembler should print this operand 3688c2ecf20Sopenharmony_ci out regardless of the PPC_OPERAND_OPTIONAL field. */ 3698c2ecf20Sopenharmony_ci#define PPC_OPERAND_NEXT (0x800) 3708c2ecf20Sopenharmony_ci 3718c2ecf20Sopenharmony_ci/* This operand should be regarded as a negative number for the 3728c2ecf20Sopenharmony_ci purposes of overflow checking (i.e., the normal most negative 3738c2ecf20Sopenharmony_ci number is disallowed and one more than the normal most positive 3748c2ecf20Sopenharmony_ci number is allowed). This flag will only be set for a signed 3758c2ecf20Sopenharmony_ci operand. */ 3768c2ecf20Sopenharmony_ci#define PPC_OPERAND_NEGATIVE (0x1000) 3778c2ecf20Sopenharmony_ci 3788c2ecf20Sopenharmony_ci/* This operand names a vector unit register. The disassembler 3798c2ecf20Sopenharmony_ci prints these with a leading 'v'. */ 3808c2ecf20Sopenharmony_ci#define PPC_OPERAND_VR (0x2000) 3818c2ecf20Sopenharmony_ci 3828c2ecf20Sopenharmony_ci/* This operand is for the DS field in a DS form instruction. */ 3838c2ecf20Sopenharmony_ci#define PPC_OPERAND_DS (0x4000) 3848c2ecf20Sopenharmony_ci 3858c2ecf20Sopenharmony_ci/* This operand is for the DQ field in a DQ form instruction. */ 3868c2ecf20Sopenharmony_ci#define PPC_OPERAND_DQ (0x8000) 3878c2ecf20Sopenharmony_ci 3888c2ecf20Sopenharmony_ci/* Valid range of operand is 0..n rather than 0..n-1. */ 3898c2ecf20Sopenharmony_ci#define PPC_OPERAND_PLUS1 (0x10000) 3908c2ecf20Sopenharmony_ci 3918c2ecf20Sopenharmony_ci/* Xilinx APU and FSL related operands */ 3928c2ecf20Sopenharmony_ci#define PPC_OPERAND_FSL (0x20000) 3938c2ecf20Sopenharmony_ci#define PPC_OPERAND_FCR (0x40000) 3948c2ecf20Sopenharmony_ci#define PPC_OPERAND_UDI (0x80000) 3958c2ecf20Sopenharmony_ci 3968c2ecf20Sopenharmony_ci/* This operand names a vector-scalar unit register. The disassembler 3978c2ecf20Sopenharmony_ci prints these with a leading 'vs'. */ 3988c2ecf20Sopenharmony_ci#define PPC_OPERAND_VSR (0x100000) 3998c2ecf20Sopenharmony_ci 4008c2ecf20Sopenharmony_ci/* This is a CR FIELD that does not use symbolic names. */ 4018c2ecf20Sopenharmony_ci#define PPC_OPERAND_CR_REG (0x200000) 4028c2ecf20Sopenharmony_ci 4038c2ecf20Sopenharmony_ci/* This flag is only used with PPC_OPERAND_OPTIONAL. If this operand 4048c2ecf20Sopenharmony_ci is omitted, then the value it should use for the operand is stored 4058c2ecf20Sopenharmony_ci in the SHIFT field of the immediatly following operand field. */ 4068c2ecf20Sopenharmony_ci#define PPC_OPERAND_OPTIONAL_VALUE (0x400000) 4078c2ecf20Sopenharmony_ci 4088c2ecf20Sopenharmony_ci/* This flag is only used with PPC_OPERAND_OPTIONAL. The operand is 4098c2ecf20Sopenharmony_ci only optional when generating 32-bit code. */ 4108c2ecf20Sopenharmony_ci#define PPC_OPERAND_OPTIONAL32 (0x800000) 4118c2ecf20Sopenharmony_ci 4128c2ecf20Sopenharmony_ci/* The POWER and PowerPC assemblers use a few macros. We keep them 4138c2ecf20Sopenharmony_ci with the operands table for simplicity. The macro table is an 4148c2ecf20Sopenharmony_ci array of struct powerpc_macro. */ 4158c2ecf20Sopenharmony_ci 4168c2ecf20Sopenharmony_cistruct powerpc_macro 4178c2ecf20Sopenharmony_ci{ 4188c2ecf20Sopenharmony_ci /* The macro name. */ 4198c2ecf20Sopenharmony_ci const char *name; 4208c2ecf20Sopenharmony_ci 4218c2ecf20Sopenharmony_ci /* The number of operands the macro takes. */ 4228c2ecf20Sopenharmony_ci unsigned int operands; 4238c2ecf20Sopenharmony_ci 4248c2ecf20Sopenharmony_ci /* One bit flags for the opcode. These are used to indicate which 4258c2ecf20Sopenharmony_ci specific processors support the instructions. The values are the 4268c2ecf20Sopenharmony_ci same as those for the struct powerpc_opcode flags field. */ 4278c2ecf20Sopenharmony_ci ppc_cpu_t flags; 4288c2ecf20Sopenharmony_ci 4298c2ecf20Sopenharmony_ci /* A format string to turn the macro into a normal instruction. 4308c2ecf20Sopenharmony_ci Each %N in the string is replaced with operand number N (zero 4318c2ecf20Sopenharmony_ci based). */ 4328c2ecf20Sopenharmony_ci const char *format; 4338c2ecf20Sopenharmony_ci}; 4348c2ecf20Sopenharmony_ci 4358c2ecf20Sopenharmony_ciextern const struct powerpc_macro powerpc_macros[]; 4368c2ecf20Sopenharmony_ciextern const int powerpc_num_macros; 4378c2ecf20Sopenharmony_ci 4388c2ecf20Sopenharmony_ciextern ppc_cpu_t ppc_parse_cpu (ppc_cpu_t, ppc_cpu_t *, const char *); 4398c2ecf20Sopenharmony_ci 4408c2ecf20Sopenharmony_cistatic inline long 4418c2ecf20Sopenharmony_cippc_optional_operand_value (const struct powerpc_operand *operand) 4428c2ecf20Sopenharmony_ci{ 4438c2ecf20Sopenharmony_ci if ((operand->flags & PPC_OPERAND_OPTIONAL_VALUE) != 0) 4448c2ecf20Sopenharmony_ci return (operand+1)->shift; 4458c2ecf20Sopenharmony_ci return 0; 4468c2ecf20Sopenharmony_ci} 4478c2ecf20Sopenharmony_ci 4488c2ecf20Sopenharmony_ci#ifdef __cplusplus 4498c2ecf20Sopenharmony_ci} 4508c2ecf20Sopenharmony_ci#endif 4518c2ecf20Sopenharmony_ci 4528c2ecf20Sopenharmony_ci#endif /* PPC_H */ 453