Skip to content

Commit

Permalink
arm64: encode relative address for B/BL. see issue #108
Browse files Browse the repository at this point in the history
  • Loading branch information
aquynh committed May 27, 2016
1 parent 2f83973 commit 93cb870
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions llvm/lib/Target/AArch64/MCTargetDesc/AArch64MCCodeEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -369,8 +369,10 @@ AArch64MCCodeEmitter::getBranchTargetOpValue(const MCInst &MI, unsigned OpIdx,
const MCOperand &MO = MI.getOperand(OpIdx);

// If the destination is an immediate, we have nothing to do.
if (MO.isImm())
return MO.getImm();
if (MO.isImm()) {
// encode relative address
return (MO.getImm() * 4 - MI.getAddress()) / 4;
}
assert(MO.isExpr() && "Unexpected ADR target type!");

MCFixupKind Kind = MI.getOpcode() == AArch64::BL
Expand Down

0 comments on commit 93cb870

Please sign in to comment.