[llvmlinux] Builtin: stack pointer

Jakub Jelinek jakub at redhat.com
Thu Mar 27 10:44:12 UTC 2014

On Thu, Mar 27, 2014 at 09:38:11AM +0000, Renato Golin wrote:
> There is a common pattern on bare-metal code to refer to the value of
> registers directly in a variable:
>  register unsigned long current_stack_pointer asm("sp");

I don't see what is wrong with this, this isn't inline asm, it is
the local register var GNU extension, which is far more general then this
proposal.  Using stack pointer is inherently target specific anyway, some
targets (e.g. sparc64) apply e.g. a bias to the stack pointer register,
it is unclear what this builtin would do in that case.

To me this sounds like clang proposing extensions because they aren't
willing to implement existing extensions, not a good reason to change.

> Is this something that can be done in another target-independent way?
> If not, is this something that GCC would also be willing to implement,
> so that we can replace the register/asm patterns by it? It would make
> kernel code simpler to have a single solution.

So why not the one that is used by the kernel for years?


More information about the LLVMLinux mailing list