]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
rust: Reintroduce TARGET_RUST_CPU_INFO hook
authorIain Buclaw <ibuclaw@gdcproject.org>
Sat, 24 Sep 2022 19:46:11 +0000 (21:46 +0200)
committerArthur Cohen <arthur.cohen@embecosm.com>
Thu, 21 Sep 2023 09:15:02 +0000 (11:15 +0200)
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-lang.cc (rust_add_target_info): Remove sorry.
* 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-target.def (rust_cpu_info): New hook.
* rust-target.h (rust_add_target_info): Declare.

gcc/doc/tm.texi
gcc/doc/tm.texi.in
gcc/rust/rust-lang.cc
gcc/rust/rust-session-manager.cc
gcc/rust/rust-target.def
gcc/rust/rust-target.h

index 69123f00298566ff59ea439e580a374e5ceab542..f7a2f8be54261ff914ac1b7db5b07034cbd48715 100644 (file)
@@ -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
@@ -10962,6 +10963,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
index 9bac02b9b661d7bc2a5d3dd4ed3ba472fc661566..cd4e687aea117bf4f160ed6cc6427c0dca214638 100644 (file)
@@ -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
@@ -7143,6 +7144,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
index 1fb1c25da7ac454f4805c8de6bfe1221fde33e12..978b8b9ead2931eebd49a5e3551f4d7d24f623af 100644 (file)
@@ -101,8 +101,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);
 }
index 074bad9c5d7f74e75dab14534ef278248a249323..112960ad3c09c683c62b45dddb7e1e09bf720016 100644 (file)
@@ -44,7 +44,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);
@@ -137,6 +138,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
index c800eefcfaa7cdcb0712ecb73155fa268c9e378d..285b7503528b4b413883a140211b9dea1d61c1c1 100644 (file)
@@ -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)
index 79edd786cddf08993154c2dfb633d2947d78b96a..7fcdfc99b81e23be06f514d5045ddbf8e20a3ad0 100644 (file)
 
 #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;