This patch implements builtin_arm_current_sp and builtin_arm_current_pc.
__builtin_arm_current_sp is also implemented for AArch64
Details
Diff Detail
Event Timeline
Hi Weiming,
We've discussed about creating builtins when I added support for named registers and the consensus was that, since there is already a way to access them, there is no point in adding a new builtin.
cheers,
--renato
I agree with Renato too.
It seems like, as a compiler, we can provide virtually no guarantees about the value of __builtin_arm_current_pc: it's not necessarily in the PC-range of the dynamically innermost frame (inlining); it's not necessarily even in the callstack at all (you actually get PC+8 or PC+4).
About the only feasible use-case is a some kind of panic/abort implementation best-effort. And at that point you'll want r0-r14 as well.
Tim.
Hi Tim/Renato,
On a similar note, I have a patch which adds the breakpoint intrinsic (for ARM and Thumb):
http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0491c/CJAHBCFH.html
Could you please let me know if this is something which the community would like to support. I can then push my patch.
Here are two other intrinsics which I wanted to implement:
enable_irq: http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0472m/chr1359124996163.html
disable_irq: http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0472m/chr1359125001077.html
The use case for these intrinsics is a customer who makes calls to __builtin_arm_breakpoint (and others) in their code base. Currently they compile with ARMCC, but LLVM does not have these intrinsics. So porting the code to build with LLVM becomes a hassle.
To facilitate customers to switch to LLVM we wanted to implement these intrinsics.
Thanks,
Mandeep
Hi Mandeep,
I don't think we should be implementing old ARMCC intrinsics either. GCC doesn't, especially since most of them are easy to do with one line inline assembly snippets.
Those intrinsics are not covered by the ACLE (mentioned, but not defined), which reinforces the notion that we shouldn't be doing anyway.
cheers,
--renato
Thanks Renato for your comments. I guess I will not upstream my patches then.
--Mandeep