diff --git a/gdb/aarch64-tdep.h b/gdb/aarch64-tdep.h
index 85c6a97a9bdf735a17f37ac5e38a7c2883d30a1b..2597443560f9caf9f7ce0d95cf3325a423b91e02 100644
--- a/gdb/aarch64-tdep.h
+++ b/gdb/aarch64-tdep.h
@@ -22,6 +22,8 @@
 #ifndef AARCH64_TDEP_H
 #define AARCH64_TDEP_H

+#include "arch/aarch64.h"
+
 /* Forward declarations.  */
 struct gdbarch;
 struct regset;
@@ -31,32 +33,6 @@ struct regset;
 #define AARCH64_DWARF_SP  31
 #define AARCH64_DWARF_V0  64

-/* Register numbers of various important registers.  */
-enum aarch64_regnum
-{
-  AARCH64_X0_REGNUM,		/* First integer register */
-
-  /* Frame register in AArch64 code, if used.  */
-  AARCH64_FP_REGNUM = AARCH64_X0_REGNUM + 29,
-  AARCH64_LR_REGNUM = AARCH64_X0_REGNUM + 30,	/* Return address */
-  AARCH64_SP_REGNUM,		/* Stack pointer */
-  AARCH64_PC_REGNUM,		/* Program counter */
-  AARCH64_CPSR_REGNUM,		/* Contains status register */
-  AARCH64_V0_REGNUM,		/* First floating point / vector register */
-
-  /* Last floating point / vector register */
-  AARCH64_V31_REGNUM = AARCH64_V0_REGNUM + 31,
-  AARCH64_FPSR_REGNUM,		/* Floating point status register */
-  AARCH64_FPCR_REGNUM,		/* Floating point control register */
-
-  /* Other useful registers.  */
-
-  /* Last integer-like argument */
-  AARCH64_LAST_X_ARG_REGNUM = AARCH64_X0_REGNUM + 7,
-  AARCH64_STRUCT_RETURN_REGNUM = AARCH64_X0_REGNUM + 8,
-  AARCH64_LAST_V_ARG_REGNUM = AARCH64_V0_REGNUM + 7
-};
-
 /* Size of integer registers.  */
 #define X_REGISTER_SIZE  8
 #define B_REGISTER_SIZE  1
diff --git a/gdb/arch/aarch64.h b/gdb/arch/aarch64.h
new file mode 100644
index 0000000000000000000000000000000000000000..d2c803a626a59216bfc20781004515a9f299a3fc
--- /dev/null
+++ b/gdb/arch/aarch64.h
@@ -0,0 +1,47 @@
+/* Common target-dependent functionality for AArch64.
+
+   Copyright (C) 2017 Free Software Foundation, Inc.
+
+   This file is part of GDB.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#ifndef AARCH64_H
+#define AARCH64_H
+
+/* Register numbers of various important registers.  */
+enum aarch64_regnum
+{
+  AARCH64_X0_REGNUM,		/* First integer register.  */
+  AARCH64_FP_REGNUM = AARCH64_X0_REGNUM + 29,	/* Frame register, if used.  */
+  AARCH64_LR_REGNUM = AARCH64_X0_REGNUM + 30,	/* Return address.  */
+  AARCH64_SP_REGNUM,		/* Stack pointer.  */
+  AARCH64_PC_REGNUM,		/* Program counter.  */
+  AARCH64_CPSR_REGNUM,		/* Current Program Status Register.  */
+  AARCH64_V0_REGNUM,		/* First fp/vec register.  */
+  AARCH64_V31_REGNUM = AARCH64_V0_REGNUM + 31,	/* Last fp/vec register.  */
+  AARCH64_FPSR_REGNUM,		/* Floating Point Status Register.  */
+  AARCH64_FPCR_REGNUM,		/* Floating Point Control Register.  */
+
+  /* Other useful registers.  */
+  AARCH64_LAST_X_ARG_REGNUM = AARCH64_X0_REGNUM + 7,
+  AARCH64_STRUCT_RETURN_REGNUM = AARCH64_X0_REGNUM + 8,
+  AARCH64_LAST_V_ARG_REGNUM = AARCH64_V0_REGNUM + 7
+};
+
+#define AARCH64_X_REGS_NUM 31
+#define AARCH64_V_REGS_NUM 32
+#define AARCH64_NUM_REGS AARCH64_FPCR_REGNUM + 1
+
+#endif /* aarch64.h */
\ No newline at end of file
diff --git a/gdb/gdbserver/linux-aarch64-low.c b/gdb/gdbserver/linux-aarch64-low.c
index 6d5c4e54235de92b0c2beb60d13ee1a200d84c45..b00d5c502d2be67daf0e7f48025647f191efef3b 100644
--- a/gdb/gdbserver/linux-aarch64-low.c
+++ b/gdb/gdbserver/linux-aarch64-low.c
@@ -38,6 +38,7 @@
 #include <sys/uio.h>

 #include "gdb_proc_service.h"
