[llvm] r350733 - [mips][micrompis] Emit 16bit NOPs by default
Aleksandar Beserminji via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 9 07:58:02 PST 2019
Author: abeserminji
Date: Wed Jan 9 07:58:02 2019
New Revision: 350733
URL: http://llvm.org/viewvc/llvm-project?rev=350733&view=rev
Log:
[mips][micrompis] Emit 16bit NOPs by default
Emit 16bit NOPs by default.
Use 32bit NOPs in delay slots where necessary.
Differential https://reviews.llvm.org/D55323
Modified:
llvm/trunk/lib/Target/Mips/AsmParser/MipsAsmParser.cpp
llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp
llvm/trunk/test/MC/Mips/micromips-branch-fixup.s
llvm/trunk/test/MC/Mips/micromips-branch-instructions.s
llvm/trunk/test/MC/Mips/micromips-el-fixup-data.s
llvm/trunk/test/MC/Mips/micromips-jump-instructions.s
llvm/trunk/test/MC/Mips/micromips-tailr.s
Modified: llvm/trunk/lib/Target/Mips/AsmParser/MipsAsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/AsmParser/MipsAsmParser.cpp?rev=350733&r1=350732&r2=350733&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Mips/AsmParser/MipsAsmParser.cpp (original)
+++ llvm/trunk/lib/Target/Mips/AsmParser/MipsAsmParser.cpp Wed Jan 9 07:58:02 2019
@@ -1711,14 +1711,23 @@ static const MCInstrDesc &getInstDesc(un
return MipsInsts[Opcode];
}
-static bool hasShortDelaySlot(unsigned Opcode) {
- switch (Opcode) {
+static bool hasShortDelaySlot(MCInst &Inst) {
+ switch (Inst.getOpcode()) {
+ case Mips::BEQ_MM:
+ case Mips::BNE_MM:
+ case Mips::BLTZ_MM:
+ case Mips::BGEZ_MM:
+ case Mips::BLEZ_MM:
+ case Mips::BGTZ_MM:
+ case Mips::JRC16_MM:
case Mips::JALS_MM:
case Mips::JALRS_MM:
case Mips::JALRS16_MM:
case Mips::BGEZALS_MM:
case Mips::BLTZALS_MM:
return true;
+ case Mips::J_MM:
+ return !Inst.getOperand(0).isReg();
default:
return false;
}
@@ -2302,7 +2311,7 @@ bool MipsAsmParser::processInstruction(M
// If this instruction has a delay slot and .set reorder is active,
// emit a NOP after it.
if (FillDelaySlot) {
- TOut.emitEmptyDelaySlot(hasShortDelaySlot(Inst.getOpcode()), IDLoc, STI);
+ TOut.emitEmptyDelaySlot(hasShortDelaySlot(Inst), IDLoc, STI);
TOut.emitDirectiveSetReorder();
}
@@ -2314,7 +2323,7 @@ bool MipsAsmParser::processInstruction(M
// If .set reorder has been used, we've already emitted a NOP.
// If .set noreorder has been used, we need to emit a NOP at this point.
if (!AssemblerOptions.back()->isReorder())
- TOut.emitEmptyDelaySlot(hasShortDelaySlot(Inst.getOpcode()), IDLoc,
+ TOut.emitEmptyDelaySlot(hasShortDelaySlot(Inst), IDLoc,
STI);
// Load the $gp from the stack.
@@ -2601,7 +2610,7 @@ bool MipsAsmParser::expandJalWithRegs(MC
// emit a NOP after it.
const MCInstrDesc &MCID = getInstDesc(JalrInst.getOpcode());
if (MCID.hasDelaySlot() && AssemblerOptions.back()->isReorder())
- TOut.emitEmptyDelaySlot(hasShortDelaySlot(JalrInst.getOpcode()), IDLoc,
+ TOut.emitEmptyDelaySlot(hasShortDelaySlot(JalrInst), IDLoc,
STI);
return false;
Modified: llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp?rev=350733&r1=350732&r2=350733&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp (original)
+++ llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp Wed Jan 9 07:58:02 2019
@@ -248,7 +248,11 @@ void MipsTargetStreamer::emitEmptyDelayS
}
void MipsTargetStreamer::emitNop(SMLoc IDLoc, const MCSubtargetInfo *STI) {
- emitRRI(Mips::SLL, Mips::ZERO, Mips::ZERO, 0, IDLoc, STI);
+ const FeatureBitset &Features = STI->getFeatureBits();
+ if (Features[Mips::FeatureMicroMips])
+ emitRR(Mips::MOVE16_MM, Mips::ZERO, Mips::ZERO, IDLoc, STI);
+ else
+ emitRRI(Mips::SLL, Mips::ZERO, Mips::ZERO, 0, IDLoc, STI);
}
/// Emit the $gp restore operation for .cprestore.
Modified: llvm/trunk/test/MC/Mips/micromips-branch-fixup.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Mips/micromips-branch-fixup.s?rev=350733&r1=350732&r2=350733&view=diff
==============================================================================
--- llvm/trunk/test/MC/Mips/micromips-branch-fixup.s (original)
+++ llvm/trunk/test/MC/Mips/micromips-branch-fixup.s Wed Jan 9 07:58:02 2019
@@ -24,29 +24,23 @@
# CHECK-FIXUP: value: bar, kind: fixup_MICROMIPS_PC16_S1
# CHECK-FIXUP: nop # encoding: [0x00,0x0c]
# CHECK-FIXUP: beq $3, $4, bar # encoding: [0x83'A',0x94'A',0x00,0x00]
-# CHECK-FIXUP: # fixup A - offset: 0,
-# CHECK-FIXUP: value: bar, kind: fixup_MICROMIPS_PC16_S1
-# CHECK-FIXUP: nop # encoding: [0x00,0x00,0x00,0x00]
+# CHECK-FIXUP: # fixup A - offset: 0, value: bar, kind: fixup_MICROMIPS_PC16_S1
+# CHECK-FIXUP: nop # encoding: [0x00,0x0c]
# CHECK-FIXUP: bne $3, $4, bar # encoding: [0x83'A',0xb4'A',0x00,0x00]
-# CHECK-FIXUP: # fixup A - offset: 0,
-# CHECK-FIXUP: value: bar, kind: fixup_MICROMIPS_PC16_S1
-# CHECK-FIXUP: nop # encoding: [0x00,0x00,0x00,0x00]
+# CHECK-FIXUP: # fixup A - offset: 0, value: bar, kind: fixup_MICROMIPS_PC16_S1
+# CHECK-FIXUP: nop # encoding: [0x00,0x0c]
# CHECK-FIXUP: bgez $4, bar # encoding: [0x44'A',0x40'A',0x00,0x00]
-# CHECK-FIXUP: # fixup A - offset: 0,
-# CHECK-FIXUP: value: bar, kind: fixup_MICROMIPS_PC16_S1
-# CHECK-FIXUP: nop # encoding: [0x00,0x00,0x00,0x00]
+# CHECK-FIXUP-NEXT: # fixup A - offset: 0, value: bar, kind: fixup_MICROMIPS_PC16_S1
+# CHECK-FIXUP-NEXT: nop # encoding: [0x00,0x0c]
# CHECK-FIXUP: bgtz $4, bar # encoding: [0xc4'A',0x40'A',0x00,0x00]
-# CHECK-FIXUP: # fixup A - offset: 0,
-# CHECK-FIXUP: value: bar, kind: fixup_MICROMIPS_PC16_S1
-# CHECK-FIXUP: nop # encoding: [0x00,0x00,0x00,0x00]
+# CHECK-FIXUP-NEXT: # fixup A - offset: 0, value: bar, kind: fixup_MICROMIPS_PC16_S1
+# CHECK-FIXUP-NEXT: nop # encoding: [0x00,0x0c]
# CHECK-FIXUP: blez $4, bar # encoding: [0x84'A',0x40'A',0x00,0x00]
-# CHECK-FIXUP: # fixup A - offset: 0,
-# CHECK-FIXUP: value: bar, kind: fixup_MICROMIPS_PC16_S1
-# CHECK-FIXUP: nop # encoding: [0x00,0x00,0x00,0x00]
+# CHECK-FIXUP-NEXT: # fixup A - offset: 0, value: bar, kind: fixup_MICROMIPS_PC16_S1
+# CHECK-FIXUP-NEXT: nop # encoding: [0x00,0x0c]
# CHECK-FIXUP: bltz $4, bar # encoding: [0x04'A',0x40'A',0x00,0x00]
-# CHECK-FIXUP: # fixup A - offset: 0,
-# CHECK-FIXUP: value: bar, kind: fixup_MICROMIPS_PC16_S1
-# CHECK-FIXUP: nop # encoding: [0x00,0x00,0x00,0x00]
+# CHECK-FIXUP-NEXT: # fixup A - offset: 0, value: bar, kind: fixup_MICROMIPS_PC16_S1
+# CHECK-FIXUP-NEXT: nop # encoding: [0x00,0x0c]
# CHECK-FIXUP: bgezal $4, bar # encoding: [0x64'A',0x40'A',0x00,0x00]
# CHECK-FIXUP: # fixup A - offset: 0,
# CHECK-FIXUP: value: bar, kind: fixup_MICROMIPS_PC16_S1
Modified: llvm/trunk/test/MC/Mips/micromips-branch-instructions.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Mips/micromips-branch-instructions.s?rev=350733&r1=350732&r2=350733&view=diff
==============================================================================
--- llvm/trunk/test/MC/Mips/micromips-branch-instructions.s (original)
+++ llvm/trunk/test/MC/Mips/micromips-branch-instructions.s Wed Jan 9 07:58:02 2019
@@ -12,23 +12,23 @@
# CHECK-EL: b 1332 # encoding: [0x00,0x94,0x9a,0x02]
# CHECK-EL: nop # encoding: [0x00,0x0c]
# CHECK-EL: beq $9, $6, 1332 # encoding: [0xc9,0x94,0x9a,0x02]
-# CHECK-EL: nop # encoding: [0x00,0x00,0x00,0x00]
+# CHECK-EL-NEXT: nop # encoding: [0x00,0x0c]
# CHECK-EL: bgez $6, 1332 # encoding: [0x46,0x40,0x9a,0x02]
-# CHECK-EL: nop # encoding: [0x00,0x00,0x00,0x00]
+# CHECK-EL-NEXT: nop # encoding: [0x00,0x0c]
# CHECK-EL: bgezal $6, 1332 # encoding: [0x66,0x40,0x9a,0x02]
# CHECK-EL: nop # encoding: [0x00,0x00,0x00,0x00]
# CHECK-EL: bltzal $6, 1332 # encoding: [0x26,0x40,0x9a,0x02]
# CHECK-EL: nop # encoding: [0x00,0x00,0x00,0x00]
# CHECK-EL: bgtz $6, 1332 # encoding: [0xc6,0x40,0x9a,0x02]
-# CHECK-EL: nop # encoding: [0x00,0x00,0x00,0x00]
+# CHECK-EL-NEXT: nop # encoding: [0x00,0x0c]
# CHECK-EL: blez $6, 1332 # encoding: [0x86,0x40,0x9a,0x02]
-# CHECK-EL: nop # encoding: [0x00,0x00,0x00,0x00]
+# CHECK-EL-NEXT: nop # encoding: [0x00,0x0c]
# CHECK-EL: bne $9, $6, 1332 # encoding: [0xc9,0xb4,0x9a,0x02]
-# CHECK-EL: nop # encoding: [0x00,0x00,0x00,0x00]
+# CHECK-EL-NEXT: nop # encoding: [0x00,0x0c]
# CHECK-EL: bal 1332 # encoding: [0x60,0x40,0x9a,0x02]
# CHECK-EL: nop # encoding: [0x00,0x00,0x00,0x00]
# CHECK-EL: bltz $6, 1332 # encoding: [0x06,0x40,0x9a,0x02]
-# CHECK-EL: nop # encoding: [0x00,0x00,0x00,0x00]
+# CHECK-EL-NEXT: nop # encoding: [0x00,0x0c]
# CHECK-EL: bgezals $6, 1332 # encoding: [0x66,0x42,0x9a,0x02]
# CHECK-EL: nop # encoding: [0x00,0x0c]
# CHECK-EL: bltzals $6, 1332 # encoding: [0x26,0x42,0x9a,0x02]
@@ -39,23 +39,23 @@
# CHECK-EB: b 1332 # encoding: [0x94,0x00,0x02,0x9a]
# CHECK-EB: nop # encoding: [0x0c,0x00]
# CHECK-EB: beq $9, $6, 1332 # encoding: [0x94,0xc9,0x02,0x9a]
-# CHECK-EB: nop # encoding: [0x00,0x00,0x00,0x00]
+# CHECK-EB-NEXT: nop # encoding: [0x0c,0x00]
# CHECK-EB: bgez $6, 1332 # encoding: [0x40,0x46,0x02,0x9a]
-# CHECK-EB: nop # encoding: [0x00,0x00,0x00,0x00]
+# CHECK-EB-NEXT: nop # encoding: [0x0c,0x00]
# CHECK-EB: bgezal $6, 1332 # encoding: [0x40,0x66,0x02,0x9a]
# CHECK-EB: nop # encoding: [0x00,0x00,0x00,0x00]
# CHECK-EB: bltzal $6, 1332 # encoding: [0x40,0x26,0x02,0x9a]
# CHECK-EB: nop # encoding: [0x00,0x00,0x00,0x00]
# CHECK-EB: bgtz $6, 1332 # encoding: [0x40,0xc6,0x02,0x9a]
-# CHECK-EB: nop # encoding: [0x00,0x00,0x00,0x00]
+# CHECK-EB-NEXT: nop # encoding: [0x0c,0x00]
# CHECK-EB: blez $6, 1332 # encoding: [0x40,0x86,0x02,0x9a]
-# CHECK-EB: nop # encoding: [0x00,0x00,0x00,0x00]
+# CHECK-EB-NEXT: nop # encoding: [0x0c,0x00]
# CHECK-EB: bne $9, $6, 1332 # encoding: [0xb4,0xc9,0x02,0x9a]
-# CHECK-EB: nop # encoding: [0x00,0x00,0x00,0x00]
+# CHECK-EB-NEXT: nop # encoding: [0x0c,0x00]
# CHECK-EB: bal 1332 # encoding: [0x40,0x60,0x02,0x9a]
# CHECK-EB: nop # encoding: [0x00,0x00,0x00,0x00]
# CHECK-EB: bltz $6, 1332 # encoding: [0x40,0x06,0x02,0x9a]
-# CHECK-EB: nop # encoding: [0x00,0x00,0x00,0x00]
+# CHECK-EB-NEXT: nop # encoding: [0x0c,0x00]
# CHECK-EB: bgezals $6, 1332 # encoding: [0x42,0x66,0x02,0x9a]
# CHECK-EB: nop # encoding: [0x0c,0x00]
# CHECK-EB: bltzals $6, 1332 # encoding: [0x42,0x26,0x02,0x9a]
Modified: llvm/trunk/test/MC/Mips/micromips-el-fixup-data.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Mips/micromips-el-fixup-data.s?rev=350733&r1=350732&r2=350733&view=diff
==============================================================================
--- llvm/trunk/test/MC/Mips/micromips-el-fixup-data.s (original)
+++ llvm/trunk/test/MC/Mips/micromips-el-fixup-data.s Wed Jan 9 07:58:02 2019
@@ -16,7 +16,7 @@ main:
addiu $sp, $sp, -16
bnez $9, lab1
-# CHECK: 09 b4 04 00 bnez $9, 12
+# CHECK: 09 b4 03 00 bnez $9, 10
addu $zero, $zero, $zero
lab1:
Modified: llvm/trunk/test/MC/Mips/micromips-jump-instructions.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Mips/micromips-jump-instructions.s?rev=350733&r1=350732&r2=350733&view=diff
==============================================================================
--- llvm/trunk/test/MC/Mips/micromips-jump-instructions.s (original)
+++ llvm/trunk/test/MC/Mips/micromips-jump-instructions.s Wed Jan 9 07:58:02 2019
@@ -10,7 +10,7 @@
# Little endian
#------------------------------------------------------------------------------
# CHECK-EL: j 1328 # encoding: [0x00,0xd4,0x98,0x02]
-# CHECK-EL: nop # encoding: [0x00,0x00,0x00,0x00]
+# CHECK-EL: nop # encoding: [0x00,0x0c]
# CHECK-EL: jal 1328 # encoding: [0x00,0xf4,0x98,0x02]
# CHECK-EL: nop # encoding: [0x00,0x00,0x00,0x00]
# CHECK-EL: jalr $ra, $6 # encoding: [0xe6,0x03,0x3c,0x0f]
@@ -33,7 +33,7 @@
# Big endian
#------------------------------------------------------------------------------
# CHECK-EB: j 1328 # encoding: [0xd4,0x00,0x02,0x98]
-# CHECK-EB: nop # encoding: [0x00,0x00,0x00,0x00]
+# CHECK-EB: nop # encoding: [0x0c,0x00]
# CHECK-EB: jal 1328 # encoding: [0xf4,0x00,0x02,0x98]
# CHECK-EB: nop # encoding: [0x00,0x00,0x00,0x00]
# CHECK-EB: jalr $ra, $6 # encoding: [0x03,0xe6,0x0f,0x3c]
Modified: llvm/trunk/test/MC/Mips/micromips-tailr.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Mips/micromips-tailr.s?rev=350733&r1=350732&r2=350733&view=diff
==============================================================================
--- llvm/trunk/test/MC/Mips/micromips-tailr.s (original)
+++ llvm/trunk/test/MC/Mips/micromips-tailr.s Wed Jan 9 07:58:02 2019
@@ -11,9 +11,8 @@
# CHECK-FIXUP: addiu $2, $zero, 1332
# CHECK-FIXUP: # encoding: [0x40,0x30,0x34,0x05]
# CHECK-FIXUP: j foo # encoding: [A,0xd4'A',A,0b000000AA]
-# CHECK-FIXUP: # fixup A - offset: 0,
-# CHECK-FIXUP: value: foo, kind: fixup_MICROMIPS_26_S1
-# CHECK-FIXUP: nop # encoding: [0x00,0x00,0x00,0x00]
+# CHECK-FIXUP-NEXT: # fixup A - offset: 0, value: foo, kind: fixup_MICROMIPS_26_S1
+# CHECK-FIXUP-NEXT: nop # encoding: [0x00,0x0c]
#------------------------------------------------------------------------------
# Check that the appropriate relocations were created.
#------------------------------------------------------------------------------
More information about the llvm-commits
mailing list