Skip to content

Commit

Permalink
Add support for the MIPS eXtended Physical Address (XPA) ASE.
Browse files Browse the repository at this point in the history
ChangeLog:

binutils/
	* doc/binutils.texi: Document the disassemble MIPS XPA instructions
	command line option.

gas/
	* config/tc-mips.c (options): Add OPTION_XPA and OPTION_NO_XPA.
 	(md_longopts): Add xpa and no-xpa command line options.
 	(mips_ases): Add MIPS XPA ASE.
 	(mips_cpu_info_table): Update p5600 entry to allow the XPA ASE.
 	* doc/as.texinfo: Document the MIPS XPA command line options.
 	* doc/c-mips.texi: Document the MIPS XPA command line options,
 	and assembler directives.

gas/testsuite/
 	* gas/mips/mips.exp: Add xpa tests.
 	* gas/mips/xpa.s: New test.
 	* gas/mips/xpa.d: Likewise.

include/
 	* opcode/mips.h (ASE_XPA): New define.

opcodes/
 	* mips-dis.c (mips_arch_choices): Update mips32r2 and mips64r2
 	to allow the MIPS XPA ASE.
 	(parse_mips_dis_option): Process the -Mxpa option.
 	* mips-opc.c (XPA): New define.
 	(mips_builtin_opcodes): Add MIPS XPA instructions and move the
 	locations of the ctc0 and cfc0 instructions.
  • Loading branch information
andrewb-IMG committed Apr 23, 2014
1 parent cd0449a commit 7d64c58
Show file tree
Hide file tree
Showing 15 changed files with 158 additions and 6 deletions.
5 changes: 5 additions & 0 deletions binutils/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2014-04-23 Andrew Bennett <andrew.bennett@imgtec.com>

* doc/binutils.texi: Document the disassemble MIPS XPA instructions
command line option.

2014-04-22 Christian Svensson <blue@cmd.nu>

* readelf.c: Remove openrisc and or32 support. Add support for or1k.
Expand Down
3 changes: 3 additions & 0 deletions binutils/doc/binutils.texi
Original file line number Diff line number Diff line change
Expand Up @@ -2132,6 +2132,9 @@ Disassemble MSA instructions.
@item virt
Disassemble the virtualization ASE instructions.

@item xpa
Disassemble the eXtended Physical Address (XPA) ASE instructions.

@item gpr-names=@var{ABI}
Print GPR (general-purpose register) names as appropriate
for the specified ABI. By default, GPR names are selected according to
Expand Down
10 changes: 10 additions & 0 deletions gas/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
2014-04-23 Andrew Bennett <andrew.bennett@imgtec.com>

* config/tc-mips.c (options): Add OPTION_XPA and OPTION_NO_XPA.
(md_longopts): Add xpa and no-xpa command line options.
(mips_ases): Add MIPS XPA ASE.
(mips_cpu_info_table): Update p5600 entry to allow the XPA ASE.
* doc/as.texinfo: Document the MIPS XPA command line options.
* doc/c-mips.texi: Document the MIPS XPA command line options,
and assembler directives.

2014-04-22 Sandra Loosemore <sandra@codesourcery.com>

* config/tc-nios2.c (nios2_consume_arg): Add case for 'E' to
Expand Down
15 changes: 13 additions & 2 deletions gas/config/tc-mips.c
Original file line number Diff line number Diff line change
Expand Up @@ -1338,6 +1338,8 @@ enum options
OPTION_NO_DSPR2,
OPTION_EVA,
OPTION_NO_EVA,
OPTION_XPA,
OPTION_NO_XPA,
OPTION_MICROMIPS,
OPTION_NO_MICROMIPS,
OPTION_MCU,
Expand Down Expand Up @@ -1447,6 +1449,8 @@ struct option md_longopts[] =
{"mno-virt", no_argument, NULL, OPTION_NO_VIRT},
{"mmsa", no_argument, NULL, OPTION_MSA},
{"mno-msa", no_argument, NULL, OPTION_NO_MSA},
{"mxpa", no_argument, NULL, OPTION_XPA},
{"mno-xpa", no_argument, NULL, OPTION_NO_XPA},

