Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp6016071ybf; Thu, 5 Mar 2020 11:23:12 -0800 (PST) X-Google-Smtp-Source: ADFU+vs3mEV0iXY9lbSAjc4mD8wKtNZRvDLIp1ruHjBccXQAZBfDccmL8XmOdarPhZRHdu8JQfyL X-Received: by 2002:a9d:7b4c:: with SMTP id f12mr8043909oto.345.1583436192379; Thu, 05 Mar 2020 11:23:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583436192; cv=none; d=google.com; s=arc-20160816; b=SWeeoKReenr6FXXbBnsLchN0H9nOQsZGkxrQC8Op55aPtry+ZJAF64V0MbG17l7M09 y91CKww3uRg+riNt7QkhlUNQLK/nDS6ivmgyL7ltYNeiyGf3w0U2M1idJqR6qVSYyUZx 7GnH5Q/qR8NF4UAdgZ9tJhy1I+qFAPF7NYxIbZM2bYsBx/i4JNDLK98LJ5NeS3CtzwSZ MPXxkys8rqcxlaeHvN3fbLZD0euT4DjTsveNj6iFSOhmnnY8s+iSe9/z+rQb3Xm/xLrF RfTNzwjHvy8iz8vcFsa1jW8jwvr3cGttyMPuYDe6GbqtP8zzmryTHqU95uicI8ISzqj7 01fA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=RO5gvj1Liy8kmn7CzB4KrBoJkAWMSsWwG2gNJleeRn4=; b=oAuIITlA92qFl2vuc92PXW9Cr3AlNlxS444p6vaFsVn+840Gvb6fvUFlqs3auXlalU oSI6kG+OWWmGWuMkc9YRNMLo/p54R3yS1roiQQ/ED17mxAR+o5UIqubGtIFTatywlcEe Oh9WD9idNtmYzr0uUQwR0KJZQpEk3UrmxJqMXsLACkecSiQLSuGvYIDz+L29GaumeP0r YbUHnms4nPg6E8QhVakf1uLmzJ4T8HPWh7D008gfAjFt+5GMDC7dSwbfEODqHuFQyJCF pZOpkX3QFCaQ1g0lJDwK0DVw6yIgsgK3d9wwOyALARQBMUB1BDBbiTQf7vC8l11GAar7 IU5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=ktKab+fi; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b68si3759198oii.117.2020.03.05.11.23.00; Thu, 05 Mar 2020 11:23:12 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=ktKab+fi; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726004AbgCETVY (ORCPT + 99 others); Thu, 5 Mar 2020 14:21:24 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:53596 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725946AbgCETVX (ORCPT ); Thu, 5 Mar 2020 14:21:23 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=RO5gvj1Liy8kmn7CzB4KrBoJkAWMSsWwG2gNJleeRn4=; b=ktKab+fi0a2dSiYwui7V18dNHO zdB8QStI67sqFG7m7lsaWAJakpXaF8ojYlz2BRmRewrH5m1zjwPnzTLELx5ALO8pgqfNXL4gvigVB 28aZZ9STgDEhS+Uoi2wNpfKXQwqN+MzcIBXDmvHWTGV43vl33yrxrLtib9HxdXMCdmR8J1dtXcYIm uvJdeAzvp+3oVdLLCuaQ4rgZfT5XVd9GhaBNvx46gYskB2eKSIs+0ePVDOyqgcz8wJg8+O5Gl3Q1y wdJpGqpjL9U/AiDgejiMQOHlgW9r8hmjjTMjO8MNXpesrC3PmcLbSnPiwfQEHVLXvxsNkry1cPxG0 3NHCqq0A==; Received: from willy by bombadil.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1j9w3f-0000R1-4G; Thu, 05 Mar 2020 19:21:23 +0000 Date: Thu, 5 Mar 2020 11:21:23 -0800 From: Matthew Wilcox To: Alexey Dobriyan Cc: torvalds@linux-foundation.org, corbet@lwn.net, linux-kernel@vger.kernel.org, linux-arch@vger.kernel, linux-doc@vger.kernel.org, x86@kernel.org Subject: Re: [PATCH] doc: code generation style Message-ID: <20200305192123.GN29971@bombadil.infradead.org> References: <20200305190253.GA28787@avx2> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200305190253.GA28787@avx2> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 05, 2020 at 10:02:53PM +0300, Alexey Dobriyan wrote: > I wonder if it would be useful to have something like this in tree. > > It states trivial things for anyone who looked at disassembly few times > but still... It's a bit x86-specific, and it ignores things which matter more like paying attention to cacheline boundaries in structures. I'm also not convinced that those who come after us in ten years and have to widen everything from int to long will thank us for saving a few bytes of Icache. > +.. code-block:: c > + > + int g(int, int, flag_t); > + int f(int a, int b) > + { > + return g(a, b, FLAG_C); > + } > + > +Appending an argument at the end adds minimum amount of code: > + > +.. code-block:: none > + > + f: > + mov edx, FLAG_C > + jmp g > + > +Appending an argument in the middle or in the beginning will generate > +reshuffle sequence: > + > +.. code-block:: none > + > + f: > + mov edx, esi > + mov esi, edi > + mov edi, FLAG_C > + jmp g But if f is static inline, then it makes no difference at all. > +Constants which don't fit into 12-bit window on arm will be loaded from memory > +or constructed with 2 loads: The 12-bit window on ARM is 8 bits rotated by a power of 4. So for example, 0xc000003f is a valid constant, but 0x000001f7 is not. I don't know what arm64 does for constants.