[13/13] x86: fold individual Jump* attributes into a single Jump one

Message ID 48ee2f7f-bbe2-18eb-04b8-8cdcc701e9ea@suse.com
State New
Headers show
Series
  • x86: further insn template compaction
Related show

Commit Message

Jan Beulich Oct. 30, 2019, 8:29 a.m.
..., taking just 3 bits instead of 5. No two of them are used together.

gas/
2019-10-XX  Jan Beulich  <jbeulich@suse.com>

	* config/tc-i386.c (operand_size_match, md_assemble,
	parse_insn, match_template, process_suffix, output_jump,
	output_insn, i386_displacement): Adjust jump* field use/
	handling.
	* config/tc-i386-intel.c (i386_intel_operand): Likewise.

opcodes/
2019-10-XX  Jan Beulich  <jbeulich@suse.com>

	* i386-gen.c (opcode_modifiers): Remove JumpDword, JumpByte,
	JumpInterSegment, and JumpAbsolute entries.
	* i386-opc.h (JUMP, JUMP_DWORD, JUMP_BYTE, JUMP_INTERSEGMENT,
	JUMP_ABSOLUTE): Define.
	(struct i386_opcode_modifier): Extend jump field to 3 bits.
	Remove jumpdword, jumpbyte, jumpintersegment, and jumpabsolute
	fields.
	* i386-opc.tbl (JumpByte, JumpDword, JumpAbsolute,
	JumpInterSegment): Define.
	* i386-tbl.h: Re-generate.

Comments

H.J. Lu Oct. 31, 2019, 8:31 p.m. | #1
On Wed, Oct 30, 2019 at 1:29 AM Jan Beulich <jbeulich@suse.com> wrote:
>

> ..., taking just 3 bits instead of 5. No two of them are used together.

>

> gas/

> 2019-10-XX  Jan Beulich  <jbeulich@suse.com>

>

>         * config/tc-i386.c (operand_size_match, md_assemble,

>         parse_insn, match_template, process_suffix, output_jump,

>         output_insn, i386_displacement): Adjust jump* field use/

>         handling.

>         * config/tc-i386-intel.c (i386_intel_operand): Likewise.

>

> opcodes/

> 2019-10-XX  Jan Beulich  <jbeulich@suse.com>

>

>         * i386-gen.c (opcode_modifiers): Remove JumpDword, JumpByte,

>         JumpInterSegment, and JumpAbsolute entries.

>         * i386-opc.h (JUMP, JUMP_DWORD, JUMP_BYTE, JUMP_INTERSEGMENT,

>         JUMP_ABSOLUTE): Define.

>         (struct i386_opcode_modifier): Extend jump field to 3 bits.

>         Remove jumpdword, jumpbyte, jumpintersegment, and jumpabsolute

>         fields.

>         * i386-opc.tbl (JumpByte, JumpDword, JumpAbsolute,

>         JumpInterSegment): Define.

>         * i386-tbl.h: Re-generate.

>


OK.

Thanks.


-- 
H.J.

Patch

--- a/gas/config/tc-i386-intel.c
+++ b/gas/config/tc-i386-intel.c
@@ -658,8 +658,9 @@  i386_intel_operand (char *operand_string
 	      || current_templates->start->base_opcode == 0x62 /* bound */)
 	    suffix = WORD_MNEM_SUFFIX;
 	  else if (flag_code == CODE_16BIT
-		   && (current_templates->start->opcode_modifier.jump
-		       || current_templates->start->opcode_modifier.jumpdword))
+		   && (current_templates->start->opcode_modifier.jump == JUMP
+		       || current_templates->start->opcode_modifier.jump
+			  == JUMP_DWORD))
 	    suffix = LONG_DOUBLE_MNEM_SUFFIX;
 	  else if (got_a_float == 1)	/* "f..." */
 	    suffix = SHORT_MNEM_SUFFIX;
