diff options
author | Jack Carter <jcarter@mips.com> | 2013-02-21 02:09:31 +0000 |
---|---|---|
committer | Jack Carter <jcarter@mips.com> | 2013-02-21 02:09:31 +0000 |
commit | 77217229ba1bbc92f3a53099fa91bcdaa7797da8 (patch) | |
tree | 0ee4752914269e634804686290d43a88c3020bba /lib/Target/Mips/AsmParser/MipsAsmParser.cpp | |
parent | 421021157eda12453b4fea7ea853d8c472bd8532 (diff) |
Mips specific standalone assembler addressing mode %hi and %lo.
The constructs %hi() and %lo() represent the high and low 16
bits of the address.
Because the 16 bit offset field of an LW instruction is
interpreted as signed, if bit 15 of the low part is 1 then the
low part will act as a negative and 1 needs to be added to the
high part.
Contributer: Vladimir Medic
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@175707 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/Mips/AsmParser/MipsAsmParser.cpp')
-rw-r--r-- | lib/Target/Mips/AsmParser/MipsAsmParser.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/Target/Mips/AsmParser/MipsAsmParser.cpp b/lib/Target/Mips/AsmParser/MipsAsmParser.cpp index 088589fbfb..ade6084752 100644 --- a/lib/Target/Mips/AsmParser/MipsAsmParser.cpp +++ b/lib/Target/Mips/AsmParser/MipsAsmParser.cpp @@ -888,7 +888,12 @@ bool MipsAsmParser::parseRelocOperand(const MCExpr *&Res) { if (Str == "lo") { Val = Val & 0xffff; } else if (Str == "hi") { + int LoSign = Val & 0x8000; Val = (Val & 0xffff0000) >> 16; + //lower part is treated as signed int, so if it is negative + //we must add 1 to hi part to compensate + if (LoSign) + Val++; } Res = MCConstantExpr::Create(Val, getContext()); return false; |