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.
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);”.