| ARM Technical Support Knowledge Articles | |
Applies to: RealView Developer Kit (RVDK) for OKI, RealView Development Suite (RVDS)
Three new compiler intrinsics have been added into RVCT 2.0 - these are: __return_address(), __current_sp()and __current_pc(). Unfortunately, these do not appear in the compiler documentation, so are described here below:
__return_address()
Syntax:
The implicit prototype for the return address intrinsic is:
int __return_address(void)
Functionality:
__return_address() returns the value of the link register that will be used to return from the current function.
The return address intrinsic does not of itself affect the compilers ability to perform optimizations such as function inlining, tail-calling and code sharing. The value returned by __return_address() will reflect the optimizations performed.
If a function call is inlined then the value returned by __return_address() within the inlined function will be the return address for the inlined-into function.
If a function call is tail-called then the value returned by __return_address() within the called function will be the return address for the caller function.
Examples
static int foo() {
return __return_address();
}int bar() {
int i;
i = foo();
return i;
}with inlining enabled compiles to:
bar PROC
MOV r0,lr
BX lr
ENDP
with inlining disabled and tail-calling disabled compiles to:
||foo|| PROC
MOV r0,lr
BX lr
ENDP
bar PROC
STR lr,[sp,#-4]!
BL ||foo||
LDR pc,[sp],#4
ENDP
with inlining disabled and tail-calling enabled compiles to:
||foo|| PROC
MOV r0,lr
BX lr
ENDP
bar PROC
B ||foo||
ENDP
__current_sp()
Syntax:
The implicit prototype for the __current_sp intrinsic is:
int __current_sp(void)
Functionality:
__current_sp() returns the current value of the stack pointer at the point in the program where the intrinsic appears.
__current_pc()
Syntax:
The implicit prototype for the __current_pc intrinsic is:
int __current_pc(void)
Functionality:
__current_pc() returns the current value of the program counter at the point in the program where the intrinsic appears.
Article last edited on: 2008-09-09 15:47:31
Did you find this article helpful? Yes No
How can we improve this article?