diff options
| author | Zoran Jovanovic <zoran.jovanovic@imgtec.com> | 2014-10-23 10:59:24 +0000 |
|---|---|---|
| committer | Zoran Jovanovic <zoran.jovanovic@imgtec.com> | 2014-10-23 10:59:24 +0000 |
| commit | 9bda2f1926db4f557eb4105b34de79f747616b1e (patch) | |
| tree | 76d832690a251dc61bcc290f39acf70695d36788 /llvm/lib | |
| parent | 4a00fdc2e3804cdf2d3ce2b426d161395d833d53 (diff) | |
| download | bcm5719-llvm-9bda2f1926db4f557eb4105b34de79f747616b1e.tar.gz bcm5719-llvm-9bda2f1926db4f557eb4105b34de79f747616b1e.zip | |
ps][microMIPS] Implement LI16 instruction
Differential Revision: http://reviews.llvm.org/D5149
llvm-svn: 220475
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp | 8 | ||||
| -rw-r--r-- | llvm/lib/Target/Mips/MicroMipsInstrFormats.td | 11 | ||||
| -rw-r--r-- | llvm/lib/Target/Mips/MicroMipsInstrInfo.td | 12 |
3 files changed, 31 insertions, 0 deletions
diff --git a/llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp b/llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp index 6e8639c0914..501b1d276a7 100644 --- a/llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp +++ b/llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp @@ -1170,6 +1170,14 @@ bool MipsAsmParser::processInstruction(MCInst &Inst, SMLoc IDLoc, if (Imm < 1 || Imm > 8) return Error(IDLoc, "immediate operand value out of range"); break; + case Mips::LI16_MM: + Opnd = Inst.getOperand(1); + if (!Opnd.isImm()) + return Error(IDLoc, "expected immediate operand kind"); + Imm = Opnd.getImm(); + if (Imm < -1 || Imm > 126) + return Error(IDLoc, "immediate operand value out of range"); + break; } } diff --git a/llvm/lib/Target/Mips/MicroMipsInstrFormats.td b/llvm/lib/Target/Mips/MicroMipsInstrFormats.td index 90ee077347e..ae80b4f7e6d 100644 --- a/llvm/lib/Target/Mips/MicroMipsInstrFormats.td +++ b/llvm/lib/Target/Mips/MicroMipsInstrFormats.td @@ -114,6 +114,17 @@ class MOVE_FM_MM16<bits<6> funct> { let Inst{4-0} = rs; } +class LI_FM_MM16 { + bits<3> rd; + bits<7> imm; + + bits<16> Inst; + + let Inst{15-10} = 0x3b; + let Inst{9-7} = rd; + let Inst{6-0} = imm; +} + class JALR_FM_MM16<bits<5> op> { bits<5> rs; diff --git a/llvm/lib/Target/Mips/MicroMipsInstrInfo.td b/llvm/lib/Target/Mips/MicroMipsInstrInfo.td index 656d369fe4d..3efa17cdc8c 100644 --- a/llvm/lib/Target/Mips/MicroMipsInstrInfo.td +++ b/llvm/lib/Target/Mips/MicroMipsInstrInfo.td @@ -1,6 +1,7 @@ def addrimm12 : ComplexPattern<iPTR, 2, "selectIntAddrMM", [frameindex]>; def simm4 : Operand<i32>; +def simm7 : Operand<i32>; def simm12 : Operand<i32> { let DecoderMethod = "DecodeSimm12"; @@ -20,6 +21,8 @@ def uimm3_shift : Operand<i32> { def immZExt2Shift : ImmLeaf<i32, [{return Imm >= 1 && Imm <= 8;}]>; +def immLi16 : ImmLeaf<i32, [{return Imm >= -1 && Imm <= 126;}]>; + def mem_mm_12 : Operand<i32> { let PrintMethod = "printMemOperand"; let MIOperandInfo = (ops GPR32, simm12); @@ -154,6 +157,13 @@ class MoveMM16<string opstr, RegisterOperand RO, bit isComm = 0, let isReMaterializable = 1; } +class LoadImmMM16<string opstr, Operand Od, RegisterOperand RO, + SDPatternOperator imm_type = null_frag> : + MicroMipsInst16<(outs RO:$rd), (ins Od:$imm), + !strconcat(opstr, "\t$rd, $imm"), [], NoItinerary, FrmI> { + let isReMaterializable = 1; +} + // 16-bit Jump and Link (Call) class JumpLinkRegMM16<string opstr, RegisterOperand RO> : MicroMipsInst16<(outs), (ins RO:$rs), !strconcat(opstr, "\t$rs"), @@ -240,6 +250,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 LI16_MM : LoadImmMM16<"li16", simm7, GPRMM16Opnd, immLi16>, + LI_FM_MM16, IsAsCheapAsAMove; def JALR16_MM : JumpLinkRegMM16<"jalr", GPR32Opnd>, JALR_FM_MM16<0x0e>; def JALRS16_MM : JumpLinkRegSMM16<"jalrs16", GPR32Opnd>, JALR_FM_MM16<0x0f>; def JRC16_MM : JumpRegCMM16<"jrc", GPR32Opnd>, JALR_FM_MM16<0x0d>; |

