public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* Re: Issue with PowerPC code generation in binutils 2.29 gas and above
       [not found] <1513034445927.2750590.6b0af7b957590fb6813af8b45920c7eb79bd1878@spica.telekom.de>
@ 2017-12-12  0:35 ` Alan Modra
  0 siblings, 0 replies; only message in thread
From: Alan Modra @ 2017-12-12  0:35 UTC (permalink / raw)
  To: frank; +Cc: binutils

On Tue, Dec 12, 2017 at 12:20:45AM +0100, frank@morphos-team.net wrote:
> Hi Alan,
>  
> not sure if that has been fixed by now but I recently came across some 
> issue when using a recent binutils toolchain to build code for our PowerPC 
> MorphOS project. gas seems to generate faulty instructions for certain 
> PowerPC opcodes like mfspr/mtspr with AltiVec SPRs. I could track this down 
> to some line in gas/config/tc-ppc.c starting with version 2.29 (probably 
> related to the following entry in the changelog):
>  
> 2017-02-20 Alan Modra <amodra@gmail.com>
> PR 21118 * NEWS: Revise powerpc register check. * config/tc-ppc.c 
> (ppc_optimize_expr, md_assemble): Make "invalid register expression" a 
> warning.

Yeah, it was the PR21118 change, but not that particular patch.  The
original patch for the PR on 2017-02-14 is the culprit.  git commit
7e0de605c.

> You seem to have added some masking to the (in my case SPR) number:
>  
> insn = ppc_insert_operand (insn, operand, ex.X_add_number & 0xff, ppc_cpu, 
> (char *) NULL, 0);
>  
> Some SPRs start at 256 though (VRSAVE) which in return will give you some 
> mfspr <gprX>,0 instead of mfspr <gprX>,256 in the final opcode encoding.

Oops, I don't think there is any reason for a mask at all.  The mask
probably came from an earlier iteration of the patch where I put
register number and flags in struct pd_reg value rather than splitting
the field into two shorts, and also put both in X_add_number rather
than splitting off flags into X_md.  Obviously we need at least 10
bits for SPRs.

diff --git a/gas/ChangeLog b/gas/ChangeLog
index 5cae4d1..99cd425 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,3 +1,8 @@
+2017-12-12  Alan Modra  <amodra@gmail.com>
+
+	PR 21118
+	* config/tc-ppc.c (md_assemble): Don't mask register number.
+
 2017-12-07  Max Filippov  <jcmvbkbc@gmail.com>
 
 	* config/tc-xtensa.c (xg_order_trampoline_chain): Replace
diff --git a/gas/config/tc-ppc.c b/gas/config/tc-ppc.c
index d4f3d60..d28164e 100644
--- a/gas/config/tc-ppc.c
+++ b/gas/config/tc-ppc.c
@@ -3040,7 +3040,7 @@ md_assemble (char *str)
 		   && ex.X_add_number != 0
 		   && (operand->flags & PPC_OPERAND_GPR_0) != 0))
 	    as_warn (_("invalid register expression"));
-	  insn = ppc_insert_operand (insn, operand, ex.X_add_number & 0xff,
+	  insn = ppc_insert_operand (insn, operand, ex.X_add_number,
 				     ppc_cpu, (char *) NULL, 0);
 	}
       else if (ex.X_op == O_constant)

-- 
Alan Modra
Australia Development Lab, IBM

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2017-12-12  0:35 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <1513034445927.2750590.6b0af7b957590fb6813af8b45920c7eb79bd1878@spica.telekom.de>
2017-12-12  0:35 ` Issue with PowerPC code generation in binutils 2.29 gas and above Alan Modra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).