/* Old-style architecture options. Don't add more of these. */
{"m4650", no_argument, NULL, OPTION_M4650},
Expand Down Expand Up @@ -1599,7 +1603,11 @@ static const struct mips_ase mips_ases[] = {

{ "msa", ASE_MSA, ASE_MSA64,
OPTION_MSA, OPTION_NO_MSA,
2, 2, 2, 2 }
2, 2, 2, 2 },

{ "xpa", ASE_XPA, 0,
OPTION_XPA, OPTION_NO_XPA,
2, 2, -1, -1 }
};

/* The set of ASEs that require -mfp64. */
Expand Down Expand Up @@ -17903,7 +17911,7 @@ static const struct mips_cpu_info mips_cpu_info_table[] =
{ "1004kf", 0, ASE_DSP | ASE_MT, ISA_MIPS32R2, CPU_MIPS32R2 },
{ "1004kf1_1", 0, ASE_DSP | ASE_MT, ISA_MIPS32R2, CPU_MIPS32R2 },
/* P5600 with EVA and Virtualization ASEs, other ASEs are optional. */
{ "p5600", 0, ASE_VIRT | ASE_EVA, ISA_MIPS32R2, CPU_MIPS32R2 },
{ "p5600", 0, ASE_VIRT | ASE_EVA | ASE_XPA, ISA_MIPS32R2, CPU_MIPS32R2 },

