From patchwork Thu Sep 7 13:36:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arthur Cohen X-Patchwork-Id: 137633 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ab0a:0:b0:3f2:4152:657d with SMTP id m10csp2964240vqo; Thu, 7 Sep 2023 06:41:50 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF0fkwWllOKzTInMmqRd9GeFdVaUb5Q5YdO/j8j3kxFIjTvswfw6nQ9kXUZbl5W154igfef X-Received: by 2002:a17:907:d690:b0:9a9:f042:dec0 with SMTP id wf16-20020a170907d69000b009a9f042dec0mr430110ejc.38.1694094109692; Thu, 07 Sep 2023 06:41:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694094109; cv=none; d=google.com; s=arc-20160816; b=vSkjKSbj0kXkL4P73XRiiGlGmh7oQQ9dN7aCdQizdZTF0bnbNb3q/Rl8BgIPEIaUnF aT6fRUDH6UdyT/vvf63dpoN3HV/DztXODAUhS0CMJFZg3tT7iUI+Fx+jCfGmMN/sS+pv lhKSvQj8DTaYi8EiEA7DSpt/hUkHiwRU7SojfaGLV1JPlPuj1Z4k8An/6+5XEV4ImR70 wFWLcUZHjTobWMQoM6ewIj0cYJYNhpBlytVpKChDcD2A3DuWmwajC/8QlzICU+nyPr9y +u7ilW50R72+11le0tztuaxdhKn024StUpEM2UxGFHNup7E/wxYwSBOWm1OEZH4HUnb3 kbnA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:reply-to:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:dkim-signature:dmarc-filter :delivered-to; bh=e70MoCq7qUHP1GHQpBdTh5qXfWgp4wGIIStEmlDRbWo=; fh=wFq7tT6aDoWtju83L9lDAhBMEFwd5hWtfnM+XVolLD0=; b=m6N/Pc5yxwyRBL2Va5OHPF3lLAGE6E7nBaFIFhJeFLfSOt8hqtLNLMfJpD0ihMwTlF LVFdnOZ7647417m3L/nDCyR2M36WVj95A2trs26VUQ9HcWJXK+D3FrYayfA8JcOX/giS w3+vlpuEa515xHogpEz31vJmud7NYoZ7DelLZWE5YPzWPDxiDiXNzJJJNFidE7nnBF23 lqzcNchtGYNqR6pooItJodz7SbeuSABm9HFFpxoOctYv1/E1OaaonLecsZivQ7PIii6n 4DV/wYYLdPym/rxWiG2AGYhPH3y0+ZdhuvbiKXLC0FqwgwK//DWkqF5N+DYj3GwASSAs yemQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@embecosm.com header.s=google header.b=TNnY3r3g; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id r5-20020a170906a20500b00988b1c57f15si10302513ejy.272.2023.09.07.06.41.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Sep 2023 06:41:49 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=fail header.i=@embecosm.com header.s=google header.b=TNnY3r3g; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2A2EF3856943 for ; Thu, 7 Sep 2023 13:39:33 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by sourceware.org (Postfix) with ESMTPS id F2AA63858422 for ; Thu, 7 Sep 2023 13:38:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org F2AA63858422 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-x432.google.com with SMTP id ffacd0b85a97d-31ad9155414so899868f8f.3 for ; Thu, 07 Sep 2023 06:38:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; t=1694093907; x=1694698707; 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=e70MoCq7qUHP1GHQpBdTh5qXfWgp4wGIIStEmlDRbWo=; b=TNnY3r3gAIE9r4RHa98wLzWG7anhVE9qaYslCZYqWdsactdNonPYTouJd9OwnKr2sF 9jKpeLFbPxaLa2FaZw47569rZvFJlgLbRtzjk0ACJyghy6KkjqZUz2v6nhxLNXOMTvKL w48rV9MoJIOqth8Qg9C6yFLdRLxDna+k6gX4BFtBYvAcx3dK1cvP14Fh8NtwP0R9PqlL n2OzwDoxagNXLitLvV9HRxTstEWkapJ6NViaLwbiCXLpW/vs0fKW1uFXnXHg5ThkhZmx crgKj6ViGpTRVElXmT8gLrAzjLxl548b4LJMcf/0FeEPtKIG3Do9nTXzHEjBR4QABoTU RU4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1694093907; x=1694698707; 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=e70MoCq7qUHP1GHQpBdTh5qXfWgp4wGIIStEmlDRbWo=; b=B2HDmGLGYcas5vb3PuFrSMGO5wQ+b2adXUuICUkSXtOK8sxrBWfSeP+6FTAtl/FSDZ /TUH9npUnj6ZDmvdaR6LP/EffxQCf+k8lNQFy/1fABMIWze+vV+/IlIeH4Eh80yTLe7N 1agPt5aI7vcnU28xmAhIyCSyw0Qbjhf0j47SLrJ8jygjyVbOBG4dYY7scumJXBwYvTzX KXYoX9MUSGdnuG0tBCslJIKwdwxcq4hfsvGHq9rWaF2pdDHn048jp/IZrB/2PR9q+5IV XnFJXzYIXe+junea7SDA9m/baRal7xMFM80UE5NB1uuRq8sjU1eqXWWwHIFUW/7RF69N vRLA== X-Gm-Message-State: AOJu0Yx+OdWt/8u/HXevU7o8KQL2VG2gIKy5lv2ZO41pZWkiaQFow8D2 oR23hNU/+zzIhl1FVCDa59whyjMfIzd8kza9Og== X-Received: by 2002:adf:f149:0:b0:313:e456:e64a with SMTP id y9-20020adff149000000b00313e456e64amr4487327wro.21.1694093907425; Thu, 07 Sep 2023 06:38:27 -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.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Sep 2023 06:38:27 -0700 (PDT) From: arthur.cohen@embecosm.com To: gcc-patches@gcc.gnu.org Subject: [PATCH 04/14] rust: Implement TARGET_RUST_CPU_INFO for i[34567]86-*-* and x86_64-*-* Date: Thu, 7 Sep 2023 15:36:30 +0200 Message-ID: <20230907133729.2518969-5-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> MIME-Version: 1.0 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, KAM_SHORT, 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: arthur.cohen@embecosm.com Cc: gcc-rust@gcc.gnu.org Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776386424749488440 X-GMAIL-MSGID: 1776386424749488440 From: Iain Buclaw There are still quite a lot of the previously reverted i386-rust.cc missing, so it's only a partial reimplementation. gcc/ChangeLog: * config/i386/t-i386 (i386-rust.o): New rule. * config/i386/i386-rust.cc: New file. * config/i386/i386-rust.h: New file. --- gcc/config/i386/i386-rust.cc | 129 +++++++++++++++++++++++++++++++++++ gcc/config/i386/i386-rust.h | 22 ++++++ gcc/config/i386/t-i386 | 4 ++ 3 files changed, 155 insertions(+) create mode 100644 gcc/config/i386/i386-rust.cc create mode 100644 gcc/config/i386/i386-rust.h diff --git a/gcc/config/i386/i386-rust.cc b/gcc/config/i386/i386-rust.cc new file mode 100644 index 00000000000..a00c4f8cee1 --- /dev/null +++ b/gcc/config/i386/i386-rust.cc @@ -0,0 +1,129 @@ +/* Subroutines for the Rust front end on the x86 architecture. + Copyright (C) 2022 Free Software Foundation, Inc. + +GCC 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. + +GCC 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 GCC; see the file COPYING3. If not see +. */ + +#define IN_TARGET_CODE 1 + +#include "config.h" +#include "system.h" +#include "coretypes.h" +#include "tm.h" +#include "tm_rust.h" +#include "rust/rust-target.h" + +/* Implement TARGET_RUST_CPU_INFO for x86 targets. */ + +void +ix86_rust_target_cpu_info (void) +{ + if (TARGET_64BIT) + rust_add_target_info ("target_arch", "x86_64"); + else + rust_add_target_info ("target_arch", "x86"); + + // features officially "stabilised" in rustc + if (TARGET_MMX) + rust_add_target_info ("target_feature", "mmx"); + if (TARGET_SSE) + rust_add_target_info ("target_feature", "sse"); + if (TARGET_SSE2) + rust_add_target_info ("target_feature", "sse2"); + if (TARGET_SSE3) + rust_add_target_info ("target_feature", "sse3"); + if (TARGET_SSSE3) + rust_add_target_info ("target_feature", "ssse3"); + if (TARGET_SSE4_1) + rust_add_target_info ("target_feature", "sse4.1"); + if (TARGET_SSE4_2) + rust_add_target_info ("target_feature", "sse4.2"); + if (TARGET_AES) + rust_add_target_info ("target_feature", "aes"); + if (TARGET_SHA) + rust_add_target_info ("target_feature", "sha"); + if (TARGET_AVX) + rust_add_target_info ("target_feature", "avx"); + if (TARGET_AVX2) + rust_add_target_info ("target_feature", "avx2"); + if (TARGET_AVX512F) + rust_add_target_info ("target_feature", "avx512f"); + if (TARGET_AVX512ER) + rust_add_target_info ("target_feature", "avx512er"); + if (TARGET_AVX512CD) + rust_add_target_info ("target_feature", "avx512cd"); + if (TARGET_AVX512PF) + rust_add_target_info ("target_feature", "avx512pf"); + if (TARGET_AVX512DQ) + rust_add_target_info ("target_feature", "avx512dq"); + if (TARGET_AVX512BW) + rust_add_target_info ("target_feature", "avx512bw"); + if (TARGET_AVX512VL) + rust_add_target_info ("target_feature", "avx512vl"); + if (TARGET_AVX512VBMI) + rust_add_target_info ("target_feature", "avx512vbmi"); + if (TARGET_AVX512IFMA) + rust_add_target_info ("target_feature", "avx512ifma"); + if (TARGET_AVX512VPOPCNTDQ) + rust_add_target_info ("target_feature", "avx512vpopcntdq"); + if (TARGET_FMA) + rust_add_target_info ("target_feature", "fma"); + if (TARGET_RTM) + rust_add_target_info ("target_feature", "rtm"); + if (TARGET_SSE4A) + rust_add_target_info ("target_feature", "sse4a"); + if (TARGET_BMI) + { + rust_add_target_info ("target_feature", "bmi1"); + rust_add_target_info ("target_feature", "bmi"); + } + if (TARGET_BMI2) + rust_add_target_info ("target_feature", "bmi2"); + if (TARGET_LZCNT) + rust_add_target_info ("target_feature", "lzcnt"); + if (TARGET_TBM) + rust_add_target_info ("target_feature", "tbm"); + if (TARGET_POPCNT) + rust_add_target_info ("target_feature", "popcnt"); + if (TARGET_RDRND) + { + rust_add_target_info ("target_feature", "rdrand"); + rust_add_target_info ("target_feature", "rdrnd"); + } + if (TARGET_F16C) + rust_add_target_info ("target_feature", "f16c"); + if (TARGET_RDSEED) + rust_add_target_info ("target_feature", "rdseed"); + if (TARGET_ADX) + rust_add_target_info ("target_feature", "adx"); + if (TARGET_FXSR) + rust_add_target_info ("target_feature", "fxsr"); + if (TARGET_XSAVE) + rust_add_target_info ("target_feature", "xsave"); + if (TARGET_XSAVEOPT) + rust_add_target_info ("target_feature", "xsaveopt"); + if (TARGET_XSAVEC) + rust_add_target_info ("target_feature", "xsavec"); + if (TARGET_XSAVES) + rust_add_target_info ("target_feature", "xsaves"); + if (TARGET_VPCLMULQDQ) + { + rust_add_target_info ("target_feature", "pclmulqdq"); + rust_add_target_info ("target_feature", "vpclmulqdq"); + } + if (TARGET_CMPXCHG16B) + rust_add_target_info ("target_feature", "cmpxchg16b"); + if (TARGET_MOVBE) + rust_add_target_info ("target_feature", "movbe"); +} diff --git a/gcc/config/i386/i386-rust.h b/gcc/config/i386/i386-rust.h new file mode 100644 index 00000000000..a837e2f1c74 --- /dev/null +++ b/gcc/config/i386/i386-rust.h @@ -0,0 +1,22 @@ +/* Definitions for the Rust front end on the x86 architecture. + Copyright (C) 2022 Free Software Foundation, Inc. + +GCC 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. + +GCC 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 GCC; see the file COPYING3. If not see +. */ + +/* In i386-rust.cc */ +extern void ix86_rust_target_cpu_info (void); + +/* Target CPU info for Rust. */ +#define TARGET_RUST_CPU_INFO ix86_rust_target_cpu_info diff --git a/gcc/config/i386/t-i386 b/gcc/config/i386/t-i386 index b417c7f17ec..f85817d698c 100644 --- a/gcc/config/i386/t-i386 +++ b/gcc/config/i386/t-i386 @@ -46,6 +46,10 @@ i386-d.o: $(srcdir)/config/i386/i386-d.cc $(COMPILE) $< $(POSTCOMPILE) +i386-rust.o: $(srcdir)/config/i386/i386-rust.cc + $(COMPILE) $< + $(POSTCOMPILE) + i386-options.o: $(srcdir)/config/i386/i386-options.cc $(COMPILE) $< $(POSTCOMPILE)