This is the mail archive of the binutils-cvs@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]

[binutils-gdb] Allow integer immediates for AArch64 fmov instructions.


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=6688183925d82d4049931e95bc4e963ab66e770d

commit 6688183925d82d4049931e95bc4e963ab66e770d
Author: Tamar Christina <tamar.christina@arm.com>
Date:   Thu May 10 16:24:58 2018 +0100

    Allow integer immediates for AArch64 fmov instructions.
    
    This patch makes it possible to use an integer immediate with the fmov instructions
    allowing you to simply write fmov d0, #2 instead of needing fmov d0, #2.0.
    
    The parse double function already know to deal with this so we just need to list the
    restriction put in place in parser.
    
    The is considered a QoL improvement for hand assembly writers and allows more
    code portability between assembler.
    
    gas/
    
    	* config/tc-aarch64.c (parse_aarch64_imm_float): Remove restrictions.
    	* testsuite/gas/aarch64/diagnostic.s: Move fmov int test to..
    	* testsuite/gas/aarch64/fpmov.s: Here.
    	* testsuite/gas/aarch64/fpmov.d: Update results with fmov.
    	* testsuite/gas/aarch64/diagnostic.l: Remove fmov values.
    	* testsuite/gas/aarch64/sve-invalid.s: Update test files.
    	* testsuite/gas/aarch64/sve-invalid.l: Likewise

Diff:
---
 gas/ChangeLog                           | 10 ++++++++++
 gas/config/tc-aarch64.c                 | 25 ++++---------------------
 gas/testsuite/gas/aarch64/diagnostic.l  |  4 ----
 gas/testsuite/gas/aarch64/diagnostic.s  |  8 ++++----
 gas/testsuite/gas/aarch64/fpmov.d       |  4 ++++
 gas/testsuite/gas/aarch64/fpmov.s       |  5 +++++
 gas/testsuite/gas/aarch64/sve-invalid.l | 14 +++++---------
 gas/testsuite/gas/aarch64/sve-invalid.s | 10 +++++-----
 8 files changed, 37 insertions(+), 43 deletions(-)

diff --git a/gas/ChangeLog b/gas/ChangeLog
index c1687b4..56c0c24 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,5 +1,15 @@
 2018-05-10  Tamar Christina  <tamar.christina@arm.com>
 
+	* config/tc-aarch64.c (parse_aarch64_imm_float): Remove restrictions.
+	* testsuite/gas/aarch64/diagnostic.s: Move fmov int test to..
+	* testsuite/gas/aarch64/fpmov.s: Here.
+	* testsuite/gas/aarch64/fpmov.d: Update results with fmov.
+	* testsuite/gas/aarch64/diagnostic.l: Remove fmov values.
+	* testsuite/gas/aarch64/sve-invalid.s: Update test files.
+	* testsuite/gas/aarch64/sve-invalid.l: Likewise
+
+2018-05-10  Tamar Christina  <tamar.christina@arm.com>
+
 	* gas/config/tc-arm.c (do_neon_mov): Allow integer literal for float
 	immediate.
 	* testsuite/gas/arm/vfp-mov-enc.s: New.
