All of lore.kernel.org
 help / color / mirror / Atom feed
From: "H. Peter Anvin" <hpa@zytor.com>
To: Jeremy Fitzhardinge <jeremy@goop.org>
Cc: Ramkumar Ramachandra <artagnon@gmail.com>,
	LKML <linux-kernel@vger.kernel.org>,
	Andi Kleen <ak@linux.intel.com>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Ingo Molnar <mingo@kernel.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Eli Friedman <eli.friedman@gmail.com>,
	Jim Grosbach <grosbach@apple.com>,
	Stephen Checkoway <s@pahtak.org>, LLVMdev <llvmdev@cs.uiuc.edu>
Subject: Re: [PATCH] x86/asm: avoid mnemonics without type suffix
Date: Mon, 15 Jul 2013 11:47:09 -0700	[thread overview]
Message-ID: <51E443AD.3020907@zytor.com> (raw)
In-Reply-To: <51E2FAB9.9050900@goop.org>

On 07/14/2013 12:23 PM, Jeremy Fitzhardinge wrote:
> (resent without HTML)
> 
> On 07/14/2013 05:56 AM, Ramkumar Ramachandra wrote:
>> 1c54d77 (x86: partial unification of asm-x86/bitops.h, 2008-01-30)
>> changed a bunch of btrl/btsl instructions to btr/bts, with the following
>> justification:
>>
>>   The inline assembly for the bit operations has been changed to remove
>>   explicit sizing hints on the instructions, so the assembler will pick
>>   the appropriate instruction forms depending on the architecture and
>>   the context.
>>
>> Unfortunately, GNU as does no such thing, and the AT&T syntax manual
>> [1] contains no references to any such inference.  As evidenced by the
>> following experiment, gas always disambiguates btr/bts to btrl/btsl.
>> Feed the following input to gas:
>>
>>   btrl	$1, 0
>>   btr	$1, 0
>>   btsl	$1, 0
>>   bts	$1, 0
> 
> When I originally did those patches, I was careful make sure that we
> didn't give implied sizes to operations with only immediate and/or
> memory operands because - in general - gas can't infer the operation
> size from such operands. However, in the case of the bit test/set
> operations, the memory access size is not really derived from the
> operation size (the SDM is a bit vague), and even if it were it would be
> an operation rather than semantic difference.  So there's no real
> problem with gas choosing 'l' as a default size in the absence of any
> explicit override or constraint.
> 
>> Check that btr matches btrl, and bts matches btsl in both cases:
>>
>>   $ as --32 -a in.s
>>   $ as --64 -a in.s
>>
>> To avoid giving readers the illusion of such an inference, and for
>> clarity, change btr/bts back to btrl/btsl.  Also, llvm-mc refuses to
>> disambiguate btr/bts automatically.
> 
> That sounds reasonable for all other operations because it makes a real
> semantic difference, but overly strict for bit operations.
> 

To be fair, we *ought to* be able to do something like:

	asm volatile(LOCK_PREFIX "bts%z0 %1,%0"
 			: BITOP_ADDR(addr) : "Ir" (nr) : "memory");

... but some older version of gcc are broken and emit "ll" rather than
"q".  Furthermore, since that would actually result in *worse* code
emitted overall (unnecessary REX prefixes), I'm not exactly happy on the
idea.

	-hpa


  parent reply	other threads:[~2013-07-15 18:53 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-14 12:56 [PATCH] x86/asm: avoid mnemonics without type suffix Ramkumar Ramachandra
2013-07-14 17:19 ` Linus Torvalds
2013-07-14 18:26   ` Ramkumar Ramachandra
2013-07-14 18:34     ` Linus Torvalds
2013-07-14 18:49       ` Ramkumar Ramachandra
2013-07-14 18:35   ` [LLVMdev] " Tim Northover
2013-07-14 19:09     ` Linus Torvalds
2013-07-14 19:30       ` Tim Northover
2013-07-14 19:41         ` Jeremy Fitzhardinge
2013-07-14 19:49         ` Linus Torvalds
2013-07-15 18:40           ` H. Peter Anvin
2013-07-15 18:56             ` Linus Torvalds
2013-07-15 19:00               ` H. Peter Anvin
2013-07-15 19:00               ` Linus Torvalds
2013-07-14 19:23   ` Jeremy Fitzhardinge
2013-07-14 19:29     ` Linus Torvalds
2013-07-15 18:40     ` H. Peter Anvin
2013-07-14 19:23 ` Jeremy Fitzhardinge
2013-07-14 21:14   ` Andi Kleen
2013-07-15 18:42     ` H. Peter Anvin
2013-07-15 18:47   ` H. Peter Anvin [this message]
2013-07-15 18:58     ` Linus Torvalds

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=51E443AD.3020907@zytor.com \
    --to=hpa@zytor.com \
    --cc=ak@linux.intel.com \
    --cc=artagnon@gmail.com \
    --cc=eli.friedman@gmail.com \
    --cc=grosbach@apple.com \
    --cc=jeremy@goop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=llvmdev@cs.uiuc.edu \
    --cc=mingo@kernel.org \
    --cc=s@pahtak.org \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.