annotate gcc/config/riscv/riscv-c.c @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children 1830386684a0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 /* RISC-V-specific code for C family languages.
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2 Copyright (C) 2011-2018 Free Software Foundation, Inc.
111
kono
parents:
diff changeset
3 Contributed by Andrew Waterman (andrew@sifive.com).
kono
parents:
diff changeset
4
kono
parents:
diff changeset
5 This file is part of GCC.
kono
parents:
diff changeset
6
kono
parents:
diff changeset
7 GCC is free software; you can redistribute it and/or modify
kono
parents:
diff changeset
8 it under the terms of the GNU General Public License as published by
kono
parents:
diff changeset
9 the Free Software Foundation; either version 3, or (at your option)
kono
parents:
diff changeset
10 any later version.
kono
parents:
diff changeset
11
kono
parents:
diff changeset
12 GCC is distributed in the hope that it will be useful,
kono
parents:
diff changeset
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
kono
parents:
diff changeset
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
kono
parents:
diff changeset
15 GNU General Public License for more details.
kono
parents:
diff changeset
16
kono
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
kono
parents:
diff changeset
18 along with GCC; see the file COPYING3. If not see
kono
parents:
diff changeset
19 <http://www.gnu.org/licenses/>. */
kono
parents:
diff changeset
20
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
21 #define IN_TARGET_CODE 1
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
22
111
kono
parents:
diff changeset
23 #include "config.h"
kono
parents:
diff changeset
24 #include "system.h"
kono
parents:
diff changeset
25 #include "coretypes.h"
kono
parents:
diff changeset
26 #include "tm.h"
kono
parents:
diff changeset
27 #include "c-family/c-common.h"
kono
parents:
diff changeset
28 #include "cpplib.h"
kono
parents:
diff changeset
29
kono
parents:
diff changeset
30 #define builtin_define(TXT) cpp_define (pfile, TXT)
kono
parents:
diff changeset
31
kono
parents:
diff changeset
32 /* Implement TARGET_CPU_CPP_BUILTINS. */
kono
parents:
diff changeset
33
kono
parents:
diff changeset
34 void
kono
parents:
diff changeset
35 riscv_cpu_cpp_builtins (cpp_reader *pfile)
kono
parents:
diff changeset
36 {
kono
parents:
diff changeset
37 builtin_define ("__riscv");
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
38
111
kono
parents:
diff changeset
39 if (TARGET_RVC)
kono
parents:
diff changeset
40 builtin_define ("__riscv_compressed");
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
41
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
42 if (TARGET_RVE)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
43 builtin_define ("__riscv_32e");
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
44
111
kono
parents:
diff changeset
45 if (TARGET_ATOMIC)
kono
parents:
diff changeset
46 builtin_define ("__riscv_atomic");
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
47
111
kono
parents:
diff changeset
48 if (TARGET_MUL)
kono
parents:
diff changeset
49 builtin_define ("__riscv_mul");
kono
parents:
diff changeset
50 if (TARGET_DIV)
kono
parents:
diff changeset
51 builtin_define ("__riscv_div");
kono
parents:
diff changeset
52 if (TARGET_DIV && TARGET_MUL)
kono
parents:
diff changeset
53 builtin_define ("__riscv_muldiv");
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
54
111
kono
parents:
diff changeset
55 builtin_define_with_int_value ("__riscv_xlen", UNITS_PER_WORD * 8);
kono
parents:
diff changeset
56 if (TARGET_HARD_FLOAT)
kono
parents:
diff changeset
57 builtin_define_with_int_value ("__riscv_flen", UNITS_PER_FP_REG * 8);
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
58
111
kono
parents:
diff changeset
59 if (TARGET_HARD_FLOAT && TARGET_FDIV)
kono
parents:
diff changeset
60 {
kono
parents:
diff changeset
61 builtin_define ("__riscv_fdiv");
kono
parents:
diff changeset
62 builtin_define ("__riscv_fsqrt");
kono
parents:
diff changeset
63 }
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
64
111
kono
parents:
diff changeset
65 switch (riscv_abi)
kono
parents:
diff changeset
66 {
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
67 case ABI_ILP32E:
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
68 builtin_define ("__riscv_abi_rve");
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
69 gcc_fallthrough ();
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
70
111
kono
parents:
diff changeset
71 case ABI_ILP32:
kono
parents:
diff changeset
72 case ABI_LP64:
kono
parents:
diff changeset
73 builtin_define ("__riscv_float_abi_soft");
kono
parents:
diff changeset
74 break;
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
75
111
kono
parents:
diff changeset
76 case ABI_ILP32F:
kono
parents:
diff changeset
77 case ABI_LP64F:
kono
parents:
diff changeset
78 builtin_define ("__riscv_float_abi_single");
kono
parents:
diff changeset
79 break;
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
80
111
kono
parents:
diff changeset
81 case ABI_ILP32D:
kono
parents:
diff changeset
82 case ABI_LP64D:
kono
parents:
diff changeset
83 builtin_define ("__riscv_float_abi_double");
kono
parents:
diff changeset
84 break;
kono
parents:
diff changeset
85 }
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
86
111
kono
parents:
diff changeset
87 switch (riscv_cmodel)
kono
parents:
diff changeset
88 {
kono
parents:
diff changeset
89 case CM_MEDLOW:
kono
parents:
diff changeset
90 builtin_define ("__riscv_cmodel_medlow");
kono
parents:
diff changeset
91 break;
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
92
111
kono
parents:
diff changeset
93 case CM_MEDANY:
kono
parents:
diff changeset
94 builtin_define ("__riscv_cmodel_medany");
kono
parents:
diff changeset
95 break;
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
96
111
kono
parents:
diff changeset
97 case CM_PIC:
kono
parents:
diff changeset
98 builtin_define ("__riscv_cmodel_pic");
kono
parents:
diff changeset
99 break;
kono
parents:
diff changeset
100 }
kono
parents:
diff changeset
101 }