|
|
01917d |
commit 11a0cf2ec0ed6e70ff25e9a50c2223dcd98c1c10
|
|
|
01917d |
Author: Peter Bergner <bergner@vnet.ibm.com>
|
|
|
01917d |
Date: Fri Jun 19 17:17:07 2015 -0500
|
|
|
01917d |
|
|
|
01917d |
Allow for optional operands with non-zero default values.
|
|
|
01917d |
|
|
|
01917d |
ISA 2.07 (ie, POWER8) added the rfebb instruction which takes one operand
|
|
|
01917d |
with the value of either a 0 or 1. It also defines an extended mnemonic
|
|
|
01917d |
with no operands (ie, "rfebb") that is supposed to be equivalent to "rfebb 1".
|
|
|
01917d |
I implemented rfebb's lone operand with PPC_OPERAND_OPTIONAL, but the
|
|
|
01917d |
problem is, optional operands that are ommitted always default to the
|
|
|
01917d |
value 0, which is wrong in this case. I have added support for allowing
|
|
|
01917d |
non-zero default values by adding an additional flag PPC_OPERAND_OPTIONAL_VALUE
|
|
|
01917d |
that specifies that the default operand value to be used is stored in the
|
|
|
01917d |
SHIFT field of the operand field immediately following this one.
|
|
|
01917d |
|
|
|
01917d |
This fixes the rfebb issue. I also fixed the mftb and mfcr instructions
|
|
|
01917d |
so they use the same mechanism. This allows us to flag invalid uses of
|
|
|
01917d |
mfcr where we explicitly pass in a zero FXM value, like the use in a2.[sd].
|
|
|
01917d |
|
|
|
01917d |
include/opcode/
|
|
|
01917d |
|
|
|
01917d |
* ppc.h (PPC_OPERAND_OPTIONAL_VALUE): New.
|
|
|
01917d |
(ppc_optional_operand_value): New inline function.
|
|
|
01917d |
|
|
|
01917d |
opcodes/
|
|
|
01917d |
* ppc-dis.h (skip_optional_operands): Use ppc_optional_operand_value.
|
|
|
01917d |
* ppc-opc.c (FXM4): Add non-zero optional value.
|
|
|
01917d |
(TBR): Likewise.
|
|
|
01917d |
(SXL): Likewise.
|
|
|
01917d |
(insert_fxm): Handle new default operand value.
|
|
|
01917d |
(extract_fxm): Likewise.
|
|
|
01917d |
(insert_tbr): Likewise.
|
|
|
01917d |
(extract_tbr): Likewise.
|
|
|
01917d |
|
|
|
01917d |
gas/
|
|
|
01917d |
* config/tc-ppc.c (md_assemble): Use ppc_optional_operand_value.
|
|
|
01917d |
Allow for optional operands without insert functions.
|
|
|
01917d |
|
|
|
01917d |
gas/testsuite/
|
|
|
01917d |
* gas/ppc/power8.d: Fixup rfebb test results.
|
|
|
01917d |
* gas/ppc/a2.s: Fix invalid mfcr test.
|
|
|
01917d |
* gas/ppc/a2.d: Likewise.
|
|
|
01917d |
|
|
|
01917d |
### a/include/opcode/ChangeLog
|
|
|
01917d |
### b/include/opcode/ChangeLog
|
|
|
01917d |
## -1,3 +1,8 @@
|
|
|
01917d |
+2015-06-19 Peter Bergner <bergner@vnet.ibm.com>
|
|
|
01917d |
+
|
|
|
01917d |
+ * ppc.h (PPC_OPERAND_OPTIONAL_VALUE): New.
|
|
|
01917d |
+ (ppc_optional_operand_value): New inline function.
|
|
|
01917d |
+
|
|
|
01917d |
2015-06-04 Matthew Wahab <matthew.wahab@arm.com>
|
|
|
01917d |
|
|
|
01917d |
* aarch64.h (AARCH64_V8_1): New.
|
|
|
01917d |
--- a/include/opcode/ppc.h
|
|
|
01917d |
+++ b/include/opcode/ppc.h
|
|
|
01917d |
@@ -380,6 +380,11 @@ extern const unsigned int num_powerpc_operands;
|
|
|
01917d |
|
|
|
01917d |
/* This is a CR FIELD that does not use symbolic names. */
|
|
|
01917d |
#define PPC_OPERAND_CR_REG (0x200000)
|
|
|
01917d |
+
|
|
|
01917d |
+/* This flag is only used with PPC_OPERAND_OPTIONAL. If this operand
|
|
|
01917d |
+ is omitted, then the value it should use for the operand is stored
|
|
|
01917d |
+ in the SHIFT field of the immediatly following operand field. */
|
|
|
01917d |
+#define PPC_OPERAND_OPTIONAL_VALUE (0x400000)
|
|
|
01917d |
|
|
|
01917d |
/* The POWER and PowerPC assemblers use a few macros. We keep them
|
|
|
01917d |
with the operands table for simplicity. The macro table is an
|
|
|
01917d |
@@ -409,4 +414,12 @@ extern const int powerpc_num_macros;
|
|
|
01917d |
|
|
|
01917d |
extern ppc_cpu_t ppc_parse_cpu (ppc_cpu_t, ppc_cpu_t *, const char *);
|
|
|
01917d |
|
|
|
01917d |
+static inline long
|
|
|
01917d |
+ppc_optional_operand_value (const struct powerpc_operand *operand)
|
|
|
01917d |
+{
|
|
|
01917d |
+ if ((operand->flags & PPC_OPERAND_OPTIONAL_VALUE) != 0)
|
|
|
01917d |
+ return (operand+1)->shift;
|
|
|
01917d |
+ return 0;
|
|
|
01917d |
+}
|
|
|
01917d |
+
|
|
|
01917d |
#endif /* PPC_H */
|
|
|
01917d |
### a/opcodes/ChangeLog
|
|
|
01917d |
### b/opcodes/ChangeLog
|
|
|
01917d |
## -1,3 +1,14 @@
|
|
|
01917d |
+2015-06-19 Peter Bergner <bergner@vnet.ibm.com>
|
|
|
01917d |
+
|
|
|
01917d |
+ * ppc-dis.h (skip_optional_operands): Use ppc_optional_operand_value.
|
|
|
01917d |
+ * ppc-opc.c (FXM4): Add non-zero optional value.
|
|
|
01917d |
+ (TBR): Likewise.
|
|
|
01917d |
+ (SXL): Likewise.
|
|
|
01917d |
+ (insert_fxm): Handle new default operand value.
|
|
|
01917d |
+ (extract_fxm): Likewise.
|
|
|
01917d |
+ (insert_tbr): Likewise.
|
|
|
01917d |
+ (extract_tbr): Likewise.
|
|
|
01917d |
+
|
|
|
01917d |
2015-06-16 Matthew Wahab <matthew.wahab@arm.com>
|
|
|
01917d |
|
|
|
01917d |
* arch64-opc.c (aarch64_sys_regs): Add "id_mmfr4_el1".
|
|
|
01917d |
--- a/opcodes/ppc-dis.c
|
|
|
01917d |
+++ b/opcodes/ppc-dis.c
|
|
|
01917d |
@@ -452,7 +452,8 @@ skip_optional_operands (const unsigned char *opindex,
|
|
|
01917d |
operand = &powerpc_operands[*opindex];
|
|
|
01917d |
if ((operand->flags & PPC_OPERAND_NEXT) != 0
|
|
|
01917d |
|| ((operand->flags & PPC_OPERAND_OPTIONAL) != 0
|
|
|
01917d |
- && operand_value_powerpc (operand, insn, dialect) != 0))
|
|
|
01917d |
+ && operand_value_powerpc (operand, insn, dialect) !=
|
|
|
01917d |
+ ppc_optional_operand_value (operand)))
|
|
|
01917d |
return 0;
|
|
|
01917d |
}
|
|
|
01917d |
|
|
|
01917d |
--- a/opcodes/ppc-opc.c
|
|
|
01917d |
+++ b/opcodes/ppc-opc.c
|
|
|
01917d |
@@ -382,10 +382,12 @@ const struct powerpc_operand powerpc_operands[] =
|
|
|
01917d |
|
|
|
01917d |
/* Power4 version for mfcr. */
|
|
|
01917d |
#define FXM4 FXM + 1
|
|
|
01917d |
- { 0xff, 12, insert_fxm, extract_fxm, PPC_OPERAND_OPTIONAL },
|
|
|
01917d |
+ { 0xff, 12, insert_fxm, extract_fxm, PPC_OPERAND_OPTIONAL | PPC_OPERAND_OPTIONAL_VALUE},
|
|
|
01917d |
+ /* If the FXM4 operand is ommitted, use the sentinel value -1. */
|
|
|
01917d |
+ { -1, -1, NULL, NULL, 0},
|
|
|
01917d |
|
|
|
01917d |
/* The IMM20 field in an LI instruction. */
|
|
|
01917d |
-#define IMM20 FXM4 + 1
|
|
|
01917d |
+#define IMM20 FXM4 + 2
|
|
|
01917d |
{ 0xfffff, PPC_OPSHIFT_INV, insert_li20, extract_li20, PPC_OPERAND_SIGNED},
|
|
|
01917d |
|
|
|
01917d |
/* The L field in a D or X form instruction. */
|
|
|
01917d |
@@ -642,10 +644,12 @@ const struct powerpc_operand powerpc_operands[] =
|
|
|
01917d |
/* The TBR field in an XFX form instruction. This is like the SPR
|
|
|
01917d |
field, but it is optional. */
|
|
|
01917d |
#define TBR SV + 1
|
|
|
01917d |
- { 0x3ff, 11, insert_tbr, extract_tbr, PPC_OPERAND_OPTIONAL },
|
|
|
01917d |
+ { 0x3ff, 11, insert_tbr, extract_tbr, PPC_OPERAND_OPTIONAL | PPC_OPERAND_OPTIONAL_VALUE},
|
|
|
01917d |
+ /* If the TBR operand is ommitted, use the value 268. */
|
|
|
01917d |
+ { -1, 268, NULL, NULL, 0},
|
|
|
01917d |
|
|
|
01917d |
/* The TO field in a D or X form instruction. */
|
|
|
01917d |
-#define TO TBR + 1
|
|
|
01917d |
+#define TO TBR + 2
|
|
|
01917d |
#define DUI TO
|
|
|
01917d |
#define TO_MASK (0x1f << 21)
|
|
|
01917d |
{ 0x1f, 21, NULL, NULL, 0 },
|
|
|
01917d |
@@ -766,10 +770,12 @@ const struct powerpc_operand powerpc_operands[] =
|
|
|
01917d |
|
|
|
01917d |
/* The S field in a XL form instruction. */
|
|
|
01917d |
#define SXL S + 1
|
|
|
01917d |
- { 0x1, 11, NULL, NULL, PPC_OPERAND_OPTIONAL },
|
|
|
01917d |
+ { 0x1, 11, NULL, NULL, PPC_OPERAND_OPTIONAL | PPC_OPERAND_OPTIONAL_VALUE},
|
|
|
01917d |
+ /* If the SXL operand is ommitted, use the value 1. */
|
|
|
01917d |
+ { -1, 1, NULL, NULL, 0},
|
|
|
01917d |
|
|
|
01917d |
/* SH field starting at bit position 16. */
|
|
|
01917d |
-#define SH16 SXL + 1
|
|
|
01917d |
+#define SH16 SXL + 2
|
|
|
01917d |
/* The DCM and DGM fields in a Z form instruction. */
|
|
|
01917d |
#define DCM SH16
|
|
|
01917d |
#define DGM DCM
|
|
|
01917d |
@@ -1284,19 +1290,13 @@ insert_fxm (unsigned long insn,
|
|
|
01917d |
}
|
|
|
01917d |
}
|
|
|
01917d |
|
|
|
01917d |
- /* If the optional field on mfcr is missing that means we want to use
|
|
|
01917d |
- the old form of the instruction that moves the whole cr. In that
|
|
|
01917d |
- case we'll have VALUE zero. There doesn't seem to be a way to
|
|
|
01917d |
- distinguish this from the case where someone writes mfcr %r3,0. */
|
|
|
01917d |
- else if (value == 0)
|
|
|
01917d |
- ;
|
|
|
01917d |
-
|
|
|
01917d |
/* If only one bit of the FXM field is set, we can use the new form
|
|
|
01917d |
of the instruction, which is faster. Unlike the Power4 branch hint
|
|
|
01917d |
encoding, this is not backward compatible. Do not generate the
|
|
|
01917d |
new form unless -mpower4 has been given, or -many and the two
|
|
|
01917d |
operand form of mfcr was used. */
|
|
|
01917d |
- else if ((value & -value) == value
|
|
|
01917d |
+ else if (value > 0
|
|
|
01917d |
+ && (value & -value) == value
|
|
|
01917d |
&& ((dialect & PPC_OPCODE_POWER4) != 0
|
|
|
01917d |
|| ((dialect & PPC_OPCODE_ANY) != 0
|
|
|
01917d |
&& (insn & (0x3ff << 1)) == 19 << 1)))
|
|
|
01917d |
@@ -1305,7 +1305,10 @@ insert_fxm (unsigned long insn,
|
|
|
01917d |
/* Any other value on mfcr is an error. */
|
|
|
01917d |
else if ((insn & (0x3ff << 1)) == 19 << 1)
|
|
|
01917d |
{
|
|
|
01917d |
- *errmsg = _("ignoring invalid mfcr mask");
|
|
|
01917d |
+ /* A value of -1 means we used the one operand form of
|
|
|
01917d |
+ mfcr which is valid. */
|
|
|
01917d |
+ if (value != -1)
|
|
|
01917d |
+ *errmsg = _("ignoring invalid mfcr mask");
|
|
|
01917d |
value = 0;
|
|
|
01917d |
}
|
|
|
01917d |
|
|
|
01917d |
@@ -1332,6 +1335,8 @@ extract_fxm (unsigned long insn,
|
|
|
01917d |
{
|
|
|
01917d |
if (mask != 0)
|
|
|
01917d |
*invalid = 1;
|
|
|
01917d |
+ else
|
|
|
01917d |
+ mask = -1;
|
|
|
01917d |
}
|
|
|
01917d |
|
|
|
01917d |
return mask;
|
|
|
01917d |
@@ -1868,12 +1873,7 @@ extract_sprg (unsigned long insn,
|
|
|
01917d |
}
|
|
|
01917d |
|
|
|
01917d |
/* The TBR field in an XFX instruction. This is just like SPR, but it
|
|
|
01917d |
- is optional. When TBR is omitted, it must be inserted as 268 (the
|
|
|
01917d |
- magic number of the TB register). These functions treat 0
|
|
|
01917d |
- (indicating an omitted optional operand) as 268. This means that
|
|
|
01917d |
- ``mftb 4,0'' is not handled correctly. This does not matter very
|
|
|
01917d |
- much, since the architecture manual does not define mftb as
|
|
|
01917d |
- accepting any values other than 268 or 269. */
|
|
|
01917d |
+ is optional. */
|
|
|
01917d |
|
|
|
01917d |
static unsigned long
|
|
|
01917d |
insert_tbr (unsigned long insn,
|
|
|
01917d |
@@ -1881,8 +1881,6 @@ insert_tbr (unsigned long insn,
|
|
|
01917d |
ppc_cpu_t dialect ATTRIBUTE_UNUSED,
|
|
|
01917d |
const char **errmsg)
|
|
|
01917d |
{
|
|
|
01917d |
- if (value == 0)
|
|
|
01917d |
- value = 268;
|
|
|
01917d |
if (value != 268 && value != 269)
|
|
|
01917d |
*errmsg = _("invalid tbr number");
|
|
|
01917d |
return insn | ((value & 0x1f) << 16) | ((value & 0x3e0) << 6);
|
|
|
01917d |
@@ -1898,8 +1896,6 @@ extract_tbr (unsigned long insn,
|
|
|
01917d |
ret = ((insn >> 16) & 0x1f) | ((insn >> 6) & 0x3e0);
|
|
|
01917d |
if (ret != 268 && ret != 269)
|
|
|
01917d |
*invalid = 1;
|
|
|
01917d |
- if (ret == 268)
|
|
|
01917d |
- ret = 0;
|
|
|
01917d |
return ret;
|
|
|
01917d |
}
|
|
|
01917d |
|