public inbox for binutils-cvs@sourceware.org
 help / color / mirror / Atom feed
* [binutils-gdb] x86: use swap_2_operands() in build_vex_prefix()
@ 2023-03-03  7:47 Jan Beulich
  0 siblings, 0 replies; only message in thread
From: Jan Beulich @ 2023-03-03  7:47 UTC (permalink / raw)
  To: bfd-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=67748abf53b22fd0273bb374923c101c9d597094

commit 67748abf53b22fd0273bb374923c101c9d597094
Author: Jan Beulich <jbeulich@suse.com>
Date:   Fri Mar 3 08:46:41 2023 +0100

    x86: use swap_2_operands() in build_vex_prefix()
    
    Open-coding part of what may eventually be needed is somewhat risky.
    Let's use the function we have, taking care of all pieces of data which
    may need swapping, no matter that
    - right now i.flags[] and i.reloc[] aren't relevant here (yet),
    - EVEX masking and embedded broadcast aren't applicable.

Diff:
---
 gas/config/tc-i386.c | 20 +++-----------------
 1 file changed, 3 insertions(+), 17 deletions(-)

diff --git a/gas/config/tc-i386.c b/gas/config/tc-i386.c
index 9ceef278008..3e12bf4c831 100644
--- a/gas/config/tc-i386.c
+++ b/gas/config/tc-i386.c
@@ -3593,16 +3593,9 @@ build_vex_prefix (const insn_template *t)
       && (i.tm.opcode_modifier.load || i.tm.opcode_modifier.d)
       && i.rex == REX_B)
     {
-      unsigned int xchg = i.operands - 1;
-      union i386_op temp_op;
-      i386_operand_type temp_type;
+      unsigned int xchg;
 
-      temp_type = i.types[xchg];
-      i.types[xchg] = i.types[0];
-      i.types[0] = temp_type;
-      temp_op = i.op[xchg];
-      i.op[xchg] = i.op[0];
-      i.op[0] = temp_op;
+      swap_2_operands (0, i.operands - 1);
 
       gas_assert (i.rm.mode == 3);
 
@@ -3632,8 +3625,6 @@ build_vex_prefix (const insn_template *t)
       && !(i.vex.register_specifier->reg_flags & RegRex))
     {
       unsigned int xchg = i.operands - i.reg_operands;
-      union i386_op temp_op;
-      i386_operand_type temp_type;
 
       gas_assert (i.tm.opcode_space == SPACE_0F);
       gas_assert (!i.tm.opcode_modifier.sae);
@@ -3641,12 +3632,7 @@ build_vex_prefix (const insn_template *t)
                                       &i.types[i.operands - 3]));
       gas_assert (i.rm.mode == 3);
 
-      temp_type = i.types[xchg];
-      i.types[xchg] = i.types[xchg + 1];
-      i.types[xchg + 1] = temp_type;
-      temp_op = i.op[xchg];
-      i.op[xchg] = i.op[xchg + 1];
-      i.op[xchg + 1] = temp_op;
+      swap_2_operands (xchg, xchg + 1);
 
       i.rex = 0;
       xchg = i.rm.regmem | 8;

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-03-03  7:47 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-03  7:47 [binutils-gdb] x86: use swap_2_operands() in build_vex_prefix() Jan Beulich

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).