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, nios2] support optional argument to trap instruction


I've checked in this patch to make the assembler know about the optional argument to the "trap" instruction. It is exactly like the optional argument to "break", which is already handled; it was just an oversight that "trap" didn't DTRT.

Giving credit where credit is due, this patch was suggested by Jeff Prothero of Altera.

-Sandra


2013-06-09  Sandra Loosemore  <sandra@codesourcery.com>

	opcodes/
	* nios2-opc.c (nios2_builtin_opcodes): Give "trap" a type-"b"
	argument.

	gas/
	* config/tc-nios2.c (nios2_parse_args):  Allow trap argument to
	omitted.

	gas/testsuite/
	* gas/nios2/trap.s: Add additional test cases for optional
	argument.
	* gas/nios2/trap.d: Likewise.
Index: opcodes/nios2-opc.c
===================================================================
RCS file: /cvs/src/src/opcodes/nios2-opc.c,v
retrieving revision 1.5
diff -u -p -r1.5 nios2-opc.c
--- opcodes/nios2-opc.c	24 Apr 2013 20:51:58 -0000	1.5
+++ opcodes/nios2-opc.c	9 Jun 2013 22:36:39 -0000
@@ -385,7 +385,7 @@ const struct nios2_opcode nios2_builtin_
    OP_MATCH_SUB, OP_MASK_ROPX | OP_MASK_ROP, 0, no_overflow},
   {"sync", "", "E", 0,
    OP_MATCH_SYNC, OP_MASK_SYNC, 0, no_overflow},
-  {"trap", "", "E", 0,
+  {"trap", "b", "b,E", 1,
    OP_MATCH_TRAP, OP_MASK_TRAP, 0, no_overflow},
   {"eret", "", "E", 0,
    OP_MATCH_ERET, OP_MASK, 0, no_overflow},
Index: gas/config/tc-nios2.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-nios2.c,v
retrieving revision 1.4
diff -u -p -r1.4 tc-nios2.c
--- gas/config/tc-nios2.c	24 Apr 2013 20:51:57 -0000	1.4
+++ gas/config/tc-nios2.c	9 Jun 2013 22:36:39 -0000
@@ -2078,7 +2078,11 @@ nios2_parse_args (nios2_insn_infoS *insn
 
   parsed_args[i] = NULL;
 
-  if (*parsestr != '\0' && insn->insn_nios2_opcode->match != OP_MATCH_BREAK)
+  /* The argument to break and trap instructions is optional; complain
+     for other cases of missing arguments.  */
+  if (*parsestr != '\0'
+      && insn->insn_nios2_opcode->match != OP_MATCH_BREAK
+      && insn->insn_nios2_opcode->match != OP_MATCH_TRAP)
     as_bad (_("missing argument"));
 }
 
Index: gas/testsuite/gas/nios2/trap.s
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/nios2/trap.s,v
retrieving revision 1.1
diff -u -p -r1.1 trap.s
--- gas/testsuite/gas/nios2/trap.s	6 Feb 2013 23:22:16 -0000	1.1
+++ gas/testsuite/gas/nios2/trap.s	9 Jun 2013 22:36:39 -0000
@@ -1,3 +1,6 @@
-# Source file used to test the ret instructions
+# Source file used to test the trap instructions
 foo:
 	trap
+	trap 0
+	trap 31
+	trap 14
Index: gas/testsuite/gas/nios2/trap.d
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/nios2/trap.d,v
retrieving revision 1.2
diff -u -p -r1.2 trap.d
--- gas/testsuite/gas/nios2/trap.d	12 Mar 2013 21:34:58 -0000	1.2
+++ gas/testsuite/gas/nios2/trap.d	9 Jun 2013 22:36:39 -0000
@@ -4,4 +4,7 @@
 .*: +file format elf32-littlenios2
 
 Disassembly of section .text:
-0+0000 <[^>]*> 003b683a 	trap
+0+0000 <[^>]*> 003b683a 	trap	0
+0+0004 <[^>]*> 003b683a 	trap	0
+0+0008 <[^>]*> 003b6ffa 	trap	31
+0+000c <[^>]*> 003b6bba 	trap	14

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