@@ -717,8 +718,8 @@  i386_intel_operand (char *operand_string
 	  suffix = LONG_DOUBLE_MNEM_SUFFIX;
 	  /* FALLTHROUGH */
 	case O_near_ptr:
-	  if (!current_templates->start->opcode_modifier.jump
-	      && !current_templates->start->opcode_modifier.jumpdword)
+	  if (current_templates->start->opcode_modifier.jump != JUMP
+	      && current_templates->start->opcode_modifier.jump != JUMP_DWORD)
 	    suffix = got_a_float /* so it will cause an error */
 		     ? BYTE_MNEM_SUFFIX
 		     : LONG_DOUBLE_MNEM_SUFFIX;
@@ -739,9 +740,9 @@  i386_intel_operand (char *operand_string
     }
 
   /* Operands for jump/call need special consideration.  */
-  if (current_templates->start->opcode_modifier.jump
-      || current_templates->start->opcode_modifier.jumpdword
-      || current_templates->start->opcode_modifier.jumpintersegment)
+  if (current_templates->start->opcode_modifier.jump == JUMP
+      || current_templates->start->opcode_modifier.jump == JUMP_DWORD
+      || current_templates->start->opcode_modifier.jump == JUMP_INTERSEGMENT)
     {
       bfd_boolean jumpabsolute = FALSE;
 
@@ -857,9 +858,9 @@  i386_intel_operand (char *operand_string
 	     ljmp	0x9090,0x90909090
 	   */
 
-	  if ((current_templates->start->opcode_modifier.jumpintersegment
-	       || current_templates->start->opcode_modifier.jumpdword
-	       || current_templates->start->opcode_modifier.jump)
+	  if ((current_templates->start->opcode_modifier.jump == JUMP_INTERSEGMENT
+	       || current_templates->start->opcode_modifier.jump == JUMP_DWORD
+	       || current_templates->start->opcode_modifier.jump == JUMP)
 	      && this_operand == 1
 	      && intel_state.seg == NULL
 	      && i.mem_operands == 1
--- a/gas/config/tc-i386.c
+++ b/gas/config/tc-i386.c
@@ -2064,11 +2064,9 @@  operand_size_match (const insn_template
 {
   unsigned int j, match = MATCH_STRAIGHT;
 
-  /* Don't check jump instructions.  */
+  /* Don't check non-absolute jump instructions.  */
   if (t->opcode_modifier.jump
-      || t->opcode_modifier.jumpbyte
-      || t->opcode_modifier.jumpdword
-      || t->opcode_modifier.jumpintersegment)
+      && t->opcode_modifier.jump != JUMP_ABSOLUTE)
     return match;
 
   /* Check memory and accumulator operand size.  */
@@ -4444,9 +4442,9 @@  md_assemble (char *line)
       i.imm_operands = 0;
     }
 
-  if ((i.tm.opcode_modifier.jump
-       || i.tm.opcode_modifier.jumpbyte
-       || i.tm.opcode_modifier.jumpdword)
+  if ((i.tm.opcode_modifier.jump == JUMP
+       || i.tm.opcode_modifier.jump == JUMP_BYTE
+       || i.tm.opcode_modifier.jump == JUMP_DWORD)
       && i.op[0].disps->X_op == O_constant)
     {
       /* Convert "jmp constant" (and "call constant") to a jump (call) to
@@ -4746,8 +4744,8 @@  check_suffix:
 	}
     }
 
-  if (current_templates->start->opcode_modifier.jump
-      || current_templates->start->opcode_modifier.jumpbyte)
+  if (current_templates->start->opcode_modifier.jump == JUMP
+      || current_templates->start->opcode_modifier.jump == JUMP_BYTE)
     {
       /* Check for a branch hint.  We allow ",pt" and ",pn" for
 	 predict taken and predict not taken respectively.
@@ -5735,11 +5733,11 @@  match_template (char mnem_suffix)
 
       /* This is intentionally not
 
-	 if (i.jumpabsolute != t->opcode_modifier.jumpabsolute)
+	 if (i.jumpabsolute != (t->opcode_modifier.jump == JUMP_ABSOLUTE))
 
 	 as the case of a missing * on the operand is accepted (perhaps with
 	 a warning, issued further down).  */
-      if (i.jumpabsolute && !t->opcode_modifier.jumpabsolute)
+      if (i.jumpabsolute && t->opcode_modifier.jump != JUMP_ABSOLUTE)
 	{
 	  i.error = operand_type_mismatch;
 	  continue;
@@ -6122,7 +6120,7 @@  check_reverse:
   if (!quiet_warnings)
     {
       if (!intel_syntax
-	  && (i.jumpabsolute != t->opcode_modifier.jumpabsolute))
+	  && (i.jumpabsolute != (t->opcode_modifier.jump == JUMP_ABSOLUTE)))
 	as_warn (_("indirect %s without `*'"), t->name);
 
       if (t->opcode_modifier.isprefix
@@ -6315,7 +6313,7 @@  process_suffix (void)
 	   /* exclude jmp/ljmp */
 	   && strcmp (i.tm.name, "jmp") && strcmp (i.tm.name, "ljmp")
 	   /* exclude byte-displacement jumps */
-	   && !i.tm.opcode_modifier.jumpbyte
+	   && i.tm.opcode_modifier.jump != JUMP_BYTE
 	   /* exclude lgdt/lidt/sgdt/sidt */
 	   && (i.tm.base_opcode != 0x0f01 || i.tm.extension_opcode > 3)
 	   /* exclude fldenv/frstor/fsave/fstenv */
@@ -6337,9 +6335,9 @@  process_suffix (void)
     }
   else if (intel_syntax
 	   && !i.suffix
-	   && (i.tm.opcode_modifier.jumpabsolute
-	       || i.tm.opcode_modifier.jumpbyte
-	       || i.tm.opcode_modifier.jumpintersegment
+	   && (i.tm.opcode_modifier.jump == JUMP_ABSOLUTE
+	       || i.tm.opcode_modifier.jump == JUMP_BYTE
+	       || i.tm.opcode_modifier.jump == JUMP_INTERSEGMENT
 	       || (i.tm.base_opcode == 0x0f01 /* [ls][gi]dt */
 		   && i.tm.extension_opcode <= 3)))
     {
@@ -6537,11 +6535,11 @@  process_suffix (void)
 	       && !is_any_vex_encoding (&i.tm)
 	       && ((i.suffix == LONG_MNEM_SUFFIX) == (flag_code == CODE_16BIT)
 		   || (flag_code == CODE_64BIT
-		       && i.tm.opcode_modifier.jumpbyte)))
+		       && i.tm.opcode_modifier.jump == JUMP_BYTE)))
 	{
 	  unsigned int prefix = DATA_PREFIX_OPCODE;
 
-	  if (i.tm.opcode_modifier.jumpbyte) /* jcxz, loop */
+	  if (i.tm.opcode_modifier.jump == JUMP_BYTE) /* jcxz, loop */
 	    prefix = ADDR_PREFIX_OPCODE;
 
 	  if (!add_prefix (prefix))
@@ -7992,7 +7990,7 @@  output_jump (void)
   fixS *fixP;
   bfd_reloc_code_real_type jump_reloc = i.reloc[0];
 
-  if (i.tm.opcode_modifier.jumpbyte)
+  if (i.tm.opcode_modifier.jump == JUMP_BYTE)
     {
       /* This is a loop or jecxz type instruction.  */
       size = 1;
@@ -8383,12 +8381,12 @@  output_insn (void)
   insn_start_off = frag_now_fix ();
 
   /* Output jumps.  */
-  if (i.tm.opcode_modifier.jump)
+  if (i.tm.opcode_modifier.jump == JUMP)
     output_branch ();
-  else if (i.tm.opcode_modifier.jumpbyte
-	   || i.tm.opcode_modifier.jumpdword)
+  else if (i.tm.opcode_modifier.jump == JUMP_BYTE
+	   || i.tm.opcode_modifier.jump == JUMP_DWORD)
     output_jump ();
-  else if (i.tm.opcode_modifier.jumpintersegment)
+  else if (i.tm.opcode_modifier.jump == JUMP_INTERSEGMENT)
     output_interseg_jump ();
   else
     {
@@ -9568,8 +9566,8 @@  i386_displacement (char *disp_start, cha
 
   operand_type_set (&bigdisp, 0);
   if (i.jumpabsolute
-      || (!current_templates->start->opcode_modifier.jump
-	  && !current_templates->start->opcode_modifier.jumpdword))
+      || (current_templates->start->opcode_modifier.jump != JUMP
+	  && current_templates->start->opcode_modifier.jump != JUMP_DWORD))
     {
       bigdisp.bitfield.disp32 = 1;
       override = (i.prefix[ADDR_PREFIX] != 0);
--- a/opcodes/i386-gen.c
+++ b/opcodes/i386-gen.c
@@ -608,10 +608,6 @@  static bitfield opcode_modifiers[] =
   BITFIELD (Load),
   BITFIELD (Modrm),
   BITFIELD (Jump),
-  BITFIELD (JumpDword),
-  BITFIELD (JumpByte),
-  BITFIELD (JumpInterSegment),
-  BITFIELD (JumpAbsolute),
   BITFIELD (FloatMF),
   BITFIELD (FloatR),
   BITFIELD (Size),
--- a/opcodes/i386-opc.h
+++ b/opcodes/i386-opc.h
@@ -395,16 +395,17 @@  enum
   Load,
   /* insn has a modrm byte. */
   Modrm,
-  /* special case for jump insns.  */
-  Jump,
+  /* special case for jump insns; value has to be 1 */
+#define JUMP 1
   /* call and jump */
-  JumpDword,
+#define JUMP_DWORD 2
   /* loop and jecxz */
-  JumpByte,
+#define JUMP_BYTE 3
   /* special case for intersegment leaps/calls */
-  JumpInterSegment,
+#define JUMP_INTERSEGMENT 4
   /* absolute address for jump */
-  JumpAbsolute,
+#define JUMP_ABSOLUTE 5
+  Jump,
   /* FP insn memory format bit, sized by 0x4 */
   FloatMF,
   /* src/dest swap for floats. */
@@ -643,11 +644,7 @@  typedef struct i386_opcode_modifier
   unsigned int w:1;
   unsigned int load:1;
   unsigned int modrm:1;
-  unsigned int jump:1;
-  unsigned int jumpdword:1;
-  unsigned int jumpbyte:1;
-  unsigned int jumpintersegment:1;
-  unsigned int jumpabsolute:1;
+  unsigned int jump:3;
   unsigned int floatmf:1;
   unsigned int floatr:1;
   unsigned int size:2;
--- a/opcodes/i386-opc.tbl
+++ b/opcodes/i386-opc.tbl
@@ -53,6 +53,11 @@ 
 
 #define RegBND Class=RegBND
 
+#define JumpByte         Jump=JUMP_BYTE
+#define JumpDword        Jump=JUMP_DWORD
+#define JumpAbsolute     Jump=JUMP_ABSOLUTE
+#define JumpInterSegment Jump=JUMP_INTERSEGMENT
+
 #define Size16 Size=SIZE16
 #define Size32 Size=SIZE32
 #define Size64 Size=SIZE64