Find a file
Cupertino Miranda e0a81559c1 bpf: Implementation of BPF CO-RE builtins
This patch updates the support for the BPF CO-RE builtins
__builtin_preserve_access_index and __builtin_preserve_field_info,
and adds support for the CO-RE builtins __builtin_btf_type_id,
__builtin_preserve_type_info and __builtin_preserve_enum_value.

These CO-RE relocations are now converted to __builtin_core_reloc which
abstracts all of the original builtins in a polymorphic relocation
specific builtin.

The builtin processing is now split in 2 stages, the first (pack) is
executed right after the front-end and the second (process) right before
the asm output.

In expand pass the __builtin_core_reloc is converted to a
unspec:UNSPEC_CORE_RELOC rtx entry.

The data required to process the builtin is now collected in the packing
stage (after front-end), not allowing the compiler to optimize any of
the relevant information required to compose the relocation when
necessary.
At expansion, that information is recovered and CTF/BTF is queried to
construct the information that will be used in the relocation.
At this point the relocation is added to specific section and the
builtin is expanded to the expected default value for the builtin.

In order to process __builtin_preserve_enum_value, it was necessary to
hook the front-end to collect the original enum value reference.
This is needed since the parser folds all the enum values to its
integer_cst representation.

More details can be found within the core-builtins.cc.

Regtested in host x86_64-linux-gnu and target bpf-unknown-none.

gcc/ChangeLog:

	PR target/107844
	PR target/107479
	PR target/107480
	PR target/107481
	* config.gcc: Added core-builtins.cc and .o files.
	* config/bpf/bpf-passes.def: Removed file.
	* config/bpf/bpf-protos.h (bpf_add_core_reloc,
	bpf_replace_core_move_operands): New prototypes.
	* config/bpf/bpf.cc (enum bpf_builtins, is_attr_preserve_access,
	maybe_make_core_relo, bpf_core_field_info, bpf_core_compute,
	bpf_core_get_index, bpf_core_new_decl, bpf_core_walk,
	bpf_is_valid_preserve_field_info_arg, is_attr_preserve_access,
	handle_attr_preserve, pass_data_bpf_core_attr, pass_bpf_core_attr):
	Removed.
	(def_builtin, bpf_expand_builtin, bpf_resolve_overloaded_builtin): Changed.
	* config/bpf/bpf.md (define_expand mov<MM:mode>): Changed.
	(mov_reloc_core<mode>): Added.
	* config/bpf/core-builtins.cc (struct cr_builtin, enum
	cr_decision struct cr_local, struct cr_final, struct
	core_builtin_helpers, enum bpf_plugin_states): Added types.
	(builtins_data, core_builtin_helpers, core_builtin_type_defs):
	Added variables.
	(allocate_builtin_data, get_builtin-data, search_builtin_data,
	remove_parser_plugin, compare_same_kind, compare_same_ptr_expr,
	compare_same_ptr_type, is_attr_preserve_access, core_field_info,
	bpf_core_get_index, compute_field_expr,
	pack_field_expr_for_access_index, pack_field_expr_for_preserve_field,
	process_field_expr, pack_enum_value, process_enum_value, pack_type,
	process_type, bpf_require_core_support, make_core_relo, read_kind,
	kind_access_index, kind_preserve_field_info, kind_enum_value,
	kind_type_id, kind_preserve_type_info, get_core_builtin_fndecl_for_type,
	bpf_handle_plugin_finish_type, bpf_init_core_builtins,
	construct_builtin_core_reloc, bpf_resolve_overloaded_core_builtin,
	bpf_expand_core_builtin, bpf_add_core_reloc,
	bpf_replace_core_move_operands): Added functions.
	* config/bpf/core-builtins.h (enum bpf_builtins): Added.
	(bpf_init_core_builtins, bpf_expand_core_builtin,
	bpf_resolve_overloaded_core_builtin): Added functions.
	* config/bpf/coreout.cc (struct bpf_core_extra): Added.
	(bpf_core_reloc_add, output_asm_btfext_core_reloc): Changed.
	* config/bpf/coreout.h (bpf_core_reloc_add) Changed prototype.
	* config/bpf/t-bpf: Added core-builtins.o.
	* doc/extend.texi: Added documentation for new BPF builtins.
