From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 79117 invoked by alias); 6 Sep 2019 22:03:53 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 79109 invoked by uid 89); 6 Sep 2019 22:03:53 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy=Feature, HX-Languages-Length:1897, H*f:CAKwvOd, H*i:MT_ X-HELO: gate.crashing.org Received: from gate.crashing.org (HELO gate.crashing.org) (63.228.1.57) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 06 Sep 2019 22:03:51 +0000 Received: from gate.crashing.org (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.14.1) with ESMTP id x86M3mnb024175; Fri, 6 Sep 2019 17:03:48 -0500 Received: (from segher@localhost) by gate.crashing.org (8.14.1/8.14.1/Submit) id x86M3lnA024173; Fri, 6 Sep 2019 17:03:47 -0500 Date: Fri, 06 Sep 2019 22:03:00 -0000 From: Segher Boessenkool To: Nick Desaulniers Cc: Jakub Jelinek , Miguel Ojeda , Rasmus Villemoes , "maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" , LKML , "gcc-patches@gcc.gnu.org" , clang-built-linux Subject: Re: [PATCH v2 4/6] compiler-gcc.h: add asm_inline definition Message-ID: <20190906220347.GD9749@gate.crashing.org> References: <20190830231527.22304-5-linux@rasmusvillemoes.dk> <20190905134535.GP9749@gate.crashing.org> <20190906122349.GZ9749@gate.crashing.org> <20190906163028.GC9749@gate.crashing.org> <20190906163918.GJ2120@tucnak> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.2.3i X-IsSubscribed: yes X-SW-Source: 2019-09/txt/msg00429.txt.bz2 On Fri, Sep 06, 2019 at 11:14:08AM -0700, Nick Desaulniers wrote: > Here's the case that I think is perfect: > https://developers.redhat.com/blog/2016/02/25/new-asm-flags-feature-for-x86-in-gcc-6/ > > Specifically the feature test preprocessor define __GCC_ASM_FLAG_OUTPUTS__. > > See exactly how we handle it in the kernel: > - https://github.com/ClangBuiltLinux/linux/blob/0445971000375859008414f87e7c72fa0d809cf8/arch/x86/include/asm/asm.h#L112-L118 > - https://github.com/ClangBuiltLinux/linux/blob/0445971000375859008414f87e7c72fa0d809cf8/arch/x86/include/asm/rmwcc.h#L14-L30 > > Feature detection of the feature makes it trivial to detect when the > feature is supported, rather than brittle compiler version checks. > Had it been a GCC version check, it wouldn't work for clang out of the > box when clang added support for __GCC_ASM_FLAG_OUTPUTS__. But since > we had the helpful __GCC_ASM_FLAG_OUTPUTS__, and wisely based our use > of the feature on that preprocessor define, the code ***just worked*** > for compilers that didn't support the feature ***and*** compilers when > they did support the feature ***without changing any of the source > code*** being compiled. And if instead you tested whether the actual feature you need works as you need it to, it would even work fine if there was a bug we fixed that breaks things for the kernel. Without needing a new compiler. Or as another example, if we added support for some other flags. (x86 has only a few flags; many other archs have many more, and in some cases newer hardware actually has more flags than older). With the "macro" scheme we would need to add new macros in all these cases. And since those are target-specific macros, that quickly expands beyond reasonable bounds. If you want to know if you can do X in some environment, just try to do X. Segher