diff options
| author | Simon Dardis <simon.dardis@mips.com> | 2017-11-06 12:59:53 +0000 | 
|---|---|---|
| committer | Simon Dardis <simon.dardis@mips.com> | 2017-11-06 12:59:53 +0000 | 
| commit | 169df4e24b2d95892fc9841786d4fec224a8eeab (patch) | |
| tree | f6af89ff2dc558cd9226793479448d923e9019b3 /llvm/lib | |
| parent | a68e048233d7e9e0102ce4864138d187f8de88d0 (diff) | |
| download | bcm5719-llvm-169df4e24b2d95892fc9841786d4fec224a8eeab.tar.gz bcm5719-llvm-169df4e24b2d95892fc9841786d4fec224a8eeab.zip  | |
[mips] Add movep for microMIPS32R6 and fix microMIPS32r3 version
Previously, the 'movep' instruction was defined for microMIPS32r3 and
shared that definition with microMIPS32R6. 'movep' was re-encoded for
microMIPS32r6, so this patch provides the correct encoding.
Secondly, correct the encoding of the 'rs' and 'rt' operands which have
an instruction specific encoding for the registers those operands accept.
Finally, correct the decoding of the 'dst_regs' operand which was extracting
the relevant field from the instruction, but was actually extracting the
field from the alreadly extracted field.
Reviewers: atanasyan
Differential Revision: https://reviews.llvm.org/D39495
llvm-svn: 317475
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/Target/Mips/Disassembler/MipsDisassembler.cpp | 6 | ||||
| -rw-r--r-- | llvm/lib/Target/Mips/MCTargetDesc/MipsMCCodeEmitter.cpp | 23 | ||||
| -rw-r--r-- | llvm/lib/Target/Mips/MCTargetDesc/MipsMCCodeEmitter.h | 3 | ||||
| -rw-r--r-- | llvm/lib/Target/Mips/MicroMips32r6InstrFormats.td | 15 | ||||
| -rw-r--r-- | llvm/lib/Target/Mips/MicroMips32r6InstrInfo.td | 4 | ||||
| -rw-r--r-- | llvm/lib/Target/Mips/MicroMipsInstrInfo.td | 3 | ||||
| -rw-r--r-- | llvm/lib/Target/Mips/MipsRegisterInfo.td | 1 | ||||
| -rw-r--r-- | llvm/lib/Target/Mips/MipsScheduleGeneric.td | 1 | 
8 files changed, 51 insertions, 5 deletions
diff --git a/llvm/lib/Target/Mips/Disassembler/MipsDisassembler.cpp b/llvm/lib/Target/Mips/Disassembler/MipsDisassembler.cpp index 002fa512b21..d8e2eef6a9f 100644 --- a/llvm/lib/Target/Mips/Disassembler/MipsDisassembler.cpp +++ b/llvm/lib/Target/Mips/Disassembler/MipsDisassembler.cpp @@ -535,7 +535,7 @@ static DecodeStatus DecodeRegListOperand16(MCInst &Inst, unsigned Insn,                                             uint64_t Address,                                             const void *Decoder); -static DecodeStatus DecodeMovePRegPair(MCInst &Inst, unsigned Insn, +static DecodeStatus DecodeMovePRegPair(MCInst &Inst, unsigned RegPair,                                         uint64_t Address,                                         const void *Decoder); @@ -2481,10 +2481,8 @@ static DecodeStatus DecodeRegListOperand16(MCInst &Inst, unsigned Insn,    return MCDisassembler::Success;  } -static DecodeStatus DecodeMovePRegPair(MCInst &Inst, unsigned Insn, +static DecodeStatus DecodeMovePRegPair(MCInst &Inst, unsigned RegPair,                                         uint64_t Address, const void *Decoder) { -  unsigned RegPair = fieldFromInstruction(Insn, 7, 3); -    switch (RegPair) {    default:      return MCDisassembler::Fail; diff --git a/llvm/lib/Target/Mips/MCTargetDesc/MipsMCCodeEmitter.cpp b/llvm/lib/Target/Mips/MCTargetDesc/MipsMCCodeEmitter.cpp index 12f7638594d..eae0f975080 100644 --- a/llvm/lib/Target/Mips/MCTargetDesc/MipsMCCodeEmitter.cpp +++ b/llvm/lib/Target/Mips/MCTargetDesc/MipsMCCodeEmitter.cpp @@ -1115,6 +1115,29 @@ MipsMCCodeEmitter::getMovePRegPairOpValue(const MCInst &MI, unsigned OpNo,  }  unsigned +MipsMCCodeEmitter::getMovePRegSingleOpValue(const MCInst &MI, unsigned OpNo, +                                            SmallVectorImpl<MCFixup> &Fixups, +                                            const MCSubtargetInfo &STI) const { +  assert(((OpNo == 2) || (OpNo == 3)) && +         "Unexpected OpNo for movep operand encoding!"); + +  MCOperand Op = MI.getOperand(OpNo); +  assert(Op.isReg() && "Operand of movep is not a register!"); +  switch (Op.getReg()) { +  default: +    llvm_unreachable("Unknown register for movep!"); +  case Mips::ZERO:  return 0; +  case Mips::S1:    return 1; +  case Mips::V0:    return 2; +  case Mips::V1:    return 3; +  case Mips::S0:    return 4; +  case Mips::S2:    return 5; +  case Mips::S3:    return 6; +  case Mips::S4:    return 7; +  } +} + +unsigned  MipsMCCodeEmitter::getSimm23Lsl2Encoding(const MCInst &MI, unsigned OpNo,                                           SmallVectorImpl<MCFixup> &Fixups,                                           const MCSubtargetInfo &STI) const { diff --git a/llvm/lib/Target/Mips/MCTargetDesc/MipsMCCodeEmitter.h b/llvm/lib/Target/Mips/MCTargetDesc/MipsMCCodeEmitter.h index d12d3195521..1e840114b2b 100644 --- a/llvm/lib/Target/Mips/MCTargetDesc/MipsMCCodeEmitter.h +++ b/llvm/lib/Target/Mips/MCTargetDesc/MipsMCCodeEmitter.h @@ -252,6 +252,9 @@ public:    unsigned getMovePRegPairOpValue(const MCInst &MI, unsigned OpNo,                                    SmallVectorImpl<MCFixup> &Fixups,                                    const MCSubtargetInfo &STI) const; +  unsigned getMovePRegSingleOpValue(const MCInst &MI, unsigned OpNo, +                                    SmallVectorImpl<MCFixup> &Fixups, +                                    const MCSubtargetInfo &STI) const;    unsigned getSimm23Lsl2Encoding(const MCInst &MI, unsigned OpNo,                                   SmallVectorImpl<MCFixup> &Fixups, diff --git a/llvm/lib/Target/Mips/MicroMips32r6InstrFormats.td b/llvm/lib/Target/Mips/MicroMips32r6InstrFormats.td index 2f0933277e8..e1f1f9262b9 100644 --- a/llvm/lib/Target/Mips/MicroMips32r6InstrFormats.td +++ b/llvm/lib/Target/Mips/MicroMips32r6InstrFormats.td @@ -829,6 +829,21 @@ class POOL16C_NOT16_FM_MMR6 : MicroMipsR6Inst16 {    let Inst{3-0}   = 0b0000;  } +class POOL16C_MOVEP16_FM_MMR6 : MicroMipsR6Inst16 { +  bits<3> dst_regs; +  bits<3> rt; +  bits<3> rs; + +  bits<16> Inst; + +  let Inst{15-10} = 0b010001; +  let Inst{9-7}   = dst_regs; +  let Inst{6-4}   = rt; +  let Inst{3}     = rs{2}; +  let Inst{2}     = 0b1; +  let Inst{1-0}   = rs{1-0}; +} +  class POOL16C_OR16_XOR16_FM_MMR6<bits<4> op> : MicroMipsR6Inst16 {    bits<3> rt;    bits<3> rs; diff --git a/llvm/lib/Target/Mips/MicroMips32r6InstrInfo.td b/llvm/lib/Target/Mips/MicroMips32r6InstrInfo.td index 425e75e14c8..fb65e4d5a36 100644 --- a/llvm/lib/Target/Mips/MicroMips32r6InstrInfo.td +++ b/llvm/lib/Target/Mips/MicroMips32r6InstrInfo.td @@ -229,6 +229,7 @@ class SRL16_MMR6_ENC : SHIFT_FM_MM16<1>, MicroMipsR6Inst16;  class BREAK16_MMR6_ENC : POOL16C_BREAKPOINT_FM_MMR6<0b011011>;  class LI16_MMR6_ENC : LI_FM_MM16;  class MOVE16_MMR6_ENC : MOVE_FM_MM16<0b000011>; +class MOVEP_MMR6_ENC  : POOL16C_MOVEP16_FM_MMR6;  class SDBBP16_MMR6_ENC : POOL16C_BREAKPOINT_FM_MMR6<0b111011>;  class SUBU16_MMR6_ENC : POOL16A_SUBU16_FM_MMR6;  class XOR16_MMR6_ENC : POOL16C_OR16_XOR16_FM_MMR6<0b1000>; @@ -1204,6 +1205,7 @@ class LI16_MMR6_DESC : LoadImmMM16<"li16", li16_imm, GPRMM16Opnd>,        MMR6Arch<"li16">, MicroMipsR6Inst16, IsAsCheapAsAMove;  class MOVE16_MMR6_DESC : MoveMM16<"move16", GPR32Opnd>, MMR6Arch<"move16">,        MicroMipsR6Inst16; +class MOVEP_MMR6_DESC : MovePMM16<"movep", GPRMM16OpndMoveP>, MMR6Arch<"movep">;  class SDBBP16_MMR6_DESC : BrkSdbbp16MM<"sdbbp16", II_SDBBP>, MMR6Arch<"sdbbp16">,        MicroMipsR6Inst16;  class SUBU16_MMR6_DESC : ArithRMM16<"subu16", GPRMM16Opnd, 0, II_SUBU, sub>, @@ -1679,6 +1681,8 @@ def LI16_MMR6 : StdMMR6Rel, LI16_MMR6_DESC, LI16_MMR6_ENC,                  ISA_MICROMIPS32R6;  def MOVE16_MMR6 : StdMMR6Rel, MOVE16_MMR6_DESC, MOVE16_MMR6_ENC,                    ISA_MICROMIPS32R6; +def MOVEP_MMR6  : StdMMR6Rel, MOVEP_MMR6_DESC, MOVEP_MMR6_ENC, +                  ISA_MICROMIPS32R6;  def SDBBP16_MMR6 : StdMMR6Rel, SDBBP16_MMR6_DESC, SDBBP16_MMR6_ENC,                     ISA_MICROMIPS32R6;  def SUBU16_MMR6 : StdMMR6Rel, SUBU16_MMR6_DESC, SUBU16_MMR6_ENC, diff --git a/llvm/lib/Target/Mips/MicroMipsInstrInfo.td b/llvm/lib/Target/Mips/MicroMipsInstrInfo.td index 90399ddfab5..8dd7088f143 100644 --- a/llvm/lib/Target/Mips/MicroMipsInstrInfo.td +++ b/llvm/lib/Target/Mips/MicroMipsInstrInfo.td @@ -631,7 +631,8 @@ def ADDIUSP_MM : AddImmUSP<"addiusp">, ADDIUSP_FM_MM16;  def MFHI16_MM : MoveFromHILOMM<"mfhi", GPR32Opnd, AC0>, MFHILO_FM_MM16<0x10>;  def MFLO16_MM : MoveFromHILOMM<"mflo", GPR32Opnd, AC0>, MFHILO_FM_MM16<0x12>;  def MOVE16_MM : MoveMM16<"move", GPR32Opnd>, MOVE_FM_MM16<0x03>; -def MOVEP_MM : MovePMM16<"movep", GPRMM16OpndMoveP>, MOVEP_FM_MM16; +def MOVEP_MM : MovePMM16<"movep", GPRMM16OpndMoveP>, MOVEP_FM_MM16, +               ISA_MICROMIPS_NOT_32R6_64R6;  def LI16_MM : LoadImmMM16<"li16", li16_imm, GPRMM16Opnd>, LI_FM_MM16,                IsAsCheapAsAMove;  def JALR16_MM : JumpLinkRegMM16<"jalr", GPR32Opnd>, JALR_FM_MM16<0x0e>, diff --git a/llvm/lib/Target/Mips/MipsRegisterInfo.td b/llvm/lib/Target/Mips/MipsRegisterInfo.td index 08fb3d7d435..f64d91aad85 100644 --- a/llvm/lib/Target/Mips/MipsRegisterInfo.td +++ b/llvm/lib/Target/Mips/MipsRegisterInfo.td @@ -616,6 +616,7 @@ def GPRMM16OpndZero : RegisterOperand<GPRMM16Zero> {  def GPRMM16OpndMoveP : RegisterOperand<GPRMM16MoveP> {    let ParserMatchClass = GPRMM16AsmOperandMoveP; +  let EncoderMethod = "getMovePRegSingleOpValue";  }  def GPR64Opnd : RegisterOperand<GPR64> { diff --git a/llvm/lib/Target/Mips/MipsScheduleGeneric.td b/llvm/lib/Target/Mips/MipsScheduleGeneric.td index 89cda676441..9621009ed1c 100644 --- a/llvm/lib/Target/Mips/MipsScheduleGeneric.td +++ b/llvm/lib/Target/Mips/MipsScheduleGeneric.td @@ -736,6 +736,7 @@ def : InstRW<[GenericDSPShort], (instregex "^MFHI_DSP_MM$")>;  def : InstRW<[GenericDSPShort], (instregex "^MFLO_DSP_MM$")>;  def : InstRW<[GenericDSPShort], (instregex "^MODSUB_MM$")>;  def : InstRW<[GenericDSPShort], (instregex "^MOVEP_MM$")>; +def : InstRW<[GenericDSPShort], (instregex "^MOVEP_MMR6$")>;  def : InstRW<[GenericDSPShort], (instregex "^MOVN_I_MM$")>;  def : InstRW<[GenericDSPShort], (instregex "^MOVZ_I_MM$")>;  def : InstRW<[GenericDSPShort], (instregex "^MSUBU_DSP_MM$")>;  | 

