forked from OSchip/llvm-project
[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 llvm-svn: 350733
This commit is contained in:
parent
d7628d9993
commit
8abf680424
|
@ -1711,14 +1711,23 @@ static const MCInstrDesc &getInstDesc(unsigned Opcode) {
|
|||
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(MCInst &Inst, SMLoc IDLoc,
|
|||
// 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(MCInst &Inst, SMLoc IDLoc,
|
|||
// 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(MCInst &Inst, SMLoc IDLoc,
|
|||
// 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;
|
||||
|
|
|
@ -248,7 +248,11 @@ void MipsTargetStreamer::emitEmptyDelaySlot(bool hasShortDelaySlot, SMLoc IDLoc,
|
|||
}
|
||||
|
||||
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.
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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]
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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]
|
||||
|
|
|
@ -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.
|
||||
#------------------------------------------------------------------------------
|
||||
|
|
Loading…
Reference in New Issue