From patchwork Mon Jun 27 21:18:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 1649114 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=NVUNqg47; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LX0wQ4xcmz9sGC for ; Tue, 28 Jun 2022 07:19:18 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 15913385E00A for ; Mon, 27 Jun 2022 21:19:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 15913385E00A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1656364756; bh=kHpBhnuu4tIBM++Xtg7riY8Tnyn5o+7W6Zdr8gKiLxE=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=NVUNqg47FCJz6O0rCWG0DpFsPcWbsOHCtqUEt1onw3MymsipuXBZ5k1gz7N3LC+1e 7SO86pMQZ7deeaC0AwALojhYWioYDHfy+yknHsugmJw8GxnhmeeRHhu1vOfjoSWjEt Ns1yOLPeyy2oYhhVogkfY6ID1DVEHuVY93IWYWWA= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pf1-x429.google.com (mail-pf1-x429.google.com [IPv6:2607:f8b0:4864:20::429]) by sourceware.org (Postfix) with ESMTPS id A152B3858D32 for ; Mon, 27 Jun 2022 21:19:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A152B3858D32 Received: by mail-pf1-x429.google.com with SMTP id k9so929888pfg.5 for ; Mon, 27 Jun 2022 14:19:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=kHpBhnuu4tIBM++Xtg7riY8Tnyn5o+7W6Zdr8gKiLxE=; b=JD4DWXCCE7u00nuL0k3wbBt2nWQDWZL6HgW7Bxma93jpX6MT9krojtKNWG1WE0cmd4 YsdYB7T/9RNateREd/AOqzcU0qAqJY9ApYaVHWl6XQ8bP7ycspe39wDtzc191d/7LIxc 6rZkxdTG1WBh3/MbtCLoWHnVYj3/rYOzSKEsdBAN78xf/EVSTbgdfomEfKqJo/5lezh1 lebaKrIR4zPjd6p2bUoR2hImjJCtBRptZmiPbkrjF4eQPN+3YZ3tSTG9EHFxDuWNSMKy IUW0RJ9uwvF5bnbxl9N1FO7xty+7ARfzycMNGPICDIpJmLi8nIuJ8KDHQaGcezaj5pCL iMPg== X-Gm-Message-State: AJIora+c7WQRA4MrIqOUOxLpjcLqHZ7WuYgxYZSCkIc0LiKUA6bRrS6B mpvrs7f7a04TbJ4/24VQMVgmLAAzHvg= X-Google-Smtp-Source: AGRyM1viYr1agnPkMMN4czPvNCByYpuvkvEKodTuVfcAE9shdZAeQ9UBKHuGyNE0nd8h5ZbREj5Vog== X-Received: by 2002:aa7:9911:0:b0:525:1bb3:965a with SMTP id z17-20020aa79911000000b005251bb3965amr17207582pff.79.1656364739572; Mon, 27 Jun 2022 14:18:59 -0700 (PDT) Received: from gnu-tgl-3.localdomain ([172.58.37.230]) by smtp.gmail.com with ESMTPSA id m19-20020a170902c45300b00163f1831ddfsm7662766plm.40.2022.06.27.14.18.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Jun 2022 14:18:59 -0700 (PDT) Received: from gnu-tgl-3.. (localhost [IPv6:::1]) by gnu-tgl-3.localdomain (Postfix) with ESMTP id 454B5C0351; Mon, 27 Jun 2022 14:18:58 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH v2 1/2] x86: Move CPU_FEATURE{S}_{USABLE|ARCH}_P to isa-level.h Date: Mon, 27 Jun 2022 14:18:57 -0700 Message-Id: <20220627211858.2807553-1-hjl.tools@gmail.com> X-Mailer: git-send-email 2.36.1 MIME-Version: 1.0 X-Spam-Status: No, score=-3027.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: "H.J. Lu via Libc-alpha" From: "H.J. Lu" Reply-To: "H.J. Lu" Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" Move X86_ISA_CPU_FEATURE_USABLE_P and X86_ISA_CPU_FEATURES_ARCH_P to where MINIMUM_X86_ISA_LEVEL and XXX_X86_ISA_LEVEL are defined. --- sysdeps/x86/isa-ifunc-macros.h | 27 --------------------------- sysdeps/x86/isa-level.h | 24 ++++++++++++++++++++++++ 2 files changed, 24 insertions(+), 27 deletions(-) diff --git a/sysdeps/x86/isa-ifunc-macros.h b/sysdeps/x86/isa-ifunc-macros.h index d69905689b..f967a1bec6 100644 --- a/sysdeps/x86/isa-ifunc-macros.h +++ b/sysdeps/x86/isa-ifunc-macros.h @@ -56,31 +56,4 @@ # define X86_IFUNC_IMPL_ADD_V1(...) #endif -/* Both X86_ISA_CPU_FEATURE_USABLE_P and X86_ISA_CPU_FEATURES_ARCH_P - macros are wrappers for the the respective - CPU_FEATURE{S}_{USABLE|ARCH}_P runtime checks. They differ in two - ways. - - 1. The USABLE_P version is evaluated to true when the feature - is enabled. - - 2. The ARCH_P version has a third argument `not`. The `not` - argument can either be '!' or empty. If the feature is - enabled above an ISA level, the third argument should be empty - and the expression is evaluated to true when the feature is - enabled. If the feature is disabled above an ISA level, the - third argument should be `!` and the expression is evaluated - to true when the feature is disabled. - */ - -#define X86_ISA_CPU_FEATURE_USABLE_P(ptr, name) \ - (((name##_X86_ISA_LEVEL) <= MINIMUM_X86_ISA_LEVEL) \ - || CPU_FEATURE_USABLE_P (ptr, name)) - - -#define X86_ISA_CPU_FEATURES_ARCH_P(ptr, name, not) \ - (((name##_X86_ISA_LEVEL) <= MINIMUM_X86_ISA_LEVEL) \ - || not CPU_FEATURES_ARCH_P (ptr, name)) - - #endif diff --git a/sysdeps/x86/isa-level.h b/sysdeps/x86/isa-level.h index 075e7c6ee1..c6156e7f7a 100644 --- a/sysdeps/x86/isa-level.h +++ b/sysdeps/x86/isa-level.h @@ -87,6 +87,30 @@ when ISA level < 3. */ #define Prefer_No_VZEROUPPER_X86_ISA_LEVEL 3 +/* Both X86_ISA_CPU_FEATURE_USABLE_P and X86_ISA_CPU_FEATURES_ARCH_P + macros are wrappers for the respective CPU_FEATURE{S}_{USABLE|ARCH}_P + runtime checks. They differ in two ways. + + 1. The USABLE_P version is evaluated to true when the feature + is enabled. + + 2. The ARCH_P version has a third argument `not`. The `not` + argument can either be `!` or empty. If the feature is + enabled above an ISA level, the third argument should be empty + and the expression is evaluated to true when the feature is + enabled. If the feature is disabled above an ISA level, the + third argument should be `!` and the expression is evaluated + to true when the feature is disabled. + */ + +#define X86_ISA_CPU_FEATURE_USABLE_P(ptr, name) \ + (((name##_X86_ISA_LEVEL) <= MINIMUM_X86_ISA_LEVEL) \ + || CPU_FEATURE_USABLE_P (ptr, name)) + +#define X86_ISA_CPU_FEATURES_ARCH_P(ptr, name, not) \ + (((name##_X86_ISA_LEVEL) <= MINIMUM_X86_ISA_LEVEL) \ + || not CPU_FEATURES_ARCH_P (ptr, name)) + #define ISA_SHOULD_BUILD(isa_build_level) \ (MINIMUM_X86_ISA_LEVEL <= (isa_build_level) && IS_IN (libc)) \ || defined ISA_DEFAULT_IMPL