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 | dc46338e2d9c534a53369901fc8025fab9cbc9ba (patch) | |
| tree | 716e910d2588714216fb6fb3720302f58331d31c /llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp | |
| parent | fd8eac66faf122105c4d2e52862cafdb6b05bce6 (diff) | |
| download | bcm5719-llvm-dc46338e2d9c534a53369901fc8025fab9cbc9ba.tar.gz bcm5719-llvm-dc46338e2d9c534a53369901fc8025fab9cbc9ba.zip | |
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
llvm-svn: 175707
Diffstat (limited to 'llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp')
| -rw-r--r-- | llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp b/llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp index 088589fbfb1..ade60847528 100644 --- a/llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp +++ b/llvm/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; |

