diff options
| author | Toma Tabacu <toma.tabacu@imgtec.com> | 2015-05-01 12:19:27 +0000 |
|---|---|---|
| committer | Toma Tabacu <toma.tabacu@imgtec.com> | 2015-05-01 12:19:27 +0000 |
| commit | 00e9867988427f30f7f6b9331d78ce3732e8feec (patch) | |
| tree | f8878a665fc591e00e09cc6519963004e5178c87 /llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp | |
| parent | b0e3c348ab3b8dc68219832351ada4e02eade960 (diff) | |
| download | bcm5719-llvm-00e9867988427f30f7f6b9331d78ce3732e8feec.tar.gz bcm5719-llvm-00e9867988427f30f7f6b9331d78ce3732e8feec.zip | |
[mips] [IAS] Fix error messages for using LI with 64-bit immediates.
Summary:
LI should never accept immediates larger than 32 bits.
The additional Is32BitImm boolean also paves the way for unifying the functionality that LA and LI have in common.
Reviewers: dsanders
Reviewed By: dsanders
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D9289
llvm-svn: 236313
Diffstat (limited to 'llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp')
| -rw-r--r-- | llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp b/llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp index ed6e8ebe048..7046b7053e8 100644 --- a/llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp +++ b/llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp @@ -179,7 +179,7 @@ class MipsAsmParser : public MCTargetAsmParser { bool expandJalWithRegs(MCInst &Inst, SMLoc IDLoc, SmallVectorImpl<MCInst> &Instructions); - bool expandLoadImm(MCInst &Inst, SMLoc IDLoc, + bool expandLoadImm(MCInst &Inst, bool Is32BitImm, SMLoc IDLoc, SmallVectorImpl<MCInst> &Instructions); bool expandLoadAddressImm(MCInst &Inst, SMLoc IDLoc, @@ -1609,13 +1609,9 @@ bool MipsAsmParser::expandInstruction(MCInst &Inst, SMLoc IDLoc, switch (Inst.getOpcode()) { default: llvm_unreachable("unimplemented expansion"); case Mips::LoadImm32: - return expandLoadImm(Inst, IDLoc, Instructions); + return expandLoadImm(Inst, true, IDLoc, Instructions); case Mips::LoadImm64: - if (!isGP64bit()) { - Error(IDLoc, "instruction requires a 64-bit architecture"); - return true; - } - return expandLoadImm(Inst, IDLoc, Instructions); + return expandLoadImm(Inst, false, IDLoc, Instructions); case Mips::LoadAddrImm32: return expandLoadAddressImm(Inst, IDLoc, Instructions); case Mips::LoadAddrReg32: @@ -1715,8 +1711,13 @@ bool MipsAsmParser::expandJalWithRegs(MCInst &Inst, SMLoc IDLoc, return false; } -bool MipsAsmParser::expandLoadImm(MCInst &Inst, SMLoc IDLoc, +bool MipsAsmParser::expandLoadImm(MCInst &Inst, bool Is32BitImm, SMLoc IDLoc, SmallVectorImpl<MCInst> &Instructions) { + if (!Is32BitImm && !isGP64bit()) { + Error(IDLoc, "instruction requires a 64-bit architecture"); + return true; + } + MCInst tmpInst; const MCOperand &ImmOp = Inst.getOperand(1); assert(ImmOp.isImm() && "expected immediate operand kind"); @@ -1757,8 +1758,8 @@ bool MipsAsmParser::expandLoadImm(MCInst &Inst, SMLoc IDLoc, Instructions.push_back(tmpInst); createLShiftOri<0>(Bits15To0, Reg, IDLoc, Instructions); } else if ((ImmValue & (0xffffLL << 48)) == 0) { - if (!isGP64bit()) { - Error(IDLoc, "instruction requires a 64-bit architecture"); + if (Is32BitImm) { + Error(IDLoc, "instruction requires a 32-bit immediate"); return true; } @@ -1786,8 +1787,8 @@ bool MipsAsmParser::expandLoadImm(MCInst &Inst, SMLoc IDLoc, createLShiftOri<0>(Bits31To16, Reg, IDLoc, Instructions); createLShiftOri<16>(Bits15To0, Reg, IDLoc, Instructions); } else { - if (!isGP64bit()) { - Error(IDLoc, "instruction requires a 64-bit architecture"); + if (Is32BitImm) { + Error(IDLoc, "instruction requires a 32-bit immediate"); return true; } |

