diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2022-08-17 11:34:00 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-17 11:34:00 +0000 |
commit | 36f52d2a9062b06a19986e2d65fa9f4e9bd62491 (patch) | |
tree | fdcc7abc0613aaabd34a436bf22441926c2bc6ed /gcc/rust | |
parent | 4f039ff9f6f18d15e32ddb54e3a6124802c45b7f (diff) | |
parent | 42a105c55f50903ffe92c1e529c1c6d091bcb10d (diff) | |
download | gcc-36f52d2a9062b06a19986e2d65fa9f4e9bd62491.zip gcc-36f52d2a9062b06a19986e2d65fa9f4e9bd62491.tar.gz gcc-36f52d2a9062b06a19986e2d65fa9f4e9bd62491.tar.bz2 |
Merge #1471
1471: Remove target hooks changes r=philberty a=philberty
This reverts the unnecessary changes we have made to GCC
so that merging from upstream should be simplified. This is
also making writing the patches for GCC simpler.
Co-authored-by: Philip Herron <philip.herron@embecosm.com>
Co-authored-by: Thomas Schwinge <thomas@codesourcery.com>
Diffstat (limited to 'gcc/rust')
-rw-r--r-- | gcc/rust/rust-lang.cc | 2 | ||||
-rw-r--r-- | gcc/rust/rust-session-manager.cc | 243 | ||||
-rw-r--r-- | gcc/rust/rust-session-manager.h | 3 | ||||
-rw-r--r-- | gcc/rust/rust-target-def.h | 20 | ||||
-rw-r--r-- | gcc/rust/rust-target.def | 89 | ||||
-rw-r--r-- | gcc/rust/rust-target.h | 47 |
6 files changed, 3 insertions, 401 deletions
diff --git a/gcc/rust/rust-lang.cc b/gcc/rust/rust-lang.cc index ed822cc..c9af790 100644 --- a/gcc/rust/rust-lang.cc +++ b/gcc/rust/rust-lang.cc @@ -104,6 +104,8 @@ 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 7d599b1..6d7f1a8 100644 --- a/gcc/rust/rust-session-manager.cc +++ b/gcc/rust/rust-session-manager.cc @@ -41,8 +41,8 @@ #include "diagnostic.h" #include "input.h" -#include "rust-target.h" #include "selftest.h" +#include "target.h" extern bool saw_errors (void); @@ -131,256 +131,15 @@ validate_crate_name (const std::string &crate_name, Error &error) return true; } -// Implicitly enable a target_feature (and recursively enable dependencies). -void -Session::implicitly_enable_feature (std::string feature_name) -{ - // TODO: is this really required since features added would be complete via - // target spec? - - if (!options.target_data.has_key_value_pair ("target_feature", feature_name)) - { - // if feature has dependencies, enable them - if (feature_name == "aes") - { - implicitly_enable_feature ("sse2"); - } - else if (feature_name == "avx") - { - implicitly_enable_feature ("sse4.2"); - } - else if (feature_name == "avx2") - { - implicitly_enable_feature ("avx"); - } - else if (feature_name == "fma") - { - implicitly_enable_feature ("avx"); - } - else if (feature_name == "pclmulqdq") - { - implicitly_enable_feature ("sse2"); - } - else if (feature_name == "sha") - { - implicitly_enable_feature ("sse2"); - } - else if (feature_name == "sse2") - { - implicitly_enable_feature ("sse"); - } - else if (feature_name == "sse3") - { - implicitly_enable_feature ("sse2"); - } - else if (feature_name == "sse4.1") - { - implicitly_enable_feature ("sse3"); - } - else if (feature_name == "sse4.2") - { - implicitly_enable_feature ("sse4.1"); - } - else if (feature_name == "ssse3") - { - implicitly_enable_feature ("sse3"); - } - - options.target_data.insert_key_value_pair ("target_feature", - std::move (feature_name)); - } -} - -// Meant to enable all target features. As this will be done by target hook, -// this method's deprecated. -void -Session::enable_features () -{ - bool has_target_crt_static = false; - - rust_debug ( - "ERROR: Somewhere in call chain Session::enable_features is called."); - - if (has_target_crt_static) - { - // enable "crt-static" attribute - } - - /* TODO: do this via target hook. have one for each target that implicitly - * enables the - * features for that platform. Would probably have to make custom target hook. - */ - - /* - if (target == "x86" || target == "x86_64") { - if (TARGET_AES) { - // enable aes, implicitly enable sse2 - implicitly_enable_feature("aes"); - } - - if (TARGET_AVX) { - // enable avx, implicitly enable sse4.2 - implicitly_enable_feature("sse4.2"); - } - - if (TARGET_AVX2) { - // enable avx2, implicitly enable avx - implicitly_enable_feature("avx"); - } - - if (TARGET_BMI) { - // enable bmi1 - implicitly_enable_feature("bmi1"); - } - - if (TARGET_BMI2) { - // enable bmi2 - implicitly_enable_feature("bmi2"); - } - - if (TARGET_FMA) { - // enable fma, implicitly enable avx - implicitly_enable_feature("fma"); - } - - if (TARGET_FXSR) { - // enable fxsr - implicitly_enable_feature("fxsr"); - } - - if (TARGET_LZCNT) { - // enable lzcnt - implicitly_enable_feature("lzcnt"); - } - - if (TARGET_VPCLMULQDQ) { - // enable pclmulqdq, implicitly enable sse2 - implicitly_enable_feature("pclmulqdq"); - } - - if (TARGET_POPCNT) { - // enable popcnt - implicitly_enable_feature("popcnt"); - } - - if (TARGET_RDRND) { - // enable rdrand - implicitly_enable_feature("rdrand"); - } - - if (TARGET_RDSEED) { - // enable rdseed - implicitly_enable_feature("rdseed"); - } - - if (TARGET_SHA) { - // enable sha, implicitly enable sse2 - implicitly_enable_feature("sha"); - } - - if (TARGET_SSE) { - // enable sse - implicitly_enable_feature("sse"); - } - - if (TARGET_SSE2) { - // enable sse2, implicitly enable sse - implicitly_enable_feature("sse2"); - } - - if (TARGET_SSE3) { - // enable sse3, implicitly enable sse2 - implicitly_enable_feature("sse3"); - } - - if (TARGET_SSE4_1) { - // enable sse4.1, implicitly enable sse3 - implicitly_enable_feature("sse4.1"); - } - - if (TARGET_SSE4_2) { - // enable sse4.2, implicitly enable sse4.1 - implicitly_enable_feature("sse4.2"); - } - - if (TARGET_SSSE3) { - // enable ssse3, implicitly enable sse3 - implicitly_enable_feature("ssse3"); - } - - if (TARGET_XSAVE) { - // enable xsave - implicitly_enable_feature("xsave"); - } - - if (TARGET_XSAVEC) { - // enable xsavec - implicitly_enable_feature("xsavec"); - } - - if (TARGET_XSAVEOPT) { - // enable xsaveopt - implicitly_enable_feature("xsaveopt"); - } - - if (TARGET_XSAVES) { - // enable xsaves - implicitly_enable_feature("xsaves"); - } - } - options.target_data.features.shrink_to_fit(); - std::sort(options.target_data.features.begin(), - options.target_data.features.end());*/ -} - void Session::init () { -#ifndef TARGET_RUST_OS_INFO -#define TARGET_RUST_OS_INFO() -#endif -//#define builtin_rust_info(KEY, VALUE) rust_add_target_info (KEY, VALUE) -// might as well use c++ stuff -#define builtin_rust_info(KEY, VALUE) \ - options.target_data.insert_key_value_pair (KEY, VALUE) - - // initialise target hooks - // targetrustm.rust_cpu_info(); - // targetrustm.rust_os_info(); - // ok, that's not working too well TODO - see if can salvage old - // implementation - TARGET_RUST_CPU_INFO (); - TARGET_RUST_OS_INFO (); - - /* note that due to issues with gcc targets, some implementations of those two - * macros above (TARGET_RUST_CPU_INFO and TARGET_RUST_OS_INFO) are not - * function calls, but actually inline substitutions. As such, they can't be - * stored with a function pointer in a "real" target hook. - * At least, that's my current understanding of it. */ - -#undef builtin_rust_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 ? "big" : "little"); - // TODO: find min atomic width and max atomic width - // from it, add atomic-related stuff for sizes 8, 16, 32, 64, and 128 (if - // inside bounds) in rustc, min atomic width is a known quantity (or 8 if not - // known), and max is also a known quantity (or is pointer size if not known) - // TODO: add atomic pointer if some criteria is satisfied - - // TODO: find whether target has "atomic cas" - - // add debug_assertions if enabled and proc_macro if crate type has it or - // whatever - - // derived values from hook - options.target_data.init_derived_values (); - // setup singleton linemap linemap = rust_get_linemap (); diff --git a/gcc/rust/rust-session-manager.h b/gcc/rust/rust-session-manager.h index 2432de7..99dd107 100644 --- a/gcc/rust/rust-session-manager.h +++ b/gcc/rust/rust-session-manager.h @@ -325,9 +325,6 @@ private: void dump_hir_pretty (HIR::Crate &crate) const; void dump_type_resolution (HIR::Crate &crate) const; - void implicitly_enable_feature (std::string feature_name); - void enable_features (); - // pipeline stages - TODO maybe move? /* Register plugins pipeline stage. TODO maybe move to another object? * Currently dummy stage. In future will handle attribute injection diff --git a/gcc/rust/rust-target-def.h b/gcc/rust/rust-target-def.h deleted file mode 100644 index 94c3f9f..0000000 --- a/gcc/rust/rust-target-def.h +++ /dev/null @@ -1,20 +0,0 @@ -/* rust-target-def.h -- Default initializers for Rust target hooks. - Copyright (C) 2020-2022 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the - Free Software Foundation; either version 3, or (at your option) any - later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; see the file COPYING3. If not see - <http://www.gnu.org/licenses/>. */ - -#include "rust/rust-target-hooks-def.h" -#include "tree.h" -#include "hooks.h" diff --git a/gcc/rust/rust-target.def b/gcc/rust/rust-target.def deleted file mode 100644 index 6d1ccaf..0000000 --- a/gcc/rust/rust-target.def +++ /dev/null @@ -1,89 +0,0 @@ -/* rust-target.def -- Target hook definitions for the Rust front end. - Copyright (C) 2020-2022 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the - Free Software Foundation; either version 3, or (at your option) any - later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; see the file COPYING3. If not see - <http://www.gnu.org/licenses/>. */ - -/* See target-hooks-macros.h for details of macros that should be - provided by the including file, and how to use them here. */ - -#include "target-hooks-macros.h" - -#undef HOOK_TYPE -#define HOOK_TYPE "Rust Target Hook" - -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 representing\n\ -the feature key and a string representing the feature value. Configuration pairs\n\ -predefined by this hook apply to all files that are being compiled.", - void, (void), - hook_void_void) - -// TODO: remove: format of DEFHOOK is return type, (param types), default value for function that it translates to - -/* Environmental OS info relating to the target OS. */ -DEFHOOK -(/*d_os_versions*/rust_os_info, - "Similar to @code{TARGET_RUST_CPU_INFO}, but is used for configuration info\n\ -relating to the target operating system.", - void, (void), - hook_void_void) - -/* The sizeof CRITICAL_SECTION or pthread_mutex_t. */ -/*DEFHOOK -(d_critsec_size, - "Returns the size of the data structure used by the target operating system\n\ -for critical sections and monitors. For example, on Microsoft Windows this\n\ -would return the @code{sizeof(CRITICAL_SECTION)}, while other platforms that\n\ -implement pthreads would return @code{sizeof(pthread_mutex_t)}.", - unsigned, (void), - hook_uint_void_0)*/ - - /* TODO: add more if required. Possible ones include static C runtime, target_env - * or vendor (if not covered by OS), and flags from the driver that may or may not - * require a target hook (might instead require a different type of hook) like - * test, debug_assertions, and proc_macro. */ - - /* TODO: rustc target support by tier: - * Tier 1 (definitely work): - * - i686-pc-windows-gnu - * - i686-pc-windows-msvc - * - i686-unknown-linux-gnu - * - x86_64-apple-darwin - * - x86_64-pc-windows-gnu - * - x86_64-pc-windows-msvc - * - x86_64-unknown-linux-gnu - * - Basically, 32-bit and 64-bit x86 for windows (MinGW and MSVC), gnu/linux, and osx - * Other tiers have too much crap, but basic breakdown is: - * Tier 2: - * - archs: ARM64 (aarch64), ARMv7, ARMv6, asm.js, i586 (32-bit x86 without SSE), mips, - * mips64, powerpc, powerpc64, risc-v, s390x, sparc, webasm, netbsd, redox (does gcc have support?), - * cloudabi (never head of it; i imagine no gcc support) - * - oses: ios, fuchsia, android, windows (msvc and mingw), gnu/linux, freebsd, netbsd - * Tier 2.5: - * - powerpc SPE linux, various cloudabi stuff, sparc - * Tier 3: - * - more obscure stuff like UWP support, vxworks, openbsd, dragonflybsd, haiku, bitrig, windows xp, - * cuda, hexagon, and combinations of them and earlier stuff */ - -/* 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 deleted file mode 100644 index 743ac51..0000000 --- a/gcc/rust/rust-target.h +++ /dev/null @@ -1,47 +0,0 @@ -/* rust-target.h -- Data structure definitions for target-specific Rust - behavior. Copyright (C) 2020-2022 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the - Free Software Foundation; either version 3, or (at your option) any - later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; see the file COPYING3. If not see - <http://www.gnu.org/licenses/>. */ - -#ifndef GCC_RUST_TARGET_H -#define GCC_RUST_TARGET_H - -#include "target.h" -#include "tm.h" -#include "memmodel.h" -#include "tm_p.h" - -// TODO: find out what this stuff actually does -#define DEFHOOKPOD(NAME, DOC, TYPE, INIT) TYPE NAME; -// #define DEFHOOK(NAME, DOC, TYPE, PARAMS, INIT) TYPE (*NAME) PARAMS; -#define DEFHOOK_UNDOC DEFHOOK -#define HOOKSTRUCT(FRAGMENT) FRAGMENT - -#include "rust-target.def" - -/* Each target can provide their own. */ -extern struct gcc_targetrustm targetrustm; -/* Some kind of structure to store all rust hook macros (like the - * TARGET_RUST_CPU_INFO). This is required to store the function pointers for - * the target hooks so that the frontend can call them - * and it calls the correct target-specific function. */ - -/* Used by target to add predefined version idenditiers. */ -// extern void d_add_builtin_version (const char *); -/* Used by target to add target-related info. */ -extern void -rust_add_target_info (const char *key, const char *value); - -#endif |