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