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

Dmitry Selyutin ghostmansd@gmail.com
Thu Jun 23 19:37:30 GMT 2022
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