From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.19]) by sourceware.org (Postfix) with ESMTPS id 8EB763829973 for ; Mon, 3 Jun 2024 15:53:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8EB763829973 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=linux.intel.com Authentication-Results: sourceware.org; spf=none smtp.mailfrom=linux.intel.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 8EB763829973 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=198.175.65.19 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1717429997; cv=none; b=norIuGEL411nYE/ox0KVwbJ5o3G3hOsPNoNY9IVbfDDM63tMOEdfFlnksmdNnzaNzPI+vrka+A7aohGNPeI2sY1Fe5MXeWzgwsCP5fggjpBxcZyfmgCV25UXCXk+BpE026+X8ugOvEky0pgF9XFxC5iDuUMw4ik3XHwv5dk155A= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1717429997; c=relaxed/simple; bh=kRGVyFrvLDzky7vWQyUOkEFImZ3/GPJs336pUSVaJ+4=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=New7M0mAjGDM+aFR8NvHAOiL6BhryC9n0H4X/moLJgV6mo5CsiBWinvlwfF1SQNFQkWS5vRlP4o/g+nI4OcLIphyqOwBgt8y5YnLDIoqjrns4ojFiqgdsOZQcLoAqG0gBs97h/23RvnUPHa/qJwcX0K50oeyl6wwsqrPMXmr7Uc= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1717429996; x=1748965996; h=date:from:to:cc:subject:message-id:references: mime-version:content-transfer-encoding:in-reply-to; bh=kRGVyFrvLDzky7vWQyUOkEFImZ3/GPJs336pUSVaJ+4=; b=V1VCK16fJtz/P9O26kJLrortb/uZpZbIWgkza4zs3mQ5xPtzl0IDCJe3 joAssjG/UP8N9nmlQyGWhgFcWAhJ6sKtD8iYwrhki5vxy2CvsfU5QATbT q40Ux8qkLYKEasVOB7VNnQRTvHkCC4LlPJqWktBuZxgpV5NmlNhJkvcuT iwD65TFKjDM/7sOZr/zvTFXJHj+QxLgpP38efpUOk6qfo1sH++0UL1VXi 2vzUcJrTieBhRKqn2lWSsJTEl11EM1nQxbvaMEgHQfZuFl8IeeW7gJMlX 5liVpRFYp2KbnqTFMIUAa5HnEg10otDbwUkV0nkqbBWwJbCKBcchzp1Uk A==; X-CSE-ConnectionGUID: 7CLL16BvT62JyfmRut4sPQ== X-CSE-MsgGUID: 17usLoZcQZWCEcnwPtEGcA== X-IronPort-AV: E=McAfee;i="6600,9927,11092"; a="13770673" X-IronPort-AV: E=Sophos;i="6.08,212,1712646000"; d="scan'208";a="13770673" Received: from fmviesa006.fm.intel.com ([10.60.135.146]) by orvoesa111.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jun 2024 08:53:15 -0700 X-CSE-ConnectionGUID: r80TKh0/RZGRKdXrbBDZ8A== X-CSE-MsgGUID: 38abtzPhTY2few4AWbqxOQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,212,1712646000"; d="scan'208";a="36938594" Received: from tassilo.jf.intel.com (HELO tassilo) ([10.54.38.190]) by fmviesa006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jun 2024 08:53:14 -0700 Date: Mon, 3 Jun 2024 08:53:12 -0700 From: Andi Kleen To: Jason Merrill Cc: gcc-patches@gcc.gnu.org, jakub@redhat.com Subject: Re: [PATCH v2 2/2] C++: Support constexpr strings for asm statements Message-ID: References: <20240603034520.1552764-1-ak@linux.intel.com> <20240603034520.1552764-2-ak@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-5.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,SPF_HELO_NONE,SPF_NONE,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 List-Id: On Mon, Jun 03, 2024 at 11:01:02AM -0400, Jason Merrill wrote: > On 6/2/24 23:45, Andi Kleen wrote: > > Some programing styles use a lot of inline assembler, and it is common > > to use very complex preprocessor macros to generate the assembler > > strings for the asm statements. In C++ there would be a typesafe alternative > > using templates and constexpr to generate the assembler strings, but > > unfortunately the asm statement requires plain string literals, so this > > doesn't work. > > > > This patch modifies the C++ parser to accept strings generated by > > constexpr instead of just plain strings. This requires new syntax > > because e.g. asm("..." : "r" (expr)) would be ambigious with a function > > call. I chose () to make it unique. For example now you can write > > > > constexpr const char *genasm() { return "insn"; } > > constexpr const char *genconstraint() { return "r"; } > > > > asm(genasm() :: (genconstraint()) (input)); > > Looks plausible. What happens when someone forgets the parens, as seems a > likely mistake? constexpr-asm-1.C:27:13: error: expected string-literal before ‘genfoo’ 27 | asm(genfoo() : genoutput() (a) : geninput() (1) : genclobber()); | ^~~~~~ Admittedly not great, I will try to give a better message. -Andi