This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH v2] NIOS2: Add wrprs instruction


Improved test case.  I manually verified the instruction values to match the
ones produced by the Altera binutils.

I do not have commit access.  If someone approves this patch, please
commit it also.

2013-03-09  Sebastian Huber <sebastian.huber@embedded-brains.de>

	* opcode/nios2.h (OPX_WRPRS): New define.
	(OP_MATCH_WRPRS): Likewise.

2013-03-09  Sebastian Huber <sebastian.huber@embedded-brains.de>

	* nios2-opc.c (nios2_builtin_opcodes): Add entry for wrprs.

2013-03-09  Sebastian Huber <sebastian.huber@embedded-brains.de>

	* config/tc-nios2.c (nios2_assemble_args_ds): New function.
	(nios2_arg_info_structs): Add "d,s" and "d,s,E" entries.

2013-03-09  Sebastian Huber <sebastian.huber@embedded-brains.de>

	* gas/nios2/nios2.exp: Run wrprs.
	* gas/nios2/wrprs.d: New file.
	* gas/nios2/wrprs.s: Likewise.
---
 gas/config/tc-nios2.c             |   24 ++++++++++++++++++++++++
 gas/testsuite/gas/nios2/nios2.exp |    1 +
 gas/testsuite/gas/nios2/wrprs.d   |   19 +++++++++++++++++++
 gas/testsuite/gas/nios2/wrprs.s   |   16 ++++++++++++++++
 include/opcode/nios2.h            |    2 ++
 opcodes/nios2-opc.c               |    2 ++
 6 files changed, 64 insertions(+)
 create mode 100644 gas/testsuite/gas/nios2/wrprs.d
 create mode 100644 gas/testsuite/gas/nios2/wrprs.s

diff --git a/gas/config/tc-nios2.c b/gas/config/tc-nios2.c
index 841c454..d669c60 100644
--- a/gas/config/tc-nios2.c
+++ b/gas/config/tc-nios2.c
@@ -1694,6 +1694,28 @@ nios2_assemble_args_cs (nios2_insn_infoS *insn_info)
 }
 
 static void
