2012-09-22 08:06:06 +08:00
|
|
|
//===- MipsDSPInstrFormats.td - Mips Instruction Formats ---*- tablegen -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2015-10-13 00:07:25 +08:00
|
|
|
class DspMMRel;
|
|
|
|
|
|
|
|
def Dsp2MicroMips : InstrMapping {
|
|
|
|
let FilterClass = "DspMMRel";
|
|
|
|
// Instructions with the same BaseOpcode and isNVStore values form a row.
|
|
|
|
let RowFields = ["BaseOpcode"];
|
|
|
|
// Instructions with the same predicate sense form a column.
|
|
|
|
let ColFields = ["Arch"];
|
|
|
|
// The key column is the unpredicated instructions.
|
|
|
|
let KeyCol = ["dsp"];
|
|
|
|
// Value columns are PredSense=true and PredSense=false
|
|
|
|
let ValueCols = [["dsp"], ["mmdsp"]];
|
|
|
|
}
|
|
|
|
|
2014-07-11 01:26:51 +08:00
|
|
|
def HasDSP : Predicate<"Subtarget->hasDSP()">,
|
2012-09-22 08:06:06 +08:00
|
|
|
AssemblerPredicate<"FeatureDSP">;
|
2014-07-11 01:26:51 +08:00
|
|
|
def HasDSPR2 : Predicate<"Subtarget->hasDSPR2()">,
|
2012-09-22 08:06:06 +08:00
|
|
|
AssemblerPredicate<"FeatureDSPR2">;
|
2015-10-13 00:07:25 +08:00
|
|
|
def HasDSPR3 : Predicate<"Subtarget->hasDSPR3()">,
|
|
|
|
AssemblerPredicate<"FeatureDSPR3">;
|
2012-09-22 08:06:06 +08:00
|
|
|
|
2015-10-15 16:59:45 +08:00
|
|
|
class ISA_DSPR2 {
|
|
|
|
list<Predicate> InsnPredicates = [HasDSPR2];
|
|
|
|
}
|
|
|
|
|
2012-09-22 08:06:06 +08:00
|
|
|
// Fields.
|
|
|
|
class Field6<bits<6> val> {
|
|
|
|
bits<6> V = val;
|
|
|
|
}
|
|
|
|
|
|
|
|
def SPECIAL3_OPCODE : Field6<0b011111>;
|
|
|
|
def REGIMM_OPCODE : Field6<0b000001>;
|
|
|
|
|
2015-10-13 00:07:25 +08:00
|
|
|
class DSPInst<string opstr = "">
|
2015-12-18 16:59:37 +08:00
|
|
|
: MipsInst<(outs), (ins), "", [], NoItinerary, FrmOther>, PredicateControl {
|
|
|
|
let InsnPredicates = [HasDSP];
|
2015-10-13 00:07:25 +08:00
|
|
|
string BaseOpcode = opstr;
|
|
|
|
string Arch = "dsp";
|
2012-09-22 08:06:06 +08:00
|
|
|
}
|
2012-09-27 10:05:42 +08:00
|
|
|
|
2012-12-20 12:20:09 +08:00
|
|
|
class PseudoDSP<dag outs, dag ins, list<dag> pattern,
|
2015-12-18 16:59:37 +08:00
|
|
|
InstrItinClass itin = IIPseudo>
|
|
|
|
: MipsPseudo<outs, ins, pattern, itin>, PredicateControl {
|
|
|
|
let InsnPredicates = [HasDSP];
|
|
|
|
}
|
|
|
|
|
|
|
|
class DSPInstAlias<string Asm, dag Result, bit Emit = 0b1>
|
|
|
|
: InstAlias<Asm, Result, Emit>, PredicateControl {
|
|
|
|
let InsnPredicates = [HasDSP];
|
2012-09-27 10:11:20 +08:00
|
|
|
}
|
|
|
|
|
2012-09-27 11:13:59 +08:00
|
|
|
// ADDU.QB sub-class format.
|
|
|
|
class ADDU_QB_FMT<bits<5> op> : DSPInst {
|
|
|
|
bits<5> rd;
|
|
|
|
bits<5> rs;
|
|
|
|
bits<5> rt;
|
|
|
|
|
|
|
|
let Opcode = SPECIAL3_OPCODE.V;
|
|
|
|
|
|
|
|
let Inst{25-21} = rs;
|
|
|
|
let Inst{20-16} = rt;
|
|
|
|
let Inst{15-11} = rd;
|
|
|
|
let Inst{10-6} = op;
|
|
|
|
let Inst{5-0} = 0b010000;
|
|
|
|
}
|
|
|
|
|
|
|
|
class RADDU_W_QB_FMT<bits<5> op> : DSPInst {
|
|
|
|
bits<5> rd;
|
|
|
|
bits<5> rs;
|
|
|
|
|
|
|
|
let Opcode = SPECIAL3_OPCODE.V;
|
|
|
|
|
|
|
|
let Inst{25-21} = rs;
|
|
|
|
let Inst{20-16} = 0;
|
|
|
|
let Inst{15-11} = rd;
|
|
|
|
let Inst{10-6} = op;
|
|
|
|
let Inst{5-0} = 0b010000;
|
|
|
|
}
|
|
|
|
|
2012-09-27 11:58:34 +08:00
|
|
|
// CMPU.EQ.QB sub-class format.
|
|
|
|
class CMP_EQ_QB_R2_FMT<bits<5> op> : DSPInst {
|
|
|
|
bits<5> rs;
|
|
|
|
bits<5> rt;
|
|
|
|
|
|
|
|
let Opcode = SPECIAL3_OPCODE.V;
|
|
|
|
|
|
|
|
let Inst{25-21} = rs;
|
|
|
|
let Inst{20-16} = rt;
|
|
|
|
let Inst{15-11} = 0;
|
|
|
|
let Inst{10-6} = op;
|
|
|
|
let Inst{5-0} = 0b010001;
|
|
|
|
}
|
|
|
|
|
|
|
|
class CMP_EQ_QB_R3_FMT<bits<5> op> : DSPInst {
|
|
|
|
bits<5> rs;
|
|
|
|
bits<5> rt;
|
|
|
|
bits<5> rd;
|
|
|
|
|
|
|
|
let Opcode = SPECIAL3_OPCODE.V;
|
|
|
|
|
|
|
|
let Inst{25-21} = rs;
|
|
|
|
let Inst{20-16} = rt;
|
|
|
|
let Inst{15-11} = rd;
|
|
|
|
let Inst{10-6} = op;
|
|
|
|
let Inst{5-0} = 0b010001;
|
|
|
|
}
|
|
|
|
|
|
|
|
class PRECR_SRA_PH_W_FMT<bits<5> op> : DSPInst {
|
|
|
|
bits<5> rs;
|
|
|
|
bits<5> rt;
|
|
|
|
bits<5> sa;
|
|
|
|
|
|
|
|
let Opcode = SPECIAL3_OPCODE.V;
|
|
|
|
|
|
|
|
let Inst{25-21} = rs;
|
|
|
|
let Inst{20-16} = rt;
|
|
|
|
let Inst{15-11} = sa;
|
|
|
|
let Inst{10-6} = op;
|
|
|
|
let Inst{5-0} = 0b010001;
|
|
|
|
}
|
|
|
|
|
2012-09-28 03:09:21 +08:00
|
|
|
// ABSQ_S.PH sub-class format.
|
|
|
|
class ABSQ_S_PH_R2_FMT<bits<5> op> : DSPInst {
|
|
|
|
bits<5> rd;
|
|
|
|
bits<5> rt;
|
|
|
|
|
|
|
|
let Opcode = SPECIAL3_OPCODE.V;
|
|
|
|
|
|
|
|
let Inst{25-21} = 0;
|
|
|
|
let Inst{20-16} = rt;
|
|
|
|
let Inst{15-11} = rd;
|
|
|
|
let Inst{10-6} = op;
|
|
|
|
let Inst{5-0} = 0b010010;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
class REPL_FMT<bits<5> op> : DSPInst {
|
|
|
|
bits<5> rd;
|
|
|
|
bits<10> imm;
|
|
|
|
|
|
|
|
let Opcode = SPECIAL3_OPCODE.V;
|
|
|
|
|
|
|
|
let Inst{25-16} = imm;
|
|
|
|
let Inst{15-11} = rd;
|
|
|
|
let Inst{10-6} = op;
|
|
|
|
let Inst{5-0} = 0b010010;
|
|
|
|
}
|
|
|
|
|
2012-09-28 03:05:08 +08:00
|
|
|
// SHLL.QB sub-class format.
|
|
|
|
class SHLL_QB_FMT<bits<5> op> : DSPInst {
|
|
|
|
bits<5> rd;
|
|
|
|
bits<5> rt;
|
|
|
|
bits<5> rs_sa;
|
|
|
|
|
|
|
|
let Opcode = SPECIAL3_OPCODE.V;
|
|
|
|
|
|
|
|
let Inst{25-21} = rs_sa;
|
|
|
|
let Inst{20-16} = rt;
|
|
|
|
let Inst{15-11} = rd;
|
|
|
|
let Inst{10-6} = op;
|
|
|
|
let Inst{5-0} = 0b010011;
|
|
|
|
}
|
|
|
|
|
2012-09-29 04:50:31 +08:00
|
|
|
// LX sub-class format.
|
|
|
|
class LX_FMT<bits<5> op> : DSPInst {
|
|
|
|
bits<5> rd;
|
|
|
|
bits<5> base;
|
|
|
|
bits<5> index;
|
|
|
|
|
|
|
|
let Opcode = SPECIAL3_OPCODE.V;
|
|
|
|
|
|
|
|
let Inst{25-21} = base;
|
|
|
|
let Inst{20-16} = index;
|
|
|
|
let Inst{15-11} = rd;
|
|
|
|
let Inst{10-6} = op;
|
|
|
|
let Inst{5-0} = 0b001010;
|
|
|
|
}
|
|
|
|
|
2012-09-29 04:16:04 +08:00
|
|
|
// ADDUH.QB sub-class format.
|
|
|
|
class ADDUH_QB_FMT<bits<5> op> : DSPInst {
|
|
|
|
bits<5> rd;
|
|
|
|
bits<5> rs;
|
|
|
|
bits<5> rt;
|
|
|
|
|
|
|
|
let Opcode = SPECIAL3_OPCODE.V;
|
|
|
|
|
|
|
|
let Inst{25-21} = rs;
|
|
|
|
let Inst{20-16} = rt;
|
|
|
|
let Inst{15-11} = rd;
|
|
|
|
let Inst{10-6} = op;
|
|
|
|
let Inst{5-0} = 0b011000;
|
|
|
|
}
|
|
|
|
|
2012-09-29 04:50:31 +08:00
|
|
|
// APPEND sub-class format.
|
|
|
|
class APPEND_FMT<bits<5> op> : DSPInst {
|
|
|
|
bits<5> rt;
|
|
|
|
bits<5> rs;
|
|
|
|
bits<5> sa;
|
|
|
|
|
|
|
|
let Opcode = SPECIAL3_OPCODE.V;
|
|
|
|
|
|
|
|
let Inst{25-21} = rs;
|
|
|
|
let Inst{20-16} = rt;
|
|
|
|
let Inst{15-11} = sa;
|
|
|
|
let Inst{10-6} = op;
|
|
|
|
let Inst{5-0} = 0b110001;
|
|
|
|
}
|
|
|
|
|
2012-09-27 10:11:20 +08:00
|
|
|
// DPA.W.PH sub-class format.
|
|
|
|
class DPA_W_PH_FMT<bits<5> op> : DSPInst {
|
|
|
|
bits<2> ac;
|
|
|
|
bits<5> rs;
|
|
|
|
bits<5> rt;
|
|
|
|
|
|
|
|
let Opcode = SPECIAL3_OPCODE.V;
|
|
|
|
|
|
|
|
let Inst{25-21} = rs;
|
|
|
|
let Inst{20-16} = rt;
|
|
|
|
let Inst{15-13} = 0;
|
|
|
|
let Inst{12-11} = ac;
|
|
|
|
let Inst{10-6} = op;
|
|
|
|
let Inst{5-0} = 0b110000;
|
|
|
|
}
|
|
|
|
|
|
|
|
// MULT sub-class format.
|
|
|
|
class MULT_FMT<bits<6> opcode, bits<6> funct> : DSPInst {
|
|
|
|
bits<2> ac;
|
|
|
|
bits<5> rs;
|
|
|
|
bits<5> rt;
|
|
|
|
|
|
|
|
let Opcode = opcode;
|
|
|
|
|
|
|
|
let Inst{25-21} = rs;
|
|
|
|
let Inst{20-16} = rt;
|
|
|
|
let Inst{15-13} = 0;
|
|
|
|
let Inst{12-11} = ac;
|
|
|
|
let Inst{10-6} = 0;
|
|
|
|
let Inst{5-0} = funct;
|
|
|
|
}
|
|
|
|
|
2013-04-18 08:52:44 +08:00
|
|
|
// MFHI sub-class format.
|
|
|
|
class MFHI_FMT<bits<6> funct> : DSPInst {
|
|
|
|
bits<5> rd;
|
|
|
|
bits<2> ac;
|
|
|
|
|
|
|
|
let Inst{31-26} = 0;
|
|
|
|
let Inst{25-23} = 0;
|
|
|
|
let Inst{22-21} = ac;
|
|
|
|
let Inst{20-16} = 0;
|
|
|
|
let Inst{15-11} = rd;
|
|
|
|
let Inst{10-6} = 0;
|
|
|
|
let Inst{5-0} = funct;
|
|
|
|
}
|
|
|
|
|
|
|
|
// MTHI sub-class format.
|
|
|
|
class MTHI_FMT<bits<6> funct> : DSPInst {
|
|
|
|
bits<5> rs;
|
|
|
|
bits<2> ac;
|
|
|
|
|
|
|
|
let Inst{31-26} = 0;
|
|
|
|
let Inst{25-21} = rs;
|
|
|
|
let Inst{20-13} = 0;
|
|
|
|
let Inst{12-11} = ac;
|
|
|
|
let Inst{10-6} = 0;
|
|
|
|
let Inst{5-0} = funct;
|
|
|
|
}
|
|
|
|
|
2012-09-27 10:05:42 +08:00
|
|
|
// EXTR.W sub-class format (type 1).
|
|
|
|
class EXTR_W_TY1_FMT<bits<5> op> : DSPInst {
|
|
|
|
bits<5> rt;
|
|
|
|
bits<2> ac;
|
|
|
|
bits<5> shift_rs;
|
|
|
|
|
|
|
|
let Opcode = SPECIAL3_OPCODE.V;
|
|
|
|
|
|
|
|
let Inst{25-21} = shift_rs;
|
|
|
|
let Inst{20-16} = rt;
|
|
|
|
let Inst{15-13} = 0;
|
|
|
|
let Inst{12-11} = ac;
|
|
|
|
let Inst{10-6} = op;
|
|
|
|
let Inst{5-0} = 0b111000;
|
|
|
|
}
|
2012-09-27 10:11:20 +08:00
|
|
|
|
|
|
|
// SHILO sub-class format.
|
|
|
|
class SHILO_R1_FMT<bits<5> op> : DSPInst {
|
|
|
|
bits<2> ac;
|
|
|
|
bits<6> shift;
|
|
|
|
|
|
|
|
let Opcode = SPECIAL3_OPCODE.V;
|
|
|
|
|
|
|
|
let Inst{25-20} = shift;
|
|
|
|
let Inst{19-13} = 0;
|
|
|
|
let Inst{12-11} = ac;
|
|
|
|
let Inst{10-6} = op;
|
|
|
|
let Inst{5-0} = 0b111000;
|
|
|
|
}
|
|
|
|
|
|
|
|
class SHILO_R2_FMT<bits<5> op> : DSPInst {
|
|
|
|
bits<2> ac;
|
|
|
|
bits<5> rs;
|
|
|
|
|
|
|
|
let Opcode = SPECIAL3_OPCODE.V;
|
|
|
|
|
|
|
|
let Inst{25-21} = rs;
|
|
|
|
let Inst{20-13} = 0;
|
|
|
|
let Inst{12-11} = ac;
|
|
|
|
let Inst{10-6} = op;
|
|
|
|
let Inst{5-0} = 0b111000;
|
|
|
|
}
|
2012-09-27 10:15:57 +08:00
|
|
|
|
2012-09-27 12:08:42 +08:00
|
|
|
class RDDSP_FMT<bits<5> op> : DSPInst {
|
|
|
|
bits<5> rd;
|
|
|
|
bits<10> mask;
|
|
|
|
|
|
|
|
let Opcode = SPECIAL3_OPCODE.V;
|
|
|
|
|
|
|
|
let Inst{25-16} = mask;
|
|
|
|
let Inst{15-11} = rd;
|
|
|
|
let Inst{10-6} = op;
|
|
|
|
let Inst{5-0} = 0b111000;
|
|
|
|
}
|
|
|
|
|
2012-09-29 04:50:31 +08:00
|
|
|
class WRDSP_FMT<bits<5> op> : DSPInst {
|
|
|
|
bits<5> rs;
|
|
|
|
bits<10> mask;
|
|
|
|
|
|
|
|
let Opcode = SPECIAL3_OPCODE.V;
|
|
|
|
|
|
|
|
let Inst{25-21} = rs;
|
|
|
|
let Inst{20-11} = mask;
|
|
|
|
let Inst{10-6} = op;
|
|
|
|
let Inst{5-0} = 0b111000;
|
|
|
|
}
|
|
|
|
|
2012-09-27 10:15:57 +08:00
|
|
|
class BPOSGE32_FMT<bits<5> op> : DSPInst {
|
|
|
|
bits<16> offset;
|
|
|
|
|
|
|
|
let Opcode = REGIMM_OPCODE.V;
|
|
|
|
|
|
|
|
let Inst{25-21} = 0;
|
|
|
|
let Inst{20-16} = op;
|
|
|
|
let Inst{15-0} = offset;
|
|
|
|
}
|
2012-09-29 04:50:31 +08:00
|
|
|
|
|
|
|
// INSV sub-class format.
|
|
|
|
class INSV_FMT<bits<6> op> : DSPInst {
|
|
|
|
bits<5> rt;
|
|
|
|
bits<5> rs;
|
|
|
|
|
|
|
|
let Opcode = SPECIAL3_OPCODE.V;
|
|
|
|
|
|
|
|
let Inst{25-21} = rs;
|
|
|
|
let Inst{20-16} = rt;
|
|
|
|
let Inst{15-6} = 0;
|
|
|
|
let Inst{5-0} = op;
|
|
|
|
}
|