1*9880d681SAndroid Build Coastguard Worker//===- Mips64InstrInfo.td - Mips64 Instruction Information -*- tablegen -*-===// 2*9880d681SAndroid Build Coastguard Worker// 3*9880d681SAndroid Build Coastguard Worker// The LLVM Compiler Infrastructure 4*9880d681SAndroid Build Coastguard Worker// 5*9880d681SAndroid Build Coastguard Worker// This file is distributed under the University of Illinois Open Source 6*9880d681SAndroid Build Coastguard Worker// License. See LICENSE.TXT for details. 7*9880d681SAndroid Build Coastguard Worker// 8*9880d681SAndroid Build Coastguard Worker//===----------------------------------------------------------------------===// 9*9880d681SAndroid Build Coastguard Worker// 10*9880d681SAndroid Build Coastguard Worker// This file describes Mips64 instructions. 11*9880d681SAndroid Build Coastguard Worker// 12*9880d681SAndroid Build Coastguard Worker//===----------------------------------------------------------------------===// 13*9880d681SAndroid Build Coastguard Worker 14*9880d681SAndroid Build Coastguard Worker//===----------------------------------------------------------------------===// 15*9880d681SAndroid Build Coastguard Worker// Mips Operand, Complex Patterns and Transformations Definitions. 16*9880d681SAndroid Build Coastguard Worker//===----------------------------------------------------------------------===// 17*9880d681SAndroid Build Coastguard Worker 18*9880d681SAndroid Build Coastguard Worker// Transformation Function - get Imm - 32. 19*9880d681SAndroid Build Coastguard Workerdef Subtract32 : SDNodeXForm<imm, [{ 20*9880d681SAndroid Build Coastguard Worker return getImm(N, (unsigned)N->getZExtValue() - 32); 21*9880d681SAndroid Build Coastguard Worker}]>; 22*9880d681SAndroid Build Coastguard Worker 23*9880d681SAndroid Build Coastguard Worker// shamt must fit in 6 bits. 24*9880d681SAndroid Build Coastguard Workerdef immZExt6 : ImmLeaf<i32, [{return Imm == (Imm & 0x3f);}]>; 25*9880d681SAndroid Build Coastguard Worker 26*9880d681SAndroid Build Coastguard Worker// Node immediate fits as 10-bit sign extended on target immediate. 27*9880d681SAndroid Build Coastguard Worker// e.g. seqi, snei 28*9880d681SAndroid Build Coastguard Workerdef immSExt10_64 : PatLeaf<(i64 imm), 29*9880d681SAndroid Build Coastguard Worker [{ return isInt<10>(N->getSExtValue()); }]>; 30*9880d681SAndroid Build Coastguard Worker 31*9880d681SAndroid Build Coastguard Workerdef immZExt16_64 : PatLeaf<(i64 imm), 32*9880d681SAndroid Build Coastguard Worker [{ return isUInt<16>(N->getZExtValue()); }]>; 33*9880d681SAndroid Build Coastguard Worker 34*9880d681SAndroid Build Coastguard Workerdef immZExt5_64 : ImmLeaf<i64, [{ return Imm == (Imm & 0x1f); }]>; 35*9880d681SAndroid Build Coastguard Worker 36*9880d681SAndroid Build Coastguard Worker// Transformation function: get log2 of low 32 bits of immediate 37*9880d681SAndroid Build Coastguard Workerdef Log2LO : SDNodeXForm<imm, [{ 38*9880d681SAndroid Build Coastguard Worker return getImm(N, Log2_64((unsigned) N->getZExtValue())); 39*9880d681SAndroid Build Coastguard Worker}]>; 40*9880d681SAndroid Build Coastguard Worker 41*9880d681SAndroid Build Coastguard Worker// Transformation function: get log2 of high 32 bits of immediate 42*9880d681SAndroid Build Coastguard Workerdef Log2HI : SDNodeXForm<imm, [{ 43*9880d681SAndroid Build Coastguard Worker return getImm(N, Log2_64((unsigned) (N->getZExtValue() >> 32))); 44*9880d681SAndroid Build Coastguard Worker}]>; 45*9880d681SAndroid Build Coastguard Worker 46*9880d681SAndroid Build Coastguard Worker// Predicate: True if immediate is a power of 2 and fits 32 bits 47*9880d681SAndroid Build Coastguard Workerdef PowerOf2LO : PatLeaf<(imm), [{ 48*9880d681SAndroid Build Coastguard Worker if (N->getValueType(0) == MVT::i64) { 49*9880d681SAndroid Build Coastguard Worker uint64_t Imm = N->getZExtValue(); 50*9880d681SAndroid Build Coastguard Worker return isPowerOf2_64(Imm) && (Imm & 0xffffffff) == Imm; 51*9880d681SAndroid Build Coastguard Worker } 52*9880d681SAndroid Build Coastguard Worker else 53*9880d681SAndroid Build Coastguard Worker return false; 54*9880d681SAndroid Build Coastguard Worker}]>; 55*9880d681SAndroid Build Coastguard Worker 56*9880d681SAndroid Build Coastguard Worker// Predicate: True if immediate is a power of 2 and exceeds 32 bits 57*9880d681SAndroid Build Coastguard Workerdef PowerOf2HI : PatLeaf<(imm), [{ 58*9880d681SAndroid Build Coastguard Worker if (N->getValueType(0) == MVT::i64) { 59*9880d681SAndroid Build Coastguard Worker uint64_t Imm = N->getZExtValue(); 60*9880d681SAndroid Build Coastguard Worker return isPowerOf2_64(Imm) && (Imm & 0xffffffff00000000) == Imm; 61*9880d681SAndroid Build Coastguard Worker } 62*9880d681SAndroid Build Coastguard Worker else 63*9880d681SAndroid Build Coastguard Worker return false; 64*9880d681SAndroid Build Coastguard Worker}]>; 65*9880d681SAndroid Build Coastguard Worker 66*9880d681SAndroid Build Coastguard Workerdef assertzext_lt_i32 : PatFrag<(ops node:$src), (assertzext node:$src), [{ 67*9880d681SAndroid Build Coastguard Worker return cast<VTSDNode>(N->getOperand(1))->getVT().bitsLT(MVT::i32); 68*9880d681SAndroid Build Coastguard Worker}]>; 69*9880d681SAndroid Build Coastguard Worker 70*9880d681SAndroid Build Coastguard Worker//===----------------------------------------------------------------------===// 71*9880d681SAndroid Build Coastguard Worker// Instructions specific format 72*9880d681SAndroid Build Coastguard Worker//===----------------------------------------------------------------------===// 73*9880d681SAndroid Build Coastguard Workerlet usesCustomInserter = 1 in { 74*9880d681SAndroid Build Coastguard Worker def ATOMIC_LOAD_ADD_I64 : Atomic2Ops<atomic_load_add_64, GPR64>; 75*9880d681SAndroid Build Coastguard Worker def ATOMIC_LOAD_SUB_I64 : Atomic2Ops<atomic_load_sub_64, GPR64>; 76*9880d681SAndroid Build Coastguard Worker def ATOMIC_LOAD_AND_I64 : Atomic2Ops<atomic_load_and_64, GPR64>; 77*9880d681SAndroid Build Coastguard Worker def ATOMIC_LOAD_OR_I64 : Atomic2Ops<atomic_load_or_64, GPR64>; 78*9880d681SAndroid Build Coastguard Worker def ATOMIC_LOAD_XOR_I64 : Atomic2Ops<atomic_load_xor_64, GPR64>; 79*9880d681SAndroid Build Coastguard Worker def ATOMIC_LOAD_NAND_I64 : Atomic2Ops<atomic_load_nand_64, GPR64>; 80*9880d681SAndroid Build Coastguard Worker def ATOMIC_SWAP_I64 : Atomic2Ops<atomic_swap_64, GPR64>; 81*9880d681SAndroid Build Coastguard Worker def ATOMIC_CMP_SWAP_I64 : AtomicCmpSwap<atomic_cmp_swap_64, GPR64>; 82*9880d681SAndroid Build Coastguard Worker} 83*9880d681SAndroid Build Coastguard Worker 84*9880d681SAndroid Build Coastguard Worker/// Pseudo instructions for loading and storing accumulator registers. 85*9880d681SAndroid Build Coastguard Workerlet isPseudo = 1, isCodeGenOnly = 1, hasNoSchedulingInfo = 1 in { 86*9880d681SAndroid Build Coastguard Worker def LOAD_ACC128 : Load<"", ACC128>; 87*9880d681SAndroid Build Coastguard Worker def STORE_ACC128 : Store<"", ACC128>; 88*9880d681SAndroid Build Coastguard Worker} 89*9880d681SAndroid Build Coastguard Worker 90*9880d681SAndroid Build Coastguard Worker//===----------------------------------------------------------------------===// 91*9880d681SAndroid Build Coastguard Worker// Instruction definition 92*9880d681SAndroid Build Coastguard Worker//===----------------------------------------------------------------------===// 93*9880d681SAndroid Build Coastguard Workerlet DecoderNamespace = "Mips64" in { 94*9880d681SAndroid Build Coastguard Worker/// Arithmetic Instructions (ALU Immediate) 95*9880d681SAndroid Build Coastguard Workerdef DADDi : ArithLogicI<"daddi", simm16_64, GPR64Opnd, II_DADDI>, 96*9880d681SAndroid Build Coastguard Worker ADDI_FM<0x18>, ISA_MIPS3_NOT_32R6_64R6; 97*9880d681SAndroid Build Coastguard Workerlet AdditionalPredicates = [NotInMicroMips] in { 98*9880d681SAndroid Build Coastguard Worker def DADDiu : StdMMR6Rel, ArithLogicI<"daddiu", simm16_64, GPR64Opnd, 99*9880d681SAndroid Build Coastguard Worker II_DADDIU, immSExt16, add>, 100*9880d681SAndroid Build Coastguard Worker ADDI_FM<0x19>, IsAsCheapAsAMove, ISA_MIPS3; 101*9880d681SAndroid Build Coastguard Worker} 102*9880d681SAndroid Build Coastguard Worker 103*9880d681SAndroid Build Coastguard Workerlet isCodeGenOnly = 1 in { 104*9880d681SAndroid Build Coastguard Workerdef SLTi64 : SetCC_I<"slti", setlt, simm16_64, immSExt16, GPR64Opnd>, 105*9880d681SAndroid Build Coastguard Worker SLTI_FM<0xa>; 106*9880d681SAndroid Build Coastguard Workerdef SLTiu64 : SetCC_I<"sltiu", setult, simm16_64, immSExt16, GPR64Opnd>, 107*9880d681SAndroid Build Coastguard Worker SLTI_FM<0xb>; 108*9880d681SAndroid Build Coastguard Workerdef ANDi64 : ArithLogicI<"andi", uimm16_64, GPR64Opnd, II_AND, immZExt16, and>, 109*9880d681SAndroid Build Coastguard Worker ADDI_FM<0xc>; 110*9880d681SAndroid Build Coastguard Workerdef ORi64 : ArithLogicI<"ori", uimm16_64, GPR64Opnd, II_OR, immZExt16, or>, 111*9880d681SAndroid Build Coastguard Worker ADDI_FM<0xd>; 112*9880d681SAndroid Build Coastguard Workerdef XORi64 : ArithLogicI<"xori", uimm16_64, GPR64Opnd, II_XOR, immZExt16, xor>, 113*9880d681SAndroid Build Coastguard Worker ADDI_FM<0xe>; 114*9880d681SAndroid Build Coastguard Workerdef LUi64 : LoadUpper<"lui", GPR64Opnd, uimm16_64_relaxed>, LUI_FM; 115*9880d681SAndroid Build Coastguard Worker} 116*9880d681SAndroid Build Coastguard Worker 117*9880d681SAndroid Build Coastguard Worker/// Arithmetic Instructions (3-Operand, R-Type) 118*9880d681SAndroid Build Coastguard Workerlet AdditionalPredicates = [NotInMicroMips] in { 119*9880d681SAndroid Build Coastguard Worker def DADD : StdMMR6Rel, ArithLogicR<"dadd", GPR64Opnd, 1, II_DADD>, 120*9880d681SAndroid Build Coastguard Worker ADD_FM<0, 0x2c>, ISA_MIPS3; 121*9880d681SAndroid Build Coastguard Worker def DADDu : StdMMR6Rel, ArithLogicR<"daddu", GPR64Opnd, 1, II_DADDU, add>, 122*9880d681SAndroid Build Coastguard Worker ADD_FM<0, 0x2d>, ISA_MIPS3; 123*9880d681SAndroid Build Coastguard Worker def DSUBu : StdMMR6Rel, ArithLogicR<"dsubu", GPR64Opnd, 0, II_DSUBU, sub>, ADD_FM<0, 0x2f>, 124*9880d681SAndroid Build Coastguard Worker ISA_MIPS3; 125*9880d681SAndroid Build Coastguard Worker def DSUB : StdMMR6Rel, ArithLogicR<"dsub", GPR64Opnd, 0, II_DSUB>, ADD_FM<0, 0x2e>, 126*9880d681SAndroid Build Coastguard Worker ISA_MIPS3; 127*9880d681SAndroid Build Coastguard Worker} 128*9880d681SAndroid Build Coastguard Worker 129*9880d681SAndroid Build Coastguard Workerlet isCodeGenOnly = 1 in { 130*9880d681SAndroid Build Coastguard Workerdef SLT64 : SetCC_R<"slt", setlt, GPR64Opnd>, ADD_FM<0, 0x2a>; 131*9880d681SAndroid Build Coastguard Workerdef SLTu64 : SetCC_R<"sltu", setult, GPR64Opnd>, ADD_FM<0, 0x2b>; 132*9880d681SAndroid Build Coastguard Workerdef AND64 : ArithLogicR<"and", GPR64Opnd, 1, II_AND, and>, ADD_FM<0, 0x24>; 133*9880d681SAndroid Build Coastguard Workerdef OR64 : ArithLogicR<"or", GPR64Opnd, 1, II_OR, or>, ADD_FM<0, 0x25>; 134*9880d681SAndroid Build Coastguard Workerdef XOR64 : ArithLogicR<"xor", GPR64Opnd, 1, II_XOR, xor>, ADD_FM<0, 0x26>; 135*9880d681SAndroid Build Coastguard Workerdef NOR64 : LogicNOR<"nor", GPR64Opnd>, ADD_FM<0, 0x27>; 136*9880d681SAndroid Build Coastguard Worker} 137*9880d681SAndroid Build Coastguard Worker 138*9880d681SAndroid Build Coastguard Worker/// Shift Instructions 139*9880d681SAndroid Build Coastguard Workerlet AdditionalPredicates = [NotInMicroMips] in { 140*9880d681SAndroid Build Coastguard Worker def DSLL : StdMMR6Rel, shift_rotate_imm<"dsll", uimm6, GPR64Opnd, II_DSLL, 141*9880d681SAndroid Build Coastguard Worker shl, immZExt6>, 142*9880d681SAndroid Build Coastguard Worker SRA_FM<0x38, 0>, ISA_MIPS3; 143*9880d681SAndroid Build Coastguard Worker def DSRL : StdMMR6Rel, shift_rotate_imm<"dsrl", uimm6, GPR64Opnd, II_DSRL, 144*9880d681SAndroid Build Coastguard Worker srl, immZExt6>, 145*9880d681SAndroid Build Coastguard Worker SRA_FM<0x3a, 0>, ISA_MIPS3; 146*9880d681SAndroid Build Coastguard Worker def DSRA : StdMMR6Rel, shift_rotate_imm<"dsra", uimm6, GPR64Opnd, II_DSRA, 147*9880d681SAndroid Build Coastguard Worker sra, immZExt6>, 148*9880d681SAndroid Build Coastguard Worker SRA_FM<0x3b, 0>, ISA_MIPS3; 149*9880d681SAndroid Build Coastguard Worker def DSLLV : StdMMR6Rel, shift_rotate_reg<"dsllv", GPR64Opnd, II_DSLLV, shl>, 150*9880d681SAndroid Build Coastguard Worker SRLV_FM<0x14, 0>, ISA_MIPS3; 151*9880d681SAndroid Build Coastguard Worker def DSRAV : StdMMR6Rel, shift_rotate_reg<"dsrav", GPR64Opnd, II_DSRAV, sra>, 152*9880d681SAndroid Build Coastguard Worker SRLV_FM<0x17, 0>, ISA_MIPS3; 153*9880d681SAndroid Build Coastguard Worker def DSRLV : StdMMR6Rel, shift_rotate_reg<"dsrlv", GPR64Opnd, II_DSRLV, srl>, 154*9880d681SAndroid Build Coastguard Worker SRLV_FM<0x16, 0>, ISA_MIPS3; 155*9880d681SAndroid Build Coastguard Worker def DSLL32 : StdMMR6Rel, shift_rotate_imm<"dsll32", uimm5, GPR64Opnd, 156*9880d681SAndroid Build Coastguard Worker II_DSLL32>, 157*9880d681SAndroid Build Coastguard Worker SRA_FM<0x3c, 0>, ISA_MIPS3; 158*9880d681SAndroid Build Coastguard Worker def DSRL32 : StdMMR6Rel, shift_rotate_imm<"dsrl32", uimm5, GPR64Opnd, 159*9880d681SAndroid Build Coastguard Worker II_DSRL32>, 160*9880d681SAndroid Build Coastguard Worker SRA_FM<0x3e, 0>, ISA_MIPS3; 161*9880d681SAndroid Build Coastguard Worker def DSRA32 : StdMMR6Rel, shift_rotate_imm<"dsra32", uimm5, GPR64Opnd, 162*9880d681SAndroid Build Coastguard Worker II_DSRA32>, 163*9880d681SAndroid Build Coastguard Worker SRA_FM<0x3f, 0>, ISA_MIPS3; 164*9880d681SAndroid Build Coastguard Worker 165*9880d681SAndroid Build Coastguard Worker// Rotate Instructions 166*9880d681SAndroid Build Coastguard Worker def DROTR : StdMMR6Rel, shift_rotate_imm<"drotr", uimm6, GPR64Opnd, II_DROTR, 167*9880d681SAndroid Build Coastguard Worker rotr, immZExt6>, 168*9880d681SAndroid Build Coastguard Worker SRA_FM<0x3a, 1>, ISA_MIPS64R2; 169*9880d681SAndroid Build Coastguard Worker def DROTRV : StdMMR6Rel, shift_rotate_reg<"drotrv", GPR64Opnd, II_DROTRV, 170*9880d681SAndroid Build Coastguard Worker rotr>, 171*9880d681SAndroid Build Coastguard Worker SRLV_FM<0x16, 1>, ISA_MIPS64R2; 172*9880d681SAndroid Build Coastguard Worker def DROTR32 : StdMMR6Rel, shift_rotate_imm<"drotr32", uimm5, GPR64Opnd, 173*9880d681SAndroid Build Coastguard Worker II_DROTR32>, 174*9880d681SAndroid Build Coastguard Worker SRA_FM<0x3e, 1>, ISA_MIPS64R2; 175*9880d681SAndroid Build Coastguard Worker} 176*9880d681SAndroid Build Coastguard Worker 177*9880d681SAndroid Build Coastguard Worker/// Load and Store Instructions 178*9880d681SAndroid Build Coastguard Worker/// aligned 179*9880d681SAndroid Build Coastguard Workerlet isCodeGenOnly = 1 in { 180*9880d681SAndroid Build Coastguard Workerdef LB64 : Load<"lb", GPR64Opnd, sextloadi8, II_LB>, LW_FM<0x20>; 181*9880d681SAndroid Build Coastguard Workerdef LBu64 : Load<"lbu", GPR64Opnd, zextloadi8, II_LBU>, LW_FM<0x24>; 182*9880d681SAndroid Build Coastguard Workerdef LH64 : Load<"lh", GPR64Opnd, sextloadi16, II_LH>, LW_FM<0x21>; 183*9880d681SAndroid Build Coastguard Workerdef LHu64 : Load<"lhu", GPR64Opnd, zextloadi16, II_LHU>, LW_FM<0x25>; 184*9880d681SAndroid Build Coastguard Workerdef LW64 : Load<"lw", GPR64Opnd, sextloadi32, II_LW>, LW_FM<0x23>; 185*9880d681SAndroid Build Coastguard Workerdef SB64 : Store<"sb", GPR64Opnd, truncstorei8, II_SB>, LW_FM<0x28>; 186*9880d681SAndroid Build Coastguard Workerdef SH64 : Store<"sh", GPR64Opnd, truncstorei16, II_SH>, LW_FM<0x29>; 187*9880d681SAndroid Build Coastguard Workerdef SW64 : Store<"sw", GPR64Opnd, truncstorei32, II_SW>, LW_FM<0x2b>; 188*9880d681SAndroid Build Coastguard Worker} 189*9880d681SAndroid Build Coastguard Worker 190*9880d681SAndroid Build Coastguard Workerlet AdditionalPredicates = [NotInMicroMips] in { 191*9880d681SAndroid Build Coastguard Worker def LWu : StdMMR6Rel, MMRel, Load<"lwu", GPR64Opnd, zextloadi32, II_LWU>, 192*9880d681SAndroid Build Coastguard Worker LW_FM<0x27>, ISA_MIPS3; 193*9880d681SAndroid Build Coastguard Worker def LD : StdMMR6Rel, LoadMemory<"ld", GPR64Opnd, mem_simm16, load, II_LD>, 194*9880d681SAndroid Build Coastguard Worker LW_FM<0x37>, ISA_MIPS3; 195*9880d681SAndroid Build Coastguard Worker def SD : StdMMR6Rel, StoreMemory<"sd", GPR64Opnd, mem_simm16, store, II_SD>, 196*9880d681SAndroid Build Coastguard Worker LW_FM<0x3f>, ISA_MIPS3; 197*9880d681SAndroid Build Coastguard Worker} 198*9880d681SAndroid Build Coastguard Worker 199*9880d681SAndroid Build Coastguard Worker 200*9880d681SAndroid Build Coastguard Worker 201*9880d681SAndroid Build Coastguard Worker/// load/store left/right 202*9880d681SAndroid Build Coastguard Workerlet isCodeGenOnly = 1 in { 203*9880d681SAndroid Build Coastguard Workerdef LWL64 : LoadLeftRight<"lwl", MipsLWL, GPR64Opnd, II_LWL>, LW_FM<0x22>; 204*9880d681SAndroid Build Coastguard Workerdef LWR64 : LoadLeftRight<"lwr", MipsLWR, GPR64Opnd, II_LWR>, LW_FM<0x26>; 205*9880d681SAndroid Build Coastguard Workerdef SWL64 : StoreLeftRight<"swl", MipsSWL, GPR64Opnd, II_SWL>, LW_FM<0x2a>; 206*9880d681SAndroid Build Coastguard Workerdef SWR64 : StoreLeftRight<"swr", MipsSWR, GPR64Opnd, II_SWR>, LW_FM<0x2e>; 207*9880d681SAndroid Build Coastguard Worker} 208*9880d681SAndroid Build Coastguard Worker 209*9880d681SAndroid Build Coastguard Workerdef LDL : LoadLeftRight<"ldl", MipsLDL, GPR64Opnd, II_LDL>, LW_FM<0x1a>, 210*9880d681SAndroid Build Coastguard Worker ISA_MIPS3_NOT_32R6_64R6; 211*9880d681SAndroid Build Coastguard Workerdef LDR : LoadLeftRight<"ldr", MipsLDR, GPR64Opnd, II_LDR>, LW_FM<0x1b>, 212*9880d681SAndroid Build Coastguard Worker ISA_MIPS3_NOT_32R6_64R6; 213*9880d681SAndroid Build Coastguard Workerdef SDL : StoreLeftRight<"sdl", MipsSDL, GPR64Opnd, II_SDL>, LW_FM<0x2c>, 214*9880d681SAndroid Build Coastguard Worker ISA_MIPS3_NOT_32R6_64R6; 215*9880d681SAndroid Build Coastguard Workerdef SDR : StoreLeftRight<"sdr", MipsSDR, GPR64Opnd, II_SDR>, LW_FM<0x2d>, 216*9880d681SAndroid Build Coastguard Worker ISA_MIPS3_NOT_32R6_64R6; 217*9880d681SAndroid Build Coastguard Worker 218*9880d681SAndroid Build Coastguard Worker/// Load-linked, Store-conditional 219*9880d681SAndroid Build Coastguard Workerlet AdditionalPredicates = [NotInMicroMips] in { 220*9880d681SAndroid Build Coastguard Worker def LLD : StdMMR6Rel, LLBase<"lld", GPR64Opnd, mem_simm16>, LW_FM<0x34>, 221*9880d681SAndroid Build Coastguard Worker ISA_MIPS3_NOT_32R6_64R6; 222*9880d681SAndroid Build Coastguard Worker} 223*9880d681SAndroid Build Coastguard Workerdef SCD : SCBase<"scd", GPR64Opnd>, LW_FM<0x3c>, ISA_MIPS3_NOT_32R6_64R6; 224*9880d681SAndroid Build Coastguard Worker 225*9880d681SAndroid Build Coastguard Workerlet AdditionalPredicates = [NotInMicroMips], 226*9880d681SAndroid Build Coastguard Worker DecoderNamespace = "Mips32_64_PTR64" in { 227*9880d681SAndroid Build Coastguard Workerdef LL64 : LLBase<"ll", GPR32Opnd>, LW_FM<0x30>, PTR_64, 228*9880d681SAndroid Build Coastguard Worker ISA_MIPS2_NOT_32R6_64R6; 229*9880d681SAndroid Build Coastguard Workerdef SC64 : SCBase<"sc", GPR32Opnd>, LW_FM<0x38>, PTR_64, 230*9880d681SAndroid Build Coastguard Worker ISA_MIPS2_NOT_32R6_64R6; 231*9880d681SAndroid Build Coastguard Worker} 232*9880d681SAndroid Build Coastguard Worker 233*9880d681SAndroid Build Coastguard Worker/// Jump and Branch Instructions 234*9880d681SAndroid Build Coastguard Workerlet isCodeGenOnly = 1 in { 235*9880d681SAndroid Build Coastguard Worker def JR64 : IndirectBranch<"jr", GPR64Opnd>, MTLO_FM<8>; 236*9880d681SAndroid Build Coastguard Worker def BEQ64 : CBranch<"beq", brtarget, seteq, GPR64Opnd>, BEQ_FM<4>; 237*9880d681SAndroid Build Coastguard Worker def BNE64 : CBranch<"bne", brtarget, setne, GPR64Opnd>, BEQ_FM<5>; 238*9880d681SAndroid Build Coastguard Worker def BGEZ64 : CBranchZero<"bgez", brtarget, setge, GPR64Opnd>, BGEZ_FM<1, 1>; 239*9880d681SAndroid Build Coastguard Worker def BGTZ64 : CBranchZero<"bgtz", brtarget, setgt, GPR64Opnd>, BGEZ_FM<7, 0>; 240*9880d681SAndroid Build Coastguard Worker def BLEZ64 : CBranchZero<"blez", brtarget, setle, GPR64Opnd>, BGEZ_FM<6, 0>; 241*9880d681SAndroid Build Coastguard Worker def BLTZ64 : CBranchZero<"bltz", brtarget, setlt, GPR64Opnd>, BGEZ_FM<1, 0>; 242*9880d681SAndroid Build Coastguard Worker def JALR64 : JumpLinkReg<"jalr", GPR64Opnd>, JALR_FM; 243*9880d681SAndroid Build Coastguard Worker def JALR64Pseudo : JumpLinkRegPseudo<GPR64Opnd, JALR, RA, GPR32Opnd>; 244*9880d681SAndroid Build Coastguard Worker def TAILCALL64_R : TailCallReg<GPR64Opnd, JR, GPR32Opnd>; 245*9880d681SAndroid Build Coastguard Worker} 246*9880d681SAndroid Build Coastguard Worker 247*9880d681SAndroid Build Coastguard Workerdef PseudoReturn64 : PseudoReturnBase<GPR64Opnd>; 248*9880d681SAndroid Build Coastguard Workerdef PseudoIndirectBranch64 : PseudoIndirectBranchBase<GPR64Opnd>; 249*9880d681SAndroid Build Coastguard Worker 250*9880d681SAndroid Build Coastguard Worker/// Multiply and Divide Instructions. 251*9880d681SAndroid Build Coastguard Workerlet AdditionalPredicates = [NotInMicroMips] in { 252*9880d681SAndroid Build Coastguard Worker def DMULT : Mult<"dmult", II_DMULT, GPR64Opnd, [HI0_64, LO0_64]>, 253*9880d681SAndroid Build Coastguard Worker MULT_FM<0, 0x1c>, ISA_MIPS3_NOT_32R6_64R6; 254*9880d681SAndroid Build Coastguard Worker def DMULTu : Mult<"dmultu", II_DMULTU, GPR64Opnd, [HI0_64, LO0_64]>, 255*9880d681SAndroid Build Coastguard Worker MULT_FM<0, 0x1d>, ISA_MIPS3_NOT_32R6_64R6; 256*9880d681SAndroid Build Coastguard Worker} 257*9880d681SAndroid Build Coastguard Workerdef PseudoDMULT : MultDivPseudo<DMULT, ACC128, GPR64Opnd, MipsMult, 258*9880d681SAndroid Build Coastguard Worker II_DMULT>, ISA_MIPS3_NOT_32R6_64R6; 259*9880d681SAndroid Build Coastguard Workerdef PseudoDMULTu : MultDivPseudo<DMULTu, ACC128, GPR64Opnd, MipsMultu, 260*9880d681SAndroid Build Coastguard Worker II_DMULTU>, ISA_MIPS3_NOT_32R6_64R6; 261*9880d681SAndroid Build Coastguard Workerlet AdditionalPredicates = [NotInMicroMips] in { 262*9880d681SAndroid Build Coastguard Worker def DSDIV : Div<"ddiv", II_DDIV, GPR64Opnd, [HI0_64, LO0_64]>, 263*9880d681SAndroid Build Coastguard Worker MULT_FM<0, 0x1e>, ISA_MIPS3_NOT_32R6_64R6; 264*9880d681SAndroid Build Coastguard Worker def DUDIV : Div<"ddivu", II_DDIVU, GPR64Opnd, [HI0_64, LO0_64]>, 265*9880d681SAndroid Build Coastguard Worker MULT_FM<0, 0x1f>, ISA_MIPS3_NOT_32R6_64R6; 266*9880d681SAndroid Build Coastguard Worker} 267*9880d681SAndroid Build Coastguard Workerdef PseudoDSDIV : MultDivPseudo<DSDIV, ACC128, GPR64Opnd, MipsDivRem, 268*9880d681SAndroid Build Coastguard Worker II_DDIV, 0, 1, 1>, ISA_MIPS3_NOT_32R6_64R6; 269*9880d681SAndroid Build Coastguard Workerdef PseudoDUDIV : MultDivPseudo<DUDIV, ACC128, GPR64Opnd, MipsDivRemU, 270*9880d681SAndroid Build Coastguard Worker II_DDIVU, 0, 1, 1>, ISA_MIPS3_NOT_32R6_64R6; 271*9880d681SAndroid Build Coastguard Worker 272*9880d681SAndroid Build Coastguard Workerlet isCodeGenOnly = 1 in { 273*9880d681SAndroid Build Coastguard Workerdef MTHI64 : MoveToLOHI<"mthi", GPR64Opnd, [HI0_64]>, MTLO_FM<0x11>, 274*9880d681SAndroid Build Coastguard Worker ISA_MIPS3_NOT_32R6_64R6; 275*9880d681SAndroid Build Coastguard Workerdef MTLO64 : MoveToLOHI<"mtlo", GPR64Opnd, [LO0_64]>, MTLO_FM<0x13>, 276*9880d681SAndroid Build Coastguard Worker ISA_MIPS3_NOT_32R6_64R6; 277*9880d681SAndroid Build Coastguard Workerdef MFHI64 : MoveFromLOHI<"mfhi", GPR64Opnd, AC0_64>, MFLO_FM<0x10>, 278*9880d681SAndroid Build Coastguard Worker ISA_MIPS3_NOT_32R6_64R6; 279*9880d681SAndroid Build Coastguard Workerdef MFLO64 : MoveFromLOHI<"mflo", GPR64Opnd, AC0_64>, MFLO_FM<0x12>, 280*9880d681SAndroid Build Coastguard Worker ISA_MIPS3_NOT_32R6_64R6; 281*9880d681SAndroid Build Coastguard Workerdef PseudoMFHI64 : PseudoMFLOHI<GPR64, ACC128, MipsMFHI>, 282*9880d681SAndroid Build Coastguard Worker ISA_MIPS3_NOT_32R6_64R6; 283*9880d681SAndroid Build Coastguard Workerdef PseudoMFLO64 : PseudoMFLOHI<GPR64, ACC128, MipsMFLO>, 284*9880d681SAndroid Build Coastguard Worker ISA_MIPS3_NOT_32R6_64R6; 285*9880d681SAndroid Build Coastguard Workerdef PseudoMTLOHI64 : PseudoMTLOHI<ACC128, GPR64>, ISA_MIPS3_NOT_32R6_64R6; 286*9880d681SAndroid Build Coastguard Worker 287*9880d681SAndroid Build Coastguard Worker/// Sign Ext In Register Instructions. 288*9880d681SAndroid Build Coastguard Workerdef SEB64 : SignExtInReg<"seb", i8, GPR64Opnd, II_SEB>, SEB_FM<0x10, 0x20>, 289*9880d681SAndroid Build Coastguard Worker ISA_MIPS32R2; 290*9880d681SAndroid Build Coastguard Workerdef SEH64 : SignExtInReg<"seh", i16, GPR64Opnd, II_SEH>, SEB_FM<0x18, 0x20>, 291*9880d681SAndroid Build Coastguard Worker ISA_MIPS32R2; 292*9880d681SAndroid Build Coastguard Worker} 293*9880d681SAndroid Build Coastguard Worker 294*9880d681SAndroid Build Coastguard Worker/// Count Leading 295*9880d681SAndroid Build Coastguard Workerlet AdditionalPredicates = [NotInMicroMips] in { 296*9880d681SAndroid Build Coastguard Worker def DCLZ : StdMMR6Rel, CountLeading0<"dclz", GPR64Opnd>, CLO_FM<0x24>, 297*9880d681SAndroid Build Coastguard Worker ISA_MIPS64_NOT_64R6; 298*9880d681SAndroid Build Coastguard Worker def DCLO : StdMMR6Rel, CountLeading1<"dclo", GPR64Opnd>, CLO_FM<0x25>, 299*9880d681SAndroid Build Coastguard Worker ISA_MIPS64_NOT_64R6; 300*9880d681SAndroid Build Coastguard Worker 301*9880d681SAndroid Build Coastguard Worker/// Double Word Swap Bytes/HalfWords 302*9880d681SAndroid Build Coastguard Worker def DSBH : SubwordSwap<"dsbh", GPR64Opnd>, SEB_FM<2, 0x24>, ISA_MIPS64R2; 303*9880d681SAndroid Build Coastguard Worker def DSHD : SubwordSwap<"dshd", GPR64Opnd>, SEB_FM<5, 0x24>, ISA_MIPS64R2; 304*9880d681SAndroid Build Coastguard Worker} 305*9880d681SAndroid Build Coastguard Worker 306*9880d681SAndroid Build Coastguard Workerdef LEA_ADDiu64 : EffectiveAddress<"daddiu", GPR64Opnd>, LW_FM<0x19>; 307*9880d681SAndroid Build Coastguard Worker 308*9880d681SAndroid Build Coastguard Workerlet isCodeGenOnly = 1 in 309*9880d681SAndroid Build Coastguard Workerdef RDHWR64 : ReadHardware<GPR64Opnd, HWRegsOpnd>, RDHWR_FM; 310*9880d681SAndroid Build Coastguard Worker 311*9880d681SAndroid Build Coastguard Workerlet AdditionalPredicates = [NotInMicroMips] in { 312*9880d681SAndroid Build Coastguard Worker // The 'pos + size' constraints are enforced by the code that lowers into 313*9880d681SAndroid Build Coastguard Worker // MipsISD::Ext. 314*9880d681SAndroid Build Coastguard Worker def DEXT : ExtBase<"dext", GPR64Opnd, uimm5_report_uimm6, uimm5_plus1, 315*9880d681SAndroid Build Coastguard Worker immZExt5, immZExt5Plus1, MipsExt>, EXT_FM<3>, 316*9880d681SAndroid Build Coastguard Worker ISA_MIPS64R2; 317*9880d681SAndroid Build Coastguard Worker def DEXTM : ExtBase<"dextm", GPR64Opnd, uimm5, uimm5_plus33, immZExt5, 318*9880d681SAndroid Build Coastguard Worker immZExt5Plus33, MipsExt>, EXT_FM<1>, ISA_MIPS64R2; 319*9880d681SAndroid Build Coastguard Worker def DEXTU : ExtBase<"dextu", GPR64Opnd, uimm5_plus32, uimm5_plus1, 320*9880d681SAndroid Build Coastguard Worker immZExt5Plus32, immZExt5Plus1, MipsExt>, EXT_FM<2>, 321*9880d681SAndroid Build Coastguard Worker ISA_MIPS64R2; 322*9880d681SAndroid Build Coastguard Worker def DINS : InsBase<"dins", GPR64Opnd, uimm6, uimm5_inssize_plus1, MipsIns>, 323*9880d681SAndroid Build Coastguard Worker EXT_FM<7>, ISA_MIPS64R2; 324*9880d681SAndroid Build Coastguard Worker def DINSU : InsBase<"dinsu", GPR64Opnd, uimm5_plus32, uimm5_inssize_plus1>, 325*9880d681SAndroid Build Coastguard Worker EXT_FM<6>, ISA_MIPS64R2; 326*9880d681SAndroid Build Coastguard Worker def DINSM : InsBase<"dinsm", GPR64Opnd, uimm5, uimm5_inssize_plus1>, 327*9880d681SAndroid Build Coastguard Worker EXT_FM<5>, ISA_MIPS64R2; 328*9880d681SAndroid Build Coastguard Worker} 329*9880d681SAndroid Build Coastguard Worker 330*9880d681SAndroid Build Coastguard Workerlet isCodeGenOnly = 1, rs = 0, shamt = 0 in { 331*9880d681SAndroid Build Coastguard Worker def DSLL64_32 : FR<0x00, 0x3c, (outs GPR64:$rd), (ins GPR32:$rt), 332*9880d681SAndroid Build Coastguard Worker "dsll\t$rd, $rt, 32", [], II_DSLL>; 333*9880d681SAndroid Build Coastguard Worker def SLL64_32 : FR<0x0, 0x00, (outs GPR64:$rd), (ins GPR32:$rt), 334*9880d681SAndroid Build Coastguard Worker "sll\t$rd, $rt, 0", [], II_SLL>; 335*9880d681SAndroid Build Coastguard Worker def SLL64_64 : FR<0x0, 0x00, (outs GPR64:$rd), (ins GPR64:$rt), 336*9880d681SAndroid Build Coastguard Worker "sll\t$rd, $rt, 0", [], II_SLL>; 337*9880d681SAndroid Build Coastguard Worker} 338*9880d681SAndroid Build Coastguard Worker 339*9880d681SAndroid Build Coastguard Worker// We need the following pseudo instruction to avoid offset calculation for 340*9880d681SAndroid Build Coastguard Worker// long branches. See the comment in file MipsLongBranch.cpp for detailed 341*9880d681SAndroid Build Coastguard Worker// explanation. 342*9880d681SAndroid Build Coastguard Worker 343*9880d681SAndroid Build Coastguard Worker// Expands to: daddiu $dst, $src, %PART($tgt - $baltgt) 344*9880d681SAndroid Build Coastguard Worker// where %PART may be %hi or %lo, depending on the relocation kind 345*9880d681SAndroid Build Coastguard Worker// that $tgt is annotated with. 346*9880d681SAndroid Build Coastguard Workerdef LONG_BRANCH_DADDiu : PseudoSE<(outs GPR64Opnd:$dst), 347*9880d681SAndroid Build Coastguard Worker (ins GPR64Opnd:$src, brtarget:$tgt, brtarget:$baltgt), []>; 348*9880d681SAndroid Build Coastguard Worker 349*9880d681SAndroid Build Coastguard Worker// Cavium Octeon cnMIPS instructions 350*9880d681SAndroid Build Coastguard Workerlet DecoderNamespace = "CnMips", 351*9880d681SAndroid Build Coastguard Worker // FIXME: The lack of HasStdEnc is probably a bug 352*9880d681SAndroid Build Coastguard Worker EncodingPredicates = []<Predicate> in { 353*9880d681SAndroid Build Coastguard Worker 354*9880d681SAndroid Build Coastguard Workerclass Count1s<string opstr, RegisterOperand RO>: 355*9880d681SAndroid Build Coastguard Worker InstSE<(outs RO:$rd), (ins RO:$rs), !strconcat(opstr, "\t$rd, $rs"), 356*9880d681SAndroid Build Coastguard Worker [(set RO:$rd, (ctpop RO:$rs))], II_POP, FrmR, opstr> { 357*9880d681SAndroid Build Coastguard Worker let TwoOperandAliasConstraint = "$rd = $rs"; 358*9880d681SAndroid Build Coastguard Worker} 359*9880d681SAndroid Build Coastguard Worker 360*9880d681SAndroid Build Coastguard Workerclass ExtsCins<string opstr, SDPatternOperator Op = null_frag>: 361*9880d681SAndroid Build Coastguard Worker InstSE<(outs GPR64Opnd:$rt), (ins GPR64Opnd:$rs, uimm5:$pos, uimm5:$lenm1), 362*9880d681SAndroid Build Coastguard Worker !strconcat(opstr, " $rt, $rs, $pos, $lenm1"), 363*9880d681SAndroid Build Coastguard Worker [(set GPR64Opnd:$rt, (Op GPR64Opnd:$rs, imm:$pos, imm:$lenm1))], 364*9880d681SAndroid Build Coastguard Worker NoItinerary, FrmR, opstr> { 365*9880d681SAndroid Build Coastguard Worker let TwoOperandAliasConstraint = "$rt = $rs"; 366*9880d681SAndroid Build Coastguard Worker} 367*9880d681SAndroid Build Coastguard Worker 368*9880d681SAndroid Build Coastguard Workerclass SetCC64_R<string opstr, PatFrag cond_op> : 369*9880d681SAndroid Build Coastguard Worker InstSE<(outs GPR64Opnd:$rd), (ins GPR64Opnd:$rs, GPR64Opnd:$rt), 370*9880d681SAndroid Build Coastguard Worker !strconcat(opstr, "\t$rd, $rs, $rt"), 371*9880d681SAndroid Build Coastguard Worker [(set GPR64Opnd:$rd, (zext (cond_op GPR64Opnd:$rs, 372*9880d681SAndroid Build Coastguard Worker GPR64Opnd:$rt)))], 373*9880d681SAndroid Build Coastguard Worker II_SEQ_SNE, FrmR, opstr> { 374*9880d681SAndroid Build Coastguard Worker let TwoOperandAliasConstraint = "$rd = $rs"; 375*9880d681SAndroid Build Coastguard Worker} 376*9880d681SAndroid Build Coastguard Worker 377*9880d681SAndroid Build Coastguard Workerclass SetCC64_I<string opstr, PatFrag cond_op>: 378*9880d681SAndroid Build Coastguard Worker InstSE<(outs GPR64Opnd:$rt), (ins GPR64Opnd:$rs, simm10_64:$imm10), 379*9880d681SAndroid Build Coastguard Worker !strconcat(opstr, "\t$rt, $rs, $imm10"), 380*9880d681SAndroid Build Coastguard Worker [(set GPR64Opnd:$rt, (zext (cond_op GPR64Opnd:$rs, 381*9880d681SAndroid Build Coastguard Worker immSExt10_64:$imm10)))], 382*9880d681SAndroid Build Coastguard Worker II_SEQI_SNEI, FrmI, opstr> { 383*9880d681SAndroid Build Coastguard Worker let TwoOperandAliasConstraint = "$rt = $rs"; 384*9880d681SAndroid Build Coastguard Worker} 385*9880d681SAndroid Build Coastguard Worker 386*9880d681SAndroid Build Coastguard Workerclass CBranchBitNum<string opstr, DAGOperand opnd, PatFrag cond_op, 387*9880d681SAndroid Build Coastguard Worker RegisterOperand RO, Operand ImmOp, bits<64> shift = 1> : 388*9880d681SAndroid Build Coastguard Worker InstSE<(outs), (ins RO:$rs, ImmOp:$p, opnd:$offset), 389*9880d681SAndroid Build Coastguard Worker !strconcat(opstr, "\t$rs, $p, $offset"), 390*9880d681SAndroid Build Coastguard Worker [(brcond (i32 (cond_op (and RO:$rs, (shl shift, immZExt5_64:$p)), 0)), 391*9880d681SAndroid Build Coastguard Worker bb:$offset)], II_BBIT, FrmI, opstr> { 392*9880d681SAndroid Build Coastguard Worker let isBranch = 1; 393*9880d681SAndroid Build Coastguard Worker let isTerminator = 1; 394*9880d681SAndroid Build Coastguard Worker let hasDelaySlot = 1; 395*9880d681SAndroid Build Coastguard Worker let Defs = [AT]; 396*9880d681SAndroid Build Coastguard Worker} 397*9880d681SAndroid Build Coastguard Worker 398*9880d681SAndroid Build Coastguard Workerclass MFC2OP<string asmstr, RegisterOperand RO> : 399*9880d681SAndroid Build Coastguard Worker InstSE<(outs RO:$rt, uimm16:$imm16), (ins), 400*9880d681SAndroid Build Coastguard Worker !strconcat(asmstr, "\t$rt, $imm16"), [], NoItinerary, FrmFR>; 401*9880d681SAndroid Build Coastguard Worker 402*9880d681SAndroid Build Coastguard Worker// Unsigned Byte Add 403*9880d681SAndroid Build Coastguard Workerdef BADDu : ArithLogicR<"baddu", GPR64Opnd, 1, II_BADDU>, 404*9880d681SAndroid Build Coastguard Worker ADD_FM<0x1c, 0x28>, ASE_CNMIPS { 405*9880d681SAndroid Build Coastguard Worker let Pattern = [(set GPR64Opnd:$rd, 406*9880d681SAndroid Build Coastguard Worker (and (add GPR64Opnd:$rs, GPR64Opnd:$rt), 255))]; 407*9880d681SAndroid Build Coastguard Worker} 408*9880d681SAndroid Build Coastguard Worker 409*9880d681SAndroid Build Coastguard Worker// Branch on Bit Clear /+32 410*9880d681SAndroid Build Coastguard Workerdef BBIT0 : CBranchBitNum<"bbit0", brtarget, seteq, GPR64Opnd, 411*9880d681SAndroid Build Coastguard Worker uimm5_64_report_uimm6>, BBIT_FM<0x32>, ASE_CNMIPS; 412*9880d681SAndroid Build Coastguard Workerdef BBIT032: CBranchBitNum<"bbit032", brtarget, seteq, GPR64Opnd, uimm5_64, 413*9880d681SAndroid Build Coastguard Worker 0x100000000>, BBIT_FM<0x36>, ASE_CNMIPS; 414*9880d681SAndroid Build Coastguard Worker 415*9880d681SAndroid Build Coastguard Worker// Branch on Bit Set /+32 416*9880d681SAndroid Build Coastguard Workerdef BBIT1 : CBranchBitNum<"bbit1", brtarget, setne, GPR64Opnd, 417*9880d681SAndroid Build Coastguard Worker uimm5_64_report_uimm6>, BBIT_FM<0x3a>, ASE_CNMIPS; 418*9880d681SAndroid Build Coastguard Workerdef BBIT132: CBranchBitNum<"bbit132", brtarget, setne, GPR64Opnd, uimm5_64, 419*9880d681SAndroid Build Coastguard Worker 0x100000000>, BBIT_FM<0x3e>, ASE_CNMIPS; 420*9880d681SAndroid Build Coastguard Worker 421*9880d681SAndroid Build Coastguard Worker// Multiply Doubleword to GPR 422*9880d681SAndroid Build Coastguard Workerdef DMUL : ArithLogicR<"dmul", GPR64Opnd, 1, II_DMUL, mul>, 423*9880d681SAndroid Build Coastguard Worker ADD_FM<0x1c, 0x03>, ASE_CNMIPS { 424*9880d681SAndroid Build Coastguard Worker let Defs = [HI0, LO0, P0, P1, P2]; 425*9880d681SAndroid Build Coastguard Worker} 426*9880d681SAndroid Build Coastguard Worker 427*9880d681SAndroid Build Coastguard Worker// Extract a signed bit field /+32 428*9880d681SAndroid Build Coastguard Workerdef EXTS : ExtsCins<"exts">, EXTS_FM<0x3a>, ASE_CNMIPS; 429*9880d681SAndroid Build Coastguard Workerdef EXTS32: ExtsCins<"exts32">, EXTS_FM<0x3b>, ASE_CNMIPS; 430*9880d681SAndroid Build Coastguard Worker 431*9880d681SAndroid Build Coastguard Worker// Clear and insert a bit field /+32 432*9880d681SAndroid Build Coastguard Workerdef CINS : ExtsCins<"cins">, EXTS_FM<0x32>, ASE_CNMIPS; 433*9880d681SAndroid Build Coastguard Workerdef CINS32: ExtsCins<"cins32">, EXTS_FM<0x33>, ASE_CNMIPS; 434*9880d681SAndroid Build Coastguard Worker 435*9880d681SAndroid Build Coastguard Worker// Move to multiplier/product register 436*9880d681SAndroid Build Coastguard Workerdef MTM0 : MoveToLOHI<"mtm0", GPR64Opnd, [MPL0, P0, P1, P2]>, MTMR_FM<0x08>, 437*9880d681SAndroid Build Coastguard Worker ASE_CNMIPS; 438*9880d681SAndroid Build Coastguard Workerdef MTM1 : MoveToLOHI<"mtm1", GPR64Opnd, [MPL1, P0, P1, P2]>, MTMR_FM<0x0c>, 439*9880d681SAndroid Build Coastguard Worker ASE_CNMIPS; 440*9880d681SAndroid Build Coastguard Workerdef MTM2 : MoveToLOHI<"mtm2", GPR64Opnd, [MPL2, P0, P1, P2]>, MTMR_FM<0x0d>, 441*9880d681SAndroid Build Coastguard Worker ASE_CNMIPS; 442*9880d681SAndroid Build Coastguard Workerdef MTP0 : MoveToLOHI<"mtp0", GPR64Opnd, [P0]>, MTMR_FM<0x09>, ASE_CNMIPS; 443*9880d681SAndroid Build Coastguard Workerdef MTP1 : MoveToLOHI<"mtp1", GPR64Opnd, [P1]>, MTMR_FM<0x0a>, ASE_CNMIPS; 444*9880d681SAndroid Build Coastguard Workerdef MTP2 : MoveToLOHI<"mtp2", GPR64Opnd, [P2]>, MTMR_FM<0x0b>, ASE_CNMIPS; 445*9880d681SAndroid Build Coastguard Worker 446*9880d681SAndroid Build Coastguard Worker// Count Ones in a Word/Doubleword 447*9880d681SAndroid Build Coastguard Workerdef POP : Count1s<"pop", GPR32Opnd>, POP_FM<0x2c>, ASE_CNMIPS; 448*9880d681SAndroid Build Coastguard Workerdef DPOP : Count1s<"dpop", GPR64Opnd>, POP_FM<0x2d>, ASE_CNMIPS; 449*9880d681SAndroid Build Coastguard Worker 450*9880d681SAndroid Build Coastguard Worker// Set on equal/not equal 451*9880d681SAndroid Build Coastguard Workerdef SEQ : SetCC64_R<"seq", seteq>, SEQ_FM<0x2a>, ASE_CNMIPS; 452*9880d681SAndroid Build Coastguard Workerdef SEQi : SetCC64_I<"seqi", seteq>, SEQI_FM<0x2e>, ASE_CNMIPS; 453*9880d681SAndroid Build Coastguard Workerdef SNE : SetCC64_R<"sne", setne>, SEQ_FM<0x2b>, ASE_CNMIPS; 454*9880d681SAndroid Build Coastguard Workerdef SNEi : SetCC64_I<"snei", setne>, SEQI_FM<0x2f>, ASE_CNMIPS; 455*9880d681SAndroid Build Coastguard Worker 456*9880d681SAndroid Build Coastguard Worker// 192-bit x 64-bit Unsigned Multiply and Add 457*9880d681SAndroid Build Coastguard Workerdef V3MULU: ArithLogicR<"v3mulu", GPR64Opnd, 0, II_DMUL>, ADD_FM<0x1c, 0x11>, 458*9880d681SAndroid Build Coastguard Worker ASE_CNMIPS { 459*9880d681SAndroid Build Coastguard Worker let Defs = [P0, P1, P2]; 460*9880d681SAndroid Build Coastguard Worker} 461*9880d681SAndroid Build Coastguard Worker 462*9880d681SAndroid Build Coastguard Worker// 64-bit Unsigned Multiply and Add Move 463*9880d681SAndroid Build Coastguard Workerdef VMM0 : ArithLogicR<"vmm0", GPR64Opnd, 0, II_DMUL>, ADD_FM<0x1c, 0x10>, 464*9880d681SAndroid Build Coastguard Worker ASE_CNMIPS { 465*9880d681SAndroid Build Coastguard Worker let Defs = [MPL0, P0, P1, P2]; 466*9880d681SAndroid Build Coastguard Worker} 467*9880d681SAndroid Build Coastguard Worker 468*9880d681SAndroid Build Coastguard Worker// 64-bit Unsigned Multiply and Add 469*9880d681SAndroid Build Coastguard Workerdef VMULU : ArithLogicR<"vmulu", GPR64Opnd, 0, II_DMUL>, ADD_FM<0x1c, 0x0f>, 470*9880d681SAndroid Build Coastguard Worker ASE_CNMIPS { 471*9880d681SAndroid Build Coastguard Worker let Defs = [MPL1, MPL2, P0, P1, P2]; 472*9880d681SAndroid Build Coastguard Worker} 473*9880d681SAndroid Build Coastguard Worker 474*9880d681SAndroid Build Coastguard Worker// Move between CPU and coprocessor registers 475*9880d681SAndroid Build Coastguard Workerdef DMFC2_OCTEON : MFC2OP<"dmfc2", GPR64Opnd>, MFC2OP_FM<0x12, 1>, ASE_CNMIPS; 476*9880d681SAndroid Build Coastguard Workerdef DMTC2_OCTEON : MFC2OP<"dmtc2", GPR64Opnd>, MFC2OP_FM<0x12, 5>, ASE_CNMIPS; 477*9880d681SAndroid Build Coastguard Worker} 478*9880d681SAndroid Build Coastguard Worker 479*9880d681SAndroid Build Coastguard Worker} 480*9880d681SAndroid Build Coastguard Worker 481*9880d681SAndroid Build Coastguard Worker/// Move between CPU and coprocessor registers 482*9880d681SAndroid Build Coastguard Workerlet DecoderNamespace = "Mips64", Predicates = [HasMips64] in { 483*9880d681SAndroid Build Coastguard Workerdef DMFC0 : MFC3OP<"dmfc0", GPR64Opnd, COP0Opnd, II_DMFC0>, MFC3OP_FM<0x10, 1>, 484*9880d681SAndroid Build Coastguard Worker ISA_MIPS3; 485*9880d681SAndroid Build Coastguard Workerdef DMTC0 : MTC3OP<"dmtc0", COP0Opnd, GPR64Opnd, II_DMTC0>, MFC3OP_FM<0x10, 5>, 486*9880d681SAndroid Build Coastguard Worker ISA_MIPS3; 487*9880d681SAndroid Build Coastguard Workerdef DMFC2 : MFC3OP<"dmfc2", GPR64Opnd, COP2Opnd, II_DMFC2>, MFC3OP_FM<0x12, 1>, 488*9880d681SAndroid Build Coastguard Worker ISA_MIPS3; 489*9880d681SAndroid Build Coastguard Workerdef DMTC2 : MTC3OP<"dmtc2", COP2Opnd, GPR64Opnd, II_DMTC2>, MFC3OP_FM<0x12, 5>, 490*9880d681SAndroid Build Coastguard Worker ISA_MIPS3; 491*9880d681SAndroid Build Coastguard Worker} 492*9880d681SAndroid Build Coastguard Worker 493*9880d681SAndroid Build Coastguard Worker//===----------------------------------------------------------------------===// 494*9880d681SAndroid Build Coastguard Worker// Arbitrary patterns that map to one or more instructions 495*9880d681SAndroid Build Coastguard Worker//===----------------------------------------------------------------------===// 496*9880d681SAndroid Build Coastguard Worker 497*9880d681SAndroid Build Coastguard Worker// extended loads 498*9880d681SAndroid Build Coastguard Workerdef : MipsPat<(i64 (extloadi1 addr:$src)), (LB64 addr:$src)>; 499*9880d681SAndroid Build Coastguard Workerdef : MipsPat<(i64 (extloadi8 addr:$src)), (LB64 addr:$src)>; 500*9880d681SAndroid Build Coastguard Workerdef : MipsPat<(i64 (extloadi16 addr:$src)), (LH64 addr:$src)>; 501*9880d681SAndroid Build Coastguard Workerdef : MipsPat<(i64 (extloadi32 addr:$src)), (LW64 addr:$src)>; 502*9880d681SAndroid Build Coastguard Worker 503*9880d681SAndroid Build Coastguard Worker// hi/lo relocs 504*9880d681SAndroid Build Coastguard Workerdef : MipsPat<(MipsHi tglobaladdr:$in), (LUi64 tglobaladdr:$in)>; 505*9880d681SAndroid Build Coastguard Workerdef : MipsPat<(MipsHi tblockaddress:$in), (LUi64 tblockaddress:$in)>; 506*9880d681SAndroid Build Coastguard Workerdef : MipsPat<(MipsHi tjumptable:$in), (LUi64 tjumptable:$in)>; 507*9880d681SAndroid Build Coastguard Workerdef : MipsPat<(MipsHi tconstpool:$in), (LUi64 tconstpool:$in)>; 508*9880d681SAndroid Build Coastguard Workerdef : MipsPat<(MipsHi tglobaltlsaddr:$in), (LUi64 tglobaltlsaddr:$in)>; 509*9880d681SAndroid Build Coastguard Workerdef : MipsPat<(MipsHi texternalsym:$in), (LUi64 texternalsym:$in)>; 510*9880d681SAndroid Build Coastguard Worker 511*9880d681SAndroid Build Coastguard Workerlet AdditionalPredicates = [NotInMicroMips] in { 512*9880d681SAndroid Build Coastguard Worker def : MipsPat<(MipsLo tglobaladdr:$in), (DADDiu ZERO_64, tglobaladdr:$in)>; 513*9880d681SAndroid Build Coastguard Worker def : MipsPat<(MipsLo tblockaddress:$in), 514*9880d681SAndroid Build Coastguard Worker (DADDiu ZERO_64, tblockaddress:$in)>; 515*9880d681SAndroid Build Coastguard Worker def : MipsPat<(MipsLo tjumptable:$in), (DADDiu ZERO_64, tjumptable:$in)>; 516*9880d681SAndroid Build Coastguard Worker def : MipsPat<(MipsLo tconstpool:$in), (DADDiu ZERO_64, tconstpool:$in)>; 517*9880d681SAndroid Build Coastguard Worker def : MipsPat<(MipsLo tglobaltlsaddr:$in), 518*9880d681SAndroid Build Coastguard Worker (DADDiu ZERO_64, tglobaltlsaddr:$in)>; 519*9880d681SAndroid Build Coastguard Worker def : MipsPat<(MipsLo texternalsym:$in), (DADDiu ZERO_64, texternalsym:$in)>; 520*9880d681SAndroid Build Coastguard Worker 521*9880d681SAndroid Build Coastguard Worker def : MipsPat<(add GPR64:$hi, (MipsLo tglobaladdr:$lo)), 522*9880d681SAndroid Build Coastguard Worker (DADDiu GPR64:$hi, tglobaladdr:$lo)>; 523*9880d681SAndroid Build Coastguard Worker def : MipsPat<(add GPR64:$hi, (MipsLo tblockaddress:$lo)), 524*9880d681SAndroid Build Coastguard Worker (DADDiu GPR64:$hi, tblockaddress:$lo)>; 525*9880d681SAndroid Build Coastguard Worker def : MipsPat<(add GPR64:$hi, (MipsLo tjumptable:$lo)), 526*9880d681SAndroid Build Coastguard Worker (DADDiu GPR64:$hi, tjumptable:$lo)>; 527*9880d681SAndroid Build Coastguard Worker def : MipsPat<(add GPR64:$hi, (MipsLo tconstpool:$lo)), 528*9880d681SAndroid Build Coastguard Worker (DADDiu GPR64:$hi, tconstpool:$lo)>; 529*9880d681SAndroid Build Coastguard Worker def : MipsPat<(add GPR64:$hi, (MipsLo tglobaltlsaddr:$lo)), 530*9880d681SAndroid Build Coastguard Worker (DADDiu GPR64:$hi, tglobaltlsaddr:$lo)>; 531*9880d681SAndroid Build Coastguard Worker 532*9880d681SAndroid Build Coastguard Worker def : WrapperPat<tglobaladdr, DADDiu, GPR64>; 533*9880d681SAndroid Build Coastguard Worker def : WrapperPat<tconstpool, DADDiu, GPR64>; 534*9880d681SAndroid Build Coastguard Worker def : WrapperPat<texternalsym, DADDiu, GPR64>; 535*9880d681SAndroid Build Coastguard Worker def : WrapperPat<tblockaddress, DADDiu, GPR64>; 536*9880d681SAndroid Build Coastguard Worker def : WrapperPat<tjumptable, DADDiu, GPR64>; 537*9880d681SAndroid Build Coastguard Worker def : WrapperPat<tglobaltlsaddr, DADDiu, GPR64>; 538*9880d681SAndroid Build Coastguard Worker} 539*9880d681SAndroid Build Coastguard Worker 540*9880d681SAndroid Build Coastguard Workerdefm : BrcondPats<GPR64, BEQ64, BNE64, SLT64, SLTu64, SLTi64, SLTiu64, 541*9880d681SAndroid Build Coastguard Worker ZERO_64>; 542*9880d681SAndroid Build Coastguard Worker 543*9880d681SAndroid Build Coastguard Workerdef : MipsPat<(brcond (i32 (setlt i64:$lhs, 1)), bb:$dst), 544*9880d681SAndroid Build Coastguard Worker (BLEZ64 i64:$lhs, bb:$dst)>; 545*9880d681SAndroid Build Coastguard Workerdef : MipsPat<(brcond (i32 (setgt i64:$lhs, -1)), bb:$dst), 546*9880d681SAndroid Build Coastguard Worker (BGEZ64 i64:$lhs, bb:$dst)>; 547*9880d681SAndroid Build Coastguard Worker 548*9880d681SAndroid Build Coastguard Worker// setcc patterns 549*9880d681SAndroid Build Coastguard Workerdefm : SeteqPats<GPR64, SLTiu64, XOR64, SLTu64, ZERO_64>; 550*9880d681SAndroid Build Coastguard Workerdefm : SetlePats<GPR64, SLT64, SLTu64>; 551*9880d681SAndroid Build Coastguard Workerdefm : SetgtPats<GPR64, SLT64, SLTu64>; 552*9880d681SAndroid Build Coastguard Workerdefm : SetgePats<GPR64, SLT64, SLTu64>; 553*9880d681SAndroid Build Coastguard Workerdefm : SetgeImmPats<GPR64, SLTi64, SLTiu64>; 554*9880d681SAndroid Build Coastguard Worker 555*9880d681SAndroid Build Coastguard Worker// truncate 556*9880d681SAndroid Build Coastguard Workerdef : MipsPat<(trunc (assertsext GPR64:$src)), 557*9880d681SAndroid Build Coastguard Worker (EXTRACT_SUBREG GPR64:$src, sub_32)>; 558*9880d681SAndroid Build Coastguard Worker// The forward compatibility strategy employed by MIPS requires us to treat 559*9880d681SAndroid Build Coastguard Worker// values as being sign extended to an infinite number of bits. This allows 560*9880d681SAndroid Build Coastguard Worker// existing software to run without modification on any future MIPS 561*9880d681SAndroid Build Coastguard Worker// implementation (e.g. 128-bit, or 1024-bit). Being compatible with this 562*9880d681SAndroid Build Coastguard Worker// strategy requires that truncation acts as a sign-extension for values being 563*9880d681SAndroid Build Coastguard Worker// fed into instructions operating on 32-bit values. Such instructions have 564*9880d681SAndroid Build Coastguard Worker// undefined results if this is not true. 565*9880d681SAndroid Build Coastguard Worker// For our case, this means that we can't issue an extract_subreg for nodes 566*9880d681SAndroid Build Coastguard Worker// such as (trunc:i32 (assertzext:i64 X, i32)), because the sign-bit of the 567*9880d681SAndroid Build Coastguard Worker// lower subreg would not be replicated into the upper half. 568*9880d681SAndroid Build Coastguard Workerdef : MipsPat<(trunc (assertzext_lt_i32 GPR64:$src)), 569*9880d681SAndroid Build Coastguard Worker (EXTRACT_SUBREG GPR64:$src, sub_32)>; 570*9880d681SAndroid Build Coastguard Workerdef : MipsPat<(i32 (trunc GPR64:$src)), 571*9880d681SAndroid Build Coastguard Worker (SLL (EXTRACT_SUBREG GPR64:$src, sub_32), 0)>; 572*9880d681SAndroid Build Coastguard Worker 573*9880d681SAndroid Build Coastguard Worker// variable shift instructions patterns 574*9880d681SAndroid Build Coastguard Workerdef : MipsPat<(shl GPR64:$rt, (i32 (trunc GPR64:$rs))), 575*9880d681SAndroid Build Coastguard Worker (DSLLV GPR64:$rt, (EXTRACT_SUBREG GPR64:$rs, sub_32))>; 576*9880d681SAndroid Build Coastguard Workerdef : MipsPat<(srl GPR64:$rt, (i32 (trunc GPR64:$rs))), 577*9880d681SAndroid Build Coastguard Worker (DSRLV GPR64:$rt, (EXTRACT_SUBREG GPR64:$rs, sub_32))>; 578*9880d681SAndroid Build Coastguard Workerdef : MipsPat<(sra GPR64:$rt, (i32 (trunc GPR64:$rs))), 579*9880d681SAndroid Build Coastguard Worker (DSRAV GPR64:$rt, (EXTRACT_SUBREG GPR64:$rs, sub_32))>; 580*9880d681SAndroid Build Coastguard Workerlet AdditionalPredicates = [NotInMicroMips] in { 581*9880d681SAndroid Build Coastguard Worker def : MipsPat<(rotr GPR64:$rt, (i32 (trunc GPR64:$rs))), 582*9880d681SAndroid Build Coastguard Worker (DROTRV GPR64:$rt, (EXTRACT_SUBREG GPR64:$rs, sub_32))>; 583*9880d681SAndroid Build Coastguard Worker} 584*9880d681SAndroid Build Coastguard Worker 585*9880d681SAndroid Build Coastguard Worker// 32-to-64-bit extension 586*9880d681SAndroid Build Coastguard Workerdef : MipsPat<(i64 (anyext GPR32:$src)), 587*9880d681SAndroid Build Coastguard Worker (INSERT_SUBREG (i64 (IMPLICIT_DEF)), GPR32:$src, sub_32)>; 588*9880d681SAndroid Build Coastguard Workerdef : MipsPat<(i64 (zext GPR32:$src)), (DSRL (DSLL64_32 GPR32:$src), 32)>; 589*9880d681SAndroid Build Coastguard Workerdef : MipsPat<(i64 (sext GPR32:$src)), (SLL64_32 GPR32:$src)>; 590*9880d681SAndroid Build Coastguard Worker 591*9880d681SAndroid Build Coastguard Worker// Sign extend in register 592*9880d681SAndroid Build Coastguard Workerdef : MipsPat<(i64 (sext_inreg GPR64:$src, i32)), 593*9880d681SAndroid Build Coastguard Worker (SLL64_64 GPR64:$src)>; 594*9880d681SAndroid Build Coastguard Worker 595*9880d681SAndroid Build Coastguard Worker// bswap MipsPattern 596*9880d681SAndroid Build Coastguard Workerdef : MipsPat<(bswap GPR64:$rt), (DSHD (DSBH GPR64:$rt))>; 597*9880d681SAndroid Build Coastguard Worker 598*9880d681SAndroid Build Coastguard Worker// Carry pattern 599*9880d681SAndroid Build Coastguard Workerlet AdditionalPredicates = [NotInMicroMips] in { 600*9880d681SAndroid Build Coastguard Worker def : MipsPat<(subc GPR64:$lhs, GPR64:$rhs), 601*9880d681SAndroid Build Coastguard Worker (DSUBu GPR64:$lhs, GPR64:$rhs)>; 602*9880d681SAndroid Build Coastguard Worker def : MipsPat<(addc GPR64:$lhs, GPR64:$rhs), 603*9880d681SAndroid Build Coastguard Worker (DADDu GPR64:$lhs, GPR64:$rhs)>, ASE_NOT_DSP; 604*9880d681SAndroid Build Coastguard Worker def : MipsPat<(addc GPR64:$lhs, immSExt16:$imm), 605*9880d681SAndroid Build Coastguard Worker (DADDiu GPR64:$lhs, imm:$imm)>, ASE_NOT_DSP; 606*9880d681SAndroid Build Coastguard Worker} 607*9880d681SAndroid Build Coastguard Worker 608*9880d681SAndroid Build Coastguard Worker// Octeon bbit0/bbit1 MipsPattern 609*9880d681SAndroid Build Coastguard Workerdef : MipsPat<(brcond (i32 (seteq (and i64:$lhs, PowerOf2LO:$mask), 0)), bb:$dst), 610*9880d681SAndroid Build Coastguard Worker (BBIT0 i64:$lhs, (Log2LO PowerOf2LO:$mask), bb:$dst)>, ASE_MIPS64_CNMIPS; 611*9880d681SAndroid Build Coastguard Workerdef : MipsPat<(brcond (i32 (seteq (and i64:$lhs, PowerOf2HI:$mask), 0)), bb:$dst), 612*9880d681SAndroid Build Coastguard Worker (BBIT032 i64:$lhs, (Log2HI PowerOf2HI:$mask), bb:$dst)>, ASE_MIPS64_CNMIPS; 613*9880d681SAndroid Build Coastguard Workerdef : MipsPat<(brcond (i32 (setne (and i64:$lhs, PowerOf2LO:$mask), 0)), bb:$dst), 614*9880d681SAndroid Build Coastguard Worker (BBIT1 i64:$lhs, (Log2LO PowerOf2LO:$mask), bb:$dst)>, ASE_MIPS64_CNMIPS; 615*9880d681SAndroid Build Coastguard Workerdef : MipsPat<(brcond (i32 (setne (and i64:$lhs, PowerOf2HI:$mask), 0)), bb:$dst), 616*9880d681SAndroid Build Coastguard Worker (BBIT132 i64:$lhs, (Log2HI PowerOf2HI:$mask), bb:$dst)>, ASE_MIPS64_CNMIPS; 617*9880d681SAndroid Build Coastguard Worker 618*9880d681SAndroid Build Coastguard Worker// Atomic load patterns. 619*9880d681SAndroid Build Coastguard Workerdef : MipsPat<(atomic_load_8 addr:$a), (LB64 addr:$a)>; 620*9880d681SAndroid Build Coastguard Workerdef : MipsPat<(atomic_load_16 addr:$a), (LH64 addr:$a)>; 621*9880d681SAndroid Build Coastguard Workerdef : MipsPat<(atomic_load_32 addr:$a), (LW64 addr:$a)>; 622*9880d681SAndroid Build Coastguard Workerdef : MipsPat<(atomic_load_64 addr:$a), (LD addr:$a)>; 623*9880d681SAndroid Build Coastguard Worker 624*9880d681SAndroid Build Coastguard Worker// Atomic store patterns. 625*9880d681SAndroid Build Coastguard Workerdef : MipsPat<(atomic_store_8 addr:$a, GPR64:$v), (SB64 GPR64:$v, addr:$a)>; 626*9880d681SAndroid Build Coastguard Workerdef : MipsPat<(atomic_store_16 addr:$a, GPR64:$v), (SH64 GPR64:$v, addr:$a)>; 627*9880d681SAndroid Build Coastguard Workerdef : MipsPat<(atomic_store_32 addr:$a, GPR64:$v), (SW64 GPR64:$v, addr:$a)>; 628*9880d681SAndroid Build Coastguard Workerdef : MipsPat<(atomic_store_64 addr:$a, GPR64:$v), (SD GPR64:$v, addr:$a)>; 629*9880d681SAndroid Build Coastguard Worker 630*9880d681SAndroid Build Coastguard Worker//===----------------------------------------------------------------------===// 631*9880d681SAndroid Build Coastguard Worker// Instruction aliases 632*9880d681SAndroid Build Coastguard Worker//===----------------------------------------------------------------------===// 633*9880d681SAndroid Build Coastguard Workerlet AdditionalPredicates = [NotInMicroMips] in { 634*9880d681SAndroid Build Coastguard Worker def : MipsInstAlias<"move $dst, $src", 635*9880d681SAndroid Build Coastguard Worker (OR64 GPR64Opnd:$dst, GPR64Opnd:$src, ZERO_64), 1>, 636*9880d681SAndroid Build Coastguard Worker GPR_64; 637*9880d681SAndroid Build Coastguard Worker def : MipsInstAlias<"move $dst, $src", 638*9880d681SAndroid Build Coastguard Worker (DADDu GPR64Opnd:$dst, GPR64Opnd:$src, ZERO_64), 1>, 639*9880d681SAndroid Build Coastguard Worker GPR_64; 640*9880d681SAndroid Build Coastguard Worker def : MipsInstAlias<"dadd $rs, $rt, $imm", 641*9880d681SAndroid Build Coastguard Worker (DADDi GPR64Opnd:$rs, GPR64Opnd:$rt, simm16_64:$imm), 642*9880d681SAndroid Build Coastguard Worker 0>, ISA_MIPS3_NOT_32R6_64R6; 643*9880d681SAndroid Build Coastguard Worker def : MipsInstAlias<"dadd $rs, $imm", 644*9880d681SAndroid Build Coastguard Worker (DADDi GPR64Opnd:$rs, GPR64Opnd:$rs, simm16_64:$imm), 645*9880d681SAndroid Build Coastguard Worker 0>, ISA_MIPS3_NOT_32R6_64R6; 646*9880d681SAndroid Build Coastguard Worker def : MipsInstAlias<"daddu $rs, $rt, $imm", 647*9880d681SAndroid Build Coastguard Worker (DADDiu GPR64Opnd:$rs, GPR64Opnd:$rt, simm16_64:$imm), 648*9880d681SAndroid Build Coastguard Worker 0>, ISA_MIPS3; 649*9880d681SAndroid Build Coastguard Worker def : MipsInstAlias<"daddu $rs, $imm", 650*9880d681SAndroid Build Coastguard Worker (DADDiu GPR64Opnd:$rs, GPR64Opnd:$rs, simm16_64:$imm), 651*9880d681SAndroid Build Coastguard Worker 0>, ISA_MIPS3; 652*9880d681SAndroid Build Coastguard Worker} 653*9880d681SAndroid Build Coastguard Workerdef : MipsInstAlias<"dsll $rd, $rt, $rs", 654*9880d681SAndroid Build Coastguard Worker (DSLLV GPR64Opnd:$rd, GPR64Opnd:$rt, GPR32Opnd:$rs), 0>, 655*9880d681SAndroid Build Coastguard Worker ISA_MIPS3; 656*9880d681SAndroid Build Coastguard Workerlet AdditionalPredicates = [NotInMicroMips] in { 657*9880d681SAndroid Build Coastguard Worker def : MipsInstAlias<"dneg $rt, $rs", 658*9880d681SAndroid Build Coastguard Worker (DSUB GPR64Opnd:$rt, ZERO_64, GPR64Opnd:$rs), 1>, 659*9880d681SAndroid Build Coastguard Worker ISA_MIPS3; 660*9880d681SAndroid Build Coastguard Worker def : MipsInstAlias<"dneg $rt", 661*9880d681SAndroid Build Coastguard Worker (DSUB GPR64Opnd:$rt, ZERO_64, GPR64Opnd:$rt), 0>, 662*9880d681SAndroid Build Coastguard Worker ISA_MIPS3; 663*9880d681SAndroid Build Coastguard Worker def : MipsInstAlias<"dnegu $rt, $rs", 664*9880d681SAndroid Build Coastguard Worker (DSUBu GPR64Opnd:$rt, ZERO_64, GPR64Opnd:$rs), 1>, 665*9880d681SAndroid Build Coastguard Worker ISA_MIPS3; 666*9880d681SAndroid Build Coastguard Worker} 667*9880d681SAndroid Build Coastguard Workerdef : MipsInstAlias<"dsubi $rs, $rt, $imm", 668*9880d681SAndroid Build Coastguard Worker (DADDi GPR64Opnd:$rs, GPR64Opnd:$rt, 669*9880d681SAndroid Build Coastguard Worker InvertedImOperand64:$imm), 670*9880d681SAndroid Build Coastguard Worker 0>, ISA_MIPS3_NOT_32R6_64R6; 671*9880d681SAndroid Build Coastguard Workerdef : MipsInstAlias<"dsubi $rs, $imm", 672*9880d681SAndroid Build Coastguard Worker (DADDi GPR64Opnd:$rs, GPR64Opnd:$rs, 673*9880d681SAndroid Build Coastguard Worker InvertedImOperand64:$imm), 674*9880d681SAndroid Build Coastguard Worker 0>, ISA_MIPS3_NOT_32R6_64R6; 675*9880d681SAndroid Build Coastguard Workerdef : MipsInstAlias<"dsub $rs, $rt, $imm", 676*9880d681SAndroid Build Coastguard Worker (DADDi GPR64Opnd:$rs, GPR64Opnd:$rt, 677*9880d681SAndroid Build Coastguard Worker InvertedImOperand64:$imm), 678*9880d681SAndroid Build Coastguard Worker 0>, ISA_MIPS3_NOT_32R6_64R6; 679*9880d681SAndroid Build Coastguard Workerdef : MipsInstAlias<"dsub $rs, $imm", 680*9880d681SAndroid Build Coastguard Worker (DADDi GPR64Opnd:$rs, GPR64Opnd:$rs, 681*9880d681SAndroid Build Coastguard Worker InvertedImOperand64:$imm), 682*9880d681SAndroid Build Coastguard Worker 0>, ISA_MIPS3_NOT_32R6_64R6; 683*9880d681SAndroid Build Coastguard Workerlet AdditionalPredicates = [NotInMicroMips] in { 684*9880d681SAndroid Build Coastguard Worker def : MipsInstAlias<"dsubu $rt, $rs, $imm", 685*9880d681SAndroid Build Coastguard Worker (DADDiu GPR64Opnd:$rt, GPR64Opnd:$rs, 686*9880d681SAndroid Build Coastguard Worker InvertedImOperand64:$imm), 0>, ISA_MIPS3; 687*9880d681SAndroid Build Coastguard Worker def : MipsInstAlias<"dsubu $rs, $imm", 688*9880d681SAndroid Build Coastguard Worker (DADDiu GPR64Opnd:$rs, GPR64Opnd:$rs, 689*9880d681SAndroid Build Coastguard Worker InvertedImOperand64:$imm), 0>, ISA_MIPS3; 690*9880d681SAndroid Build Coastguard Worker} 691*9880d681SAndroid Build Coastguard Workerdef : MipsInstAlias<"dsra $rd, $rt, $rs", 692*9880d681SAndroid Build Coastguard Worker (DSRAV GPR64Opnd:$rd, GPR64Opnd:$rt, GPR32Opnd:$rs), 0>, 693*9880d681SAndroid Build Coastguard Worker ISA_MIPS3; 694*9880d681SAndroid Build Coastguard Workerlet AdditionalPredicates = [NotInMicroMips] in { 695*9880d681SAndroid Build Coastguard Worker def : MipsInstAlias<"dsrl $rd, $rt, $rs", 696*9880d681SAndroid Build Coastguard Worker (DSRLV GPR64Opnd:$rd, GPR64Opnd:$rt, GPR32Opnd:$rs), 0>, 697*9880d681SAndroid Build Coastguard Worker ISA_MIPS3; 698*9880d681SAndroid Build Coastguard Worker 699*9880d681SAndroid Build Coastguard Worker// Two operand (implicit 0 selector) versions: 700*9880d681SAndroid Build Coastguard Worker def : MipsInstAlias<"dmtc0 $rt, $rd", 701*9880d681SAndroid Build Coastguard Worker (DMTC0 COP0Opnd:$rd, GPR64Opnd:$rt, 0), 0>; 702*9880d681SAndroid Build Coastguard Worker def : MipsInstAlias<"dmfc0 $rt, $rd", 703*9880d681SAndroid Build Coastguard Worker (DMFC0 GPR64Opnd:$rt, COP0Opnd:$rd, 0), 0>; 704*9880d681SAndroid Build Coastguard Worker} 705*9880d681SAndroid Build Coastguard Workerdef : MipsInstAlias<"dmfc2 $rt, $rd", (DMFC2 GPR64Opnd:$rt, COP2Opnd:$rd, 0), 0>; 706*9880d681SAndroid Build Coastguard Workerdef : MipsInstAlias<"dmtc2 $rt, $rd", (DMTC2 COP2Opnd:$rd, GPR64Opnd:$rt, 0), 0>; 707*9880d681SAndroid Build Coastguard Worker 708*9880d681SAndroid Build Coastguard Workerdef : MipsInstAlias<"synciobdma", (SYNC 0x2), 0>, ASE_MIPS64_CNMIPS; 709*9880d681SAndroid Build Coastguard Workerdef : MipsInstAlias<"syncs", (SYNC 0x6), 0>, ASE_MIPS64_CNMIPS; 710*9880d681SAndroid Build Coastguard Workerdef : MipsInstAlias<"syncw", (SYNC 0x4), 0>, ASE_MIPS64_CNMIPS; 711*9880d681SAndroid Build Coastguard Workerdef : MipsInstAlias<"syncws", (SYNC 0x5), 0>, ASE_MIPS64_CNMIPS; 712*9880d681SAndroid Build Coastguard Worker 713*9880d681SAndroid Build Coastguard Worker// cnMIPS Aliases. 714*9880d681SAndroid Build Coastguard Worker 715*9880d681SAndroid Build Coastguard Worker// bbit* with $p 32-63 converted to bbit*32 with $p 0-31 716*9880d681SAndroid Build Coastguard Workerdef : MipsInstAlias<"bbit0 $rs, $p, $offset", 717*9880d681SAndroid Build Coastguard Worker (BBIT032 GPR64Opnd:$rs, uimm5_plus32_normalize_64:$p, 718*9880d681SAndroid Build Coastguard Worker brtarget:$offset), 0>, 719*9880d681SAndroid Build Coastguard Worker ASE_CNMIPS; 720*9880d681SAndroid Build Coastguard Workerdef : MipsInstAlias<"bbit1 $rs, $p, $offset", 721*9880d681SAndroid Build Coastguard Worker (BBIT132 GPR64Opnd:$rs, uimm5_plus32_normalize_64:$p, 722*9880d681SAndroid Build Coastguard Worker brtarget:$offset), 0>, 723*9880d681SAndroid Build Coastguard Worker ASE_CNMIPS; 724*9880d681SAndroid Build Coastguard Worker 725*9880d681SAndroid Build Coastguard Worker// exts with $pos 32-63 in converted to exts32 with $pos 0-31 726*9880d681SAndroid Build Coastguard Workerdef : MipsInstAlias<"exts $rt, $rs, $pos, $lenm1", 727*9880d681SAndroid Build Coastguard Worker (EXTS32 GPR64Opnd:$rt, GPR64Opnd:$rs, 728*9880d681SAndroid Build Coastguard Worker uimm5_plus32_normalize:$pos, uimm5:$lenm1), 0>, 729*9880d681SAndroid Build Coastguard Worker ASE_CNMIPS; 730*9880d681SAndroid Build Coastguard Workerdef : MipsInstAlias<"exts $rt, $pos, $lenm1", 731*9880d681SAndroid Build Coastguard Worker (EXTS32 GPR64Opnd:$rt, GPR64Opnd:$rt, 732*9880d681SAndroid Build Coastguard Worker uimm5_plus32_normalize:$pos, uimm5:$lenm1), 0>, 733*9880d681SAndroid Build Coastguard Worker ASE_CNMIPS; 734*9880d681SAndroid Build Coastguard Worker 735*9880d681SAndroid Build Coastguard Worker// cins with $pos 32-63 in converted to cins32 with $pos 0-31 736*9880d681SAndroid Build Coastguard Workerdef : MipsInstAlias<"cins $rt, $rs, $pos, $lenm1", 737*9880d681SAndroid Build Coastguard Worker (CINS32 GPR64Opnd:$rt, GPR64Opnd:$rs, 738*9880d681SAndroid Build Coastguard Worker uimm5_plus32_normalize:$pos, uimm5:$lenm1), 0>, 739*9880d681SAndroid Build Coastguard Worker ASE_CNMIPS; 740*9880d681SAndroid Build Coastguard Workerdef : MipsInstAlias<"cins $rt, $pos, $lenm1", 741*9880d681SAndroid Build Coastguard Worker (CINS32 GPR64Opnd:$rt, GPR64Opnd:$rt, 742*9880d681SAndroid Build Coastguard Worker uimm5_plus32_normalize:$pos, uimm5:$lenm1), 0>, 743*9880d681SAndroid Build Coastguard Worker ASE_CNMIPS; 744*9880d681SAndroid Build Coastguard Worker 745*9880d681SAndroid Build Coastguard Worker//===----------------------------------------------------------------------===// 746*9880d681SAndroid Build Coastguard Worker// Assembler Pseudo Instructions 747*9880d681SAndroid Build Coastguard Worker//===----------------------------------------------------------------------===// 748*9880d681SAndroid Build Coastguard Worker 749*9880d681SAndroid Build Coastguard Workerclass LoadImmediate64<string instr_asm, Operand Od, RegisterOperand RO> : 750*9880d681SAndroid Build Coastguard Worker MipsAsmPseudoInst<(outs RO:$rt), (ins Od:$imm64), 751*9880d681SAndroid Build Coastguard Worker !strconcat(instr_asm, "\t$rt, $imm64")> ; 752*9880d681SAndroid Build Coastguard Workerdef LoadImm64 : LoadImmediate64<"dli", imm64, GPR64Opnd>; 753*9880d681SAndroid Build Coastguard Worker 754*9880d681SAndroid Build Coastguard Workerdef LoadAddrReg64 : MipsAsmPseudoInst<(outs GPR64Opnd:$rt), (ins mem:$addr), 755*9880d681SAndroid Build Coastguard Worker "dla\t$rt, $addr">; 756*9880d681SAndroid Build Coastguard Workerdef LoadAddrImm64 : MipsAsmPseudoInst<(outs GPR64Opnd:$rt), (ins imm64:$imm64), 757*9880d681SAndroid Build Coastguard Worker "dla\t$rt, $imm64">; 758