[PATCH v3 2/6] ppc: introduce non-zero operand

lkcl luke.leighton@gmail.com
Thu Jun 23 19:58:02 GMT 2022


the "normal" way of handling this is e.g. to have a 5-bit field where 0b00000 represents 32 (i.e. 0b100000 rather than 0b00000).

the reasoning behind the decision to go with the -1 offset is that a future version, using v3.1 64-bit prefixing, may end up extending the immediates with a lot more bits, at which point it gets complicated to detect the maximum.

l.


On June 23, 2022 8:37:30 PM GMT+01:00, Dmitry Selyutin <ghostmansd@gmail.com> wrote:
>svstep and svshape instructions subtract 1 before encoding some of the
>operands. Obviously zero is not supported for these operands. Whilst
>PPC_OPCODE_PLUS1 fits perfectly to mark that maximal value should be
>incremented, there is no flag which marks the fact that zero values are
>not allowed. This patch adds a new flag, PPC_OPCODE_NONZERO, for this
>purpose.
>---
> gas/config/tc-ppc.c  | 3 +++
> include/opcode/ppc.h | 3 +++
> 2 files changed, 6 insertions(+)
>
>diff --git a/gas/config/tc-ppc.c b/gas/config/tc-ppc.c
>index 76bdfb2e35..7d27334aa6 100644
>--- a/gas/config/tc-ppc.c
>+++ b/gas/config/tc-ppc.c
>@@ -1951,6 +1951,9 @@ ppc_insert_operand (uint64_t insn,
>   right = max & -max;
>   min = 0;
> 
>+  if ((operand->flags & PPC_OPERAND_NONZERO) != 0)
>+    min = 1;
>+
>   if ((operand->flags & PPC_OPERAND_SIGNOPT) != 0)
>     {
>       /* Extend the allowed range for addis to [-32768, 65535].
>diff --git a/include/opcode/ppc.h b/include/opcode/ppc.h
>index d5752a42e6..215fa8c5e0 100644
>--- a/include/opcode/ppc.h
>+++ b/include/opcode/ppc.h
>@@ -463,6 +463,9 @@ extern const unsigned int num_powerpc_operands;
> #define PPC_OPERAND_FCR (0x1000000)
> #define PPC_OPERAND_UDI (0x2000000)
> 
>+/* The operand cannot be zero.  */
>+#define PPC_OPERAND_NONZERO (0x4000000)
>+
> extern ppc_cpu_t ppc_parse_cpu (ppc_cpu_t, ppc_cpu_t *, const char *);
> 
> static inline int64_t
>-- 
>2.36.1


More information about the Binutils mailing list