+nios2_assemble_args_ds (nios2_insn_infoS * insn_info)
+{
+  if (insn_info->insn_tokens[1] != NULL && insn_info->insn_tokens[2] != NULL)
+    {
+      struct nios2_reg *dst = nios2_reg_lookup (insn_info->insn_tokens[1]);
+      struct nios2_reg *src = nios2_reg_lookup (insn_info->insn_tokens[2]);
+
+      if (dst == NULL)
+	as_bad (_("unknown register %s"), insn_info->insn_tokens[1]);
+      else
+	SET_INSN_FIELD (RRD, insn_info->insn_code, dst->index);
+
+      if (src == NULL)
+	as_bad (_("unknown register %s"), insn_info->insn_tokens[2]);
+      else
+	SET_INSN_FIELD (RRS, insn_info->insn_code, src->index);
+
+      nios2_check_assembly (insn_info->insn_code, insn_info->insn_tokens[3]);
+    }
+}
+
+static void
 nios2_assemble_args_ldst (nios2_insn_infoS *insn_info)
 {
   if (insn_info->insn_tokens[1] != NULL
@@ -1850,6 +1872,8 @@ const nios2_arg_infoS nios2_arg_info_structs[] = {
   {"d,c,E", nios2_assemble_args_dc},
   {"c,s", nios2_assemble_args_cs},
   {"c,s,E", nios2_assemble_args_cs},
+  {"d,s", nios2_assemble_args_ds},
+  {"d,s,E", nios2_assemble_args_ds},
   {"l,d,s,t", nios2_assemble_args_ldst},
   {"l,d,s,t,E", nios2_assemble_args_ldst},
   {"d,s,j", nios2_assemble_args_dsj},
diff --git a/gas/testsuite/gas/nios2/nios2.exp b/gas/testsuite/gas/nios2/nios2.exp
index 173db00..af22bf8 100644
--- a/gas/testsuite/gas/nios2/nios2.exp
+++ b/gas/testsuite/gas/nios2/nios2.exp
@@ -54,6 +54,7 @@ if { [istarget nios2-*-*] } then {
     run_dump_test "rotate"
     run_dump_test "registers"
     run_dump_test "rdprs"
+    run_dump_test "wrprs"
     
     run_dump_test "stw"
     run_dump_test "sth"
diff --git a/gas/testsuite/gas/nios2/wrprs.d b/gas/testsuite/gas/nios2/wrprs.d
new file mode 100644
index 0000000..2e6de57
--- /dev/null
+++ b/gas/testsuite/gas/nios2/wrprs.d
@@ -0,0 +1,19 @@
+#objdump: -dr --prefix-addresses --show-raw-insn
+#name: NIOS2 wrprs
+
+# Test the wrprs instruction
+
+.*: +file format elf32-littlenios2
+
+Disassembly of section .text:
+0+0000 <[^>]*> 0000a03a 	wrprs	zero,zero
+0+0004 <[^>]*> 0002a03a 	wrprs	at,zero
+0+0008 <[^>]*> 0004a03a 	wrprs	r2,zero
+0+000c <[^>]*> 0008a03a 	wrprs	r4,zero
+0+0010 <[^>]*> 0010a03a 	wrprs	r8,zero
+0+0014 <[^>]*> 0020a03a 	wrprs	r16,zero
+0+0018 <[^>]*> 0800a03a 	wrprs	zero,at
+0+001c <[^>]*> 1000a03a 	wrprs	zero,r2
+0+0020 <[^>]*> 2000a03a 	wrprs	zero,r4
+0+0024 <[^>]*> 4000a03a 	wrprs	zero,r8
+0+0028 <[^>]*> 8000a03a 	wrprs	zero,r16
diff --git a/gas/testsuite/gas/nios2/wrprs.s b/gas/testsuite/gas/nios2/wrprs.s
new file mode 100644
index 0000000..c722ce5
--- /dev/null
+++ b/gas/testsuite/gas/nios2/wrprs.s
@@ -0,0 +1,16 @@
+# Source file used to test the wrprs instruction
+
+.set noat
+
+foo:
+	wrprs zero, zero
+	wrprs at, zero
+	wrprs r2, zero
+	wrprs r4, zero
+	wrprs r8, zero
+	wrprs r16, zero
+	wrprs zero, at
+	wrprs zero, r2
+	wrprs zero, r4
+	wrprs zero, r8
+	wrprs zero, r16
diff --git a/include/opcode/nios2.h b/include/opcode/nios2.h
index 83773d5..3405f55 100644
--- a/include/opcode/nios2.h
+++ b/include/opcode/nios2.h
@@ -344,6 +344,7 @@ struct nios2_reg
 #define OPX_SYNC 54
 #define OPX_TRAP 45
 #define OPX_WRCTL 46
+#define OPX_WRPRS 20
 #define OPX_XOR 30
 
 /* The following macros define the opcode matches for each
@@ -440,6 +441,7 @@ struct nios2_reg
 #define OP_MATCH_TRAP		((0x1d << 17) | OPX_MATCH (OPX_TRAP))
 #define OP_MATCH_ERET		(0xe8000000 | OPX_MATCH (OPX_ERET))
 #define OP_MATCH_WRCTL		OPX_MATCH (OPX_WRCTL)
+#define OP_MATCH_WRPRS		OPX_MATCH (OPX_WRPRS)
 #define OP_MATCH_XOR		OPX_MATCH (OPX_XOR)
 #define OP_MATCH_FLUSHI		OPX_MATCH (OPX_FLUSHI)
 #define OP_MATCH_FLUSHP		OPX_MATCH (OPX_FLUSHP)
diff --git a/opcodes/nios2-opc.c b/opcodes/nios2-opc.c
index 9617d47..41903d0 100644
--- a/opcodes/nios2-opc.c
+++ b/opcodes/nios2-opc.c
@@ -393,6 +393,8 @@ const struct nios2_opcode nios2_builtin_opcodes[] =
    OP_MATCH_CUSTOM, OP_MASK_ROP, 0, custom_opcode_overflow},
   {"wrctl", "c,s", "c,s,E", 2,
    OP_MATCH_WRCTL, OP_MASK_WRCTL, 0, no_overflow},
+  {"wrprs", "d,s", "d,s,E", 2,
+   OP_MATCH_WRPRS, OP_MASK_RRT|OP_MASK_ROPX|OP_MASK_ROP, 0, no_overflow},
   {"xor", "d,s,t", "d,s,t,E", 3,
    OP_MATCH_XOR, OP_MASK_ROPX | OP_MASK_ROP, 0, no_overflow},
   {"xorhi", "t,s,u", "t,s,u,E", 3,
-- 
1.7.10.4


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]