This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: Issue with PowerPC code generation in binutils 2.29 gas and above
- From: Alan Modra <amodra at gmail dot com>
- To: "frank at morphos-team dot net" <frank at morphos-team dot net>
- Cc: binutils at sourceware dot org
- Date: Tue, 12 Dec 2017 11:05:31 +1030
- Subject: Re: Issue with PowerPC code generation in binutils 2.29 gas and above
- Authentication-results: sourceware.org; auth=none
- References: <1513034445927.2750590.6b0af7b957590fb6813af8b45920c7eb79bd1878@spica.telekom.de>
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