[dmd-internals] Help with dl_* functions in DMD

Jacob Carlborg via dmd-internals dmd-internals at puremagic.com
Mon Dec 28 04:29:41 PST 2015


> On 27 dec 2015, at 22:33, Martin Nowak via dmd-internals <dmd-internals at puremagic.com> wrote:
> 
> What do you want to achieve?

My overall goal is to implement native TLS on OS X in DMD. For this particular question I was trying to figure out how to get DMD to generate same assembly as the corresponding D code, when a TLS variable is accessed, using the el_* functions.

auto foo = *bar.thunk(&bar);

> In general specific instructions such as
> for TLS access should be implemented by the corresponding cd* function,
> not in the intermediate representation.
> The IR might be the right place for a low-level lowering though.

It looks like the lowering for a TLS variable access to a call to ___tls_get_addr occurs in el_picvar for OS X.

> The simply construct an IR tree, no magic here.


You make it sound so easy :). I guess my main problem is that I’m reading the assembly that Clang outputs then I have no idea how to get DMD to generate the same assembly.

Anyway, I think I managed to figure it out, this seems to work [1]. I basically traced all the el_* functions to see which were called and with what arguments when I compiled D code looking something like "auto foo = *bar.thunk(&bar);”.

[1] https://github.com/jacob-carlborg/dmd/commit/49ecd3ff7861e2eb5838e2b2cd14b18f7fe2e07b

-- 
/Jacob Carlborg
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/dmd-internals/attachments/20151228/1c908a63/attachment.html>


More information about the dmd-internals mailing list