/* MIPS 64 */
{ "5kc", 0, 0, ISA_MIPS64, CPU_MIPS64 },
Expand Down Expand Up @@ -18161,6 +18169,9 @@ MIPS options:\n\
-mmsa generate MSA instructions\n\
-mno-msa do not generate MSA instructions\n"));
fprintf (stream, _("\
-mxpa generate eXtended Physical Address (XPA) instructions\n\
-mno-xpa do not generate eXtended Physical Address (XPA) instructions\n"));
fprintf (stream, _("\
-mvirt generate Virtualization instructions\n\
-mno-virt do not generate Virtualization instructions\n"));
fprintf (stream, _("\
Expand Down
7 changes: 7 additions & 0 deletions gas/doc/as.texinfo
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,7 @@ gcc(1), ld(1), and the Info entries for @file{binutils} and @file{ld}.
[@b{-mdsp}] [@b{-mno-dsp}]
[@b{-mdspr2}] [@b{-mno-dspr2}]
[@b{-mmsa}] [@b{-mno-msa}]
[@b{-mxpa}] [@b{-mno-xpa}]
[@b{-mmt}] [@b{-mno-mt}]
[@b{-mmcu}] [@b{-mno-mcu}]
[@b{-minsn32}] [@b{-mno-insn32}]
Expand Down Expand Up @@ -1357,6 +1358,12 @@ Generate code for the MIPS SIMD Architecture Extension.
This tells the assembler to accept MSA instructions.
@samp{-mno-msa} turns off this option.

@item -mxpa
@itemx -mno-xpa
Generate code for the MIPS eXtended Physical Address (XPA) Extension.
This tells the assembler to accept XPA instructions.
@samp{-mno-xpa} turns off this option.

@item -mmt
@itemx -mno-mt
Generate code for the MT Application Specific Extension.
Expand Down
13 changes: 13 additions & 0 deletions gas/doc/c-mips.texi
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,12 @@ Generate code for the MIPS SIMD Architecture Extension.
This tells the assembler to accept MSA instructions.
@samp{-mno-msa} turns off this option.

@item -mxpa
@itemx -mno-xpa
Generate code for the MIPS eXtended Physical Address (XPA) Extension.
This tells the assembler to accept XPA instructions.
@samp{-mno-xpa} turns off this option.

@item -mvirt
@itemx -mno-virt
Generate code for the Virtualization Application Specific Extension.
Expand Down Expand Up @@ -879,6 +885,13 @@ from the Virtualization Application Specific Extension from that point
on in the assembly. The @code{.set novirt} directive prevents Virtualization
instructions from being accepted.

@cindex MIPS eXtended Physical Address (XPA) instruction generation override
@kindex @code{.set xpa}
@kindex @code{.set noxpa}
The directive @code{.set xpa} makes the assembler accept instructions
from the XPA Extension from that point on in the assembly. The
@code{.set noxpa} directive prevents XPA instructions from being accepted.

Traditional MIPS assemblers do not support these directives.

@node MIPS Floating-Point
Expand Down
6 changes: 6 additions & 0 deletions gas/testsuite/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
2014-04-23 Andrew Bennett <andrew.bennett@imgtec.com>

* gas/mips/mips.exp: Add xpa tests.
* gas/mips/xpa.s: New test.
* gas/mips/xpa.d: Likewise.

2014-04-22 Sandra Loosemore <sandra@codesourcery.com>

* gas/nios2/selftest.s: New.
Expand Down
2 changes: 2 additions & 0 deletions gas/testsuite/gas/mips/mips.exp
Original file line number Diff line number Diff line change
Expand Up @@ -1170,6 +1170,8 @@ if { [istarget mips*-*-vxworks*] } {
run_dump_test_arches "msa-relax" [mips_arch_list_matching mips32r2]
run_dump_test_arches "msa-branch" [mips_arch_list_matching mips32r2]

run_dump_test_arches "xpa" [mips_arch_list_matching mips32r2 !micromips]

run_dump_test "pcrel-1"
run_dump_test "pcrel-2"
run_list_test "pcrel-3" "" "Invalid cross-section PC-relative references"
Expand Down
24 changes: 24 additions & 0 deletions gas/testsuite/gas/mips/xpa.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#objdump: -dr --prefix-addresses --show-raw-insn -Mxpa,cp0-names=mips32r2
#name: XPA instructions
#as: -32 -mxpa

.*: +file format .*mips.*

Disassembly of section \.text:
[0-9a-f]+ <[^>]*> 40420800 mfhc0 v0,c0_random
[0-9a-f]+ <[^>]*> 40428000 mfhc0 v0,c0_config
[0-9a-f]+ <[^>]*> 40420002 mfhc0 v0,c0_mvpconf0
[0-9a-f]+ <[^>]*> 40420007 mfhc0 v0,\$0,7
[0-9a-f]+ <[^>]*> 40c20800 mthc0 v0,c0_random
[0-9a-f]+ <[^>]*> 40c28000 mthc0 v0,c0_config
[0-9a-f]+ <[^>]*> 40c20002 mthc0 v0,c0_mvpconf0
[0-9a-f]+ <[^>]*> 40c20007 mthc0 v0,\$0,7
[0-9a-f]+ <[^>]*> 40620c00 mfhgc0 v0,c0_random
[0-9a-f]+ <[^>]*> 40628400 mfhgc0 v0,c0_config
[0-9a-f]+ <[^>]*> 40620402 mfhgc0 v0,c0_mvpconf0
[0-9a-f]+ <[^>]*> 40620407 mfhgc0 v0,\$0,7
[0-9a-f]+ <[^>]*> 40620e00 mthgc0 v0,c0_random
[0-9a-f]+ <[^>]*> 40628600 mthgc0 v0,c0_config
[0-9a-f]+ <[^>]*> 40620602 mthgc0 v0,c0_mvpconf0
[0-9a-f]+ <[^>]*> 40620607 mthgc0 v0,\$0,7
...
29 changes: 29 additions & 0 deletions gas/testsuite/gas/mips/xpa.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
.text
.set noat
.set noreorder
.set nomacro
test_xpa:

mfhc0 $2, $1
mfhc0 $2, $16
mfhc0 $2, $0, 2
mfhc0 $2, $0, 7

mthc0 $2, $1
mthc0 $2, $16
mthc0 $2, $0, 2
mthc0 $2, $0, 7

mfhgc0 $2, $1
mfhgc0 $2, $16
mfhgc0 $2, $0, 2
mfhgc0 $2, $0, 7

mthgc0 $2, $1
mthgc0 $2, $16
mthgc0 $2, $0, 2
mthgc0 $2, $0, 7

# Force at least 8 (non-delay-slot) zero bytes, to make 'objdump' print ...
.align 2
.space 8
4 changes: 4 additions & 0 deletions include/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
2014-04-23 Andrew Bennett <andrew.bennett@imgtec.com>

* opcode/mips.h (ASE_XPA): New define.

2014-04-22 Christian Svensson <blue@cmd.nu>

* dis-asm.h: Remove openrisc and or32 support. Add support for or1k.
Expand Down
2 changes: 2 additions & 0 deletions include/opcode/mips.h
Original file line number Diff line number Diff line change
Expand Up @@ -1155,6 +1155,8 @@ static const unsigned int mips_isa_table[] =
/* MSA Extension */
#define ASE_MSA 0x00000800
#define ASE_MSA64 0x00001000
/* eXtended Physical Address (XPA) Extension. */
#define ASE_XPA 0x00002000

/* MIPS ISA defines, use instead of hardcoding ISA level. */

Expand Down
9 changes: 9 additions & 0 deletions opcodes/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
2014-04-23 Andrew Bennett <andrew.bennett@imgtec.com>

* mips-dis.c (mips_arch_choices): Update mips32r2 and mips64r2
to allow the MIPS XPA ASE.
(parse_mips_dis_option): Process the -Mxpa option.
* mips-opc.c (XPA): New define.
(mips_builtin_opcodes): Add MIPS XPA instructions and move the
locations of the ctc0 and cfc0 instructions.

2014-04-22 Christian Svensson <blue@cmd.nu>

* Makefile.am: Remove openrisc and or32 support. Add support for or1k.
Expand Down
14 changes: 12 additions & 2 deletions opcodes/mips-dis.c
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ const struct mips_arch_choice mips_arch_choices[] =
{ "mips32r2", 1, bfd_mach_mipsisa32r2, CPU_MIPS32R2,
ISA_MIPS32R2,
(ASE_SMARTMIPS | ASE_DSP | ASE_DSPR2 | ASE_EVA | ASE_MIPS3D
| ASE_MT | ASE_MCU | ASE_VIRT | ASE_MSA),
| ASE_MT | ASE_MCU | ASE_VIRT | ASE_MSA | ASE_XPA),
mips_cp0_names_mips3264r2,
mips_cp0sel_names_mips3264r2, ARRAY_SIZE (mips_cp0sel_names_mips3264r2),
mips_cp1_names_mips3264, mips_hwr_names_mips3264r2 },
Expand All @@ -566,7 +566,7 @@ const struct mips_arch_choice mips_arch_choices[] =
{ "mips64r2", 1, bfd_mach_mipsisa64r2, CPU_MIPS64R2,
ISA_MIPS64R2,
(ASE_MIPS3D | ASE_DSP | ASE_DSPR2 | ASE_DSP64 | ASE_EVA | ASE_MT
| ASE_MCU | ASE_VIRT | ASE_VIRT64 | ASE_MSA | ASE_MSA64),
| ASE_MCU | ASE_VIRT | ASE_VIRT64 | ASE_MSA | ASE_MSA64 | ASE_XPA),
mips_cp0_names_mips3264r2,
mips_cp0sel_names_mips3264r2, ARRAY_SIZE (mips_cp0sel_names_mips3264r2),
mips_cp1_names_mips3264, mips_hwr_names_mips3264r2 },
Expand Down Expand Up @@ -810,6 +810,13 @@ parse_mips_dis_option (const char *option, unsigned int len)
mips_ase |= ASE_VIRT64;
return;
}