2023-08-03 19:46:44 +01:00
c++tools Daily bump. 2023-06-23 00:16:38 +00:00
config Daily bump. 2023-07-22 00:17:44 +00:00
contrib Daily bump. 2023-07-14 00:16:43 +00:00
fixincludes Daily bump. 2023-06-16 00:17:18 +00:00
gcc bpf: Implementation of BPF CO-RE builtins 2023-08-03 19:46:44 +01:00
gnattools Daily bump. 2023-04-26 00:17:46 +00:00
gotools Daily bump. 2022-08-31 00:16:45 +00:00
include Daily bump. 2023-07-30 00:17:03 +00:00
INSTALL
intl Daily bump. 2023-06-16 00:17:18 +00:00
libada Update copyright years. 2023-01-16 11:52:17 +01:00
libatomic Daily bump. 2023-06-11 00:17:37 +00:00
libbacktrace [libbacktrace] fix up broken test 2023-08-03 15:26:04 +02:00
libcc1 Daily bump. 2023-05-19 00:17:43 +00:00
libcody Daily bump. 2023-06-16 00:17:18 +00:00
libcpp Daily bump. 2023-07-20 00:17:53 +00:00
libdecnumber Daily bump. 2023-06-16 00:17:18 +00:00
libffi Daily bump. 2023-05-07 00:16:40 +00:00
libgcc Daily bump. 2023-07-24 00:16:51 +00:00
libgfortran Daily bump. 2023-07-22 00:17:44 +00:00
libgm2 Daily bump. 2023-06-03 00:16:48 +00:00
libgo cmd/go: don't collect package CGOLDFLAGS when using gccgo 2023-07-20 12:29:11 -07:00
libgomp Daily bump. 2023-07-30 00:17:03 +00:00
libiberty Daily bump. 2023-06-16 00:17:18 +00:00
libitm Daily bump. 2023-06-03 00:16:48 +00:00
libobjc Daily bump. 2023-05-23 00:17:11 +00:00
libphobos Daily bump. 2023-07-11 00:16:56 +00:00
libquadmath Daily bump. 2023-03-03 00:16:38 +00:00
libsanitizer Daily bump. 2023-05-01 00:16:44 +00:00
libssp Update copyright years. 2023-01-16 11:52:17 +01:00
libstdc++-v3 Daily bump. 2023-07-31 00:16:58 +00:00
libvtv Update copyright years. 2023-01-16 11:52:17 +01:00
lto-plugin Daily bump. 2023-07-01 00:18:32 +00:00
maintainer-scripts Daily bump. 2023-07-08 00:16:53 +00:00
zlib Daily bump. 2023-06-17 00:17:17 +00:00
.dir-locals.el
.gitattributes
.gitignore .gitignore: do not ignore config.h 2022-07-19 17:07:04 +03:00
ABOUT-NLS
ar-lib
ChangeLog Daily bump. 2023-08-03 00:17:10 +00:00
ChangeLog.jit
ChangeLog.tree-ssa
compile
config-ml.in
config.guess
config.rpath
config.sub
configure Use substituted GDCFLAGS 2023-07-31 11:37:47 +02:00
configure.ac Use substituted GDCFLAGS 2023-07-31 11:37:47 +02:00
COPYING
COPYING.LIB
COPYING.RUNTIME
COPYING3
COPYING3.LIB
depcomp
install-sh
libtool-ldflags
libtool.m4 Generic configury support for shared libs on VxWorks 2022-10-11 07:31:07 +00:00
ltgcc.m4
ltmain.sh
ltoptions.m4
ltsugar.m4
ltversion.m4
lt~obsolete.m4
MAINTAINERS MAINTAINERS: correct my email address 2023-08-02 11:00:35 +02:00
Makefile.def configure, Darwin: Ensure overrides to host-pie are passed to gcc configure. 2023-06-25 10:16:39 +01:00
Makefile.in Use substituted GDCFLAGS 2023-07-31 11:37:47 +02:00
Makefile.tpl Collect both user and kernel events for autofdo tests and autoprofiledbootstrap 2023-07-07 13:06:28 -07:00
missing
mkdep
mkinstalldirs
move-if-change
multilib.am
README
symlink-tree
test-driver
ylwrap

This directory contains the GNU Compiler Collection (GCC).

The GNU Compiler Collection is free software.  See the files whose
names start with COPYING for copying permission.  The manuals, and
some of the runtime libraries, are under different terms; see the
individual source files for details.

The directory INSTALL contains copies of the installation information
as HTML and plain text.  The source of this information is
gcc/doc/install.texi.  The installation information includes details
of what is included in the GCC sources and what files GCC installs.

See the file gcc/doc/gcc.texi (together with other files that it
includes) for usage and porting information.  An online readable
version of the manual is in the files gcc/doc/gcc.info*.

See http://gcc.gnu.org/bugs/ for how to report bugs usefully.

Copyright years on GCC source files may be listed using range
notation, e.g., 1987-2012, indicating that every year in the range,
inclusive, is a copyrightable year that could otherwise be listed
individually.