xref: /netbsd-src/external/gpl3/gcc/dist/gcc/config/nvptx/nvptx-c.cc (revision b1e838363e3c6fc78a55519254d99869742dd33c)
1 /* Subroutines for the C front end on the NVPTX architecture.
2  * Copyright (C) 2021-2022 Free Software Foundation, Inc.
3  *
4  * This file is part of GCC.
5  *
6  * GCC is free software; you can redistribute it and/or modify it
7  * under the terms of the GNU General Public License as published
8  * by the Free Software Foundation; either version 3, or (at your
9  * option) any later version.
10  *
11  * GCC is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
14  * License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with GCC; see the file COPYING3.  If not see
18  * <http://www.gnu.org/licenses/>.  */
19 
20 #define IN_TARGET_CODE 1
21 
22 #include "config.h"
23 #include "system.h"
24 #include "coretypes.h"
25 #include "target.h"
26 #include "c-family/c-common.h"
27 #include "memmodel.h"
28 #include "tm_p.h"
29 #include "c-family/c-pragma.h"
30 
31 /* Function to tell the preprocessor about the defines for the target.  */
32 void
nvptx_cpu_cpp_builtins(void)33 nvptx_cpu_cpp_builtins (void)
34 {
35   cpp_assert (parse_in, "machine=nvptx");
36   cpp_assert (parse_in, "cpu=nvptx");
37   cpp_define (parse_in, "__nvptx__");
38   if (TARGET_SOFT_STACK)
39     cpp_define (parse_in, "__nvptx_softstack__");
40   if (TARGET_UNIFORM_SIMT)
41     cpp_define (parse_in,"__nvptx_unisimt__");
42 
43   const char *ptx_sm = NULL;
44 #define NVPTX_SM(XX, SEP) \
45   {						\
46     if (TARGET_SM ## XX)			\
47       ptx_sm = "__PTX_SM__=" #XX "0"; \
48   }
49 #include "nvptx-sm.def"
50 #undef NVPTX_SM
51   cpp_define (parse_in, ptx_sm);
52 
53   {
54     unsigned major
55       = ptx_version_to_number ((ptx_version)ptx_version_option, true);
56     unsigned minor
57       = ptx_version_to_number ((ptx_version)ptx_version_option, false);
58     cpp_define_formatted (parse_in, "__PTX_ISA_VERSION_MAJOR__=%u", major);
59     cpp_define_formatted (parse_in, "__PTX_ISA_VERSION_MINOR__=%u", minor);
60   }
61 }
62 
63