1e8d8bef9SDimitry Andric//===-- CSKYInstrInfo.td - Target Description for CSKY -----*- tablegen -*-===// 2e8d8bef9SDimitry Andric// 3e8d8bef9SDimitry Andric// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4e8d8bef9SDimitry Andric// See https://llvm.org/LICENSE.txt for license information. 5e8d8bef9SDimitry Andric// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6e8d8bef9SDimitry Andric// 7e8d8bef9SDimitry Andric//===----------------------------------------------------------------------===// 8e8d8bef9SDimitry Andric// 9e8d8bef9SDimitry Andric// This file describes the CSKY instructions in TableGen format. 10e8d8bef9SDimitry Andric// 11e8d8bef9SDimitry Andric//===----------------------------------------------------------------------===// 12e8d8bef9SDimitry Andric 13e8d8bef9SDimitry Andric 14e8d8bef9SDimitry Andric//===----------------------------------------------------------------------===// 15e8d8bef9SDimitry Andric// CSKY specific DAG Nodes. 16e8d8bef9SDimitry Andric//===----------------------------------------------------------------------===// 17e8d8bef9SDimitry Andric 18*349cc55cSDimitry Andricdef SDT_CallSeqStart : SDCallSeqStart<[SDTCisVT<0, i32>, 19*349cc55cSDimitry Andric SDTCisVT<1, i32>]>; 20*349cc55cSDimitry Andric 21*349cc55cSDimitry Andricdef SDT_CallSeqEnd : SDCallSeqEnd<[SDTCisVT<0, i32>, 22*349cc55cSDimitry Andric SDTCisVT<1, i32>]>; 23*349cc55cSDimitry Andric 24*349cc55cSDimitry Andricdef callseq_start : SDNode<"ISD::CALLSEQ_START", SDT_CallSeqStart, 25*349cc55cSDimitry Andric [SDNPHasChain, SDNPOutGlue]>; 26*349cc55cSDimitry Andric 27*349cc55cSDimitry Andricdef callseq_end : SDNode<"ISD::CALLSEQ_END", SDT_CallSeqEnd, 28*349cc55cSDimitry Andric [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue]>; 29*349cc55cSDimitry Andric 30fe6060f1SDimitry Andric// Target-dependent nodes. 31fe6060f1SDimitry Andricdef CSKY_RET : SDNode<"CSKYISD::RET", SDTNone, 32fe6060f1SDimitry Andric [SDNPHasChain, SDNPOptInGlue, SDNPVariadic]>; 33e8d8bef9SDimitry Andric 34e8d8bef9SDimitry Andric//===----------------------------------------------------------------------===// 35e8d8bef9SDimitry Andric// Operand and SDNode transformation definitions. 36e8d8bef9SDimitry Andric//===----------------------------------------------------------------------===// 37fe6060f1SDimitry Andricclass ImmAsmOperand<string prefix, int width, string suffix> : AsmOperandClass { 38fe6060f1SDimitry Andric let Name = prefix # "Imm" # width # suffix; 39fe6060f1SDimitry Andric let RenderMethod = "addImmOperands"; 40fe6060f1SDimitry Andric let DiagnosticType = !strconcat("Invalid", Name); 41fe6060f1SDimitry Andric} 42fe6060f1SDimitry Andric 43fe6060f1SDimitry Andricclass SImmAsmOperand<int width, string suffix = ""> 44fe6060f1SDimitry Andric : ImmAsmOperand<"S", width, suffix> { 45fe6060f1SDimitry Andric} 46fe6060f1SDimitry Andric 47fe6060f1SDimitry Andricclass UImmAsmOperand<int width, string suffix = ""> 48fe6060f1SDimitry Andric : ImmAsmOperand<"U", width, suffix> { 49fe6060f1SDimitry Andric} 50fe6060f1SDimitry Andric 51fe6060f1SDimitry Andricclass OImmAsmOperand<int width, string suffix = ""> 52fe6060f1SDimitry Andric : ImmAsmOperand<"O", width, suffix> { 53fe6060f1SDimitry Andric} 54e8d8bef9SDimitry Andric 55e8d8bef9SDimitry Andricclass oimm<int num> : Operand<i32>, 56e8d8bef9SDimitry Andric ImmLeaf<i32, "return isUInt<"#num#">(Imm - 1);"> { 57e8d8bef9SDimitry Andric let EncoderMethod = "getOImmOpValue"; 58fe6060f1SDimitry Andric let ParserMatchClass = OImmAsmOperand<num>; 59*349cc55cSDimitry Andric let DecoderMethod = "decodeOImmOperand<"#num#">"; 60e8d8bef9SDimitry Andric} 61e8d8bef9SDimitry Andric 62e8d8bef9SDimitry Andricclass uimm<int num, int shift = 0> : Operand<i32>, 63e8d8bef9SDimitry Andric ImmLeaf<i32, "return isShiftedUInt<"#num#", "#shift#">(Imm);"> { 64e8d8bef9SDimitry Andric let EncoderMethod = "getImmOpValue<"#shift#">"; 65fe6060f1SDimitry Andric let ParserMatchClass = 66fe6060f1SDimitry Andric !if(!ne(shift, 0), 67fe6060f1SDimitry Andric UImmAsmOperand<num, "Shift"#shift>, 68fe6060f1SDimitry Andric UImmAsmOperand<num>); 69*349cc55cSDimitry Andric let DecoderMethod = "decodeUImmOperand<"#num#", "#shift#">"; 70e8d8bef9SDimitry Andric} 71e8d8bef9SDimitry Andric 72e8d8bef9SDimitry Andricclass simm<int num, int shift = 0> : Operand<i32>, 73e8d8bef9SDimitry Andric ImmLeaf<i32, "return isShiftedInt<"#num#", "#shift#">(Imm);"> { 74e8d8bef9SDimitry Andric let EncoderMethod = "getImmOpValue<"#shift#">"; 75fe6060f1SDimitry Andric let ParserMatchClass = SImmAsmOperand<num>; 76*349cc55cSDimitry Andric let DecoderMethod = "decodeSImmOperand<"#num#", "#shift#">"; 77e8d8bef9SDimitry Andric} 78e8d8bef9SDimitry Andric 79e8d8bef9SDimitry Andricdef nimm_XFORM : SDNodeXForm<imm, [{ 80e8d8bef9SDimitry Andric return CurDAG->getTargetConstant(~N->getSExtValue(), SDLoc(N), MVT::i32); 81e8d8bef9SDimitry Andric}]>; 82e8d8bef9SDimitry Andricclass nimm<int num> : Operand<i32>, 83e8d8bef9SDimitry Andric ImmLeaf<i32, "return isUInt<"#num#">(~Imm);", nimm_XFORM> { 84fe6060f1SDimitry Andric let ParserMatchClass = UImmAsmOperand<num>; 85e8d8bef9SDimitry Andric} 86e8d8bef9SDimitry Andric 87fe6060f1SDimitry Andricdef uimm32_hi16 : SDNodeXForm<imm, [{ 88fe6060f1SDimitry Andric return CurDAG->getTargetConstant((N->getZExtValue() >> 16) & 0xFFFF, 89fe6060f1SDimitry Andric SDLoc(N), MVT::i32); 90fe6060f1SDimitry Andric}]>; 91*349cc55cSDimitry Andricdef uimm32_lo16 : SDNodeXForm<imm, [{ 92*349cc55cSDimitry Andric return CurDAG->getTargetConstant(N->getZExtValue()& 0xFFFF, SDLoc(N), MVT::i32); 93*349cc55cSDimitry Andric}]>; 94fe6060f1SDimitry Andricdef uimm16_16_xform : Operand<i32>, 95fe6060f1SDimitry Andric ImmLeaf<i32, "return isShiftedUInt<16, 16>(Imm);", uimm32_hi16> { 96fe6060f1SDimitry Andric let ParserMatchClass = UImmAsmOperand<16>; 97*349cc55cSDimitry Andric let EncoderMethod = "getImmOpValue"; 98fe6060f1SDimitry Andric} 99fe6060f1SDimitry Andric 100fe6060f1SDimitry Andricdef uimm_shift : Operand<i32>, ImmLeaf<i32, "return isUInt<2>(Imm);"> { 101fe6060f1SDimitry Andric let EncoderMethod = "getImmShiftOpValue"; 102fe6060f1SDimitry Andric let ParserMatchClass = UImmAsmOperand<2>; 103*349cc55cSDimitry Andric let DecoderMethod = "decodeImmShiftOpValue"; 104fe6060f1SDimitry Andric} 105fe6060f1SDimitry Andric 106fe6060f1SDimitry Andricdef CSKYSymbol : AsmOperandClass { 107fe6060f1SDimitry Andric let Name = "CSKYSymbol"; 108fe6060f1SDimitry Andric let RenderMethod = "addImmOperands"; 109fe6060f1SDimitry Andric let DiagnosticType = "InvalidCSKYSymbol"; 110fe6060f1SDimitry Andric let ParserMethod = "parseCSKYSymbol"; 111fe6060f1SDimitry Andric} 112fe6060f1SDimitry Andric 113fe6060f1SDimitry Andricdef br_symbol : Operand<iPTR> { 114fe6060f1SDimitry Andric let EncoderMethod = 115fe6060f1SDimitry Andric "getBranchSymbolOpValue<CSKY::fixup_csky_pcrel_imm16_scale2>"; 116fe6060f1SDimitry Andric let ParserMatchClass = CSKYSymbol; 117*349cc55cSDimitry Andric let DecoderMethod = "decodeSImmOperand<16, 1>"; 118*349cc55cSDimitry Andric let PrintMethod = "printCSKYSymbolOperand"; 119*349cc55cSDimitry Andric let OperandType = "OPERAND_PCREL"; 120fe6060f1SDimitry Andric} 121fe6060f1SDimitry Andric 122fe6060f1SDimitry Andricdef call_symbol : Operand<iPTR> { 123fe6060f1SDimitry Andric let ParserMatchClass = CSKYSymbol; 124fe6060f1SDimitry Andric let EncoderMethod = "getCallSymbolOpValue"; 125*349cc55cSDimitry Andric let DecoderMethod = "decodeSImmOperand<26, 1>"; 126*349cc55cSDimitry Andric let PrintMethod = "printCSKYSymbolOperand"; 127*349cc55cSDimitry Andric let OperandType = "OPERAND_PCREL"; 128fe6060f1SDimitry Andric} 129fe6060f1SDimitry Andric 130fe6060f1SDimitry Andricdef Constpool : AsmOperandClass { 131*349cc55cSDimitry Andric let Name = "Constpool"; 132*349cc55cSDimitry Andric let RenderMethod = "addConstpoolOperands"; 133fe6060f1SDimitry Andric let DiagnosticType = "InvalidConstpool"; 134fe6060f1SDimitry Andric let ParserMethod = "parseConstpoolSymbol"; 135fe6060f1SDimitry Andric} 136fe6060f1SDimitry Andric 137fe6060f1SDimitry Andricdef constpool_symbol : Operand<iPTR> { 138fe6060f1SDimitry Andric let ParserMatchClass = Constpool; 139fe6060f1SDimitry Andric let EncoderMethod = 140fe6060f1SDimitry Andric "getConstpoolSymbolOpValue<CSKY::fixup_csky_pcrel_uimm16_scale4>"; 141*349cc55cSDimitry Andric let DecoderMethod = "decodeUImmOperand<16, 2>"; 142*349cc55cSDimitry Andric let PrintMethod = "printConstpool"; 143*349cc55cSDimitry Andric let OperandType = "OPERAND_PCREL"; 144*349cc55cSDimitry Andric} 145*349cc55cSDimitry Andric 146*349cc55cSDimitry Andricdef DataAsmClass : AsmOperandClass { 147*349cc55cSDimitry Andric let Name = "DataSymbol"; 148*349cc55cSDimitry Andric let RenderMethod = "addConstpoolOperands"; 149*349cc55cSDimitry Andric let DiagnosticType = "InvalidConstpool"; 150*349cc55cSDimitry Andric let ParserMethod = "parseDataSymbol"; 151*349cc55cSDimitry Andric} 152*349cc55cSDimitry Andric 153*349cc55cSDimitry Andricclass data_symbol<string reloc, int shift> : Operand<iPTR> { 154*349cc55cSDimitry Andric let ParserMatchClass = Constpool; 155*349cc55cSDimitry Andric let EncoderMethod = 156*349cc55cSDimitry Andric "getDataSymbolOpValue<"#reloc#">"; 157*349cc55cSDimitry Andric let DecoderMethod = "decodeUImmOperand<18, "#shift#">"; 158*349cc55cSDimitry Andric let PrintMethod = "printDataSymbol"; 159fe6060f1SDimitry Andric} 160fe6060f1SDimitry Andric 161fe6060f1SDimitry Andricdef bare_symbol : Operand<iPTR> { 162fe6060f1SDimitry Andric let ParserMatchClass = CSKYSymbol; 163fe6060f1SDimitry Andric let EncoderMethod = "getBareSymbolOpValue"; 164*349cc55cSDimitry Andric let PrintMethod = "printCSKYSymbolOperand"; 165*349cc55cSDimitry Andric let DecoderMethod = "decodeSImmOperand<18, 1>"; 166*349cc55cSDimitry Andric let OperandType = "OPERAND_PCREL"; 167fe6060f1SDimitry Andric} 168e8d8bef9SDimitry Andric 169*349cc55cSDimitry Andricdef oimm3 : oimm<3>; 170*349cc55cSDimitry Andricdef oimm4 : oimm<4>; 171*349cc55cSDimitry Andricdef oimm5 : oimm<5>; 172*349cc55cSDimitry Andricdef oimm6 : oimm<6>; 173*349cc55cSDimitry Andric 174*349cc55cSDimitry Andricdef imm5_idly : Operand<i32>, ImmLeaf<i32, 175*349cc55cSDimitry Andric "return Imm <= 32 && Imm >= 0;"> { 176*349cc55cSDimitry Andric let EncoderMethod = "getImmOpValueIDLY"; 177*349cc55cSDimitry Andric let DecoderMethod = "decodeOImmOperand<5>"; 178*349cc55cSDimitry Andric} 179*349cc55cSDimitry Andric 180*349cc55cSDimitry Andricdef oimm8 : oimm<8>; 181e8d8bef9SDimitry Andricdef oimm12 : oimm<12>; 182fe6060f1SDimitry Andricdef oimm16 : oimm<16>; 183e8d8bef9SDimitry Andric 184e8d8bef9SDimitry Andricdef nimm12 : nimm<12>; 185e8d8bef9SDimitry Andric 186*349cc55cSDimitry Andricdef uimm1 : uimm<1>; 187*349cc55cSDimitry Andricdef uimm2 : uimm<2>; 188*349cc55cSDimitry Andric 189*349cc55cSDimitry Andric 190*349cc55cSDimitry Andricdef uimm2_jmpix : Operand<i32>, 191*349cc55cSDimitry Andric ImmLeaf<i32, "return Imm == 16 || Imm == 24 || Imm == 32 || Imm == 40;"> { 192*349cc55cSDimitry Andric let EncoderMethod = "getImmJMPIX"; 193*349cc55cSDimitry Andric let DecoderMethod = "decodeJMPIXImmOperand"; 194*349cc55cSDimitry Andric} 195*349cc55cSDimitry Andric 196*349cc55cSDimitry Andricdef uimm3 : uimm<3>; 197*349cc55cSDimitry Andricdef uimm4 : uimm<4>; 198e8d8bef9SDimitry Andricdef uimm5 : uimm<5>; 199*349cc55cSDimitry Andricdef uimm5_msb_size : uimm<5> { 200*349cc55cSDimitry Andric let EncoderMethod = "getImmOpValueMSBSize"; 201*349cc55cSDimitry Andric} 202*349cc55cSDimitry Andric 203*349cc55cSDimitry Andricdef uimm5_1 : uimm<5, 1>; 204*349cc55cSDimitry Andricdef uimm5_2 : uimm<5, 2>; 205*349cc55cSDimitry Andricdef uimm6 : uimm<6>; 206*349cc55cSDimitry Andricdef uimm7 : uimm<7>; 207*349cc55cSDimitry Andricdef uimm7_1 : uimm<7, 1>; 208*349cc55cSDimitry Andricdef uimm7_2 : uimm<7, 2>; 209*349cc55cSDimitry Andricdef uimm7_3 : uimm<7, 3>; 210*349cc55cSDimitry Andricdef uimm8 : uimm<8>; 211*349cc55cSDimitry Andricdef uimm8_2 : uimm<8, 2>; 212*349cc55cSDimitry Andricdef uimm8_3 : uimm<8, 3>; 213*349cc55cSDimitry Andricdef uimm8_8 : uimm<8, 8>; 214*349cc55cSDimitry Andricdef uimm8_16 : uimm<8, 16>; 215*349cc55cSDimitry Andricdef uimm8_24 : uimm<8, 24>; 216e8d8bef9SDimitry Andricdef uimm12 : uimm<12>; 217fe6060f1SDimitry Andricdef uimm12_1 : uimm<12, 1>; 218fe6060f1SDimitry Andricdef uimm12_2 : uimm<12, 2>; 219fe6060f1SDimitry Andricdef uimm16 : uimm<16>; 220*349cc55cSDimitry Andricdef uimm16_8 : uimm<16, 8>; 221*349cc55cSDimitry Andricdef uimm16_16 : uimm<16, 16>; 222*349cc55cSDimitry Andricdef uimm20 : uimm<20>; 223*349cc55cSDimitry Andricdef uimm24 : uimm<24>; 224*349cc55cSDimitry Andricdef uimm24_8 : uimm<24, 8>; 225fe6060f1SDimitry Andric 226*349cc55cSDimitry Andricdef simm8_2 : simm<8, 2>; 227*349cc55cSDimitry Andric 228*349cc55cSDimitry Andricclass RegSeqAsmOperand<string Suffix = ""> : AsmOperandClass { 229*349cc55cSDimitry Andric let Name = "RegSeq"#Suffix; 230*349cc55cSDimitry Andric let RenderMethod = "addRegSeqOperands"; 231*349cc55cSDimitry Andric let DiagnosticType = "InvalidRegSeq"; 232*349cc55cSDimitry Andric let ParserMethod = "parseRegSeq"; 233*349cc55cSDimitry Andric} 234*349cc55cSDimitry Andric 235*349cc55cSDimitry Andricdef regseq : Operand<iPTR> { 236*349cc55cSDimitry Andric let EncoderMethod = "getRegisterSeqOpValue"; 237*349cc55cSDimitry Andric let ParserMatchClass = RegSeqAsmOperand<"">; 238*349cc55cSDimitry Andric let PrintMethod = "printRegisterSeq"; 239*349cc55cSDimitry Andric let DecoderMethod = "DecodeRegSeqOperand"; 240*349cc55cSDimitry Andric let MIOperandInfo = (ops GPR, uimm5); 241*349cc55cSDimitry Andric} 242*349cc55cSDimitry Andric 243*349cc55cSDimitry Andricdef RegListAsmOperand : AsmOperandClass { 244*349cc55cSDimitry Andric let Name = "RegList"; 245*349cc55cSDimitry Andric let RenderMethod = "addRegListOperands"; 246*349cc55cSDimitry Andric let DiagnosticType = "InvalidRegList"; 247*349cc55cSDimitry Andric let ParserMethod = "parseRegList"; 248*349cc55cSDimitry Andric} 249*349cc55cSDimitry Andric 250*349cc55cSDimitry Andricdef reglist : Operand<iPTR> { 251*349cc55cSDimitry Andric let ParserMatchClass = RegListAsmOperand; 252*349cc55cSDimitry Andric let PrintMethod = "printRegisterList"; 253*349cc55cSDimitry Andric} 254*349cc55cSDimitry Andric 255*349cc55cSDimitry Andricdef PSRFlag : AsmOperandClass { 256*349cc55cSDimitry Andric let Name = "PSRFlag"; 257*349cc55cSDimitry Andric let RenderMethod = "addImmOperands"; 258*349cc55cSDimitry Andric let DiagnosticType = "InvalidPSRFlag"; 259*349cc55cSDimitry Andric let ParserMethod = "parsePSRFlag"; 260*349cc55cSDimitry Andric} 261*349cc55cSDimitry Andric 262*349cc55cSDimitry Andricdef psrflag : Operand<i32>, ImmLeaf<i32, "return isShiftedUInt<5, 0>(Imm);"> { 263*349cc55cSDimitry Andric let EncoderMethod = "getImmOpValue"; 264*349cc55cSDimitry Andric let ParserMatchClass = PSRFlag; 265*349cc55cSDimitry Andric let PrintMethod = "printPSRFlag"; 266*349cc55cSDimitry Andric} 267fe6060f1SDimitry Andric 268fe6060f1SDimitry Andric//===----------------------------------------------------------------------===// 269fe6060f1SDimitry Andric// Instruction Formats 270fe6060f1SDimitry Andric//===----------------------------------------------------------------------===// 271fe6060f1SDimitry Andric 272fe6060f1SDimitry Andricinclude "CSKYInstrFormats.td" 273e8d8bef9SDimitry Andric 274e8d8bef9SDimitry Andric//===----------------------------------------------------------------------===// 275e8d8bef9SDimitry Andric// Instruction definitions. 276e8d8bef9SDimitry Andric//===----------------------------------------------------------------------===// 277e8d8bef9SDimitry Andric 278e8d8bef9SDimitry Andricclass TriOpFrag<dag res> : PatFrag<(ops node: $LHS, node:$MHS, node:$RHS), res>; 279e8d8bef9SDimitry Andricclass BinOpFrag<dag res> : PatFrag<(ops node:$LHS, node:$RHS), res>; 280e8d8bef9SDimitry Andricclass UnOpFrag<dag res> : PatFrag<(ops node:$Src), res>; 281e8d8bef9SDimitry Andric 282*349cc55cSDimitry Andricdef eqToAdd : PatFrag<(ops node:$lhs, node:$rhs), (or node:$lhs, node:$rhs), [{ 283*349cc55cSDimitry Andric return isOrEquivalentToAdd(N); 284*349cc55cSDimitry Andric}]>; 285*349cc55cSDimitry Andric 286*349cc55cSDimitry Andricdef BaseAddr : ComplexPattern<iPTR, 1, "SelectBaseAddr">; 287*349cc55cSDimitry Andric 288*349cc55cSDimitry Andric 289*349cc55cSDimitry Andric//===----------------------------------------------------------------------===// 290*349cc55cSDimitry Andric// CSKYPseudo 291*349cc55cSDimitry Andric//===----------------------------------------------------------------------===// 292*349cc55cSDimitry Andric 293*349cc55cSDimitry Andric// Pessimistically assume the stack pointer will be clobbered 294*349cc55cSDimitry Andriclet Defs = [R14], Uses = [R14] in { 295*349cc55cSDimitry Andricdef ADJCALLSTACKDOWN : CSKYPseudo<(outs), (ins i32imm:$amt1, i32imm:$amt2), 296*349cc55cSDimitry Andric "!ADJCALLSTACKDOWN $amt1, $amt2", [(callseq_start timm:$amt1, timm:$amt2)]>; 297*349cc55cSDimitry Andricdef ADJCALLSTACKUP : CSKYPseudo<(outs), (ins i32imm:$amt1, i32imm:$amt2), 298*349cc55cSDimitry Andric "!ADJCALLSTACKUP $amt1, $amt2", [(callseq_end timm:$amt1, timm:$amt2)]>; 299*349cc55cSDimitry Andric} // Defs = [R14], Uses = [R14] 300fe6060f1SDimitry Andric 301fe6060f1SDimitry Andric 302fe6060f1SDimitry Andric//===----------------------------------------------------------------------===// 303fe6060f1SDimitry Andric// Basic ALU instructions. 304fe6060f1SDimitry Andric//===----------------------------------------------------------------------===// 305fe6060f1SDimitry Andric 306*349cc55cSDimitry Andriclet Predicates = [iHasE2] in { 307*349cc55cSDimitry Andric let isReMaterializable = 1, isAsCheapAsAMove = 1 in { 308*349cc55cSDimitry Andric let isAdd = 1 in 309e8d8bef9SDimitry Andric def ADDI32 : I_12<0x0, "addi32", add, oimm12>; 310e8d8bef9SDimitry Andric def SUBI32 : I_12<0x1, "subi32", sub, oimm12>; 311fe6060f1SDimitry Andric def ORI32 : I_16_ZX<"ori32", uimm16, 312fe6060f1SDimitry Andric [(set GPR:$rz, (or GPR:$rx, uimm16:$imm16))]>; 313fe6060f1SDimitry Andric def XORI32 : I_12<0x4, "xori32", xor, uimm12>; 314e8d8bef9SDimitry Andric def ANDI32 : I_12<0x2, "andi32", and, uimm12>; 315e8d8bef9SDimitry Andric def ANDNI32 : I_12<0x3, "andni32", and, nimm12>; 316e8d8bef9SDimitry Andric def LSLI32 : I_5_XZ<0x12, 0x1, "lsli32", 317e8d8bef9SDimitry Andric (outs GPR:$rz), (ins GPR:$rx, uimm5:$imm5), 318e8d8bef9SDimitry Andric [(set GPR:$rz, (shl GPR:$rx, uimm5:$imm5))]>; 319e8d8bef9SDimitry Andric def LSRI32 : I_5_XZ<0x12, 0x2, "lsri32", 320e8d8bef9SDimitry Andric (outs GPR:$rz), (ins GPR:$rx, uimm5:$imm5), 321e8d8bef9SDimitry Andric [(set GPR:$rz, (srl GPR:$rx, uimm5:$imm5))]>; 322e8d8bef9SDimitry Andric def ASRI32 : I_5_XZ<0x12, 0x4, "asri32", 323e8d8bef9SDimitry Andric (outs GPR:$rz), (ins GPR:$rx, uimm5:$imm5), 324e8d8bef9SDimitry Andric [(set GPR:$rz, (sra GPR:$rx, uimm5:$imm5))]>; 325fe6060f1SDimitry Andric def ROTLI32 : I_5_XZ<0x12, 0x8, "rotli32", 326fe6060f1SDimitry Andric (outs GPR:$rz), (ins GPR:$rx, uimm5:$imm5), 327fe6060f1SDimitry Andric [(set GPR:$rz, (rotl GPR:$rx, uimm5:$imm5))]>; 328e8d8bef9SDimitry Andric 329*349cc55cSDimitry Andric def ROTRI32 : CSKYPseudo<(outs GPR:$rz), (ins GPR:$rx, oimm5:$imm5), 330*349cc55cSDimitry Andric "rotri32 $rz, $rx, $imm5", []>; 331*349cc55cSDimitry Andric } 332*349cc55cSDimitry Andric let isAdd = 1 in 333e8d8bef9SDimitry Andric def ADDU32 : R_YXZ_SP_F1<0x0, 0x1, 334e8d8bef9SDimitry Andric BinOpFrag<(add node:$LHS, node:$RHS)>, "addu32", 1>; 335e8d8bef9SDimitry Andric def SUBU32 : R_YXZ_SP_F1<0x0, 0x4, 336e8d8bef9SDimitry Andric BinOpFrag<(sub node:$LHS, node:$RHS)>, "subu32">; 337*349cc55cSDimitry Andric 338fe6060f1SDimitry Andric def MULT32 : R_YXZ_SP_F1<0x21, 0x1, 339fe6060f1SDimitry Andric BinOpFrag<(mul node:$LHS, node:$RHS)>, "mult32", 1>; 340e8d8bef9SDimitry Andric def AND32 : R_YXZ_SP_F1<0x8, 0x1, 341e8d8bef9SDimitry Andric BinOpFrag<(and node:$LHS, node:$RHS)>, "and32", 1>; 342e8d8bef9SDimitry Andric def ANDN32 : R_YXZ_SP_F1<0x8, 0x2, 343e8d8bef9SDimitry Andric BinOpFrag<(and node:$LHS, (not node:$RHS))>, "andn32">; 344e8d8bef9SDimitry Andric def OR32: R_YXZ_SP_F1<0x9, 0x1, 345e8d8bef9SDimitry Andric BinOpFrag<(or node:$LHS, node:$RHS)>, "or32", 1>; 346e8d8bef9SDimitry Andric def XOR32 : R_YXZ_SP_F1<0x9, 0x2, 347e8d8bef9SDimitry Andric BinOpFrag<(xor node:$LHS, node:$RHS)>, "xor32", 1>; 348e8d8bef9SDimitry Andric def NOR32 : R_YXZ_SP_F1<0x9, 0x4, 349e8d8bef9SDimitry Andric BinOpFrag<(not (or node:$LHS, node:$RHS))>, "nor32", 1>; 350*349cc55cSDimitry Andric let isCodeGenOnly = 1 in 351fe6060f1SDimitry Andric def NOT32 : R_XXZ<0b001001, 0b00100, (outs GPR:$rz), (ins GPR:$rx), 352fe6060f1SDimitry Andric "not32", [(set GPR:$rz, (not GPR:$rx))]>; 353*349cc55cSDimitry Andric 354*349cc55cSDimitry Andric let Size = 8 in 355*349cc55cSDimitry Andric def NEG32 : CSKYPseudo<(outs GPR:$rd), (ins GPR:$rx), "neg32 $rd, $rx", []>; 356*349cc55cSDimitry Andric 357*349cc55cSDimitry Andric let Size = 8 in 358*349cc55cSDimitry Andric def RSUBI32 : CSKYPseudo<(outs GPR:$rd), (ins GPR:$rx, uimm12:$imm12), "rsubi32 $rd, $rx, $imm12", []>; 359*349cc55cSDimitry Andric 360e8d8bef9SDimitry Andric def LSL32 : R_YXZ_SP_F1<0x10, 0x1, 361e8d8bef9SDimitry Andric BinOpFrag<(shl node:$LHS, node:$RHS)>, "lsl32">; 362e8d8bef9SDimitry Andric def LSR32 : R_YXZ_SP_F1<0x10, 0x2, 363e8d8bef9SDimitry Andric BinOpFrag<(srl node:$LHS, node:$RHS)>, "lsr32">; 364e8d8bef9SDimitry Andric def ASR32 : R_YXZ_SP_F1<0x10, 0x4, 365e8d8bef9SDimitry Andric BinOpFrag<(sra node:$LHS, node:$RHS)>, "asr32">; 366fe6060f1SDimitry Andric def ROTL32 : R_YXZ_SP_F1<0x10, 0x8, 367fe6060f1SDimitry Andric BinOpFrag<(rotl node:$LHS, (and node:$RHS, 0x1f))>, "rotl32">; 368fe6060f1SDimitry Andric 369*349cc55cSDimitry Andric def BMASKI32 : I_5_Z<0b010100, 0x1, "bmaski32", oimm5, []>; 370*349cc55cSDimitry Andric def LSLC32 : I_5_XZ<0x13, 0x1, "lslc32", 371*349cc55cSDimitry Andric (outs GPR:$rz, CARRY:$cout), (ins GPR:$rx, oimm5:$imm5), []>; 372*349cc55cSDimitry Andric def LSRC32 : I_5_XZ<0x13, 0x2, "lsrc32", 373*349cc55cSDimitry Andric (outs GPR:$rz, CARRY:$cout), (ins GPR:$rx, oimm5:$imm5), []>; 374*349cc55cSDimitry Andric def ASRC32 : I_5_XZ<0x13, 0x4, "asrc32", 375*349cc55cSDimitry Andric (outs GPR:$rz, CARRY:$cout), (ins GPR:$rx, oimm5:$imm5), []>; 376*349cc55cSDimitry Andric def XSR32 : I_5_XZ<0x13, 0x8, "xsr32", 377*349cc55cSDimitry Andric (outs GPR:$rz, CARRY:$cout), (ins GPR:$rx, oimm5:$imm5, CARRY:$cin), []>; 378fe6060f1SDimitry Andric 379fe6060f1SDimitry Andric def IXH32 : R_YXZ_SP_F1<0x2, 0x1, 380fe6060f1SDimitry Andric BinOpFrag<(add node:$LHS, (shl node:$RHS, (i32 1)))>, "ixh32">; 381fe6060f1SDimitry Andric def IXW32 : R_YXZ_SP_F1<0x2, 0x2, 382fe6060f1SDimitry Andric BinOpFrag<(add node:$LHS, (shl node:$RHS, (i32 2)))>, "ixw32">; 383*349cc55cSDimitry Andric let Predicates = [iHas2E3] in 384fe6060f1SDimitry Andric def IXD32 : R_YXZ_SP_F1<0x2, 0x4, 385fe6060f1SDimitry Andric BinOpFrag<(add node:$LHS, (shl node:$RHS, (i32 3)))>, "ixd32">; 386fe6060f1SDimitry Andric 387*349cc55cSDimitry Andric let isCommutable = 1, isAdd = 1 in 388fe6060f1SDimitry Andric def ADDC32 : R_YXZ<0x31, 0x0, 0x2, (outs GPR:$rz, CARRY:$cout), 389fe6060f1SDimitry Andric (ins GPR:$rx, GPR:$ry, CARRY:$cin), "addc32", []>; 390fe6060f1SDimitry Andric def SUBC32 : R_YXZ<0x31, 0x0, 0x8, (outs GPR:$rz, CARRY:$cout), 391fe6060f1SDimitry Andric (ins GPR:$rx, GPR:$ry, CARRY:$cin), "subc32", []>; 392fe6060f1SDimitry Andric 393*349cc55cSDimitry Andric def INCF32 : I_5_ZX<0x3, 0x1, "incf32", uimm5, []>; 394*349cc55cSDimitry Andric def INCT32 : I_5_ZX<0x3, 0x2, "inct32", uimm5, []>; 395*349cc55cSDimitry Andric def DECF32 : I_5_ZX<0x3, 0x4, "decf32", uimm5, []>; 396*349cc55cSDimitry Andric def DECT32 : I_5_ZX<0x3, 0x8, "dect32", uimm5, []>; 397*349cc55cSDimitry Andric} 398*349cc55cSDimitry Andric 399*349cc55cSDimitry Andriclet Predicates = [iHas2E3] in { 400e8d8bef9SDimitry Andric def DIVS32 : R_YXZ_SP_F1<0x20, 0x2, 401e8d8bef9SDimitry Andric BinOpFrag<(sdiv node:$LHS, node:$RHS)>, "divs32">; 402e8d8bef9SDimitry Andric def DIVU32 : R_YXZ_SP_F1<0x20, 0x1, 403e8d8bef9SDimitry Andric BinOpFrag<(udiv node:$LHS, node:$RHS)>, "divu32">; 404e8d8bef9SDimitry Andric 405fe6060f1SDimitry Andric def DECGT32 : I_5_XZ<0x4, 0x1, "decgt32", 406fe6060f1SDimitry Andric (outs GPR:$rz, CARRY:$cout), (ins GPR:$rx, uimm5:$imm5), []>; 407fe6060f1SDimitry Andric def DECLT32 : I_5_XZ<0x4, 0x2, "declt32", 408fe6060f1SDimitry Andric (outs GPR:$rz, CARRY:$cout), (ins GPR:$rx, uimm5:$imm5), []>; 409fe6060f1SDimitry Andric def DECNE32 : I_5_XZ<0x4, 0x4, "decne32", 410fe6060f1SDimitry Andric (outs GPR:$rz, CARRY:$cout), (ins GPR:$rx, uimm5:$imm5), []>; 411fe6060f1SDimitry Andric 412*349cc55cSDimitry Andric def SEXT32 : I_5_XZ_U<0x16, (outs GPR:$rz), (ins GPR:$rx, uimm5:$msb, uimm5:$lsb), "sext32", []>; 413*349cc55cSDimitry Andric let isCodeGenOnly = 1 in { 414*349cc55cSDimitry Andric def SEXTB32 : I_5_XZ_US<0x16, 0, 7, "sextb32", sext_inreg, i8>; 415*349cc55cSDimitry Andric def SEXTH32 : I_5_XZ_US<0x16, 0, 15, "sexth32", sext_inreg, i16>; 416*349cc55cSDimitry Andric def ZEXTB32 : I_5_XZ_UZ<0x15, 0, 7, "zextb32", 255>; 417*349cc55cSDimitry Andric def ZEXTH32 : I_5_XZ_UZ<0x15, 0, 15, "zexth32", 65535>; 418*349cc55cSDimitry Andric } 419*349cc55cSDimitry Andric def ZEXT32 : I_5_XZ_U<0x15, (outs GPR:$rz), (ins GPR:$rx, uimm5:$msb, uimm5:$lsb), "zext32",[]>; 420*349cc55cSDimitry Andric 421*349cc55cSDimitry Andric let Constraints = "$rZ = $rz" in 422*349cc55cSDimitry Andric def INS32 : I_5_XZ_INS<0b010111, (outs GPR:$rz), (ins GPR:$rZ, GPR:$rx, uimm5_msb_size:$msb, uimm5:$lsb), "ins32", []>; 423*349cc55cSDimitry Andric} 424*349cc55cSDimitry Andric 425*349cc55cSDimitry Andriclet Predicates = [iHas3E3r1] in { 426*349cc55cSDimitry Andricdef MULTS32 : R_YXZ<0x3e, 0x20, 0x10, (outs GPRPair:$rz), 427*349cc55cSDimitry Andric (ins GPR:$rx, GPR:$ry), "mul.s32", []>; 428*349cc55cSDimitry Andricdef MULTU32 : R_YXZ<0x3e, 0x20, 0x00, (outs GPRPair:$rz), 429*349cc55cSDimitry Andric (ins GPR:$rx, GPR:$ry), "mul.u32", []>; 430*349cc55cSDimitry Andric 431*349cc55cSDimitry Andriclet Constraints = "$rZ = $rz" in { 432*349cc55cSDimitry Andricdef MULATS32 : R_YXZ<0x3e, 0x20, 0x14, (outs GPRPair:$rZ), 433*349cc55cSDimitry Andric (ins GPRPair:$rz, GPR:$rx, GPR:$ry), "mula.s32", []>; 434*349cc55cSDimitry Andricdef MULATU32 : R_YXZ<0x3e, 0x20, 0x04, (outs GPRPair:$rZ), 435*349cc55cSDimitry Andric (ins GPRPair:$rz, GPR:$rx, GPR:$ry), "mula.u32", []>; 436*349cc55cSDimitry Andric} 437*349cc55cSDimitry Andric} 438*349cc55cSDimitry Andric 439*349cc55cSDimitry Andricdef MULSH32 : R_YXZ<0x31, 0b100100, 0b00001, (outs GPR:$rz), 440*349cc55cSDimitry Andric (ins GPR:$rx, GPR:$ry), "mulsh32", []>; 441fe6060f1SDimitry Andric 442fe6060f1SDimitry Andric//===----------------------------------------------------------------------===// 443fe6060f1SDimitry Andric// Load & Store instructions. 444fe6060f1SDimitry Andric//===----------------------------------------------------------------------===// 445fe6060f1SDimitry Andric 446fe6060f1SDimitry Andricdef LD32B : I_LD<AddrMode32B, 0x0, "ld32.b", uimm12>; 447fe6060f1SDimitry Andricdef LD32H : I_LD<AddrMode32H, 0x1, "ld32.h", uimm12_1>; 448fe6060f1SDimitry Andricdef LD32W : I_LD<AddrMode32WD, 0x2, "ld32.w", uimm12_2>; 449fe6060f1SDimitry Andric 450*349cc55cSDimitry Andriclet OutOperandList = (outs GPRPair:$rz) in 451*349cc55cSDimitry Andricdef LD32D : I_LD<AddrMode32WD, 0x3, "ld32.d", uimm12_2>; 452fe6060f1SDimitry Andric 453*349cc55cSDimitry Andriclet Predicates = [iHasE2] in { 454fe6060f1SDimitry Andric def LD32BS : I_LD<AddrMode32B, 0x4, "ld32.bs", uimm12>; 455fe6060f1SDimitry Andric def LD32HS : I_LD<AddrMode32H, 0x5, "ld32.hs", uimm12_1>; 456fe6060f1SDimitry Andric 457*349cc55cSDimitry Andric def LDM32 : I_5_YX<0b110100, 0b000111, 458*349cc55cSDimitry Andric (outs), (ins GPR:$rx, regseq:$regs, variable_ops), "ldm32\t$regs, (${rx})", []>; 459*349cc55cSDimitry Andric def STM32 : I_5_YX<0b110101, 0b000111, 460*349cc55cSDimitry Andric (outs), (ins GPR:$rx, regseq:$regs, variable_ops), "stm32\t$regs, (${rx})", []>; 461fe6060f1SDimitry Andric 462*349cc55cSDimitry Andric let Size = 4, isCodeGenOnly = 0 in { 463*349cc55cSDimitry Andric def LDQ32 : CSKYPseudo<(outs), (ins GPR:$rx, regseq:$regs, variable_ops), 464*349cc55cSDimitry Andric "ldq32\t$regs, (${rx})", []>; 465*349cc55cSDimitry Andric def STQ32 : CSKYPseudo<(outs), (ins GPR:$rx, regseq:$regs, variable_ops), 466*349cc55cSDimitry Andric "stq32\t$regs, (${rx})", []>; 467*349cc55cSDimitry Andric } 468*349cc55cSDimitry Andric 469*349cc55cSDimitry Andric} 470fe6060f1SDimitry Andric 471fe6060f1SDimitry Andricdef ST32B : I_ST<AddrMode32B, 0x0, "st32.b", uimm12>; 472fe6060f1SDimitry Andricdef ST32H : I_ST<AddrMode32H, 0x1, "st32.h", uimm12_1>; 473fe6060f1SDimitry Andricdef ST32W : I_ST<AddrMode32WD, 0x2, "st32.w", uimm12_2>; 474fe6060f1SDimitry Andric 475*349cc55cSDimitry Andriclet InOperandList = (ins GPRPair:$rz, GPR:$rx, uimm12_2:$imm12 ) in 476*349cc55cSDimitry Andricdef ST32D : I_ST<AddrMode32WD, 0x3, "st32.d", uimm12_2>; 477fe6060f1SDimitry Andric 478*349cc55cSDimitry Andriclet Predicates = [iHas2E3] in { 479fe6060f1SDimitry Andric def LDR32B : I_LDR<0x0, "ldr32.b">; 480fe6060f1SDimitry Andric def LDR32BS : I_LDR<0x4, "ldr32.bs">; 481fe6060f1SDimitry Andric def LDR32H : I_LDR<0x1, "ldr32.h">; 482fe6060f1SDimitry Andric def LDR32HS : I_LDR<0x5, "ldr32.hs">; 483fe6060f1SDimitry Andric def LDR32W : I_LDR<0x2, "ldr32.w">; 484fe6060f1SDimitry Andric def STR32B : I_STR<0x0, "str32.b">; 485fe6060f1SDimitry Andric def STR32H : I_STR<0x1, "str32.h">; 486fe6060f1SDimitry Andric def STR32W : I_STR<0x2, "str32.w">; 487*349cc55cSDimitry Andric} 488fe6060f1SDimitry Andric 489*349cc55cSDimitry Andric// Indicate that we're dumping the CR register, so we'll need to 490*349cc55cSDimitry Andric// scavenge a register for it. 491*349cc55cSDimitry Andriclet mayStore = 1 in { 492*349cc55cSDimitry Andricdef SPILL_CARRY : CSKYPseudo<(outs), (ins CARRY:$cond, GPR:$rx, uimm12_2:$imm), 493*349cc55cSDimitry Andric "!SPILL_CARRY $cond, $rx, $imm", []>; 494*349cc55cSDimitry Andric} 495*349cc55cSDimitry Andric 496*349cc55cSDimitry Andric// Indicate that we're restoring the CR register (previously 497*349cc55cSDimitry Andric// spilled), so we'll need to scavenge a register for it. 498*349cc55cSDimitry Andriclet mayLoad = 1 in { 499*349cc55cSDimitry Andricdef RESTORE_CARRY : CSKYPseudo<(outs CARRY:$cond), (ins GPR:$rx, uimm12_2:$imm), 500*349cc55cSDimitry Andric "!RESTORE_CARRY $cond, $rx, $imm", []>; 501*349cc55cSDimitry Andric} 502*349cc55cSDimitry Andric 503*349cc55cSDimitry Andriclet mayLoad = 1 in { 504*349cc55cSDimitry Andricdef STORE_PAIR : CSKYPseudo<(outs), (ins GPRPair:$rz, GPR:$rx, uimm12_2:$imm), 505*349cc55cSDimitry Andric "!STORE_PAIR $rz, $rx, $imm", []>; 506*349cc55cSDimitry Andric} 507*349cc55cSDimitry Andric 508*349cc55cSDimitry Andriclet mayLoad = 1 in { 509*349cc55cSDimitry Andricdef LOAD_PAIR : CSKYPseudo<(outs GPRPair:$rz), (ins GPR:$rx, uimm12_2:$imm), 510*349cc55cSDimitry Andric "!LOAD_PAIR $rz, $rx, $imm", []>; 511*349cc55cSDimitry Andric} 512fe6060f1SDimitry Andric 513fe6060f1SDimitry Andric//===----------------------------------------------------------------------===// 514fe6060f1SDimitry Andric// Compare instructions. 515fe6060f1SDimitry Andric//===----------------------------------------------------------------------===// 516*349cc55cSDimitry Andriclet Predicates = [iHasE2] in { 517fe6060f1SDimitry Andric def CMPNEI32 : I_16_X<0x1A, "cmpnei32", uimm16>; 518fe6060f1SDimitry Andric def CMPHSI32 : I_16_X<0x18, "cmphsi32", oimm16>; 519fe6060f1SDimitry Andric def CMPLTI32 : I_16_X<0x19, "cmplti32", oimm16>; 520*349cc55cSDimitry Andric def CMPLEI32 : CSKYPseudo<(outs CARRY:$ca), (ins GPR:$rx, uimm16:$imm16), 521*349cc55cSDimitry Andric "cmplei32\t$rx, $imm16", []>; 522*349cc55cSDimitry Andric} 523*349cc55cSDimitry Andriclet Predicates = [iHas2E3] in { 524fe6060f1SDimitry Andric def CMPNE32 : R_YX<0x1, 0x4, "cmpne32">; 525fe6060f1SDimitry Andric def CMPHS32 : R_YX<0x1, 0x1, "cmphs32">; 526fe6060f1SDimitry Andric def CMPLT32 : R_YX<0x1, 0x2, "cmplt32">; 527fe6060f1SDimitry Andric 528*349cc55cSDimitry Andric def SETC32 : CSKY32Inst<AddrModeNone, 0x31, 529*349cc55cSDimitry Andric (outs CARRY:$ca), (ins), "setc32", []> { 530*349cc55cSDimitry Andric let Inst{25 - 21} = 0; //rx 531*349cc55cSDimitry Andric let Inst{20 - 16} = 0; //ry 532*349cc55cSDimitry Andric let Inst{15 - 10} = 0x1; 533*349cc55cSDimitry Andric let Inst{9 - 5} = 0x1; 534*349cc55cSDimitry Andric let Inst{4 - 0} = 0; 535*349cc55cSDimitry Andric let isCompare = 1; 536*349cc55cSDimitry Andric } 537*349cc55cSDimitry Andric def CLRC32 : CSKY32Inst<AddrModeNone, 0x31, 538*349cc55cSDimitry Andric (outs CARRY:$ca), (ins), "clrc32", []> { 539*349cc55cSDimitry Andric let Inst{25 - 21} = 0; //rx 540*349cc55cSDimitry Andric let Inst{20 - 16} = 0; //ry 541*349cc55cSDimitry Andric let Inst{15 - 10} = 0x1; 542*349cc55cSDimitry Andric let Inst{9 - 5} = 0x4; 543*349cc55cSDimitry Andric let Inst{4 - 0} = 0; 544*349cc55cSDimitry Andric let isCompare = 1; 545*349cc55cSDimitry Andric } 546*349cc55cSDimitry Andric 547*349cc55cSDimitry Andric def TST32 : R_YX<0x8, 0x4, "tst32">; 548*349cc55cSDimitry Andric def TSTNBZ32 : R_X<0x8, 0x8, 549*349cc55cSDimitry Andric (outs CARRY:$ca), (ins GPR:$rx), "tstnbz32", []>; 550*349cc55cSDimitry Andric} 551fe6060f1SDimitry Andric 552fe6060f1SDimitry Andric//===----------------------------------------------------------------------===// 553fe6060f1SDimitry Andric// Data move instructions. 554fe6060f1SDimitry Andric//===----------------------------------------------------------------------===// 555fe6060f1SDimitry Andric 556*349cc55cSDimitry Andriclet Predicates= [iHasE2] in { 557*349cc55cSDimitry Andric let isCodeGenOnly = 1 in { 558fe6060f1SDimitry Andric def MOVT32 : R_ZX<0x3, 0x2, "movt32", []>; 559fe6060f1SDimitry Andric def MOVF32 : R_ZX<0x3, 0x1, "movf32", []>; 560*349cc55cSDimitry Andric } 561fe6060f1SDimitry Andric def MOVI32 : I_16_MOV<0x10, "movi32", uimm16>; 562*349cc55cSDimitry Andric let Size = 4, isCodeGenOnly = 0 in 563*349cc55cSDimitry Andric def BGENI : CSKYPseudo<(outs GPR:$dst), (ins uimm5:$imm), "bgeni\t$dst, $imm", []>; 564*349cc55cSDimitry Andric def : InstAlias<"bgeni16 $dst, $imm", (BGENI GPR:$dst, uimm5:$imm)>; 565*349cc55cSDimitry Andric def : InstAlias<"bgeni32 $dst, $imm", (BGENI GPR:$dst, uimm5:$imm)>; 566fe6060f1SDimitry Andric def MOVIH32 : I_16_MOV<0x11, "movih32", uimm16_16_xform>; 567fe6060f1SDimitry Andric def MVC32 : R_Z_1<0x1, 0x8, "mvc32">; 568*349cc55cSDimitry Andric let isCodeGenOnly = 1 in 569fe6060f1SDimitry Andric def MOV32 : R_XZ<0x12, 0x1, "mov32">; 570fe6060f1SDimitry Andric 571*349cc55cSDimitry Andric let usesCustomInserter = 1 in 572*349cc55cSDimitry Andric def ISEL32 : CSKYPseudo<(outs GPR:$dst), (ins CARRY:$cond, GPR:$src1, GPR:$src2), 573*349cc55cSDimitry Andric "!isel32\t$dst, $src1, src2", [(set GPR:$dst, (select CARRY:$cond, GPR:$src1, GPR:$src2))]>; 574*349cc55cSDimitry Andric} 575fe6060f1SDimitry Andric 576*349cc55cSDimitry Andriclet Predicates = [iHas2E3] in { 577fe6060f1SDimitry Andric def MVCV32 : R_Z_1<0x1, 0x10, "mvcv32">; 578fe6060f1SDimitry Andric def CLRF32 : R_Z_2<0xB, 0x1, "clrf32", []>; 579fe6060f1SDimitry Andric def CLRT32 : R_Z_2<0xB, 0x2, "clrt32", []>; 580*349cc55cSDimitry Andric} 581fe6060f1SDimitry Andric 582fe6060f1SDimitry Andric//===----------------------------------------------------------------------===// 583fe6060f1SDimitry Andric// Branch and call instructions. 584fe6060f1SDimitry Andric//===----------------------------------------------------------------------===// 585fe6060f1SDimitry Andric 586fe6060f1SDimitry Andriclet isBranch = 1, isTerminator = 1 in { 587fe6060f1SDimitry Andric let isBarrier = 1, isPredicable = 1 in 588fe6060f1SDimitry Andric def BR32 : I_16_L<0x0, (outs), (ins br_symbol:$imm16), "br32\t$imm16", 589fe6060f1SDimitry Andric [(br bb:$imm16)]>; 590fe6060f1SDimitry Andric 591fe6060f1SDimitry Andric def BT32 : I_16_L<0x3, (outs), (ins CARRY:$ca, br_symbol:$imm16), 592*349cc55cSDimitry Andric "bt32\t$imm16", [(brcond CARRY:$ca, bb:$imm16)]>, Requires<[iHasE2]>; 593fe6060f1SDimitry Andric def BF32 : I_16_L<0x2, (outs), (ins CARRY:$ca, br_symbol:$imm16), 594*349cc55cSDimitry Andric "bf32\t$imm16", []>, Requires<[iHasE2]>; 595fe6060f1SDimitry Andric} 596fe6060f1SDimitry Andric 597*349cc55cSDimitry Andriclet Predicates = [iHas2E3] in { 598fe6060f1SDimitry Andric def BEZ32 : I_16_X_L<0x8, "bez32", br_symbol>; 599fe6060f1SDimitry Andric def BNEZ32 : I_16_X_L<0x9, "bnez32", br_symbol>; 600fe6060f1SDimitry Andric def BHZ32 : I_16_X_L<0xA, "bhz32", br_symbol>; 601fe6060f1SDimitry Andric def BLSZ32 : I_16_X_L<0xB, "blsz32", br_symbol>; 602fe6060f1SDimitry Andric def BLZ32 : I_16_X_L<0xC, "blz32", br_symbol>; 603fe6060f1SDimitry Andric def BHSZ32 : I_16_X_L<0xD, "bhsz32", br_symbol>; 604fe6060f1SDimitry Andric 605fe6060f1SDimitry Andric let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in { 606fe6060f1SDimitry Andric def JMP32 : I_16_JX<0x6, "jmp32", [(brind GPR:$rx)]>; // jmp to register 607fe6060f1SDimitry Andric def JMPI32 : I_16_L<0x16, (outs), (ins constpool_symbol:$imm16), 608fe6060f1SDimitry Andric "jmpi32\t$imm16", []>; 609fe6060f1SDimitry Andric } 610fe6060f1SDimitry Andric 611fe6060f1SDimitry Andric let isCall = 1, Defs = [ R15 ] in 612fe6060f1SDimitry Andric def JSR32 : I_16_JX<0x7, "jsr32", []>; 613fe6060f1SDimitry Andric 614fe6060f1SDimitry Andric let isCall = 1, Defs = [ R15 ] , mayLoad = 1 in 615fe6060f1SDimitry Andric def JSRI32: I_16_L<0x17, (outs), 616fe6060f1SDimitry Andric (ins constpool_symbol:$imm16), "jsri32\t$imm16", []>; 617*349cc55cSDimitry Andric} 618fe6060f1SDimitry Andric 619*349cc55cSDimitry Andricdef BNEZAD32 : CSKY32Inst<AddrModeNone, 0x3a, 620*349cc55cSDimitry Andric (outs GPR:$rx_u), (ins GPR:$rx, br_symbol:$imm16), "bnezad32\t$rx, $imm16", []> { 621*349cc55cSDimitry Andric bits<5> rx; 622*349cc55cSDimitry Andric bits<16> imm16; 623*349cc55cSDimitry Andric let Inst{25 - 21} = 0x1; 624*349cc55cSDimitry Andric let Inst{20 - 16} = rx; 625*349cc55cSDimitry Andric let Inst{15 - 0} = imm16; 626*349cc55cSDimitry Andric let isBranch = 1; 627*349cc55cSDimitry Andric let isTerminator = 1; 628*349cc55cSDimitry Andric let Constraints = "$rx_u = $rx"; 629*349cc55cSDimitry Andric let Predicates = [iHas2E3, iHas10E60]; 630*349cc55cSDimitry Andric} 631fe6060f1SDimitry Andric 632fe6060f1SDimitry Andricdef BSR32 : J<0x38, (outs), (ins call_symbol:$offset), "bsr32", []>; 633fe6060f1SDimitry Andric 634*349cc55cSDimitry Andricdef : InstAlias<"bsr $dst", (BSR32 call_symbol:$dst)>; 635*349cc55cSDimitry Andric 636fe6060f1SDimitry Andricdef BSR32_BR : J<0x38, (outs), (ins call_symbol:$offset), "bsr32", []>{ 637fe6060f1SDimitry Andric let isCodeGenOnly = 1; 638fe6060f1SDimitry Andric let isBranch = 1; 639fe6060f1SDimitry Andric let isTerminator = 1; 640fe6060f1SDimitry Andric let isBarrier = 1; 641fe6060f1SDimitry Andric let isPredicable = 1; 642fe6060f1SDimitry Andric let Defs = [ R15 ]; 643fe6060f1SDimitry Andric} 644fe6060f1SDimitry Andric 645*349cc55cSDimitry Andriclet Predicates = [iHasE2], isCodeGenOnly = 1 in { 646fe6060f1SDimitry Andric def RTS32 : I_16_RET<0x6, 0xF, "rts32", [(CSKY_RET)]>; 647*349cc55cSDimitry Andric} 648fe6060f1SDimitry Andric 649fe6060f1SDimitry Andric 650fe6060f1SDimitry Andric//===----------------------------------------------------------------------===// 651fe6060f1SDimitry Andric// Symbol address instructions. 652fe6060f1SDimitry Andric//===----------------------------------------------------------------------===// 653fe6060f1SDimitry Andric 654*349cc55cSDimitry Andricdef data_symbol_b : data_symbol<"CSKY::fixup_csky_doffset_imm18", 0>; 655*349cc55cSDimitry Andricdef data_symbol_h : data_symbol<"CSKY::fixup_csky_doffset_imm18_scale2", 1>; 656*349cc55cSDimitry Andricdef data_symbol_w : data_symbol<"CSKY::fixup_csky_doffset_imm18_scale4", 2> { 657*349cc55cSDimitry Andric let ParserMatchClass = DataAsmClass; 658*349cc55cSDimitry Andric} 659*349cc55cSDimitry Andric 660*349cc55cSDimitry Andriclet Predicates = [iHas2E3] in { 661*349cc55cSDimitry Andric 662fe6060f1SDimitry Andricdef GRS32 : I_18_Z_L<0x3, "grs32\t$rz, $offset", 663fe6060f1SDimitry Andric (outs GPR:$rz), (ins bare_symbol:$offset), []>; 664*349cc55cSDimitry Andricdef : InstAlias<"grs\t$rz, $offset", (GRS32 GPR:$rz, bare_symbol:$offset)>; 665*349cc55cSDimitry Andric 666*349cc55cSDimitry Andriclet Uses = [R28] in { 667*349cc55cSDimitry Andricdef LRS32B : I_18_Z_L<0x0, "lrs32.b\t$rz, $offset", 668*349cc55cSDimitry Andric (outs GPR:$rz), (ins data_symbol_b:$offset), []>; 669*349cc55cSDimitry Andricdef LRS32H : I_18_Z_L<0x1, "lrs32.h\t$rz, $offset", 670*349cc55cSDimitry Andric (outs GPR:$rz), (ins data_symbol_h:$offset), []>; 671*349cc55cSDimitry Andricdef LRS32W : I_18_Z_L<0x2, "lrs32.w\t$rz, $offset", 672*349cc55cSDimitry Andric (outs GPR:$rz), (ins data_symbol_w:$offset), []>; 673*349cc55cSDimitry Andricdef SRS32B : I_18_Z_L<0x4, "srs32.b\t$rz, $offset", 674*349cc55cSDimitry Andric (outs), (ins GPR:$rz, data_symbol_b:$offset), []>; 675*349cc55cSDimitry Andricdef SRS32H : I_18_Z_L<0x5, "srs32.h\t$rz, $offset", 676*349cc55cSDimitry Andric (outs), (ins GPR:$rz, data_symbol_h:$offset), []>; 677*349cc55cSDimitry Andricdef SRS32W : I_18_Z_L<0x6, "srs32.w\t$rz, $offset", 678*349cc55cSDimitry Andric (outs), (ins GPR:$rz, data_symbol_w:$offset), []>; 679*349cc55cSDimitry Andric} 680*349cc55cSDimitry Andric 681*349cc55cSDimitry Andricdef PUSH32 : I_12_PP<0b11111, 0b00000, (outs), (ins reglist:$regs, variable_ops), "push32 $regs">; 682*349cc55cSDimitry Andric 683*349cc55cSDimitry Andriclet Uses = [R14, R15], isReturn = 1, isTerminator = 1, isBarrier = 1 in 684*349cc55cSDimitry Andricdef POP32 : I_12_PP<0b11110, 0b00000, (outs), (ins reglist:$regs, variable_ops), "pop32 $regs">; 685*349cc55cSDimitry Andric 686*349cc55cSDimitry Andric} 687fe6060f1SDimitry Andric 688fe6060f1SDimitry Andriclet mayLoad = 1, mayStore = 0 in { 689fe6060f1SDimitry Andricdef LRW32 : I_16_Z_L<0x14, "lrw32", (ins constpool_symbol:$imm16), []>; 690fe6060f1SDimitry Andriclet isCodeGenOnly = 1 in 691*349cc55cSDimitry Andricdef LRW32_Gen : I_16_Z_L<0x14, "lrw32", (ins bare_symbol:$src1, constpool_symbol:$imm16), []>; 692fe6060f1SDimitry Andric} 693fe6060f1SDimitry Andric 694*349cc55cSDimitry Andric//===----------------------------------------------------------------------===// 695*349cc55cSDimitry Andric// Atomic and fence instructions. 696*349cc55cSDimitry Andric//===----------------------------------------------------------------------===// 697*349cc55cSDimitry Andric 698*349cc55cSDimitry Andriclet Predicates = [iHasMP1E2] in { 699*349cc55cSDimitry Andric def BRWARW : BAR<0b01111, "bar.brwarw", 0>; 700*349cc55cSDimitry Andric def BRWARWS : BAR<0b01111, "bar.brwarws", 1>; 701*349cc55cSDimitry Andric def BRARW : BAR<0b00111, "bar.brarw", 0>; 702*349cc55cSDimitry Andric def BRARWS : BAR<0b00111, "bar.brarws", 1>; 703*349cc55cSDimitry Andric def BRWAW : BAR<0b01110, "bar.brwaw", 0>; 704*349cc55cSDimitry Andric def BRWAWS : BAR<0b01110, "bar.brwaws", 1>; 705*349cc55cSDimitry Andric def BRAR : BAR<0b00101, "bar.brar", 0>; 706*349cc55cSDimitry Andric def BRARS : BAR<0b00101, "bar.brars", 1>; 707*349cc55cSDimitry Andric def BWAW : BAR<0b01010, "bar.bwaw", 0>; 708*349cc55cSDimitry Andric def BWAWS : BAR<0b01010, "bar.bwaws", 1>; 709*349cc55cSDimitry Andric 710*349cc55cSDimitry Andric def LDEX32W : I_LD<AddrMode32WD, 0x7, "ldex32.w", uimm12_2>; 711*349cc55cSDimitry Andric let Constraints = "$rd = $rz" in 712*349cc55cSDimitry Andric def STEX32W : I_LDST<AddrMode32WD, 0x37, 7, 713*349cc55cSDimitry Andric (outs GPR:$rd), (ins GPR:$rz, GPR:$rx, uimm12_2:$imm12), "stex32.w", []>; 714*349cc55cSDimitry Andric} 715*349cc55cSDimitry Andric 716*349cc55cSDimitry Andric//===----------------------------------------------------------------------===// 717*349cc55cSDimitry Andric// Other operation instructions. 718*349cc55cSDimitry Andric//===----------------------------------------------------------------------===// 719*349cc55cSDimitry Andric 720*349cc55cSDimitry Andriclet Predicates = [iHas2E3] in { 721*349cc55cSDimitry Andric def BREV32 : R_XZ<0x18, 0x10, "brev32">; 722*349cc55cSDimitry Andric def ABS32 : R_XZ<0x0, 0x10, "abs32">; 723*349cc55cSDimitry Andric def BGENR32 : R_XZ<0x14, 0x2, "bgenr32">; 724*349cc55cSDimitry Andric} 725*349cc55cSDimitry Andric 726*349cc55cSDimitry Andriclet Predicates = [iHasE2] in { 727*349cc55cSDimitry Andric def REVB32 : R_XZ<0x18, 0x4, "revb32">; 728*349cc55cSDimitry Andric def REVH32 : R_XZ<0x18, 0x8, "revh32">; 729*349cc55cSDimitry Andric def FF0 : R_XZ<0x1F, 0x1, "ff0.32">; 730*349cc55cSDimitry Andric def FF1 : R_XZ<0x1F, 0x2, "ff1.32">; 731*349cc55cSDimitry Andric def XTRB0 : R_XZ<0x1C, 0x1, "xtrb0.32">; 732*349cc55cSDimitry Andric def XTRB1 : R_XZ<0x1C, 0x2, "xtrb1.32">; 733*349cc55cSDimitry Andric def XTRB2 : R_XZ<0x1C, 0x4, "xtrb2.32">; 734*349cc55cSDimitry Andric def XTRB3 : R_XZ<0x1C, 0x8, "xtrb3.32">; 735*349cc55cSDimitry Andric def BTSTI32 : I_5_X<0x0A, 0x4, "btsti32", uimm5, []>; 736*349cc55cSDimitry Andric def BCLRI32 : I_5_XZ<0xA, 0x1, "bclri32", 737*349cc55cSDimitry Andric (outs GPR:$rz), (ins GPR:$rx, uimm5:$imm5), []>; 738*349cc55cSDimitry Andric def BSETI32 : I_5_XZ<0xA, 0x2, "bseti32", 739*349cc55cSDimitry Andric (outs GPR:$rz), (ins GPR:$rx, uimm5:$imm5), []>; 740*349cc55cSDimitry Andric} 741*349cc55cSDimitry Andric 742*349cc55cSDimitry Andric//===----------------------------------------------------------------------===// 743*349cc55cSDimitry Andric// Special instructions. 744*349cc55cSDimitry Andric//===----------------------------------------------------------------------===// 745*349cc55cSDimitry Andric 746*349cc55cSDimitry Andricdef MFFCR : CSKY32Inst<AddrModeNone, 0x30, 747*349cc55cSDimitry Andric (outs GPR:$rx), (ins), "mfcr\t$rx, fcr", []> { 748*349cc55cSDimitry Andric bits<5> rx; 749*349cc55cSDimitry Andric 750*349cc55cSDimitry Andric let Inst{25 - 21} = 0b00010; 751*349cc55cSDimitry Andric let Inst{20 - 16} = 0b00001; 752*349cc55cSDimitry Andric let Inst{15 - 10} = 0b011000; 753*349cc55cSDimitry Andric let Inst{9 - 5} = 0b00001; 754*349cc55cSDimitry Andric let Inst{4 - 0} = rx; 755*349cc55cSDimitry Andric let hasSideEffects = 1; 756*349cc55cSDimitry Andric let isCodeGenOnly = 1; 757*349cc55cSDimitry Andric} 758*349cc55cSDimitry Andric 759*349cc55cSDimitry Andricdef MTFCR : CSKY32Inst<AddrModeNone, 0x30, 760*349cc55cSDimitry Andric (outs), (ins GPR:$rx), "mtcr\t$rx, fcr", []> { 761*349cc55cSDimitry Andric bits<5> rx; 762*349cc55cSDimitry Andric 763*349cc55cSDimitry Andric let Inst{25 - 21} = 0b00010; 764*349cc55cSDimitry Andric let Inst{20 - 16} = rx; 765*349cc55cSDimitry Andric let Inst{15 - 10} = 0b011001; 766*349cc55cSDimitry Andric let Inst{9 - 5} = 0b00001; 767*349cc55cSDimitry Andric let Inst{4 - 0} = 0b00001; 768*349cc55cSDimitry Andric let hasSideEffects = 1; 769*349cc55cSDimitry Andric let isCodeGenOnly = 1; 770*349cc55cSDimitry Andric} 771*349cc55cSDimitry Andric 772*349cc55cSDimitry Andricdef SYNC32 : I_5_IMM5<0x30, 0b000001, 0b00001, "sync32", uimm5, []>; 773*349cc55cSDimitry Andric 774*349cc55cSDimitry Andricdef SYNC0_32 : CSKY32Inst<AddrModeNone, 0x30, (outs), (ins), 775*349cc55cSDimitry Andric "sync32", []> { 776*349cc55cSDimitry Andric let Inst{25 - 21} = 0; 777*349cc55cSDimitry Andric let Inst{20 - 16} = 0; 778*349cc55cSDimitry Andric let Inst{15 - 10} = 0b000001; 779*349cc55cSDimitry Andric let Inst{9 - 5} = 0b00001; 780*349cc55cSDimitry Andric let Inst{4 - 0} = 0; 781*349cc55cSDimitry Andric} 782*349cc55cSDimitry Andric 783*349cc55cSDimitry Andricdef SYNC_32_I : CSKY32Inst<AddrModeNone, 0x30, (outs), (ins), 784*349cc55cSDimitry Andric "sync32.i", []> { 785*349cc55cSDimitry Andric let Inst{25 - 21} = 1; 786*349cc55cSDimitry Andric let Inst{20 - 16} = 0; 787*349cc55cSDimitry Andric let Inst{15 - 10} = 0b000001; 788*349cc55cSDimitry Andric let Inst{9 - 5} = 0b00001; 789*349cc55cSDimitry Andric let Inst{4 - 0} = 0; 790*349cc55cSDimitry Andric} 791*349cc55cSDimitry Andric 792*349cc55cSDimitry Andricdef SYNC_32_S : CSKY32Inst<AddrModeNone, 0x30, (outs), (ins), 793*349cc55cSDimitry Andric "sync32.s", []> { 794*349cc55cSDimitry Andric let Inst{25 - 21} = 0b10000; 795*349cc55cSDimitry Andric let Inst{20 - 16} = 0; 796*349cc55cSDimitry Andric let Inst{15 - 10} = 0b000001; 797*349cc55cSDimitry Andric let Inst{9 - 5} = 0b00001; 798*349cc55cSDimitry Andric let Inst{4 - 0} = 0; 799*349cc55cSDimitry Andric} 800*349cc55cSDimitry Andric 801*349cc55cSDimitry Andricdef SYNC_32_IS : CSKY32Inst<AddrModeNone, 0x30, (outs), (ins), 802*349cc55cSDimitry Andric "sync32.is", []> { 803*349cc55cSDimitry Andric let Inst{25 - 21} = 0b10001; 804*349cc55cSDimitry Andric let Inst{20 - 16} = 0; 805*349cc55cSDimitry Andric let Inst{15 - 10} = 0b000001; 806*349cc55cSDimitry Andric let Inst{9 - 5} = 0b00001; 807*349cc55cSDimitry Andric let Inst{4 - 0} = 0; 808*349cc55cSDimitry Andric} 809*349cc55cSDimitry Andric 810*349cc55cSDimitry Andriclet Predicates = [iHas2E3] in { 811*349cc55cSDimitry Andric def RFI32 : I_5_XZ_PRIVI<0x11, 0x1, "rfi32">; 812*349cc55cSDimitry Andric def SCE32 : I_5_IMM5<0x30, 0b000110, 0b00001, "sce32", uimm4, []>; 813*349cc55cSDimitry Andric} 814*349cc55cSDimitry Andriclet Predicates = [HasExtendLrw] in 815*349cc55cSDimitry Andricdef IDLY32 : I_5_IMM5<0x30, 0b000111, 0b00001, "idly32", imm5_idly, []>; 816*349cc55cSDimitry Andricdef STOP32 : I_5_XZ_PRIVI<0x12, 0x1, "stop32">; 817*349cc55cSDimitry Andricdef WAIT32 : I_5_XZ_PRIVI<0x13, 0x1, "wait32">; 818*349cc55cSDimitry Andricdef DOZE32 : I_5_XZ_PRIVI<0x14, 0x1, "doze32">; 819*349cc55cSDimitry Andricdef WE32 : I_5_XZ_PRIVI<0b010101, 0x1, "we32">; 820*349cc55cSDimitry Andricdef SE32 : I_5_XZ_PRIVI<0b010110, 0x1, "se32">; 821*349cc55cSDimitry Andricdef WSC32 : I_5_XZ_PRIVI<0b001111, 0x1, "wsc32">; 822*349cc55cSDimitry Andric 823*349cc55cSDimitry Andricdef CPOP32 : I_CPOP<(outs), (ins uimm5:$cpid, uimm20:$usdef), "cpop32 <$cpid, ${usdef}>">; 824*349cc55cSDimitry Andricdef CPRC32 : I_CP<0b0100, (outs CARRY:$ca), (ins uimm5:$cpid, uimm12:$usdef), "cprc32 <$cpid, ${usdef}>">; 825*349cc55cSDimitry Andricdef CPRCR32 : I_CP_Z<0b0010, (outs GPR:$rz), (ins uimm5:$cpid, uimm12:$usdef), "cprcr32 $rz, <$cpid, ${usdef}>">; 826*349cc55cSDimitry Andricdef CPRGR32 : I_CP_Z<0b0000, (outs GPR:$rz), (ins uimm5:$cpid, uimm12:$usdef), "cprgr32 $rz, <$cpid, ${usdef}>">; 827*349cc55cSDimitry Andricdef CPWCR32 : I_CP_Z<0b0011, (outs), (ins GPR:$rz, uimm5:$cpid, uimm12:$usdef), "cpwcr32 $rz, <$cpid, ${usdef}>">; 828*349cc55cSDimitry Andricdef CPWGR32 : I_CP_Z<0b0001, (outs), (ins GPR:$rz, uimm5:$cpid, uimm12:$usdef), "cpwgr32 $rz, <$cpid, ${usdef}>">; 829*349cc55cSDimitry Andric 830*349cc55cSDimitry Andriclet Predicates = [iHas3r2E3r3] in { 831*349cc55cSDimitry Andricdef DCACHE_IALL32 : I_5_CACHE<0b100101, 0b01000, "dcache32.iall">; 832*349cc55cSDimitry Andricdef DCACHE_CALL32 : I_5_CACHE<0b100101, 0b00100, "dcache32.call">; 833*349cc55cSDimitry Andricdef DCACHE_CIALL32 : I_5_CACHE<0b100101, 0b01100, "dcache32.ciall">; 834*349cc55cSDimitry Andricdef DCACHE_IVA32 : I_5_X_CACHE<0b100101, 0b01011, "dcache32.iva">; 835*349cc55cSDimitry Andricdef DCACHE_ISW32: I_5_X_CACHE<0b100101, 0b01010, "dcache32.isw">; 836*349cc55cSDimitry Andricdef DCACHE_CVA32 : I_5_X_CACHE<0b100101, 0b00111, "dcache32.cva">; 837*349cc55cSDimitry Andricdef DCACHE_CVAL32 : I_5_X_CACHE<0b100101, 0b10111, "dcache32.cval1">; 838*349cc55cSDimitry Andricdef DCACHE_CSW32 : I_5_X_CACHE<0b100101, 0b00110, "dcache32.csw">; 839*349cc55cSDimitry Andricdef DCACHE_CIVA32 : I_5_X_CACHE<0b100101, 0b01111, "dcache32.civa">; 840*349cc55cSDimitry Andricdef DCACHE_CISW32 : I_5_X_CACHE<0b100101, 0b01110, "dcache32.cisw">; 841*349cc55cSDimitry Andric 842*349cc55cSDimitry Andricdef ICACHE_IALL32 : I_5_CACHE<0b100100, 0b01000, "icache32.iall">; 843*349cc55cSDimitry Andricdef ICACHE_IALLS32 : I_5_CACHE<0b100100, 0b11000, "icache32.ialls">; 844*349cc55cSDimitry Andricdef ICACHE_IVA32 : I_5_X_CACHE<0b100100, 0b01011, "icache32.iva">; 845*349cc55cSDimitry Andric 846*349cc55cSDimitry Andricdef TLBI_VAA32 : I_5_X_CACHE<0b100010, 0b00010, "tlbi32.vaa">; 847*349cc55cSDimitry Andricdef TLBI_VAAS32 : I_5_X_CACHE<0b100010, 0b10010, "tlbi32.vaas">; 848*349cc55cSDimitry Andricdef TLBI_ASID32 : I_5_X_CACHE<0b100010, 0b00001, "tlbi32.asid">; 849*349cc55cSDimitry Andricdef TLBI_ASIDS32 : I_5_X_CACHE<0b100010, 0b10001, "tlbi32.asids">; 850*349cc55cSDimitry Andricdef TLBI_VA32 : I_5_X_CACHE<0b100010, 0b00011, "tlbi32.va">; 851*349cc55cSDimitry Andricdef TLBI_VAS32 : I_5_X_CACHE<0b100010, 0b10011, "tlbi32.vas">; 852*349cc55cSDimitry Andricdef TLBI_ALL32 : I_5_CACHE<0b100010, 0b00000, "tlbi32.all">; 853*349cc55cSDimitry Andricdef TLBI_ALLS32 : I_5_CACHE<0b100010, 0b10000, "tlbi32.alls">; 854*349cc55cSDimitry Andric 855*349cc55cSDimitry Andricdef L2CACHE_IALL : I_5_CACHE<0b100110, 0b01000, "l2cache.iall">; 856*349cc55cSDimitry Andricdef L2CACHE_CALL : I_5_CACHE<0b100110, 0b00100, "l2cache.call">; 857*349cc55cSDimitry Andricdef L2CACHE_CIALL : I_5_CACHE<0b100110, 0b01100, "l2cache.ciall">; 858*349cc55cSDimitry Andric} 859*349cc55cSDimitry Andric 860*349cc55cSDimitry Andricdef PLDR32 :I_PLDR<AddrMode32WD, 0x36, 0b0110, (outs), (ins GPR:$rx, uimm12_2:$imm12), "pldr32", []>; 861*349cc55cSDimitry Andricdef PLDW32 :I_PLDR<AddrMode32WD, 0x37, 0b0110, (outs), (ins GPR:$rx, uimm12_2:$imm12), "pldw32", []>; 862*349cc55cSDimitry Andric 863*349cc55cSDimitry Andricdef TRAP32 : CSKY32Inst<AddrModeNone, 0x30, (outs), (ins uimm2:$imm2), "trap32 ${imm2}", []> { 864*349cc55cSDimitry Andric bits<2> imm2; 865*349cc55cSDimitry Andric 866*349cc55cSDimitry Andric let Inst{25 - 21} = 0; 867*349cc55cSDimitry Andric let Inst{20 - 16} = 0; 868*349cc55cSDimitry Andric let Inst{15 - 12} = 0b0010; 869*349cc55cSDimitry Andric let Inst{11 - 10} = imm2; 870*349cc55cSDimitry Andric let Inst{9 - 5} = 0b00001; 871*349cc55cSDimitry Andric let Inst{4 - 0} = 0; 872*349cc55cSDimitry Andric 873*349cc55cSDimitry Andric} 874*349cc55cSDimitry Andric 875*349cc55cSDimitry Andric 876*349cc55cSDimitry Andric//===----------------------------------------------------------------------===// 877*349cc55cSDimitry Andric// Pseudo for assembly 878*349cc55cSDimitry Andric//===----------------------------------------------------------------------===// 879*349cc55cSDimitry Andric 880*349cc55cSDimitry Andriclet isCall = 1, Defs = [ R15 ], mayLoad = 1, Size = 4, isCodeGenOnly = 0 in 881*349cc55cSDimitry Andricdef JBSR32 : CSKYPseudo<(outs), (ins call_symbol:$src1), "jbsr32\t$src1", []>; 882*349cc55cSDimitry Andric 883*349cc55cSDimitry Andricdef : InstAlias<"jbsr\t$src1", (JBSR32 call_symbol:$src1)>; 884*349cc55cSDimitry Andric 885*349cc55cSDimitry Andricdef JBR32 : CSKYPseudo<(outs), (ins br_symbol:$src1), "jbr32\t$src1", []> { 886*349cc55cSDimitry Andric let isBranch = 1; 887*349cc55cSDimitry Andric let isTerminator = 1; 888*349cc55cSDimitry Andric let isBarrier = 1; 889*349cc55cSDimitry Andric let isIndirectBranch = 1; 890*349cc55cSDimitry Andric let mayLoad = 1; 891*349cc55cSDimitry Andric let Size = 4; 892*349cc55cSDimitry Andric} 893*349cc55cSDimitry Andric 894*349cc55cSDimitry Andricdef JBT32 : CSKYPseudo<(outs), (ins CARRY:$ca, br_symbol:$src1), "jbt32\t$src1", []> { 895*349cc55cSDimitry Andric let isBranch = 1; 896*349cc55cSDimitry Andric let isTerminator = 1; 897*349cc55cSDimitry Andric let isIndirectBranch = 1; 898*349cc55cSDimitry Andric let mayLoad = 1; 899*349cc55cSDimitry Andric let Size = 4; 900*349cc55cSDimitry Andric} 901*349cc55cSDimitry Andric 902*349cc55cSDimitry Andricdef JBF32 : CSKYPseudo<(outs), (ins CARRY:$ca, br_symbol:$src1), "jbf32\t$src1", []> { 903*349cc55cSDimitry Andric let isBranch = 1; 904*349cc55cSDimitry Andric let isTerminator = 1; 905*349cc55cSDimitry Andric let isIndirectBranch = 1; 906*349cc55cSDimitry Andric let mayLoad = 1; 907*349cc55cSDimitry Andric let Size = 4; 908*349cc55cSDimitry Andric} 909*349cc55cSDimitry Andric 910*349cc55cSDimitry Andricdef JBT_E : CSKYPseudo<(outs), (ins CARRY:$ca, br_symbol:$src1), "!jbt_e\t$src1", []> { 911*349cc55cSDimitry Andric let isBranch = 1; 912*349cc55cSDimitry Andric let isTerminator = 1; 913*349cc55cSDimitry Andric let isIndirectBranch = 1; 914*349cc55cSDimitry Andric let mayLoad = 1; 915*349cc55cSDimitry Andric let Size = 6; 916*349cc55cSDimitry Andric} 917*349cc55cSDimitry Andric 918*349cc55cSDimitry Andricdef JBF_E : CSKYPseudo<(outs), (ins CARRY:$ca, br_symbol:$src1), "!jbf_e\t$src1", []> { 919*349cc55cSDimitry Andric let isBranch = 1; 920*349cc55cSDimitry Andric let isTerminator = 1; 921*349cc55cSDimitry Andric let isIndirectBranch = 1; 922*349cc55cSDimitry Andric let mayLoad = 1; 923*349cc55cSDimitry Andric let Size = 6; 924*349cc55cSDimitry Andric} 925*349cc55cSDimitry Andric 926*349cc55cSDimitry Andriclet mayLoad = 1, Size = 2, isCodeGenOnly = 0 in 927*349cc55cSDimitry Andricdef PseudoLRW32 : CSKYPseudo<(outs GPR:$rz), (ins bare_symbol:$src), "lrw32 $rz, $src", []>; 928*349cc55cSDimitry Andric 929*349cc55cSDimitry Andric 930*349cc55cSDimitry Andricdef : InstAlias<"lrw $rz, $src", (PseudoLRW32 GPR:$rz, bare_symbol:$src)>; 931*349cc55cSDimitry Andricdef : InstAlias<"lrw $rz, $src", (LRW32 GPR:$rz, constpool_symbol:$src)>; 932*349cc55cSDimitry Andric 933*349cc55cSDimitry Andriclet mayLoad = 1, Size = 4, isCodeGenOnly = 0 in 934*349cc55cSDimitry Andricdef PseudoJSRI32 : CSKYPseudo<(outs), (ins call_symbol:$src), "jsri32 $src", []>; 935*349cc55cSDimitry Andricdef : InstAlias<"jsri $dst", (PseudoJSRI32 call_symbol:$dst)>; 936*349cc55cSDimitry Andricdef : InstAlias<"jsri $dst", (JSRI32 constpool_symbol:$dst)>; 937*349cc55cSDimitry Andric 938*349cc55cSDimitry Andriclet mayLoad = 1, Size = 4, isCodeGenOnly = 0 in 939*349cc55cSDimitry Andricdef PseudoJMPI32 : CSKYPseudo<(outs), (ins br_symbol:$src), "jmpi32 $src", []>; 940*349cc55cSDimitry Andricdef : InstAlias<"jmpi $dst", (PseudoJMPI32 br_symbol:$dst)>; 941*349cc55cSDimitry Andricdef : InstAlias<"jmpi $dst", (JMPI32 constpool_symbol:$dst)>; 942*349cc55cSDimitry Andric 943*349cc55cSDimitry Andriclet isNotDuplicable = 1, mayLoad = 1, mayStore = 0, Size = 8 in 944*349cc55cSDimitry Andricdef PseudoTLSLA32 : CSKYPseudo<(outs GPR:$dst1, GPR:$dst2), 945*349cc55cSDimitry Andric (ins constpool_symbol:$src, i32imm:$label), "!tlslrw32\t$dst1, $dst2, $src, $label", []>; 946*349cc55cSDimitry Andric 947*349cc55cSDimitry Andriclet hasSideEffects = 0, isNotDuplicable = 1 in 948*349cc55cSDimitry Andricdef CONSTPOOL_ENTRY : CSKYPseudo<(outs), 949*349cc55cSDimitry Andric (ins i32imm:$instid, i32imm:$cpidx, i32imm:$size), "", []>; 950*349cc55cSDimitry Andric 951*349cc55cSDimitry Andricinclude "CSKYInstrInfo16Instr.td" 952