xref: /openbmc/linux/arch/powerpc/xmon/ppc.h (revision 4f2c0a4acffbec01079c28f839422e64ddeff004)
1f78541dcSPaul Mackerras /* ppc.h -- Header file for PowerPC opcode table
2*08d96e0bSBalbir Singh    Copyright (C) 1994-2016 Free Software Foundation, Inc.
3f78541dcSPaul Mackerras    Written by Ian Lance Taylor, Cygnus Support
4f78541dcSPaul Mackerras 
5f78541dcSPaul Mackerras This file is part of GDB, GAS, and the GNU binutils.
6f78541dcSPaul Mackerras 
7f78541dcSPaul Mackerras GDB, GAS, and the GNU binutils are free software; you can redistribute
8f78541dcSPaul Mackerras them and/or modify them under the terms of the GNU General Public
9f78541dcSPaul Mackerras License as published by the Free Software Foundation; either version
10f78541dcSPaul Mackerras 1, or (at your option) any later version.
11f78541dcSPaul Mackerras 
12f78541dcSPaul Mackerras GDB, GAS, and the GNU binutils are distributed in the hope that they
13f78541dcSPaul Mackerras will be useful, but WITHOUT ANY WARRANTY; without even the implied
14f78541dcSPaul Mackerras warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
15f78541dcSPaul Mackerras the GNU General Public License for more details.
16f78541dcSPaul Mackerras 
17f78541dcSPaul Mackerras You should have received a copy of the GNU General Public License
18f78541dcSPaul Mackerras along with this file; see the file COPYING.  If not, write to the Free
19897f112bSMichael Ellerman Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.  */
20f78541dcSPaul Mackerras 
21f78541dcSPaul Mackerras #ifndef PPC_H
22f78541dcSPaul Mackerras #define PPC_H
23f78541dcSPaul Mackerras 
24*08d96e0bSBalbir Singh #ifdef __cplusplus
25*08d96e0bSBalbir Singh extern "C" {
26*08d96e0bSBalbir Singh #endif
27*08d96e0bSBalbir Singh 
28*08d96e0bSBalbir Singh typedef uint64_t ppc_cpu_t;
29*08d96e0bSBalbir Singh 
30f78541dcSPaul Mackerras /* The opcode table is an array of struct powerpc_opcode.  */
31f78541dcSPaul Mackerras 
32f78541dcSPaul Mackerras struct powerpc_opcode
33f78541dcSPaul Mackerras {
34f78541dcSPaul Mackerras   /* The opcode name.  */
35f78541dcSPaul Mackerras   const char *name;
36f78541dcSPaul Mackerras 
37f78541dcSPaul Mackerras   /* The opcode itself.  Those bits which will be filled in with
38f78541dcSPaul Mackerras      operands are zeroes.  */
39f78541dcSPaul Mackerras   unsigned long opcode;
40f78541dcSPaul Mackerras 
41f78541dcSPaul Mackerras   /* The opcode mask.  This is used by the disassembler.  This is a
42f78541dcSPaul Mackerras      mask containing ones indicating those bits which must match the
43f78541dcSPaul Mackerras      opcode field, and zeroes indicating those bits which need not
44f78541dcSPaul Mackerras      match (and are presumably filled in by operands).  */
45f78541dcSPaul Mackerras   unsigned long mask;
46f78541dcSPaul Mackerras 
47f78541dcSPaul Mackerras   /* One bit flags for the opcode.  These are used to indicate which
48f78541dcSPaul Mackerras      specific processors support the instructions.  The defined values
49f78541dcSPaul Mackerras      are listed below.  */
50*08d96e0bSBalbir Singh   ppc_cpu_t flags;
51*08d96e0bSBalbir Singh 
52*08d96e0bSBalbir Singh   /* One bit flags for the opcode.  These are used to indicate which
53*08d96e0bSBalbir Singh      specific processors no longer support the instructions.  The defined
54*08d96e0bSBalbir Singh      values are listed below.  */
55*08d96e0bSBalbir Singh   ppc_cpu_t deprecated;
56f78541dcSPaul Mackerras 
57f78541dcSPaul Mackerras   /* An array of operand codes.  Each code is an index into the
58f78541dcSPaul Mackerras      operand table.  They appear in the order which the operands must
59f78541dcSPaul Mackerras      appear in assembly code, and are terminated by a zero.  */
60f78541dcSPaul Mackerras   unsigned char operands[8];
61f78541dcSPaul Mackerras };
62f78541dcSPaul Mackerras 
63f78541dcSPaul Mackerras /* The table itself is sorted by major opcode number, and is otherwise
64f78541dcSPaul Mackerras    in the order in which the disassembler should consider
65f78541dcSPaul Mackerras    instructions.  */
66f78541dcSPaul Mackerras extern const struct powerpc_opcode powerpc_opcodes[];
67f78541dcSPaul Mackerras extern const int powerpc_num_opcodes;
68*08d96e0bSBalbir Singh extern const struct powerpc_opcode vle_opcodes[];
69*08d96e0bSBalbir Singh extern const int vle_num_opcodes;
70f78541dcSPaul Mackerras 
71f78541dcSPaul Mackerras /* Values defined for the flags field of a struct powerpc_opcode.  */
72f78541dcSPaul Mackerras 
73f78541dcSPaul Mackerras /* Opcode is defined for the PowerPC architecture.  */
74f78541dcSPaul Mackerras #define PPC_OPCODE_PPC			 1
75f78541dcSPaul Mackerras 
76f78541dcSPaul Mackerras /* Opcode is defined for the POWER (RS/6000) architecture.  */
77f78541dcSPaul Mackerras #define PPC_OPCODE_POWER		 2
78f78541dcSPaul Mackerras 
79f78541dcSPaul Mackerras /* Opcode is defined for the POWER2 (Rios 2) architecture.  */
80f78541dcSPaul Mackerras #define PPC_OPCODE_POWER2		 4
81f78541dcSPaul Mackerras 
82f78541dcSPaul Mackerras /* Opcode is supported by the Motorola PowerPC 601 processor.  The 601
83f78541dcSPaul Mackerras    is assumed to support all PowerPC (PPC_OPCODE_PPC) instructions,
84f78541dcSPaul Mackerras    but it also supports many additional POWER instructions.  */
85*08d96e0bSBalbir Singh #define PPC_OPCODE_601			 8
86f78541dcSPaul Mackerras 
87f78541dcSPaul Mackerras /* Opcode is supported in both the Power and PowerPC architectures
88*08d96e0bSBalbir Singh    (ie, compiler's -mcpu=common or assembler's -mcom).  More than just
89*08d96e0bSBalbir Singh    the intersection of PPC_OPCODE_PPC with the union of PPC_OPCODE_POWER
90*08d96e0bSBalbir Singh    and PPC_OPCODE_POWER2 because many instructions changed mnemonics
91*08d96e0bSBalbir Singh    between POWER and POWERPC.  */
92*08d96e0bSBalbir Singh #define PPC_OPCODE_COMMON	      0x10
93f78541dcSPaul Mackerras 
94f78541dcSPaul Mackerras /* Opcode is supported for any Power or PowerPC platform (this is
95f78541dcSPaul Mackerras    for the assembler's -many option, and it eliminates duplicates).  */
96*08d96e0bSBalbir Singh #define PPC_OPCODE_ANY		      0x20
97*08d96e0bSBalbir Singh 
98*08d96e0bSBalbir Singh /* Opcode is only defined on 64 bit architectures.  */
99*08d96e0bSBalbir Singh #define PPC_OPCODE_64		      0x40
100f78541dcSPaul Mackerras 
101f78541dcSPaul Mackerras /* Opcode is supported as part of the 64-bit bridge.  */
102*08d96e0bSBalbir Singh #define PPC_OPCODE_64_BRIDGE	      0x80
103f78541dcSPaul Mackerras 
104f78541dcSPaul Mackerras /* Opcode is supported by Altivec Vector Unit */
105*08d96e0bSBalbir Singh #define PPC_OPCODE_ALTIVEC	     0x100
106f78541dcSPaul Mackerras 
107f78541dcSPaul Mackerras /* Opcode is supported by PowerPC 403 processor.  */
108*08d96e0bSBalbir Singh #define PPC_OPCODE_403		     0x200
109f78541dcSPaul Mackerras 
110f78541dcSPaul Mackerras /* Opcode is supported by PowerPC BookE processor.  */
111*08d96e0bSBalbir Singh #define PPC_OPCODE_BOOKE	     0x400
112f78541dcSPaul Mackerras 
113f78541dcSPaul Mackerras /* Opcode is supported by PowerPC 440 processor.  */
114*08d96e0bSBalbir Singh #define PPC_OPCODE_440		     0x800
115f78541dcSPaul Mackerras 
116f78541dcSPaul Mackerras /* Opcode is only supported by Power4 architecture.  */
117*08d96e0bSBalbir Singh #define PPC_OPCODE_POWER4	    0x1000
118f78541dcSPaul Mackerras 
119*08d96e0bSBalbir Singh /* Opcode is only supported by Power7 architecture.  */
120*08d96e0bSBalbir Singh #define PPC_OPCODE_POWER7	    0x2000
121f78541dcSPaul Mackerras 
122f78541dcSPaul Mackerras /* Opcode is only supported by e500x2 Core.  */
123*08d96e0bSBalbir Singh #define PPC_OPCODE_SPE		    0x4000
124f78541dcSPaul Mackerras 
125f78541dcSPaul Mackerras /* Opcode is supported by e500x2 Integer select APU.  */
126*08d96e0bSBalbir Singh #define PPC_OPCODE_ISEL		    0x8000
127f78541dcSPaul Mackerras 
128f78541dcSPaul Mackerras /* Opcode is an e500 SPE floating point instruction.  */
129*08d96e0bSBalbir Singh #define PPC_OPCODE_EFS		   0x10000
130f78541dcSPaul Mackerras 
131f78541dcSPaul Mackerras /* Opcode is supported by branch locking APU.  */
132*08d96e0bSBalbir Singh #define PPC_OPCODE_BRLOCK	   0x20000
133f78541dcSPaul Mackerras 
134f78541dcSPaul Mackerras /* Opcode is supported by performance monitor APU.  */
135*08d96e0bSBalbir Singh #define PPC_OPCODE_PMR		   0x40000
136f78541dcSPaul Mackerras 
137f78541dcSPaul Mackerras /* Opcode is supported by cache locking APU.  */
138*08d96e0bSBalbir Singh #define PPC_OPCODE_CACHELCK	   0x80000
139f78541dcSPaul Mackerras 
140f78541dcSPaul Mackerras /* Opcode is supported by machine check APU.  */
141*08d96e0bSBalbir Singh #define PPC_OPCODE_RFMCI	  0x100000
142f78541dcSPaul Mackerras 
143897f112bSMichael Ellerman /* Opcode is only supported by Power5 architecture.  */
144*08d96e0bSBalbir Singh #define PPC_OPCODE_POWER5	  0x200000
145897f112bSMichael Ellerman 
146897f112bSMichael Ellerman /* Opcode is supported by PowerPC e300 family.  */
147*08d96e0bSBalbir Singh #define PPC_OPCODE_E300           0x400000
148897f112bSMichael Ellerman 
149897f112bSMichael Ellerman /* Opcode is only supported by Power6 architecture.  */
150*08d96e0bSBalbir Singh #define PPC_OPCODE_POWER6	  0x800000
151897f112bSMichael Ellerman 
152897f112bSMichael Ellerman /* Opcode is only supported by PowerPC Cell family.  */
153*08d96e0bSBalbir Singh #define PPC_OPCODE_CELL		 0x1000000
154*08d96e0bSBalbir Singh 
155*08d96e0bSBalbir Singh /* Opcode is supported by CPUs with paired singles support.  */
156*08d96e0bSBalbir Singh #define PPC_OPCODE_PPCPS	 0x2000000
157*08d96e0bSBalbir Singh 
158*08d96e0bSBalbir Singh /* Opcode is supported by Power E500MC */
159*08d96e0bSBalbir Singh #define PPC_OPCODE_E500MC        0x4000000
160*08d96e0bSBalbir Singh 
161*08d96e0bSBalbir Singh /* Opcode is supported by PowerPC 405 processor.  */
162*08d96e0bSBalbir Singh #define PPC_OPCODE_405		 0x8000000
163*08d96e0bSBalbir Singh 
164*08d96e0bSBalbir Singh /* Opcode is supported by Vector-Scalar (VSX) Unit */
165*08d96e0bSBalbir Singh #define PPC_OPCODE_VSX		0x10000000
166*08d96e0bSBalbir Singh 
167*08d96e0bSBalbir Singh /* Opcode is supported by A2.  */
168*08d96e0bSBalbir Singh #define PPC_OPCODE_A2	 	0x20000000
169*08d96e0bSBalbir Singh 
170*08d96e0bSBalbir Singh /* Opcode is supported by PowerPC 476 processor.  */
171*08d96e0bSBalbir Singh #define PPC_OPCODE_476		0x40000000
172*08d96e0bSBalbir Singh 
173*08d96e0bSBalbir Singh /* Opcode is supported by AppliedMicro Titan core */
174*08d96e0bSBalbir Singh #define PPC_OPCODE_TITAN        0x80000000
175*08d96e0bSBalbir Singh 
176*08d96e0bSBalbir Singh /* Opcode which is supported by the e500 family */
177*08d96e0bSBalbir Singh #define PPC_OPCODE_E500	       0x100000000ull
178*08d96e0bSBalbir Singh 
179*08d96e0bSBalbir Singh /* Opcode is supported by Extended Altivec Vector Unit */
180*08d96e0bSBalbir Singh #define PPC_OPCODE_ALTIVEC2    0x200000000ull
181*08d96e0bSBalbir Singh 
182*08d96e0bSBalbir Singh /* Opcode is supported by Power E6500 */
183*08d96e0bSBalbir Singh #define PPC_OPCODE_E6500       0x400000000ull
184*08d96e0bSBalbir Singh 
185*08d96e0bSBalbir Singh /* Opcode is supported by Thread management APU */
186*08d96e0bSBalbir Singh #define PPC_OPCODE_TMR         0x800000000ull
187*08d96e0bSBalbir Singh 
188*08d96e0bSBalbir Singh /* Opcode which is supported by the VLE extension.  */
189*08d96e0bSBalbir Singh #define PPC_OPCODE_VLE	      0x1000000000ull
190*08d96e0bSBalbir Singh 
191*08d96e0bSBalbir Singh /* Opcode is only supported by Power8 architecture.  */
192*08d96e0bSBalbir Singh #define PPC_OPCODE_POWER8     0x2000000000ull
193*08d96e0bSBalbir Singh 
194*08d96e0bSBalbir Singh /* Opcode which is supported by the Hardware Transactional Memory extension.  */
195*08d96e0bSBalbir Singh /* Currently, this is the same as the POWER8 mask.  If another cpu comes out
196*08d96e0bSBalbir Singh    that isn't a superset of POWER8, we can define this to its own mask.  */
197*08d96e0bSBalbir Singh #define PPC_OPCODE_HTM        PPC_OPCODE_POWER8
198*08d96e0bSBalbir Singh 
199*08d96e0bSBalbir Singh /* Opcode is supported by ppc750cl.  */
200*08d96e0bSBalbir Singh #define PPC_OPCODE_750	      0x4000000000ull
201*08d96e0bSBalbir Singh 
202*08d96e0bSBalbir Singh /* Opcode is supported by ppc7450.  */
203*08d96e0bSBalbir Singh #define PPC_OPCODE_7450	      0x8000000000ull
204*08d96e0bSBalbir Singh 
205*08d96e0bSBalbir Singh /* Opcode is supported by ppc821/850/860.  */
206*08d96e0bSBalbir Singh #define PPC_OPCODE_860	      0x10000000000ull
207*08d96e0bSBalbir Singh 
208*08d96e0bSBalbir Singh /* Opcode is only supported by Power9 architecture.  */
209*08d96e0bSBalbir Singh #define PPC_OPCODE_POWER9     0x20000000000ull
210*08d96e0bSBalbir Singh 
211*08d96e0bSBalbir Singh /* Opcode is supported by Vector-Scalar (VSX) Unit from ISA 2.08.  */
212*08d96e0bSBalbir Singh #define PPC_OPCODE_VSX3       0x40000000000ull
213*08d96e0bSBalbir Singh 
214*08d96e0bSBalbir Singh   /* Opcode is supported by e200z4.  */
215*08d96e0bSBalbir Singh #define PPC_OPCODE_E200Z4     0x80000000000ull
216897f112bSMichael Ellerman 
217f78541dcSPaul Mackerras /* A macro to extract the major opcode from an instruction.  */
218f78541dcSPaul Mackerras #define PPC_OP(i) (((i) >> 26) & 0x3f)
219*08d96e0bSBalbir Singh 
220*08d96e0bSBalbir Singh /* A macro to determine if the instruction is a 2-byte VLE insn.  */
221*08d96e0bSBalbir Singh #define PPC_OP_SE_VLE(m) ((m) <= 0xffff)
222*08d96e0bSBalbir Singh 
223*08d96e0bSBalbir Singh /* A macro to extract the major opcode from a VLE instruction.  */
224*08d96e0bSBalbir Singh #define VLE_OP(i,m) (((i) >> ((m) <= 0xffff ? 10 : 26)) & 0x3f)
225*08d96e0bSBalbir Singh 
226*08d96e0bSBalbir Singh /* A macro to convert a VLE opcode to a VLE opcode segment.  */
227*08d96e0bSBalbir Singh #define VLE_OP_TO_SEG(i) ((i) >> 1)
228f78541dcSPaul Mackerras 
229f78541dcSPaul Mackerras /* The operands table is an array of struct powerpc_operand.  */
230f78541dcSPaul Mackerras 
231f78541dcSPaul Mackerras struct powerpc_operand
232f78541dcSPaul Mackerras {
233cc7639ceSBalbir Singh   /* A bitmask of bits in the operand.  */
234cc7639ceSBalbir Singh   unsigned int bitm;
235f78541dcSPaul Mackerras 
236*08d96e0bSBalbir Singh   /* The shift operation to be applied to the operand.  No shift
237*08d96e0bSBalbir Singh      is made if this is zero.  For positive values, the operand
238*08d96e0bSBalbir Singh      is shifted left by SHIFT.  For negative values, the operand
239*08d96e0bSBalbir Singh      is shifted right by -SHIFT.  Use PPC_OPSHIFT_INV to indicate
240*08d96e0bSBalbir Singh      that BITM and SHIFT cannot be used to determine where the
241*08d96e0bSBalbir Singh      operand goes in the insn.  */
242f78541dcSPaul Mackerras   int shift;
243f78541dcSPaul Mackerras 
244f78541dcSPaul Mackerras   /* Insertion function.  This is used by the assembler.  To insert an
245f78541dcSPaul Mackerras      operand value into an instruction, check this field.
246f78541dcSPaul Mackerras 
247f78541dcSPaul Mackerras      If it is NULL, execute
248*08d96e0bSBalbir Singh 	 if (o->shift >= 0)
249cc7639ceSBalbir Singh 	   i |= (op & o->bitm) << o->shift;
250*08d96e0bSBalbir Singh 	 else
251*08d96e0bSBalbir Singh 	   i |= (op & o->bitm) >> -o->shift;
252f78541dcSPaul Mackerras      (i is the instruction which we are filling in, o is a pointer to
253cc7639ceSBalbir Singh      this structure, and op is the operand value).
254f78541dcSPaul Mackerras 
255f78541dcSPaul Mackerras      If this field is not NULL, then simply call it with the
256f78541dcSPaul Mackerras      instruction and the operand value.  It will return the new value
257f78541dcSPaul Mackerras      of the instruction.  If the ERRMSG argument is not NULL, then if
258f78541dcSPaul Mackerras      the operand value is illegal, *ERRMSG will be set to a warning
259f78541dcSPaul Mackerras      string (the operand will be inserted in any case).  If the
260f78541dcSPaul Mackerras      operand value is legal, *ERRMSG will be unchanged (most operands
261f78541dcSPaul Mackerras      can accept any value).  */
262f78541dcSPaul Mackerras   unsigned long (*insert)
263*08d96e0bSBalbir Singh     (unsigned long instruction, long op, ppc_cpu_t dialect, const char **errmsg);
264f78541dcSPaul Mackerras 
265f78541dcSPaul Mackerras   /* Extraction function.  This is used by the disassembler.  To
266f78541dcSPaul Mackerras      extract this operand type from an instruction, check this field.
267f78541dcSPaul Mackerras 
268f78541dcSPaul Mackerras      If it is NULL, compute
269*08d96e0bSBalbir Singh 	 if (o->shift >= 0)
270cc7639ceSBalbir Singh 	   op = (i >> o->shift) & o->bitm;
271*08d96e0bSBalbir Singh 	 else
272*08d96e0bSBalbir Singh 	   op = (i << -o->shift) & o->bitm;
273cc7639ceSBalbir Singh 	 if ((o->flags & PPC_OPERAND_SIGNED) != 0)
274cc7639ceSBalbir Singh 	   sign_extend (op);
275f78541dcSPaul Mackerras      (i is the instruction, o is a pointer to this structure, and op
276cc7639ceSBalbir Singh      is the result).
277f78541dcSPaul Mackerras 
278f78541dcSPaul Mackerras      If this field is not NULL, then simply call it with the
279f78541dcSPaul Mackerras      instruction value.  It will return the value of the operand.  If
280f78541dcSPaul Mackerras      the INVALID argument is not NULL, *INVALID will be set to
281f78541dcSPaul Mackerras      non-zero if this operand type can not actually be extracted from
282f78541dcSPaul Mackerras      this operand (i.e., the instruction does not match).  If the
283f78541dcSPaul Mackerras      operand is valid, *INVALID will not be changed.  */
284*08d96e0bSBalbir Singh   long (*extract) (unsigned long instruction, ppc_cpu_t dialect, int *invalid);
285f78541dcSPaul Mackerras 
286f78541dcSPaul Mackerras   /* One bit syntax flags.  */
287f78541dcSPaul Mackerras   unsigned long flags;
288f78541dcSPaul Mackerras };
289f78541dcSPaul Mackerras 
290f78541dcSPaul Mackerras /* Elements in the table are retrieved by indexing with values from
291f78541dcSPaul Mackerras    the operands field of the powerpc_opcodes table.  */
292f78541dcSPaul Mackerras 
293f78541dcSPaul Mackerras extern const struct powerpc_operand powerpc_operands[];
294cc7639ceSBalbir Singh extern const unsigned int num_powerpc_operands;
295f78541dcSPaul Mackerras 
296*08d96e0bSBalbir Singh /* Use with the shift field of a struct powerpc_operand to indicate
297*08d96e0bSBalbir Singh      that BITM and SHIFT cannot be used to determine where the operand
298*08d96e0bSBalbir Singh      goes in the insn.  */
299*08d96e0bSBalbir Singh #define PPC_OPSHIFT_INV (-1U << 31)
300*08d96e0bSBalbir Singh 
301f78541dcSPaul Mackerras /* Values defined for the flags field of a struct powerpc_operand.  */
302f78541dcSPaul Mackerras 
303f78541dcSPaul Mackerras /* This operand takes signed values.  */
304cc7639ceSBalbir Singh #define PPC_OPERAND_SIGNED (0x1)
305f78541dcSPaul Mackerras 
306f78541dcSPaul Mackerras /* This operand takes signed values, but also accepts a full positive
307f78541dcSPaul Mackerras    range of values when running in 32 bit mode.  That is, if bits is
308f78541dcSPaul Mackerras    16, it takes any value from -0x8000 to 0xffff.  In 64 bit mode,
309f78541dcSPaul Mackerras    this flag is ignored.  */
310cc7639ceSBalbir Singh #define PPC_OPERAND_SIGNOPT (0x2)
311f78541dcSPaul Mackerras 
312f78541dcSPaul Mackerras /* This operand does not actually exist in the assembler input.  This
313f78541dcSPaul Mackerras    is used to support extended mnemonics such as mr, for which two
314f78541dcSPaul Mackerras    operands fields are identical.  The assembler should call the
315f78541dcSPaul Mackerras    insert function with any op value.  The disassembler should call
316f78541dcSPaul Mackerras    the extract function, ignore the return value, and check the value
317f78541dcSPaul Mackerras    placed in the valid argument.  */
318cc7639ceSBalbir Singh #define PPC_OPERAND_FAKE (0x4)
319f78541dcSPaul Mackerras 
320f78541dcSPaul Mackerras /* The next operand should be wrapped in parentheses rather than
321f78541dcSPaul Mackerras    separated from this one by a comma.  This is used for the load and
322f78541dcSPaul Mackerras    store instructions which want their operands to look like
323f78541dcSPaul Mackerras        reg,displacement(reg)
324f78541dcSPaul Mackerras    */
325cc7639ceSBalbir Singh #define PPC_OPERAND_PARENS (0x8)
326f78541dcSPaul Mackerras 
327f78541dcSPaul Mackerras /* This operand may use the symbolic names for the CR fields, which
328f78541dcSPaul Mackerras    are
329f78541dcSPaul Mackerras        lt  0	gt  1	eq  2	so  3	un  3
330f78541dcSPaul Mackerras        cr0 0	cr1 1	cr2 2	cr3 3
331f78541dcSPaul Mackerras        cr4 4	cr5 5	cr6 6	cr7 7
332f78541dcSPaul Mackerras    These may be combined arithmetically, as in cr2*4+gt.  These are
333f78541dcSPaul Mackerras    only supported on the PowerPC, not the POWER.  */
334*08d96e0bSBalbir Singh #define PPC_OPERAND_CR_BIT (0x10)
335f78541dcSPaul Mackerras 
336f78541dcSPaul Mackerras /* This operand names a register.  The disassembler uses this to print
337f78541dcSPaul Mackerras    register names with a leading 'r'.  */
338cc7639ceSBalbir Singh #define PPC_OPERAND_GPR (0x20)
339f78541dcSPaul Mackerras 
340897f112bSMichael Ellerman /* Like PPC_OPERAND_GPR, but don't print a leading 'r' for r0.  */
341cc7639ceSBalbir Singh #define PPC_OPERAND_GPR_0 (0x40)
342897f112bSMichael Ellerman 
343f78541dcSPaul Mackerras /* This operand names a floating point register.  The disassembler
344f78541dcSPaul Mackerras    prints these with a leading 'f'.  */
345cc7639ceSBalbir Singh #define PPC_OPERAND_FPR (0x80)
346f78541dcSPaul Mackerras 
347f78541dcSPaul Mackerras /* This operand is a relative branch displacement.  The disassembler
348f78541dcSPaul Mackerras    prints these symbolically if possible.  */
349cc7639ceSBalbir Singh #define PPC_OPERAND_RELATIVE (0x100)
350f78541dcSPaul Mackerras 
351f78541dcSPaul Mackerras /* This operand is an absolute branch address.  The disassembler
352f78541dcSPaul Mackerras    prints these symbolically if possible.  */
353cc7639ceSBalbir Singh #define PPC_OPERAND_ABSOLUTE (0x200)
354f78541dcSPaul Mackerras 
355f78541dcSPaul Mackerras /* This operand is optional, and is zero if omitted.  This is used for
356897f112bSMichael Ellerman    example, in the optional BF field in the comparison instructions.  The
357f78541dcSPaul Mackerras    assembler must count the number of operands remaining on the line,
358f78541dcSPaul Mackerras    and the number of operands remaining for the opcode, and decide
359f78541dcSPaul Mackerras    whether this operand is present or not.  The disassembler should
360f78541dcSPaul Mackerras    print this operand out only if it is not zero.  */
361cc7639ceSBalbir Singh #define PPC_OPERAND_OPTIONAL (0x400)
362f78541dcSPaul Mackerras 
363f78541dcSPaul Mackerras /* This flag is only used with PPC_OPERAND_OPTIONAL.  If this operand
364f78541dcSPaul Mackerras    is omitted, then for the next operand use this operand value plus
365f78541dcSPaul Mackerras    1, ignoring the next operand field for the opcode.  This wretched
366f78541dcSPaul Mackerras    hack is needed because the Power rotate instructions can take
367f78541dcSPaul Mackerras    either 4 or 5 operands.  The disassembler should print this operand
368f78541dcSPaul Mackerras    out regardless of the PPC_OPERAND_OPTIONAL field.  */
369cc7639ceSBalbir Singh #define PPC_OPERAND_NEXT (0x800)
370f78541dcSPaul Mackerras 
371f78541dcSPaul Mackerras /* This operand should be regarded as a negative number for the
372f78541dcSPaul Mackerras    purposes of overflow checking (i.e., the normal most negative
373f78541dcSPaul Mackerras    number is disallowed and one more than the normal most positive
374f78541dcSPaul Mackerras    number is allowed).  This flag will only be set for a signed
375f78541dcSPaul Mackerras    operand.  */
376cc7639ceSBalbir Singh #define PPC_OPERAND_NEGATIVE (0x1000)
377f78541dcSPaul Mackerras 
378f78541dcSPaul Mackerras /* This operand names a vector unit register.  The disassembler
379f78541dcSPaul Mackerras    prints these with a leading 'v'.  */
380cc7639ceSBalbir Singh #define PPC_OPERAND_VR (0x2000)
381f78541dcSPaul Mackerras 
382f78541dcSPaul Mackerras /* This operand is for the DS field in a DS form instruction.  */
383cc7639ceSBalbir Singh #define PPC_OPERAND_DS (0x4000)
384f78541dcSPaul Mackerras 
385f78541dcSPaul Mackerras /* This operand is for the DQ field in a DQ form instruction.  */
386cc7639ceSBalbir Singh #define PPC_OPERAND_DQ (0x8000)
387cc7639ceSBalbir Singh 
388cc7639ceSBalbir Singh /* Valid range of operand is 0..n rather than 0..n-1.  */
389cc7639ceSBalbir Singh #define PPC_OPERAND_PLUS1 (0x10000)
390*08d96e0bSBalbir Singh 
391*08d96e0bSBalbir Singh /* Xilinx APU and FSL related operands */
392*08d96e0bSBalbir Singh #define PPC_OPERAND_FSL (0x20000)
393*08d96e0bSBalbir Singh #define PPC_OPERAND_FCR (0x40000)
394*08d96e0bSBalbir Singh #define PPC_OPERAND_UDI (0x80000)
395*08d96e0bSBalbir Singh 
396*08d96e0bSBalbir Singh /* This operand names a vector-scalar unit register.  The disassembler
397*08d96e0bSBalbir Singh    prints these with a leading 'vs'.  */
398*08d96e0bSBalbir Singh #define PPC_OPERAND_VSR (0x100000)
399*08d96e0bSBalbir Singh 
400*08d96e0bSBalbir Singh /* This is a CR FIELD that does not use symbolic names.  */
401*08d96e0bSBalbir Singh #define PPC_OPERAND_CR_REG (0x200000)
402*08d96e0bSBalbir Singh 
403*08d96e0bSBalbir Singh /* This flag is only used with PPC_OPERAND_OPTIONAL.  If this operand
404*08d96e0bSBalbir Singh    is omitted, then the value it should use for the operand is stored
405*08d96e0bSBalbir Singh    in the SHIFT field of the immediatly following operand field.  */
406*08d96e0bSBalbir Singh #define PPC_OPERAND_OPTIONAL_VALUE (0x400000)
407*08d96e0bSBalbir Singh 
408*08d96e0bSBalbir Singh /* This flag is only used with PPC_OPERAND_OPTIONAL.  The operand is
409*08d96e0bSBalbir Singh    only optional when generating 32-bit code.  */
410*08d96e0bSBalbir Singh #define PPC_OPERAND_OPTIONAL32 (0x800000)
411f78541dcSPaul Mackerras 
412f78541dcSPaul Mackerras /* The POWER and PowerPC assemblers use a few macros.  We keep them
413f78541dcSPaul Mackerras    with the operands table for simplicity.  The macro table is an
414f78541dcSPaul Mackerras    array of struct powerpc_macro.  */
415f78541dcSPaul Mackerras 
416f78541dcSPaul Mackerras struct powerpc_macro
417f78541dcSPaul Mackerras {
418f78541dcSPaul Mackerras   /* The macro name.  */
419f78541dcSPaul Mackerras   const char *name;
420f78541dcSPaul Mackerras 
421f78541dcSPaul Mackerras   /* The number of operands the macro takes.  */
422f78541dcSPaul Mackerras   unsigned int operands;
423f78541dcSPaul Mackerras 
424f78541dcSPaul Mackerras   /* One bit flags for the opcode.  These are used to indicate which
425f78541dcSPaul Mackerras      specific processors support the instructions.  The values are the
426f78541dcSPaul Mackerras      same as those for the struct powerpc_opcode flags field.  */
427*08d96e0bSBalbir Singh   ppc_cpu_t flags;
428f78541dcSPaul Mackerras 
429f78541dcSPaul Mackerras   /* A format string to turn the macro into a normal instruction.
430f78541dcSPaul Mackerras      Each %N in the string is replaced with operand number N (zero
431f78541dcSPaul Mackerras      based).  */
432f78541dcSPaul Mackerras   const char *format;
433f78541dcSPaul Mackerras };
434f78541dcSPaul Mackerras 
435f78541dcSPaul Mackerras extern const struct powerpc_macro powerpc_macros[];
436f78541dcSPaul Mackerras extern const int powerpc_num_macros;
437f78541dcSPaul Mackerras 
438*08d96e0bSBalbir Singh static inline long
ppc_optional_operand_value(const struct powerpc_operand * operand)439*08d96e0bSBalbir Singh ppc_optional_operand_value (const struct powerpc_operand *operand)
440*08d96e0bSBalbir Singh {
441*08d96e0bSBalbir Singh   if ((operand->flags & PPC_OPERAND_OPTIONAL_VALUE) != 0)
442*08d96e0bSBalbir Singh     return (operand+1)->shift;
443*08d96e0bSBalbir Singh   return 0;
444*08d96e0bSBalbir Singh }
445*08d96e0bSBalbir Singh 
446*08d96e0bSBalbir Singh #ifdef __cplusplus
447*08d96e0bSBalbir Singh }
448*08d96e0bSBalbir Singh #endif
449*08d96e0bSBalbir Singh 
450f78541dcSPaul Mackerras #endif /* PPC_H */
451