+#include "arch/aarch64.h"

 /* Defined in auto-generated files.  */
 void init_registers_aarch64 (void);
@@ -47,18 +48,6 @@ extern const struct target_desc *tdesc_aarch64;
 #include <sys/reg.h>
 #endif

-#define AARCH64_X_REGS_NUM 31
-#define AARCH64_V_REGS_NUM 32
-#define AARCH64_X0_REGNO    0
-#define AARCH64_SP_REGNO   31
-#define AARCH64_PC_REGNO   32
-#define AARCH64_CPSR_REGNO 33
-#define AARCH64_V0_REGNO   34
-#define AARCH64_FPSR_REGNO (AARCH64_V0_REGNO + AARCH64_V_REGS_NUM)
-#define AARCH64_FPCR_REGNO (AARCH64_V0_REGNO + AARCH64_V_REGS_NUM + 1)
-
-#define AARCH64_NUM_REGS (AARCH64_V0_REGNO + AARCH64_V_REGS_NUM + 2)
-
 /* Per-process arch-specific data we want to keep.  */

 struct arch_process_info
@@ -109,10 +98,10 @@ aarch64_fill_gregset (struct regcache *regcache, void *buf)
   int i;

   for (i = 0; i < AARCH64_X_REGS_NUM; i++)
-    collect_register (regcache, AARCH64_X0_REGNO + i, &regset->regs[i]);
-  collect_register (regcache, AARCH64_SP_REGNO, &regset->sp);
-  collect_register (regcache, AARCH64_PC_REGNO, &regset->pc);
-  collect_register (regcache, AARCH64_CPSR_REGNO, &regset->pstate);
+    collect_register (regcache, AARCH64_X0_REGNUM + i, &regset->regs[i]);
+  collect_register (regcache, AARCH64_SP_REGNUM, &regset->sp);
+  collect_register (regcache, AARCH64_PC_REGNUM, &regset->pc);
+  collect_register (regcache, AARCH64_CPSR_REGNUM, &regset->pstate);
 }

 static void
@@ -122,10 +111,10 @@ aarch64_store_gregset (struct regcache *regcache, const void *buf)
   int i;

   for (i = 0; i < AARCH64_X_REGS_NUM; i++)
-    supply_register (regcache, AARCH64_X0_REGNO + i, &regset->regs[i]);
-  supply_register (regcache, AARCH64_SP_REGNO, &regset->sp);
-  supply_register (regcache, AARCH64_PC_REGNO, &regset->pc);
-  supply_register (regcache, AARCH64_CPSR_REGNO, &regset->pstate);
+    supply_register (regcache, AARCH64_X0_REGNUM + i, &regset->regs[i]);
+  supply_register (regcache, AARCH64_SP_REGNUM, &regset->sp);
+  supply_register (regcache, AARCH64_PC_REGNUM, &regset->pc);
+  supply_register (regcache, AARCH64_CPSR_REGNUM, &regset->pstate);
 }

 static void
@@ -135,9 +124,9 @@ aarch64_fill_fpregset (struct regcache *regcache, void *buf)
   int i;

   for (i = 0; i < AARCH64_V_REGS_NUM; i++)
-    collect_register (regcache, AARCH64_V0_REGNO + i, &regset->vregs[i]);
-  collect_register (regcache, AARCH64_FPSR_REGNO, &regset->fpsr);
-  collect_register (regcache, AARCH64_FPCR_REGNO, &regset->fpcr);
+    collect_register (regcache, AARCH64_V0_REGNUM + i, &regset->vregs[i]);
+  collect_register (regcache, AARCH64_FPSR_REGNUM, &regset->fpsr);
+  collect_register (regcache, AARCH64_FPCR_REGNUM, &regset->fpcr);
 }

 static void
@@ -148,9 +137,9 @@ aarch64_store_fpregset (struct regcache *regcache, const void *buf)
   int i;

   for (i = 0; i < AARCH64_V_REGS_NUM; i++)
-    supply_register (regcache, AARCH64_V0_REGNO + i, &regset->vregs[i]);
-  supply_register (regcache, AARCH64_FPSR_REGNO, &regset->fpsr);
-  supply_register (regcache, AARCH64_FPCR_REGNO, &regset->fpcr);
+    supply_register (regcache, AARCH64_V0_REGNUM + i, &regset->vregs[i]);
+  supply_register (regcache, AARCH64_FPSR_REGNUM, &regset->fpsr);
+  supply_register (regcache, AARCH64_FPCR_REGNUM, &regset->fpcr);
 }

 /* Enable miscellaneous debugging output.  The name is historical - it
