• alexandre.rames@arm.com's avatar
    A64: Let the MacroAssembler resolve branches to distant targets. · 62116e2c
    alexandre.rames@arm.com authored
    Code generation would fail when assembling a branch to a label that is bound
    outside the immediate range of the instruction. A64 is sensitive to this, as the
    various branching instructions have different ranges, going down to +-32KB for
    TBZ/TBNZ.  The MacroAssembler is augmented to handle branches to targets that
    may exceed the immediate range of instructions.
    
    When branching backward to a label exceeding the instruction range, the
    MacroAssembler can simply tweak the generated code to use an unconditional
    branch with a longer range. For example instead of
        B(cond, &label);
    the MacroAssembler can generate:
        b(InvertCondition(cond), &done);
        b(&label);
        bind(&done);
    
    Since the target is not known when the branch is emitted, forward branches uses
    a different mechanism. The MacroAssembler keeps track of forward branches to
    unbound labels. When the code generation approaches the end of the range of a
    branch, a veneer is generated for the branch.
    
    BUG=v8:3148
    LOG=Y
    R=ulan@chromium.org
    
    Review URL: https://codereview.chromium.org/169893002
    
    git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@19444 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
    62116e2c
assembler-a64.h 71.4 KB