opcodes: gas: i386: use Rex2 as attribute not constraint

Message ID 20240109011229.4191052-2-indu.bhagat@oracle.com
State Unresolved
Headers
Series opcodes: gas: i386: use Rex2 as attribute not constraint |

Checks

Context Check Description
snail/binutils-gdb-check warning Git am fail log

Commit Message

Indu Bhagat Jan. 9, 2024, 1:12 a.m. UTC
  It seems to fit better if Rex2 is an attribute for now rather than a
constraint.

PS: Removed the opcodes/i386-tbl.h diffs from patch to keep the message
size within limits.

ChangeLog:
        * gas/config/tc-i386.c (is_apx_rex2_encoding): Update the check.
        * opcodes/i386-gen.c: Add a new BITFIELD for Rex2.
        * opcodes/i386-opc.h (REX2_REQUIRED): Remove.
        * opcodes/i386-opc.tbl: Remove Rex2 operand constraint.
        * opcodes/i386-tbl.h: Regenerated.
---
 gas/config/tc-i386.c |     2 +-
 opcodes/i386-gen.c   |     1 +
 opcodes/i386-opc.h   |     6 +-
 opcodes/i386-opc.tbl |     1 -
 opcodes/i386-tbl.h   | 11659 +++++++++++++++++++++++++++--------------
 5 files changed, 7778 insertions(+), 3891 deletions(-)
  

Comments

Jan Beulich Jan. 9, 2024, 8:14 a.m. UTC | #1
On 09.01.2024 02:12, Indu Bhagat wrote:
> It seems to fit better if Rex2 is an attribute for now rather than a
> constraint.

On its own, I disagree with this as justification. When it was introduced,
I had specifically asked for it to be the way it is right now. The issue
with it is that it conflicts with an operand constraint you mean to add.
So while I'm okay with the code change, I'd like to ask that
- the description be extended,
- the patch be part of the SCFI series, preferably to also be committed
  together with the (subsequent) patch introducing the new operand
  constraint.

Jan

> PS: Removed the opcodes/i386-tbl.h diffs from patch to keep the message
> size within limits.
> 
> ChangeLog:
>         * gas/config/tc-i386.c (is_apx_rex2_encoding): Update the check.
>         * opcodes/i386-gen.c: Add a new BITFIELD for Rex2.
>         * opcodes/i386-opc.h (REX2_REQUIRED): Remove.
>         * opcodes/i386-opc.tbl: Remove Rex2 operand constraint.
>         * opcodes/i386-tbl.h: Regenerated.
> ---
>  gas/config/tc-i386.c |     2 +-
>  opcodes/i386-gen.c   |     1 +
>  opcodes/i386-opc.h   |     6 +-
>  opcodes/i386-opc.tbl |     1 -
>  opcodes/i386-tbl.h   | 11659 +++++++++++++++++++++++++++--------------
>  5 files changed, 7778 insertions(+), 3891 deletions(-)
> 
> diff --git a/gas/config/tc-i386.c b/gas/config/tc-i386.c
> index 27d0742c6c8..b25cc517240 100644
> --- a/gas/config/tc-i386.c
> +++ b/gas/config/tc-i386.c
> @@ -3929,7 +3929,7 @@ static INLINE bool
>  is_apx_rex2_encoding (void)
>  {
>    return i.rex2 || i.rex2_encoding
> -	|| i.tm.opcode_modifier.operandconstraint == REX2_REQUIRED;
> +	|| i.tm.opcode_modifier.rex2;
>  }
>  
>  static unsigned int
> diff --git a/opcodes/i386-gen.c b/opcodes/i386-gen.c
> index e8b92e32f45..21331216486 100644
> --- a/opcodes/i386-gen.c
> +++ b/opcodes/i386-gen.c
> @@ -490,6 +490,7 @@ static bitfield opcode_modifiers[] =
>    BITFIELD (ISA64),
>    BITFIELD (NoEgpr),
>    BITFIELD (NF),
> +  BITFIELD (Rex2),
>  };
>  
>  #define CLASS(n) #n, n
> diff --git a/opcodes/i386-opc.h b/opcodes/i386-opc.h
> index 38661ffe70c..eaebfaa9ba8 100644
> --- a/opcodes/i386-opc.h
> +++ b/opcodes/i386-opc.h
> @@ -579,8 +579,6 @@ enum
>    /* Instrucion requires that destination must be distinct from source
>       registers.  */
>  #define DISTINCT_DEST 9
> -  /* Instrucion requires REX2 prefix.  */
> -#define REX2_REQUIRED 10
>    OperandConstraint,
>    /* instruction ignores operand size prefix and in Intel mode ignores
>       mnemonic size suffix check.  */
> @@ -750,6 +748,9 @@ enum
>    /* No CSPAZO flags update indication.  */
>    NF,
>  
> +  /* Instrucion requires REX2 prefix.  */
> +  Rex2,
> +
>    /* The last bitfield in i386_opcode_modifier.  */
>    Opcode_Modifier_Num
>  };
> @@ -796,6 +797,7 @@ typedef struct i386_opcode_modifier
>    unsigned int isa64:2;
>    unsigned int noegpr:1;
>    unsigned int nf:1;
> +  unsigned int rex2:1;
>  } i386_opcode_modifier;
>  
>  /* Operand classes.  */
> diff --git a/opcodes/i386-opc.tbl b/opcodes/i386-opc.tbl
> index 1751eff8bd2..ada5c06e501 100644
> --- a/opcodes/i386-opc.tbl
> +++ b/opcodes/i386-opc.tbl
> @@ -85,7 +85,6 @@
>  #define RegKludge         OperandConstraint=REG_KLUDGE
>  #define SwapSources       OperandConstraint=SWAP_SOURCES
>  #define Ugh               OperandConstraint=UGH
> -#define Rex2              OperandConstraint=REX2_REQUIRED
>  
>  #define ATTSyntax         Dialect=ATT_SYNTAX
>  #define ATTMnemonic       Dialect=ATT_MNEMONIC
  

