summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/Mips/MCTargetDesc/MipsMCCodeEmitter.cpp
diff options
context:
space:
mode:
authorDaniel Sanders <daniel.sanders@imgtec.com>2016-02-29 15:26:54 +0000
committerDaniel Sanders <daniel.sanders@imgtec.com>2016-02-29 15:26:54 +0000
commit611eb829532da35c19f6ac85818eae06e5534b5e (patch)
tree6a051d6da2fc59249e0fcf811dab54b73ff1f512 /llvm/lib/Target/Mips/MCTargetDesc/MipsMCCodeEmitter.cpp
parent2c7cdd25ee6e1f3f6ff67aa035f1b5174581c132 (diff)
downloadbcm5719-llvm-611eb829532da35c19f6ac85818eae06e5534b5e.tar.gz
bcm5719-llvm-611eb829532da35c19f6ac85818eae06e5534b5e.zip
[mips] Make isel select the correct DEXT variant up front.
Summary: Previously, it would always select DEXT and substitute any invalid matches for DEXTU/DEXTM during MipsMCCodeEmitter::encodeInstruction(). This works but causes problems when adding range checked immediates to IAS. Now isel selects the correct variant up front. Reviewers: vkalintiris Subscribers: dsanders, llvm-commits Differential Revision: http://reviews.llvm.org/D16810 llvm-svn: 262229
Diffstat (limited to 'llvm/lib/Target/Mips/MCTargetDesc/MipsMCCodeEmitter.cpp')
-rw-r--r--llvm/lib/Target/Mips/MCTargetDesc/MipsMCCodeEmitter.cpp29
1 files changed, 11 insertions, 18 deletions
diff --git a/llvm/lib/Target/Mips/MCTargetDesc/MipsMCCodeEmitter.cpp b/llvm/lib/Target/Mips/MCTargetDesc/MipsMCCodeEmitter.cpp
index 4b030ebfce8..d043bdf6fdd 100644
--- a/llvm/lib/Target/Mips/MCTargetDesc/MipsMCCodeEmitter.cpp
+++ b/llvm/lib/Target/Mips/MCTargetDesc/MipsMCCodeEmitter.cpp
@@ -81,16 +81,10 @@ static void LowerLargeShift(MCInst& Inst) {
}
}
-// Pick a DEXT or DINS instruction variant based on the pos and size operands
-static void LowerDextDins(MCInst& InstIn) {
- int Opcode = InstIn.getOpcode();
-
- if (Opcode == Mips::DEXT)
- assert(InstIn.getNumOperands() == 4 &&
- "Invalid no. of machine operands for DEXT!");
- else // Only DEXT and DINS are possible
- assert(InstIn.getNumOperands() == 5 &&
- "Invalid no. of machine operands for DINS!");
+// Pick a DINS instruction variant based on the pos and size operands
+static void LowerDins(MCInst& InstIn) {
+ assert(InstIn.getNumOperands() == 5 &&
+ "Invalid no. of machine operands for DINS!");
assert(InstIn.getOperand(2).isImm());
int64_t pos = InstIn.getOperand(2).getImm();
@@ -98,17 +92,17 @@ static void LowerDextDins(MCInst& InstIn) {
int64_t size = InstIn.getOperand(3).getImm();
if (size <= 32) {
- if (pos < 32) // DEXT/DINS, do nothing
+ if (pos < 32) // DINS, do nothing
return;
- // DEXTU/DINSU
+ // DINSU
InstIn.getOperand(2).setImm(pos - 32);
- InstIn.setOpcode((Opcode == Mips::DEXT) ? Mips::DEXTU : Mips::DINSU);
+ InstIn.setOpcode(Mips::DINSU);
return;
}
- // DEXTM/DINSM
- assert(pos < 32 && "DEXT/DINS cannot have both size and pos > 32");
+ // DINSM
+ assert(pos < 32 && "DINS cannot have both size and pos > 32");
InstIn.getOperand(3).setImm(size - 32);
- InstIn.setOpcode((Opcode == Mips::DEXT) ? Mips::DEXTM : Mips::DINSM);
+ InstIn.setOpcode(Mips::DINSM);
return;
}
@@ -164,9 +158,8 @@ encodeInstruction(const MCInst &MI, raw_ostream &OS,
LowerLargeShift(TmpInst);
break;
// Double extract instruction is chosen by pos and size operands
- case Mips::DEXT:
case Mips::DINS:
- LowerDextDins(TmpInst);
+ LowerDins(TmpInst);
}
unsigned long N = Fixups.size();
OpenPOWER on IntegriCloud