| Akira Hatanaka | ecfb828 | 2012-09-22 00:07:12 +0000 | [diff] [blame] | 1 | //===- MipsDSPInstrInfo.td - DSP ASE instructions -*- tablegen ------------*-=// | 
|  | 2 | // | 
|  | 3 | //                     The LLVM Compiler Infrastructure | 
|  | 4 | // | 
|  | 5 | // This file is distributed under the University of Illinois Open Source | 
|  | 6 | // License. See LICENSE.TXT for details. | 
|  | 7 | // | 
|  | 8 | //===----------------------------------------------------------------------===// | 
|  | 9 | // | 
|  | 10 | // This file describes Mips DSP ASE instructions. | 
|  | 11 | // | 
|  | 12 | //===----------------------------------------------------------------------===// | 
|  | 13 |  | 
|  | 14 | // ImmLeaf | 
|  | 15 | def immZExt2 : ImmLeaf<i32, [{return isUInt<2>(Imm);}]>; | 
|  | 16 | def immZExt3 : ImmLeaf<i32, [{return isUInt<3>(Imm);}]>; | 
|  | 17 | def immZExt4 : ImmLeaf<i32, [{return isUInt<4>(Imm);}]>; | 
|  | 18 | def immZExt8 : ImmLeaf<i32, [{return isUInt<8>(Imm);}]>; | 
|  | 19 | def immZExt10 : ImmLeaf<i32, [{return isUInt<10>(Imm);}]>; | 
|  | 20 | def immSExt6 : ImmLeaf<i32, [{return isInt<6>(Imm);}]>; | 
| Akira Hatanaka | 5eeac4f | 2012-09-27 01:50:59 +0000 | [diff] [blame] | 21 |  | 
| Akira Hatanaka | 1babeaa | 2012-09-27 02:05:42 +0000 | [diff] [blame^] | 22 | // Mips-specific dsp nodes | 
|  | 23 | def SDT_MipsExtr : SDTypeProfile<1, 1, [SDTCisVT<0, i32>, SDTCisSameAs<0, 1>]>; | 
|  | 24 |  | 
|  | 25 | class MipsDSPSideEffectBase<string Opc, SDTypeProfile Prof> : | 
|  | 26 | SDNode<!strconcat("MipsISD::", Opc), Prof, | 
|  | 27 | [SDNPHasChain, SDNPInGlue, SDNPOutGlue, SDNPSideEffect]>; | 
|  | 28 |  | 
|  | 29 | def MipsEXTP : MipsDSPSideEffectBase<"EXTP", SDT_MipsExtr>; | 
|  | 30 | def MipsEXTPDP : MipsDSPSideEffectBase<"EXTPDP", SDT_MipsExtr>; | 
|  | 31 | def MipsEXTR_S_H : MipsDSPSideEffectBase<"EXTR_S_H", SDT_MipsExtr>; | 
|  | 32 | def MipsEXTR_W : MipsDSPSideEffectBase<"EXTR_W", SDT_MipsExtr>; | 
|  | 33 | def MipsEXTR_R_W : MipsDSPSideEffectBase<"EXTR_R_W", SDT_MipsExtr>; | 
|  | 34 | def MipsEXTR_RS_W : MipsDSPSideEffectBase<"EXTR_RS_W", SDT_MipsExtr>; | 
|  | 35 |  | 
|  | 36 | // Instruction encoding. | 
|  | 37 | class EXTP_ENC : EXTR_W_TY1_FMT<0b00010>; | 
|  | 38 | class EXTPV_ENC : EXTR_W_TY1_FMT<0b00011>; | 
|  | 39 | class EXTPDP_ENC : EXTR_W_TY1_FMT<0b01010>; | 
|  | 40 | class EXTPDPV_ENC : EXTR_W_TY1_FMT<0b01011>; | 
|  | 41 | class EXTR_W_ENC : EXTR_W_TY1_FMT<0b00000>; | 
|  | 42 | class EXTRV_W_ENC : EXTR_W_TY1_FMT<0b00001>; | 
|  | 43 | class EXTR_R_W_ENC : EXTR_W_TY1_FMT<0b00100>; | 
|  | 44 | class EXTRV_R_W_ENC : EXTR_W_TY1_FMT<0b00101>; | 
|  | 45 | class EXTR_RS_W_ENC : EXTR_W_TY1_FMT<0b00110>; | 
|  | 46 | class EXTRV_RS_W_ENC : EXTR_W_TY1_FMT<0b00111>; | 
|  | 47 | class EXTR_S_H_ENC : EXTR_W_TY1_FMT<0b01110>; | 
|  | 48 | class EXTRV_S_H_ENC : EXTR_W_TY1_FMT<0b01111>; | 
|  | 49 |  | 
|  | 50 | // Instruction desc. | 
|  | 51 | class EXTR_W_TY1_R2_DESC_BASE<string instr_asm, SDPatternOperator OpNode, | 
|  | 52 | InstrItinClass itin> { | 
|  | 53 | dag OutOperandList = (outs CPURegs:$rt); | 
|  | 54 | dag InOperandList = (ins ACRegs:$ac, CPURegs:$shift_rs); | 
|  | 55 | string AsmString = !strconcat(instr_asm, "\t$rt, $ac, $shift_rs"); | 
|  | 56 | InstrItinClass Itinerary = itin; | 
|  | 57 | list<Register> Defs = [DSPCtrl]; | 
|  | 58 | } | 
|  | 59 |  | 
|  | 60 | class EXTR_W_TY1_R1_DESC_BASE<string instr_asm, SDPatternOperator OpNode, | 
|  | 61 | InstrItinClass itin> { | 
|  | 62 | dag OutOperandList = (outs CPURegs:$rt); | 
|  | 63 | dag InOperandList = (ins ACRegs:$ac, uimm16:$shift_rs); | 
|  | 64 | string AsmString = !strconcat(instr_asm, "\t$rt, $ac, $shift_rs"); | 
|  | 65 | InstrItinClass Itinerary = itin; | 
|  | 66 | list<Register> Defs = [DSPCtrl]; | 
|  | 67 | } | 
|  | 68 |  | 
|  | 69 | //===----------------------------------------------------------------------===// | 
|  | 70 | // MIPS DSP Rev 1 | 
|  | 71 | //===----------------------------------------------------------------------===// | 
|  | 72 |  | 
|  | 73 | // Extr | 
|  | 74 | class EXTP_DESC : EXTR_W_TY1_R1_DESC_BASE<"extp", MipsEXTP, NoItinerary>; | 
|  | 75 |  | 
|  | 76 | class EXTPV_DESC : EXTR_W_TY1_R2_DESC_BASE<"extpv", MipsEXTP, NoItinerary>; | 
|  | 77 |  | 
|  | 78 | class EXTPDP_DESC : EXTR_W_TY1_R1_DESC_BASE<"extpdp", MipsEXTPDP, NoItinerary>; | 
|  | 79 |  | 
|  | 80 | class EXTPDPV_DESC : EXTR_W_TY1_R2_DESC_BASE<"extpdpv", MipsEXTPDP, | 
|  | 81 | NoItinerary>; | 
|  | 82 |  | 
|  | 83 | class EXTR_W_DESC : EXTR_W_TY1_R1_DESC_BASE<"extr.w", MipsEXTR_W, NoItinerary>; | 
|  | 84 |  | 
|  | 85 | class EXTRV_W_DESC : EXTR_W_TY1_R2_DESC_BASE<"extrv.w", MipsEXTR_W, | 
|  | 86 | NoItinerary>; | 
|  | 87 |  | 
|  | 88 | class EXTR_R_W_DESC : EXTR_W_TY1_R1_DESC_BASE<"extr_r.w", MipsEXTR_R_W, | 
|  | 89 | NoItinerary>; | 
|  | 90 |  | 
|  | 91 | class EXTRV_R_W_DESC : EXTR_W_TY1_R2_DESC_BASE<"extrv_r.w", MipsEXTR_R_W, | 
|  | 92 | NoItinerary>; | 
|  | 93 |  | 
|  | 94 | class EXTR_RS_W_DESC : EXTR_W_TY1_R1_DESC_BASE<"extr_rs.w", MipsEXTR_RS_W, | 
|  | 95 | NoItinerary>; | 
|  | 96 |  | 
|  | 97 | class EXTRV_RS_W_DESC : EXTR_W_TY1_R2_DESC_BASE<"extrv_rs.w", MipsEXTR_RS_W, | 
|  | 98 | NoItinerary>; | 
|  | 99 |  | 
|  | 100 | class EXTR_S_H_DESC : EXTR_W_TY1_R1_DESC_BASE<"extr_s.h", MipsEXTR_S_H, | 
|  | 101 | NoItinerary>; | 
|  | 102 |  | 
|  | 103 | class EXTRV_S_H_DESC : EXTR_W_TY1_R2_DESC_BASE<"extrv_s.h", MipsEXTR_S_H, | 
|  | 104 | NoItinerary>; | 
|  | 105 |  | 
|  | 106 | // Instruction defs. | 
|  | 107 | // MIPS DSP Rev 1 | 
|  | 108 | def EXTP : EXTP_ENC, EXTP_DESC; | 
|  | 109 | def EXTPV : EXTPV_ENC, EXTPV_DESC; | 
|  | 110 | def EXTPDP : EXTPDP_ENC, EXTPDP_DESC; | 
|  | 111 | def EXTPDPV : EXTPDPV_ENC, EXTPDPV_DESC; | 
|  | 112 | def EXTR_W : EXTR_W_ENC, EXTR_W_DESC; | 
|  | 113 | def EXTRV_W : EXTRV_W_ENC, EXTRV_W_DESC; | 
|  | 114 | def EXTR_R_W : EXTR_R_W_ENC, EXTR_R_W_DESC; | 
|  | 115 | def EXTRV_R_W : EXTRV_R_W_ENC, EXTRV_R_W_DESC; | 
|  | 116 | def EXTR_RS_W : EXTR_RS_W_ENC, EXTR_RS_W_DESC; | 
|  | 117 | def EXTRV_RS_W : EXTRV_RS_W_ENC, EXTRV_RS_W_DESC; | 
|  | 118 | def EXTR_S_H : EXTR_S_H_ENC, EXTR_S_H_DESC; | 
|  | 119 | def EXTRV_S_H : EXTRV_S_H_ENC, EXTRV_S_H_DESC; | 
|  | 120 |  | 
| Akira Hatanaka | 5eeac4f | 2012-09-27 01:50:59 +0000 | [diff] [blame] | 121 | // Patterns. | 
|  | 122 | class DSPPat<dag pattern, dag result, Predicate pred = HasDSP> : | 
|  | 123 | Pat<pattern, result>, Requires<[pred]>; | 
|  | 124 |  | 
| Akira Hatanaka | de8231ea | 2012-09-27 01:56:38 +0000 | [diff] [blame] | 125 | class BitconvertPat<ValueType DstVT, ValueType SrcVT, RegisterClass DstRC, | 
|  | 126 | RegisterClass SrcRC> : | 
|  | 127 | DSPPat<(DstVT (bitconvert (SrcVT SrcRC:$src))), | 
|  | 128 | (COPY_TO_REGCLASS SrcRC:$src, DstRC)>; | 
|  | 129 |  | 
|  | 130 | def : BitconvertPat<i32, v2i16, CPURegs, DSPRegs>; | 
|  | 131 | def : BitconvertPat<i32, v4i8, CPURegs, DSPRegs>; | 
|  | 132 | def : BitconvertPat<v2i16, i32, DSPRegs, CPURegs>; | 
|  | 133 | def : BitconvertPat<v4i8, i32, DSPRegs, CPURegs>; | 
|  | 134 |  | 
| Akira Hatanaka | 5eeac4f | 2012-09-27 01:50:59 +0000 | [diff] [blame] | 135 | def : DSPPat<(v2i16 (load addr:$a)), | 
|  | 136 | (v2i16 (COPY_TO_REGCLASS (LW addr:$a), DSPRegs))>; | 
|  | 137 | def : DSPPat<(v4i8 (load addr:$a)), | 
|  | 138 | (v4i8 (COPY_TO_REGCLASS (LW addr:$a), DSPRegs))>; | 
|  | 139 | def : DSPPat<(store (v2i16 DSPRegs:$val), addr:$a), | 
|  | 140 | (SW (COPY_TO_REGCLASS DSPRegs:$val, CPURegs), addr:$a)>; | 
|  | 141 | def : DSPPat<(store (v4i8 DSPRegs:$val), addr:$a), | 
|  | 142 | (SW (COPY_TO_REGCLASS DSPRegs:$val, CPURegs), addr:$a)>; | 
| Akira Hatanaka | 1babeaa | 2012-09-27 02:05:42 +0000 | [diff] [blame^] | 143 |  | 
|  | 144 | // Extr patterns. | 
|  | 145 | class EXTR_W_TY1_R2_Pat<SDPatternOperator OpNode, Instruction Instr> : | 
|  | 146 | DSPPat<(i32 (OpNode CPURegs:$rs)), (Instr AC0, CPURegs:$rs)>; | 
|  | 147 |  | 
|  | 148 | class EXTR_W_TY1_R1_Pat<SDPatternOperator OpNode, Instruction Instr> : | 
|  | 149 | DSPPat<(i32 (OpNode immZExt5:$shift)), (Instr AC0, immZExt5:$shift)>; | 
|  | 150 |  | 
|  | 151 | def : EXTR_W_TY1_R1_Pat<MipsEXTP, EXTP>; | 
|  | 152 | def : EXTR_W_TY1_R2_Pat<MipsEXTP, EXTPV>; | 
|  | 153 | def : EXTR_W_TY1_R1_Pat<MipsEXTPDP, EXTPDP>; | 
|  | 154 | def : EXTR_W_TY1_R2_Pat<MipsEXTPDP, EXTPDPV>; | 
|  | 155 | def : EXTR_W_TY1_R1_Pat<MipsEXTR_W, EXTR_W>; | 
|  | 156 | def : EXTR_W_TY1_R2_Pat<MipsEXTR_W, EXTRV_W>; | 
|  | 157 | def : EXTR_W_TY1_R1_Pat<MipsEXTR_R_W, EXTR_R_W>; | 
|  | 158 | def : EXTR_W_TY1_R2_Pat<MipsEXTR_R_W, EXTRV_R_W>; | 
|  | 159 | def : EXTR_W_TY1_R1_Pat<MipsEXTR_RS_W, EXTR_RS_W>; | 
|  | 160 | def : EXTR_W_TY1_R2_Pat<MipsEXTR_RS_W, EXTRV_RS_W>; | 
|  | 161 | def : EXTR_W_TY1_R1_Pat<MipsEXTR_S_H, EXTR_S_H>; | 
|  | 162 | def : EXTR_W_TY1_R2_Pat<MipsEXTR_S_H, EXTRV_S_H>; |