Commit | Line | Data |
---|---|---|
b5ffee31 AB |
1 | /* Copyright (C) 2018 Free Software Foundation, Inc. |
2 | ||
3 | This file is part of GDB. | |
4 | ||
5 | This program is free software; you can redistribute it and/or modify | |
6 | it under the terms of the GNU General Public License as published by | |
7 | the Free Software Foundation; either version 3 of the License, or | |
8 | (at your option) any later version. | |
9 | ||
10 | This program is distributed in the hope that it will be useful, | |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | GNU General Public License for more details. | |
14 | ||
15 | You should have received a copy of the GNU General Public License | |
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ | |
17 | ||
18 | #include "common-defs.h" | |
19 | #include "riscv.h" | |
20 | #include <stdlib.h> | |
21 | ||
22 | #include "../features/riscv/32bit-cpu.c" | |
23 | #include "../features/riscv/64bit-cpu.c" | |
24 | #include "../features/riscv/32bit-fpu.c" | |
25 | #include "../features/riscv/64bit-fpu.c" | |
26 | ||
27 | /* See arch/riscv.h. */ | |
28 | ||
29 | target_desc * | |
30 | riscv_create_target_description (struct riscv_gdbarch_features features) | |
31 | { | |
32 | target_desc *tdesc = allocate_target_description (); | |
33 | ||
34 | #ifndef IN_PROCESS_AGENT | |
35 | std::string arch_name = "riscv"; | |
36 | ||
37 | if (features.xlen == 4) | |
38 | arch_name.append (":rv32i"); | |
39 | else if (features.xlen == 8) | |
40 | arch_name.append (":rv64i"); | |
41 | else if (features.xlen == 16) | |
42 | arch_name.append (":rv128i"); | |
43 | ||
44 | if (features.flen == 4) | |
45 | arch_name.append ("f"); | |
46 | else if (features.flen == 8) | |
47 | arch_name.append ("d"); | |
48 | else if (features.flen == 16) | |
49 | arch_name.append ("q"); | |
50 | ||
51 | set_tdesc_architecture (tdesc, arch_name.c_str ()); | |
52 | #endif | |
53 | ||
54 | long regnum = 0; | |
55 | ||
56 | /* For now we only support creating 32-bit or 64-bit x-registers. */ | |
57 | if (features.xlen == 4) | |
58 | regnum = create_feature_riscv_32bit_cpu (tdesc, regnum); | |
59 | else if (features.xlen == 8) | |
60 | regnum = create_feature_riscv_64bit_cpu (tdesc, regnum); | |
61 | ||
62 | /* For now we only support creating 32-bit or 64-bit f-registers. */ | |
63 | if (features.flen == 4) | |
64 | regnum = create_feature_riscv_32bit_fpu (tdesc, regnum); | |
65 | else if (features.flen == 8) | |
66 | regnum = create_feature_riscv_64bit_fpu (tdesc, regnum); | |
67 | ||
68 | return tdesc; | |
69 | } |