Skip to content

Commit a3f1e7c

Browse files
author
Jens Remus
committed
s390: Simplify (dis)assembly of insn operands with const bits
Simplify assembly and disassembly of extended mnemonics with operands with constant ORed bits: Their instruction template already contains the respective constant operand bits, as they are significant to distinguish the extended from their base mnemonic. Operands are ORed into the instruction template. Therefore it is not necessary to OR the constant bits into the operand value during assembly in s390_insert_operand. Additionally the constant operand bits from the instruction template can be used to mask them from the operand value during disassembly in s390_print_insn_with_opcode. For now do so for non-length unsigned integer operands only. The separate instruction formats need to be retained, as their masks differ, which is relevant during disassembly to distinguish the base and extended mnemonics from each other. This affects the following extended mnemonics: - vfaebs, vfaehs, vfaefs - vfaezb, vfaezh, vfaezf - vfaezbs, vfaezhs, vfaezfs - vstrcbs, vstrchs, vstrcfs - vstrczb, vstrczh, vstrczf - vstrczbs, vstrczhs, vstrczfs - wcefb, wcdgb - wcelfb, wcdlgb - wcfeb, wcgdb - wclfeb, wclgdb - wfisb, wfidb, wfixb - wledb, wflrd, wflrx include/ * opcode/s390.h (S390_OPERAND_OR1, S390_OPERAND_OR2, S390_OPERAND_OR8): Remove. opcodes/ * s390-opc.c (U4_OR1_24, U4_OR2_24, U4_OR8_28): Remove. (INSTR_VRR_VVV0U1, INSTR_VRR_VVV0U2, INSTR_VRR_VVV0U3): Define as INSTR_VRR_VVV0U0 while retaining respective insn fmt mask. (INSTR_VRR_VV0UU8): Define as INSTR_VRR_VV0UU while retaining respective insn fmt mask. (INSTR_VRR_VVVU0VB1, INSTR_VRR_VVVU0VB2, INSTR_VRR_VVVU0VB3): Define as INSTR_VRR_VVVU0VB while retaining respective insn fmt mask. * s390-dis.c (s390_print_insn_with_opcode): Mask constant operand bits set in insn template of non-length unsigned integer operands. gas/ * config/tc-s390.c (s390_insert_operand): Do not OR constant operand value bits. Signed-off-by: Jens Remus <jremus@linux.ibm.com>
1 parent 4290b2c commit a3f1e7c

File tree

4 files changed

+17
-34
lines changed

4 files changed

+17
-34
lines changed

gas/config/tc-s390.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -795,13 +795,6 @@ s390_insert_operand (unsigned char *insn,
795795
uval &= 0xf;
796796
}
797797

