Next: Xtensa Immediate Relaxation, Previous: Xtensa Call Relaxation, Up: Xtensa Relaxation [Contents][Index]

#### 9.55.4.3 Jump Relaxation

Jump instruction may require relaxation because the Xtensa jump instruction (`J`) provide a PC-relative offset of only 128 Kbytes in either direction. One option is to use jump long (`J.L`) instruction, which depending on jump distance may be assembled as jump (`J`) or indirect jump (`JX`). However it needs a free register. When there’s no spare register it is possible to plant intermediate jump sites (trampolines) between the jump instruction and its target. These sites may be located in areas unreachable by normal code execution flow, in that case they only contain intermediate jumps, or they may be inserted in the middle of code block, in which case there’s an additional jump from the beginning of the trampoline to the instruction past its end. So, for example:

        j 1f
        ...
        retw
        ...
        mov a10, a2
        call8 func
        ...
    1:
        ...

might be relaxed to:

        j .L0_TR_1
        ...
        retw
    .L0_TR_1:
        j 1f
        ...
        mov a10, a2
        call8 func
        ...
    1:
        ...

or to:

        j .L0_TR_1
        ...
        retw
        ...
        mov a10, a2
        j .L0_TR_0
    .L0_TR_1:
        j 1f
    .L0_TR_0:
        call8 func
        ...
    1:
        ...

The Xtensa assembler uses trampolines with jump around only when it cannot find suitable unreachable trampoline. There may be multiple trampolines between the jump instruction and its target.

This relaxation does not apply to jumps to undefined symbols, assuming they will reach their targets once resolved.

Jump relaxation is enabled by default because it does not affect code size or performance while the code itself is small. This relaxation may be disabled completely with ‘`--no-trampolines`’ or ‘`--no-transform`’ command-line options (see Command Line Options).

Next: Xtensa Immediate Relaxation, Previous: Xtensa Call Relaxation, Up: Xtensa Relaxation [Contents][Index]