www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.ldc - Thread.getStackTop: use ldc.intrinsics.llvm_frameaddress?

reply "Kai Nacke" <kai redstar.de> writes:
Hi!

LLVM for PPC64 does not feature an inline assembler yet.

In a few places this hurts. One place is Thread.getStackTop(). 
Here inline assembler is used to return the stack pointer of the 
current function.

I rewrote this to use ldc.intrinsics.llvm_frameaddress for PPC64.
Now I wonder if this should not be the default implementation for 
LDC, e.g.

version (LDC)
     return ldc.intrinsics.llvm_frameaddress(0);

Does anyone have an argument against this approach?

Thanks!

Regards
Kai
Feb 17 2013
parent "David Nadlinger" <see klickverbot.at> writes:
On Sunday, 17 February 2013 at 14:54:22 UTC, Kai Nacke wrote:
 version (LDC)
     return ldc.intrinsics.llvm_frameaddress(0);

 Does anyone have an argument against this approach?
I thought about this as well some time ago, but didn't make the change because from the description, it seems like llvm.frameaddress returns EBP instead of ESP. At least if the function is not inlined, it shouldn't make any a difference, but I simply didn't have enough time for doing the amount of testing I wanted to do to be sure none of the use cases break. I'd say, make the change, see if all the test suites pass, maybe have a closer look at the getStackTop() users, and commit it if everything is okay. David
Feb 17 2013