aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBalbir Singh <bsingharora@gmail.com>2017-02-02 00:03:42 -0500
committerMichael Ellerman <mpe@ellerman.id.au>2017-02-15 04:02:41 -0500
commitcc7639ce18b950086c7b06e00350652db3732183 (patch)
treee82078fbb9bba99e021eedd312af411d246a769a
parent438e69b52be776c035aa2a851ccc1709033d729b (diff)
powerpc/xmon: Update ppc-dis/opc.c and ppc.h
Upgrade ppc-opc.c, ppc-dis.c and ppc.h to the versions belonging to the following binutils commit: 65b650b4c7463f4508bed523c24ab0031a5ae5cd * ppc-dis.c (print_insn_powerpc): Don't skip all operands after setting skip_optional. That is the last version of those files that were licensed under GPLv2. This leaves the code in a state that does not compile, because the binutils code needs to be tweaked to work in the kernel. We don't fix that in this commit, because we want to import more binutils changes in subsequent commits. So for now we mark XMON_DISASSEMBLY as BROKEN, so it can't be built. Signed-off-by: Balbir Singh <bsingharora@gmail.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
-rw-r--r--arch/powerpc/Kconfig.debug1
-rw-r--r--arch/powerpc/xmon/ppc-dis.c272
-rw-r--r--arch/powerpc/xmon/ppc-opc.c728
-rw-r--r--arch/powerpc/xmon/ppc.h62
4 files changed, 493 insertions, 570 deletions
diff --git a/arch/powerpc/Kconfig.debug b/arch/powerpc/Kconfig.debug
index c86df246339e..73a3264cf052 100644
--- a/arch/powerpc/Kconfig.debug
+++ b/arch/powerpc/Kconfig.debug
@@ -115,6 +115,7 @@ config XMON_DEFAULT
115config XMON_DISASSEMBLY 115config XMON_DISASSEMBLY
116 bool "Include disassembly support in xmon" 116 bool "Include disassembly support in xmon"
117 depends on XMON 117 depends on XMON
118 depends on BROKEN
118 default y 119 default y
119 help 120 help
120 Include support for disassembling in xmon. You probably want 121 Include support for disassembling in xmon. You probably want
diff --git a/arch/powerpc/xmon/ppc-dis.c b/arch/powerpc/xmon/ppc-dis.c
index ee9891734149..2545a36f21a5 100644
--- a/arch/powerpc/xmon/ppc-dis.c
+++ b/arch/powerpc/xmon/ppc-dis.c
@@ -1,5 +1,5 @@
1/* ppc-dis.c -- Disassemble PowerPC instructions 1/* ppc-dis.c -- Disassemble PowerPC instructions
2 Copyright 1994, 1995, 2000, 2001, 2002, 2003, 2004, 2005, 2006 2 Copyright 1994, 1995, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
3 Free Software Foundation, Inc. 3 Free Software Foundation, Inc.
4 Written by Ian Lance Taylor, Cygnus Support 4 Written by Ian Lance Taylor, Cygnus Support
5 5
@@ -19,34 +19,193 @@ You should have received a copy of the GNU General Public License
19along with this file; see the file COPYING. If not, write to the Free 19along with this file; see the file COPYING. If not, write to the Free
20Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ 20Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */
21 21
22#include <asm/cputable.h> 22#include <stdio.h>
23#include <asm/cpu_has_feature.h> 23#include "sysdep.h"
24#include "nonstdio.h"
25#include "ansidecl.h"
26#include "ppc.h"
27#include "dis-asm.h" 24#include "dis-asm.h"
25#include "opcode/ppc.h"
28 26
29/* Print a PowerPC or POWER instruction. */ 27/* This file provides several disassembler functions, all of which use
28 the disassembler interface defined in dis-asm.h. Several functions
29 are provided because this file handles disassembly for the PowerPC
30 in both big and little endian mode and also for the POWER (RS/6000)
31 chip. */
32
33static int print_insn_powerpc (bfd_vma, struct disassemble_info *, int, int);
34
35/* Determine which set of machines to disassemble for. PPC403/601 or
36 BookE. For convenience, also disassemble instructions supported
37 by the AltiVec vector unit. */
38
39static int
40powerpc_dialect (struct disassemble_info *info)
41{
42 int dialect = PPC_OPCODE_PPC;
43
44 if (BFD_DEFAULT_TARGET_SIZE == 64)
45 dialect |= PPC_OPCODE_64;
46
47 if (info->disassembler_options
48 && strstr (info->disassembler_options, "booke") != NULL)
49 dialect |= PPC_OPCODE_BOOKE | PPC_OPCODE_BOOKE64;
50 else if ((info->mach == bfd_mach_ppc_e500)
51 || (info->disassembler_options
52 && strstr (info->disassembler_options, "e500") != NULL))
53 dialect |= (PPC_OPCODE_BOOKE
54 | PPC_OPCODE_SPE | PPC_OPCODE_ISEL
55 | PPC_OPCODE_EFS | PPC_OPCODE_BRLOCK
56 | PPC_OPCODE_PMR | PPC_OPCODE_CACHELCK
57 | PPC_OPCODE_RFMCI);
58 else if (info->disassembler_options
59 && strstr (info->disassembler_options, "efs") != NULL)
60 dialect |= PPC_OPCODE_EFS;
61 else if (info->disassembler_options
62 && strstr (info->disassembler_options, "e300") != NULL)
63 dialect |= PPC_OPCODE_E300 | PPC_OPCODE_CLASSIC | PPC_OPCODE_COMMON;
64 else if (info->disassembler_options
65 && strstr (info->disassembler_options, "440") != NULL)
66 dialect |= PPC_OPCODE_BOOKE | PPC_OPCODE_32
67 | PPC_OPCODE_440 | PPC_OPCODE_ISEL | PPC_OPCODE_RFMCI;
68 else
69 dialect |= (PPC_OPCODE_403 | PPC_OPCODE_601 | PPC_OPCODE_CLASSIC
70 | PPC_OPCODE_COMMON | PPC_OPCODE_ALTIVEC);
71
72 if (info->disassembler_options
73 && strstr (info->disassembler_options, "power4") != NULL)
74 dialect |= PPC_OPCODE_POWER4;
75
76 if (info->disassembler_options
77 && strstr (info->disassembler_options, "power5") != NULL)
78 dialect |= PPC_OPCODE_POWER4 | PPC_OPCODE_POWER5;
79
80 if (info->disassembler_options
81 && strstr (info->disassembler_options, "cell") != NULL)
82 dialect |= PPC_OPCODE_POWER4 | PPC_OPCODE_CELL | PPC_OPCODE_ALTIVEC;
83
84 if (info->disassembler_options
85 && strstr (info->disassembler_options, "power6") != NULL)
86 dialect |= PPC_OPCODE_POWER4 | PPC_OPCODE_POWER5 | PPC_OPCODE_POWER6 | PPC_OPCODE_ALTIVEC;
87
88 if (info->disassembler_options
89 && strstr (info->disassembler_options, "any") != NULL)
90 dialect |= PPC_OPCODE_ANY;
91
92 if (info->disassembler_options)
93 {
94 if (strstr (info->disassembler_options, "32") != NULL)
95 dialect &= ~PPC_OPCODE_64;
96 else if (strstr (info->disassembler_options, "64") != NULL)
97 dialect |= PPC_OPCODE_64;
98 }
99
100 info->private_data = (char *) 0 + dialect;
101 return dialect;
102}
103
104/* Print a big endian PowerPC instruction. */
105
106int
107print_insn_big_powerpc (bfd_vma memaddr, struct disassemble_info *info)
108{
109 int dialect = (char *) info->private_data - (char *) 0;
110 return print_insn_powerpc (memaddr, info, 1, dialect);
111}
112
113/* Print a little endian PowerPC instruction. */
30 114
31int 115int
32print_insn_powerpc (unsigned long insn, unsigned long memaddr) 116print_insn_little_powerpc (bfd_vma memaddr, struct disassemble_info *info)
117{
118 int dialect = (char *) info->private_data - (char *) 0;
119 return print_insn_powerpc (memaddr, info, 0, dialect);
120}
121
122/* Print a POWER (RS/6000) instruction. */
123
124int
125print_insn_rs6000 (bfd_vma memaddr, struct disassemble_info *info)
126{
127 return print_insn_powerpc (memaddr, info, 1, PPC_OPCODE_POWER);
128}
129
130/* Extract the operand value from the PowerPC or POWER instruction. */
131
132static long
133operand_value_powerpc (const struct powerpc_operand *operand,
134 unsigned long insn, int dialect)
135{
136 long value;
137 int invalid;
138 /* Extract the value from the instruction. */
139 if (operand->extract)
140 value = (*operand->extract) (insn, dialect, &invalid);
141 else
142 {
143 value = (insn >> operand->shift) & operand->bitm;
144 if ((operand->flags & PPC_OPERAND_SIGNED) != 0)
145 {
146 /* BITM is always some number of zeros followed by some
147 number of ones, followed by some numer of zeros. */
148 unsigned long top = operand->bitm;
149 /* top & -top gives the rightmost 1 bit, so this
150 fills in any trailing zeros. */
151 top |= (top & -top) - 1;
152 top &= ~(top >> 1);
153 value = (value ^ top) - top;
154 }
155 }
156
157 return value;
158}
159
160/* Determine whether the optional operand(s) should be printed. */
161
162static int
163skip_optional_operands (const unsigned char *opindex,
164 unsigned long insn, int dialect)
165{
166 const struct powerpc_operand *operand;
167
168 for (; *opindex != 0; opindex++)
169 {
170 operand = &powerpc_operands[*opindex];
171 if ((operand->flags & PPC_OPERAND_NEXT) != 0
172 || ((operand->flags & PPC_OPERAND_OPTIONAL) != 0
173 && operand_value_powerpc (operand, insn, dialect) != 0))
174 return 0;
175 }
176
177 return 1;
178}
179
180/* Print a PowerPC or POWER instruction. */
181
182static int
183print_insn_powerpc (bfd_vma memaddr,
184 struct disassemble_info *info,
185 int bigendian,
186 int dialect)
33{ 187{
188 bfd_byte buffer[4];
189 int status;
190 unsigned long insn;
34 const struct powerpc_opcode *opcode; 191 const struct powerpc_opcode *opcode;
35 const struct powerpc_opcode *opcode_end; 192 const struct powerpc_opcode *opcode_end;
36 unsigned long op; 193 unsigned long op;
37 int dialect;
38
39 dialect = PPC_OPCODE_PPC | PPC_OPCODE_CLASSIC | PPC_OPCODE_COMMON
40 | PPC_OPCODE_64 | PPC_OPCODE_POWER4 | PPC_OPCODE_ALTIVEC;
41 194
42 if (cpu_has_feature(CPU_FTRS_POWER5)) 195 if (dialect == 0)
43 dialect |= PPC_OPCODE_POWER5; 196 dialect = powerpc_dialect (info);
44 197
45 if (cpu_has_feature(CPU_FTRS_CELL)) 198 status = (*info->read_memory_func) (memaddr, buffer, 4, info);
46 dialect |= PPC_OPCODE_CELL | PPC_OPCODE_ALTIVEC; 199 if (status != 0)
200 {
201 (*info->memory_error_func) (status, memaddr, info);
202 return -1;
203 }
47 204
48 if (cpu_has_feature(CPU_FTRS_POWER6)) 205 if (bigendian)
49 dialect |= PPC_OPCODE_POWER5 | PPC_OPCODE_POWER6 | PPC_OPCODE_ALTIVEC; 206 insn = bfd_getb32 (buffer);
207 else
208 insn = bfd_getl32 (buffer);
50 209
51 /* Get the major opcode of the instruction. */ 210 /* Get the major opcode of the instruction. */
52 op = PPC_OP (insn); 211 op = PPC_OP (insn);
@@ -63,6 +222,7 @@ print_insn_powerpc (unsigned long insn, unsigned long memaddr)
63 int invalid; 222 int invalid;
64 int need_comma; 223 int need_comma;
65 int need_paren; 224 int need_paren;
225 int skip_optional;
66 226
67 table_op = PPC_OP (opcode->opcode); 227 table_op = PPC_OP (opcode->opcode);
68 if (op < table_op) 228 if (op < table_op)
@@ -88,13 +248,15 @@ print_insn_powerpc (unsigned long insn, unsigned long memaddr)
88 continue; 248 continue;
89 249
90 /* The instruction is valid. */ 250 /* The instruction is valid. */
91 printf("%s", opcode->name);
92 if (opcode->operands[0] != 0) 251 if (opcode->operands[0] != 0)
93 printf("\t"); 252 (*info->fprintf_func) (info->stream, "%-7s ", opcode->name);
253 else
254 (*info->fprintf_func) (info->stream, "%s", opcode->name);
94 255
95 /* Now extract and print the operands. */ 256 /* Now extract and print the operands. */
96 need_comma = 0; 257 need_comma = 0;
97 need_paren = 0; 258 need_paren = 0;
259 skip_optional = -1;
98 for (opindex = opcode->operands; *opindex != 0; opindex++) 260 for (opindex = opcode->operands; *opindex != 0; opindex++)
99 { 261 {
100 long value; 262 long value;
@@ -107,49 +269,44 @@ print_insn_powerpc (unsigned long insn, unsigned long memaddr)
107 if ((operand->flags & PPC_OPERAND_FAKE) != 0) 269 if ((operand->flags & PPC_OPERAND_FAKE) != 0)
108 continue; 270 continue;
109 271
110 /* Extract the value from the instruction. */ 272 /* If all of the optional operands have the value zero,
111 if (operand->extract) 273 then don't print any of them. */
112 value = (*operand->extract) (insn, dialect, &invalid); 274 if ((operand->flags & PPC_OPERAND_OPTIONAL) != 0)
113 else
114 { 275 {
115 value = (insn >> operand->shift) & ((1 << operand->bits) - 1); 276 if (skip_optional < 0)
116 if ((operand->flags & PPC_OPERAND_SIGNED) != 0 277 skip_optional = skip_optional_operands (opindex, insn,
117 && (value & (1 << (operand->bits - 1))) != 0) 278 dialect);
118 value -= 1 << operand->bits; 279 if (skip_optional)
280 continue;
119 } 281 }
120 282
121 /* If the operand is optional, and the value is zero, don't 283 value = operand_value_powerpc (operand, insn, dialect);
122 print anything. */
123 if ((operand->flags & PPC_OPERAND_OPTIONAL) != 0
124 && (operand->flags & PPC_OPERAND_NEXT) == 0
125 && value == 0)
126 continue;
127 284
128 if (need_comma) 285 if (need_comma)
129 { 286 {
130 printf(","); 287 (*info->fprintf_func) (info->stream, ",");
131 need_comma = 0; 288 need_comma = 0;
132 } 289 }
133 290
134 /* Print the operand as directed by the flags. */ 291 /* Print the operand as directed by the flags. */
135 if ((operand->flags & PPC_OPERAND_GPR) != 0 292 if ((operand->flags & PPC_OPERAND_GPR) != 0
136 || ((operand->flags & PPC_OPERAND_GPR_0) != 0 && value != 0)) 293 || ((operand->flags & PPC_OPERAND_GPR_0) != 0 && value != 0))
137 printf("r%ld", value); 294 (*info->fprintf_func) (info->stream, "r%ld", value);
138 else if ((operand->flags & PPC_OPERAND_FPR) != 0) 295 else if ((operand->flags & PPC_OPERAND_FPR) != 0)
139 printf("f%ld", value); 296 (*info->fprintf_func) (info->stream, "f%ld", value);
140 else if ((operand->flags & PPC_OPERAND_VR) != 0) 297 else if ((operand->flags & PPC_OPERAND_VR) != 0)
141 printf("v%ld", value); 298 (*info->fprintf_func) (info->stream, "v%ld", value);
142 else if ((operand->flags & PPC_OPERAND_RELATIVE) != 0) 299 else if ((operand->flags & PPC_OPERAND_RELATIVE) != 0)
143 print_address (memaddr + value); 300 (*info->print_address_func) (memaddr + value, info);
144 else if ((operand->flags & PPC_OPERAND_ABSOLUTE) != 0) 301 else if ((operand->flags & PPC_OPERAND_ABSOLUTE) != 0)
145 print_address (value & 0xffffffff); 302 (*info->print_address_func) ((bfd_vma) value & 0xffffffff, info);
146 else if ((operand->flags & PPC_OPERAND_CR) == 0 303 else if ((operand->flags & PPC_OPERAND_CR) == 0
147 || (dialect & PPC_OPCODE_PPC) == 0) 304 || (dialect & PPC_OPCODE_PPC) == 0)
148 printf("%ld", value); 305 (*info->fprintf_func) (info->stream, "%ld", value);
149 else 306 else
150 { 307 {
151 if (operand->bits == 3) 308 if (operand->bitm == 7)
152 printf("cr%ld", value); 309 (*info->fprintf_func) (info->stream, "cr%ld", value);
153 else 310 else
154 { 311 {
155 static const char *cbnames[4] = { "lt", "gt", "eq", "so" }; 312 static const char *cbnames[4] = { "lt", "gt", "eq", "so" };
@@ -158,15 +315,15 @@ print_insn_powerpc (unsigned long insn, unsigned long memaddr)
158 315
159 cr = value >> 2; 316 cr = value >> 2;
160 if (cr != 0) 317 if (cr != 0)
161 printf("4*cr%d+", cr); 318 (*info->fprintf_func) (info->stream, "4*cr%d+", cr);
162 cc = value & 3; 319 cc = value & 3;
163 printf("%s", cbnames[cc]); 320 (*info->fprintf_func) (info->stream, "%s", cbnames[cc]);
164 } 321 }
165 } 322 }
166 323
167 if (need_paren) 324 if (need_paren)
168 { 325 {
169 printf(")"); 326 (*info->fprintf_func) (info->stream, ")");
170 need_paren = 0; 327 need_paren = 0;
171 } 328 }
172 329
@@ -174,7 +331,7 @@ print_insn_powerpc (unsigned long insn, unsigned long memaddr)
174 need_comma = 1; 331 need_comma = 1;
175 else 332 else
176 { 333 {
177 printf("("); 334 (*info->fprintf_func) (info->stream, "(");
178 need_paren = 1; 335 need_paren = 1;
179 } 336 }
180 } 337 }
@@ -190,7 +347,26 @@ print_insn_powerpc (unsigned long insn, unsigned long memaddr)
190 } 347 }
191 348
192 /* We could not find a match. */ 349 /* We could not find a match. */
193 printf(".long 0x%lx", insn); 350 (*info->fprintf_func) (info->stream, ".long 0x%lx", insn);
194 351
195 return 4; 352 return 4;
196} 353}
354
355void
356print_ppc_disassembler_options (FILE *stream)
357{
358 fprintf (stream, "\n\
359The following PPC specific disassembler options are supported for use with\n\
360the -M switch:\n");
361
362 fprintf (stream, " booke|booke32|booke64 Disassemble the BookE instructions\n");
363 fprintf (stream, " e300 Disassemble the e300 instructions\n");
364 fprintf (stream, " e500|e500x2 Disassemble the e500 instructions\n");
365 fprintf (stream, " 440 Disassemble the 440 instructions\n");
366 fprintf (stream, " efs Disassemble the EFS instructions\n");
367 fprintf (stream, " power4 Disassemble the Power4 instructions\n");
368 fprintf (stream, " power5 Disassemble the Power5 instructions\n");
369 fprintf (stream, " power6 Disassemble the Power6 instructions\n");
370 fprintf (stream, " 32 Do not disassemble 64-bit instructions\n");
371 fprintf (stream, " 64 Allow disassembly of 64-bit instructions\n");
372}
diff --git a/arch/powerpc/xmon/ppc-opc.c b/arch/powerpc/xmon/ppc-opc.c
index 6845e91ba04a..5995f81de9ff 100644
--- a/arch/powerpc/xmon/ppc-opc.c
+++ b/arch/powerpc/xmon/ppc-opc.c
@@ -1,6 +1,6 @@
1/* ppc-opc.c -- PowerPC opcode list 1/* ppc-opc.c -- PowerPC opcode list
2 Copyright 1994, 1995, 1996, 1997, 1998, 2000, 2001, 2002, 2003, 2004, 2 Copyright 1994, 1995, 1996, 1997, 1998, 2000, 2001, 2002, 2003, 2004,
3 2005 Free Software Foundation, Inc. 3 2005, 2006, 2007 Free Software Foundation, Inc.
4 Written by Ian Lance Taylor, Cygnus Support 4 Written by Ian Lance Taylor, Cygnus Support
5 5
6 This file is part of GDB, GAS, and the GNU binutils. 6 This file is part of GDB, GAS, and the GNU binutils.
@@ -20,14 +20,10 @@
20 Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA 20 Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
21 02110-1301, USA. */ 21 02110-1301, USA. */
22 22
23#include <linux/stddef.h> 23#include <stdio.h>
24#include <linux/kernel.h> 24#include "sysdep.h"
25#include <linux/bug.h> 25#include "opcode/ppc.h"
26#include "nonstdio.h" 26#include "opintl.h"
27#include "ppc.h"
28
29#define ATTRIBUTE_UNUSED
30#define _(x) x
31 27
32/* This file holds the PowerPC opcode table. The opcode table 28/* This file holds the PowerPC opcode table. The opcode table
33 includes almost all of the extended instruction mnemonics. This 29 includes almost all of the extended instruction mnemonics. This
@@ -46,8 +42,6 @@ static unsigned long insert_bat (unsigned long, long, int, const char **);
46static long extract_bat (unsigned long, int, int *); 42static long extract_bat (unsigned long, int, int *);
47static unsigned long insert_bba (unsigned long, long, int, const char **); 43static unsigned long insert_bba (unsigned long, long, int, const char **);
48static long extract_bba (unsigned long, int, int *); 44static long extract_bba (unsigned long, int, int *);
49static unsigned long insert_bd (unsigned long, long, int, const char **);
50static long extract_bd (unsigned long, int, int *);
51static unsigned long insert_bdm (unsigned long, long, int, const char **); 45static unsigned long insert_bdm (unsigned long, long, int, const char **);
52static long extract_bdm (unsigned long, int, int *); 46static long extract_bdm (unsigned long, int, int *);
53static unsigned long insert_bdp (unsigned long, long, int, const char **); 47static unsigned long insert_bdp (unsigned long, long, int, const char **);
@@ -56,23 +50,12 @@ static unsigned long insert_bo (unsigned long, long, int, const char **);
56static long extract_bo (unsigned long, int, int *); 50static long extract_bo (unsigned long, int, int *);
57static unsigned long insert_boe (unsigned long, long, int, const char **); 51static unsigned long insert_boe (unsigned long, long, int, const char **);
58static long extract_boe (unsigned long, int, int *); 52static long extract_boe (unsigned long, int, int *);
59static unsigned long insert_dq (unsigned long, long, int, const char **);
60static long extract_dq (unsigned long, int, int *);
61static unsigned long insert_ds (unsigned long, long, int, const char **);
62static long extract_ds (unsigned long, int, int *);
63static unsigned long insert_de (unsigned long, long, int, const char **);
64static long extract_de (unsigned long, int, int *);
65static unsigned long insert_des (unsigned long, long, int, const char **);
66static long extract_des (unsigned long, int, int *);
67static unsigned long insert_fxm (unsigned long, long, int, const char **); 53static unsigned long insert_fxm (unsigned long, long, int, const char **);
68static long extract_fxm (unsigned long, int, int *); 54static long extract_fxm (unsigned long, int, int *);
69static unsigned long insert_li (unsigned long, long, int, const char **);
70static long extract_li (unsigned long, int, int *);
71static unsigned long insert_mbe (unsigned long, long, int, const char **); 55static unsigned long insert_mbe (unsigned long, long, int, const char **);
72static long extract_mbe (unsigned long, int, int *); 56static long extract_mbe (unsigned long, int, int *);
73static unsigned long insert_mb6 (unsigned long, long, int, const char **); 57static unsigned long insert_mb6 (unsigned long, long, int, const char **);
74static long extract_mb6 (unsigned long, int, int *); 58static long extract_mb6 (unsigned long, int, int *);
75static unsigned long insert_nb (unsigned long, long, int, const char **);
76static long extract_nb (unsigned long, int, int *); 59static long extract_nb (unsigned long, int, int *);
77static unsigned long insert_nsi (unsigned long, long, int, const char **); 60static unsigned long insert_nsi (unsigned long, long, int, const char **);
78static long extract_nsi (unsigned long, int, int *); 61static long extract_nsi (unsigned long, int, int *);
@@ -82,8 +65,6 @@ static unsigned long insert_raq (unsigned long, long, int, const char **);
82static unsigned long insert_ras (unsigned long, long, int, const char **); 65static unsigned long insert_ras (unsigned long, long, int, const char **);
83static unsigned long insert_rbs (unsigned long, long, int, const char **); 66static unsigned long insert_rbs (unsigned long, long, int, const char **);
84static long extract_rbs (unsigned long, int, int *); 67static long extract_rbs (unsigned long, int, int *);
85static unsigned long insert_rsq (unsigned long, long, int, const char **);
86static unsigned long insert_rtq (unsigned long, long, int, const char **);
87static unsigned long insert_sh6 (unsigned long, long, int, const char **); 68static unsigned long insert_sh6 (unsigned long, long, int, const char **);
88static long extract_sh6 (unsigned long, int, int *); 69static long extract_sh6 (unsigned long, int, int *);
89static unsigned long insert_spr (unsigned long, long, int, const char **); 70static unsigned long insert_spr (unsigned long, long, int, const char **);
@@ -92,16 +73,10 @@ static unsigned long insert_sprg (unsigned long, long, int, const char **);
92static long extract_sprg (unsigned long, int, int *); 73static long extract_sprg (unsigned long, int, int *);
93static unsigned long insert_tbr (unsigned long, long, int, const char **); 74static unsigned long insert_tbr (unsigned long, long, int, const char **);
94static long extract_tbr (unsigned long, int, int *); 75static long extract_tbr (unsigned long, int, int *);
95static unsigned long insert_ev2 (unsigned long, long, int, const char **);
96static long extract_ev2 (unsigned long, int, int *);
97static unsigned long insert_ev4 (unsigned long, long, int, const char **);
98static long extract_ev4 (unsigned long, int, int *);
99static unsigned long insert_ev8 (unsigned long, long, int, const char **);
100static long extract_ev8 (unsigned long, int, int *);
101 76
102/* The operands table. 77/* The operands table.
103 78
104 The fields are bits, shift, insert, extract, flags. 79 The fields are bitm, shift, insert, extract, flags.
105 80
106 We used to put parens around the various additions, like the one 81 We used to put parens around the various additions, like the one
107 for BA just below. However, that caused trouble with feeble 82 for BA just below. However, that caused trouble with feeble
@@ -119,302 +94,298 @@ const struct powerpc_operand powerpc_operands[] =
119 94
120 /* The BA field in an XL form instruction. */ 95 /* The BA field in an XL form instruction. */
121#define BA UNUSED + 1 96#define BA UNUSED + 1
122#define BA_MASK (0x1f << 16) 97 /* The BI field in a B form or XL form instruction. */
123 { 5, 16, NULL, NULL, PPC_OPERAND_CR }, 98#define BI BA
99#define BI_MASK (0x1f << 16)
100 { 0x1f, 16, NULL, NULL, PPC_OPERAND_CR },
124 101
125 /* The BA field in an XL form instruction when it must be the same 102 /* The BA field in an XL form instruction when it must be the same
126 as the BT field in the same instruction. */ 103 as the BT field in the same instruction. */
127#define BAT BA + 1 104#define BAT BA + 1
128 { 5, 16, insert_bat, extract_bat, PPC_OPERAND_FAKE }, 105 { 0x1f, 16, insert_bat, extract_bat, PPC_OPERAND_FAKE },
129 106
130 /* The BB field in an XL form instruction. */ 107 /* The BB field in an XL form instruction. */
131#define BB BAT + 1 108#define BB BAT + 1
132#define BB_MASK (0x1f << 11) 109#define BB_MASK (0x1f << 11)
133 { 5, 11, NULL, NULL, PPC_OPERAND_CR }, 110 { 0x1f, 11, NULL, NULL, PPC_OPERAND_CR },
134 111
135 /* The BB field in an XL form instruction when it must be the same 112 /* The BB field in an XL form instruction when it must be the same
136 as the BA field in the same instruction. */ 113 as the BA field in the same instruction. */
137#define BBA BB + 1 114#define BBA BB + 1
138 { 5, 11, insert_bba, extract_bba, PPC_OPERAND_FAKE }, 115 { 0x1f, 11, insert_bba, extract_bba, PPC_OPERAND_FAKE },
139 116
140 /* The BD field in a B form instruction. The lower two bits are 117 /* The BD field in a B form instruction. The lower two bits are
141 forced to zero. */ 118 forced to zero. */
142#define BD BBA + 1 119#define BD BBA + 1
143 { 16, 0, insert_bd, extract_bd, PPC_OPERAND_RELATIVE | PPC_OPERAND_SIGNED }, 120 { 0xfffc, 0, NULL, NULL, PPC_OPERAND_RELATIVE | PPC_OPERAND_SIGNED },
144 121
145 /* The BD field in a B form instruction when absolute addressing is 122 /* The BD field in a B form instruction when absolute addressing is
146 used. */ 123 used. */
147#define BDA BD + 1 124#define BDA BD + 1
148 { 16, 0, insert_bd, extract_bd, PPC_OPERAND_ABSOLUTE | PPC_OPERAND_SIGNED }, 125 { 0xfffc, 0, NULL, NULL, PPC_OPERAND_ABSOLUTE | PPC_OPERAND_SIGNED },
149 126
150 /* The BD field in a B form instruction when the - modifier is used. 127 /* The BD field in a B form instruction when the - modifier is used.
151 This sets the y bit of the BO field appropriately. */ 128 This sets the y bit of the BO field appropriately. */
152#define BDM BDA + 1 129#define BDM BDA + 1
153 { 16, 0, insert_bdm, extract_bdm, 130 { 0xfffc, 0, insert_bdm, extract_bdm,
154 PPC_OPERAND_RELATIVE | PPC_OPERAND_SIGNED }, 131 PPC_OPERAND_RELATIVE | PPC_OPERAND_SIGNED },
155 132
156 /* The BD field in a B form instruction when the - modifier is used 133 /* The BD field in a B form instruction when the - modifier is used
157 and absolute address is used. */ 134 and absolute address is used. */
158#define BDMA BDM + 1 135#define BDMA BDM + 1
159 { 16, 0, insert_bdm, extract_bdm, 136 { 0xfffc, 0, insert_bdm, extract_bdm,
160 PPC_OPERAND_ABSOLUTE | PPC_OPERAND_SIGNED }, 137 PPC_OPERAND_ABSOLUTE | PPC_OPERAND_SIGNED },
161 138
162 /* The BD field in a B form instruction when the + modifier is used. 139 /* The BD field in a B form instruction when the + modifier is used.
163 This sets the y bit of the BO field appropriately. */ 140 This sets the y bit of the BO field appropriately. */
164#define BDP BDMA + 1 141#define BDP BDMA + 1
165 { 16, 0, insert_bdp, extract_bdp, 142 { 0xfffc, 0, insert_bdp, extract_bdp,
166 PPC_OPERAND_RELATIVE | PPC_OPERAND_SIGNED }, 143 PPC_OPERAND_RELATIVE | PPC_OPERAND_SIGNED },
167 144
168 /* The BD field in a B form instruction when the + modifier is used 145 /* The BD field in a B form instruction when the + modifier is used
169 and absolute addressing is used. */ 146 and absolute addressing is used. */
170#define BDPA BDP + 1 147#define BDPA BDP + 1
171 { 16, 0, insert_bdp, extract_bdp, 148 { 0xfffc, 0, insert_bdp, extract_bdp,
172 PPC_OPERAND_ABSOLUTE | PPC_OPERAND_SIGNED }, 149 PPC_OPERAND_ABSOLUTE | PPC_OPERAND_SIGNED },
173 150
174 /* The BF field in an X or XL form instruction. */ 151 /* The BF field in an X or XL form instruction. */
175#define BF BDPA + 1 152#define BF BDPA + 1
176 { 3, 23, NULL, NULL, PPC_OPERAND_CR }, 153 /* The CRFD field in an X form instruction. */
154#define CRFD BF
155 { 0x7, 23, NULL, NULL, PPC_OPERAND_CR },
156
157 /* The BF field in an X or XL form instruction. */
158#define BFF BF + 1
159 { 0x7, 23, NULL, NULL, 0 },
177 160
178 /* An optional BF field. This is used for comparison instructions, 161 /* An optional BF field. This is used for comparison instructions,
179 in which an omitted BF field is taken as zero. */ 162 in which an omitted BF field is taken as zero. */
180#define OBF BF + 1 163#define OBF BFF + 1
181 { 3, 23, NULL, NULL, PPC_OPERAND_CR | PPC_OPERAND_OPTIONAL }, 164 { 0x7, 23, NULL, NULL, PPC_OPERAND_CR | PPC_OPERAND_OPTIONAL },
182 165
183 /* The BFA field in an X or XL form instruction. */ 166 /* The BFA field in an X or XL form instruction. */
184#define BFA OBF + 1 167#define BFA OBF + 1
185 { 3, 18, NULL, NULL, PPC_OPERAND_CR }, 168 { 0x7, 18, NULL, NULL, PPC_OPERAND_CR },
186
187 /* The BI field in a B form or XL form instruction. */
188#define BI BFA + 1
189#define BI_MASK (0x1f << 16)
190 { 5, 16, NULL, NULL, PPC_OPERAND_CR },
191 169
192 /* The BO field in a B form instruction. Certain values are 170 /* The BO field in a B form instruction. Certain values are
193 illegal. */ 171 illegal. */
194#define BO BI + 1 172#define BO BFA + 1
195#define BO_MASK (0x1f << 21) 173#define BO_MASK (0x1f << 21)
196 { 5, 21, insert_bo, extract_bo, 0 }, 174 { 0x1f, 21, insert_bo, extract_bo, 0 },
197 175
198 /* The BO field in a B form instruction when the + or - modifier is 176 /* The BO field in a B form instruction when the + or - modifier is
199 used. This is like the BO field, but it must be even. */ 177 used. This is like the BO field, but it must be even. */
200#define BOE BO + 1 178#define BOE BO + 1
201 { 5, 21, insert_boe, extract_boe, 0 }, 179 { 0x1e, 21, insert_boe, extract_boe, 0 },
202 180
203#define BH BOE + 1 181#define BH BOE + 1
204 { 2, 11, NULL, NULL, PPC_OPERAND_OPTIONAL }, 182 { 0x3, 11, NULL, NULL, PPC_OPERAND_OPTIONAL },
205 183
206 /* The BT field in an X or XL form instruction. */ 184 /* The BT field in an X or XL form instruction. */
207#define BT BH + 1 185#define BT BH + 1
208 { 5, 21, NULL, NULL, PPC_OPERAND_CR }, 186 { 0x1f, 21, NULL, NULL, PPC_OPERAND_CR },
209 187
210 /* The condition register number portion of the BI field in a B form 188 /* The condition register number portion of the BI field in a B form
211 or XL form instruction. This is used for the extended 189 or XL form instruction. This is used for the extended
212 conditional branch mnemonics, which set the lower two bits of the 190 conditional branch mnemonics, which set the lower two bits of the
213 BI field. This field is optional. */ 191 BI field. This field is optional. */
214#define CR BT + 1 192#define CR BT + 1
215 { 3, 18, NULL, NULL, PPC_OPERAND_CR | PPC_OPERAND_OPTIONAL }, 193 { 0x7, 18, NULL, NULL, PPC_OPERAND_CR | PPC_OPERAND_OPTIONAL },
216 194
217 /* The CRB field in an X form instruction. */ 195 /* The CRB field in an X form instruction. */
218#define CRB CR + 1 196#define CRB CR + 1
219 { 5, 6, NULL, NULL, 0 }, 197 /* The MB field in an M form instruction. */
220 198#define MB CRB
221 /* The CRFD field in an X form instruction. */ 199#define MB_MASK (0x1f << 6)
222#define CRFD CRB + 1 200 { 0x1f, 6, NULL, NULL, 0 },
223 { 3, 23, NULL, NULL, PPC_OPERAND_CR },
224 201
225 /* The CRFS field in an X form instruction. */ 202 /* The CRFS field in an X form instruction. */
226#define CRFS CRFD + 1 203#define CRFS CRB + 1
227 { 3, 0, NULL, NULL, PPC_OPERAND_CR }, 204 { 0x7, 0, NULL, NULL, PPC_OPERAND_CR },
228 205
229 /* The CT field in an X form instruction. */ 206 /* The CT field in an X form instruction. */
230#define CT CRFS + 1 207#define CT CRFS + 1
231 { 5, 21, NULL, NULL, PPC_OPERAND_OPTIONAL }, 208 /* The MO field in an mbar instruction. */
209#define MO CT
210 { 0x1f, 21, NULL, NULL, PPC_OPERAND_OPTIONAL },
232 211
233 /* The D field in a D form instruction. This is a displacement off 212 /* The D field in a D form instruction. This is a displacement off
234 a register, and implies that the next operand is a register in 213 a register, and implies that the next operand is a register in
235 parentheses. */ 214 parentheses. */
236#define D CT + 1 215#define D CT + 1
237 { 16, 0, NULL, NULL, PPC_OPERAND_PARENS | PPC_OPERAND_SIGNED }, 216 { 0xffff, 0, NULL, NULL, PPC_OPERAND_PARENS | PPC_OPERAND_SIGNED },
238 217
239 /* The DE field in a DE form instruction. This is like D, but is 12 218 /* The DE field in a DE form instruction. This is like D, but is 12
240 bits only. */ 219 bits only. */
241#define DE D + 1 220#define DE D + 1
242 { 14, 0, insert_de, extract_de, PPC_OPERAND_PARENS }, 221 { 0xfff, 4, NULL, NULL, PPC_OPERAND_PARENS | PPC_OPERAND_SIGNED },
243 222
244 /* The DES field in a DES form instruction. This is like DS, but is 14 223 /* The DES field in a DES form instruction. This is like DS, but is 14
245 bits only (12 stored.) */ 224 bits only (12 stored.) */
246#define DES DE + 1 225#define DES DE + 1
247 { 14, 0, insert_des, extract_des, PPC_OPERAND_PARENS | PPC_OPERAND_SIGNED }, 226 { 0x3ffc, 2, NULL, NULL, PPC_OPERAND_PARENS | PPC_OPERAND_SIGNED },
248 227
249 /* The DQ field in a DQ form instruction. This is like D, but the 228 /* The DQ field in a DQ form instruction. This is like D, but the
250 lower four bits are forced to zero. */ 229 lower four bits are forced to zero. */
251#define DQ DES + 1 230#define DQ DES + 1
252 { 16, 0, insert_dq, extract_dq, 231 { 0xfff0, 0, NULL, NULL,
253 PPC_OPERAND_PARENS | PPC_OPERAND_SIGNED | PPC_OPERAND_DQ }, 232 PPC_OPERAND_PARENS | PPC_OPERAND_SIGNED | PPC_OPERAND_DQ },
254 233
255 /* The DS field in a DS form instruction. This is like D, but the 234 /* The DS field in a DS form instruction. This is like D, but the
256 lower two bits are forced to zero. */ 235 lower two bits are forced to zero. */
257#define DS DQ + 1 236#define DS DQ + 1
258 { 16, 0, insert_ds, extract_ds, 237 { 0xfffc, 0, NULL, NULL,
259 PPC_OPERAND_PARENS | PPC_OPERAND_SIGNED | PPC_OPERAND_DS }, 238 PPC_OPERAND_PARENS | PPC_OPERAND_SIGNED | PPC_OPERAND_DS },
260 239
261 /* The E field in a wrteei instruction. */ 240 /* The E field in a wrteei instruction. */
262#define E DS + 1 241#define E DS + 1
263 { 1, 15, NULL, NULL, 0 }, 242 { 0x1, 15, NULL, NULL, 0 },
264 243
265 /* The FL1 field in a POWER SC form instruction. */ 244 /* The FL1 field in a POWER SC form instruction. */
266#define FL1 E + 1 245#define FL1 E + 1
267 { 4, 12, NULL, NULL, 0 }, 246 /* The U field in an X form instruction. */
247#define U FL1
248 { 0xf, 12, NULL, NULL, 0 },
268 249
269 /* The FL2 field in a POWER SC form instruction. */ 250 /* The FL2 field in a POWER SC form instruction. */
270#define FL2 FL1 + 1 251#define FL2 FL1 + 1
271 { 3, 2, NULL, NULL, 0 }, 252 { 0x7, 2, NULL, NULL, 0 },
272 253
273 /* The FLM field in an XFL form instruction. */ 254 /* The FLM field in an XFL form instruction. */
274#define FLM FL2 + 1 255#define FLM FL2 + 1
275 { 8, 17, NULL, NULL, 0 }, 256 { 0xff, 17, NULL, NULL, 0 },
276 257
277 /* The FRA field in an X or A form instruction. */ 258 /* The FRA field in an X or A form instruction. */
278#define FRA FLM + 1 259#define FRA FLM + 1
279#define FRA_MASK (0x1f << 16) 260#define FRA_MASK (0x1f << 16)
280 { 5, 16, NULL, NULL, PPC_OPERAND_FPR }, 261 { 0x1f, 16, NULL, NULL, PPC_OPERAND_FPR },
281 262
282 /* The FRB field in an X or A form instruction. */ 263 /* The FRB field in an X or A form instruction. */
283#define FRB FRA + 1 264#define FRB FRA + 1
284#define FRB_MASK (0x1f << 11) 265#define FRB_MASK (0x1f << 11)
285 { 5, 11, NULL, NULL, PPC_OPERAND_FPR }, 266 { 0x1f, 11, NULL, NULL, PPC_OPERAND_FPR },
286 267
287 /* The FRC field in an A form instruction. */ 268 /* The FRC field in an A form instruction. */
288#define FRC FRB + 1 269#define FRC FRB + 1
289#define FRC_MASK (0x1f << 6) 270#define FRC_MASK (0x1f << 6)
290 { 5, 6, NULL, NULL, PPC_OPERAND_FPR }, 271 { 0x1f, 6, NULL, NULL, PPC_OPERAND_FPR },
291 272
292 /* The FRS field in an X form instruction or the FRT field in a D, X 273 /* The FRS field in an X form instruction or the FRT field in a D, X
293 or A form instruction. */ 274 or A form instruction. */
294#define FRS FRC + 1 275#define FRS FRC + 1
295#define FRT FRS 276#define FRT FRS
296 { 5, 21, NULL, NULL, PPC_OPERAND_FPR }, 277 { 0x1f, 21, NULL, NULL, PPC_OPERAND_FPR },
297 278
298 /* The FXM field in an XFX instruction. */ 279 /* The FXM field in an XFX instruction. */
299#define FXM FRS + 1 280#define FXM FRS + 1
300#define FXM_MASK (0xff << 12) 281 { 0xff, 12, insert_fxm, extract_fxm, 0 },
301 { 8, 12, insert_fxm, extract_fxm, 0 },
302 282
303 /* Power4 version for mfcr. */ 283 /* Power4 version for mfcr. */
304#define FXM4 FXM + 1 284#define FXM4 FXM + 1
305 { 8, 12, insert_fxm, extract_fxm, PPC_OPERAND_OPTIONAL }, 285 { 0xff, 12, insert_fxm, extract_fxm, PPC_OPERAND_OPTIONAL },
306 286
307 /* The L field in a D or X form instruction. */ 287 /* The L field in a D or X form instruction. */
308#define L FXM4 + 1 288#define L FXM4 + 1
309 { 1, 21, NULL, NULL, PPC_OPERAND_OPTIONAL }, 289 { 0x1, 21, NULL, NULL, PPC_OPERAND_OPTIONAL },
310 290
311 /* The LEV field in a POWER SVC form instruction. */ 291 /* The LEV field in a POWER SVC form instruction. */
312#define SVC_LEV L + 1 292#define SVC_LEV L + 1
313 { 7, 5, NULL, NULL, 0 }, 293 { 0x7f, 5, NULL, NULL, 0 },
314 294
315 /* The LEV field in an SC form instruction. */ 295 /* The LEV field in an SC form instruction. */
316#define LEV SVC_LEV + 1 296#define LEV SVC_LEV + 1
317 { 7, 5, NULL, NULL, PPC_OPERAND_OPTIONAL }, 297 { 0x7f, 5, NULL, NULL, PPC_OPERAND_OPTIONAL },
318 298
319 /* The LI field in an I form instruction. The lower two bits are 299 /* The LI field in an I form instruction. The lower two bits are
320 forced to zero. */ 300 forced to zero. */
321#define LI LEV + 1 301#define LI LEV + 1
322 { 26, 0, insert_li, extract_li, PPC_OPERAND_RELATIVE | PPC_OPERAND_SIGNED }, 302 { 0x3fffffc, 0, NULL, NULL, PPC_OPERAND_RELATIVE | PPC_OPERAND_SIGNED },
323 303
324 /* The LI field in an I form instruction when used as an absolute 304 /* The LI field in an I form instruction when used as an absolute
325 address. */ 305 address. */
326#define LIA LI + 1 306#define LIA LI + 1
327 { 26, 0, insert_li, extract_li, PPC_OPERAND_ABSOLUTE | PPC_OPERAND_SIGNED }, 307 { 0x3fffffc, 0, NULL, NULL, PPC_OPERAND_ABSOLUTE | PPC_OPERAND_SIGNED },
328 308
329 /* The LS field in an X (sync) form instruction. */ 309 /* The LS field in an X (sync) form instruction. */
330#define LS LIA + 1 310#define LS LIA + 1
331 { 2, 21, NULL, NULL, PPC_OPERAND_OPTIONAL }, 311 { 0x3, 21, NULL, NULL, PPC_OPERAND_OPTIONAL },
332
333 /* The MB field in an M form instruction. */
334#define MB LS + 1
335#define MB_MASK (0x1f << 6)
336 { 5, 6, NULL, NULL, 0 },
337 312
338 /* The ME field in an M form instruction. */ 313 /* The ME field in an M form instruction. */
339#define ME MB + 1 314#define ME LS + 1
340#define ME_MASK (0x1f << 1) 315#define ME_MASK (0x1f << 1)
341 { 5, 1, NULL, NULL, 0 }, 316 { 0x1f, 1, NULL, NULL, 0 },
342 317
343 /* The MB and ME fields in an M form instruction expressed a single 318 /* The MB and ME fields in an M form instruction expressed a single
344 operand which is a bitmask indicating which bits to select. This 319 operand which is a bitmask indicating which bits to select. This
345 is a two operand form using PPC_OPERAND_NEXT. See the 320 is a two operand form using PPC_OPERAND_NEXT. See the
346 description in opcode/ppc.h for what this means. */ 321 description in opcode/ppc.h for what this means. */
347#define MBE ME + 1 322#define MBE ME + 1
348 { 5, 6, NULL, NULL, PPC_OPERAND_OPTIONAL | PPC_OPERAND_NEXT }, 323 { 0x1f, 6, NULL, NULL, PPC_OPERAND_OPTIONAL | PPC_OPERAND_NEXT },
349 { 32, 0, insert_mbe, extract_mbe, 0 }, 324 { -1, 0, insert_mbe, extract_mbe, 0 },
350 325
351 /* The MB or ME field in an MD or MDS form instruction. The high 326 /* The MB or ME field in an MD or MDS form instruction. The high
352 bit is wrapped to the low end. */ 327 bit is wrapped to the low end. */
353#define MB6 MBE + 2 328#define MB6 MBE + 2
354#define ME6 MB6 329#define ME6 MB6
355#define MB6_MASK (0x3f << 5) 330#define MB6_MASK (0x3f << 5)
356 { 6, 5, insert_mb6, extract_mb6, 0 }, 331 { 0x3f, 5, insert_mb6, extract_mb6, 0 },
357
358 /* The MO field in an mbar instruction. */
359#define MO MB6 + 1
360 { 5, 21, NULL, NULL, PPC_OPERAND_OPTIONAL },
361 332
362 /* The NB field in an X form instruction. The value 32 is stored as 333 /* The NB field in an X form instruction. The value 32 is stored as
363 0. */ 334 0. */
364#define NB MO + 1 335#define NB MB6 + 1
365 { 6, 11, insert_nb, extract_nb, 0 }, 336 { 0x1f, 11, NULL, extract_nb, PPC_OPERAND_PLUS1 },
366 337
367 /* The NSI field in a D form instruction. This is the same as the 338 /* The NSI field in a D form instruction. This is the same as the
368 SI field, only negated. */ 339 SI field, only negated. */
369#define NSI NB + 1 340#define NSI NB + 1
370 { 16, 0, insert_nsi, extract_nsi, 341 { 0xffff, 0, insert_nsi, extract_nsi,
371 PPC_OPERAND_NEGATIVE | PPC_OPERAND_SIGNED }, 342 PPC_OPERAND_NEGATIVE | PPC_OPERAND_SIGNED },
372 343
373 /* The RA field in an D, DS, DQ, X, XO, M, or MDS form instruction. */ 344 /* The RA field in an D, DS, DQ, X, XO, M, or MDS form instruction. */
374#define RA NSI + 1 345#define RA NSI + 1
375#define RA_MASK (0x1f << 16) 346#define RA_MASK (0x1f << 16)
376 { 5, 16, NULL, NULL, PPC_OPERAND_GPR }, 347 { 0x1f, 16, NULL, NULL, PPC_OPERAND_GPR },
377 348
378 /* As above, but 0 in the RA field means zero, not r0. */ 349 /* As above, but 0 in the RA field means zero, not r0. */
379#define RA0 RA + 1 350#define RA0 RA + 1
380 { 5, 16, NULL, NULL, PPC_OPERAND_GPR_0 }, 351 { 0x1f, 16, NULL, NULL, PPC_OPERAND_GPR_0 },
381 352
382 /* The RA field in the DQ form lq instruction, which has special 353 /* The RA field in the DQ form lq instruction, which has special
383 value restrictions. */ 354 value restrictions. */
384#define RAQ RA0 + 1 355#define RAQ RA0 + 1
385 { 5, 16, insert_raq, NULL, PPC_OPERAND_GPR_0 }, 356 { 0x1f, 16, insert_raq, NULL, PPC_OPERAND_GPR_0 },
386 357
387 /* The RA field in a D or X form instruction which is an updating 358 /* The RA field in a D or X form instruction which is an updating
388 load, which means that the RA field may not be zero and may not 359 load, which means that the RA field may not be zero and may not
389 equal the RT field. */ 360 equal the RT field. */
390#define RAL RAQ + 1 361#define RAL RAQ + 1
391 { 5, 16, insert_ral, NULL, PPC_OPERAND_GPR_0 }, 362 { 0x1f, 16, insert_ral, NULL, PPC_OPERAND_GPR_0 },
392 363
393 /* The RA field in an lmw instruction, which has special value 364 /* The RA field in an lmw instruction, which has special value
394 restrictions. */ 365 restrictions. */
395#define RAM RAL + 1 366#define RAM RAL + 1
396 { 5, 16, insert_ram, NULL, PPC_OPERAND_GPR_0 }, 367 { 0x1f, 16, insert_ram, NULL, PPC_OPERAND_GPR_0 },
397 368
398 /* The RA field in a D or X form instruction which is an updating 369 /* The RA field in a D or X form instruction which is an updating
399 store or an updating floating point load, which means that the RA 370 store or an updating floating point load, which means that the RA
400 field may not be zero. */ 371 field may not be zero. */
401#define RAS RAM + 1 372#define RAS RAM + 1
402 { 5, 16, insert_ras, NULL, PPC_OPERAND_GPR_0 }, 373 { 0x1f, 16, insert_ras, NULL, PPC_OPERAND_GPR_0 },
403 374
404 /* The RA field of the tlbwe instruction, which is optional. */ 375 /* The RA field of the tlbwe instruction, which is optional. */
405#define RAOPT RAS + 1 376#define RAOPT RAS + 1
406 { 5, 16, NULL, NULL, PPC_OPERAND_GPR | PPC_OPERAND_OPTIONAL }, 377 { 0x1f, 16, NULL, NULL, PPC_OPERAND_GPR | PPC_OPERAND_OPTIONAL },
407 378
408 /* The RB field in an X, XO, M, or MDS form instruction. */ 379 /* The RB field in an X, XO, M, or MDS form instruction. */
409#define RB RAOPT + 1 380#define RB RAOPT + 1
410#define RB_MASK (0x1f << 11) 381#define RB_MASK (0x1f << 11)
411 { 5, 11, NULL, NULL, PPC_OPERAND_GPR }, 382 { 0x1f, 11, NULL, NULL, PPC_OPERAND_GPR },
412 383
413 /* The RB field in an X form instruction when it must be the same as 384 /* The RB field in an X form instruction when it must be the same as
414 the RS field in the instruction. This is used for extended 385 the RS field in the instruction. This is used for extended
415 mnemonics like mr. */ 386 mnemonics like mr. */
416#define RBS RB + 1 387#define RBS RB + 1
417 { 5, 1, insert_rbs, extract_rbs, PPC_OPERAND_FAKE }, 388 { 0x1f, 11, insert_rbs, extract_rbs, PPC_OPERAND_FAKE },
418 389
419 /* The RS field in a D, DS, X, XFX, XS, M, MD or MDS form 390 /* The RS field in a D, DS, X, XFX, XS, M, MD or MDS form
420 instruction or the RT field in a D, DS, X, XFX or XO form 391 instruction or the RT field in a D, DS, X, XFX or XO form
@@ -422,188 +393,168 @@ const struct powerpc_operand powerpc_operands[] =
422#define RS RBS + 1 393#define RS RBS + 1
423#define RT RS 394#define RT RS
424#define RT_MASK (0x1f << 21) 395#define RT_MASK (0x1f << 21)
425 { 5, 21, NULL, NULL, PPC_OPERAND_GPR }, 396 { 0x1f, 21, NULL, NULL, PPC_OPERAND_GPR },
426 397
427 /* The RS field of the DS form stq instruction, which has special 398 /* The RS and RT fields of the DS form stq instruction, which have
428 value restrictions. */ 399 special value restrictions. */
429#define RSQ RS + 1 400#define RSQ RS + 1
430 { 5, 21, insert_rsq, NULL, PPC_OPERAND_GPR_0 }, 401#define RTQ RSQ
431 402 { 0x1e, 21, NULL, NULL, PPC_OPERAND_GPR_0 },
432 /* The RT field of the DQ form lq instruction, which has special
433 value restrictions. */
434#define RTQ RSQ + 1
435 { 5, 21, insert_rtq, NULL, PPC_OPERAND_GPR_0 },
436 403
437 /* The RS field of the tlbwe instruction, which is optional. */ 404 /* The RS field of the tlbwe instruction, which is optional. */
438#define RSO RTQ + 1 405#define RSO RSQ + 1
439#define RTO RSO 406#define RTO RSO
440 { 5, 21, NULL, NULL, PPC_OPERAND_GPR | PPC_OPERAND_OPTIONAL }, 407 { 0x1f, 21, NULL, NULL, PPC_OPERAND_GPR | PPC_OPERAND_OPTIONAL },
441 408
442 /* The SH field in an X or M form instruction. */ 409 /* The SH field in an X or M form instruction. */
443#define SH RSO + 1 410#define SH RSO + 1
444#define SH_MASK (0x1f << 11) 411#define SH_MASK (0x1f << 11)
445 { 5, 11, NULL, NULL, 0 }, 412 /* The other UIMM field in a EVX form instruction. */
413#define EVUIMM SH
414 { 0x1f, 11, NULL, NULL, 0 },
446 415
447 /* The SH field in an MD form instruction. This is split. */ 416 /* The SH field in an MD form instruction. This is split. */
448#define SH6 SH + 1 417#define SH6 SH + 1
449#define SH6_MASK ((0x1f << 11) | (1 << 1)) 418#define SH6_MASK ((0x1f << 11) | (1 << 1))
450 { 6, 1, insert_sh6, extract_sh6, 0 }, 419 { 0x3f, -1, insert_sh6, extract_sh6, 0 },
451 420
452 /* The SH field of the tlbwe instruction, which is optional. */ 421 /* The SH field of the tlbwe instruction, which is optional. */
453#define SHO SH6 + 1 422#define SHO SH6 + 1
454 { 5, 11,NULL, NULL, PPC_OPERAND_OPTIONAL }, 423 { 0x1f, 11, NULL, NULL, PPC_OPERAND_OPTIONAL },
455 424
456 /* The SI field in a D form instruction. */ 425 /* The SI field in a D form instruction. */
457#define SI SHO + 1 426#define SI SHO + 1
458 { 16, 0, NULL, NULL, PPC_OPERAND_SIGNED }, 427 { 0xffff, 0, NULL, NULL, PPC_OPERAND_SIGNED },
459 428
460 /* The SI field in a D form instruction when we accept a wide range 429 /* The SI field in a D form instruction when we accept a wide range
461 of positive values. */ 430 of positive values. */
462#define SISIGNOPT SI + 1 431#define SISIGNOPT SI + 1
463 { 16, 0, NULL, NULL, PPC_OPERAND_SIGNED | PPC_OPERAND_SIGNOPT }, 432 { 0xffff, 0, NULL, NULL, PPC_OPERAND_SIGNED | PPC_OPERAND_SIGNOPT },
464 433
465 /* The SPR field in an XFX form instruction. This is flipped--the 434 /* The SPR field in an XFX form instruction. This is flipped--the
466 lower 5 bits are stored in the upper 5 and vice- versa. */ 435 lower 5 bits are stored in the upper 5 and vice- versa. */
467#define SPR SISIGNOPT + 1 436#define SPR SISIGNOPT + 1
468#define PMR SPR 437#define PMR SPR
469#define SPR_MASK (0x3ff << 11) 438#define SPR_MASK (0x3ff << 11)
470 { 10, 11, insert_spr, extract_spr, 0 }, 439 { 0x3ff, 11, insert_spr, extract_spr, 0 },
471 440
472 /* The BAT index number in an XFX form m[ft]ibat[lu] instruction. */ 441 /* The BAT index number in an XFX form m[ft]ibat[lu] instruction. */
473#define SPRBAT SPR + 1 442#define SPRBAT SPR + 1
474#define SPRBAT_MASK (0x3 << 17) 443#define SPRBAT_MASK (0x3 << 17)
475 { 2, 17, NULL, NULL, 0 }, 444 { 0x3, 17, NULL, NULL, 0 },
476 445
477 /* The SPRG register number in an XFX form m[ft]sprg instruction. */ 446 /* The SPRG register number in an XFX form m[ft]sprg instruction. */
478#define SPRG SPRBAT + 1 447#define SPRG SPRBAT + 1
479 { 5, 16, insert_sprg, extract_sprg, 0 }, 448 { 0x1f, 16, insert_sprg, extract_sprg, 0 },
480 449
481 /* The SR field in an X form instruction. */ 450 /* The SR field in an X form instruction. */
482#define SR SPRG + 1 451#define SR SPRG + 1
483 { 4, 16, NULL, NULL, 0 }, 452 { 0xf, 16, NULL, NULL, 0 },
484 453
485 /* The STRM field in an X AltiVec form instruction. */ 454 /* The STRM field in an X AltiVec form instruction. */
486#define STRM SR + 1 455#define STRM SR + 1
487#define STRM_MASK (0x3 << 21) 456 { 0x3, 21, NULL, NULL, 0 },
488 { 2, 21, NULL, NULL, 0 },
489 457
490 /* The SV field in a POWER SC form instruction. */ 458 /* The SV field in a POWER SC form instruction. */
491#define SV STRM + 1 459#define SV STRM + 1
492 { 14, 2, NULL, NULL, 0 }, 460 { 0x3fff, 2, NULL, NULL, 0 },
493 461
494 /* The TBR field in an XFX form instruction. This is like the SPR 462 /* The TBR field in an XFX form instruction. This is like the SPR
495 field, but it is optional. */ 463 field, but it is optional. */
496#define TBR SV + 1 464#define TBR SV + 1
497 { 10, 11, insert_tbr, extract_tbr, PPC_OPERAND_OPTIONAL }, 465 { 0x3ff, 11, insert_tbr, extract_tbr, PPC_OPERAND_OPTIONAL },
498 466
499 /* The TO field in a D or X form instruction. */ 467 /* The TO field in a D or X form instruction. */
500#define TO TBR + 1 468#define TO TBR + 1
501#define TO_MASK (0x1f << 21) 469#define TO_MASK (0x1f << 21)
502 { 5, 21, NULL, NULL, 0 }, 470 { 0x1f, 21, NULL, NULL, 0 },
503
504 /* The U field in an X form instruction. */
505#define U TO + 1
506 { 4, 12, NULL, NULL, 0 },
507 471
508 /* The UI field in a D form instruction. */ 472 /* The UI field in a D form instruction. */
509#define UI U + 1 473#define UI TO + 1
510 { 16, 0, NULL, NULL, 0 }, 474 { 0xffff, 0, NULL, NULL, 0 },
511 475
512 /* The VA field in a VA, VX or VXR form instruction. */ 476 /* The VA field in a VA, VX or VXR form instruction. */
513#define VA UI + 1 477#define VA UI + 1
514#define VA_MASK (0x1f << 16) 478 { 0x1f, 16, NULL, NULL, PPC_OPERAND_VR },
515 { 5, 16, NULL, NULL, PPC_OPERAND_VR },
516 479
517 /* The VB field in a VA, VX or VXR form instruction. */ 480 /* The VB field in a VA, VX or VXR form instruction. */
518#define VB VA + 1 481#define VB VA + 1
519#define VB_MASK (0x1f << 11) 482 { 0x1f, 11, NULL, NULL, PPC_OPERAND_VR },
520 { 5, 11, NULL, NULL, PPC_OPERAND_VR },
521 483
522 /* The VC field in a VA form instruction. */ 484 /* The VC field in a VA form instruction. */
523#define VC VB + 1 485#define VC VB + 1
524#define VC_MASK (0x1f << 6) 486 { 0x1f, 6, NULL, NULL, PPC_OPERAND_VR },
525 { 5, 6, NULL, NULL, PPC_OPERAND_VR },
526 487
527 /* The VD or VS field in a VA, VX, VXR or X form instruction. */ 488 /* The VD or VS field in a VA, VX, VXR or X form instruction. */
528#define VD VC + 1 489#define VD VC + 1
529#define VS VD 490#define VS VD
530#define VD_MASK (0x1f << 21) 491 { 0x1f, 21, NULL, NULL, PPC_OPERAND_VR },
531 { 5, 21, NULL, NULL, PPC_OPERAND_VR },
532 492
533 /* The SIMM field in a VX form instruction. */ 493 /* The SIMM field in a VX form instruction. */
534#define SIMM VD + 1 494#define SIMM VD + 1
535 { 5, 16, NULL, NULL, PPC_OPERAND_SIGNED}, 495 { 0x1f, 16, NULL, NULL, PPC_OPERAND_SIGNED},
536 496
537 /* The UIMM field in a VX form instruction. */ 497 /* The UIMM field in a VX form instruction, and TE in Z form. */
538#define UIMM SIMM + 1 498#define UIMM SIMM + 1
539 { 5, 16, NULL, NULL, 0 }, 499#define TE UIMM
500 { 0x1f, 16, NULL, NULL, 0 },
540 501
541 /* The SHB field in a VA form instruction. */ 502 /* The SHB field in a VA form instruction. */
542#define SHB UIMM + 1 503#define SHB UIMM + 1
543 { 4, 6, NULL, NULL, 0 }, 504 { 0xf, 6, NULL, NULL, 0 },
544
545 /* The other UIMM field in a EVX form instruction. */
546#define EVUIMM SHB + 1
547 { 5, 11, NULL, NULL, 0 },
548 505
549 /* The other UIMM field in a half word EVX form instruction. */ 506 /* The other UIMM field in a half word EVX form instruction. */
550#define EVUIMM_2 EVUIMM + 1 507#define EVUIMM_2 SHB + 1
551 { 32, 11, insert_ev2, extract_ev2, PPC_OPERAND_PARENS }, 508 { 0x3e, 10, NULL, NULL, PPC_OPERAND_PARENS },
552 509
553 /* The other UIMM field in a word EVX form instruction. */ 510 /* The other UIMM field in a word EVX form instruction. */
554#define EVUIMM_4 EVUIMM_2 + 1 511#define EVUIMM_4 EVUIMM_2 + 1
555 { 32, 11, insert_ev4, extract_ev4, PPC_OPERAND_PARENS }, 512 { 0x7c, 9, NULL, NULL, PPC_OPERAND_PARENS },
556 513
557 /* The other UIMM field in a double EVX form instruction. */ 514 /* The other UIMM field in a double EVX form instruction. */
558#define EVUIMM_8 EVUIMM_4 + 1 515#define EVUIMM_8 EVUIMM_4 + 1
559 { 32, 11, insert_ev8, extract_ev8, PPC_OPERAND_PARENS }, 516 { 0xf8, 8, NULL, NULL, PPC_OPERAND_PARENS },
560 517
561 /* The WS field. */ 518 /* The WS field. */
562#define WS EVUIMM_8 + 1 519#define WS EVUIMM_8 + 1
563#define WS_MASK (0x7 << 11) 520 { 0x7, 11, NULL, NULL, 0 },
564 { 3, 11, NULL, NULL, 0 },
565
566 /* The L field in an mtmsrd or A form instruction. */
567#define MTMSRD_L WS + 1
568#define A_L MTMSRD_L
569 { 1, 16, NULL, NULL, PPC_OPERAND_OPTIONAL },
570
571 /* The DCM field in a Z form instruction. */
572#define DCM MTMSRD_L + 1
573 { 6, 16, NULL, NULL, 0 },
574 521
575 /* Likewise, the DGM field in a Z form instruction. */ 522 /* The L field in an mtmsrd or A form instruction or W in an X form. */
576#define DGM DCM + 1 523#define A_L WS + 1
577 { 6, 16, NULL, NULL, 0 }, 524#define W A_L
525 { 0x1, 16, NULL, NULL, PPC_OPERAND_OPTIONAL },
578 526
579#define TE DGM + 1 527#define RMC A_L + 1
580 { 5, 11, NULL, NULL, 0 }, 528 { 0x3, 9, NULL, NULL, 0 },
581
582#define RMC TE + 1
583 { 2, 21, NULL, NULL, 0 },
584 529
585#define R RMC + 1 530#define R RMC + 1
586 { 1, 15, NULL, NULL, 0 }, 531 { 0x1, 16, NULL, NULL, 0 },
587 532
588#define SP R + 1 533#define SP R + 1
589 { 2, 11, NULL, NULL, 0 }, 534 { 0x3, 19, NULL, NULL, 0 },
590 535
591#define S SP + 1 536#define S SP + 1
592 { 1, 11, NULL, NULL, 0 }, 537 { 0x1, 20, NULL, NULL, 0 },
593 538
594 /* SH field starting at bit position 16. */ 539 /* SH field starting at bit position 16. */
595#define SH16 S + 1 540#define SH16 S + 1
596 { 6, 10, NULL, NULL, 0 }, 541 /* The DCM and DGM fields in a Z form instruction. */
597 542#define DCM SH16
598 /* The L field in an X form with the RT field fixed instruction. */ 543#define DGM DCM
599#define XRT_L SH16 + 1 544 { 0x3f, 10, NULL, NULL, 0 },
600 { 2, 21, NULL, NULL, PPC_OPERAND_OPTIONAL },
601 545
602 /* The EH field in larx instruction. */ 546 /* The EH field in larx instruction. */
603#define EH XRT_L + 1 547#define EH SH16 + 1
604 { 1, 0, NULL, NULL, PPC_OPERAND_OPTIONAL }, 548 { 0x1, 0, NULL, NULL, PPC_OPERAND_OPTIONAL },
549
550 /* The L field in an mtfsf or XFL form instruction. */
551#define XFL_L EH + 1
552 { 0x1, 25, NULL, NULL, PPC_OPERAND_OPTIONAL},
605}; 553};
606 554
555const unsigned int num_powerpc_operands = (sizeof (powerpc_operands)
556 / sizeof (powerpc_operands[0]));
557
607/* The functions used to insert and extract complicated operands. */ 558/* The functions used to insert and extract complicated operands. */
608 559
609/* The BA field in an XL form instruction when it must be the same as 560/* The BA field in an XL form instruction when it must be the same as
@@ -656,26 +607,6 @@ extract_bba (unsigned long insn,
656 return 0; 607 return 0;
657} 608}
658 609
659/* The BD field in a B form instruction. The lower two bits are
660 forced to zero. */
661
662static unsigned long
663insert_bd (unsigned long insn,
664 long value,
665 int dialect ATTRIBUTE_UNUSED,
666 const char **errmsg ATTRIBUTE_UNUSED)
667{
668 return insn | (value & 0xfffc);
669}
670
671static long
672extract_bd (unsigned long insn,
673 int dialect ATTRIBUTE_UNUSED,
674 int *invalid ATTRIBUTE_UNUSED)
675{
676 return ((insn & 0xfffc) ^ 0x8000) - 0x8000;
677}
678
679/* The BD field in a B form instruction when the - modifier is used. 610/* The BD field in a B form instruction when the - modifier is used.
680 This modifier means that the branch is not expected to be taken. 611 This modifier means that the branch is not expected to be taken.
681 For chips built to versions of the architecture prior to version 2 612 For chips built to versions of the architecture prior to version 2
@@ -687,7 +618,11 @@ extract_bd (unsigned long insn,
687 the "y" bit. "at" == 00 => no hint, "at" == 01 => unpredictable, 618 the "y" bit. "at" == 00 => no hint, "at" == 01 => unpredictable,
688 "at" == 10 => not taken, "at" == 11 => taken. The "t" bit is 00001 619 "at" == 10 => not taken, "at" == 11 => taken. The "t" bit is 00001
689 in BO field, the "a" bit is 00010 for branch on CR(BI) and 01000 620 in BO field, the "a" bit is 00010 for branch on CR(BI) and 01000
690 for branch on CTR. We only handle the taken/not-taken hint here. */ 621 for branch on CTR. We only handle the taken/not-taken hint here.
622 Note that we don't relax the conditions tested here when
623 disassembling with -Many because insns using extract_bdm and
624 extract_bdp always occur in pairs. One or the other will always
625 be valid. */
691 626
692static unsigned long 627static unsigned long
693insert_bdm (unsigned long insn, 628insert_bdm (unsigned long insn,
@@ -778,10 +713,11 @@ extract_bdp (unsigned long insn,
778/* Check for legal values of a BO field. */ 713/* Check for legal values of a BO field. */
779 714
780static int 715static int
781valid_bo (long value, int dialect) 716valid_bo (long value, int dialect, int extract)
782{ 717{
783 if ((dialect & PPC_OPCODE_POWER4) == 0) 718 if ((dialect & PPC_OPCODE_POWER4) == 0)
784 { 719 {
720 int valid;
785 /* Certain encodings have bits that are required to be zero. 721 /* Certain encodings have bits that are required to be zero.
786 These are (z must be zero, y may be anything): 722 These are (z must be zero, y may be anything):
787 001zy 723 001zy
@@ -794,36 +730,43 @@ valid_bo (long value, int dialect)
794 { 730 {
795 default: 731 default:
796 case 0: 732 case 0:
797 return 1; 733 valid = 1;
734 break;
798 case 0x4: 735 case 0x4:
799 return (value & 0x2) == 0; 736 valid = (value & 0x2) == 0;
737 break;
800 case 0x10: 738 case 0x10:
801 return (value & 0x8) == 0; 739 valid = (value & 0x8) == 0;
740 break;
802 case 0x14: 741 case 0x14:
803 return value == 0x14; 742 valid = value == 0x14;
743 break;
804 } 744 }
745 /* When disassembling with -Many, accept power4 encodings too. */
746 if (valid
747 || (dialect & PPC_OPCODE_ANY) == 0
748 || !extract)
749 return valid;
805 } 750 }
751
752 /* Certain encodings have bits that are required to be zero.
753 These are (z must be zero, a & t may be anything):
754 0000z
755 0001z
756 0100z
757 0101z
758 001at
759 011at
760 1a00t
761 1a01t
762 1z1zz
763 */
764 if ((value & 0x14) == 0)
765 return (value & 0x1) == 0;
766 else if ((value & 0x14) == 0x14)
767 return value == 0x14;
806 else 768 else
807 { 769 return 1;
808 /* Certain encodings have bits that are required to be zero.
809 These are (z must be zero, a & t may be anything):
810 0000z
811 0001z
812 0100z
813 0101z
814 001at
815 011at
816 1a00t
817 1a01t
818 1z1zz
819 */
820 if ((value & 0x14) == 0)
821 return (value & 0x1) == 0;
822 else if ((value & 0x14) == 0x14)
823 return value == 0x14;
824 else
825 return 1;
826 }
827} 770}
828 771
829/* The BO field in a B form instruction. Warn about attempts to set 772/* The BO field in a B form instruction. Warn about attempts to set
@@ -835,7 +778,7 @@ insert_bo (unsigned long insn,
835 int dialect, 778 int dialect,
836 const char **errmsg) 779 const char **errmsg)
837{ 780{
838 if (!valid_bo (value, dialect)) 781 if (!valid_bo (value, dialect, 0))
839 *errmsg = _("invalid conditional option"); 782 *errmsg = _("invalid conditional option");
840 return insn | ((value & 0x1f) << 21); 783 return insn | ((value & 0x1f) << 21);
841} 784}
@@ -848,7 +791,7 @@ extract_bo (unsigned long insn,
848 long value; 791 long value;
849 792
850 value = (insn >> 21) & 0x1f; 793 value = (insn >> 21) & 0x1f;
851 if (!valid_bo (value, dialect)) 794 if (!valid_bo (value, dialect, 1))
852 *invalid = 1; 795 *invalid = 1;
853 return value; 796 return value;
854} 797}
@@ -863,7 +806,7 @@ insert_boe (unsigned long insn,
863 int dialect, 806 int dialect,
864 const char **errmsg) 807 const char **errmsg)
865{ 808{
866 if (!valid_bo (value, dialect)) 809 if (!valid_bo (value, dialect, 0))
867 *errmsg = _("invalid conditional option"); 810 *errmsg = _("invalid conditional option");
868 else if ((value & 1) != 0) 811 else if ((value & 1) != 0)
869 *errmsg = _("attempt to set y bit when using + or - modifier"); 812 *errmsg = _("attempt to set y bit when using + or - modifier");
@@ -879,162 +822,11 @@ extract_boe (unsigned long insn,
879 long value; 822 long value;
880 823
881 value = (insn >> 21) & 0x1f; 824 value = (insn >> 21) & 0x1f;
882 if (!valid_bo (value, dialect)) 825 if (!valid_bo (value, dialect, 1))
883 *invalid = 1; 826 *invalid = 1;
884 return value & 0x1e; 827 return value & 0x1e;
885} 828}
886 829
887/* The DQ field in a DQ form instruction. This is like D, but the
888 lower four bits are forced to zero. */
889
890static unsigned long
891insert_dq (unsigned long insn,
892 long value,
893 int dialect ATTRIBUTE_UNUSED,
894 const char **errmsg)
895{
896 if ((value & 0xf) != 0)
897 *errmsg = _("offset not a multiple of 16");
898 return insn | (value & 0xfff0);
899}
900
901static long
902extract_dq (unsigned long insn,
903 int dialect ATTRIBUTE_UNUSED,
904 int *invalid ATTRIBUTE_UNUSED)
905{
906 return ((insn & 0xfff0) ^ 0x8000) - 0x8000;
907}
908
909static unsigned long
910insert_ev2 (unsigned long insn,
911 long value,
912 int dialect ATTRIBUTE_UNUSED,
913 const char **errmsg)
914{
915 if ((value & 1) != 0)
916 *errmsg = _("offset not a multiple of 2");
917 if ((value > 62) != 0)
918 *errmsg = _("offset greater than 62");
919 return insn | ((value & 0x3e) << 10);
920}
921
922static long
923extract_ev2 (unsigned long insn,
924 int dialect ATTRIBUTE_UNUSED,
925 int *invalid ATTRIBUTE_UNUSED)
926{
927 return (insn >> 10) & 0x3e;
928}
929
930static unsigned long
931insert_ev4 (unsigned long insn,
932 long value,
933 int dialect ATTRIBUTE_UNUSED,
934 const char **errmsg)
935{
936 if ((value & 3) != 0)
937 *errmsg = _("offset not a multiple of 4");
938 if ((value > 124) != 0)
939 *errmsg = _("offset greater than 124");
940 return insn | ((value & 0x7c) << 9);
941}
942
943static long
944extract_ev4 (unsigned long insn,
945 int dialect ATTRIBUTE_UNUSED,
946 int *invalid ATTRIBUTE_UNUSED)
947{
948 return (insn >> 9) & 0x7c;
949}
950
951static unsigned long
952insert_ev8 (unsigned long insn,
953 long value,
954 int dialect ATTRIBUTE_UNUSED,
955 const char **errmsg)
956{
957 if ((value & 7) != 0)
958 *errmsg = _("offset not a multiple of 8");
959 if ((value > 248) != 0)
960 *errmsg = _("offset greater than 248");
961 return insn | ((value & 0xf8) << 8);
962}
963
964static long
965extract_ev8 (unsigned long insn,
966 int dialect ATTRIBUTE_UNUSED,
967 int *invalid ATTRIBUTE_UNUSED)
968{
969 return (insn >> 8) & 0xf8;
970}
971
972/* The DS field in a DS form instruction. This is like D, but the
973 lower two bits are forced to zero. */
974
975static unsigned long
976insert_ds (unsigned long insn,
977 long value,
978 int dialect ATTRIBUTE_UNUSED,
979 const char **errmsg)
980{
981 if ((value & 3) != 0)
982 *errmsg = _("offset not a multiple of 4");
983 return insn | (value & 0xfffc);
984}
985
986static long
987extract_ds (unsigned long insn,
988 int dialect ATTRIBUTE_UNUSED,
989 int *invalid ATTRIBUTE_UNUSED)
990{
991 return ((insn & 0xfffc) ^ 0x8000) - 0x8000;
992}
993
994/* The DE field in a DE form instruction. */
995
996static unsigned long
997insert_de (unsigned long insn,
998 long value,
999 int dialect ATTRIBUTE_UNUSED,
1000 const char **errmsg)
1001{
1002 if (value > 2047 || value < -2048)
1003 *errmsg = _("offset not between -2048 and 2047");
1004 return insn | ((value << 4) & 0xfff0);
1005}
1006
1007static long
1008extract_de (unsigned long insn,
1009 int dialect ATTRIBUTE_UNUSED,
1010 int *invalid ATTRIBUTE_UNUSED)
1011{
1012 return (insn & 0xfff0) >> 4;
1013}
1014
1015/* The DES field in a DES form instruction. */
1016
1017static unsigned long
1018insert_des (unsigned long insn,
1019 long value,
1020 int dialect ATTRIBUTE_UNUSED,
1021 const char **errmsg)
1022{
1023 if (value > 8191 || value < -8192)
1024 *errmsg = _("offset not between -8192 and 8191");
1025 else if ((value & 3) != 0)
1026 *errmsg = _("offset not a multiple of 4");
1027 return insn | ((value << 2) & 0xfff0);
1028}
1029
1030static long
1031extract_des (unsigned long insn,
1032 int dialect ATTRIBUTE_UNUSED,
1033 int *invalid ATTRIBUTE_UNUSED)
1034{
1035 return (((insn >> 2) & 0x3ffc) ^ 0x2000) - 0x2000;
1036}
1037
1038/* FXM mask in mfcr and mtcrf instructions. */ 830/* FXM mask in mfcr and mtcrf instructions. */
1039 831
1040static unsigned long 832static unsigned long
@@ -1107,28 +899,6 @@ extract_fxm (unsigned long insn,
1107 return mask; 899 return mask;
1108} 900}
1109 901
1110/* The LI field in an I form instruction. The lower two bits are
1111 forced to zero. */
1112
1113static unsigned long
1114insert_li (unsigned long insn,
1115 long value,
1116 int dialect ATTRIBUTE_UNUSED,
1117 const char **errmsg)
1118{
1119 if ((value & 3) != 0)
1120 *errmsg = _("ignoring least significant bits in branch offset");
1121 return insn | (value & 0x3fffffc);
1122}
1123
1124static long
1125extract_li (unsigned long insn,
1126 int dialect ATTRIBUTE_UNUSED,
1127 int *invalid ATTRIBUTE_UNUSED)
1128{
1129 return ((insn & 0x3fffffc) ^ 0x2000000) - 0x2000000;
1130}
1131
1132/* The MB and ME fields in an M form instruction expressed as a single 902/* The MB and ME fields in an M form instruction expressed as a single
1133 operand which is itself a bitmask. The extraction function always 903 operand which is itself a bitmask. The extraction function always
1134 marks it as invalid, since we never want to recognize an 904 marks it as invalid, since we never want to recognize an
@@ -1240,19 +1010,6 @@ extract_mb6 (unsigned long insn,
1240/* The NB field in an X form instruction. The value 32 is stored as 1010/* The NB field in an X form instruction. The value 32 is stored as
1241 0. */ 1011 0. */
1242 1012
1243static unsigned long
1244insert_nb (unsigned long insn,
1245 long value,
1246 int dialect ATTRIBUTE_UNUSED,
1247 const char **errmsg)
1248{
1249 if (value < 0 || value > 32)
1250 *errmsg = _("value out of range");
1251 if (value == 32)
1252 value = 0;
1253 return insn | ((value & 0x1f) << 11);
1254}
1255
1256static long 1013static long
1257extract_nb (unsigned long insn, 1014extract_nb (unsigned long insn,
1258 int dialect ATTRIBUTE_UNUSED, 1015 int dialect ATTRIBUTE_UNUSED,
@@ -1375,34 +1132,6 @@ extract_rbs (unsigned long insn,
1375 return 0; 1132 return 0;
1376} 1133}
1377 1134
1378/* The RT field of the DQ form lq instruction, which has special
1379 value restrictions. */
1380
1381static unsigned long
1382insert_rtq (unsigned long insn,
1383 long value,
1384 int dialect ATTRIBUTE_UNUSED,
1385 const char **errmsg)
1386{
1387 if ((value & 1) != 0)
1388 *errmsg = _("target register operand must be even");
1389 return insn | ((value & 0x1f) << 21);
1390}
1391
1392/* The RS field of the DS form stq instruction, which has special
1393 value restrictions. */
1394
1395static unsigned long
1396insert_rsq (unsigned long insn,
1397 long value ATTRIBUTE_UNUSED,
1398 int dialect ATTRIBUTE_UNUSED,
1399 const char **errmsg)
1400{
1401 if ((value & 1) != 0)
1402 *errmsg = _("source register operand must be even");
1403 return insn | ((value & 0x1f) << 21);
1404}
1405
1406/* The SH field in an MD form instruction. This is split. */ 1135/* The SH field in an MD form instruction. This is split. */
1407 1136
1408static unsigned long 1137static unsigned long
@@ -1675,10 +1404,14 @@ extract_tbr (unsigned long insn,
1675 1404
1676/* The mask for a Z form instruction. */ 1405/* The mask for a Z form instruction. */
1677#define Z_MASK ZRC (0x3f, 0x1ff, 1) 1406#define Z_MASK ZRC (0x3f, 0x1ff, 1)
1407#define Z2_MASK ZRC (0x3f, 0xff, 1)
1678 1408
1679/* An X_MASK with the RA field fixed. */ 1409/* An X_MASK with the RA field fixed. */
1680#define XRA_MASK (X_MASK | RA_MASK) 1410#define XRA_MASK (X_MASK | RA_MASK)
1681 1411
1412/* An XRA_MASK with the W field clear. */
1413#define XWRA_MASK (XRA_MASK & ~((unsigned long) 1 << 16))
1414
1682/* An X_MASK with the RB field fixed. */ 1415/* An X_MASK with the RB field fixed. */
1683#define XRB_MASK (X_MASK | RB_MASK) 1416#define XRB_MASK (X_MASK | RB_MASK)
1684 1417
@@ -1733,7 +1466,7 @@ extract_tbr (unsigned long insn,
1733 1466
1734/* An XFL form instruction. */ 1467/* An XFL form instruction. */
1735#define XFL(op, xop, rc) (OP (op) | ((((unsigned long)(xop)) & 0x3ff) << 1) | (((unsigned long)(rc)) & 1)) 1468#define XFL(op, xop, rc) (OP (op) | ((((unsigned long)(xop)) & 0x3ff) << 1) | (((unsigned long)(rc)) & 1))
1736#define XFL_MASK (XFL (0x3f, 0x3ff, 1) | (((unsigned long)1) << 25) | (((unsigned long)1) << 16)) 1469#define XFL_MASK XFL (0x3f, 0x3ff, 1)
1737 1470
1738/* An X form isel instruction. */ 1471/* An X form isel instruction. */
1739#define XISEL(op, xop) (OP (op) | ((((unsigned long)(xop)) & 0x1f) << 1)) 1472#define XISEL(op, xop) (OP (op) | ((((unsigned long)(xop)) & 0x1f) << 1))
@@ -1809,7 +1542,7 @@ extract_tbr (unsigned long insn,
1809 1542
1810/* An XFX form instruction with the SPR field filled in except for the 1543/* An XFX form instruction with the SPR field filled in except for the
1811 SPRG field. */ 1544 SPRG field. */
1812#define XSPRG_MASK (XSPR_MASK & ~(0x17 << 16)) 1545#define XSPRG_MASK (XSPR_MASK & ~(0x1f << 16))
1813 1546
1814/* An X form instruction with everything filled in except the E field. */ 1547/* An X form instruction with everything filled in except the E field. */
1815#define XE_MASK (0xffff7fff) 1548#define XE_MASK (0xffff7fff)
@@ -3240,8 +2973,8 @@ const struct powerpc_opcode powerpc_opcodes[] = {
3240{ "bcctrl", XLLK(19,528,1), XLBH_MASK, PPCCOM, { BO, BI, BH } }, 2973{ "bcctrl", XLLK(19,528,1), XLBH_MASK, PPCCOM, { BO, BI, BH } },
3241{ "bcc", XLLK(19,528,0), XLBB_MASK, PWRCOM, { BO, BI } }, 2974{ "bcc", XLLK(19,528,0), XLBB_MASK, PWRCOM, { BO, BI } },
3242{ "bccl", XLLK(19,528,1), XLBB_MASK, PWRCOM, { BO, BI } }, 2975{ "bccl", XLLK(19,528,1), XLBB_MASK, PWRCOM, { BO, BI } },
3243{ "bcctre", XLLK(19,529,0), XLYBB_MASK, BOOKE64, { BO, BI } }, 2976{ "bcctre", XLLK(19,529,0), XLBB_MASK, BOOKE64, { BO, BI } },
3244{ "bcctrel", XLLK(19,529,1), XLYBB_MASK, BOOKE64, { BO, BI } }, 2977{ "bcctrel", XLLK(19,529,1), XLBB_MASK, BOOKE64, { BO, BI } },
3245 2978
3246{ "rlwimi", M(20,0), M_MASK, PPCCOM, { RA,RS,SH,MBE,ME } }, 2979{ "rlwimi", M(20,0), M_MASK, PPCCOM, { RA,RS,SH,MBE,ME } },
3247{ "rlimi", M(20,0), M_MASK, PWRCOM, { RA,RS,SH,MBE,ME } }, 2980{ "rlimi", M(20,0), M_MASK, PWRCOM, { RA,RS,SH,MBE,ME } },
@@ -3486,7 +3219,7 @@ const struct powerpc_opcode powerpc_opcodes[] = {
3486{ "ldarx", X(31,84), XEH_MASK, PPC64, { RT, RA0, RB, EH } }, 3219{ "ldarx", X(31,84), XEH_MASK, PPC64, { RT, RA0, RB, EH } },
3487 3220
3488{ "dcbfl", XOPL(31,86,1), XRT_MASK, POWER5, { RA, RB } }, 3221{ "dcbfl", XOPL(31,86,1), XRT_MASK, POWER5, { RA, RB } },
3489{ "dcbf", X(31,86), XLRT_MASK, PPC, { RA, RB, XRT_L } }, 3222{ "dcbf", X(31,86), XLRT_MASK, PPC, { RA, RB, L } },
3490 3223
3491{ "lbzx", X(31,87), X_MASK, COM, { RT, RA0, RB } }, 3224{ "lbzx", X(31,87), X_MASK, COM, { RT, RA0, RB } },
3492 3225
@@ -3575,7 +3308,7 @@ const struct powerpc_opcode powerpc_opcodes[] = {
3575{ "dcbtls", X(31,166), X_MASK, PPCCHLK, { CT, RA, RB }}, 3308{ "dcbtls", X(31,166), X_MASK, PPCCHLK, { CT, RA, RB }},
3576{ "dcbtlse", X(31,174), X_MASK, PPCCHLK64, { CT, RA, RB }}, 3309{ "dcbtlse", X(31,174), X_MASK, PPCCHLK64, { CT, RA, RB }},
3577 3310
3578{ "mtmsrd", X(31,178), XRLARB_MASK, PPC64, { RS, MTMSRD_L } }, 3311{ "mtmsrd", X(31,178), XRLARB_MASK, PPC64, { RS, A_L } },
3579 3312
3580{ "stdux", X(31,181), X_MASK, PPC64, { RS, RAS, RB } }, 3313{ "stdux", X(31,181), X_MASK, PPC64, { RS, RAS, RB } },
3581 3314
@@ -4026,6 +3759,13 @@ const struct powerpc_opcode powerpc_opcodes[] = {
4026 3759
4027{ "sthuxe", X(31,447), X_MASK, BOOKE64, { RS, RAS, RB } }, 3760{ "sthuxe", X(31,447), X_MASK, BOOKE64, { RS, RAS, RB } },
4028 3761
3762{ "cctpl", 0x7c210b78, 0xffffffff, CELL, { 0 }},
3763{ "cctpm", 0x7c421378, 0xffffffff, CELL, { 0 }},
3764{ "cctph", 0x7c631b78, 0xffffffff, CELL, { 0 }},
3765{ "db8cyc", 0x7f9ce378, 0xffffffff, CELL, { 0 }},
3766{ "db10cyc", 0x7fbdeb78, 0xffffffff, CELL, { 0 }},
3767{ "db12cyc", 0x7fdef378, 0xffffffff, CELL, { 0 }},
3768{ "db16cyc", 0x7ffffb78, 0xffffffff, CELL, { 0 }},
4029{ "mr", XRC(31,444,0), X_MASK, COM, { RA, RS, RBS } }, 3769{ "mr", XRC(31,444,0), X_MASK, COM, { RA, RS, RBS } },
4030{ "or", XRC(31,444,0), X_MASK, COM, { RA, RS, RB } }, 3770{ "or", XRC(31,444,0), X_MASK, COM, { RA, RS, RB } },
4031{ "mr.", XRC(31,444,1), X_MASK, COM, { RA, RS, RBS } }, 3771{ "mr.", XRC(31,444,1), X_MASK, COM, { RA, RS, RBS } },
@@ -4446,8 +4186,8 @@ const struct powerpc_opcode powerpc_opcodes[] = {
4446 4186
4447{ "tlbsx", XRC(31,914,0), X_MASK, PPC403|BOOKE, { RTO, RA, RB } }, 4187{ "tlbsx", XRC(31,914,0), X_MASK, PPC403|BOOKE, { RTO, RA, RB } },
4448{ "tlbsx.", XRC(31,914,1), X_MASK, PPC403|BOOKE, { RTO, RA, RB } }, 4188{ "tlbsx.", XRC(31,914,1), X_MASK, PPC403|BOOKE, { RTO, RA, RB } },
4449{ "tlbsxe", XRC(31,915,0), X_MASK, BOOKE64, { RA, RB } }, 4189{ "tlbsxe", XRC(31,915,0), X_MASK, BOOKE64, { RTO, RA, RB } },
4450{ "tlbsxe.", XRC(31,915,1), X_MASK, BOOKE64, { RA, RB } }, 4190{ "tlbsxe.", XRC(31,915,1), X_MASK, BOOKE64, { RTO, RA, RB } },
4451 4191
4452{ "slbmfee", X(31,915), XRA_MASK, PPC64, { RT, RB } }, 4192{ "slbmfee", X(31,915), XRA_MASK, PPC64, { RT, RB } },
4453 4193
@@ -4624,8 +4364,8 @@ const struct powerpc_opcode powerpc_opcodes[] = {
4624{ "dadd", XRC(59,2,0), X_MASK, POWER6, { FRT, FRA, FRB } }, 4364{ "dadd", XRC(59,2,0), X_MASK, POWER6, { FRT, FRA, FRB } },
4625{ "dadd.", XRC(59,2,1), X_MASK, POWER6, { FRT, FRA, FRB } }, 4365{ "dadd.", XRC(59,2,1), X_MASK, POWER6, { FRT, FRA, FRB } },
4626 4366
4627{ "dqua", ZRC(59,3,0), Z_MASK, POWER6, { FRT, FRA, FRB, RMC } }, 4367{ "dqua", ZRC(59,3,0), Z2_MASK, POWER6, { FRT, FRA, FRB, RMC } },
4628{ "dqua.", ZRC(59,3,1), Z_MASK, POWER6, { FRT, FRA, FRB, RMC } }, 4368{ "dqua.", ZRC(59,3,1), Z2_MASK, POWER6, { FRT, FRA, FRB, RMC } },
4629 4369
4630{ "fdivs", A(59,18,0), AFRC_MASK, PPC, { FRT, FRA, FRB } }, 4370{ "fdivs", A(59,18,0), AFRC_MASK, PPC, { FRT, FRA, FRB } },
4631{ "fdivs.", A(59,18,1), AFRC_MASK, PPC, { FRT, FRA, FRB } }, 4371{ "fdivs.", A(59,18,1), AFRC_MASK, PPC, { FRT, FRA, FRB } },
@@ -4663,20 +4403,20 @@ const struct powerpc_opcode powerpc_opcodes[] = {
4663{ "dmul", XRC(59,34,0), X_MASK, POWER6, { FRT, FRA, FRB } }, 4403{ "dmul", XRC(59,34,0), X_MASK, POWER6, { FRT, FRA, FRB } },
4664{ "dmul.", XRC(59,34,1), X_MASK, POWER6, { FRT, FRA, FRB } }, 4404{ "dmul.", XRC(59,34,1), X_MASK, POWER6, { FRT, FRA, FRB } },
4665 4405
4666{ "drrnd", ZRC(59,35,0), Z_MASK, POWER6, { FRT, FRA, FRB, RMC } }, 4406{ "drrnd", ZRC(59,35,0), Z2_MASK, POWER6, { FRT, FRA, FRB, RMC } },
4667{ "drrnd.", ZRC(59,35,1), Z_MASK, POWER6, { FRT, FRA, FRB, RMC } }, 4407{ "drrnd.", ZRC(59,35,1), Z2_MASK, POWER6, { FRT, FRA, FRB, RMC } },
4668 4408
4669{ "dscli", ZRC(59,66,0), Z_MASK, POWER6, { FRT, FRA, SH16 } }, 4409{ "dscli", ZRC(59,66,0), Z_MASK, POWER6, { FRT, FRA, SH16 } },
4670{ "dscli.", ZRC(59,66,1), Z_MASK, POWER6, { FRT, FRA, SH16 } }, 4410{ "dscli.", ZRC(59,66,1), Z_MASK, POWER6, { FRT, FRA, SH16 } },
4671 4411
4672{ "dquai", ZRC(59,67,0), Z_MASK, POWER6, { TE, FRT, FRB, RMC } }, 4412{ "dquai", ZRC(59,67,0), Z2_MASK, POWER6, { TE, FRT, FRB, RMC } },
4673{ "dquai.", ZRC(59,67,1), Z_MASK, POWER6, { TE, FRT, FRB, RMC } }, 4413{ "dquai.", ZRC(59,67,1), Z2_MASK, POWER6, { TE, FRT, FRB, RMC } },
4674 4414
4675{ "dscri", ZRC(59,98,0), Z_MASK, POWER6, { FRT, FRA, SH16 } }, 4415{ "dscri", ZRC(59,98,0), Z_MASK, POWER6, { FRT, FRA, SH16 } },
4676{ "dscri.", ZRC(59,98,1), Z_MASK, POWER6, { FRT, FRA, SH16 } }, 4416{ "dscri.", ZRC(59,98,1), Z_MASK, POWER6, { FRT, FRA, SH16 } },
4677 4417
4678{ "drintx", ZRC(59,99,0), Z_MASK, POWER6, { R, FRT, FRB, RMC } }, 4418{ "drintx", ZRC(59,99,0), Z2_MASK, POWER6, { R, FRT, FRB, RMC } },
4679{ "drintx.", ZRC(59,99,1), Z_MASK, POWER6, { R, FRT, FRB, RMC } }, 4419{ "drintx.", ZRC(59,99,1), Z2_MASK, POWER6, { R, FRT, FRB, RMC } },
4680 4420
4681{ "dcmpo", X(59,130), X_MASK, POWER6, { BF, FRA, FRB } }, 4421{ "dcmpo", X(59,130), X_MASK, POWER6, { BF, FRA, FRB } },
4682 4422
@@ -4684,8 +4424,8 @@ const struct powerpc_opcode powerpc_opcodes[] = {
4684{ "dtstdc", Z(59,194), Z_MASK, POWER6, { BF, FRA, DCM } }, 4424{ "dtstdc", Z(59,194), Z_MASK, POWER6, { BF, FRA, DCM } },
4685{ "dtstdg", Z(59,226), Z_MASK, POWER6, { BF, FRA, DGM } }, 4425{ "dtstdg", Z(59,226), Z_MASK, POWER6, { BF, FRA, DGM } },
4686 4426
4687{ "drintn", ZRC(59,227,0), Z_MASK, POWER6, { R, FRT, FRB, RMC } }, 4427{ "drintn", ZRC(59,227,0), Z2_MASK, POWER6, { R, FRT, FRB, RMC } },
4688{ "drintn.", ZRC(59,227,1), Z_MASK, POWER6, { R, FRT, FRB, RMC } }, 4428{ "drintn.", ZRC(59,227,1), Z2_MASK, POWER6, { R, FRT, FRB, RMC } },
4689 4429
4690{ "dctdp", XRC(59,258,0), X_MASK, POWER6, { FRT, FRB } }, 4430{ "dctdp", XRC(59,258,0), X_MASK, POWER6, { FRT, FRB } },
4691{ "dctdp.", XRC(59,258,1), X_MASK, POWER6, { FRT, FRB } }, 4431{ "dctdp.", XRC(59,258,1), X_MASK, POWER6, { FRT, FRB } },
@@ -4751,8 +4491,8 @@ const struct powerpc_opcode powerpc_opcodes[] = {
4751{ "daddq", XRC(63,2,0), X_MASK, POWER6, { FRT, FRA, FRB } }, 4491{ "daddq", XRC(63,2,0), X_MASK, POWER6, { FRT, FRA, FRB } },
4752{ "daddq.", XRC(63,2,1), X_MASK, POWER6, { FRT, FRA, FRB } }, 4492{ "daddq.", XRC(63,2,1), X_MASK, POWER6, { FRT, FRA, FRB } },
4753 4493
4754{ "dquaq", ZRC(63,3,0), Z_MASK, POWER6, { FRT, FRA, FRB, RMC } }, 4494{ "dquaq", ZRC(63,3,0), Z2_MASK, POWER6, { FRT, FRA, FRB, RMC } },
4755{ "dquaq.", ZRC(63,3,1), Z_MASK, POWER6, { FRT, FRA, FRB, RMC } }, 4495{ "dquaq.", ZRC(63,3,1), Z2_MASK, POWER6, { FRT, FRA, FRB, RMC } },
4756 4496
4757{ "fcpsgn", XRC(63,8,0), X_MASK, POWER6, { FRT, FRA, FRB } }, 4497{ "fcpsgn", XRC(63,8,0), X_MASK, POWER6, { FRT, FRA, FRB } },
4758{ "fcpsgn.", XRC(63,8,1), X_MASK, POWER6, { FRT, FRA, FRB } }, 4498{ "fcpsgn.", XRC(63,8,1), X_MASK, POWER6, { FRT, FRA, FRB } },
@@ -4827,8 +4567,8 @@ const struct powerpc_opcode powerpc_opcodes[] = {
4827{ "dmulq", XRC(63,34,0), X_MASK, POWER6, { FRT, FRA, FRB } }, 4567{ "dmulq", XRC(63,34,0), X_MASK, POWER6, { FRT, FRA, FRB } },
4828{ "dmulq.", XRC(63,34,1), X_MASK, POWER6, { FRT, FRA, FRB } }, 4568{ "dmulq.", XRC(63,34,1), X_MASK, POWER6, { FRT, FRA, FRB } },
4829 4569
4830{ "drrndq", ZRC(63,35,0), Z_MASK, POWER6, { FRT, FRA, FRB, RMC } }, 4570{ "drrndq", ZRC(63,35,0), Z2_MASK, POWER6, { FRT, FRA, FRB, RMC } },
4831{ "drrndq.", ZRC(63,35,1), Z_MASK, POWER6, { FRT, FRA, FRB, RMC } }, 4571{ "drrndq.", ZRC(63,35,1), Z2_MASK, POWER6, { FRT, FRA, FRB, RMC } },
4832 4572
4833{ "mtfsb1", XRC(63,38,0), XRARB_MASK, COM, { BT } }, 4573{ "mtfsb1", XRC(63,38,0), XRARB_MASK, COM, { BT } },
4834{ "mtfsb1.", XRC(63,38,1), XRARB_MASK, COM, { BT } }, 4574{ "mtfsb1.", XRC(63,38,1), XRARB_MASK, COM, { BT } },
@@ -4841,8 +4581,8 @@ const struct powerpc_opcode powerpc_opcodes[] = {
4841{ "dscliq", ZRC(63,66,0), Z_MASK, POWER6, { FRT, FRA, SH16 } }, 4581{ "dscliq", ZRC(63,66,0), Z_MASK, POWER6, { FRT, FRA, SH16 } },
4842{ "dscliq.", ZRC(63,66,1), Z_MASK, POWER6, { FRT, FRA, SH16 } }, 4582{ "dscliq.", ZRC(63,66,1), Z_MASK, POWER6, { FRT, FRA, SH16 } },
4843 4583
4844{ "dquaiq", ZRC(63,67,0), Z_MASK, POWER6, { TE, FRT, FRB, RMC } }, 4584{ "dquaiq", ZRC(63,67,0), Z2_MASK, POWER6, { TE, FRT, FRB, RMC } },
4845{ "dquaiq.", ZRC(63,67,1), Z_MASK, POWER6, { FRT, FRA, FRB, RMC } }, 4585{ "dquaiq.", ZRC(63,67,1), Z2_MASK, POWER6, { FRT, FRA, FRB, RMC } },
4846 4586
4847{ "mtfsb0", XRC(63,70,0), XRARB_MASK, COM, { BT } }, 4587{ "mtfsb0", XRC(63,70,0), XRARB_MASK, COM, { BT } },
4848{ "mtfsb0.", XRC(63,70,1), XRARB_MASK, COM, { BT } }, 4588{ "mtfsb0.", XRC(63,70,1), XRARB_MASK, COM, { BT } },
@@ -4853,13 +4593,13 @@ const struct powerpc_opcode powerpc_opcodes[] = {
4853{ "dscriq", ZRC(63,98,0), Z_MASK, POWER6, { FRT, FRA, SH16 } }, 4593{ "dscriq", ZRC(63,98,0), Z_MASK, POWER6, { FRT, FRA, SH16 } },
4854{ "dscriq.", ZRC(63,98,1), Z_MASK, POWER6, { FRT, FRA, SH16 } }, 4594{ "dscriq.", ZRC(63,98,1), Z_MASK, POWER6, { FRT, FRA, SH16 } },
4855 4595
4856{ "drintxq", ZRC(63,99,0), Z_MASK, POWER6, { R, FRT, FRB, RMC } }, 4596{ "drintxq", ZRC(63,99,0), Z2_MASK, POWER6, { R, FRT, FRB, RMC } },
4857{ "drintxq.",ZRC(63,99,1), Z_MASK, POWER6, { R, FRT, FRB, RMC } }, 4597{ "drintxq.",ZRC(63,99,1), Z2_MASK, POWER6, { R, FRT, FRB, RMC } },
4858 4598
4859{ "dcmpoq", X(63,130), X_MASK, POWER6, { BF, FRA, FRB } }, 4599{ "dcmpoq", X(63,130), X_MASK, POWER6, { BF, FRA, FRB } },
4860 4600
4861{ "mtfsfi", XRC(63,134,0), XRA_MASK|(3<<21)|(1<<11), COM, { BF, U } }, 4601{ "mtfsfi", XRC(63,134,0), XWRA_MASK|(3<<21)|(1<<11), COM, { BFF, U, W } },
4862{ "mtfsfi.", XRC(63,134,1), XRA_MASK|(3<<21)|(1<<11), COM, { BF, U } }, 4602{ "mtfsfi.", XRC(63,134,1), XWRA_MASK|(3<<21)|(1<<11), COM, { BFF, U, W } },
4863 4603
4864{ "fnabs", XRC(63,136,0), XRA_MASK, COM, { FRT, FRB } }, 4604{ "fnabs", XRC(63,136,0), XRA_MASK, COM, { FRT, FRB } },
4865{ "fnabs.", XRC(63,136,1), XRA_MASK, COM, { FRT, FRB } }, 4605{ "fnabs.", XRC(63,136,1), XRA_MASK, COM, { FRT, FRB } },
@@ -4868,8 +4608,8 @@ const struct powerpc_opcode powerpc_opcodes[] = {
4868{ "dtstdcq", Z(63,194), Z_MASK, POWER6, { BF, FRA, DCM } }, 4608{ "dtstdcq", Z(63,194), Z_MASK, POWER6, { BF, FRA, DCM } },
4869{ "dtstdgq", Z(63,226), Z_MASK, POWER6, { BF, FRA, DGM } }, 4609{ "dtstdgq", Z(63,226), Z_MASK, POWER6, { BF, FRA, DGM } },
4870 4610
4871{ "drintnq", ZRC(63,227,0), Z_MASK, POWER6, { R, FRT, FRB, RMC } }, 4611{ "drintnq", ZRC(63,227,0), Z2_MASK, POWER6, { R, FRT, FRB, RMC } },
4872{ "drintnq.",ZRC(63,227,1), Z_MASK, POWER6, { R, FRT, FRB, RMC } }, 4612{ "drintnq.",ZRC(63,227,1), Z2_MASK, POWER6, { R, FRT, FRB, RMC } },
4873 4613
4874{ "dctqpq", XRC(63,258,0), X_MASK, POWER6, { FRT, FRB } }, 4614{ "dctqpq", XRC(63,258,0), X_MASK, POWER6, { FRT, FRB } },
4875{ "dctqpq.", XRC(63,258,1), X_MASK, POWER6, { FRT, FRB } }, 4615{ "dctqpq.", XRC(63,258,1), X_MASK, POWER6, { FRT, FRB } },
@@ -4908,8 +4648,8 @@ const struct powerpc_opcode powerpc_opcodes[] = {
4908 4648
4909{ "dtstsfq", X(63,674), X_MASK, POWER6, { BF, FRA, FRB } }, 4649{ "dtstsfq", X(63,674), X_MASK, POWER6, { BF, FRA, FRB } },
4910 4650
4911{ "mtfsf", XFL(63,711,0), XFL_MASK, COM, { FLM, FRB } }, 4651{ "mtfsf", XFL(63,711,0), XFL_MASK, COM, { FLM, FRB, XFL_L, W } },
4912{ "mtfsf.", XFL(63,711,1), XFL_MASK, COM, { FLM, FRB } }, 4652{ "mtfsf.", XFL(63,711,1), XFL_MASK, COM, { FLM, FRB, XFL_L, W } },
4913 4653
4914{ "drdpq", XRC(63,770,0), X_MASK, POWER6, { FRT, FRB } }, 4654{ "drdpq", XRC(63,770,0), X_MASK, POWER6, { FRT, FRB } },
4915{ "drdpq.", XRC(63,770,1), X_MASK, POWER6, { FRT, FRB } }, 4655{ "drdpq.", XRC(63,770,1), X_MASK, POWER6, { FRT, FRB } },
@@ -4934,7 +4674,8 @@ const struct powerpc_opcode powerpc_opcodes[] = {
4934 4674
4935}; 4675};
4936 4676
4937const int powerpc_num_opcodes = ARRAY_SIZE(powerpc_opcodes); 4677const int powerpc_num_opcodes =
4678 sizeof (powerpc_opcodes) / sizeof (powerpc_opcodes[0]);
4938 4679
4939/* The macro table. This is only used by the assembler. */ 4680/* The macro table. This is only used by the assembler. */
4940 4681
@@ -4990,4 +4731,5 @@ const struct powerpc_macro powerpc_macros[] = {
4990{ "clrlslwi.",4, PPCCOM, "rlwinm. %0,%1,%3,(%2)-(%3),31-(%3)" }, 4731{ "clrlslwi.",4, PPCCOM, "rlwinm. %0,%1,%3,(%2)-(%3),31-(%3)" },
4991}; 4732};
4992 4733
4993const int powerpc_num_macros = ARRAY_SIZE(powerpc_macros); 4734const int powerpc_num_macros =
4735 sizeof (powerpc_macros) / sizeof (powerpc_macros[0]);
diff --git a/arch/powerpc/xmon/ppc.h b/arch/powerpc/xmon/ppc.h
index 110df96354b4..6771856fd5f8 100644
--- a/arch/powerpc/xmon/ppc.h
+++ b/arch/powerpc/xmon/ppc.h
@@ -1,6 +1,6 @@
1/* ppc.h -- Header file for PowerPC opcode table 1/* ppc.h -- Header file for PowerPC opcode table
2 Copyright 1994, 1995, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 2 Copyright 1994, 1995, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
3 Free Software Foundation, Inc. 3 2007 Free Software Foundation, Inc.
4 Written by Ian Lance Taylor, Cygnus Support 4 Written by Ian Lance Taylor, Cygnus Support
5 5
6This file is part of GDB, GAS, and the GNU binutils. 6This file is part of GDB, GAS, and the GNU binutils.
@@ -153,20 +153,21 @@ extern const int powerpc_num_opcodes;
153 153
154struct powerpc_operand 154struct powerpc_operand
155{ 155{
156 /* The number of bits in the operand. */ 156 /* A bitmask of bits in the operand. */
157 int bits; 157 unsigned int bitm;
158 158
159 /* How far the operand is left shifted in the instruction. */ 159 /* How far the operand is left shifted in the instruction.
160 -1 to indicate that BITM and SHIFT cannot be used to determine
161 where the operand goes in the insn. */
160 int shift; 162 int shift;
161 163
162 /* Insertion function. This is used by the assembler. To insert an 164 /* Insertion function. This is used by the assembler. To insert an
163 operand value into an instruction, check this field. 165 operand value into an instruction, check this field.
164 166
165 If it is NULL, execute 167 If it is NULL, execute
166 i |= (op & ((1 << o->bits) - 1)) << o->shift; 168 i |= (op & o->bitm) << o->shift;
167 (i is the instruction which we are filling in, o is a pointer to 169 (i is the instruction which we are filling in, o is a pointer to
168 this structure, and op is the opcode value; this assumes twos 170 this structure, and op is the operand value).
169 complement arithmetic).
170 171
171 If this field is not NULL, then simply call it with the 172 If this field is not NULL, then simply call it with the
172 instruction and the operand value. It will return the new value 173 instruction and the operand value. It will return the new value
@@ -182,12 +183,11 @@ struct powerpc_operand
182 extract this operand type from an instruction, check this field. 183 extract this operand type from an instruction, check this field.
183 184
184 If it is NULL, compute 185 If it is NULL, compute
185 op = ((i) >> o->shift) & ((1 << o->bits) - 1); 186 op = (i >> o->shift) & o->bitm;
186 if ((o->flags & PPC_OPERAND_SIGNED) != 0 187 if ((o->flags & PPC_OPERAND_SIGNED) != 0)
187 && (op & (1 << (o->bits - 1))) != 0) 188 sign_extend (op);
188 op -= 1 << o->bits;
189 (i is the instruction, o is a pointer to this structure, and op 189 (i is the instruction, o is a pointer to this structure, and op
190 is the result; this assumes twos complement arithmetic). 190 is the result).
191 191
192 If this field is not NULL, then simply call it with the 192 If this field is not NULL, then simply call it with the
193 instruction value. It will return the value of the operand. If 193 instruction value. It will return the value of the operand. If
@@ -205,17 +205,18 @@ struct powerpc_operand
205 the operands field of the powerpc_opcodes table. */ 205 the operands field of the powerpc_opcodes table. */
206 206
207extern const struct powerpc_operand powerpc_operands[]; 207extern const struct powerpc_operand powerpc_operands[];
208extern const unsigned int num_powerpc_operands;
208 209
209/* Values defined for the flags field of a struct powerpc_operand. */ 210/* Values defined for the flags field of a struct powerpc_operand. */
210 211
211/* This operand takes signed values. */ 212/* This operand takes signed values. */
212#define PPC_OPERAND_SIGNED (01) 213#define PPC_OPERAND_SIGNED (0x1)
213 214
214/* This operand takes signed values, but also accepts a full positive 215/* This operand takes signed values, but also accepts a full positive
215 range of values when running in 32 bit mode. That is, if bits is 216 range of values when running in 32 bit mode. That is, if bits is
216 16, it takes any value from -0x8000 to 0xffff. In 64 bit mode, 217 16, it takes any value from -0x8000 to 0xffff. In 64 bit mode,
217 this flag is ignored. */ 218 this flag is ignored. */
218#define PPC_OPERAND_SIGNOPT (02) 219#define PPC_OPERAND_SIGNOPT (0x2)
219 220
220/* This operand does not actually exist in the assembler input. This 221/* This operand does not actually exist in the assembler input. This
221 is used to support extended mnemonics such as mr, for which two 222 is used to support extended mnemonics such as mr, for which two
@@ -223,14 +224,14 @@ extern const struct powerpc_operand powerpc_operands[];
223 insert function with any op value. The disassembler should call 224 insert function with any op value. The disassembler should call
224 the extract function, ignore the return value, and check the value 225 the extract function, ignore the return value, and check the value
225 placed in the valid argument. */ 226 placed in the valid argument. */
226#define PPC_OPERAND_FAKE (04) 227#define PPC_OPERAND_FAKE (0x4)
227 228
228/* The next operand should be wrapped in parentheses rather than 229/* The next operand should be wrapped in parentheses rather than
229 separated from this one by a comma. This is used for the load and 230 separated from this one by a comma. This is used for the load and
230 store instructions which want their operands to look like 231 store instructions which want their operands to look like
231 reg,displacement(reg) 232 reg,displacement(reg)
232 */ 233 */
233#define PPC_OPERAND_PARENS (010) 234#define PPC_OPERAND_PARENS (0x8)
234 235
235/* This operand may use the symbolic names for the CR fields, which 236/* This operand may use the symbolic names for the CR fields, which
236 are 237 are
@@ -239,26 +240,26 @@ extern const struct powerpc_operand powerpc_operands[];
239 cr4 4 cr5 5 cr6 6 cr7 7 240 cr4 4 cr5 5 cr6 6 cr7 7
240 These may be combined arithmetically, as in cr2*4+gt. These are 241 These may be combined arithmetically, as in cr2*4+gt. These are
241 only supported on the PowerPC, not the POWER. */ 242 only supported on the PowerPC, not the POWER. */
242#define PPC_OPERAND_CR (020) 243#define PPC_OPERAND_CR (0x10)
243 244
244/* This operand names a register. The disassembler uses this to print 245/* This operand names a register. The disassembler uses this to print
245 register names with a leading 'r'. */ 246 register names with a leading 'r'. */
246#define PPC_OPERAND_GPR (040) 247#define PPC_OPERAND_GPR (0x20)
247 248
248/* Like PPC_OPERAND_GPR, but don't print a leading 'r' for r0. */ 249/* Like PPC_OPERAND_GPR, but don't print a leading 'r' for r0. */
249#define PPC_OPERAND_GPR_0 (0100) 250#define PPC_OPERAND_GPR_0 (0x40)
250 251
251/* This operand names a floating point register. The disassembler 252/* This operand names a floating point register. The disassembler
252 prints these with a leading 'f'. */ 253 prints these with a leading 'f'. */
253#define PPC_OPERAND_FPR (0200) 254#define PPC_OPERAND_FPR (0x80)
254 255
255/* This operand is a relative branch displacement. The disassembler 256/* This operand is a relative branch displacement. The disassembler
256 prints these symbolically if possible. */ 257 prints these symbolically if possible. */
257#define PPC_OPERAND_RELATIVE (0400) 258#define PPC_OPERAND_RELATIVE (0x100)
258 259
259/* This operand is an absolute branch address. The disassembler 260/* This operand is an absolute branch address. The disassembler
260 prints these symbolically if possible. */ 261 prints these symbolically if possible. */
261#define PPC_OPERAND_ABSOLUTE (01000) 262#define PPC_OPERAND_ABSOLUTE (0x200)
262 263
263/* This operand is optional, and is zero if omitted. This is used for 264/* This operand is optional, and is zero if omitted. This is used for
264 example, in the optional BF field in the comparison instructions. The 265 example, in the optional BF field in the comparison instructions. The
@@ -266,7 +267,7 @@ extern const struct powerpc_operand powerpc_operands[];
266 and the number of operands remaining for the opcode, and decide 267 and the number of operands remaining for the opcode, and decide
267 whether this operand is present or not. The disassembler should 268 whether this operand is present or not. The disassembler should
268 print this operand out only if it is not zero. */ 269 print this operand out only if it is not zero. */
269#define PPC_OPERAND_OPTIONAL (02000) 270#define PPC_OPERAND_OPTIONAL (0x400)
270 271
271/* This flag is only used with PPC_OPERAND_OPTIONAL. If this operand 272/* This flag is only used with PPC_OPERAND_OPTIONAL. If this operand
272 is omitted, then for the next operand use this operand value plus 273 is omitted, then for the next operand use this operand value plus
@@ -274,24 +275,27 @@ extern const struct powerpc_operand powerpc_operands[];
274 hack is needed because the Power rotate instructions can take 275 hack is needed because the Power rotate instructions can take
275 either 4 or 5 operands. The disassembler should print this operand 276 either 4 or 5 operands. The disassembler should print this operand
276 out regardless of the PPC_OPERAND_OPTIONAL field. */ 277 out regardless of the PPC_OPERAND_OPTIONAL field. */
277#define PPC_OPERAND_NEXT (04000) 278#define PPC_OPERAND_NEXT (0x800)
278 279
279/* This operand should be regarded as a negative number for the 280/* This operand should be regarded as a negative number for the
280 purposes of overflow checking (i.e., the normal most negative 281 purposes of overflow checking (i.e., the normal most negative
281 number is disallowed and one more than the normal most positive 282 number is disallowed and one more than the normal most positive
282 number is allowed). This flag will only be set for a signed 283 number is allowed). This flag will only be set for a signed
283 operand. */ 284 operand. */
284#define PPC_OPERAND_NEGATIVE (010000) 285#define PPC_OPERAND_NEGATIVE (0x1000)
285 286
286/* This operand names a vector unit register. The disassembler 287/* This operand names a vector unit register. The disassembler
287 prints these with a leading 'v'. */ 288 prints these with a leading 'v'. */
288#define PPC_OPERAND_VR (020000) 289#define PPC_OPERAND_VR (0x2000)
289 290
290/* This operand is for the DS field in a DS form instruction. */ 291/* This operand is for the DS field in a DS form instruction. */
291#define PPC_OPERAND_DS (040000) 292#define PPC_OPERAND_DS (0x4000)
292 293
293/* This operand is for the DQ field in a DQ form instruction. */ 294/* This operand is for the DQ field in a DQ form instruction. */
294#define PPC_OPERAND_DQ (0100000) 295#define PPC_OPERAND_DQ (0x8000)
296
297/* Valid range of operand is 0..n rather than 0..n-1. */
298#define PPC_OPERAND_PLUS1 (0x10000)
295 299
296/* The POWER and PowerPC assemblers use a few macros. We keep them 300/* The POWER and PowerPC assemblers use a few macros. We keep them
297 with the operands table for simplicity. The macro table is an 301 with the operands table for simplicity. The macro table is an