Patch

diff --git a/gas/config/tc-i386.c b/gas/config/tc-i386.c
index 27d0742c6c8..b25cc517240 100644
--- a/gas/config/tc-i386.c
+++ b/gas/config/tc-i386.c
@@ -3929,7 +3929,7 @@  static INLINE bool
 is_apx_rex2_encoding (void)
 {
   return i.rex2 || i.rex2_encoding
-	|| i.tm.opcode_modifier.operandconstraint == REX2_REQUIRED;
+	|| i.tm.opcode_modifier.rex2;
 }
 
 static unsigned int
diff --git a/opcodes/i386-gen.c b/opcodes/i386-gen.c
index e8b92e32f45..21331216486 100644
--- a/opcodes/i386-gen.c
+++ b/opcodes/i386-gen.c
@@ -490,6 +490,7 @@  static bitfield opcode_modifiers[] =
   BITFIELD (ISA64),
   BITFIELD (NoEgpr),
   BITFIELD (NF),
+  BITFIELD (Rex2),
 };
 
 #define CLASS(n) #n, n
diff --git a/opcodes/i386-opc.h b/opcodes/i386-opc.h
index 38661ffe70c..eaebfaa9ba8 100644
--- a/opcodes/i386-opc.h
+++ b/opcodes/i386-opc.h
@@ -579,8 +579,6 @@  enum
   /* Instrucion requires that destination must be distinct from source
      registers.  */
 #define DISTINCT_DEST 9
-  /* Instrucion requires REX2 prefix.  */
-#define REX2_REQUIRED 10
   OperandConstraint,
   /* instruction ignores operand size prefix and in Intel mode ignores
      mnemonic size suffix check.  */
@@ -750,6 +748,9 @@  enum
   /* No CSPAZO flags update indication.  */
   NF,
 
+  /* Instrucion requires REX2 prefix.  */
+  Rex2,
+
   /* The last bitfield in i386_opcode_modifier.  */
   Opcode_Modifier_Num
 };
@@ -796,6 +797,7 @@  typedef struct i386_opcode_modifier
   unsigned int isa64:2;
   unsigned int noegpr:1;
   unsigned int nf:1;
+  unsigned int rex2:1;
 } i386_opcode_modifier;
 
 /* Operand classes.  */
diff --git a/opcodes/i386-opc.tbl b/opcodes/i386-opc.tbl
index 1751eff8bd2..ada5c06e501 100644
--- a/opcodes/i386-opc.tbl
+++ b/opcodes/i386-opc.tbl
@@ -85,7 +85,6 @@ 
 #define RegKludge         OperandConstraint=REG_KLUDGE
 #define SwapSources       OperandConstraint=SWAP_SOURCES
 #define Ugh               OperandConstraint=UGH
-#define Rex2              OperandConstraint=REX2_REQUIRED
 
 #define ATTSyntax         Dialect=ATT_SYNTAX
 #define ATTMnemonic       Dialect=ATT_MNEMONIC