diff --git a/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp b/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp index f4f923d6d8b3447911d887be7411252e736e56eb..06c5caf13e03ea0a42c9dcb45591868b23e3fd3a 100644 --- a/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp +++ b/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp @@ -1133,7 +1133,7 @@ public: return false; if (const MCConstantExpr *CE = dyn_cast<MCConstantExpr>(Imm.Val)) { - int64_t Val = CE->getValue(); + int64_t Val = CE->getValue() - Ctx.getBaseAddress(); int64_t Min = - (4096 * (1LL << (21 - 1))); int64_t Max = 4096 * ((1LL << (21 - 1)) - 1); return (Val % 4096) == 0 && Val >= Min && Val <= Max; diff --git a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64MCCodeEmitter.cpp b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64MCCodeEmitter.cpp index 3600a276d90b746c23be03a6130b2379bcdfd31f..3fd0442d8777e3b8766fbf2f1d230fcd8d28d026 100644 --- a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64MCCodeEmitter.cpp +++ b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64MCCodeEmitter.cpp @@ -219,7 +219,7 @@ AArch64MCCodeEmitter::getAdrLabelOpValue(const MCInst &MI, unsigned OpIdx, // If the destination is an immediate, we have nothing to do. if (MO.isImm()) - return MO.getImm(); + return (MO.getImm() * 4096 - MI.getAddress()) / 4096; assert(MO.isExpr() && "Unexpected target type!"); const MCExpr *Expr = MO.getExpr(); @@ -268,7 +268,7 @@ uint32_t AArch64MCCodeEmitter::getCondBranchTargetOpValue( // If the destination is an immediate, we have nothing to do. if (MO.isImm()) - return MO.getImm(); + return (MO.getImm() * 4 - MI.getAddress()) / 4; assert(MO.isExpr() && "Unexpected target type!"); MCFixupKind Kind = MCFixupKind(AArch64::fixup_aarch64_pcrel_branch19); @@ -332,7 +332,7 @@ uint32_t AArch64MCCodeEmitter::getTestBranchTargetOpValue( // If the destination is an immediate, we have nothing to do. if (MO.isImm()) - return MO.getImm(); + return (MO.getImm() * 4 - MI.getAddress()) / 4; assert(MO.isExpr() && "Unexpected ADR target type!"); MCFixupKind Kind = MCFixupKind(AArch64::fixup_aarch64_pcrel_branch14);