From: Dylan McKay Date: Mon, 11 Dec 2017 11:01:19 +0000 (+0000) Subject: [AVR] Fix incorrectly-calculated AVRMCExpr evaluations X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7135491375069df2cfb0d62102c1b8258d96dff2;p=llvm [AVR] Fix incorrectly-calculated AVRMCExpr evaluations This has been broken since r320009. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@320347 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Target/AVR/MCTargetDesc/AVRMCExpr.cpp b/lib/Target/AVR/MCTargetDesc/AVRMCExpr.cpp index fdd43dd5ee1..4e13e7adf39 100644 --- a/lib/Target/AVR/MCTargetDesc/AVRMCExpr.cpp +++ b/lib/Target/AVR/MCTargetDesc/AVRMCExpr.cpp @@ -102,6 +102,7 @@ int64_t AVRMCExpr::evaluateAsInt64(int64_t Value) const { switch (Kind) { case AVRMCExpr::VK_AVR_LO8: + Value &= 0xff; break; case AVRMCExpr::VK_AVR_HI8: Value &= 0xff00; @@ -116,27 +117,23 @@ int64_t AVRMCExpr::evaluateAsInt64(int64_t Value) const { Value >>= 24; break; case AVRMCExpr::VK_AVR_PM_LO8: + case AVRMCExpr::VK_AVR_LO8_GS: + Value >>= 1; // Program memory addresses must always be shifted by one. Value &= 0xff; - Value >>= 1; break; case AVRMCExpr::VK_AVR_PM_HI8: + case AVRMCExpr::VK_AVR_HI8_GS: + Value >>= 1; // Program memory addresses must always be shifted by one. Value &= 0xff00; - Value >>= 9; + Value >>= 8; break; case AVRMCExpr::VK_AVR_PM_HH8: + Value >>= 1; // Program memory addresses must always be shifted by one. Value &= 0xff0000; - Value >>= 17; - break; - case AVRMCExpr::VK_AVR_LO8_GS: - Value &= 0xff; - Value >>= 1; - break; - case AVRMCExpr::VK_AVR_HI8_GS: - Value &= 0xff00; - Value >>= 9; + Value >>= 16; break; case AVRMCExpr::VK_AVR_GS: - Value >>= 1; + Value >>= 1; // Program memory addresses must always be shifted by one. break; case AVRMCExpr::VK_AVR_None: