1 /* BPF-specific code for C family languages.
2 Copyright (C) 2024 Free Software Foundation, Inc.
3 Contributed by Oracle Inc.
5 This file is part of GCC.
7 GCC 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, or (at your option)
12 GCC 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.
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */
21 #define IN_TARGET_CODE 1
25 #include "coretypes.h"
27 #include "c-family/c-common.h"
30 /* Define target-specific CPP macros. This function in used in the
31 definition of TARGET_CPU_CPP_BUILTINS in bpf.h */
33 #define builtin_define(TXT) cpp_define (pfile, TXT)
36 bpf_target_macros (cpp_reader
*pfile
)
38 builtin_define ("__BPF__");
39 builtin_define ("__bpf__");
41 if (TARGET_BIG_ENDIAN
)
42 builtin_define ("__BPF_BIG_ENDIAN__");
44 builtin_define ("__BPF_LITTLE_ENDIAN__");
49 builtin_define_with_int_value ("__BPF_CPU_VERSION__", 1);
52 builtin_define_with_int_value ("__BPF_CPU_VERSION__", 2);
55 builtin_define_with_int_value ("__BPF_CPU_VERSION__", 3);
58 builtin_define_with_int_value ("__BPF_CPU_VERSION__", 4);
65 /* Different BPF CPU versions support different features. Some of
66 them can be enabled/disabled explicitly. */
68 builtin_define ("__BPF_FEATURE_ALU32");
70 builtin_define ("__BPF_FEATURE_JMP32");
72 builtin_define ("__BPF_FEATURE_JMP_EXT");
74 builtin_define ("__BPF_FEATURE_BSWAP");
76 builtin_define ("__BPF_FEATURE_SDIV_SMOD");
78 builtin_define ("__BPF_FEATURE_MOVSX");
80 /* Other CPU features can only be enabled/disabled generically by
81 selecting the corresponding CPU version. */
82 if (bpf_isa
>= ISA_V4
)
84 builtin_define ("__BPF_FEATURE_LDSX");
85 builtin_define ("__BPF_FEATURE_GOTOL");
86 builtin_define ("__BPF_FEATURE_ST");