]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
[gdb/tdep] Factor out amd64_get_used_input_int_regs
authorTom de Vries <tdevries@suse.de>
Fri, 7 Mar 2025 08:25:33 +0000 (09:25 +0100)
committerTom de Vries <tdevries@suse.de>
Fri, 7 Mar 2025 08:25:33 +0000 (09:25 +0100)
The function amd64_get_unused_input_int_reg consists of two parts:
- finding the used int registers in an insn, and
- picking an unused int register.

Factor out the first part as new function amd64_get_used_input_int_regs.

No functional changes.

Tested on x86_64-linux.

gdb/amd64-tdep.c

index 0c3eae14371f88297538844e8cb70901f05eb85b..dd0fa06f354aa9a4904139d510bb55356b8133e7 100644 (file)
@@ -1206,13 +1206,11 @@ amd64_skip_prefixes (gdb_byte *insn)
   return insn;
 }
 
-/* Return an integer register in ALLOWED_REGS_MASK that is unused as an input
-   operand in INSN.  The register numbering of the result follows architecture
-   ordering, e.g. RDI = 7.  Return -1 if no register can be found.  */
+/* Return a register mask for the integer registers that are used as an input
+   operand in INSN.  */
 
-static int
-amd64_get_unused_input_int_reg (const struct amd64_insn *details,
-                               uint32_t allowed_regs_mask)
+static uint32_t
+amd64_get_used_input_int_regs (const struct amd64_insn *details)
 {
   /* 1 bit for each reg */
   uint32_t used_regs_mask = 0;
@@ -1255,6 +1253,19 @@ amd64_get_unused_input_int_reg (const struct amd64_insn *details,
     }
 
   gdb_assert (used_regs_mask < 256);
+  return used_regs_mask;
+}
+
+/* Return an integer register in ALLOWED_REGS_MASK that is unused as an input
+   operand in INSN.  The register numbering of the result follows architecture
+   ordering, e.g. RDI = 7.  Return -1 if no register can be found.  */
+
+static int
+amd64_get_unused_input_int_reg (const struct amd64_insn *details,
+                               uint32_t allowed_regs_mask)
+{
+  /* 1 bit for each reg */
+  uint32_t used_regs_mask = amd64_get_used_input_int_regs (details);
 
   /* Finally, find a free reg.  */
   {