From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1643) id 0A6983858000; Mon, 10 Oct 2022 07:33:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0A6983858000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1665387198; bh=XJ04dqrtQr2zZR6fQDJmBx9T4HXc/hpm3RkgKATKnPw=; h=From:To:Subject:Date:From; b=baR0h1tN915VKLMjv1w1tjIvWwO2HaeKd2/OwWAo8ymQPtq3LAkXCUUyJgiydnoTi NsJFXvGp1XYhEq5hzKTz5cXbA2H+S1rHEQ/wEFcrS2Spegnzaw0pIlf7qBHkYW3ZzB CxfWIksDUxyTt8e3L8gcoa4ctmoC1F3NL7QEtsW4= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Thomas Schwinge To: gcc-cvs@gcc.gnu.org Subject: [gcc/devel/rust/master] rust: Reintroduce TARGET_RUST_CPU_INFO hook X-Act-Checkin: gcc X-Git-Author: Iain Buclaw X-Git-Refname: refs/heads/devel/rust/master X-Git-Oldrev: 066b6b8df960796362dbdcff62851ebea201b8e9 X-Git-Newrev: f97e0ca6e4e5efb33a47f8a1f0a49375fd1197f9 Message-Id: <20221010073318.0A6983858000@sourceware.org> Date: Mon, 10 Oct 2022 07:33:18 +0000 (GMT) List-Id: https://gcc.gnu.org/g:f97e0ca6e4e5efb33a47f8a1f0a49375fd1197f9 commit f97e0ca6e4e5efb33a47f8a1f0a49375fd1197f9 Author: Iain Buclaw Date: Sat Sep 24 21:46:11 2022 +0200 rust: Reintroduce TARGET_RUST_CPU_INFO hook gcc/ChangeLog: * doc/tm.texi: Regenerate. * doc/tm.texi.in: Add @node for Rust language and ABI, and document TARGET_RUST_CPU_INFO. gcc/rust/ChangeLog: * rust/rust-lang.cc (rust_add_target_info): Remove sorry. * rust/rust-session-manager.cc: Replace include of target.h with include of tm.h and rust-target.h. (Session::init): Call targetrustm.rust_cpu_info. * rust/rust-target.def (rust_cpu_info): New hook. * rust/rust-target.h (rust_add_target_info): Declare. Diff: --- gcc/doc/tm.texi | 13 +++++++++++++ gcc/doc/tm.texi.in | 7 +++++++ gcc/rust/rust-lang.cc | 2 -- gcc/rust/rust-session-manager.cc | 7 ++++++- gcc/rust/rust-target.def | 12 ++++++++++++ gcc/rust/rust-target.h | 4 ++++ 6 files changed, 42 insertions(+), 3 deletions(-) diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi index 9042059fd8a..638296d6fb9 100644 --- a/gcc/doc/tm.texi +++ b/gcc/doc/tm.texi @@ -53,6 +53,7 @@ through the macros defined in the @file{.h} file. * PCH Target:: Validity checking for precompiled headers. * C++ ABI:: Controlling C++ ABI changes. * D Language and ABI:: Controlling D ABI changes. +* Rust Language and ABI:: Controlling Rust ABI changes. * Named Address Spaces:: Adding support for named address spaces * Misc:: Everything else. @end menu @@ -10882,6 +10883,18 @@ if they have external linkage. If this flag is false, then instantiated decls will be emitted as weak symbols. The default is @code{false}. @end deftypevr +@node Rust Language and ABI +@section Rust ABI parameters +@cindex parameters, rust abi + +@deftypefn {Rust Target Hook} void TARGET_RUST_CPU_INFO (void) +Declare all environmental CPU info and features relating to the target CPU +using the function @code{rust_add_target_info}, which takes a string +representing the feature key and a string representing the feature value. +Configuration pairs predefined by this hook apply to all files that are being +compiled. +@end deftypefn + @node Named Address Spaces @section Adding support for named address spaces @cindex named address spaces diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in index dc639cc643f..911d5dca4e6 100644 --- a/gcc/doc/tm.texi.in +++ b/gcc/doc/tm.texi.in @@ -53,6 +53,7 @@ through the macros defined in the @file{.h} file. * PCH Target:: Validity checking for precompiled headers. * C++ ABI:: Controlling C++ ABI changes. * D Language and ABI:: Controlling D ABI changes. +* Rust Language and ABI:: Controlling Rust ABI changes. * Named Address Spaces:: Adding support for named address spaces * Misc:: Everything else. @end menu @@ -7127,6 +7128,12 @@ floating-point support; they are not included in this mechanism. @hook TARGET_D_TEMPLATES_ALWAYS_COMDAT +@node Rust Language and ABI +@section Rust ABI parameters +@cindex parameters, rust abi + +@hook TARGET_RUST_CPU_INFO + @node Named Address Spaces @section Adding support for named address spaces @cindex named address spaces diff --git a/gcc/rust/rust-lang.cc b/gcc/rust/rust-lang.cc index c9af790f66b..ed822cc4f13 100644 --- a/gcc/rust/rust-lang.cc +++ b/gcc/rust/rust-lang.cc @@ -104,8 +104,6 @@ struct GTY (()) language_function void rust_add_target_info (const char *key, const char *value) { - sorry ("TODO"); - Rust::Session::get_instance ().options.target_data.insert_key_value_pair ( key, value); } diff --git a/gcc/rust/rust-session-manager.cc b/gcc/rust/rust-session-manager.cc index a6291a3cab8..0947c18152c 100644 --- a/gcc/rust/rust-session-manager.cc +++ b/gcc/rust/rust-session-manager.cc @@ -42,7 +42,8 @@ #include "diagnostic.h" #include "input.h" #include "selftest.h" -#include "target.h" +#include "tm.h" +#include "rust-target.h" extern bool saw_errors (void); @@ -135,6 +136,10 @@ validate_crate_name (const std::string &crate_name, Error &error) void Session::init () { + // initialize target hooks + targetrustm.rust_cpu_info (); + + // target-independent values that should exist in all targets options.target_data.insert_key_value_pair ("target_pointer_width", std::to_string (POINTER_SIZE)); options.target_data.insert_key_value_pair ("target_endian", BYTES_BIG_ENDIAN diff --git a/gcc/rust/rust-target.def b/gcc/rust/rust-target.def index c800eefcfaa..285b7503528 100644 --- a/gcc/rust/rust-target.def +++ b/gcc/rust/rust-target.def @@ -28,5 +28,17 @@ HOOK_VECTOR (TARGETRUSTM_INITIALIZER, gcc_targetrustm) #undef HOOK_PREFIX #define HOOK_PREFIX "TARGET_" +/* Environmental CPU info and features (e.g. endianness, pointer size) relating + to the target CPU. */ +DEFHOOK +(rust_cpu_info, + "Declare all environmental CPU info and features relating to the target CPU\n\ +using the function @code{rust_add_target_info}, which takes a string\n\ +representing the feature key and a string representing the feature value.\n\ +Configuration pairs predefined by this hook apply to all files that are being\n\ +compiled.", + void, (void), + hook_void_void) + /* Close the 'struct gcc_targetrustm' definition. */ HOOK_VECTOR_END (C90_EMPTY_HACK) diff --git a/gcc/rust/rust-target.h b/gcc/rust/rust-target.h index 79edd786cdd..7fcdfc99b81 100644 --- a/gcc/rust/rust-target.h +++ b/gcc/rust/rust-target.h @@ -25,6 +25,10 @@ #include "rust-target.def" +/* Used by target to add target-related info. */ +extern void +rust_add_target_info (const char *, const char *); + /* Each target can provide their own. */ extern struct gcc_targetrustm targetrustm;