if (CONST_STRNEQ (option, "xpa"))
{
mips_ase |= ASE_XPA;
return;
}


/* Look for the = that delimits the end of the option name. */
for (i = 0; i < len; i++)
Expand Down Expand Up @@ -2195,6 +2202,9 @@ with the -M switch (multiple options should be separated by commas):\n"));
fprintf (stream, _("\n\
virt Recognize the virtualization ASE instructions.\n"));

fprintf (stream, _("\n\
xpa Recognize the eXtended Physical Address (XPA) ASE instructions.\n"));

fprintf (stream, _("\n\
gpr-names=ABI Print GPR names according to specified ABI.\n\
Default: based on binary being disassembled.\n"));
Expand Down
21 changes: 19 additions & 2 deletions opcodes/mips-opc.c
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,9 @@ decode_mips_operand (const char *p)
#define MSA ASE_MSA
#define MSA64 ASE_MSA64

/* eXtended Physical Address (XPA) support. */
#define XPA ASE_XPA

/* The order of overloaded instructions matters. Label arguments and
register arguments look the same. Instructions that can have either
for arguments must apear in the correct order in this table for the
Expand Down Expand Up @@ -895,7 +898,7 @@ const struct mips_opcode mips_builtin_opcodes[] =
{"ceil.l.s", "D,S", 0x4600000a, 0xffff003f, WR_1|RD_2|FP_S|FP_D, 0, I3_33, 0, 0 },
{"ceil.w.d", "D,S", 0x4620000e, 0xffff003f, WR_1|RD_2|FP_S|FP_D, 0, I2, 0, SF },
{"ceil.w.s", "D,S", 0x4600000e, 0xffff003f, WR_1|RD_2|FP_S, 0, I2, 0, EE },
{"cfc0", "t,G", 0x40400000, 0xffe007ff, WR_1|RD_C0|LCD, 0, I1, 0, IOCT|IOCTP|IOCT2 },
/* cfc0 is at the bottom of the table. */
{"cfc1", "t,G", 0x44400000, 0xffe007ff, WR_1|RD_C1|LCD|FP_S, 0, I1, 0, 0 },
{"cfc1", "t,S", 0x44400000, 0xffe007ff, WR_1|RD_C1|LCD|FP_S, 0, I1, 0, 0 },
/* cfc2 is at the bottom of the table. */
Expand All @@ -908,7 +911,7 @@ const struct mips_opcode mips_builtin_opcodes[] =
{"cins", "t,r,+p,+S", 0x70000032, 0xfc00003f, WR_1|RD_2, 0, IOCT, 0, 0 },
{"clo", "U,s", 0x70000021, 0xfc0007ff, WR_1|RD_2, 0, I32|N55, 0, 0 },
{"clz", "U,s", 0x70000020, 0xfc0007ff, WR_1|RD_2, 0, I32|N55, 0, 0 },
{"ctc0", "t,G", 0x40c00000, 0xffe007ff, RD_1|WR_CC|COD, 0, I1, 0, IOCT|IOCTP|IOCT2 },
/* ctc0 is at the bottom of the table. */
{"ctc1", "t,G", 0x44c00000, 0xffe007ff, RD_1|WR_CC|COD|FP_S, 0, I1, 0, 0 },
{"ctc1", "t,S", 0x44c00000, 0xffe007ff, RD_1|WR_CC|COD|FP_S, 0, I1, 0, 0 },
/* ctc2 is at the bottom of the table. */
Expand Down Expand Up @@ -1300,6 +1303,10 @@ const struct mips_opcode mips_builtin_opcodes[] =
{"mfc0", "t,G,H", 0x40000000, 0xffe007f8, WR_1|RD_C0|LCD, 0, I32, 0, 0 },
{"mfgc0", "t,G", 0x40600000, 0xffe007ff, WR_1|RD_C0|LCD, 0, 0, IVIRT, 0 },
{"mfgc0", "t,G,H", 0x40600000, 0xffe007f8, WR_1|RD_C0|LCD, 0, 0, IVIRT, 0 },
{"mfhc0", "t,G", 0x40400000, 0xffe007ff, WR_1|RD_C0|LCD, 0, I33, XPA, 0 },
{"mfhc0", "t,G,H", 0x40400000, 0xffe007f8, WR_1|RD_C0|LCD, 0, I33, XPA, 0 },
{"mfhgc0", "t,G", 0x40600400, 0xffe007ff, WR_1|RD_C0|LCD, 0, I33, IVIRT|XPA, 0 },
{"mfhgc0", "t,G,H", 0x40600400, 0xffe007f8, WR_1|RD_C0|LCD, 0, I33, IVIRT|XPA, 0 },
{"mfc1", "t,S", 0x44000000, 0xffe007ff, WR_1|RD_2|LCD|FP_S, 0, I1, 0, 0 },
{"mfc1", "t,G", 0x44000000, 0xffe007ff, WR_1|RD_2|LCD|FP_S, 0, I1, 0, 0 },
{"mfhc1", "t,S", 0x44600000, 0xffe007ff, WR_1|RD_2|LCD|FP_D, 0, I33, 0, 0 },
Expand Down Expand Up @@ -1393,6 +1400,10 @@ const struct mips_opcode mips_builtin_opcodes[] =
{"mtc0", "t,G,H", 0x40800000, 0xffe007f8, RD_1|WR_C0|WR_CC|COD, 0, I32, 0, 0 },
{"mtgc0", "t,G", 0x40600200, 0xffe007ff, RD_1|WR_C0|WR_CC|COD, 0, 0, IVIRT, 0 },
{"mtgc0", "t,G,H", 0x40600200, 0xffe007f8, RD_1|WR_C0|WR_CC|COD, 0, 0, IVIRT, 0 },
{"mthc0", "t,G", 0x40c00000, 0xffe007ff, RD_1|WR_C0|WR_CC|COD, 0, I33, XPA, 0 },
{"mthc0", "t,G,H", 0x40c00000, 0xffe007f8, RD_1|WR_C0|WR_CC|COD, 0, I33, XPA, 0 },
{"mthgc0", "t,G", 0x40600600, 0xffe007ff, RD_1|WR_C0|WR_CC|COD, 0, I33, IVIRT|XPA, 0 },
{"mthgc0", "t,G,H", 0x40600600, 0xffe007f8, RD_1|WR_C0|WR_CC|COD, 0, I33, IVIRT|XPA, 0 },
{"mtc1", "t,S", 0x44800000, 0xffe007ff, RD_1|WR_2|COD|FP_S, 0, I1, 0, 0 },
{"mtc1", "t,G", 0x44800000, 0xffe007ff, RD_1|WR_2|COD|FP_S, 0, I1, 0, 0 },
{"mthc1", "t,S", 0x44e00000, 0xffe007ff, RD_1|WR_2|COD|FP_D, 0, I33, 0, 0 },
Expand Down Expand Up @@ -1954,6 +1965,12 @@ const struct mips_opcode mips_builtin_opcodes[] =
{"zcb", "(b)", 0x7000071f, 0xfc1fffff, RD_1|SM, 0, IOCT2, 0, 0 },
{"zcbt", "(b)", 0x7000075f, 0xfc1fffff, RD_1|SM, 0, IOCT2, 0, 0 },

/* Coprocessor 0 move instructions cfc0 and ctc0 conflict with the
mfhc0 and mthc0 XPA instructions, so they have been placed here
to allow the XPA instructions to take precedence. */
{"ctc0", "t,G", 0x40c00000, 0xffe007ff, RD_1|WR_CC|COD, 0, I1, 0, IOCT|IOCTP|IOCT2 },
{"cfc0", "t,G", 0x40400000, 0xffe007ff, WR_1|RD_C0|LCD, 0, I1, 0, IOCT|IOCTP|IOCT2 },

/* Coprocessor 2 move/branch operations overlap with VR5400 .ob format
instructions so they are here for the latters to take precedence. */
{"bc2f", "p", 0x49000000, 0xffff0000, RD_CC|CBD, 0, I1, 0, IOCT|IOCTP|IOCT2 },
Expand Down

0 comments on commit 7d64c58

Please sign in to comment.