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