220 39 <b870c8ef-a7ba-4347-b2c8-e1c6246d6582@isocpp.org> article
Path: news.gmane.org!not-for-mail
From: stackmachine@hotmail.com
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Allowing constexpr char[]'s in asm directives
Date: Sun, 11 Nov 2012 07:02:04 -0800 (PST)
Lines: 100
Approved: news@gmane.org
Message-ID: <b870c8ef-a7ba-4347-b2c8-e1c6246d6582@isocpp.org>
References: <27482d3f-117d-4913-b1ff-feb6267760f3@isocpp.org>
 <509DFF12.9060206@gmx.net>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; 
	boundary="----=_Part_324_26262145.1352646124819"
X-Trace: ger.gmane.org 1352646127 20319 80.91.229.3 (11 Nov 2012 15:02:07 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Sun, 11 Nov 2012 15:02:07 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBDC7BQ4GSIMRB3P372CAKGQEX5CLIUA@isocpp.org Sun Nov 11 16:02:18 2012
Return-path: <std-proposals+bncBDC7BQ4GSIMRB3P372CAKGQEX5CLIUA@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-yh0-f70.google.com ([209.85.213.70])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBDC7BQ4GSIMRB3P372CAKGQEX5CLIUA@isocpp.org>)
	id 1TXZ3A-0007SC-2t
	for gclcip-std-proposals@m.gmane.org; Sun, 11 Nov 2012 16:02:16 +0100
Original-Received: by mail-yh0-f70.google.com with SMTP id o21sf9343894yho.9
        for <gclcip-std-proposals@m.gmane.org>; Sun, 11 Nov 2012 07:02:06 -0800 (PST)
Original-Received: by 10.236.193.73 with SMTP id j49mr11878126yhn.7.1352646126061;
        Sun, 11 Nov 2012 07:02:06 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.236.114.196 with SMTP id c44ls8230643yhh.7.gmail; Sun, 11 Nov
 2012 07:02:05 -0800 (PST)
Original-Received: by 10.236.149.66 with SMTP id w42mr2139426yhj.18.1352646125716;
        Sun, 11 Nov 2012 07:02:05 -0800 (PST)
In-Reply-To: <509DFF12.9060206@gmx.net>
X-Original-Sender: stackmachine@hotmail.com
Precedence: list
Mailing-list: list std-proposals@isocpp.org; contact std-proposals+owners@isocpp.org
List-ID: <std-proposals.isocpp.org>
X-Google-Group-Id: 399137483710
List-Post: <http://groups.google.com/a/isocpp.org/group/std-proposals/post?hl=en>,
 <mailto:std-proposals@isocpp.org>
List-Help: <http://support.google.com/a/isocpp.org/bin/topic.py?hl=en&topic=25838>,
 <mailto:std-proposals+help@isocpp.org>
List-Archive: <http://groups.google.com/a/isocpp.org/group/std-proposals/?hl=en>
List-Subscribe: <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe?hl=en>,
 <mailto:std-proposals+subscribe@isocpp.org>
List-Unsubscribe: <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe?hl=en>,
 <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:39
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/39>

------=_Part_324_26262145.1352646124819
Content-Type: text/plain; charset=ISO-8859-1



Am Samstag, 10. November 2012 08:16:19 UTC+1 schrieb Jens Maurer:
>
> On 11/10/2012 02:15 AM, stackm...@hotmail.com <javascript:> wrote: 
> > Simple feature: Allow the use of compiletime constant strings in asm 
> directives. That would allow generating asm through template-meta programs. 
> Wouldn't that be damn awesome? 
>
> Could you provide an example program that makes use of such a 
> feature in a non-trivial way, including the generation of 
> the compile-time constant strings?  In which way would the 
> portability of that program be improved if the standard 
> would prescribe the feature you're proposing? 
>
The program would not neccessarily be more portable but it would allow (for 
example) simple abstractions around common patterns, such as loops, 
conditions, or function calls.
Here's a simple example of how this could be used:

typedef function<stdcall, "print_int"> print_int; // assuming that string 
literals could be used as template parameters in the future
typedef for_from_to<1, 10, call<print_int>> print_1_to_10;

asm(generate_asm<x86_64, print_1_to_10>::value::c_str);

::value might be some compiletime string type, which itself holds a 
constexpr char[] ::c_str.
Now I do admit that this example might not be the best, but it demonstrates 
one important aspect of this feature: The programmer does not have to deal 
with details, such as calling conventions, as this is handled by the 
library that generates the code.
 

> The current standard doesn't say a lot about "asm" (see section 7.4), 
> except that its argument must be a string-literal.  And even then, 
> the entire asm is conditionally-supported, meaning an implementation 
> can simply refuse an "asm" with an error message (and not implement it).
>
Instead of only allowing string literals, I propose to allow constant 
string expressions. This would only require a change to the grammar AFAIK. 
(?)

-- 




------=_Part_324_26262145.1352646124819
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<br><br>Am Samstag, 10. November 2012 08:16:19 UTC+1 schrieb Jens Maurer:<b=
lockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;borde=
r-left: 1px #ccc solid;padding-left: 1ex;">On 11/10/2012 02:15 AM, <a href=
=3D"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"pkN49n5U4rIJ">s=
tackm...@hotmail.com</a> wrote:
<br>&gt; Simple feature: Allow the use of compiletime constant strings in a=
sm directives. That would allow generating asm through template-meta progra=
ms. Wouldn't that be damn awesome?
<br>
<br>Could you provide an example program that makes use of such a
<br>feature in a non-trivial way, including the generation of
<br>the compile-time constant strings? &nbsp;In which way would the
<br>portability of that program be improved if the standard
<br>would prescribe the feature you're proposing?
<br></blockquote><div>The program would not neccessarily be more portable b=
ut it would allow (for example) simple abstractions around common patterns,=
 such as loops, conditions, or function calls.<br>Here's a simple example o=
f how this could be used:<br><br>typedef function&lt;stdcall, "print_int"&g=
t; print_int; // assuming that string literals could be used as template pa=
rameters in the future<br>typedef for_from_to&lt;1, 10, call&lt;print_int&g=
t;&gt; print_1_to_10;<br><br>asm(generate_asm&lt;x86_64, print_1_to_10&gt;:=
:value::c_str);<br><br>::value might be some compiletime string type, which=
 itself holds a constexpr char[] ::c_str.<br>Now I do admit that this examp=
le might not be the best, but it demonstrates one important aspect of this =
feature: The programmer does not have to deal with details, such as calling=
 conventions, as this is handled by the library that generates the code.<br=
></div><div>&nbsp;<br></div><blockquote class=3D"gmail_quote" style=3D"marg=
in: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">Th=
e current standard doesn't say a lot about "asm" (see section 7.4),
<br>except that its argument must be a string-literal. &nbsp;And even then,
<br>the entire asm is conditionally-supported, meaning an implementation
<br>can simply refuse an "asm" with an error message (and not implement it)=
..<br></blockquote><div>Instead of only allowing string literals, I propose =
to allow constant string expressions. This would only require a change to t=
he grammar AFAIK. (?)<br></div>

<p></p>

-- <br />
&nbsp;<br />
&nbsp;<br />
&nbsp;<br />

------=_Part_324_26262145.1352646124819--

.
