2f80a293bb940bdcdf3c4ea5374fd3f44eb9026a
[external/binutils.git] / gdb / arch / aarch64.h
1 /* Common target-dependent functionality for AArch64.
2
3    Copyright (C) 2017-2018 Free Software Foundation, Inc.
4
5    This file is part of GDB.
6
7    This program is free software; you can redistribute it and/or modify
8    it under the terms of the GNU General Public License as published by
9    the Free Software Foundation; either version 3 of the License, or
10    (at your option) any later version.
11
12    This program is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU General Public License for more details.
16
17    You should have received a copy of the GNU General Public License
18    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
19
20 #ifndef ARCH_AARCH64_H
21 #define ARCH_AARCH64_H
22
23 #include "common/tdesc.h"
24
25 /* Create the aarch64 target description.  A non zero VQ value indicates both
26    the presence of SVE and the Vector Quotient - the number of 128bit chunks in
27    an SVE Z register.  */
28
29 target_desc *aarch64_create_target_description (long vq);
30
31 /* Register numbers of various important registers.  */
32 enum aarch64_regnum
33 {
34   AARCH64_X0_REGNUM,            /* First integer register.  */
35   AARCH64_FP_REGNUM = AARCH64_X0_REGNUM + 29,   /* Frame register, if used.  */
36   AARCH64_LR_REGNUM = AARCH64_X0_REGNUM + 30,   /* Return address.  */
37   AARCH64_SP_REGNUM,            /* Stack pointer.  */
38   AARCH64_PC_REGNUM,            /* Program counter.  */
39   AARCH64_CPSR_REGNUM,          /* Current Program Status Register.  */
40   AARCH64_V0_REGNUM,            /* First fp/vec register.  */
41   AARCH64_V31_REGNUM = AARCH64_V0_REGNUM + 31,  /* Last fp/vec register.  */
42   AARCH64_FPSR_REGNUM,          /* Floating Point Status Register.  */
43   AARCH64_FPCR_REGNUM,          /* Floating Point Control Register.  */
44
45   /* Other useful registers.  */
46   AARCH64_LAST_X_ARG_REGNUM = AARCH64_X0_REGNUM + 7,
47   AARCH64_STRUCT_RETURN_REGNUM = AARCH64_X0_REGNUM + 8,
48   AARCH64_LAST_V_ARG_REGNUM = AARCH64_V0_REGNUM + 7
49 };
50
51 #define AARCH64_X_REGS_NUM 31
52 #define AARCH64_V_REGS_NUM 32
53 #define AARCH64_NUM_REGS AARCH64_FPCR_REGNUM + 1
54
55 /* There are a number of ways of expressing the current SVE vector size:
56
57    VL : Vector Length.
58         The number of bytes in an SVE Z register.
59    VQ : Vector Quotient.
60         The number of 128bit chunks in an SVE Z register.
61    VG : Vector Gradient.
62         The number of 64bit chunks in an SVE Z register.  */
63
64 #define sve_vg_from_vl(vl)      ((vl) / 8)
65 #define sve_vl_from_vg(vg)      ((vg) * 8)
66 #define sve_vq_from_vl(vl)      ((vl) / 0x10)
67 #define sve_vl_from_vq(vq)      ((vq) * 0x10)
68 #define sve_vq_from_vg(vg)      (sve_vq_from_vl (sve_vl_from_vg (vg)))
69 #define sve_vg_from_vq(vq)      (sve_vg_from_vl (sve_vl_from_vq (vq)))
70
71
72 /* Maximum supported VQ value.  Increase if required.  */
73 #define AARCH64_MAX_SVE_VQ  16
74
75 #endif /* ARCH_AARCH64_H */