798-
if (operand->flags & S390_OPERAND_OR1)
799-
uval |= 1;
800-
if (operand->flags & S390_OPERAND_OR2)
801-
uval |= 2;
802-
if (operand->flags & S390_OPERAND_OR8)
803-
uval |= 8;
804-
805798
/* Duplicate the GPR/VR operand at bit pos 12 to 16. */
806799
if (operand->flags & S390_OPERAND_CP16)
807800
{

include/opcode/s390.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,4 @@ extern const struct s390_operand s390_operands[];
193193

194194
#define S390_OPERAND_CP16 0x1000
195195

196-
#define S390_OPERAND_OR1 0x2000
197-
#define S390_OPERAND_OR2 0x4000
198-
#define S390_OPERAND_OR8 0x8000
199-
200196
#endif /* S390_H */

opcodes/s390-dis.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -299,12 +299,14 @@ s390_print_insn_with_opcode (bfd_vma memaddr,
299299
{
300300
enum disassembler_style style;
301301

302-
if (flags & S390_OPERAND_OR1)
303-
val.u &= ~1;
304-
if (flags & S390_OPERAND_OR2)
305-
val.u &= ~2;
306-
if (flags & S390_OPERAND_OR8)
307-
val.u &= ~8;
302+
if (!(flags & S390_OPERAND_LENGTH))
303+
{
304+
union operand_value insn_opval;
305+
306+
/* Mask any constant operand bits set in insn template. */
307+
insn_opval = s390_extract_operand (opcode->opcode, operand);
308+
val.u &= ~insn_opval.u;
309+
}
308310

309311
if ((opcode->flags & S390_INSTR_FLAG_OPTPARM)
310312
&& val.u == 0

opcodes/s390-opc.c

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -208,17 +208,9 @@ const struct s390_operand s390_operands[] =
208208
{ 4, 20, 0 },
209209
#define U4_24 (U4_20 + 1) /* 4 bit unsigned value starting at 24 */
210210
{ 4, 24, 0 },
211-
#define U4_OR1_24 (U4_24 + 1) /* 4 bit unsigned value ORed with 1 */
212-
{ 4, 24, S390_OPERAND_OR1 }, /* starting at 24 */
213-
#define U4_OR2_24 (U4_OR1_24+1) /* 4 bit unsigned value ORed with 2 */
214-
{ 4, 24, S390_OPERAND_OR2 }, /* starting at 24 */
215-
#define U4_OR3_24 (U4_OR2_24+1) /* 4 bit unsigned value ORed with 3 */
216-
{ 4, 24, S390_OPERAND_OR1 | S390_OPERAND_OR2 }, /* starting at 24 */
217-
#define U4_28 (U4_OR3_24+1) /* 4 bit unsigned value starting at 28 */
211+
#define U4_28 (U4_24+1) /* 4 bit unsigned value starting at 28 */
218212
{ 4, 28, 0 },
219-
#define U4_OR8_28 (U4_28 + 1) /* 4 bit unsigned value ORed with 8 */
220-
{ 4, 28, S390_OPERAND_OR8 }, /* starting at 28 */
221-
#define U4_32 (U4_OR8_28+1) /* 4 bit unsigned value starting at 32 */
213+
#define U4_32 (U4_28+1) /* 4 bit unsigned value starting at 32 */
222214
{ 4, 32, 0 },
223215
#define U4_36 (U4_32 + 1) /* 4 bit unsigned value starting at 36 */
224216
{ 4, 36, 0 },
@@ -512,23 +504,23 @@ unused_s390_operands_static_asserts (void)
512504
#define INSTR_VRR_VRR 6, { V_8,R_12,R_16,0,0,0 } /* e.g. vlvgp */
513505
#define INSTR_VRR_VVV0U 6, { V_8,V_12,V_16,U4_32,0,0 } /* e.g. vmrh */
514506
#define INSTR_VRR_VVV0U0 6, { V_8,V_12,V_16,U4_24,0,0 } /* e.g. vfaeb */
515-
#define INSTR_VRR_VVV0U1 6, { V_8,V_12,V_16,U4_OR1_24,0,0 } /* e.g. vfaebs*/
516-
#define INSTR_VRR_VVV0U2 6, { V_8,V_12,V_16,U4_OR2_24,0,0 } /* e.g. vfaezb*/
517-
#define INSTR_VRR_VVV0U3 6, { V_8,V_12,V_16,U4_OR3_24,0,0 } /* e.g. vfaezbs*/
507+
#define INSTR_VRR_VVV0U1 INSTR_VRR_VVV0U0 /* e.g. vfaebs*/
508+
#define INSTR_VRR_VVV0U2 INSTR_VRR_VVV0U0 /* e.g. vfaezb*/
509+
#define INSTR_VRR_VVV0U3 INSTR_VRR_VVV0U0 /* e.g. vfaezbs*/
518510
#define INSTR_VRR_VVV 6, { V_8,V_12,V_16,0,0,0 } /* e.g. vmrhb */
519511
#define INSTR_VRR_VVV2 6, { V_8,V_CP16_12,0,0,0,0 } /* e.g. vnot */
520512
#define INSTR_VRR_VV0U 6, { V_8,V_12,U4_32,0,0,0 } /* e.g. vseg */
521513
#define INSTR_VRR_VV0U2 6, { V_8,V_12,U4_24,0,0,0 } /* e.g. vistrb*/
522514
#define INSTR_VRR_VV0UU 6, { V_8,V_12,U4_28,U4_24,0,0 } /* e.g. vcdgb */
523515
#define INSTR_VRR_VV0UU2 6, { V_8,V_12,U4_32,U4_28,0,0 } /* e.g. wfc */
524-
#define INSTR_VRR_VV0UU8 6, { V_8,V_12,U4_OR8_28,U4_24,0,0 } /* e.g. wcdgb */
516+
#define INSTR_VRR_VV0UU8 INSTR_VRR_VV0UU /* e.g. wcdgb */
525517
#define INSTR_VRR_VV 6, { V_8,V_12,0,0,0,0 } /* e.g. vsegb */
526518
#define INSTR_VRR_VVVUU0V 6, { V_8,V_12,V_16,V_32,U4_20,U4_24 } /* e.g. vstrc */
527519
#define INSTR_VRR_VVVU0V 6, { V_8,V_12,V_16,V_32,U4_20,0 } /* e.g. vac */
528520
#define INSTR_VRR_VVVU0VB 6, { V_8,V_12,V_16,V_32,U4_24,0 } /* e.g. vstrcb*/
529-
#define INSTR_VRR_VVVU0VB1 6, { V_8,V_12,V_16,V_32,U4_OR1_24,0 } /* e.g. vstrcbs*/
530-
#define INSTR_VRR_VVVU0VB2 6, { V_8,V_12,V_16,V_32,U4_OR2_24,0 } /* e.g. vstrczb*/
531-
#define INSTR_VRR_VVVU0VB3 6, { V_8,V_12,V_16,V_32,U4_OR3_24,0 } /* e.g. vstrczbs*/
521+
#define INSTR_VRR_VVVU0VB1 INSTR_VRR_VVVU0VB /* e.g. vstrcbs*/
522+
#define INSTR_VRR_VVVU0VB2 INSTR_VRR_VVVU0VB /* e.g. vstrczb*/
523+
#define INSTR_VRR_VVVU0VB3 INSTR_VRR_VVVU0VB /* e.g. vstrczbs*/
532524
#define INSTR_VRR_VVV0V 6, { V_8,V_12,V_16,V_32,0,0 } /* e.g. vacq */
533525
#define INSTR_VRR_VVV0U0U 6, { V_8,V_12,V_16,U4_32,U4_24,0 } /* e.g. vfae */
534526
#define INSTR_VRR_VVVV 6, { V_8,V_12,V_16,V_32,0,0 } /* e.g. vfmadb*/

0 commit comments

Comments
 (0)