From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate.crashing.org (gate.crashing.org [63.228.1.57]) by sourceware.org (Postfix) with ESMTP id 45FA13858D1E for ; Fri, 5 Jan 2024 18:47:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 45FA13858D1E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=kernel.crashing.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=kernel.crashing.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 45FA13858D1E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=63.228.1.57 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704480435; cv=none; b=H3UIgb1Fvtk5OOv5LWGPpjlHk8Yu8iqL9y2ZlQCwIuxTZU3Pf9O1C0FajelAdJCYgoYPI2kLpik0APcS2a635DHT/3UsRqMG3QnAkLwJGv1cuWhmbmHbC7Fv85vZLXrdRHVrxo3ne4dyDI6N4cmONybxs+tL1ZMERhY5HcKUMZE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704480435; c=relaxed/simple; bh=Mddcf/XZf9o+zKrcFuBpg4Y4jZLelRxkZ647B33DVHc=; h=Date:From:To:Subject:Message-ID:Mime-Version; b=axvV+000diJEkga1ATJb7OqinqIyeLTrof4Kwaj6b2EBuKHj3ycEa9HnDRjdgCHirMLSYi+VileF8jjtWbXm2ANo5bYzsBEx+rBdVDKdr7w+yedVPCT2rrX9GowgxuCDeYZ2d/qz/33UeNDsZoULOS6ZlxwpNMCmhbDz6lpDHcs= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from gate.crashing.org (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.14.1) with ESMTP id 405IkD7o032362; Fri, 5 Jan 2024 12:46:13 -0600 Received: (from segher@localhost) by gate.crashing.org (8.14.1/8.14.1/Submit) id 405IkDaC032361; Fri, 5 Jan 2024 12:46:13 -0600 X-Authentication-Warning: gate.crashing.org: segher set sender to segher@kernel.crashing.org using -f Date: Fri, 5 Jan 2024 12:46:12 -0600 From: Segher Boessenkool To: David Brown Cc: gcc-help@gcc.gnu.org Subject: Re: Odd error with the "X" inline assembly constraint Message-ID: <20240105184612.GE19790@gate.crashing.org> References: 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-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,JMQ_SPF_NEUTRAL,KAM_DMARC_STATUS,SPF_HELO_PASS,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Fri, Jan 05, 2024 at 05:30:51PM +0100, David Brown via Gcc-help wrote: > However, when I use just "asm ("" : "+X" (x));", I get an error message > "error: inconsistent operand constraints in an 'asm'". I have no idea > why this is an issue. The C constraint means "Any operand whatsoever is allowed." Here you are saying to use it both as input and as output, and GCC does not know how to reload wherever it chose to put it. Using "X" for outputs is strange already, fwiw, but tieing it to an input is, hrm, let's call it "creative" :-) > I'd imagine that the "X" operand doesn't see much use in real inline > assembly It is used rather often. But usually for inputs, and (as you found out) trying to use if for an input and for an output at the same time does not work reliably. "+" really creates two operands, and ties them together. Writing asm("oink" : "+X"(bla)); is shorthand for asm("oink" : "=X"(bla) : "0"(bla)); Segher