*
*Home|Chinese|Japanese*About ARM|Forums|Events|News|Employment|Contact Us|Investors*
dotted rule
*ARM - the architecture for the digital worldARM - the architecture for the digital world
search
*
*
***
*MARKETS:PRODUCTS & SOLUTIONS:CONNECTED COMMUNITY:TECHNICAL SUPPORT:DOCUMENTATION*
*
technical support
*
*
****
*.Technical Support
*
*
*>>Home Page*
*
*.Obtaining Support*
*
*.FAQs*
*
**Development Tool FAQs*
**IP FAQs*
**Embedded Software FAQs*
**Artisan Physical IP FAQs (Login Required)*
*
*.Downloads*
*
*.Documentation*
*
*.Training*
*
*.Where To Buy*
*
*.Keil MCU Tools*
*
*.What's New*
*
*.ARM Newsgroups*
*
*
*
technical support FAQsask ARM*
*

Technical Support Search
*     (Advanced Search)
  FAQs   Documentation   Downloads   Forums

*

 
downarrowNew compiler intrinsics: __return_address(), __current_sp(), __current_pc()
Applies to: Compilers, RealView Developer Kit (RVDK) for OKI , RealView Developer Suite (RVDS) 2.0

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:

  1. __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
  2. __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.

  3. __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.






back to top

*
**
*4 dots*Other ARM Websites | Help with Accessibility
*
shadow *LEGAL STATEMENTshadow