From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by sourceware.org (Postfix) with ESMTPS id B58813858408 for ; Thu, 7 Sep 2023 13:38:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B58813858408 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=embecosm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=embecosm.com Received: by mail-wr1-x433.google.com with SMTP id ffacd0b85a97d-31c5a2e8501so943072f8f.0 for ; Thu, 07 Sep 2023 06:38:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; t=1694093906; x=1694698706; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to; bh=r4sdw/c9etMvKXu3HvRjXr9mkLMbRpQW/WLQa47OZ+c=; b=g7m5d2oynzPxGVl6ZIKjrXPYHiU4ncEvNP7FDCmJqc3+JNqm9ZqwRHDwXGphqmyAl+ a/GxD1HrWJqkc1iVWw3GhY6IHS0uIeNtMXXtwWYVP2wweCl/z9BUFc2EwskQpR4kHTVF uUdZmAURhXcYoloMRNaUZCNU+Um75WQR52STRpXesvxkbyo7lQSow59ZhlyUNjZfwGbB NI1TCDYoZEO7pF1mAZDZwj1gv2gy+JYs1WBJVi8+4sZ/xPPMDbfSXhsf41VhA+lcwYx2 57U7l+7/qt80K6yDPmB7hWtr+VXkRKIKJyzBh2N4OlTlJrHVYkKzYh/9VfCRGfkcTlNU IduQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1694093906; x=1694698706; h=content-transfer-encoding:mime-version:reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=r4sdw/c9etMvKXu3HvRjXr9mkLMbRpQW/WLQa47OZ+c=; b=gufJkcEPKUgCoJsIaRNRzouucqNwtV4n8kEF+kFPPHTQ92OrXp7zjcM58D3n3hXxIA FtzHZZpZNPjZ8V5nZnVVEusrJcLeEv+2E1OhHrz7lkBOlv58L9V2bNbZE8S9spN7fcfn tewPMuYES7IVVWZrKk3+4oGbYO2HXdRCgkIg165Q5dDG+Vyry39FAAMvZtTADUohGnWD gveT11Z+uL9/0kmUuvJrkZZ1n4TgZhkW9Rt2xpjdY8XZVqrUvQ/z0Kpc7Axd2O6fCY2b prau+pNEucF7cL9IdqzgQ/CLJ3oZ5a8ptram8i7+h8Xbadr+uy+6rXUKe5lktCN2fYYi +r7w== X-Gm-Message-State: AOJu0YxYE224JL2h8dQAnYC/xieP1vJBMP6BD11z2G8m7b4aOO/dNwtx RGEDRgT5AyKDykst1AkXlhf24IfIhBH/sn4Czw== X-Google-Smtp-Source: AGHT+IGpS2BZy5BeLscBk+JyJXuuXm7oNpQsML+H287GJhnJQ5EzRPKr1Zxo42846URyAA0iAkofXA== X-Received: by 2002:a5d:45d0:0:b0:313:f395:f5a3 with SMTP id b16-20020a5d45d0000000b00313f395f5a3mr4754637wrs.38.1694093906029; Thu, 07 Sep 2023 06:38:26 -0700 (PDT) Received: from platypus.localdomain ([62.23.166.218]) by smtp.gmail.com with ESMTPSA id bt12-20020a056000080c00b0031433443265sm17693052wrb.53.2023.09.07.06.38.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Sep 2023 06:38:25 -0700 (PDT) From: arthur.cohen@embecosm.com To: gcc-patches@gcc.gnu.org Cc: gcc-rust@gcc.gnu.org, ibuclaw@gdcproject.org Subject: [PATCH 02/14] rust: Reintroduce TARGET_RUST_CPU_INFO hook Date: Thu, 7 Sep 2023 15:36:28 +0200 Message-ID: <20230907133729.2518969-3-arthur.cohen@embecosm.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230907133729.2518969-2-arthur.cohen@embecosm.com> References: <20230907133729.2518969-2-arthur.cohen@embecosm.com> Reply-To: arthur.cohen@embecosm.com MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-14.2 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: From: Iain Buclaw 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 | 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 69123f00298..f7a2f8be542 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 @@ -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 diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in index 9bac02b9b66..cd4e687aea1 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 @@ -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 diff --git a/gcc/rust/rust-lang.cc b/gcc/rust/rust-lang.cc index 1fb1c25da7a..978b8b9ead2 100644 --- a/gcc/rust/rust-lang.cc +++ b/gcc/rust/rust-lang.cc @@ -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); } diff --git a/gcc/rust/rust-session-manager.cc b/gcc/rust/rust-session-manager.cc index 074bad9c5d7..112960ad3c0 100644 --- a/gcc/rust/rust-session-manager.cc +++ b/gcc/rust/rust-session-manager.cc @@ -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 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; -- 2.42.0