diff --git a/gas/config/tc-aarch64.c b/gas/config/tc-aarch64.c
index 02c92e3..e673e12 100644
--- a/gas/config/tc-aarch64.c
+++ b/gas/config/tc-aarch64.c
@@ -2279,7 +2279,6 @@ parse_aarch64_imm_float (char **ccp, int *immed, bfd_boolean dp_p,
   char *str = *ccp;
   char *fpnum;
   LITTLENUM_TYPE words[MAX_LITTLENUMS];
-  int found_fpchar = 0;
   int64_t val = 0;
   unsigned fpword = 0;
   bfd_boolean hex_p = FALSE;
@@ -2309,26 +2308,10 @@ parse_aarch64_imm_float (char **ccp, int *immed, bfd_boolean dp_p,
 
       hex_p = TRUE;
     }
-  else
-    {
-      if (reg_name_p (str, reg_type))
-	{
-	  set_recoverable_error (_("immediate operand required"));
-	  return FALSE;
-	}
-
-      /* We must not accidentally parse an integer as a floating-point number.
-	 Make sure that the value we parse is not an integer by checking for
-	 special characters '.' or 'e'.  */
-      for (; *fpnum != '\0' && *fpnum != ' ' && *fpnum != '\n'; fpnum++)
-	if (*fpnum == '.' || *fpnum == 'e' || *fpnum == 'E')
-	  {
-	    found_fpchar = 1;
-	    break;
-	  }
-
-      if (!found_fpchar)
-	return FALSE;
+  else if (reg_name_p (str, reg_type))
+   {
+     set_recoverable_error (_("immediate operand required"));
+     return FALSE;
     }
 
   if (! hex_p)
diff --git a/gas/testsuite/gas/aarch64/diagnostic.l b/gas/testsuite/gas/aarch64/diagnostic.l
index cd3ce99..00bb512 100644
--- a/gas/testsuite/gas/aarch64/diagnostic.l
+++ b/gas/testsuite/gas/aarch64/diagnostic.l
@@ -144,10 +144,6 @@
 [^:]*:256: Error: register element index out of range 0 to 15 at operand 1 -- `ld2 {v0\.b,v1\.b}\[-1\],\[x0\]'
 [^:]*:259: Error: register element index out of range 0 to 15 at operand 1 -- `ld2 {v0\.b,v1\.b}\[16\],\[x0\]'
 [^:]*:260: Error: register element index out of range 0 to 15 at operand 1 -- `ld2 {v0\.b,v1\.b}\[67\],\[x0\]'
-[^:]*:262: Error: invalid floating-point constant at operand 2 -- `fmov d0,#2'
-[^:]*:263: Error: invalid floating-point constant at operand 2 -- `fmov d0,#-2'
-[^:]*:264: Error: invalid floating-point constant at operand 2 -- `fmov s0,2'
-[^:]*:265: Error: invalid floating-point constant at operand 2 -- `fmov s0,-2'
 [^:]*:267: Error: integer 64-bit register expected at operand 2 -- `st2 {v0.4s,v1.4s},\[sp\],xzr'
 [^:]*:268: Error: integer or zero register expected at operand 2 -- `str x1,\[x2,sp\]'
 [^:]*:271: Error: relocation not allowed at operand 3 -- `ldnp x1,x2,\[x3,#:lo12:foo\]'
diff --git a/gas/testsuite/gas/aarch64/diagnostic.s b/gas/testsuite/gas/aarch64/diagnostic.s
index 12e8504..a62327d 100644
--- a/gas/testsuite/gas/aarch64/diagnostic.s
+++ b/gas/testsuite/gas/aarch64/diagnostic.s
@@ -259,10 +259,10 @@
 	ld2	{v0.b, v1.b}[16], [x0]
 	ld2	{v0.b, v1.b}[67], [x0]
 
-	fmov	d0, #2
-	fmov	d0, #-2
-	fmov	s0, 2
-	fmov	s0, -2
+
+
+
+
 
 	st2	{v0.4s, v1.4s}, [sp], xzr
 	str	x1, [x2, sp]
diff --git a/gas/testsuite/gas/aarch64/fpmov.d b/gas/testsuite/gas/aarch64/fpmov.d
index fb032c6..21c16b7 100644
--- a/gas/testsuite/gas/aarch64/fpmov.d
+++ b/gas/testsuite/gas/aarch64/fpmov.d
@@ -17,3 +17,7 @@ Disassembly of section .*:
   24:	1e69f000 	fmov	d0, #2\.421875000000000000e-01
   28:	1e69f000 	fmov	d0, #2\.421875000000000000e-01
   2c:	1e29f000 	fmov	s0, #2\.421875000000000000e-01
+  30:	1e601000 	fmov	d0, #2\.000000000000000000e\+00
+  34:	1e701000 	fmov	d0, #-2\.000000000000000000e\+00
+  38:	1e201000 	fmov	s0, #2\.000000000000000000e\+00
+  3c:	1e301000 	fmov	s0, #-2\.000000000000000000e\+00
diff --git a/gas/testsuite/gas/aarch64/fpmov.s b/gas/testsuite/gas/aarch64/fpmov.s
index ffc9881..0b0a63e 100644
--- a/gas/testsuite/gas/aarch64/fpmov.s
+++ b/gas/testsuite/gas/aarch64/fpmov.s
@@ -15,3 +15,8 @@
 	fmov	d0, 0.2421875
 	fmov	d0, 0x3fcf000000000000
 	fmov	s0, 0x3e780000
+
+	fmov	d0, #2
+	fmov	d0, #-2
+	fmov	s0, 2
+	fmov	s0, -2
diff --git a/gas/testsuite/gas/aarch64/sve-invalid.l b/gas/testsuite/gas/aarch64/sve-invalid.l
index 6e614c3..32b7952 100644
--- a/gas/testsuite/gas/aarch64/sve-invalid.l
+++ b/gas/testsuite/gas/aarch64/sve-invalid.l
@@ -820,23 +820,19 @@
 .*: Error: immediate out of range at operand 3 -- `bic z0\.d,z0\.d,#0xd'
 .*: Error: immediate zero expected at operand 4 -- `fcmeq p0\.s,p1/z,z2\.s,#1'
 .*: Error: immediate zero expected at operand 4 -- `fcmeq p0\.s,p1/z,z2\.s,#1\.0'
-.*: Error: invalid floating-point constant at operand 4 -- `fadd z0\.s,p1/m,z0\.s,#0'
+.*: Error: floating-point value must be 0\.5 or 1\.0 at operand 4 -- `fadd z0\.s,p1/m,z0\.s,#0'
 .*: Error: floating-point value must be 0\.5 or 1\.0 at operand 4 -- `fadd z0\.s,p1/m,z0\.s,#0\.0'
-.*: Error: invalid floating-point constant at operand 4 -- `fadd z0\.s,p1/m,z0\.s,#1'
 .*: Error: floating-point value must be 0\.5 or 1\.0 at operand 4 -- `fadd z0\.s,p1/m,z0\.s,#1\.5'
-.*: Error: invalid floating-point constant at operand 4 -- `fadd z0\.s,p1/m,z0\.s,#2'
+.*: Error: floating-point value must be 0\.5 or 1\.0 at operand 4 -- `fadd z0\.s,p1/m,z0\.s,#2'
 .*: Error: floating-point value must be 0\.5 or 1\.0 at operand 4 -- `fadd z0\.s,p1/m,z0\.s,#2\.0'
-.*: Error: invalid floating-point constant at operand 4 -- `fmul z0\.s,p1/m,z0\.s,#0'
+.*: Error: floating-point value must be 0\.5 or 2\.0 at operand 4 -- `fmul z0\.s,p1/m,z0\.s,#0'
 .*: Error: floating-point value must be 0\.5 or 2\.0 at operand 4 -- `fmul z0\.s,p1/m,z0\.s,#0\.0'
-.*: Error: invalid floating-point constant at operand 4 -- `fmul z0\.s,p1/m,z0\.s,#1'
+.*: Error: floating-point value must be 0\.5 or 2\.0 at operand 4 -- `fmul z0\.s,p1/m,z0\.s,#1'
 .*: Error: floating-point value must be 0\.5 or 2\.0 at operand 4 -- `fmul z0\.s,p1/m,z0\.s,#1\.0'
 .*: Error: floating-point value must be 0\.5 or 2\.0 at operand 4 -- `fmul z0\.s,p1/m,z0\.s,#1\.5'
-.*: Error: invalid floating-point constant at operand 4 -- `fmul z0\.s,p1/m,z0\.s,#2'
-.*: Error: invalid floating-point constant at operand 4 -- `fmax z0\.s,p1/m,z0\.s,#0'
 .*: Error: floating-point value must be 0\.0 or 1\.0 at operand 4 -- `fmax z0\.s,p1/m,z0\.s,#0\.5'
-.*: Error: invalid floating-point constant at operand 4 -- `fmax z0\.s,p1/m,z0\.s,#1'
 .*: Error: floating-point value must be 0\.0 or 1\.0 at operand 4 -- `fmax z0\.s,p1/m,z0\.s,#1\.5'
-.*: Error: invalid floating-point constant at operand 4 -- `fmax z0\.s,p1/m,z0\.s,#2'
+.*: Error: floating-point value must be 0\.0 or 1\.0 at operand 4 -- `fmax z0\.s,p1/m,z0\.s,#2'
 .*: Error: floating-point value must be 0\.0 or 1\.0 at operand 4 -- `fmax z0\.s,p1/m,z0\.s,#2\.0'
 .*: Error: operand 2 must be an enumeration value such as POW2 -- `ptrue p1\.b,vl0'
 .*: Error: operand 2 must be an enumeration value such as POW2 -- `ptrue p1\.b,vl255'
diff --git a/gas/testsuite/gas/aarch64/sve-invalid.s b/gas/testsuite/gas/aarch64/sve-invalid.s
index 148dbc8..204721e 100644
--- a/gas/testsuite/gas/aarch64/sve-invalid.s
+++ b/gas/testsuite/gas/aarch64/sve-invalid.s
@@ -914,7 +914,7 @@
 	fadd	z0.s, p1/m, z0.s, #0
 	fadd	z0.s, p1/m, z0.s, #0.0
 	fadd	z0.s, p1/m, z0.s, #0.5			// OK
-	fadd	z0.s, p1/m, z0.s, #1
+	fadd	z0.s, p1/m, z0.s, #1			// OK
 	fadd	z0.s, p1/m, z0.s, #1.0			// OK
 	fadd	z0.s, p1/m, z0.s, #1.5
 	fadd	z0.s, p1/m, z0.s, #2
@@ -923,16 +923,16 @@
 	fmul	z0.s, p1/m, z0.s, #0
 	fmul	z0.s, p1/m, z0.s, #0.0
 	fmul	z0.s, p1/m, z0.s, #0.5			// OK
-	fmul	z0.s, p1/m, z0.s, #1
+	fmul	z0.s, p1/m, z0.s, #1			// OK
 	fmul	z0.s, p1/m, z0.s, #1.0
 	fmul	z0.s, p1/m, z0.s, #1.5
-	fmul	z0.s, p1/m, z0.s, #2
+	fmul	z0.s, p1/m, z0.s, #2			// OK
 	fmul	z0.s, p1/m, z0.s, #2.0			// OK
 
-	fmax	z0.s, p1/m, z0.s, #0
+	fmax	z0.s, p1/m, z0.s, #0			// OK
 	fmax	z0.s, p1/m, z0.s, #0.0			// OK
 	fmax	z0.s, p1/m, z0.s, #0.5
-	fmax	z0.s, p1/m, z0.s, #1
+	fmax	z0.s, p1/m, z0.s, #1			// OK
 	fmax	z0.s, p1/m, z0.s, #1.0			// OK
 	fmax	z0.s, p1/m, z0.s, #1.5
 	fmax	z0.s, p1/m, z0.s, #2


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