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] MIPS16/GAS: Improve [32768, 65535] out-of-range operand error diagnostics


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

commit 20c59b843a90300e5f9e07add83f5c72c8f994a6
Author: Maciej W. Rozycki <macro@imgtec.com>
Date:   Mon May 15 13:21:01 2017 +0100

    MIPS16/GAS: Improve [32768,65535] out-of-range operand error diagnostics
    
    Improve out-of-range operand error diagnostics for invalid values in the
    [32768,65535] range used for a signed 16-bit immediate, making the
    message consistent with that used for other invalid values, e.g.:
    
    foo.s:1: Error: operand 2 must be an immediate expression `addiu $2,$gp,32768'
    foo.s:2: Error: invalid operands `lw $2,32768($gp)'
    
    vs:
    
    foo.s:3: Error: operand 3 out of range `addiu $2,$gp,-32769'
    foo.s:4: Error: operand 2 out of range `lw $2,-32769($gp)'
    
    This case does not currently trigger however, for two reasons.
    
    First, for regular MIPS and microMIPS assembly in the case of no match
    caused by `match_int_operand' here, the function is always called again
    from `mips_ip' via `match_insns', `match_insn' and then `match_operand'
    for the same opcode table's entry with `lax_match' set to TRUE, in which
    case the attempt to match succeeds and no error is issued.
    
    Second, in the case of MIPS16 assembly no call to `match_int_operand' is
    made at all for signed 16-bit immediates, because such immediates are
    currently only matched with extensible instructions, and these are
    handled in `match_mips16_insn' via `match_expression' directly rather
    than via `match_operand'.
    
    This will change for MIPS16 code with MIPS16e2 support introduced, where
    non-extensible instructions accepting signed 16-bit immediates will be
    added, so make the case work well right from the start:
    
    foo.s:1: Error: operand 3 out of range `addiu $2,$gp,32768'
    foo.s:2: Error: operand 2 out of range `lw $2,32768($gp)'
    
    	gas/
    	* config/tc-mips.c (match_int_operand): Call
    	`match_out_of_range' before returning failure for 0x8000-0xffff
    	values conditionally allowed.

Diff:
---
 gas/ChangeLog        | 6 ++++++
 gas/config/tc-mips.c | 5 ++++-
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/gas/ChangeLog b/gas/ChangeLog
index 0952daf..c9ed98b 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,6 +1,12 @@
 2017-05-15  Maciej W. Rozycki  <macro@imgtec.com>
 
 	* config/tc-mips.c (match_int_operand): Call
+	`match_out_of_range' before returning failure for 0x8000-0xffff
+	values conditionally allowed.
+
+2017-05-15  Maciej W. Rozycki  <macro@imgtec.com>
+
+	* config/tc-mips.c (match_int_operand): Call
 	`match_not_constant' before returning failure for a non-constant
 	16-bit immediate conditionally allowed.
 
diff --git a/gas/config/tc-mips.c b/gas/config/tc-mips.c
index 3dc6a53..beb4d46 100644
--- a/gas/config/tc-mips.c
+++ b/gas/config/tc-mips.c
@@ -5102,7 +5102,10 @@ match_int_operand (struct mips_arg_info *arg,
 	{
 	  max_val = ((1 << operand_base->size) - 1) << operand->shift;
 	  if (!arg->lax_match && sval <= max_val)
-	    return FALSE;
+	    {
+	      match_out_of_range (arg);
+	      return FALSE;
+	    }
 	}
     }
   else


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