www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - TypeTuple ABI mangling

reply "Iain Buclaw" <ibuclaw gdcproject.org> writes:
Hi,

TypeTuples have a special mangling convention in the compiler.

As per the docs (ref: http://dlang.org/abi.html)

TypeTuple:
     B Number Arguments


However after some cursory tests, it seems that the most obvious 
examples of, passing a tuple via parameters, returning a tuple, 
declaring a tuple variable, etc... all get lowered before 
mangling.

So at first glance, this mangling convention is redundant.

Unless of course someone can post an example which triggers 
mangling of TypeTuples...

Regards
Iain.
Jul 26 2014
next sibling parent "Iain Buclaw" <ibuclaw gdcproject.org> writes:
On Saturday, 26 July 2014 at 19:44:49 UTC, Iain Buclaw wrote:
 Hi,

 TypeTuples have a special mangling convention in the compiler.

 As per the docs (ref: http://dlang.org/abi.html)

 TypeTuple:
     B Number Arguments


 However after some cursory tests, it seems that the most 
 obvious examples of, passing a tuple via parameters, returning 
 a tuple, declaring a tuple variable, etc... all get lowered 
 before mangling.

 So at first glance, this mangling convention is redundant.

 Unless of course someone can post an example which triggers 
 mangling of TypeTuples...
NB. This is purely for the purpose of demangling in binutils.
Jul 26 2014
prev sibling next sibling parent "Dicebot" <public dicebot.lv> writes:
On Saturday, 26 July 2014 at 19:44:49 UTC, Iain Buclaw wrote:
 Hi,

 TypeTuples have a special mangling convention in the compiler.

 As per the docs (ref: http://dlang.org/abi.html)

 TypeTuple:
     B Number Arguments
This is.. funny. Type tuples don't really have ABI, they don't even have .sizeof - any usage where expansion is meaningless results in compile-time error afaik. No idea what this may mean :O
Jul 26 2014
prev sibling next sibling parent "H. S. Teoh via Digitalmars-d" <digitalmars-d puremagic.com> writes:
On Sat, Jul 26, 2014 at 07:44:47PM +0000, Iain Buclaw via Digitalmars-d wrote:
 Hi,
 
 TypeTuples have a special mangling convention in the compiler.
 
 As per the docs (ref: http://dlang.org/abi.html)
 
 TypeTuple:
     B Number Arguments
 
 
 However after some cursory tests, it seems that the most obvious examples
 of, passing a tuple via parameters, returning a tuple, declaring a tuple
 variable, etc... all get lowered before mangling.
 
 So at first glance, this mangling convention is redundant.
 
 Unless of course someone can post an example which triggers mangling
 of TypeTuples...
[...] Huh, interesting. I tried various wrapping/unwrapping tricks and passing things via alias parameters, but none of them triggered TypeTuple mangling. Either I missed something obvious, or perhaps this mangling is never actually emitted? Not sure. T -- It won't be covered in the book. The source code has to be useful for something, after all. -- Larry Wall
Jul 26 2014
prev sibling next sibling parent Iain Buclaw via Digitalmars-d <digitalmars-d puremagic.com> writes:
On 26 July 2014 21:06, H. S. Teoh via Digitalmars-d
<digitalmars-d puremagic.com> wrote:
 On Sat, Jul 26, 2014 at 07:44:47PM +0000, Iain Buclaw via Digitalmars-d wrote:
 Hi,

 TypeTuples have a special mangling convention in the compiler.

 As per the docs (ref: http://dlang.org/abi.html)

 TypeTuple:
     B Number Arguments


 However after some cursory tests, it seems that the most obvious examples
 of, passing a tuple via parameters, returning a tuple, declaring a tuple
 variable, etc... all get lowered before mangling.

 So at first glance, this mangling convention is redundant.

 Unless of course someone can post an example which triggers mangling
 of TypeTuples...
[...] Huh, interesting. I tried various wrapping/unwrapping tricks and passing things via alias parameters, but none of them triggered TypeTuple mangling. Either I missed something obvious, or perhaps this mangling is never actually emitted? Not sure.
I've tried something similar using D1 too, and get the same results. I'd be willing to do an experiment and remove TypeTuple mangling from the language by force and see what ICE's.
Jul 26 2014
prev sibling next sibling parent Iain Buclaw via Digitalmars-d <digitalmars-d puremagic.com> writes:
On 27 July 2014 00:20, Iain Buclaw <ibuclaw gdcproject.org> wrote:
 On 26 July 2014 21:06, H. S. Teoh via Digitalmars-d
 <digitalmars-d puremagic.com> wrote:
 On Sat, Jul 26, 2014 at 07:44:47PM +0000, Iain Buclaw via Digitalmars-d wrote:
 Hi,

 TypeTuples have a special mangling convention in the compiler.

 As per the docs (ref: http://dlang.org/abi.html)

 TypeTuple:
     B Number Arguments


 However after some cursory tests, it seems that the most obvious examples
 of, passing a tuple via parameters, returning a tuple, declaring a tuple
 variable, etc... all get lowered before mangling.

 So at first glance, this mangling convention is redundant.

 Unless of course someone can post an example which triggers mangling
 of TypeTuples...
[...] Huh, interesting. I tried various wrapping/unwrapping tricks and passing things via alias parameters, but none of them triggered TypeTuple mangling. Either I missed something obvious, or perhaps this mangling is never actually emitted? Not sure.
I've tried something similar using D1 too, and get the same results. I'd be willing to do an experiment and remove TypeTuple mangling from the language by force and see what ICE's.
I changed Ttuple = 'B' to Ttuple = ' ' and waited for assembly errors to happen. Finally got them when compiling std.outbuffer unittests. Reducing....
Jul 27 2014
prev sibling next sibling parent Iain Buclaw via Digitalmars-d <digitalmars-d puremagic.com> writes:
On 27 July 2014 08:14, Iain Buclaw <ibuclaw gdcproject.org> wrote:
 On 27 July 2014 00:20, Iain Buclaw <ibuclaw gdcproject.org> wrote:
 On 26 July 2014 21:06, H. S. Teoh via Digitalmars-d
 <digitalmars-d puremagic.com> wrote:
 On Sat, Jul 26, 2014 at 07:44:47PM +0000, Iain Buclaw via Digitalmars-d wrote:
 Hi,

 TypeTuples have a special mangling convention in the compiler.

 As per the docs (ref: http://dlang.org/abi.html)

 TypeTuple:
     B Number Arguments


 However after some cursory tests, it seems that the most obvious examples
 of, passing a tuple via parameters, returning a tuple, declaring a tuple
 variable, etc... all get lowered before mangling.

 So at first glance, this mangling convention is redundant.

 Unless of course someone can post an example which triggers mangling
 of TypeTuples...
[...] Huh, interesting. I tried various wrapping/unwrapping tricks and passing things via alias parameters, but none of them triggered TypeTuple mangling. Either I missed something obvious, or perhaps this mangling is never actually emitted? Not sure.
I've tried something similar using D1 too, and get the same results. I'd be willing to do an experiment and remove TypeTuple mangling from the language by force and see what ICE's.
I changed Ttuple = 'B' to Ttuple = ' ' and waited for assembly errors to happen. Finally got them when compiling std.outbuffer unittests. Reducing....
Ah ha! D-style native varargs use them! void printf(...) { } void main() { printf; // printf(_arguments_typeinfo); } Here, the _arguments_typeinfo is a TypeInfo_Tuple. Regards Iain.
Jul 27 2014
prev sibling parent Iain Buclaw via Digitalmars-d <digitalmars-d puremagic.com> writes:
On 27 July 2014 08:22, Iain Buclaw <ibuclaw gdcproject.org> wrote:
 On 27 July 2014 08:14, Iain Buclaw <ibuclaw gdcproject.org> wrote:
 On 27 July 2014 00:20, Iain Buclaw <ibuclaw gdcproject.org> wrote:
 On 26 July 2014 21:06, H. S. Teoh via Digitalmars-d
 <digitalmars-d puremagic.com> wrote:
 On Sat, Jul 26, 2014 at 07:44:47PM +0000, Iain Buclaw via Digitalmars-d wrote:
 Hi,

 TypeTuples have a special mangling convention in the compiler.

 As per the docs (ref: http://dlang.org/abi.html)

 TypeTuple:
     B Number Arguments


 However after some cursory tests, it seems that the most obvious examples
 of, passing a tuple via parameters, returning a tuple, declaring a tuple
 variable, etc... all get lowered before mangling.

 So at first glance, this mangling convention is redundant.

 Unless of course someone can post an example which triggers mangling
 of TypeTuples...
[...] Huh, interesting. I tried various wrapping/unwrapping tricks and passing things via alias parameters, but none of them triggered TypeTuple mangling. Either I missed something obvious, or perhaps this mangling is never actually emitted? Not sure.
I've tried something similar using D1 too, and get the same results. I'd be willing to do an experiment and remove TypeTuple mangling from the language by force and see what ICE's.
I changed Ttuple = 'B' to Ttuple = ' ' and waited for assembly errors to happen. Finally got them when compiling std.outbuffer unittests. Reducing....
Ah ha! D-style native varargs use them! void printf(...) { } void main() { printf; // printf(_arguments_typeinfo); } Here, the _arguments_typeinfo is a TypeInfo_Tuple.
Inspecting the resultant mangled identifier itself though, the tuple part will never get demangled. _D15TypeInfo_B4iiii6__initZ Meaning that I'm back at demangling tuple being pointless because it will never be reached.
Jul 27 2014