Update xmon disassembly
cover Update xmon disassembly
This series updates xmon to allow disassembly of
upto POWER9 instructions.
With a lot of help from Peter Bergner and help from Paul Mckenney I was able to get help in relicensing the new binutils ppc-opc.c/ppc-dis.c and ppc.h to GPLv2. The details of the commits are in patch 2 in the series. The authors of the various commits have generously allowed their commits to be relicensed under GPLv2.
The first patch updates the files in xmon to latest GPLv2 version. The second patch are commits relicensed as GPLv2 The third patch makes modifications necessary to integration with xmon
This series is not git-bisect friendly, the first two patches will not compile, but are split for ease of understanding and better understanding of how we got to patch 3. In addition the CodingStyle followed in these files is not the Linux CodingStyle, so scripts like checkpatch do not warm up to the series nicely.
NOTE: This is an internal posting at the moment for review and criticism.
Balbir Singh (3):
powerpc/xmon Update ppc-dis/opc.c and ppc.h powerpc/xmon: Apply binutils changes to upgrade disassembly powerpc/xmon: Enable disassembly files (compilation changes)
arch/powerpc/xmon/ppc-dis.c | 260 +- arch/powerpc/xmon/ppc-opc.c | 8999 +++++++++++++++++++++++++++---------------- arch/powerpc/xmon/ppc.h | 268 +- 3 files changed, 6030 insertions(+), 3497 deletions(-)
Signature · 1 line
2.9.3
PATCH 1/3 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 commit
65b650b4c7463f4508bed523c24ab0031a5ae5cd
* ppc-dis.c (print_insn_powerpc): Don't skip all operands after setting skip_optional.
This version will not compile, but make it easier to apply newer reclicensed commits on top of
NOTE: This commit is not bisect friendly
--- arch/powerpc/xmon/ppc-dis.c | 272 ++++++++++++++--- arch/powerpc/xmon/ppc-opc.c | 728 ++++++++++++++------------------------------ arch/powerpc/xmon/ppc.h | 62 ++-- 3 files changed, 492 insertions(+), 570 deletions(-)
arch/powerpc/xmon/ppc-dis.c +224 -48
@@ -1,5 +1,5 @@/* ppc-dis.c -- Disassemble PowerPC instructions -Copyright 1994, 1995, 2000, 2001, 2002, 2003, 2004, 2005, 2006 +Copyright 1994, 1995, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc. Written by Ian Lance Taylor, Cygnus Support
@@ -19,34 +19,193 @@ You should have received a copy of the GNU General Public Licensealong with this file; see the file COPYING. If not, write to the Free Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ -#include <asm/cputable.h> -#include <asm/cpu_has_feature.h> -#include "nonstdio.h" -#include "ansidecl.h" -#include "ppc.h" +#include <stdio.h> +#include "sysdep.h" #include "dis-asm.h" +#include "opcode/ppc.h" -/* Print a PowerPC or POWER instruction. */ +/* This file provides several disassembler functions, all of which use +the disassembler interface defined in dis-asm.h. Several functions +are provided because this file handles disassembly for the PowerPC +in both big and little endian mode and also for the POWER (RS/6000) +chip. */ + +static int print_insn_powerpc (bfd_vma ,struct disassemble_info *,int ,int ); + +/* Determine which set of machines to disassemble for. PPC403/601 or +BookE. For convenience, also disassemble instructions supported +by the AltiVec vector unit. */ + +static int +powerpc_dialect (struct disassemble_info *info) +{ +int dialect =PPC_OPCODE_PPC ; + +if (BFD_DEFAULT_TARGET_SIZE ==64 ) + dialect |=PPC_OPCODE_64 ; + +if (info->disassembler_options + &&strstr (info->disassembler_options,"booke" ) !=NULL ) + dialect |=PPC_OPCODE_BOOKE |PPC_OPCODE_BOOKE64 ; +else if ((info->mach == bfd_mach_ppc_e500) + || (info->disassembler_options + &&strstr (info->disassembler_options,"e500" ) !=NULL )) + dialect |= (PPC_OPCODE_BOOKE + |PPC_OPCODE_SPE |PPC_OPCODE_ISEL + |PPC_OPCODE_EFS |PPC_OPCODE_BRLOCK + |PPC_OPCODE_PMR |PPC_OPCODE_CACHELCK + |PPC_OPCODE_RFMCI ); +else if (info->disassembler_options + &&strstr (info->disassembler_options,"efs" ) !=NULL ) + dialect |=PPC_OPCODE_EFS ; +else if (info->disassembler_options + &&strstr (info->disassembler_options,"e300" ) !=NULL ) + dialect |=PPC_OPCODE_E300 |PPC_OPCODE_CLASSIC |PPC_OPCODE_COMMON ; +else if (info->disassembler_options + &&strstr (info->disassembler_options,"440" ) !=NULL ) + dialect |=PPC_OPCODE_BOOKE |PPC_OPCODE_32 + |PPC_OPCODE_440 |PPC_OPCODE_ISEL |PPC_OPCODE_RFMCI ; +else + dialect |= (PPC_OPCODE_403 |PPC_OPCODE_601 |PPC_OPCODE_CLASSIC + |PPC_OPCODE_COMMON |PPC_OPCODE_ALTIVEC ); + +if (info->disassembler_options + &&strstr (info->disassembler_options,"power4" ) !=NULL ) + dialect |=PPC_OPCODE_POWER4 ; + +if (info->disassembler_options + &&strstr (info->disassembler_options,"power5" ) !=NULL ) + dialect |=PPC_OPCODE_POWER4 |PPC_OPCODE_POWER5 ; + +if (info->disassembler_options + &&strstr (info->disassembler_options,"cell" ) !=NULL ) + dialect |=PPC_OPCODE_POWER4 |PPC_OPCODE_CELL |PPC_OPCODE_ALTIVEC ; + +if (info->disassembler_options + &&strstr (info->disassembler_options,"power6" ) !=NULL ) + dialect |=PPC_OPCODE_POWER4 |PPC_OPCODE_POWER5 |PPC_OPCODE_POWER6 |PPC_OPCODE_ALTIVEC ; + +if (info->disassembler_options + &&strstr (info->disassembler_options,"any" ) !=NULL ) + dialect |=PPC_OPCODE_ANY ; + +if (info->disassembler_options) + { +if (strstr (info->disassembler_options,"32" ) !=NULL ) + dialect &= ~PPC_OPCODE_64 ; +else if (strstr (info->disassembler_options,"64" ) !=NULL ) + dialect |=PPC_OPCODE_64 ; + } + + info->private_data = (char *)0 + dialect; +return dialect; +} + +/* Print a big endian PowerPC instruction. */ + +int +print_insn_big_powerpc (bfd_vma memaddr,struct disassemble_info *info) +{ +int dialect = (char *) info->private_data - (char *)0 ; +return print_insn_powerpc (memaddr, info,1 , dialect); +} + +/* Print a little endian PowerPC instruction. */ int -print_insn_powerpc (unsigned long insn,unsigned long memaddr) +print_insn_little_powerpc (bfd_vma memaddr,struct disassemble_info *info) +{ +int dialect = (char *) info->private_data - (char *)0 ; +return print_insn_powerpc (memaddr, info,0 , dialect); +} + +/* Print a POWER (RS/6000) instruction. */ + +int +print_insn_rs6000 (bfd_vma memaddr,struct disassemble_info *info) +{ +return print_insn_powerpc (memaddr, info,1 ,PPC_OPCODE_POWER ); +} + +/* Extract the operand value from the PowerPC or POWER instruction. */ + +static long +operand_value_powerpc (const struct powerpc_operand *operand, +unsigned long insn,int dialect) +{ +long value; +int invalid; +/* Extract the value from the instruction. */ +if (operand->extract) + value = (*operand->extract) (insn, dialect, &invalid); +else + { + value = (insn >> operand->shift) & operand->bitm; +if ((operand->flags &PPC_OPERAND_SIGNED ) !=0 ) + { +/* BITM is always some number of zeros followed by some +number of ones, followed by some numer of zeros. */ +unsigned long top = operand->bitm; +/* top & -top gives the rightmost 1 bit, so this +fills in any trailing zeros. */ + top |= (top & -top) -1 ; + top &= ~(top >>1 ); + value = (value ^ top) - top; + } + } + +return value; +} + +/* Determine whether the optional operand(s) should be printed. */ + +static int +skip_optional_operands (const unsigned char *opindex, +unsigned long insn,int dialect) +{ +const struct powerpc_operand *operand; + +for (; *opindex !=0 ; opindex++) + { + operand = &powerpc_operands[*opindex]; +if ((operand->flags &PPC_OPERAND_NEXT ) !=0 + || ((operand->flags &PPC_OPERAND_OPTIONAL ) !=0 + &&operand_value_powerpc (operand, insn, dialect) !=0 )) +return 0 ; + } + +return 1 ; +} + +/* Print a PowerPC or POWER instruction. */ + +static int +print_insn_powerpc (bfd_vma memaddr, +struct disassemble_info *info, +int bigendian, +int dialect) { +bfd_byte buffer[4 ]; +int status; +unsigned long insn;const struct powerpc_opcode *opcode;const struct powerpc_opcode *opcode_end;unsigned long op; -int dialect; - - dialect =PPC_OPCODE_PPC |PPC_OPCODE_CLASSIC |PPC_OPCODE_COMMON - |PPC_OPCODE_64 |PPC_OPCODE_POWER4 |PPC_OPCODE_ALTIVEC ; -if (cpu_has_feature (CPU_FTRS_POWER5 )) - dialect |=PPC_OPCODE_POWER5 ; +if (dialect ==0 ) + dialect =powerpc_dialect (info); -if (cpu_has_feature (CPU_FTRS_CELL )) - dialect |=PPC_OPCODE_CELL |PPC_OPCODE_ALTIVEC ; + status = (*info->read_memory_func) (memaddr, buffer,4 , info); +if (status !=0 ) + { + (*info->memory_error_func) (status, memaddr, info); +return -1 ; + } -if (cpu_has_feature (CPU_FTRS_POWER6 )) - dialect |=PPC_OPCODE_POWER5 |PPC_OPCODE_POWER6 |PPC_OPCODE_ALTIVEC ; +if (bigendian) + insn =bfd_getb32 (buffer); +else + insn =bfd_getl32 (buffer);/* Get the major opcode of the instruction. */ op =PPC_OP (insn);
@@ -63,6 +222,7 @@ print_insn_powerpc (unsigned long insn, unsigned long memaddr)int invalid;int need_comma;int need_paren; +int skip_optional; table_op =PPC_OP (opcode->opcode);if (op < table_op)
@@ -88,13 +248,15 @@ print_insn_powerpc (unsigned long insn, unsigned long memaddr)continue ;/* The instruction is valid. */ -printf ("%s" , opcode->name);if (opcode->operands[0 ] !=0 ) -printf ("\t" ); + (*info->fprintf_func) (info->stream,"%-7s " , opcode->name); +else + (*info->fprintf_func) (info->stream,"%s" , opcode->name);/* Now extract and print the operands. */ need_comma =0 ; need_paren =0 ; + skip_optional =-1 ;for (opindex = opcode->operands; *opindex !=0 ; opindex++) {long value;
@@ -107,49 +269,44 @@ print_insn_powerpc (unsigned long insn, unsigned long memaddr)if ((operand->flags &PPC_OPERAND_FAKE ) !=0 )continue ; -/* Extract the value from the instruction. */ -if (operand->extract) - value = (*operand->extract) (insn, dialect, &invalid); -else +/* If all of the optional operands have the value zero, +then don't print any of them. */ +if ((operand->flags &PPC_OPERAND_OPTIONAL ) !=0 ) { - value = (insn >> operand->shift) & ((1 << operand->bits) -1 ); -if ((operand->flags &PPC_OPERAND_SIGNED ) !=0 - && (value & (1 << (operand->bits -1 ))) !=0 ) - value -=1 << operand->bits; +if (skip_optional <0 ) + skip_optional =skip_optional_operands (opindex, insn, + dialect); +if (skip_optional) +continue ; } -/* If the operand is optional, and the value is zero, don't -print anything. */ -if ((operand->flags &PPC_OPERAND_OPTIONAL ) !=0 - && (operand->flags &PPC_OPERAND_NEXT ) ==0 - && value ==0 ) -continue ; + value =operand_value_powerpc (operand, insn, dialect);if (need_comma) { -printf ("," ); + (*info->fprintf_func) (info->stream,"," ); need_comma =0 ; }/* Print the operand as directed by the flags. */ if ((operand->flags &PPC_OPERAND_GPR ) !=0 || ((operand->flags &PPC_OPERAND_GPR_0 ) !=0 && value !=0 )) -printf ("r%ld" , value); + (*info->fprintf_func) (info->stream,"r%ld" , value);else if ((operand->flags &PPC_OPERAND_FPR ) !=0 ) -printf ("f%ld" , value); + (*info->fprintf_func) (info->stream,"f%ld" , value);else if ((operand->flags &PPC_OPERAND_VR ) !=0 ) -printf ("v%ld" , value); + (*info->fprintf_func) (info->stream,"v%ld" , value);else if ((operand->flags &PPC_OPERAND_RELATIVE ) !=0 ) -print_address (memaddr + value); + (*info->print_address_func) (memaddr + value, info);else if ((operand->flags &PPC_OPERAND_ABSOLUTE ) !=0 ) -print_address (value &0xffffffff ); + (*info->print_address_func) ((bfd_vma ) value &0xffffffff , info);else if ((operand->flags &PPC_OPERAND_CR ) ==0 || (dialect &PPC_OPCODE_PPC ) ==0 ) -printf ("%ld" , value); + (*info->fprintf_func) (info->stream,"%ld" , value);else { -if (operand->bits ==3 ) -printf ("cr%ld" , value); +if (operand->bitm ==7 ) + (*info->fprintf_func) (info->stream,"cr%ld" , value);else {static const char *cbnames[4 ] = {"lt" ,"gt" ,"eq" ,"so" };
@@ -158,15 +315,15 @@ print_insn_powerpc (unsigned long insn, unsigned long memaddr) cr = value >>2 ;if (cr !=0 ) -printf ("4*cr%d+" , cr); + (*info->fprintf_func) (info->stream,"4*cr%d+" , cr); cc = value &3 ; -printf ("%s" , cbnames[cc]); + (*info->fprintf_func) (info->stream,"%s" , cbnames[cc]); } }if (need_paren) { -printf (")" ); + (*info->fprintf_func) (info->stream,")" ); need_paren =0 ; }
@@ -174,7 +331,7 @@ print_insn_powerpc (unsigned long insn, unsigned long memaddr) need_comma =1 ; else { -printf ("(" ); + (*info->fprintf_func) (info->stream,"(" ); need_paren =1 ; } }
@@ -190,7 +347,26 @@ print_insn_powerpc (unsigned long insn, unsigned long memaddr) }/* We could not find a match. */ -printf (".long 0x%lx" , insn); + (*info->fprintf_func) (info->stream,".long 0x%lx" , insn);return 4 ; } + +void +print_ppc_disassembler_options (FILE *stream) +{ +fprintf (stream,"\n\ +The following PPC specific disassembler options are supported for use with\n\ +the -M switch:\n" ); + +fprintf (stream," booke|booke32|booke64 Disassemble the BookE instructions\n" ); +fprintf (stream," e300 Disassemble the e300 instructions\n" ); +fprintf (stream," e500|e500x2 Disassemble the e500 instructions\n" ); +fprintf (stream," 440 Disassemble the 440 instructions\n" ); +fprintf (stream," efs Disassemble the EFS instructions\n" ); +fprintf (stream," power4 Disassemble the Power4 instructions\n" ); +fprintf (stream," power5 Disassemble the Power5 instructions\n" ); +fprintf (stream," power6 Disassemble the Power6 instructions\n" ); +fprintf (stream," 32 Do not disassemble 64-bit instructions\n" ); +fprintf (stream," 64 Allow disassembly of 64-bit instructions\n" ); +}
arch/powerpc/xmon/ppc-opc.c +235 -493
1,303 lines not on this page · raw message
arch/powerpc/xmon/ppc.h +33 -29
159 lines not on this page · raw message
Signature · 1 line
2.9.3
kbuild test robot
build botRe: [PATCH 1/3] powerpc/xmon Update ppc-dis/opc.c and ppc.h
reproduce: wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree…
Hi Balbir,
[auto build test ERROR on powerpc/next]
[also build test ERROR on v4.10-rc6 next-20170201]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Balbir-Singh/Update-xmon-disassembly/20170202-135830 base: https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git next config: powerpc-allmodconfig (attached as .config) compiler: powerpc64-linux-gnu-gcc (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=powerpc
Note: the linux-review/Balbir-Singh/Update-xmon-disassembly/20170202-135830 HEAD aab7a78909e32ae5743164fc79d9f5eda993f0e7 builds fine.
It only hurts bisectibility.
All errors (new ones prefixed by >>):
>> arch/powerpc/xmon/ppc-dis.c:22:19: fatal error: stdio.h: No such file or directory
#include <stdio.h>
^
compilation terminated.
--
>> arch/powerpc/xmon/ppc-opc.c:23:19: fatal error: stdio.h: No such file or directory
#include <stdio.h>
^compilation terminated.
vim +22 arch/powerpc/xmon/ppc-dis.c
16 the GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this file; see the file COPYING. If not, write to the Free
20 Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */
21
> 22 #include <stdio.h>
23 #include "sysdep.h"
24 #include "dis-asm.h"
25 #include "opcode/ppc.h"---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
Re: [1/3] powerpc/xmon Update ppc-dis/opc.c and ppc.h
In reply to Balbir SinghQuoted 11 lines · Balbir Singh
Upgrade
ppc-opc.c,ppc-dis.candppc.hto the
versions belonging to the following commit
65b650b4c7463f4508bed523c24ab0031a5ae5cd
*ppc-dis.c(print_insn_powerpc): Don't skip all operands after settingskip_optional.This version will not compile, but make it easier to apply newer reclicensed commits on top of
Signed-off-by Balbir Singh <[email protected]>
Series applied to powerpc next, thanks.
https://git.kernel.org/powerpc/c/cc7639ce18b950086c7b06e0035065
cheers
PATCH 2/3 powerpc/xmon: Apply binutils changes to upgrade disassembly
In reply to Balbir SinghThe following commit-ids from the binutils project were applied on the xmon branch and relicensed under GPLv2 for the following files
ppc-opc.cppc-dis.cppc.h
Working off of 65b650b4c7463f4508bed523c24ab0031a5ae5cd we have now moved up to a5721ba270ddf860e0e5a45bba456214e8eac2be
Some commit logs have been taken verbatim, some are summarized for ease of understanding.
Here is a summary of the commits
33e8d5ac613dc8fbde6806bb3142335038eb2f22
PPC7450 New. (powerpc_opcodes): Use it in dcba.
c3d65c1ced61cfb87d77e677ee576a3353ce5e34
New opcodes and mask
8dbcd839b1bbad39586246ca2d444822b5f91ad7
Instruction Sorting
91eb7075e37075db0e2187235065e44f281e806e
(powerpc_opcodes): Fix the first two operands of
dquaiq. to use the TE and FRT macros.
548b1dcfcbab2c7ef43c5a7cee6287d69708df54ppc-opc.c (powerpc_opcodes): Remove the dcffix and dcffix. opcodes which are not included in the "Preliminary Decimal Floating-Point Architecture" document.
930bb4cfae30f3816321b8843b87fab945c57515
Support optional L form mtmsr.
de866fccd87dec7412357edcead235dd019fba09
(powerpc_opcodes): Order and format.
19a6653ce8c6d8a76586a54f3c0396063de5f987
ppc e500mc support
fa452fa6833cbb3088361ac35f4c51716afde520
(ppc_cpu_t): New typedef.
c8187e1509b28d4d9c0bbc2de688144ef80537c0
(parse_cpu): Handle -m464.
081ba1b3c08bce14fac7c6c240734f7bd230f784
Define. (PPC_OPERAND_FSL, PPC_OPERAND_FCR, PPC_OPERAND_UDI)
9b4e57660d385d9135549aeb8360ebfa14fb3990
Rename altivec_or_spe to retain_flags.
Handle -mvsx and -mpower7.
899d85beadd08b604d95d700c80f8270964dd449 (powerpc_opcodes): Enable rfci, mfpmr, mtpmr for e300.
e1c93c699b7dceb3fc41fb039ff5fecea73677ba
(extract_sprg): Correct operand range check.
2f3bb96af7966880e7378a1633f6ffe1ea7a6587 (powerpc_init_dialect): Do not set PPC_OPCODE_BOOKE
1cb0a7674666a4beff8f5f76f4392051ea649a82 (ppc_setup_opcodes): Remove PPC_OPCODE_NOPOWER4 test
21169fcfadfac63f7c02e33e19301cf375930b5e (print_insn_powerpc): Skip insn if it is deprecated
80890a619b855d6e124be63b31aae7201df994e3
("dcbt", "dcbtst")
0e55be1624c24e2361c3ea06ea73ca4e67e030e0
("lfdepx", "stfdepx")
066be9f7bd8ea9121322608fcba256ac5e33093c
(parse_cpu): Extend -mpower7 to accept power7 and
isel instructions.
c72ab5f2c55dded72dcb9b3810fbf1bd7964d4f2 (powerpc_opcodes): Reorder the opcode table so that instructions from newer processors are listed before older ones.
69fe9ce501f5fde501443648fe4243dc9fe8d5b1
(ppc_parse_cpu): New function. (powerpc_init_dialect)
e401b04ca7cd4cc3450c375b63b30b0907f14de0
(powerpc_opcodes) <"dcbzl">: Merge the POWER4 and
E500MC entries.
70dc4e324b9aecad6c9732ebedd0eeb66eb2e176 (powerpc_init_dialect): Do not choose a default dialect due to -many/-Many.
858d7a6db20b82c4cc9a2ae1a614169e95801e56 (powerpc_opcodes) <"tlbilxlpid", "tlbilxpid", "tlbilxva", "tlbilx">: Use secondary opcode "18" as per the ISA 2.06 documentation.
bdc7fcfe59f1347e78f71ee13b557ff5df8ca5de
(powerpc_macros <extrdi>): Allow n+b of 64
e0d602ecffb0256181ea45c653d261973c819d2b
(md_show_usage): Document -mpcca2
b961e85b6ebebe1381c29c9f50ba67d835d7c561
(ppc_cpu_t): Typedef to uint64_t
8765b556928465dc61f7bc00061c2a411a015361 (powerpc_opcodes): Remove support for the the "lxsdux", "lxvd2ux", "lxvw4ux", "stxsdux", "stxvd2ux" and "stxvw4ux" opcodes
634b50f2a6239deaa1eb3a9811b6b11659fa2e1b
Rename "ppca2" to "a2"
9fe54b1ca1c054c9323d232bf077abadf4d02c88
(md_show_usage): Document -m476
0dc9305793c81af5abbfb34743ebb97767d5b59e
Add bfd_mach_ppc_e500mc64
ce3d2015b21ba6aa3d2bb0b0ca88101cec56a7be
Define. bfd/ * archures.c (bfd_mach_ppc_titan)
cdc51b0748c418670cd15476234146993d202449
Add -mpwr4, -mpwr5, -mpwr5x, -mpwr6 and -mpwr7
63d0fa4e9e574017c5b6df9bec23771a63f7b3cd
Add PPC_OPCODE_E500MC for "e500mc64"
cee62821d4720ae9bd589e9c2f202de18ede9228
New Define. ("dccci"): Enable for PPCA2
85d4ac0b3c0bcfcd4c77fd943c0219d1934628df
Correct wclr encoding.
51b5d4a8c5e50baae29270983b16cfdd49ed7646
(powerpc_opcodes): Enable divdeu, devweu, divde,
divwe, divdeuo, divweuo, divdeo, divweo for A2.
Add icswepx.
e01d869a3be23aa63825fa1a10e894c5aa3c31a9 (md_assemble): Emit APUinfo section for PPC_OPCODE_E500
09a8ad8d8f56980fa431ad5ad36dee90fa08ee76
(powerpc_opcodes): Revert deprecation of mfocrf, mtcrf and
mtocrf on EFS.
f2bae120dcefc6a640fada0dd3eebbf02aa31296
(PPC_OPCODE_COMMON): Expand comment.
81a0b7e2ae09cfd58f4d9505928ff426e10ade05 (PPCPWR2): Add PPC_OPCODE_COMMON. (powerpc_opcodes): Add "subc", "subco", "subco.", "fcir", "fcir.", "fcirz", "fcirz." to -mcom opcodes. Remove "mfsri", "dclst", "rac" from -mcom.
bdc70b4a03fd884e60bfef2cc2fa7b864f51d6fe (PPC_OPCODE_32, PPC_OPCODE_BOOKE64, PPC_OPCODE_CLASSIC)
7102e95e494350cc1df80b4163e6f0a20537315e (ppc_set_cpu): Cast PPC_OPCODE_xxx to ppc_cpu_t before inverting
f383de6633cba5ef363eabb486005f1cdb1270f7 (powerpc_opcodes) [lswx,lswi,stswx,stswi]: Deprecate on E500 and E500MC
6b069ee70de3c540cef090a8733f8fc233cdb342
Remove PPC_OPCODE_PPCPS
2f7f771012795f9e832ff0228fcc353f2e8e079e
(powerpc_opcodes): Enable icswx for POWER7
989993d80a97a66f24c22a34ae9f28d9cd7387ca
(insert_nbi, insert_rbx, FRAp, FRBp, FRSp, FRTp, NBI, RAX, RBX): New
a08fc94222d1b5be7ecbf52d4d41fa6da1d71f18
<drrndq, drrndq., dtstexq, dctqpq, dctqpq., dctfixq, dctfixq., dxexq, dxexq., dtstsfq, dcffixq, dcffixq., diexq, diexq.>
Use FRT, FRA, FRB and FRBp repsectively on DFP quad instructions.
8ebac3aae962b531a2b86b6afba9e9d19a30c74d (ISA_V2): Define and use for relevant BO field tests aea77599d0dbdb7c7ca87e52b86184cf67e71e49
Add PPC_OPCODE_ALTIVEC2, PPC_OPCODE_E6500, PPC_OPCODE_TMR
b240011aba98dd8a0c4736a51afcea38af814200
(disassemble_init_for_target): Handle ppc init.
d668828207c26bba844378d72a56c5a7b6373bac
(powerpc_opcd_indices): Bump array size
b9c361e0ad33f2c841067fd4bf0959a72ad5a265
Add support for PowerPC VLE.
e1dad58d73dcf0ab1cabb92b2e2a79106486b1b0 (has_tls_reloc, has_tls_get_addr_call, has_vle_insns,is_ppc_vle): Move to.. * elf32-ppc.h
df7b86aa4cb63ce86e60949b8160438bc0f9e389
Add check that sysdep.h has been included before
98c76446ea6bc1223c314500d3e11178e4911018
(extract_sprg): Use ALLOW8_SPRG to include VLE.
a4ebc835cbcbc0a6f55f1dbe68332cfd8359fdfd (powerpc_macros): Add entries for e_extlwi to e_clrlslwi
94caa966375d53b07f39beac80f1f9af4cac18da
(has_vle_insns, is_ppc_vle): Delete
c7a8dbf91f37df83dd9153f0a540a34d710d5f73
Change RA to RA0
d908c8af5a1d7d9122decf3cab08018e9f925d27
Add necessary casts for printing integer values
03edbe3bfb93fca9d6f197040a41b0ec11ace6eb
Add/remove PPCVLE for some 32-bit insns
9f6a6cc022e1be500d3e49da1ad8bb2463b6da1b <xnop, yield, mdoio, mdoom>: New extended mnemonics
588925d0654555b1a0024f18bb7c0e073b285686
<RSQ, RTQ>: Use PPC_OPERAND_GPR
8baf7b78b5d92823965cad6263b0e0ea65c9cd36
<"lswx">: Use RAX for the second and RBX for the third operand
e67ed0e885d6b05f552b96e4ef0c1f1ea96fcadc Changed opcode for vabsdub, vabsduh, vabsduw, mviwsplt
fb048c26f19fec860e5e9004351307ed22fe1a11
(UIMM4, UIMM3, UIMM2, VXVA_MASK, VXVB_MASK, VXVAVB_MASK, VXVDVA_MASK, VXUIMM4_MASK, VXUIMM3_MASK, VXUIMM2_MASK): New defines
382c72e904414bd6b15f6307d5aaf2708edb2eaf
(VXASHB_MASK): New define
c7a5aa9c64fc5b4fd7de8119dd6597127060e884
(ppc_opts) <altivec>: Use PPC_OPCODE_ALTIVEC2
ab4437c3224faf2513c72e9361f6577e02998c5d
<vcfpsxws>: Fix opcode spelling
62082a42b9cd32b0b4c5925edd615f2495f9ae98
"lfdp" and "stfdp" use DS offset.
776fc41826bb3fba1c6ced6c28f54347004a694b
(ppc_parse_cpu): Update prototype
943d398f4c528b87e85092e6b47b7f87f1b899bc
(insert_sci8, extract_sci8): Rewrite.
(insert_sci8n, extract_sci8n): Likewise.
5817ffd1f81cf2d2ae173071775e6e620aa41283
New define (PPC_OPCODE_HTM/POWER8)
9f0682fe89d9bb1107239411dc555d4063543ce0
(extract_vlesi): Properly sign extend
c0637f3af6866ed35039406e564a6743f373cd67 (powerpc_init_dialect): Set default dialect to power8.
58ae08f29af8b8261fddecc9618fd8ea1ebe1532 (powerpc_opcodes): Add tdui, twui, tdu, twu, tui, tu
4f6ffcd38d90eef0e0afc2fd32d7086c706b9bb0 (powerpc_init_dialect): Use ppc_parse_cpu() to set dialect
4b95cf5c0c75d6efc1b2f96af72317aecca079f1
Update copyright years
a47622ac1badbd906c7533ef6011b6bb021271ee
Allow both signed and unsigned fields in PowerPC cmpli insn
12e87fac5c760b04eed4f5a5948c2dfd6ec8f6d8
ppc: enable msgclr and msgsnd on Power8
8514e4db84ccafaf3be07e842be2fa2001ba876e
Don't deprecate powerpc mftb insn
db76a70026ab100148eb274322fac01f1a1dd466 Power4 should treat mftb as extended mfspr mnemonic
b90efa5b79ac1524ec260f8eb89d1be37e0219a7
ChangeLog rotatation and copyright year update
c4e676f196560500d41ff8652d6be0c735758001
powerpc: Add slbfee. instruction
27c49e9a8fc004de116243ba8887e054f1190b42
powerpc: Only initialise opcode indices once
4fff86c517abb5ba454befe0ec0f284f720dde00DCBT_EO): New define
4bc0608a8b693f033555aa5705fdd5fc44cb9a9a
Fix some PPC assembler errors
dc302c00611b6973fbc55e9fdd643ad24c370bd1
Add hwsync extended mnemonic
99a2c56121247207d4846fe7e28b5e7e18e0bfa0 Remove unused MTMSRD_L macro and re-add accidentally deleted comment
11a0cf2ec0ed6e70ff25e9a50c2223dcd98c1c10
Allow for optional operands with non-zero default values
7b9341139a693eac8d316275004b2d752b1f0cb8
PPC sync instruction accepts invalid and incompatible operands
ef5a96d564a22a25d31533c7377eede42c12b25c Remove ppc860, ppc750cl, ppc7450 insns from common ppc
43e65147c07b1400ae0dbb6694882eceb2363713
Remove trailing spaces in opcodes
6dca4fd141fd0b9fe0ea662295833b8ed43cb4e8
Add dscr and ctrl SPR mnemonics
b6518b3871859f9eeb7653bf2f3baaa43fa0a5d0
Fix compile time warnings generated when compiling with clang
36f7a9411dcd7dbeb3483bc83a1acbb3dd235deb
Patches for illegal ppc 500 instructions
a680de9a980e9d268846e8605af14ba1e7f3a39b
Add assembler, disassembler and linker support for power9
dd2887fc3de48f6261d34208a0132122f05d7ef4
Reorder some power9 insns
b817670b52b7414d592cbfd96fd77cf725a33413
Enable 2 operand form of powerpc mfcr with -many
6f2750feaf2827ef8a1a0a5b2f90c1e9a6cabbd1
Copyright update for binutils
afa8d4054b8e0b1384f2d07f1c15163c0699d660 Delete opcodes that have been removed from ISA 3.0
1178da445ad5faf37f9cc2be3aaa69d916f10f62
Accept valid one byte signed and unsigned values for the IMM8 operand
e43de63c8fd11a15d7c6c852747c81664c0beb2a
Fix powerpc subis range
514e58b726338c24b672d96bd48f8ce8a47f7803
Correct "Fix powerpc subis range"
19dfcc89e8d94526f011242041b700ede8834996
Add support for new POWER ISA 3.0 instructions
1fe0971e41a4097610862acabf54a896695fe834
add more extern C
026122a670440bc51266f8e013e5c5877c19b54e
Re-add support for lbarx, lharx, stbcx. and sthcx. insns back to the E6500 cpu
14b57c7c6a53c747a8819fed3da858eae4195a0e
PowerPC VLE
6fd3a02da5548c71ff469f978444ef6c3af18783
Add support for yet some more new ISA 3.0 instructions
dfdaec14b0db059497b47b515d753b6383772b6b
Fix some PowerPC VLE BFD issues and add some PowerPC VLE instructions
fd486b633e87f8ab2977592d56a6d98168814e2e
Modify POWER9 support to match final ISA 3.0 documentation
a5721ba270ddf860e0e5a45bba456214e8eac2be
Disallow 3-operand cmp[l][i] for ppc64
This updates the disassembly capabilities to add
support newer processors.
NOTE: This version will break build, a bisect to
this point will yield nothing as this version
does not even compile.
--- arch/powerpc/xmon/ppc-dis.c | 710 +++- arch/powerpc/xmon/ppc-opc.c | 8591 ++++++++++++++++++++++++++++--------------- arch/powerpc/xmon/ppc.h | 222 +- 3 files changed, 6310 insertions(+), 3213 deletions(-)
arch/powerpc/xmon/ppc-dis.c +563 -147
@@ -1,6 +1,5 @@/* ppc-dis.c -- Disassemble PowerPC instructions -Copyright 1994, 1995, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 -Free Software Foundation, Inc. +Copyright (C) 1994-2016 Free Software Foundation, Inc. Written by Ian Lance Taylor, Cygnus Support This file is part of GDB, GAS, and the GNU binutils.
@@ -19,9 +18,12 @@ You should have received a copy of the GNU General Public Licensealong with this file; see the file COPYING. If not, write to the Free Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ -#include <stdio.h> #include "sysdep.h" +#include <stdio.h> #include "dis-asm.h" +#include "elf-bfd.h" +#include "elf/ppc.h" +#include "opintl.h" #include "opcode/ppc.h" /* This file provides several disassembler functions, all of which use
@@ -29,76 +31,380 @@ Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USare provided because this file handles disassembly for the PowerPC in both big and little endian mode and also for the POWER (RS/6000) chip. */ +static int print_insn_powerpc (bfd_vma ,struct disassemble_info *,int , +ppc_cpu_t ); -static int print_insn_powerpc (bfd_vma ,struct disassemble_info *,int ,int ); +struct dis_private +{ +/* Stash the result of parsing disassembler_options here. */ +ppc_cpu_t dialect; +} private; + +#define POWERPC_DIALECT (INFO ) \ + (((struct dis_private *) ((INFO)->private_data))->dialect) + +struct ppc_mopt { +const char *opt; +ppc_cpu_t cpu; +ppc_cpu_t sticky; +}; + +struct ppc_mopt ppc_opts[] = { + {"403" ,PPC_OPCODE_PPC |PPC_OPCODE_403 , +0 }, + {"405" ,PPC_OPCODE_PPC |PPC_OPCODE_403 |PPC_OPCODE_405 , +0 }, + {"440" , (PPC_OPCODE_PPC |PPC_OPCODE_BOOKE |PPC_OPCODE_440 + |PPC_OPCODE_ISEL |PPC_OPCODE_RFMCI ), +0 }, + {"464" , (PPC_OPCODE_PPC |PPC_OPCODE_BOOKE |PPC_OPCODE_440 + |PPC_OPCODE_ISEL |PPC_OPCODE_RFMCI ), +0 }, + {"476" , (PPC_OPCODE_PPC |PPC_OPCODE_ISEL |PPC_OPCODE_440 + |PPC_OPCODE_476 |PPC_OPCODE_POWER4 |PPC_OPCODE_POWER5 ), +0 }, + {"601" ,PPC_OPCODE_PPC |PPC_OPCODE_601 , +0 }, + {"603" ,PPC_OPCODE_PPC , +0 }, + {"604" ,PPC_OPCODE_PPC , +0 }, + {"620" ,PPC_OPCODE_PPC |PPC_OPCODE_64 , +0 }, + {"7400" ,PPC_OPCODE_PPC |PPC_OPCODE_ALTIVEC , +0 }, + {"7410" ,PPC_OPCODE_PPC |PPC_OPCODE_ALTIVEC , +0 }, + {"7450" ,PPC_OPCODE_PPC |PPC_OPCODE_7450 |PPC_OPCODE_ALTIVEC , +0 }, + {"7455" ,PPC_OPCODE_PPC |PPC_OPCODE_ALTIVEC , +0 }, + {"750cl" ,PPC_OPCODE_PPC |PPC_OPCODE_750 |PPC_OPCODE_PPCPS + ,0 }, + {"821" ,PPC_OPCODE_PPC |PPC_OPCODE_860 , +0 }, + {"850" ,PPC_OPCODE_PPC |PPC_OPCODE_860 , +0 }, + {"860" ,PPC_OPCODE_PPC |PPC_OPCODE_860 , +0 }, + {"a2" , (PPC_OPCODE_PPC |PPC_OPCODE_ISEL |PPC_OPCODE_POWER4 + |PPC_OPCODE_POWER5 |PPC_OPCODE_CACHELCK |PPC_OPCODE_64 + |PPC_OPCODE_A2 ), +0 }, + {"altivec" ,PPC_OPCODE_PPC , +PPC_OPCODE_ALTIVEC |PPC_OPCODE_ALTIVEC2 }, + {"any" ,0 , +PPC_OPCODE_ANY }, + {"booke" ,PPC_OPCODE_PPC |PPC_OPCODE_BOOKE , +0 }, + {"booke32" ,PPC_OPCODE_PPC |PPC_OPCODE_BOOKE , +0 }, + {"cell" , (PPC_OPCODE_PPC |PPC_OPCODE_64 |PPC_OPCODE_POWER4 + |PPC_OPCODE_CELL |PPC_OPCODE_ALTIVEC ), +0 }, + {"com" ,PPC_OPCODE_COMMON , +0 }, + {"e200z4" , (PPC_OPCODE_PPC |PPC_OPCODE_BOOKE |PPC_OPCODE_SPE + |PPC_OPCODE_ISEL |PPC_OPCODE_EFS |PPC_OPCODE_BRLOCK + |PPC_OPCODE_PMR |PPC_OPCODE_CACHELCK |PPC_OPCODE_RFMCI + |PPC_OPCODE_E500 |PPC_OPCODE_E200Z4 ), +PPC_OPCODE_VLE }, + {"e300" ,PPC_OPCODE_PPC |PPC_OPCODE_E300 , +0 }, + {"e500" , (PPC_OPCODE_PPC |PPC_OPCODE_BOOKE |PPC_OPCODE_SPE + |PPC_OPCODE_ISEL |PPC_OPCODE_EFS |PPC_OPCODE_BRLOCK + |PPC_OPCODE_PMR |PPC_OPCODE_CACHELCK |PPC_OPCODE_RFMCI + |PPC_OPCODE_E500 ), +0 }, + {"e500mc" , (PPC_OPCODE_PPC |PPC_OPCODE_BOOKE |PPC_OPCODE_ISEL + |PPC_OPCODE_PMR |PPC_OPCODE_CACHELCK |PPC_OPCODE_RFMCI + |PPC_OPCODE_E500MC ), +0 }, + {"e500mc64" , (PPC_OPCODE_PPC |PPC_OPCODE_BOOKE |PPC_OPCODE_ISEL + |PPC_OPCODE_PMR |PPC_OPCODE_CACHELCK |PPC_OPCODE_RFMCI + |PPC_OPCODE_E500MC |PPC_OPCODE_64 |PPC_OPCODE_POWER5 + |PPC_OPCODE_POWER6 |PPC_OPCODE_POWER7 ), +0 }, + {"e5500" , (PPC_OPCODE_PPC |PPC_OPCODE_BOOKE |PPC_OPCODE_ISEL + |PPC_OPCODE_PMR |PPC_OPCODE_CACHELCK |PPC_OPCODE_RFMCI + |PPC_OPCODE_E500MC |PPC_OPCODE_64 |PPC_OPCODE_POWER4 + |PPC_OPCODE_POWER5 |PPC_OPCODE_POWER6 + |PPC_OPCODE_POWER7 ), +0 }, + {"e6500" , (PPC_OPCODE_PPC |PPC_OPCODE_BOOKE |PPC_OPCODE_ISEL + |PPC_OPCODE_PMR |PPC_OPCODE_CACHELCK |PPC_OPCODE_RFMCI + |PPC_OPCODE_E500MC |PPC_OPCODE_64 |PPC_OPCODE_ALTIVEC + |PPC_OPCODE_ALTIVEC2 |PPC_OPCODE_E6500 |PPC_OPCODE_POWER4 + |PPC_OPCODE_POWER5 |PPC_OPCODE_POWER6 |PPC_OPCODE_POWER7 ), +0 }, + {"e500x2" , (PPC_OPCODE_PPC |PPC_OPCODE_BOOKE |PPC_OPCODE_SPE + |PPC_OPCODE_ISEL |PPC_OPCODE_EFS |PPC_OPCODE_BRLOCK + |PPC_OPCODE_PMR |PPC_OPCODE_CACHELCK |PPC_OPCODE_RFMCI + |PPC_OPCODE_E500 ), +0 }, + {"efs" ,PPC_OPCODE_PPC |PPC_OPCODE_EFS , +0 }, + {"power4" ,PPC_OPCODE_PPC |PPC_OPCODE_64 |PPC_OPCODE_POWER4 , +0 }, + {"power5" , (PPC_OPCODE_PPC |PPC_OPCODE_64 |PPC_OPCODE_POWER4 + |PPC_OPCODE_POWER5 ), +0 }, + {"power6" , (PPC_OPCODE_PPC |PPC_OPCODE_64 |PPC_OPCODE_POWER4 + |PPC_OPCODE_POWER5 |PPC_OPCODE_POWER6 |PPC_OPCODE_ALTIVEC ), +0 }, + {"power7" , (PPC_OPCODE_PPC |PPC_OPCODE_ISEL |PPC_OPCODE_64 + |PPC_OPCODE_POWER4 |PPC_OPCODE_POWER5 |PPC_OPCODE_POWER6 + |PPC_OPCODE_POWER7 |PPC_OPCODE_ALTIVEC |PPC_OPCODE_VSX ), +0 }, + {"power8" , (PPC_OPCODE_PPC |PPC_OPCODE_ISEL |PPC_OPCODE_64 + |PPC_OPCODE_POWER4 |PPC_OPCODE_POWER5 |PPC_OPCODE_POWER6 + |PPC_OPCODE_POWER7 |PPC_OPCODE_POWER8 |PPC_OPCODE_HTM + |PPC_OPCODE_ALTIVEC |PPC_OPCODE_ALTIVEC2 |PPC_OPCODE_VSX ), +0 }, + {"power9" , (PPC_OPCODE_PPC |PPC_OPCODE_ISEL |PPC_OPCODE_64 + |PPC_OPCODE_POWER4 |PPC_OPCODE_POWER5 |PPC_OPCODE_POWER6 + |PPC_OPCODE_POWER7 |PPC_OPCODE_POWER8 |PPC_OPCODE_POWER9 + |PPC_OPCODE_HTM |PPC_OPCODE_ALTIVEC |PPC_OPCODE_ALTIVEC2 + |PPC_OPCODE_VSX |PPC_OPCODE_VSX3 ), +0 }, + {"ppc" ,PPC_OPCODE_PPC , +0 }, + {"ppc32" ,PPC_OPCODE_PPC , +0 }, + {"ppc64" ,PPC_OPCODE_PPC |PPC_OPCODE_64 , +0 }, + {"ppc64bridge" ,PPC_OPCODE_PPC |PPC_OPCODE_64_BRIDGE , +0 }, + {"ppcps" ,PPC_OPCODE_PPC |PPC_OPCODE_PPCPS , +0 }, + {"pwr" ,PPC_OPCODE_POWER , +0 }, + {"pwr2" ,PPC_OPCODE_POWER |PPC_OPCODE_POWER2 , +0 }, + {"pwr4" ,PPC_OPCODE_PPC |PPC_OPCODE_64 |PPC_OPCODE_POWER4 , +0 }, + {"pwr5" , (PPC_OPCODE_PPC |PPC_OPCODE_64 |PPC_OPCODE_POWER4 + |PPC_OPCODE_POWER5 ), +0 }, + {"pwr5x" , (PPC_OPCODE_PPC |PPC_OPCODE_64 |PPC_OPCODE_POWER4 + |PPC_OPCODE_POWER5 ), +0 }, + {"pwr6" , (PPC_OPCODE_PPC |PPC_OPCODE_64 |PPC_OPCODE_POWER4 + |PPC_OPCODE_POWER5 |PPC_OPCODE_POWER6 |PPC_OPCODE_ALTIVEC ), +0 }, + {"pwr7" , (PPC_OPCODE_PPC |PPC_OPCODE_ISEL |PPC_OPCODE_64 + |PPC_OPCODE_POWER4 |PPC_OPCODE_POWER5 |PPC_OPCODE_POWER6 + |PPC_OPCODE_POWER7 |PPC_OPCODE_ALTIVEC |PPC_OPCODE_VSX ), +0 }, + {"pwr8" , (PPC_OPCODE_PPC |PPC_OPCODE_ISEL |PPC_OPCODE_64 + |PPC_OPCODE_POWER4 |PPC_OPCODE_POWER5 |PPC_OPCODE_POWER6 + |PPC_OPCODE_POWER7 |PPC_OPCODE_POWER8 |PPC_OPCODE_HTM + |PPC_OPCODE_ALTIVEC |PPC_OPCODE_ALTIVEC2 |PPC_OPCODE_VSX ), +0 }, + {"pwr9" , (PPC_OPCODE_PPC |PPC_OPCODE_ISEL |PPC_OPCODE_64 + |PPC_OPCODE_POWER4 |PPC_OPCODE_POWER5 |PPC_OPCODE_POWER6 + |PPC_OPCODE_POWER7 |PPC_OPCODE_POWER8 |PPC_OPCODE_POWER9 + |PPC_OPCODE_HTM |PPC_OPCODE_ALTIVEC |PPC_OPCODE_ALTIVEC2 + |PPC_OPCODE_VSX |PPC_OPCODE_VSX3 ), +0 }, + {"pwrx" ,PPC_OPCODE_POWER |PPC_OPCODE_POWER2 , +0 }, + {"spe" ,PPC_OPCODE_PPC |PPC_OPCODE_EFS , +PPC_OPCODE_SPE }, + {"titan" , (PPC_OPCODE_PPC |PPC_OPCODE_BOOKE |PPC_OPCODE_PMR + |PPC_OPCODE_RFMCI |PPC_OPCODE_TITAN ), +0 }, + {"vle" , (PPC_OPCODE_PPC |PPC_OPCODE_BOOKE |PPC_OPCODE_SPE + |PPC_OPCODE_ISEL |PPC_OPCODE_EFS |PPC_OPCODE_BRLOCK + |PPC_OPCODE_PMR |PPC_OPCODE_CACHELCK |PPC_OPCODE_RFMCI + |PPC_OPCODE_E500 ), +PPC_OPCODE_VLE }, + {"vsx" ,PPC_OPCODE_PPC , +PPC_OPCODE_VSX |PPC_OPCODE_VSX3 }, + {"htm" ,PPC_OPCODE_PPC , +PPC_OPCODE_HTM }, +}; + +/* Switch between Booke and VLE dialects for interlinked dumps. */ +static ppc_cpu_t +get_powerpc_dialect (struct disassemble_info *info) +{ +ppc_cpu_t dialect =0 ; -/* Determine which set of machines to disassemble for. PPC403/601 or -BookE. For convenience, also disassemble instructions supported -by the AltiVec vector unit. */ + dialect =POWERPC_DIALECT (info); -static int -powerpc_dialect (struct disassemble_info *info) -{ -int dialect =PPC_OPCODE_PPC ; - -if (BFD_DEFAULT_TARGET_SIZE ==64 ) - dialect |=PPC_OPCODE_64 ; - -if (info->disassembler_options - &&strstr (info->disassembler_options,"booke" ) !=NULL ) - dialect |=PPC_OPCODE_BOOKE |PPC_OPCODE_BOOKE64 ; -else if ((info->mach == bfd_mach_ppc_e500) - || (info->disassembler_options - &&strstr (info->disassembler_options,"e500" ) !=NULL )) - dialect |= (PPC_OPCODE_BOOKE - |PPC_OPCODE_SPE |PPC_OPCODE_ISEL - |PPC_OPCODE_EFS |PPC_OPCODE_BRLOCK - |PPC_OPCODE_PMR |PPC_OPCODE_CACHELCK - |PPC_OPCODE_RFMCI ); -else if (info->disassembler_options - &&strstr (info->disassembler_options,"efs" ) !=NULL ) - dialect |=PPC_OPCODE_EFS ; -else if (info->disassembler_options - &&strstr (info->disassembler_options,"e300" ) !=NULL ) - dialect |=PPC_OPCODE_E300 |PPC_OPCODE_CLASSIC |PPC_OPCODE_COMMON ; -else if (info->disassembler_options - &&strstr (info->disassembler_options,"440" ) !=NULL ) - dialect |=PPC_OPCODE_BOOKE |PPC_OPCODE_32 - |PPC_OPCODE_440 |PPC_OPCODE_ISEL |PPC_OPCODE_RFMCI ; +/* Disassemble according to the section headers flags for VLE-mode. */ +if (dialect &PPC_OPCODE_VLE + && info->section->owner !=NULL + &&bfd_get_flavour (info->section->owner) == bfd_target_elf_flavour + &&elf_object_id (info->section->owner) ==PPC32_ELF_DATA + && (elf_section_flags (info->section) &SHF_PPC_VLE ) !=0 ) +return dialect;else - dialect |= (PPC_OPCODE_403 |PPC_OPCODE_601 |PPC_OPCODE_CLASSIC - |PPC_OPCODE_COMMON |PPC_OPCODE_ALTIVEC ); +return dialect & ~PPC_OPCODE_VLE ; +} + +/* Handle -m and -M options that set cpu type, and .machine arg. */ -if (info->disassembler_options - &&strstr (info->disassembler_options,"power4" ) !=NULL ) - dialect |=PPC_OPCODE_POWER4 ; +ppc_cpu_t +ppc_parse_cpu (ppc_cpu_t ppc_cpu,ppc_cpu_t *sticky,const char *arg) +{ +unsigned int i; + +for (i =0 ; i <sizeof (ppc_opts) /sizeof (ppc_opts[0 ]); i++) +if (strcmp (ppc_opts[i].opt, arg) ==0 ) + { +if (ppc_opts[i].sticky) + { + *sticky |= ppc_opts[i].sticky; +if ((ppc_cpu & ~*sticky) !=0 ) +break ; + } + ppc_cpu = ppc_opts[i].cpu; +break ; + } +if (i >=sizeof (ppc_opts) /sizeof (ppc_opts[0 ])) +return 0 ; + + ppc_cpu |= *sticky; +return ppc_cpu; +} -if (info->disassembler_options - &&strstr (info->disassembler_options,"power5" ) !=NULL ) - dialect |=PPC_OPCODE_POWER4 |PPC_OPCODE_POWER5 ; +/* Determine which set of machines to disassemble for. */ -if (info->disassembler_options - &&strstr (info->disassembler_options,"cell" ) !=NULL ) - dialect |=PPC_OPCODE_POWER4 |PPC_OPCODE_CELL |PPC_OPCODE_ALTIVEC ; +static void +powerpc_init_dialect (struct disassemble_info *info) +{ +ppc_cpu_t dialect =0 ; +ppc_cpu_t sticky =0 ; +char *arg; +struct dis_private *priv =calloc (sizeof (*priv),1 ); -if (info->disassembler_options - &&strstr (info->disassembler_options,"power6" ) !=NULL ) - dialect |=PPC_OPCODE_POWER4 |PPC_OPCODE_POWER5 |PPC_OPCODE_POWER6 |PPC_OPCODE_ALTIVEC ; +if (priv ==NULL ) + priv = &private; -if (info->disassembler_options - &&strstr (info->disassembler_options,"any" ) !=NULL ) - dialect |=PPC_OPCODE_ANY ; +switch (info->mach) + { +case bfd_mach_ppc_403: +case bfd_mach_ppc_403gc: + dialect =ppc_parse_cpu (dialect, &sticky,"403" ); +break ; +case bfd_mach_ppc_405: + dialect =ppc_parse_cpu (dialect, &sticky,"405" ); +break ; +case bfd_mach_ppc_601: + dialect =ppc_parse_cpu (dialect, &sticky,"601" ); +break ; +case bfd_mach_ppc_a35: +case bfd_mach_ppc_rs64ii: +case bfd_mach_ppc_rs64iii: + dialect =ppc_parse_cpu (dialect, &sticky,"pwr2" ) |PPC_OPCODE_64 ; +break ; +case bfd_mach_ppc_e500: + dialect =ppc_parse_cpu (dialect, &sticky,"e500" ); +break ; +case bfd_mach_ppc_e500mc: + dialect =ppc_parse_cpu (dialect, &sticky,"e500mc" ); +break ; +case bfd_mach_ppc_e500mc64: + dialect =ppc_parse_cpu (dialect, &sticky,"e500mc64" ); +break ; +case bfd_mach_ppc_e5500: + dialect =ppc_parse_cpu (dialect, &sticky,"e5500" ); +break ; +case bfd_mach_ppc_e6500: + dialect =ppc_parse_cpu (dialect, &sticky,"e6500" ); +break ; +case bfd_mach_ppc_titan: + dialect =ppc_parse_cpu (dialect, &sticky,"titan" ); +break ; +case bfd_mach_ppc_vle: + dialect =ppc_parse_cpu (dialect, &sticky,"vle" ); +break ; +default : + dialect =ppc_parse_cpu (dialect, &sticky,"power9" ) |PPC_OPCODE_ANY ; + } -if (info->disassembler_options) + arg = info->disassembler_options; +while (arg !=NULL ) { -if (strstr (info->disassembler_options,"32" ) !=NULL ) - dialect &= ~PPC_OPCODE_64 ; -else if (strstr (info->disassembler_options,"64" ) !=NULL ) +ppc_cpu_t new_cpu =0 ; +char *end =strchr (arg,',' ); + +if (end !=NULL ) + *end =0 ; + +if ((new_cpu =ppc_parse_cpu (dialect, &sticky, arg)) !=0 ) + dialect = new_cpu; +else if (strcmp (arg,"32" ) ==0 ) + dialect &= ~(ppc_cpu_t )PPC_OPCODE_64 ; +else if (strcmp (arg,"64" ) ==0 ) dialect |=PPC_OPCODE_64 ; +else +fprintf (stderr,_ ("warning: ignoring unknown -M%s option\n" ), arg); + +if (end !=NULL ) + *end++ =',' ; + arg = end; + } + + info->private_data = priv; +POWERPC_DIALECT (info) = dialect; +} + +#define PPC_OPCD_SEGS 64 +static unsigned short powerpc_opcd_indices[PPC_OPCD_SEGS +1 ]; +#define VLE_OPCD_SEGS 32 +static unsigned short vle_opcd_indices[VLE_OPCD_SEGS +1 ]; + +/* Calculate opcode table indices to speed up disassembly, +and init dialect. */ + +void +disassemble_init_powerpc (struct disassemble_info *info) +{ +int i; +unsigned short last; + +if (powerpc_opcd_indices[PPC_OPCD_SEGS ] ==0 ) + { + + i = powerpc_num_opcodes; +while (--i >=0 ) + { +unsigned op =PPC_OP (powerpc_opcodes[i].opcode); + + powerpc_opcd_indices[op] = i; + } + + last = powerpc_num_opcodes; +for (i =PPC_OPCD_SEGS ; i >0 ; --i) + { +if (powerpc_opcd_indices[i] ==0 ) + powerpc_opcd_indices[i] = last; + last = powerpc_opcd_indices[i]; + } + + i = vle_num_opcodes; +while (--i >=0 ) + { +unsigned op =VLE_OP (vle_opcodes[i].opcode, vle_opcodes[i].mask); +unsigned seg =VLE_OP_TO_SEG (op); + + vle_opcd_indices[seg] = i; + } + + last = vle_num_opcodes; +for (i =VLE_OPCD_SEGS ; i >0 ; --i) + { +if (vle_opcd_indices[i] ==0 ) + vle_opcd_indices[i] = last; + last = vle_opcd_indices[i]; + } } - info->private_data = (char *)0 + dialect; -return dialect; +if (info->arch == bfd_arch_powerpc) +powerpc_init_dialect (info); }/* Print a big endian PowerPC instruction. */
@@ -106,8 +412,7 @@ powerpc_dialect (struct disassemble_info *info)int print_insn_big_powerpc (bfd_vma memaddr,struct disassemble_info *info) { -int dialect = (char *) info->private_data - (char *)0 ; -return print_insn_powerpc (memaddr, info,1 , dialect); +return print_insn_powerpc (memaddr, info,1 ,get_powerpc_dialect (info)); }/* Print a little endian PowerPC instruction. */
@@ -115,8 +420,7 @@ print_insn_big_powerpc (bfd_vma memaddr, struct disassemble_info *info)int print_insn_little_powerpc (bfd_vma memaddr,struct disassemble_info *info) { -int dialect = (char *) info->private_data - (char *)0 ; -return print_insn_powerpc (memaddr, info,0 , dialect); +return print_insn_powerpc (memaddr, info,0 ,get_powerpc_dialect (info)); }/* Print a POWER (RS/6000) instruction. */
@@ -131,7 +435,7 @@ print_insn_rs6000 (bfd_vma memaddr, struct disassemble_info *info)static long operand_value_powerpc (const struct powerpc_operand *operand, -unsigned long insn,int dialect) +unsigned long insn,ppc_cpu_t dialect) {long value;int invalid;
@@ -140,11 +444,14 @@ operand_value_powerpc (const struct powerpc_operand *operand, value = (*operand->extract) (insn, dialect, &invalid); else { - value = (insn >> operand->shift) & operand->bitm; +if (operand->shift >=0 ) + value = (insn >> operand->shift) & operand->bitm; +else + value = (insn << -operand->shift) & operand->bitm;if ((operand->flags &PPC_OPERAND_SIGNED ) !=0 ) {/* BITM is always some number of zeros followed by some -number of ones, followed by some numer of zeros. */ +number of ones, followed by some number of zeros. */ unsigned long top = operand->bitm;/* top & -top gives the rightmost 1 bit, so this fills in any trailing zeros. */
@@ -161,7 +468,7 @@ operand_value_powerpc (const struct powerpc_operand *operand,static int skip_optional_operands (const unsigned char *opindex, -unsigned long insn,int dialect) +unsigned long insn,ppc_cpu_t dialect) {const struct powerpc_operand *operand;
@@ -170,36 +477,148 @@ skip_optional_operands (const unsigned char *opindex, operand = &powerpc_operands[*opindex];if ((operand->flags &PPC_OPERAND_NEXT ) !=0 || ((operand->flags &PPC_OPERAND_OPTIONAL ) !=0 - &&operand_value_powerpc (operand, insn, dialect) !=0 )) + &&operand_value_powerpc (operand, insn, dialect) != +ppc_optional_operand_value (operand)))return 0 ; }return 1 ; } +/* Find a match for INSN in the opcode table, given machine DIALECT. +A DIALECT of -1 is special, matching all machine opcode variations. */ + +static const struct powerpc_opcode * +lookup_powerpc (unsigned long insn,ppc_cpu_t dialect) +{ +const struct powerpc_opcode *opcode; +const struct powerpc_opcode *opcode_end; +unsigned long op; + +/* Get the major opcode of the instruction. */ + op =PPC_OP (insn); + +/* Find the first match in the opcode table for this major opcode. */ + opcode_end = powerpc_opcodes + powerpc_opcd_indices[op +1 ]; +for (opcode = powerpc_opcodes + powerpc_opcd_indices[op]; + opcode < opcode_end; + ++opcode) + { +const unsigned char *opindex; +const struct powerpc_operand *operand; +int invalid; + +if ((insn & opcode->mask) != opcode->opcode + || (dialect != (ppc_cpu_t) -1 + && ((opcode->flags & dialect) ==0 + || (opcode->deprecated & dialect) !=0 ))) +continue ; + +/* Check validity of operands. */ + invalid =0 ; +for (opindex = opcode->operands; *opindex !=0 ; opindex++) + { + operand = powerpc_operands + *opindex; +if (operand->extract) + (*operand->extract) (insn, dialect, &invalid); + } +if (invalid) +continue ; + +return opcode; + } + +return NULL ; +} + +/* Find a match for INSN in the VLE opcode table. */ + +static const struct powerpc_opcode * +lookup_vle (unsigned long insn) +{ +const struct powerpc_opcode *opcode; +const struct powerpc_opcode *opcode_end; +unsigned op, seg; + + op =PPC_OP (insn); +if (op >=0x20 && op <=0x37 ) + { +/* This insn has a 4-bit opcode. */ + op &=0x3c ; + } + seg =VLE_OP_TO_SEG (op); + +/* Find the first match in the opcode table for this major opcode. */ + opcode_end = vle_opcodes + vle_opcd_indices[seg +1 ]; +for (opcode = vle_opcodes + vle_opcd_indices[seg]; + opcode < opcode_end; + ++opcode) + { +unsigned long table_opcd = opcode->opcode; +unsigned long table_mask = opcode->mask; +bfd_boolean table_op_is_short =PPC_OP_SE_VLE (table_mask); +unsigned long insn2; +const unsigned char *opindex; +const struct powerpc_operand *operand; +int invalid; + + insn2 = insn; +if (table_op_is_short) + insn2 >>=16 ; +if ((insn2 & table_mask) != table_opcd) +continue ; + +/* Check validity of operands. */ + invalid =0 ; +for (opindex = opcode->operands; *opindex !=0 ; ++opindex) + { + operand = powerpc_operands + *opindex; +if (operand->extract) + (*operand->extract) (insn, (ppc_cpu_t )0 , &invalid); + } +if (invalid) +continue ; + +return opcode; + } + +return NULL ; +} +/* Print a PowerPC or POWER instruction. */ static int print_insn_powerpc (bfd_vma memaddr,struct disassemble_info *info,int bigendian, -int dialect) +ppc_cpu_t dialect) {bfd_byte buffer[4 ];int status;unsigned long insn;const struct powerpc_opcode *opcode; -const struct powerpc_opcode *opcode_end; -unsigned long op; - -if (dialect ==0 ) - dialect =powerpc_dialect (info); +bfd_boolean insn_is_short; status = (*info->read_memory_func) (memaddr, buffer,4 , info);if (status !=0 ) { - (*info->memory_error_func) (status, memaddr, info); -return -1 ; +/* The final instruction may be a 2-byte VLE insn. */ +if ((dialect &PPC_OPCODE_VLE ) !=0 ) + { +/* Clear buffer so unused bytes will not have garbage in them. */ + buffer[0 ] = buffer[1 ] = buffer[2 ] = buffer[3 ] =0 ; + status = (*info->read_memory_func) (memaddr, buffer,2 , info); +if (status !=0 ) + { + (*info->memory_error_func) (status, memaddr, info); +return -1 ; + } + } +else + { + (*info->memory_error_func) (status, memaddr, info); +return -1 ; + } }if (bigendian)
@@ -207,52 +626,37 @@ print_insn_powerpc (bfd_vma memaddr,else insn =bfd_getl32 (buffer); -/* Get the major opcode of the instruction. */ - op =PPC_OP (insn); +/* Get the major opcode of the insn. */ + opcode =NULL ; + insn_is_short = FALSE; +if ((dialect &PPC_OPCODE_VLE ) !=0 ) + { + opcode =lookup_vle (insn); +if (opcode !=NULL ) + insn_is_short =PPC_OP_SE_VLE (opcode->mask); + } +if (opcode ==NULL ) + opcode =lookup_powerpc (insn, dialect); +if (opcode ==NULL && (dialect &PPC_OPCODE_ANY ) !=0 ) + opcode =lookup_powerpc (insn, (ppc_cpu_t) -1 ); -/* Find the first match in the opcode table. We could speed this up -a bit by doing a binary search on the major opcode. */ - opcode_end = powerpc_opcodes + powerpc_num_opcodes; - again: -for (opcode = powerpc_opcodes; opcode < opcode_end; opcode++) +if (opcode !=NULL ) { -unsigned long table_op;const unsigned char *opindex;const struct powerpc_operand *operand; -int invalid;int need_comma;int need_paren;int skip_optional; - table_op =PPC_OP (opcode->opcode); -if (op < table_op) -break ; -if (op > table_op) -continue ; - -if ((insn & opcode->mask) != opcode->opcode - || (opcode->flags & dialect) ==0 ) -continue ; - -/* Make two passes over the operands. First see if any of them -have extraction functions, and, if they do, make sure the -instruction is valid. */ - invalid =0 ; -for (opindex = opcode->operands; *opindex !=0 ; opindex++) - { - operand = powerpc_operands + *opindex; -if (operand->extract) - (*operand->extract) (insn, dialect, &invalid); - } -if (invalid) -continue ; - -/* The instruction is valid. */ if (opcode->operands[0 ] !=0 ) (*info->fprintf_func) (info->stream,"%-7s " , opcode->name);else (*info->fprintf_func) (info->stream,"%s" , opcode->name); +if (insn_is_short) +/* The operands will be fetched out of the 16-bit instruction. */ + insn >>=16 ; +/* Now extract and print the operands. */ need_comma =0 ; need_paren =0 ;
@@ -296,30 +700,38 @@ print_insn_powerpc (bfd_vma memaddr, (*info->fprintf_func) (info->stream,"f%ld" , value); else if ((operand->flags & PPC_OPERAND_VR) != 0) (*info->fprintf_func) (info->stream, "v%ld", value); + else if ((operand->flags & PPC_OPERAND_VSR) != 0) + (*info->fprintf_func) (info->stream, "vs%ld", value); else if ((operand->flags & PPC_OPERAND_RELATIVE) != 0) (*info->print_address_func) (memaddr + value, info); else if ((operand->flags & PPC_OPERAND_ABSOLUTE) != 0) (*info->print_address_func) ((bfd_vma) value & 0xffffffff, info); - else if ((operand->flags & PPC_OPERAND_CR) == 0 - || (dialect & PPC_OPCODE_PPC) == 0) + else if ((operand->flags & PPC_OPERAND_FSL) != 0) + (*info->fprintf_func) (info->stream, "fsl%ld", value); + else if ((operand->flags & PPC_OPERAND_FCR) != 0) + (*info->fprintf_func) (info->stream, "fcr%ld", value); + else if ((operand->flags & PPC_OPERAND_UDI) != 0) (*info->fprintf_func) (info->stream, "%ld", value); - else + else if ((operand->flags & PPC_OPERAND_CR_REG) != 0 + && (((dialect & PPC_OPCODE_PPC) != 0) + || ((dialect & PPC_OPCODE_VLE) != 0))) + (*info->fprintf_func) (info->stream, "cr%ld", value); + else if (((operand->flags & PPC_OPERAND_CR_BIT) != 0) + && (((dialect & PPC_OPCODE_PPC) != 0) + || ((dialect & PPC_OPCODE_VLE) != 0))) { -if (operand->bitm ==7 ) - (*info->fprintf_func) (info->stream,"cr%ld" , value); -else - { -static const char *cbnames[4 ] = {"lt" ,"gt" ,"eq" ,"so" }; -int cr; -int cc; - - cr = value >>2 ; -if (cr !=0 ) - (*info->fprintf_func) (info->stream,"4*cr%d+" , cr); - cc = value &3 ; - (*info->fprintf_func) (info->stream,"%s" , cbnames[cc]); - } + static const char *cbnames[4] = { "lt", "gt", "eq", "so" }; + int cr; + int cc; + + cr = value >> 2; + if (cr != 0) + (*info->fprintf_func) (info->stream, "4*cr%d+", cr); + cc = value &3 ; + (*info->fprintf_func) (info->stream,"%s" , cbnames[cc]); } + else + (*info->fprintf_func) (info->stream,"%d" , (int ) value);if (need_paren) {
@@ -336,14 +748,16 @@ print_insn_powerpc (bfd_vma memaddr, } } -/* We have found and printed an instruction; return. */ -return 4 ; - } - -if ((dialect &PPC_OPCODE_ANY ) !=0 ) - { - dialect = ~PPC_OPCODE_ANY ; - goto again; +/* We have found and printed an instruction. +If it was a short VLE instruction we have more to do. */ +if (insn_is_short) + { + memaddr +=2 ; +return 2 ; + } +else +/* Otherwise, return. */ +return 4 ; }/* We could not find a match. */
@@ -355,18 +769,20 @@ print_insn_powerpc (bfd_vma memaddr,void print_ppc_disassembler_options (FILE *stream) { -fprintf (stream,"\n\ +unsigned int i, col; + +fprintf (stream,_ ("\n\ The following PPC specific disassembler options are supported for use with\n\ -the -M switch:\n" ); - -fprintf (stream," booke|booke32|booke64 Disassemble the BookE instructions\n" ); -fprintf (stream," e300 Disassemble the e300 instructions\n" ); -fprintf (stream," e500|e500x2 Disassemble the e500 instructions\n" ); -fprintf (stream," 440 Disassemble the 440 instructions\n" ); -fprintf (stream," efs Disassemble the EFS instructions\n" ); -fprintf (stream," power4 Disassemble the Power4 instructions\n" ); -fprintf (stream," power5 Disassemble the Power5 instructions\n" ); -fprintf (stream," power6 Disassemble the Power6 instructions\n" ); -fprintf (stream," 32 Do not disassemble 64-bit instructions\n" ); -fprintf (stream," 64 Allow disassembly of 64-bit instructions\n" ); +the -M switch:\n" )); + +for (col =0 , i =0 ; i <sizeof (ppc_opts) /sizeof (ppc_opts[0 ]); i++) + { + col +=fprintf (stream," %s," , ppc_opts[i].opt); +if (col >66 ) + { +fprintf (stream,"\n" ); + col =0 ; + } + } +fprintf (stream," 32, 64\n" ); }
arch/powerpc/xmon/ppc-opc.c +5572 -3019
2,155 lines not on this page · raw message
arch/powerpc/xmon/ppc.h +175 -47
222 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.9.3
Part of the diff is not shown here. View the raw message.
kbuild test robot
build botRe: [PATCH 2/3] powerpc/xmon: Apply binutils changes to upgrade disassembly
reproduce: wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree…
Hi Balbir,
[auto build test ERROR on powerpc/next]
[also build test ERROR on v4.10-rc6 next-20170201]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Balbir-Singh/Update-xmon-disassembly/20170202-135830 base: https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git next config: powerpc-defconfig (attached as .config) compiler: powerpc64-linux-gnu-gcc (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=powerpc
Note: the linux-review/Balbir-Singh/Update-xmon-disassembly/20170202-135830 HEAD aab7a78909e32ae5743164fc79d9f5eda993f0e7 builds fine.
It only hurts bisectibility.
All errors (new ones prefixed by >>):
>> arch/powerpc/xmon/ppc-dis.c:21:20: fatal error: sysdep.h: No such file or directory
#include "sysdep.h"
^
compilation terminated.
--
>> arch/powerpc/xmon/ppc-opc.c:22:20: fatal error: sysdep.h: No such file or directory
#include "sysdep.h"
^compilation terminated.
vim +21 arch/powerpc/xmon/ppc-dis.c
^1da177e arch/ppc64/xmon/ppc-dis.c Linus Torvalds 2005-04-16 15 the GNU General Public License for more details. ^1da177e arch/ppc64/xmon/ppc-dis.c Linus Torvalds 2005-04-16 16 ^1da177e arch/ppc64/xmon/ppc-dis.c Linus Torvalds 2005-04-16 17 You should have received a copy of the GNU General Public License ^1da177e arch/ppc64/xmon/ppc-dis.c Linus Torvalds 2005-04-16 18 along with this file; see the file COPYING. If not, write to the Free 897f112b arch/powerpc/xmon/ppc-dis.c Michael Ellerman 2006-11-23 19 Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ ^1da177e arch/ppc64/xmon/ppc-dis.c Linus Torvalds 2005-04-16 20 36a211d8 arch/powerpc/xmon/ppc-dis.c Balbir Singh 2017-02-02 @21 #include "sysdep.h" c4d6af82 arch/powerpc/xmon/ppc-dis.c Balbir Singh 2017-02-02 22 #include <stdio.h> e0426047 arch/powerpc/xmon/ppc-dis.c Michael Ellerman 2006-11-23 23 #include "dis-asm.h" c4d6af82 arch/powerpc/xmon/ppc-dis.c Balbir Singh 2017-02-02 24 #include "elf-bfd.h"
:::::: The code at line 21 was first introduced by commit
:::::: 36a211d8b7faed8b0730f7f4b19bf2a546c40d06 powerpc/xmon Update ppc-dis/opc.c and ppc.h
:::::: TO: Balbir Singh <[email protected]> :::::: CC: 0day robot <[email protected]>
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
Re: [PATCH 2/3] powerpc/xmon: Apply binutils changes to upgrade disassembly
Quoted 6 lines · kbuild test robot
Hi Balbir,
[auto build test ERROR on powerpc/next]
[also build test ERROR on v4.10-rc6 next-20170201]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
FYI for everyone
This patch does not compile, its documented in the patchset and breaks bisect. The organization of this patch is driven more by licensing constraints and modularization
Balbir
Michael Ellerman
reviewerRe: [PATCH 2/3] powerpc/xmon: Apply binutils changes to upgrade disassembly
Quoted 8 lines · Balbir Singh
Quoted 6 lines · kbuild test robot
Hi Balbir,
[auto build test ERROR on powerpc/next]
[also build test ERROR on v4.10-rc6 next-20170201]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
Quoted 5 lines
FYI for everyone
This patch does not compile, its documented in the patchset and breaks bisect. The organization of this patch is driven more by licensing constraints and modularization
I was thinking what I'll do is just disable CONFIG_XMON_DISASSEMBLY before patch 1, and then turn it on again in patch 3.
That way the build won't break at any point, just that code will be unbuildable for a couple of commits, which is fine.
cheers
PATCH 3/3 powerpc/xmon: Enable disassembly files (compilation changes)
In reply to Balbir SinghAfter updating ppc-dis.c, ppc-opc.c and ppc.h the following changes were made to enable compilation and working of xmon
1. Remove all disasmebler_info
2. Use xmon's printf/print_address to output data and addresses respectively
3. All bfd_* types and casts have been removed
4. Optimizations related to opcd_indices have been removed
5. The dialect is set based on cpu features
6. PPC_OPCODE_CLASSIC is no longer supported in the new disassembler
7. VLE opcode parsing and printing has been stripped
8. Coding style conventions used for those routines has been retained and it does not match our CodingStyle
9. The highest supported dialect is POWER9
10. Defined ATTRIBUTE_UNUSED in ppc-dis.c
11. Defined _(x) in ppc-dis.c
--- arch/powerpc/xmon/ppc-dis.c | 592 ++++---------------------------------------- arch/powerpc/xmon/ppc-opc.c | 12 +- arch/powerpc/xmon/ppc.h | 2 - 3 files changed, 60 insertions(+), 546 deletions(-)
arch/powerpc/xmon/ppc-dis.c +52 -540
@@ -18,418 +18,18 @@ You should have received a copy of the GNU General Public Licensealong with this file; see the file COPYING. If not, write to the Free Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ -#include "sysdep.h" -#include <stdio.h> +#include <asm/cputable.h> +#include <asm/cpu_has_feature.h> +#include "nonstdio.h" +#include "ansidecl.h" +#include "ppc.h" #include "dis-asm.h" -#include "elf-bfd.h" -#include "elf/ppc.h" -#include "opintl.h" -#include "opcode/ppc.h" /* This file provides several disassembler functions, all of which use the disassembler interface defined in dis-asm.h. Several functions are provided because this file handles disassembly for the PowerPC in both big and little endian mode and also for the POWER (RS/6000) chip. */ -static int print_insn_powerpc (bfd_vma ,struct disassemble_info *,int , -ppc_cpu_t ); - -struct dis_private -{ -/* Stash the result of parsing disassembler_options here. */ -ppc_cpu_t dialect; -} private; - -#define POWERPC_DIALECT (INFO ) \ - (((struct dis_private *) ((INFO)->private_data))->dialect) - -struct ppc_mopt { -const char *opt; -ppc_cpu_t cpu; -ppc_cpu_t sticky; -}; - -struct ppc_mopt ppc_opts[] = { - {"403" ,PPC_OPCODE_PPC |PPC_OPCODE_403 , -0 }, - {"405" ,PPC_OPCODE_PPC |PPC_OPCODE_403 |PPC_OPCODE_405 , -0 }, - {"440" , (PPC_OPCODE_PPC |PPC_OPCODE_BOOKE |PPC_OPCODE_440 - |PPC_OPCODE_ISEL |PPC_OPCODE_RFMCI ), -0 }, - {"464" , (PPC_OPCODE_PPC |PPC_OPCODE_BOOKE |PPC_OPCODE_440 - |PPC_OPCODE_ISEL |PPC_OPCODE_RFMCI ), -0 }, - {"476" , (PPC_OPCODE_PPC |PPC_OPCODE_ISEL |PPC_OPCODE_440 - |PPC_OPCODE_476 |PPC_OPCODE_POWER4 |PPC_OPCODE_POWER5 ), -0 }, - {"601" ,PPC_OPCODE_PPC |PPC_OPCODE_601 , -0 }, - {"603" ,PPC_OPCODE_PPC , -0 }, - {"604" ,PPC_OPCODE_PPC , -0 }, - {"620" ,PPC_OPCODE_PPC |PPC_OPCODE_64 , -0 }, - {"7400" ,PPC_OPCODE_PPC |PPC_OPCODE_ALTIVEC , -0 }, - {"7410" ,PPC_OPCODE_PPC |PPC_OPCODE_ALTIVEC , -0 }, - {"7450" ,PPC_OPCODE_PPC |PPC_OPCODE_7450 |PPC_OPCODE_ALTIVEC , -0 }, - {"7455" ,PPC_OPCODE_PPC |PPC_OPCODE_ALTIVEC , -0 }, - {"750cl" ,PPC_OPCODE_PPC |PPC_OPCODE_750 |PPC_OPCODE_PPCPS - ,0 }, - {"821" ,PPC_OPCODE_PPC |PPC_OPCODE_860 , -0 }, - {"850" ,PPC_OPCODE_PPC |PPC_OPCODE_860 , -0 }, - {"860" ,PPC_OPCODE_PPC |PPC_OPCODE_860 , -0 }, - {"a2" , (PPC_OPCODE_PPC |PPC_OPCODE_ISEL |PPC_OPCODE_POWER4 - |PPC_OPCODE_POWER5 |PPC_OPCODE_CACHELCK |PPC_OPCODE_64 - |PPC_OPCODE_A2 ), -0 }, - {"altivec" ,PPC_OPCODE_PPC , -PPC_OPCODE_ALTIVEC |PPC_OPCODE_ALTIVEC2 }, - {"any" ,0 , -PPC_OPCODE_ANY }, - {"booke" ,PPC_OPCODE_PPC |PPC_OPCODE_BOOKE , -0 }, - {"booke32" ,PPC_OPCODE_PPC |PPC_OPCODE_BOOKE , -0 }, - {"cell" , (PPC_OPCODE_PPC |PPC_OPCODE_64 |PPC_OPCODE_POWER4 - |PPC_OPCODE_CELL |PPC_OPCODE_ALTIVEC ), -0 }, - {"com" ,PPC_OPCODE_COMMON , -0 }, - {"e200z4" , (PPC_OPCODE_PPC |PPC_OPCODE_BOOKE |PPC_OPCODE_SPE - |PPC_OPCODE_ISEL |PPC_OPCODE_EFS |PPC_OPCODE_BRLOCK - |PPC_OPCODE_PMR |PPC_OPCODE_CACHELCK |PPC_OPCODE_RFMCI - |PPC_OPCODE_E500 |PPC_OPCODE_E200Z4 ), -PPC_OPCODE_VLE }, - {"e300" ,PPC_OPCODE_PPC |PPC_OPCODE_E300 , -0 }, - {"e500" , (PPC_OPCODE_PPC |PPC_OPCODE_BOOKE |PPC_OPCODE_SPE - |PPC_OPCODE_ISEL |PPC_OPCODE_EFS |PPC_OPCODE_BRLOCK - |PPC_OPCODE_PMR |PPC_OPCODE_CACHELCK |PPC_OPCODE_RFMCI - |PPC_OPCODE_E500 ), -0 }, - {"e500mc" , (PPC_OPCODE_PPC |PPC_OPCODE_BOOKE |PPC_OPCODE_ISEL - |PPC_OPCODE_PMR |PPC_OPCODE_CACHELCK |PPC_OPCODE_RFMCI - |PPC_OPCODE_E500MC ), -0 }, - {"e500mc64" , (PPC_OPCODE_PPC |PPC_OPCODE_BOOKE |PPC_OPCODE_ISEL - |PPC_OPCODE_PMR |PPC_OPCODE_CACHELCK |PPC_OPCODE_RFMCI - |PPC_OPCODE_E500MC |PPC_OPCODE_64 |PPC_OPCODE_POWER5 - |PPC_OPCODE_POWER6 |PPC_OPCODE_POWER7 ), -0 }, - {"e5500" , (PPC_OPCODE_PPC |PPC_OPCODE_BOOKE |PPC_OPCODE_ISEL - |PPC_OPCODE_PMR |PPC_OPCODE_CACHELCK |PPC_OPCODE_RFMCI - |PPC_OPCODE_E500MC |PPC_OPCODE_64 |PPC_OPCODE_POWER4 - |PPC_OPCODE_POWER5 |PPC_OPCODE_POWER6 - |PPC_OPCODE_POWER7 ), -0 }, - {"e6500" , (PPC_OPCODE_PPC |PPC_OPCODE_BOOKE |PPC_OPCODE_ISEL - |PPC_OPCODE_PMR |PPC_OPCODE_CACHELCK |PPC_OPCODE_RFMCI - |PPC_OPCODE_E500MC |PPC_OPCODE_64 |PPC_OPCODE_ALTIVEC - |PPC_OPCODE_ALTIVEC2 |PPC_OPCODE_E6500 |PPC_OPCODE_POWER4 - |PPC_OPCODE_POWER5 |PPC_OPCODE_POWER6 |PPC_OPCODE_POWER7 ), -0 }, - {"e500x2" , (PPC_OPCODE_PPC |PPC_OPCODE_BOOKE |PPC_OPCODE_SPE - |PPC_OPCODE_ISEL |PPC_OPCODE_EFS |PPC_OPCODE_BRLOCK - |PPC_OPCODE_PMR |PPC_OPCODE_CACHELCK |PPC_OPCODE_RFMCI - |PPC_OPCODE_E500 ), -0 }, - {"efs" ,PPC_OPCODE_PPC |PPC_OPCODE_EFS , -0 }, - {"power4" ,PPC_OPCODE_PPC |PPC_OPCODE_64 |PPC_OPCODE_POWER4 , -0 }, - {"power5" , (PPC_OPCODE_PPC |PPC_OPCODE_64 |PPC_OPCODE_POWER4 - |PPC_OPCODE_POWER5 ), -0 }, - {"power6" , (PPC_OPCODE_PPC |PPC_OPCODE_64 |PPC_OPCODE_POWER4 - |PPC_OPCODE_POWER5 |PPC_OPCODE_POWER6 |PPC_OPCODE_ALTIVEC ), -0 }, - {"power7" , (PPC_OPCODE_PPC |PPC_OPCODE_ISEL |PPC_OPCODE_64 - |PPC_OPCODE_POWER4 |PPC_OPCODE_POWER5 |PPC_OPCODE_POWER6 - |PPC_OPCODE_POWER7 |PPC_OPCODE_ALTIVEC |PPC_OPCODE_VSX ), -0 }, - {"power8" , (PPC_OPCODE_PPC |PPC_OPCODE_ISEL |PPC_OPCODE_64 - |PPC_OPCODE_POWER4 |PPC_OPCODE_POWER5 |PPC_OPCODE_POWER6 - |PPC_OPCODE_POWER7 |PPC_OPCODE_POWER8 |PPC_OPCODE_HTM - |PPC_OPCODE_ALTIVEC |PPC_OPCODE_ALTIVEC2 |PPC_OPCODE_VSX ), -0 }, - {"power9" , (PPC_OPCODE_PPC |PPC_OPCODE_ISEL |PPC_OPCODE_64 - |PPC_OPCODE_POWER4 |PPC_OPCODE_POWER5 |PPC_OPCODE_POWER6 - |PPC_OPCODE_POWER7 |PPC_OPCODE_POWER8 |PPC_OPCODE_POWER9 - |PPC_OPCODE_HTM |PPC_OPCODE_ALTIVEC |PPC_OPCODE_ALTIVEC2 - |PPC_OPCODE_VSX |PPC_OPCODE_VSX3 ), -0 }, - {"ppc" ,PPC_OPCODE_PPC , -0 }, - {"ppc32" ,PPC_OPCODE_PPC , -0 }, - {"ppc64" ,PPC_OPCODE_PPC |PPC_OPCODE_64 , -0 }, - {"ppc64bridge" ,PPC_OPCODE_PPC |PPC_OPCODE_64_BRIDGE , -0 }, - {"ppcps" ,PPC_OPCODE_PPC |PPC_OPCODE_PPCPS , -0 }, - {"pwr" ,PPC_OPCODE_POWER , -0 }, - {"pwr2" ,PPC_OPCODE_POWER |PPC_OPCODE_POWER2 , -0 }, - {"pwr4" ,PPC_OPCODE_PPC |PPC_OPCODE_64 |PPC_OPCODE_POWER4 , -0 }, - {"pwr5" , (PPC_OPCODE_PPC |PPC_OPCODE_64 |PPC_OPCODE_POWER4 - |PPC_OPCODE_POWER5 ), -0 }, - {"pwr5x" , (PPC_OPCODE_PPC |PPC_OPCODE_64 |PPC_OPCODE_POWER4 - |PPC_OPCODE_POWER5 ), -0 }, - {"pwr6" , (PPC_OPCODE_PPC |PPC_OPCODE_64 |PPC_OPCODE_POWER4 - |PPC_OPCODE_POWER5 |PPC_OPCODE_POWER6 |PPC_OPCODE_ALTIVEC ), -0 }, - {"pwr7" , (PPC_OPCODE_PPC |PPC_OPCODE_ISEL |PPC_OPCODE_64 - |PPC_OPCODE_POWER4 |PPC_OPCODE_POWER5 |PPC_OPCODE_POWER6 - |PPC_OPCODE_POWER7 |PPC_OPCODE_ALTIVEC |PPC_OPCODE_VSX ), -0 }, - {"pwr8" , (PPC_OPCODE_PPC |PPC_OPCODE_ISEL |PPC_OPCODE_64 - |PPC_OPCODE_POWER4 |PPC_OPCODE_POWER5 |PPC_OPCODE_POWER6 - |PPC_OPCODE_POWER7 |PPC_OPCODE_POWER8 |PPC_OPCODE_HTM - |PPC_OPCODE_ALTIVEC |PPC_OPCODE_ALTIVEC2 |PPC_OPCODE_VSX ), -0 }, - {"pwr9" , (PPC_OPCODE_PPC |PPC_OPCODE_ISEL |PPC_OPCODE_64 - |PPC_OPCODE_POWER4 |PPC_OPCODE_POWER5 |PPC_OPCODE_POWER6 - |PPC_OPCODE_POWER7 |PPC_OPCODE_POWER8 |PPC_OPCODE_POWER9 - |PPC_OPCODE_HTM |PPC_OPCODE_ALTIVEC |PPC_OPCODE_ALTIVEC2 - |PPC_OPCODE_VSX |PPC_OPCODE_VSX3 ), -0 }, - {"pwrx" ,PPC_OPCODE_POWER |PPC_OPCODE_POWER2 , -0 }, - {"spe" ,PPC_OPCODE_PPC |PPC_OPCODE_EFS , -PPC_OPCODE_SPE }, - {"titan" , (PPC_OPCODE_PPC |PPC_OPCODE_BOOKE |PPC_OPCODE_PMR - |PPC_OPCODE_RFMCI |PPC_OPCODE_TITAN ), -0 }, - {"vle" , (PPC_OPCODE_PPC |PPC_OPCODE_BOOKE |PPC_OPCODE_SPE - |PPC_OPCODE_ISEL |PPC_OPCODE_EFS |PPC_OPCODE_BRLOCK - |PPC_OPCODE_PMR |PPC_OPCODE_CACHELCK |PPC_OPCODE_RFMCI - |PPC_OPCODE_E500 ), -PPC_OPCODE_VLE }, - {"vsx" ,PPC_OPCODE_PPC , -PPC_OPCODE_VSX |PPC_OPCODE_VSX3 }, - {"htm" ,PPC_OPCODE_PPC , -PPC_OPCODE_HTM }, -}; - -/* Switch between Booke and VLE dialects for interlinked dumps. */ -static ppc_cpu_t -get_powerpc_dialect (struct disassemble_info *info) -{ -ppc_cpu_t dialect =0 ; - - dialect =POWERPC_DIALECT (info); - -/* Disassemble according to the section headers flags for VLE-mode. */ -if (dialect &PPC_OPCODE_VLE - && info->section->owner !=NULL - &&bfd_get_flavour (info->section->owner) == bfd_target_elf_flavour - &&elf_object_id (info->section->owner) ==PPC32_ELF_DATA - && (elf_section_flags (info->section) &SHF_PPC_VLE ) !=0 ) -return dialect; -else -return dialect & ~PPC_OPCODE_VLE ; -} - -/* Handle -m and -M options that set cpu type, and .machine arg. */ - -ppc_cpu_t -ppc_parse_cpu (ppc_cpu_t ppc_cpu,ppc_cpu_t *sticky,const char *arg) -{ -unsigned int i; - -for (i =0 ; i <sizeof (ppc_opts) /sizeof (ppc_opts[0 ]); i++) -if (strcmp (ppc_opts[i].opt, arg) ==0 ) - { -if (ppc_opts[i].sticky) - { - *sticky |= ppc_opts[i].sticky; -if ((ppc_cpu & ~*sticky) !=0 ) -break ; - } - ppc_cpu = ppc_opts[i].cpu; -break ; - } -if (i >=sizeof (ppc_opts) /sizeof (ppc_opts[0 ])) -return 0 ; - - ppc_cpu |= *sticky; -return ppc_cpu; -} - -/* Determine which set of machines to disassemble for. */ - -static void -powerpc_init_dialect (struct disassemble_info *info) -{ -ppc_cpu_t dialect =0 ; -ppc_cpu_t sticky =0 ; -char *arg; -struct dis_private *priv =calloc (sizeof (*priv),1 ); - -if (priv ==NULL ) - priv = &private; - -switch (info->mach) - { -case bfd_mach_ppc_403: -case bfd_mach_ppc_403gc: - dialect =ppc_parse_cpu (dialect, &sticky,"403" ); -break ; -case bfd_mach_ppc_405: - dialect =ppc_parse_cpu (dialect, &sticky,"405" ); -break ; -case bfd_mach_ppc_601: - dialect =ppc_parse_cpu (dialect, &sticky,"601" ); -break ; -case bfd_mach_ppc_a35: -case bfd_mach_ppc_rs64ii: -case bfd_mach_ppc_rs64iii: - dialect =ppc_parse_cpu (dialect, &sticky,"pwr2" ) |PPC_OPCODE_64 ; -break ; -case bfd_mach_ppc_e500: - dialect =ppc_parse_cpu (dialect, &sticky,"e500" ); -break ; -case bfd_mach_ppc_e500mc: - dialect =ppc_parse_cpu (dialect, &sticky,"e500mc" ); -break ; -case bfd_mach_ppc_e500mc64: - dialect =ppc_parse_cpu (dialect, &sticky,"e500mc64" ); -break ; -case bfd_mach_ppc_e5500: - dialect =ppc_parse_cpu (dialect, &sticky,"e5500" ); -break ; -case bfd_mach_ppc_e6500: - dialect =ppc_parse_cpu (dialect, &sticky,"e6500" ); -break ; -case bfd_mach_ppc_titan: - dialect =ppc_parse_cpu (dialect, &sticky,"titan" ); -break ; -case bfd_mach_ppc_vle: - dialect =ppc_parse_cpu (dialect, &sticky,"vle" ); -break ; -default : - dialect =ppc_parse_cpu (dialect, &sticky,"power9" ) |PPC_OPCODE_ANY ; - } - - arg = info->disassembler_options; -while (arg !=NULL ) - { -ppc_cpu_t new_cpu =0 ; -char *end =strchr (arg,',' ); - -if (end !=NULL ) - *end =0 ; - -if ((new_cpu =ppc_parse_cpu (dialect, &sticky, arg)) !=0 ) - dialect = new_cpu; -else if (strcmp (arg,"32" ) ==0 ) - dialect &= ~(ppc_cpu_t )PPC_OPCODE_64 ; -else if (strcmp (arg,"64" ) ==0 ) - dialect |=PPC_OPCODE_64 ; -else -fprintf (stderr,_ ("warning: ignoring unknown -M%s option\n" ), arg); - -if (end !=NULL ) - *end++ =',' ; - arg = end; - } - - info->private_data = priv; -POWERPC_DIALECT (info) = dialect; -} - -#define PPC_OPCD_SEGS 64 -static unsigned short powerpc_opcd_indices[PPC_OPCD_SEGS +1 ]; -#define VLE_OPCD_SEGS 32 -static unsigned short vle_opcd_indices[VLE_OPCD_SEGS +1 ]; - -/* Calculate opcode table indices to speed up disassembly, -and init dialect. */ - -void -disassemble_init_powerpc (struct disassemble_info *info) -{ -int i; -unsigned short last; - -if (powerpc_opcd_indices[PPC_OPCD_SEGS ] ==0 ) - { - - i = powerpc_num_opcodes; -while (--i >=0 ) - { -unsigned op =PPC_OP (powerpc_opcodes[i].opcode); - - powerpc_opcd_indices[op] = i; - } - - last = powerpc_num_opcodes; -for (i =PPC_OPCD_SEGS ; i >0 ; --i) - { -if (powerpc_opcd_indices[i] ==0 ) - powerpc_opcd_indices[i] = last; - last = powerpc_opcd_indices[i]; - } - - i = vle_num_opcodes; -while (--i >=0 ) - { -unsigned op =VLE_OP (vle_opcodes[i].opcode, vle_opcodes[i].mask); -unsigned seg =VLE_OP_TO_SEG (op); - - vle_opcd_indices[seg] = i; - } - - last = vle_num_opcodes; -for (i =VLE_OPCD_SEGS ; i >0 ; --i) - { -if (vle_opcd_indices[i] ==0 ) - vle_opcd_indices[i] = last; - last = vle_opcd_indices[i]; - } - } - -if (info->arch == bfd_arch_powerpc) -powerpc_init_dialect (info); -} - -/* Print a big endian PowerPC instruction. */ - -int -print_insn_big_powerpc (bfd_vma memaddr,struct disassemble_info *info) -{ -return print_insn_powerpc (memaddr, info,1 ,get_powerpc_dialect (info)); -} - -/* Print a little endian PowerPC instruction. */ - -int -print_insn_little_powerpc (bfd_vma memaddr,struct disassemble_info *info) -{ -return print_insn_powerpc (memaddr, info,0 ,get_powerpc_dialect (info)); -} - -/* Print a POWER (RS/6000) instruction. */ - -int -print_insn_rs6000 (bfd_vma memaddr,struct disassemble_info *info) -{ -return print_insn_powerpc (memaddr, info,1 ,PPC_OPCODE_POWER ); -}/* Extract the operand value from the PowerPC or POWER instruction. */
@@ -498,11 +98,9 @@ lookup_powerpc (unsigned long insn, ppc_cpu_t dialect)/* Get the major opcode of the instruction. */ op =PPC_OP (insn); + opcode_end = powerpc_opcodes + powerpc_num_opcodes;/* Find the first match in the opcode table for this major opcode. */ - opcode_end = powerpc_opcodes + powerpc_opcd_indices[op +1 ]; -for (opcode = powerpc_opcodes + powerpc_opcd_indices[op]; - opcode < opcode_end; - ++opcode) +for (opcode = powerpc_opcodes; opcode < opcode_end; ++opcode) {const unsigned char *opindex;const struct powerpc_operand *operand;
@@ -531,110 +129,45 @@ lookup_powerpc (unsigned long insn, ppc_cpu_t dialect)return NULL ; } -/* Find a match for INSN in the VLE opcode table. */ +/* Print a PowerPC or POWER instruction. */ -static const struct powerpc_opcode * -lookup_vle (unsigned long insn) +int print_insn_powerpc (unsigned long insn,unsigned long memaddr) {const struct powerpc_opcode *opcode; -const struct powerpc_opcode *opcode_end; -unsigned op, seg; - - op =PPC_OP (insn); -if (op >=0x20 && op <=0x37 ) - { -/* This insn has a 4-bit opcode. */ - op &=0x3c ; - } - seg =VLE_OP_TO_SEG (op); - -/* Find the first match in the opcode table for this major opcode. */ - opcode_end = vle_opcodes + vle_opcd_indices[seg +1 ]; -for (opcode = vle_opcodes + vle_opcd_indices[seg]; - opcode < opcode_end; - ++opcode) - { -unsigned long table_opcd = opcode->opcode; -unsigned long table_mask = opcode->mask; -bfd_boolean table_op_is_short =PPC_OP_SE_VLE (table_mask); -unsigned long insn2; -const unsigned char *opindex; -const struct powerpc_operand *operand; -int invalid; - - insn2 = insn; -if (table_op_is_short) - insn2 >>=16 ; -if ((insn2 & table_mask) != table_opcd) -continue ; +bool insn_is_short; +ppc_cpu_t dialect; -/* Check validity of operands. */ - invalid =0 ; -for (opindex = opcode->operands; *opindex !=0 ; ++opindex) - { - operand = powerpc_operands + *opindex; -if (operand->extract) - (*operand->extract) (insn, (ppc_cpu_t )0 , &invalid); - } -if (invalid) -continue ; + dialect =PPC_OPCODE_PPC |PPC_OPCODE_COMMON + |PPC_OPCODE_64 |PPC_OPCODE_POWER4 |PPC_OPCODE_ALTIVEC ; -return opcode; - } +if (cpu_has_feature (CPU_FTRS_POWER5 )) + dialect |=PPC_OPCODE_POWER5 ; -return NULL ; -} +if (cpu_has_feature (CPU_FTRS_CELL )) + dialect |= (PPC_OPCODE_CELL |PPC_OPCODE_ALTIVEC ); -/* Print a PowerPC or POWER instruction. */ +if (cpu_has_feature (CPU_FTRS_POWER6 )) + dialect |= (PPC_OPCODE_POWER5 |PPC_OPCODE_POWER6 |PPC_OPCODE_ALTIVEC ); -static int -print_insn_powerpc (bfd_vma memaddr, -struct disassemble_info *info, -int bigendian, -ppc_cpu_t dialect) -{ -bfd_byte buffer[4 ]; -int status; -unsigned long insn; -const struct powerpc_opcode *opcode; -bfd_boolean insn_is_short; +if (cpu_has_feature (CPU_FTRS_POWER7 )) + dialect |= (PPC_OPCODE_POWER5 |PPC_OPCODE_POWER6 |PPC_OPCODE_POWER7 + |PPC_OPCODE_ALTIVEC |PPC_OPCODE_VSX ); - status = (*info->read_memory_func) (memaddr, buffer,4 , info); -if (status !=0 ) - { -/* The final instruction may be a 2-byte VLE insn. */ -if ((dialect &PPC_OPCODE_VLE ) !=0 ) - { -/* Clear buffer so unused bytes will not have garbage in them. */ - buffer[0 ] = buffer[1 ] = buffer[2 ] = buffer[3 ] =0 ; - status = (*info->read_memory_func) (memaddr, buffer,2 , info); -if (status !=0 ) - { - (*info->memory_error_func) (status, memaddr, info); -return -1 ; - } - } -else - { - (*info->memory_error_func) (status, memaddr, info); -return -1 ; - } - } +if (cpu_has_feature (CPU_FTRS_POWER8 )) + dialect |= (PPC_OPCODE_POWER5 |PPC_OPCODE_POWER6 |PPC_OPCODE_POWER7 + |PPC_OPCODE_POWER8 |PPC_OPCODE_HTM + |PPC_OPCODE_ALTIVEC |PPC_OPCODE_ALTIVEC2 |PPC_OPCODE_VSX ); -if (bigendian) - insn =bfd_getb32 (buffer); -else - insn =bfd_getl32 (buffer); +if (cpu_has_feature (CPU_FTRS_POWER9 )) + dialect |= (PPC_OPCODE_POWER5 |PPC_OPCODE_POWER6 |PPC_OPCODE_POWER7 + |PPC_OPCODE_POWER8 |PPC_OPCODE_POWER9 |PPC_OPCODE_HTM + |PPC_OPCODE_ALTIVEC |PPC_OPCODE_ALTIVEC2 + |PPC_OPCODE_VSX |PPC_OPCODE_VSX3 ),/* Get the major opcode of the insn. */ opcode =NULL ; - insn_is_short = FALSE; -if ((dialect &PPC_OPCODE_VLE ) !=0 ) - { - opcode =lookup_vle (insn); -if (opcode !=NULL ) - insn_is_short =PPC_OP_SE_VLE (opcode->mask); - } + insn_is_short = false; +if (opcode ==NULL ) opcode =lookup_powerpc (insn, dialect);if (opcode ==NULL && (dialect &PPC_OPCODE_ANY ) !=0 )
@@ -649,9 +182,9 @@ print_insn_powerpc (bfd_vma memaddr,int skip_optional;if (opcode->operands[0 ] !=0 ) - (*info->fprintf_func) (info->stream,"%-7s " , opcode->name); +printf ("%-7s " , opcode->name);else - (*info->fprintf_func) (info->stream,"%s" , opcode->name); +printf ("%s" , opcode->name);if (insn_is_short)/* The operands will be fetched out of the 16-bit instruction. */
@@ -688,34 +221,34 @@ print_insn_powerpc (bfd_vma memaddr,if (need_comma) { - (*info->fprintf_func) (info->stream,"," ); +printf ("," ); need_comma =0 ; }/* Print the operand as directed by the flags. */ if ((operand->flags &PPC_OPERAND_GPR ) !=0 || ((operand->flags &PPC_OPERAND_GPR_0 ) !=0 && value !=0 )) - (*info->fprintf_func) (info->stream,"r%ld" , value); +printf ("r%ld" , value);else if ((operand->flags &PPC_OPERAND_FPR ) !=0 ) - (*info->fprintf_func) (info->stream,"f%ld" , value); +printf ("f%ld" , value);else if ((operand->flags &PPC_OPERAND_VR ) !=0 ) - (*info->fprintf_func) (info->stream,"v%ld" , value); +printf ("v%ld" , value);else if ((operand->flags &PPC_OPERAND_VSR ) !=0 ) - (*info->fprintf_func) (info->stream,"vs%ld" , value); +printf ("vs%ld" , value);else if ((operand->flags &PPC_OPERAND_RELATIVE ) !=0 ) - (*info->print_address_func) (memaddr + value, info); +print_address (memaddr + value);else if ((operand->flags &PPC_OPERAND_ABSOLUTE ) !=0 ) - (*info->print_address_func) ((bfd_vma ) value &0xffffffff , info); +print_address (value &0xffffffff );else if ((operand->flags &PPC_OPERAND_FSL ) !=0 ) - (*info->fprintf_func) (info->stream,"fsl%ld" , value); +printf ("fsl%ld" , value);else if ((operand->flags &PPC_OPERAND_FCR ) !=0 ) - (*info->fprintf_func) (info->stream,"fcr%ld" , value); +printf ("fcr%ld" , value);else if ((operand->flags &PPC_OPERAND_UDI ) !=0 ) - (*info->fprintf_func) (info->stream,"%ld" , value); +printf ("%ld" , value);else if ((operand->flags &PPC_OPERAND_CR_REG ) !=0 && (((dialect &PPC_OPCODE_PPC ) !=0 ) || ((dialect &PPC_OPCODE_VLE ) !=0 ))) - (*info->fprintf_func) (info->stream,"cr%ld" , value); +printf ("cr%ld" , value);else if (((operand->flags &PPC_OPERAND_CR_BIT ) !=0 ) && (((dialect &PPC_OPCODE_PPC ) !=0 ) || ((dialect &PPC_OPCODE_VLE ) !=0 )))
@@ -726,16 +259,16 @@ print_insn_powerpc (bfd_vma memaddr, cr = value >>2 ;if (cr !=0 ) - (*info->fprintf_func) (info->stream,"4*cr%d+" , cr); +printf ("4*cr%d+" , cr); cc = value &3 ; - (*info->fprintf_func) (info->stream,"%s" , cbnames[cc]); +printf ("%s" , cbnames[cc]); }else - (*info->fprintf_func) (info->stream,"%d" , (int ) value); +printf ("%d" , (int ) value);if (need_paren) { - (*info->fprintf_func) (info->stream,")" ); +printf (")" ); need_paren =0 ; }
@@ -743,7 +276,7 @@ print_insn_powerpc (bfd_vma memaddr, need_comma =1 ; else { - (*info->fprintf_func) (info->stream,"(" ); +printf ("(" ); need_paren =1 ; } }
@@ -761,28 +294,7 @@ print_insn_powerpc (bfd_vma memaddr, }/* We could not find a match. */ - (*info->fprintf_func) (info->stream,".long 0x%lx" , insn); +printf (".long 0x%lx" , insn);return 4 ; } - -void -print_ppc_disassembler_options (FILE *stream) -{ -unsigned int i, col; - -fprintf (stream,_ ("\n\ -The following PPC specific disassembler options are supported for use with\n\ -the -M switch:\n" )); - -for (col =0 , i =0 ; i <sizeof (ppc_opts) /sizeof (ppc_opts[0 ]); i++) - { - col +=fprintf (stream," %s," , ppc_opts[i].opt); -if (col >66 ) - { -fprintf (stream,"\n" ); - col =0 ; - } - } -fprintf (stream," 32, 64\n" ); -}
arch/powerpc/xmon/ppc-opc.c +8 -4
@@ -19,10 +19,14 @@Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ -#include "sysdep.h" -#include <stdio.h> -#include "opcode/ppc.h" -#include "opintl.h" +#include <linux/stddef.h> +#include <linux/kernel.h> +#include <linux/bug.h> +#include "nonstdio.h" +#include "ppc.h" + +#define ATTRIBUTE_UNUSED +#define _ (x) x/* This file holds the PowerPC opcode table. The opcode table includes almost all of the extended instruction mnemonics. This
arch/powerpc/xmon/ppc.h +0 -2
@@ -21,8 +21,6 @@ Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, US #ifndef PPC_H #define PPC_H -#include "bfd_stdint.h" - #ifdef __cplusplus extern "C" { #endif
Signature · 1 line
2.9.3
Quoted 3 lines
NOTE: This is an internal posting at the moment for review and criticism.
Clearly left over bits, please ignore
Balbir