1 //===-- XCoreInstrInfo.td - Target Description for XCore ---*- tablegen -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file describes the XCore instructions in TableGen format.
12 //===----------------------------------------------------------------------===//
14 // Uses of CP, DP are not currently reflected in the patterns, since
15 // having a physical register as an operand prevents loop hoisting and
16 // since the value of these registers never changes during the life of the
19 //===----------------------------------------------------------------------===//
20 // Instruction format superclass.
21 //===----------------------------------------------------------------------===//
23 include "XCoreInstrFormats.td"
25 //===----------------------------------------------------------------------===//
26 // XCore specific DAG Nodes.
30 def SDT_XCoreBranchLink : SDTypeProfile<0, 1, [SDTCisPtrTy<0>]>;
31 def XCoreBranchLink : SDNode<"XCoreISD::BL",SDT_XCoreBranchLink,
32 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
35 def XCoreRetsp : SDNode<"XCoreISD::RETSP", SDTBrind,
36 [SDNPHasChain, SDNPOptInGlue, SDNPMayLoad, SDNPVariadic]>;
38 def SDT_XCoreBR_JT : SDTypeProfile<0, 2,
39 [SDTCisVT<0, i32>, SDTCisVT<1, i32>]>;
41 def XCoreBR_JT : SDNode<"XCoreISD::BR_JT", SDT_XCoreBR_JT,
44 def XCoreBR_JT32 : SDNode<"XCoreISD::BR_JT32", SDT_XCoreBR_JT,
47 def SDT_XCoreAddress : SDTypeProfile<1, 1,
48 [SDTCisSameAs<0, 1>, SDTCisPtrTy<0>]>;
50 def pcrelwrapper : SDNode<"XCoreISD::PCRelativeWrapper", SDT_XCoreAddress,
53 def dprelwrapper : SDNode<"XCoreISD::DPRelativeWrapper", SDT_XCoreAddress,
56 def cprelwrapper : SDNode<"XCoreISD::CPRelativeWrapper", SDT_XCoreAddress,
59 def SDT_XCoreStwsp : SDTypeProfile<0, 2, [SDTCisInt<1>]>;
60 def XCoreStwsp : SDNode<"XCoreISD::STWSP", SDT_XCoreStwsp,
61 [SDNPHasChain, SDNPMayStore]>;
63 // These are target-independent nodes, but have target-specific formats.
64 def SDT_XCoreCallSeqStart : SDCallSeqStart<[ SDTCisVT<0, i32> ]>;
65 def SDT_XCoreCallSeqEnd : SDCallSeqEnd<[ SDTCisVT<0, i32>,
68 def callseq_start : SDNode<"ISD::CALLSEQ_START", SDT_XCoreCallSeqStart,
69 [SDNPHasChain, SDNPOutGlue]>;
70 def callseq_end : SDNode<"ISD::CALLSEQ_END", SDT_XCoreCallSeqEnd,
71 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue]>;
73 //===----------------------------------------------------------------------===//
74 // Instruction Pattern Stuff
75 //===----------------------------------------------------------------------===//
77 def div4_xform : SDNodeXForm<imm, [{
78 // Transformation function: imm/4
79 assert(N->getZExtValue() % 4 == 0);
80 return getI32Imm(N->getZExtValue()/4);
83 def msksize_xform : SDNodeXForm<imm, [{
84 // Transformation function: get the size of a mask
85 assert(isMask_32(N->getZExtValue()));
86 // look for the first non-zero bit
87 return getI32Imm(32 - CountLeadingZeros_32(N->getZExtValue()));
90 def neg_xform : SDNodeXForm<imm, [{
91 // Transformation function: -imm
92 uint32_t value = N->getZExtValue();
93 return getI32Imm(-value);
96 def bpwsub_xform : SDNodeXForm<imm, [{
97 // Transformation function: 32-imm
98 uint32_t value = N->getZExtValue();
99 return getI32Imm(32-value);
102 def div4neg_xform : SDNodeXForm<imm, [{
103 // Transformation function: -imm/4
104 uint32_t value = N->getZExtValue();
105 assert(-value % 4 == 0);
106 return getI32Imm(-value/4);
109 def immUs4Neg : PatLeaf<(imm), [{
110 uint32_t value = (uint32_t)N->getZExtValue();
111 return (-value)%4 == 0 && (-value)/4 <= 11;
114 def immUs4 : PatLeaf<(imm), [{
115 uint32_t value = (uint32_t)N->getZExtValue();
116 return value%4 == 0 && value/4 <= 11;
119 def immUsNeg : PatLeaf<(imm), [{
120 return -((uint32_t)N->getZExtValue()) <= 11;
123 def immUs : PatLeaf<(imm), [{
124 return (uint32_t)N->getZExtValue() <= 11;
127 def immU6 : PatLeaf<(imm), [{
128 return (uint32_t)N->getZExtValue() < (1 << 6);
131 def immU10 : PatLeaf<(imm), [{
132 return (uint32_t)N->getZExtValue() < (1 << 10);
135 def immU16 : PatLeaf<(imm), [{
136 return (uint32_t)N->getZExtValue() < (1 << 16);
139 def immU20 : PatLeaf<(imm), [{
140 return (uint32_t)N->getZExtValue() < (1 << 20);
143 def immMskBitp : PatLeaf<(imm), [{ return immMskBitp(N); }]>;
145 def immBitp : PatLeaf<(imm), [{
146 uint32_t value = (uint32_t)N->getZExtValue();
147 return (value >= 1 && value <= 8)
153 def immBpwSubBitp : PatLeaf<(imm), [{
154 uint32_t value = (uint32_t)N->getZExtValue();
155 return (value >= 24 && value <= 31)
161 def lda16f : PatFrag<(ops node:$addr, node:$offset),
162 (add node:$addr, (shl node:$offset, 1))>;
163 def lda16b : PatFrag<(ops node:$addr, node:$offset),
164 (sub node:$addr, (shl node:$offset, 1))>;
165 def ldawf : PatFrag<(ops node:$addr, node:$offset),
166 (add node:$addr, (shl node:$offset, 2))>;
167 def ldawb : PatFrag<(ops node:$addr, node:$offset),
168 (sub node:$addr, (shl node:$offset, 2))>;
170 // Instruction operand types
171 def calltarget : Operand<i32>;
172 def brtarget : Operand<OtherVT>;
173 def pclabel : Operand<i32>;
176 def ADDRspii : ComplexPattern<i32, 2, "SelectADDRspii", [add, frameindex], []>;
179 def MEMii : Operand<i32> {
180 let MIOperandInfo = (ops i32imm, i32imm);
184 def InlineJT : Operand<i32> {
185 let PrintMethod = "printInlineJT";
188 def InlineJT32 : Operand<i32> {
189 let PrintMethod = "printInlineJT32";
192 //===----------------------------------------------------------------------===//
193 // Instruction Class Templates
194 //===----------------------------------------------------------------------===//
196 // Three operand short
198 multiclass F3R_2RUS<bits<5> opc1, bits<5> opc2, string OpcStr, SDNode OpNode> {
199 def _3r: _F3R<opc1, (outs GRRegs:$dst), (ins GRRegs:$b, GRRegs:$c),
200 !strconcat(OpcStr, " $dst, $b, $c"),
201 [(set GRRegs:$dst, (OpNode GRRegs:$b, GRRegs:$c))]>;
202 def _2rus : _F2RUS<opc2, (outs GRRegs:$dst), (ins GRRegs:$b, i32imm:$c),
203 !strconcat(OpcStr, " $dst, $b, $c"),
204 [(set GRRegs:$dst, (OpNode GRRegs:$b, immUs:$c))]>;
207 multiclass F3R_2RUS_np<bits<5> opc1, bits<5> opc2, string OpcStr> {
208 def _3r: _F3R<opc1, (outs GRRegs:$dst), (ins GRRegs:$b, GRRegs:$c),
209 !strconcat(OpcStr, " $dst, $b, $c"), []>;
210 def _2rus : _F2RUS<opc2, (outs GRRegs:$dst), (ins GRRegs:$b, i32imm:$c),
211 !strconcat(OpcStr, " $dst, $b, $c"), []>;
214 multiclass F3R_2RBITP<bits<5> opc1, bits<5> opc2, string OpcStr,
216 def _3r: _F3R<opc1, (outs GRRegs:$dst), (ins GRRegs:$b, GRRegs:$c),
217 !strconcat(OpcStr, " $dst, $b, $c"),
218 [(set GRRegs:$dst, (OpNode GRRegs:$b, GRRegs:$c))]>;
219 def _2rus : _F2RUSBitp<opc2, (outs GRRegs:$dst), (ins GRRegs:$b, i32imm:$c),
220 !strconcat(OpcStr, " $dst, $b, $c"),
221 [(set GRRegs:$dst, (OpNode GRRegs:$b, immBitp:$c))]>;
224 class F3R<bits<5> opc, string OpcStr, SDNode OpNode> :
225 _F3R<opc, (outs GRRegs:$dst), (ins GRRegs:$b, GRRegs:$c),
226 !strconcat(OpcStr, " $dst, $b, $c"),
227 [(set GRRegs:$dst, (OpNode GRRegs:$b, GRRegs:$c))]>;
229 class F3R_np<bits<5> opc, string OpcStr> :
230 _F3R<opc, (outs GRRegs:$dst), (ins GRRegs:$b, GRRegs:$c),
231 !strconcat(OpcStr, " $dst, $b, $c"), []>;
232 // Three operand long
234 /// FL3R_L2RUS multiclass - Define a normal FL3R/FL2RUS pattern in one shot.
235 multiclass FL3R_L2RUS<bits<9> opc1, bits<9> opc2, string OpcStr,
237 def _l3r: _FL3R<opc1, (outs GRRegs:$dst), (ins GRRegs:$b, GRRegs:$c),
238 !strconcat(OpcStr, " $dst, $b, $c"),
239 [(set GRRegs:$dst, (OpNode GRRegs:$b, GRRegs:$c))]>;
240 def _l2rus : _FL2RUS<opc2, (outs GRRegs:$dst), (ins GRRegs:$b, i32imm:$c),
241 !strconcat(OpcStr, " $dst, $b, $c"),
242 [(set GRRegs:$dst, (OpNode GRRegs:$b, immUs:$c))]>;
245 /// FL3R_L2RUS multiclass - Define a normal FL3R/FL2RUS pattern in one shot.
246 multiclass FL3R_L2RBITP<bits<9> opc1, bits<9> opc2, string OpcStr,
248 def _l3r: _FL3R<opc1, (outs GRRegs:$dst), (ins GRRegs:$b, GRRegs:$c),
249 !strconcat(OpcStr, " $dst, $b, $c"),
250 [(set GRRegs:$dst, (OpNode GRRegs:$b, GRRegs:$c))]>;
251 def _l2rus : _FL2RUSBitp<opc2, (outs GRRegs:$dst), (ins GRRegs:$b, i32imm:$c),
252 !strconcat(OpcStr, " $dst, $b, $c"),
253 [(set GRRegs:$dst, (OpNode GRRegs:$b, immBitp:$c))]>;
256 class FL3R<bits<9> opc, string OpcStr, SDNode OpNode> :
257 _FL3R<opc, (outs GRRegs:$dst), (ins GRRegs:$b, GRRegs:$c),
258 !strconcat(OpcStr, " $dst, $b, $c"),
259 [(set GRRegs:$dst, (OpNode GRRegs:$b, GRRegs:$c))]>;
262 // Operand register - U6
263 multiclass FRU6_LRU6_branch<bits<6> opc, string OpcStr> {
264 def _ru6: _FRU6<opc, (outs), (ins GRRegs:$a, brtarget:$b),
265 !strconcat(OpcStr, " $a, $b"), []>;
266 def _lru6: _FLRU6<opc, (outs), (ins GRRegs:$a, brtarget:$b),
267 !strconcat(OpcStr, " $a, $b"), []>;
270 multiclass FRU6_LRU6_backwards_branch<bits<6> opc, string OpcStr> {
271 def _ru6: _FRU6<opc, (outs), (ins GRRegs:$a, brtarget:$b),
272 !strconcat(OpcStr, " $a, -$b"), []>;
273 def _lru6: _FLRU6<opc, (outs), (ins GRRegs:$a, brtarget:$b),
274 !strconcat(OpcStr, " $a, -$b"), []>;
277 multiclass FRU6_LRU6_cp<bits<6> opc, string OpcStr> {
278 def _ru6: _FRU6<opc, (outs RRegs:$a), (ins i32imm:$b),
279 !strconcat(OpcStr, " $a, cp[$b]"), []>;
280 def _lru6: _FLRU6<opc, (outs RRegs:$a), (ins i32imm:$b),
281 !strconcat(OpcStr, " $a, cp[$b]"), []>;
285 multiclass FU6_LU6<bits<10> opc, string OpcStr, SDNode OpNode> {
286 def _u6: _FU6<opc, (outs), (ins i32imm:$a), !strconcat(OpcStr, " $a"),
287 [(OpNode immU6:$a)]>;
288 def _lu6: _FLU6<opc, (outs), (ins i32imm:$a), !strconcat(OpcStr, " $a"),
289 [(OpNode immU16:$a)]>;
292 multiclass FU6_LU6_int<bits<10> opc, string OpcStr, Intrinsic Int> {
293 def _u6: _FU6<opc, (outs), (ins i32imm:$a), !strconcat(OpcStr, " $a"),
295 def _lu6: _FLU6<opc, (outs), (ins i32imm:$a), !strconcat(OpcStr, " $a"),
299 multiclass FU6_LU6_np<bits<10> opc, string OpcStr> {
300 def _u6: _FU6<opc, (outs), (ins i32imm:$a), !strconcat(OpcStr, " $a"), []>;
301 def _lu6: _FLU6<opc, (outs), (ins i32imm:$a), !strconcat(OpcStr, " $a"), []>;
306 class F2R_np<bits<6> opc, string OpcStr> :
307 _F2R<opc, (outs GRRegs:$dst), (ins GRRegs:$b),
308 !strconcat(OpcStr, " $dst, $b"), []>;
312 //===----------------------------------------------------------------------===//
313 // Pseudo Instructions
314 //===----------------------------------------------------------------------===//
316 let Defs = [SP], Uses = [SP] in {
317 def ADJCALLSTACKDOWN : PseudoInstXCore<(outs), (ins i32imm:$amt),
318 "# ADJCALLSTACKDOWN $amt",
319 [(callseq_start timm:$amt)]>;
320 def ADJCALLSTACKUP : PseudoInstXCore<(outs), (ins i32imm:$amt1, i32imm:$amt2),
321 "# ADJCALLSTACKUP $amt1",
322 [(callseq_end timm:$amt1, timm:$amt2)]>;
325 def LDWFI : PseudoInstXCore<(outs GRRegs:$dst), (ins MEMii:$addr),
326 "# LDWFI $dst, $addr",
327 [(set GRRegs:$dst, (load ADDRspii:$addr))]>;
329 def LDAWFI : PseudoInstXCore<(outs GRRegs:$dst), (ins MEMii:$addr),
330 "# LDAWFI $dst, $addr",
331 [(set GRRegs:$dst, ADDRspii:$addr)]>;
333 def STWFI : PseudoInstXCore<(outs), (ins GRRegs:$src, MEMii:$addr),
334 "# STWFI $src, $addr",
335 [(store GRRegs:$src, ADDRspii:$addr)]>;
337 // SELECT_CC_* - Used to implement the SELECT_CC DAG operation. Expanded after
338 // instruction selection into a branch sequence.
339 let usesCustomInserter = 1 in {
340 def SELECT_CC : PseudoInstXCore<(outs GRRegs:$dst),
341 (ins GRRegs:$cond, GRRegs:$T, GRRegs:$F),
342 "# SELECT_CC PSEUDO!",
344 (select GRRegs:$cond, GRRegs:$T, GRRegs:$F))]>;
347 //===----------------------------------------------------------------------===//
349 //===----------------------------------------------------------------------===//
351 // Three operand short
352 defm ADD : F3R_2RUS<0b00010, 0b10010, "add", add>;
353 defm SUB : F3R_2RUS<0b00011, 0b10011, "sub", sub>;
354 let neverHasSideEffects = 1 in {
355 defm EQ : F3R_2RUS_np<0b00110, 0b10110, "eq">;
356 def LSS_3r : F3R_np<0b11000, "lss">;
357 def LSU_3r : F3R_np<0b11001, "lsu">;
359 def AND_3r : F3R<0b00111, "and", and>;
360 def OR_3r : F3R<0b01000, "or", or>;
363 def LDW_3r : _F3R<0b01001, (outs GRRegs:$dst),
364 (ins GRRegs:$addr, GRRegs:$offset),
365 "ldw $dst, $addr[$offset]", []>;
367 def LDW_2rus : _F2RUS<0b00001, (outs GRRegs:$dst),
368 (ins GRRegs:$addr, i32imm:$offset),
369 "ldw $dst, $addr[$offset]", []>;
371 def LD16S_3r : _F3R<0b10000, (outs GRRegs:$dst),
372 (ins GRRegs:$addr, GRRegs:$offset),
373 "ld16s $dst, $addr[$offset]", []>;
375 def LD8U_3r : _F3R<0b10001, (outs GRRegs:$dst),
376 (ins GRRegs:$addr, GRRegs:$offset),
377 "ld8u $dst, $addr[$offset]", []>;
381 def STW_l3r : _FL3R<0b000001100, (outs),
382 (ins GRRegs:$val, GRRegs:$addr, GRRegs:$offset),
383 "stw $val, $addr[$offset]", []>;
385 def STW_2rus : _F2RUS<0b0000, (outs),
386 (ins GRRegs:$val, GRRegs:$addr, i32imm:$offset),
387 "stw $val, $addr[$offset]", []>;
390 defm SHL : F3R_2RBITP<0b00100, 0b10100, "shl", shl>;
391 defm SHR : F3R_2RBITP<0b00101, 0b10101, "shr", srl>;
393 // The first operand is treated as an immediate since it refers to a register
394 // number in another thread.
395 def TSETR_3r : _F3RImm<0b10111, (outs), (ins i32imm:$a, GRRegs:$b, GRRegs:$c),
396 "set t[$c]:r$a, $b", []>;
398 // Three operand long
399 def LDAWF_l3r : _FL3R<0b000111100, (outs GRRegs:$dst),
400 (ins GRRegs:$addr, GRRegs:$offset),
401 "ldaw $dst, $addr[$offset]",
403 (ldawf GRRegs:$addr, GRRegs:$offset))]>;
405 let neverHasSideEffects = 1 in
406 def LDAWF_l2rus : _FL2RUS<0b100111100, (outs GRRegs:$dst),
407 (ins GRRegs:$addr, i32imm:$offset),
408 "ldaw $dst, $addr[$offset]", []>;
410 def LDAWB_l3r : _FL3R<0b001001100, (outs GRRegs:$dst),
411 (ins GRRegs:$addr, GRRegs:$offset),
412 "ldaw $dst, $addr[-$offset]",
414 (ldawb GRRegs:$addr, GRRegs:$offset))]>;
416 let neverHasSideEffects = 1 in
417 def LDAWB_l2rus : _FL2RUS<0b101001100, (outs GRRegs:$dst),
418 (ins GRRegs:$addr, i32imm:$offset),
419 "ldaw $dst, $addr[-$offset]", []>;
421 def LDA16F_l3r : _FL3R<0b001011100, (outs GRRegs:$dst),
422 (ins GRRegs:$addr, GRRegs:$offset),
423 "lda16 $dst, $addr[$offset]",
425 (lda16f GRRegs:$addr, GRRegs:$offset))]>;
427 def LDA16B_l3r : _FL3R<0b001101100, (outs GRRegs:$dst),
428 (ins GRRegs:$addr, GRRegs:$offset),
429 "lda16 $dst, $addr[-$offset]",
431 (lda16b GRRegs:$addr, GRRegs:$offset))]>;
433 def MUL_l3r : FL3R<0b001111100, "mul", mul>;
434 // Instructions which may trap are marked as side effecting.
435 let hasSideEffects = 1 in {
436 def DIVS_l3r : FL3R<0b010001100, "divs", sdiv>;
437 def DIVU_l3r : FL3R<0b010011100, "divu", udiv>;
438 def REMS_l3r : FL3R<0b110001100, "rems", srem>;
439 def REMU_l3r : FL3R<0b110011100, "remu", urem>;
441 def XOR_l3r : FL3R<0b000011100, "xor", xor>;
442 defm ASHR : FL3R_L2RBITP<0b000101100, 0b100101100, "ashr", sra>;
444 let Constraints = "$src1 = $dst" in
445 def CRC_l3r : _FL3RSrcDst<0b101011100, (outs GRRegs:$dst),
446 (ins GRRegs:$src1, GRRegs:$src2, GRRegs:$src3),
447 "crc32 $dst, $src2, $src3",
449 (int_xcore_crc32 GRRegs:$src1, GRRegs:$src2,
453 def ST16_l3r : _FL3R<0b100001100, (outs),
454 (ins GRRegs:$val, GRRegs:$addr, GRRegs:$offset),
455 "st16 $val, $addr[$offset]", []>;
457 def ST8_l3r : _FL3R<0b100011100, (outs),
458 (ins GRRegs:$val, GRRegs:$addr, GRRegs:$offset),
459 "st8 $val, $addr[$offset]", []>;
462 def INPW_l2rus : _FL2RUSBitp<0b100101110, (outs GRRegs:$a),
463 (ins GRRegs:$b, i32imm:$c), "inpw $a, res[$b], $c",
466 def OUTPW_l2rus : _FL2RUSBitp<0b100101101, (outs),
467 (ins GRRegs:$a, GRRegs:$b, i32imm:$c),
468 "outpw res[$b], $a, $c", []>;
471 let Constraints = "$e = $a,$f = $b" in {
472 def MACCU_l4r : _FL4RSrcDstSrcDst<
473 0b000001, (outs GRRegs:$a, GRRegs:$b),
474 (ins GRRegs:$e, GRRegs:$f, GRRegs:$c, GRRegs:$d), "maccu $a, $b, $c, $d", []>;
476 def MACCS_l4r : _FL4RSrcDstSrcDst<
477 0b000010, (outs GRRegs:$a, GRRegs:$b),
478 (ins GRRegs:$e, GRRegs:$f, GRRegs:$c, GRRegs:$d), "maccs $a, $b, $c, $d", []>;
481 let Constraints = "$e = $b" in
482 def CRC8_l4r : _FL4RSrcDst<0b000000, (outs GRRegs:$a, GRRegs:$b),
483 (ins GRRegs:$e, GRRegs:$c, GRRegs:$d),
484 "crc8 $b, $a, $c, $d", []>;
488 def LADD_l5r : _FL5R<0b000001, (outs GRRegs:$dst1, GRRegs:$dst2),
489 (ins GRRegs:$src1, GRRegs:$src2, GRRegs:$src3),
490 "ladd $dst2, $dst1, $src1, $src2, $src3",
493 def LSUB_l5r : _FL5R<0b000010, (outs GRRegs:$dst1, GRRegs:$dst2),
494 (ins GRRegs:$src1, GRRegs:$src2, GRRegs:$src3),
495 "lsub $dst2, $dst1, $src1, $src2, $src3", []>;
497 def LDIVU_l5r : _FL5R<0b000000, (outs GRRegs:$dst1, GRRegs:$dst2),
498 (ins GRRegs:$src1, GRRegs:$src2, GRRegs:$src3),
499 "ldivu $dst1, $dst2, $src3, $src1, $src2", []>;
503 def LMUL_l6r : _FL6R<
504 0b00000, (outs GRRegs:$dst1, GRRegs:$dst2),
505 (ins GRRegs:$src1, GRRegs:$src2, GRRegs:$src3, GRRegs:$src4),
506 "lmul $dst1, $dst2, $src1, $src2, $src3, $src4", []>;
510 //let Uses = [DP] in ...
511 let neverHasSideEffects = 1, isReMaterializable = 1 in
512 def LDAWDP_ru6: _FRU6<0b011000, (outs RRegs:$a), (ins i32imm:$b),
513 "ldaw $a, dp[$b]", []>;
515 let isReMaterializable = 1 in
516 def LDAWDP_lru6: _FLRU6<0b011000, (outs RRegs:$a), (ins i32imm:$b),
518 [(set RRegs:$a, (dprelwrapper tglobaladdr:$b))]>;
521 def LDWDP_ru6: _FRU6<0b010110, (outs RRegs:$a), (ins i32imm:$b),
522 "ldw $a, dp[$b]", []>;
524 def LDWDP_lru6: _FLRU6<0b010110, (outs RRegs:$a), (ins i32imm:$b),
526 [(set RRegs:$a, (load (dprelwrapper tglobaladdr:$b)))]>;
529 def STWDP_ru6 : _FRU6<0b010100, (outs), (ins RRegs:$a, i32imm:$b),
530 "stw $a, dp[$b]", []>;
532 def STWDP_lru6 : _FLRU6<0b010100, (outs), (ins RRegs:$a, i32imm:$b),
534 [(store RRegs:$a, (dprelwrapper tglobaladdr:$b))]>;
536 //let Uses = [CP] in ..
537 let mayLoad = 1, isReMaterializable = 1, neverHasSideEffects = 1 in
538 defm LDWCP : FRU6_LRU6_cp<0b011011, "ldw">;
542 def STWSP_ru6 : _FRU6<0b010101, (outs), (ins RRegs:$a, i32imm:$b),
544 [(XCoreStwsp RRegs:$a, immU6:$b)]>;
546 def STWSP_lru6 : _FLRU6<0b010101, (outs), (ins RRegs:$a, i32imm:$b),
548 [(XCoreStwsp RRegs:$a, immU16:$b)]>;
552 def LDWSP_ru6 : _FRU6<0b010111, (outs RRegs:$a), (ins i32imm:$b),
553 "ldw $a, sp[$b]", []>;
555 def LDWSP_lru6 : _FLRU6<0b010111, (outs RRegs:$a), (ins i32imm:$b),
556 "ldw $a, sp[$b]", []>;
559 let neverHasSideEffects = 1 in {
560 def LDAWSP_ru6 : _FRU6<0b011001, (outs RRegs:$a), (ins i32imm:$b),
561 "ldaw $a, sp[$b]", []>;
563 def LDAWSP_lru6 : _FLRU6<0b011001, (outs RRegs:$a), (ins i32imm:$b),
564 "ldaw $a, sp[$b]", []>;
568 let isReMaterializable = 1 in {
569 def LDC_ru6 : _FRU6<0b011010, (outs RRegs:$a), (ins i32imm:$b),
570 "ldc $a, $b", [(set RRegs:$a, immU6:$b)]>;
572 def LDC_lru6 : _FLRU6<0b011010, (outs RRegs:$a), (ins i32imm:$b),
573 "ldc $a, $b", [(set RRegs:$a, immU16:$b)]>;
576 def SETC_ru6 : _FRU6<0b111010, (outs), (ins GRRegs:$a, i32imm:$b),
578 [(int_xcore_setc GRRegs:$a, immU6:$b)]>;
580 def SETC_lru6 : _FLRU6<0b111010, (outs), (ins GRRegs:$a, i32imm:$b),
582 [(int_xcore_setc GRRegs:$a, immU16:$b)]>;
584 // Operand register - U6
585 let isBranch = 1, isTerminator = 1 in {
586 defm BRFT: FRU6_LRU6_branch<0b011100, "bt">;
587 defm BRBT: FRU6_LRU6_backwards_branch<0b011101, "bt">;
588 defm BRFF: FRU6_LRU6_branch<0b011110, "bf">;
589 defm BRBF: FRU6_LRU6_backwards_branch<0b011111, "bf">;
593 let Defs = [SP], Uses = [SP] in {
594 let neverHasSideEffects = 1 in
595 defm EXTSP : FU6_LU6_np<0b0111011110, "extsp">;
598 defm ENTSP : FU6_LU6_np<0b0111011101, "entsp">;
600 let isReturn = 1, isTerminator = 1, mayLoad = 1, isBarrier = 1 in {
601 defm RETSP : FU6_LU6<0b0111011111, "retsp", XCoreRetsp>;
605 let neverHasSideEffects = 1 in
606 defm EXTDP : FU6_LU6_np<0b0111001110, "extdp">;
608 let Uses = [R11], isCall=1 in
609 defm BLAT : FU6_LU6_np<0b0111001101, "blat">;
611 let isBranch = 1, isTerminator = 1, isBarrier = 1 in {
612 def BRBU_u6 : _FU6<0b0111011100, (outs), (ins brtarget:$a), "bu -$a", []>;
614 def BRBU_lu6 : _FLU6<0b0111011100, (outs), (ins brtarget:$a), "bu -$a", []>;
616 def BRFU_u6 : _FU6<0b0111001100, (outs), (ins brtarget:$a), "bu $a", []>;
618 def BRFU_lu6 : _FLU6<0b0111001100, (outs), (ins brtarget:$a), "bu $a", []>;
621 //let Uses = [CP] in ...
622 let Defs = [R11], neverHasSideEffects = 1, isReMaterializable = 1 in
623 def LDAWCP_u6: _FU6<0b0111111101, (outs), (ins i32imm:$a), "ldaw r11, cp[$a]",
626 let Defs = [R11], isReMaterializable = 1 in
627 def LDAWCP_lu6: _FLU6<0b0111111101, (outs), (ins i32imm:$a), "ldaw r11, cp[$a]",
628 [(set R11, (cprelwrapper tglobaladdr:$a))]>;
631 defm GETSR : FU6_LU6_np<0b0111111100, "getsr r11,">;
633 defm SETSR : FU6_LU6_int<0b0111101101, "setsr", int_xcore_setsr>;
635 defm CLRSR : FU6_LU6_int<0b0111101100, "clrsr", int_xcore_clrsr>;
637 // setsr may cause a branch if it is used to enable events. clrsr may
638 // branch if it is executed while events are enabled.
639 let isBranch=1, isIndirectBranch=1, isTerminator=1, isBarrier = 1,
640 isCodeGenOnly = 1 in {
641 defm SETSR_branch : FU6_LU6_np<0b0111101101, "setsr">;
642 defm CLRSR_branch : FU6_LU6_np<0b0111101100, "clrsr">;
645 defm KCALL : FU6_LU6_np<0b0111001111, "kcall">;
647 let Uses = [SP], Defs = [SP], mayStore = 1 in
648 defm KENTSP : FU6_LU6_np<0b0111101110, "kentsp">;
650 let Uses = [SP], Defs = [SP], mayLoad = 1 in
651 defm KRESTSP : FU6_LU6_np<0b0111101111, "krestsp">;
655 let Defs = [R11], isReMaterializable = 1, neverHasSideEffects = 1 in
656 def LDAPF_u10 : _FU10<0b110110, (outs), (ins i32imm:$a), "ldap r11, $a", []>;
658 let Defs = [R11], isReMaterializable = 1 in
659 def LDAPF_lu10 : _FLU10<0b110110, (outs), (ins i32imm:$a), "ldap r11, $a",
660 [(set R11, (pcrelwrapper tglobaladdr:$a))]>;
662 let Defs = [R11], isReMaterializable = 1, isCodeGenOnly = 1 in
663 def LDAPF_lu10_ba : _FLU10<0b110110, (outs), (ins i32imm:$a), "ldap r11, $a",
664 [(set R11, (pcrelwrapper tblockaddress:$a))]>;
667 // All calls clobber the link register and the non-callee-saved registers:
668 Defs = [R0, R1, R2, R3, R11, LR], Uses = [SP] in {
669 def BLACP_u10 : _FU10<0b111000, (outs), (ins i32imm:$a), "bla cp[$a]", []>;
671 def BLACP_lu10 : _FLU10<0b111000, (outs), (ins i32imm:$a), "bla cp[$a]", []>;
673 def BLRF_u10 : _FU10<0b110100, (outs), (ins calltarget:$a), "bl $a",
674 [(XCoreBranchLink immU10:$a)]>;
676 def BLRF_lu10 : _FLU10<0b110100, (outs), (ins calltarget:$a), "bl $a",
677 [(XCoreBranchLink immU20:$a)]>;
680 let Defs = [R11], mayLoad = 1, isReMaterializable = 1,
681 neverHasSideEffects = 1 in {
682 def LDWCP_u10 : _FU10<0b111001, (outs), (ins i32imm:$a), "ldw r11, cp[$a]", []>;
684 def LDWCP_lu10 : _FLU10<0b111001, (outs), (ins i32imm:$a), "ldw r11, cp[$a]",
689 def NOT : _F2R<0b100010, (outs GRRegs:$dst), (ins GRRegs:$b),
690 "not $dst, $b", [(set GRRegs:$dst, (not GRRegs:$b))]>;
692 def NEG : _F2R<0b100100, (outs GRRegs:$dst), (ins GRRegs:$b),
693 "neg $dst, $b", [(set GRRegs:$dst, (ineg GRRegs:$b))]>;
695 let Constraints = "$src1 = $dst" in {
697 _FRUSSrcDstBitp<0b001101, (outs GRRegs:$dst), (ins GRRegs:$src1, i32imm:$src2),
699 [(set GRRegs:$dst, (int_xcore_sext GRRegs:$src1,
703 _F2RSrcDst<0b001100, (outs GRRegs:$dst), (ins GRRegs:$src1, GRRegs:$src2),
705 [(set GRRegs:$dst, (int_xcore_sext GRRegs:$src1, GRRegs:$src2))]>;
708 _FRUSSrcDstBitp<0b010001, (outs GRRegs:$dst), (ins GRRegs:$src1, i32imm:$src2),
710 [(set GRRegs:$dst, (int_xcore_zext GRRegs:$src1,
714 _F2RSrcDst<0b010000, (outs GRRegs:$dst), (ins GRRegs:$src1, GRRegs:$src2),
716 [(set GRRegs:$dst, (int_xcore_zext GRRegs:$src1, GRRegs:$src2))]>;
719 _F2RSrcDst<0b001010, (outs GRRegs:$dst), (ins GRRegs:$src1, GRRegs:$src2),
720 "andnot $dst, $src2",
721 [(set GRRegs:$dst, (and GRRegs:$src1, (not GRRegs:$src2)))]>;
724 let isReMaterializable = 1, neverHasSideEffects = 1 in
725 def MKMSK_rus : _FRUSBitp<0b101001, (outs GRRegs:$dst), (ins i32imm:$size),
726 "mkmsk $dst, $size", []>;
728 def MKMSK_2r : _F2R<0b101000, (outs GRRegs:$dst), (ins GRRegs:$size),
730 [(set GRRegs:$dst, (add (shl 1, GRRegs:$size), -1))]>;
732 def GETR_rus : _FRUS<0b100000, (outs GRRegs:$dst), (ins i32imm:$type),
734 [(set GRRegs:$dst, (int_xcore_getr immUs:$type))]>;
736 def GETTS_2r : _F2R<0b001110, (outs GRRegs:$dst), (ins GRRegs:$r),
737 "getts $dst, res[$r]",
738 [(set GRRegs:$dst, (int_xcore_getts GRRegs:$r))]>;
740 def SETPT_2r : _FR2R<0b001111, (outs), (ins GRRegs:$r, GRRegs:$val),
741 "setpt res[$r], $val",
742 [(int_xcore_setpt GRRegs:$r, GRRegs:$val)]>;
744 def OUTCT_2r : _F2R<0b010010, (outs), (ins GRRegs:$r, GRRegs:$val),
745 "outct res[$r], $val",
746 [(int_xcore_outct GRRegs:$r, GRRegs:$val)]>;
748 def OUTCT_rus : _FRUS<0b010011, (outs), (ins GRRegs:$r, i32imm:$val),
749 "outct res[$r], $val",
750 [(int_xcore_outct GRRegs:$r, immUs:$val)]>;
752 def OUTT_2r : _FR2R<0b000011, (outs), (ins GRRegs:$r, GRRegs:$val),
753 "outt res[$r], $val",
754 [(int_xcore_outt GRRegs:$r, GRRegs:$val)]>;
756 def OUT_2r : _FR2R<0b101010, (outs), (ins GRRegs:$r, GRRegs:$val),
758 [(int_xcore_out GRRegs:$r, GRRegs:$val)]>;
760 let Constraints = "$src = $dst" in
762 _F2RSrcDst<0b101011, (outs GRRegs:$dst), (ins GRRegs:$src, GRRegs:$r),
763 "outshr res[$r], $src",
764 [(set GRRegs:$dst, (int_xcore_outshr GRRegs:$r, GRRegs:$src))]>;
766 def INCT_2r : _F2R<0b100001, (outs GRRegs:$dst), (ins GRRegs:$r),
767 "inct $dst, res[$r]",
768 [(set GRRegs:$dst, (int_xcore_inct GRRegs:$r))]>;
770 def INT_2r : _F2R<0b100011, (outs GRRegs:$dst), (ins GRRegs:$r),
772 [(set GRRegs:$dst, (int_xcore_int GRRegs:$r))]>;
774 def IN_2r : _F2R<0b101100, (outs GRRegs:$dst), (ins GRRegs:$r),
776 [(set GRRegs:$dst, (int_xcore_in GRRegs:$r))]>;
778 let Constraints = "$src = $dst" in
780 _F2RSrcDst<0b101101, (outs GRRegs:$dst), (ins GRRegs:$src, GRRegs:$r),
781 "inshr $dst, res[$r]",
782 [(set GRRegs:$dst, (int_xcore_inshr GRRegs:$r, GRRegs:$src))]>;
784 def CHKCT_2r : _F2R<0b110010, (outs), (ins GRRegs:$r, GRRegs:$val),
785 "chkct res[$r], $val",
786 [(int_xcore_chkct GRRegs:$r, GRRegs:$val)]>;
788 def CHKCT_rus : _FRUSBitp<0b110011, (outs), (ins GRRegs:$r, i32imm:$val),
789 "chkct res[$r], $val",
790 [(int_xcore_chkct GRRegs:$r, immUs:$val)]>;
792 def TESTCT_2r : _F2R<0b101111, (outs GRRegs:$dst), (ins GRRegs:$src),
793 "testct $dst, res[$src]",
794 [(set GRRegs:$dst, (int_xcore_testct GRRegs:$src))]>;
796 def TESTWCT_2r : _F2R<0b110001, (outs GRRegs:$dst), (ins GRRegs:$src),
797 "testwct $dst, res[$src]",
798 [(set GRRegs:$dst, (int_xcore_testwct GRRegs:$src))]>;
800 def SETD_2r : _FR2R<0b000101, (outs), (ins GRRegs:$r, GRRegs:$val),
801 "setd res[$r], $val",
802 [(int_xcore_setd GRRegs:$r, GRRegs:$val)]>;
804 def SETPSC_2r : _FR2R<0b110000, (outs), (ins GRRegs:$src1, GRRegs:$src2),
805 "setpsc res[$src1], $src2",
806 [(int_xcore_setpsc GRRegs:$src1, GRRegs:$src2)]>;
808 def GETST_2r : _F2R<0b000001, (outs GRRegs:$dst), (ins GRRegs:$r),
809 "getst $dst, res[$r]",
810 [(set GRRegs:$dst, (int_xcore_getst GRRegs:$r))]>;
812 def INITSP_2r : _F2R<0b000100, (outs), (ins GRRegs:$src, GRRegs:$t),
813 "init t[$t]:sp, $src",
814 [(int_xcore_initsp GRRegs:$t, GRRegs:$src)]>;
816 def INITPC_2r : _F2R<0b000000, (outs), (ins GRRegs:$src, GRRegs:$t),
817 "init t[$t]:pc, $src",
818 [(int_xcore_initpc GRRegs:$t, GRRegs:$src)]>;
820 def INITCP_2r : _F2R<0b000110, (outs), (ins GRRegs:$src, GRRegs:$t),
821 "init t[$t]:cp, $src",
822 [(int_xcore_initcp GRRegs:$t, GRRegs:$src)]>;
824 def INITDP_2r : _F2R<0b000010, (outs), (ins GRRegs:$src, GRRegs:$t),
825 "init t[$t]:dp, $src",
826 [(int_xcore_initdp GRRegs:$t, GRRegs:$src)]>;
828 def PEEK_2r : _F2R<0b101110, (outs GRRegs:$dst), (ins GRRegs:$src),
829 "peek $dst, res[$src]",
830 [(set GRRegs:$dst, (int_xcore_peek GRRegs:$src))]>;
832 def ENDIN_2r : _F2R<0b100101, (outs GRRegs:$dst), (ins GRRegs:$src),
833 "endin $dst, res[$src]",
834 [(set GRRegs:$dst, (int_xcore_endin GRRegs:$src))]>;
836 def EEF_2r : _F2R<0b001011, (outs), (ins GRRegs:$a, GRRegs:$b),
837 "eef $a, res[$b]", []>;
839 def EET_2r : _F2R<0b001001, (outs), (ins GRRegs:$a, GRRegs:$b),
840 "eet $a, res[$b]", []>;
842 def TSETMR_2r : _F2RImm<0b000111, (outs), (ins i32imm:$a, GRRegs:$b),
843 "tsetmr r$a, $b", []>;
846 def BITREV_l2r : _FL2R<0b0000011000, (outs GRRegs:$dst), (ins GRRegs:$src),
848 [(set GRRegs:$dst, (int_xcore_bitrev GRRegs:$src))]>;
850 def BYTEREV_l2r : _FL2R<0b0000011001, (outs GRRegs:$dst), (ins GRRegs:$src),
851 "byterev $dst, $src",
852 [(set GRRegs:$dst, (bswap GRRegs:$src))]>;
854 def CLZ_l2r : _FL2R<0b000111000, (outs GRRegs:$dst), (ins GRRegs:$src),
856 [(set GRRegs:$dst, (ctlz GRRegs:$src))]>;
858 def GETD_l2r : _FL2R<0b0001111001, (outs GRRegs:$dst), (ins GRRegs:$src),
859 "getd $dst, res[$src]", []>;
861 def GETN_l2r : _FL2R<0b0011011001, (outs GRRegs:$dst), (ins GRRegs:$src),
862 "getn $dst, res[$src]", []>;
864 def SETC_l2r : _FL2R<0b0010111001, (outs), (ins GRRegs:$r, GRRegs:$val),
865 "setc res[$r], $val",
866 [(int_xcore_setc GRRegs:$r, GRRegs:$val)]>;
868 def SETTW_l2r : _FLR2R<0b0010011001, (outs), (ins GRRegs:$r, GRRegs:$val),
869 "settw res[$r], $val",
870 [(int_xcore_settw GRRegs:$r, GRRegs:$val)]>;
872 def GETPS_l2r : _FL2R<0b0001011001, (outs GRRegs:$dst), (ins GRRegs:$src),
873 "get $dst, ps[$src]",
874 [(set GRRegs:$dst, (int_xcore_getps GRRegs:$src))]>;
876 def SETPS_l2r : _FLR2R<0b0001111000, (outs), (ins GRRegs:$src1, GRRegs:$src2),
877 "set ps[$src1], $src2",
878 [(int_xcore_setps GRRegs:$src1, GRRegs:$src2)]>;
880 def INITLR_l2r : _FL2R<0b0001011000, (outs), (ins GRRegs:$src, GRRegs:$t),
881 "init t[$t]:lr, $src",
882 [(int_xcore_initlr GRRegs:$t, GRRegs:$src)]>;
884 def SETCLK_l2r : _FLR2R<0b0000111001, (outs), (ins GRRegs:$src1, GRRegs:$src2),
885 "setclk res[$src1], $src2",
886 [(int_xcore_setclk GRRegs:$src1, GRRegs:$src2)]>;
888 def SETN_l2r : _FLR2R<0b0011011000, (outs), (ins GRRegs:$src1, GRRegs:$src2),
889 "setn res[$src1], $src2", []>;
891 def SETRDY_l2r : _FLR2R<0b0010111000, (outs), (ins GRRegs:$src1, GRRegs:$src2),
892 "setrdy res[$src1], $src2",
893 [(int_xcore_setrdy GRRegs:$src1, GRRegs:$src2)]>;
895 def TESTLCL_l2r : _FL2R<0b0010011000, (outs GRRegs:$dst), (ins GRRegs:$src),
896 "testlcl $dst, res[$src]", []>;
899 def MSYNC_1r : _F1R<0b000111, (outs), (ins GRRegs:$a),
901 [(int_xcore_msync GRRegs:$a)]>;
902 def MJOIN_1r : _F1R<0b000101, (outs), (ins GRRegs:$a),
904 [(int_xcore_mjoin GRRegs:$a)]>;
906 let isBranch=1, isIndirectBranch=1, isTerminator=1, isBarrier = 1 in
907 def BAU_1r : _F1R<0b001001, (outs), (ins GRRegs:$a),
909 [(brind GRRegs:$a)]>;
911 let isBranch=1, isIndirectBranch=1, isTerminator=1, isBarrier = 1 in
912 def BR_JT : PseudoInstXCore<(outs), (ins InlineJT:$t, GRRegs:$i),
914 [(XCoreBR_JT tjumptable:$t, GRRegs:$i)]>;
916 let isBranch=1, isIndirectBranch=1, isTerminator=1, isBarrier = 1 in
917 def BR_JT32 : PseudoInstXCore<(outs), (ins InlineJT32:$t, GRRegs:$i),
919 [(XCoreBR_JT32 tjumptable:$t, GRRegs:$i)]>;
921 let isBranch=1, isIndirectBranch=1, isTerminator=1, isBarrier = 1 in
922 def BRU_1r : _F1R<0b001010, (outs), (ins GRRegs:$a), "bru $a", []>;
924 let Defs=[SP], neverHasSideEffects=1 in
925 def SETSP_1r : _F1R<0b001011, (outs), (ins GRRegs:$a), "set sp, $a", []>;
927 let neverHasSideEffects=1 in
928 def SETDP_1r : _F1R<0b001100, (outs), (ins GRRegs:$a), "set dp, $a", []>;
930 let neverHasSideEffects=1 in
931 def SETCP_1r : _F1R<0b001101, (outs), (ins GRRegs:$a), "set cp, $a", []>;
933 let hasCtrlDep = 1 in
934 def ECALLT_1r : _F1R<0b010011, (outs), (ins GRRegs:$a),
938 let hasCtrlDep = 1 in
939 def ECALLF_1r : _F1R<0b010010, (outs), (ins GRRegs:$a),
944 // All calls clobber the link register and the non-callee-saved registers:
945 Defs = [R0, R1, R2, R3, R11, LR], Uses = [SP] in {
946 def BLA_1r : _F1R<0b001000, (outs), (ins GRRegs:$a),
948 [(XCoreBranchLink GRRegs:$a)]>;
951 def SYNCR_1r : _F1R<0b100001, (outs), (ins GRRegs:$a),
953 [(int_xcore_syncr GRRegs:$a)]>;
955 def FREER_1r : _F1R<0b000100, (outs), (ins GRRegs:$a),
957 [(int_xcore_freer GRRegs:$a)]>;
960 def SETV_1r : _F1R<0b010001, (outs), (ins GRRegs:$a),
962 [(int_xcore_setv GRRegs:$a, R11)]>;
964 def SETEV_1r : _F1R<0b001111, (outs), (ins GRRegs:$a),
965 "setev res[$a], r11",
966 [(int_xcore_setev GRRegs:$a, R11)]>;
969 def DGETREG_1r : _F1R<0b001110, (outs GRRegs:$a), (ins), "dgetreg $a", []>;
971 def EDU_1r : _F1R<0b000000, (outs), (ins GRRegs:$a), "edu res[$a]", []>;
973 def EEU_1r : _F1R<0b000001, (outs), (ins GRRegs:$a),
975 [(int_xcore_eeu GRRegs:$a)]>;
977 def KCALL_1r : _F1R<0b010000, (outs), (ins GRRegs:$a), "kcall $a", []>;
979 def WAITEF_1R : _F1R<0b000011, (outs), (ins GRRegs:$a), "waitef $a", []>;
981 def WAITET_1R : _F1R<0b000010, (outs), (ins GRRegs:$a), "waitet $a", []>;
983 def TSTART_1R : _F1R<0b000110, (outs), (ins GRRegs:$a), "start t[$a]", []>;
985 def CLRPT_1R : _F1R<0b100000, (outs), (ins GRRegs:$a), "clrpt res[$a]", []>;
987 // Zero operand short
989 def CLRE_0R : _F0R<0b0000001101, (outs), (ins), "clre", [(int_xcore_clre)]>;
991 def DCALL_0R : _F0R<0b0000011100, (outs), (ins), "dcall", []>;
993 let Defs = [SP], Uses = [SP] in
994 def DENTSP_0R : _F0R<0b0001001100, (outs), (ins), "dentsp", []>;
997 def DRESTSP_0R : _F0R<0b0001001101, (outs), (ins), "drestsp", []>;
999 def DRET_0R : _F0R<0b0000011110, (outs), (ins), "dret", []>;
1001 def FREET_0R : _F0R<0b0000001111, (outs), (ins), "freet", []>;
1003 let Defs = [R11] in {
1004 def GETID_0R : _F0R<0b0001001110, (outs), (ins),
1006 [(set R11, (int_xcore_getid))]>;
1008 def GETED_0R : _F0R<0b0000111110, (outs), (ins),
1010 [(set R11, (int_xcore_geted))]>;
1012 def GETET_0R : _F0R<0b0000111111, (outs), (ins),
1014 [(set R11, (int_xcore_getet))]>;
1016 def GETKEP_0R : _F0R<0b0001001111, (outs), (ins),
1017 "get r11, kep", []>;
1019 def GETKSP_0R : _F0R<0b0001011100, (outs), (ins),
1020 "get r11, ksp", []>;
1024 def KRET_0R : _F0R<0b0000011101, (outs), (ins), "kret", []>;
1026 let Uses = [SP], mayLoad = 1 in {
1027 def LDET_0R : _F0R<0b0001011110, (outs), (ins), "ldw et, sp[4]", []>;
1029 def LDSED_0R : _F0R<0b0001011101, (outs), (ins), "ldw sed, sp[3]", []>;
1031 def LDSPC_0R : _F0R<0b0000101100, (outs), (ins), "ldw spc, sp[1]", []>;
1033 def LDSSR_0R : _F0R<0b0000101110, (outs), (ins), "ldw ssr, sp[2]", []>;
1037 def SETKEP_0R : _F0R<0b0000011111, (outs), (ins), "set kep, r11", []>;
1039 def SSYNC_0r : _F0R<0b0000001110, (outs), (ins),
1041 [(int_xcore_ssync)]>;
1043 let Uses = [SP], mayStore = 1 in {
1044 def STET_0R : _F0R<0b0000111101, (outs), (ins), "stw et, sp[4]", []>;
1046 def STSED_0R : _F0R<0b0000111100, (outs), (ins), "stw sed, sp[3]", []>;
1048 def STSPC_0R : _F0R<0b0000101101, (outs), (ins), "stw spc, sp[1]", []>;
1050 def STSSR_0R : _F0R<0b0000101111, (outs), (ins), "stw ssr, sp[2]", []>;
1053 let isBranch=1, isIndirectBranch=1, isTerminator=1, isBarrier = 1,
1054 hasSideEffects = 1 in
1055 def WAITEU_0R : _F0R<0b0000001100, (outs), (ins),
1057 [(brind (int_xcore_waitevent))]>;
1059 //===----------------------------------------------------------------------===//
1060 // Non-Instruction Patterns
1061 //===----------------------------------------------------------------------===//
1063 def : Pat<(XCoreBranchLink tglobaladdr:$addr), (BLRF_lu10 tglobaladdr:$addr)>;
1064 def : Pat<(XCoreBranchLink texternalsym:$addr), (BLRF_lu10 texternalsym:$addr)>;
1067 def : Pat<(sext_inreg GRRegs:$b, i1), (SEXT_rus GRRegs:$b, 1)>;
1068 def : Pat<(sext_inreg GRRegs:$b, i8), (SEXT_rus GRRegs:$b, 8)>;
1069 def : Pat<(sext_inreg GRRegs:$b, i16), (SEXT_rus GRRegs:$b, 16)>;
1072 def : Pat<(zextloadi8 (add GRRegs:$addr, GRRegs:$offset)),
1073 (LD8U_3r GRRegs:$addr, GRRegs:$offset)>;
1074 def : Pat<(zextloadi8 GRRegs:$addr), (LD8U_3r GRRegs:$addr, (LDC_ru6 0))>;
1076 def : Pat<(sextloadi16 (lda16f GRRegs:$addr, GRRegs:$offset)),
1077 (LD16S_3r GRRegs:$addr, GRRegs:$offset)>;
1078 def : Pat<(sextloadi16 GRRegs:$addr), (LD16S_3r GRRegs:$addr, (LDC_ru6 0))>;
1080 def : Pat<(load (ldawf GRRegs:$addr, GRRegs:$offset)),
1081 (LDW_3r GRRegs:$addr, GRRegs:$offset)>;
1082 def : Pat<(load (add GRRegs:$addr, immUs4:$offset)),
1083 (LDW_2rus GRRegs:$addr, (div4_xform immUs4:$offset))>;
1084 def : Pat<(load GRRegs:$addr), (LDW_2rus GRRegs:$addr, 0)>;
1087 def : Pat<(extloadi8 (add GRRegs:$addr, GRRegs:$offset)),
1088 (LD8U_3r GRRegs:$addr, GRRegs:$offset)>;
1089 def : Pat<(extloadi8 GRRegs:$addr), (LD8U_3r GRRegs:$addr, (LDC_ru6 0))>;
1090 def : Pat<(extloadi16 (lda16f GRRegs:$addr, GRRegs:$offset)),
1091 (LD16S_3r GRRegs:$addr, GRRegs:$offset)>;
1092 def : Pat<(extloadi16 GRRegs:$addr), (LD16S_3r GRRegs:$addr, (LDC_ru6 0))>;
1095 def : Pat<(truncstorei8 GRRegs:$val, (add GRRegs:$addr, GRRegs:$offset)),
1096 (ST8_l3r GRRegs:$val, GRRegs:$addr, GRRegs:$offset)>;
1097 def : Pat<(truncstorei8 GRRegs:$val, GRRegs:$addr),
1098 (ST8_l3r GRRegs:$val, GRRegs:$addr, (LDC_ru6 0))>;
1100 def : Pat<(truncstorei16 GRRegs:$val, (lda16f GRRegs:$addr, GRRegs:$offset)),
1101 (ST16_l3r GRRegs:$val, GRRegs:$addr, GRRegs:$offset)>;
1102 def : Pat<(truncstorei16 GRRegs:$val, GRRegs:$addr),
1103 (ST16_l3r GRRegs:$val, GRRegs:$addr, (LDC_ru6 0))>;
1105 def : Pat<(store GRRegs:$val, (ldawf GRRegs:$addr, GRRegs:$offset)),
1106 (STW_l3r GRRegs:$val, GRRegs:$addr, GRRegs:$offset)>;
1107 def : Pat<(store GRRegs:$val, (add GRRegs:$addr, immUs4:$offset)),
1108 (STW_2rus GRRegs:$val, GRRegs:$addr, (div4_xform immUs4:$offset))>;
1109 def : Pat<(store GRRegs:$val, GRRegs:$addr),
1110 (STW_2rus GRRegs:$val, GRRegs:$addr, 0)>;
1113 def : Pat<(cttz GRRegs:$src), (CLZ_l2r (BITREV_l2r GRRegs:$src))>;
1116 def : Pat<(trap), (ECALLF_1r (LDC_ru6 0))>;
1122 // unconditional branch
1123 def : Pat<(br bb:$addr), (BRFU_lu6 bb:$addr)>;
1125 // direct match equal/notequal zero brcond
1126 def : Pat<(brcond (setne GRRegs:$lhs, 0), bb:$dst),
1127 (BRFT_lru6 GRRegs:$lhs, bb:$dst)>;
1128 def : Pat<(brcond (seteq GRRegs:$lhs, 0), bb:$dst),
1129 (BRFF_lru6 GRRegs:$lhs, bb:$dst)>;
1131 def : Pat<(brcond (setle GRRegs:$lhs, GRRegs:$rhs), bb:$dst),
1132 (BRFF_lru6 (LSS_3r GRRegs:$rhs, GRRegs:$lhs), bb:$dst)>;
1133 def : Pat<(brcond (setule GRRegs:$lhs, GRRegs:$rhs), bb:$dst),
1134 (BRFF_lru6 (LSU_3r GRRegs:$rhs, GRRegs:$lhs), bb:$dst)>;
1135 def : Pat<(brcond (setge GRRegs:$lhs, GRRegs:$rhs), bb:$dst),
1136 (BRFF_lru6 (LSS_3r GRRegs:$lhs, GRRegs:$rhs), bb:$dst)>;
1137 def : Pat<(brcond (setuge GRRegs:$lhs, GRRegs:$rhs), bb:$dst),
1138 (BRFF_lru6 (LSU_3r GRRegs:$lhs, GRRegs:$rhs), bb:$dst)>;
1139 def : Pat<(brcond (setne GRRegs:$lhs, GRRegs:$rhs), bb:$dst),
1140 (BRFF_lru6 (EQ_3r GRRegs:$lhs, GRRegs:$rhs), bb:$dst)>;
1141 def : Pat<(brcond (setne GRRegs:$lhs, immUs:$rhs), bb:$dst),
1142 (BRFF_lru6 (EQ_2rus GRRegs:$lhs, immUs:$rhs), bb:$dst)>;
1144 // generic brcond pattern
1145 def : Pat<(brcond GRRegs:$cond, bb:$addr), (BRFT_lru6 GRRegs:$cond, bb:$addr)>;
1152 // direct match equal/notequal zero select
1153 def : Pat<(select (setne GRRegs:$lhs, 0), GRRegs:$T, GRRegs:$F),
1154 (SELECT_CC GRRegs:$lhs, GRRegs:$T, GRRegs:$F)>;
1156 def : Pat<(select (seteq GRRegs:$lhs, 0), GRRegs:$T, GRRegs:$F),
1157 (SELECT_CC GRRegs:$lhs, GRRegs:$F, GRRegs:$T)>;
1159 def : Pat<(select (setle GRRegs:$lhs, GRRegs:$rhs), GRRegs:$T, GRRegs:$F),
1160 (SELECT_CC (LSS_3r GRRegs:$rhs, GRRegs:$lhs), GRRegs:$F, GRRegs:$T)>;
1161 def : Pat<(select (setule GRRegs:$lhs, GRRegs:$rhs), GRRegs:$T, GRRegs:$F),
1162 (SELECT_CC (LSU_3r GRRegs:$rhs, GRRegs:$lhs), GRRegs:$F, GRRegs:$T)>;
1163 def : Pat<(select (setge GRRegs:$lhs, GRRegs:$rhs), GRRegs:$T, GRRegs:$F),
1164 (SELECT_CC (LSS_3r GRRegs:$lhs, GRRegs:$rhs), GRRegs:$F, GRRegs:$T)>;
1165 def : Pat<(select (setuge GRRegs:$lhs, GRRegs:$rhs), GRRegs:$T, GRRegs:$F),
1166 (SELECT_CC (LSU_3r GRRegs:$lhs, GRRegs:$rhs), GRRegs:$F, GRRegs:$T)>;
1167 def : Pat<(select (setne GRRegs:$lhs, GRRegs:$rhs), GRRegs:$T, GRRegs:$F),
1168 (SELECT_CC (EQ_3r GRRegs:$lhs, GRRegs:$rhs), GRRegs:$F, GRRegs:$T)>;
1169 def : Pat<(select (setne GRRegs:$lhs, immUs:$rhs), GRRegs:$T, GRRegs:$F),
1170 (SELECT_CC (EQ_2rus GRRegs:$lhs, immUs:$rhs), GRRegs:$F, GRRegs:$T)>;
1173 /// setcc patterns, only matched when none of the above brcond
1177 // setcc 2 register operands
1178 def : Pat<(setle GRRegs:$lhs, GRRegs:$rhs),
1179 (EQ_2rus (LSS_3r GRRegs:$rhs, GRRegs:$lhs), 0)>;
1180 def : Pat<(setule GRRegs:$lhs, GRRegs:$rhs),
1181 (EQ_2rus (LSU_3r GRRegs:$rhs, GRRegs:$lhs), 0)>;
1183 def : Pat<(setgt GRRegs:$lhs, GRRegs:$rhs),
1184 (LSS_3r GRRegs:$rhs, GRRegs:$lhs)>;
1185 def : Pat<(setugt GRRegs:$lhs, GRRegs:$rhs),
1186 (LSU_3r GRRegs:$rhs, GRRegs:$lhs)>;
1188 def : Pat<(setge GRRegs:$lhs, GRRegs:$rhs),
1189 (EQ_2rus (LSS_3r GRRegs:$lhs, GRRegs:$rhs), 0)>;
1190 def : Pat<(setuge GRRegs:$lhs, GRRegs:$rhs),
1191 (EQ_2rus (LSU_3r GRRegs:$lhs, GRRegs:$rhs), 0)>;
1193 def : Pat<(setlt GRRegs:$lhs, GRRegs:$rhs),
1194 (LSS_3r GRRegs:$lhs, GRRegs:$rhs)>;
1195 def : Pat<(setult GRRegs:$lhs, GRRegs:$rhs),
1196 (LSU_3r GRRegs:$lhs, GRRegs:$rhs)>;
1198 def : Pat<(setne GRRegs:$lhs, GRRegs:$rhs),
1199 (EQ_2rus (EQ_3r GRRegs:$lhs, GRRegs:$rhs), 0)>;
1201 def : Pat<(seteq GRRegs:$lhs, GRRegs:$rhs),
1202 (EQ_3r GRRegs:$lhs, GRRegs:$rhs)>;
1204 // setcc reg/imm operands
1205 def : Pat<(seteq GRRegs:$lhs, immUs:$rhs),
1206 (EQ_2rus GRRegs:$lhs, immUs:$rhs)>;
1207 def : Pat<(setne GRRegs:$lhs, immUs:$rhs),
1208 (EQ_2rus (EQ_2rus GRRegs:$lhs, immUs:$rhs), 0)>;
1211 def : Pat<(add GRRegs:$addr, immUs4:$offset),
1212 (LDAWF_l2rus GRRegs:$addr, (div4_xform immUs4:$offset))>;
1214 def : Pat<(sub GRRegs:$addr, immUs4:$offset),
1215 (LDAWB_l2rus GRRegs:$addr, (div4_xform immUs4:$offset))>;
1217 def : Pat<(and GRRegs:$val, immMskBitp:$mask),
1218 (ZEXT_rus GRRegs:$val, (msksize_xform immMskBitp:$mask))>;
1220 // (sub X, imm) gets canonicalized to (add X, -imm). Match this form.
1221 def : Pat<(add GRRegs:$src1, immUsNeg:$src2),
1222 (SUB_2rus GRRegs:$src1, (neg_xform immUsNeg:$src2))>;
1224 def : Pat<(add GRRegs:$src1, immUs4Neg:$src2),
1225 (LDAWB_l2rus GRRegs:$src1, (div4neg_xform immUs4Neg:$src2))>;
1231 def : Pat<(mul GRRegs:$src, 3),
1232 (LDA16F_l3r GRRegs:$src, GRRegs:$src)>;
1234 def : Pat<(mul GRRegs:$src, 5),
1235 (LDAWF_l3r GRRegs:$src, GRRegs:$src)>;
1237 def : Pat<(mul GRRegs:$src, -3),
1238 (LDAWB_l3r GRRegs:$src, GRRegs:$src)>;
1240 // ashr X, 32 is equivalent to ashr X, 31 on the XCore.
1241 def : Pat<(sra GRRegs:$src, 31),
1242 (ASHR_l2rus GRRegs:$src, 32)>;
1244 def : Pat<(brcond (setlt GRRegs:$lhs, 0), bb:$dst),
1245 (BRFT_lru6 (ASHR_l2rus GRRegs:$lhs, 32), bb:$dst)>;
1247 // setge X, 0 is canonicalized to setgt X, -1
1248 def : Pat<(brcond (setgt GRRegs:$lhs, -1), bb:$dst),
1249 (BRFF_lru6 (ASHR_l2rus GRRegs:$lhs, 32), bb:$dst)>;
1251 def : Pat<(select (setlt GRRegs:$lhs, 0), GRRegs:$T, GRRegs:$F),
1252 (SELECT_CC (ASHR_l2rus GRRegs:$lhs, 32), GRRegs:$T, GRRegs:$F)>;
1254 def : Pat<(select (setgt GRRegs:$lhs, -1), GRRegs:$T, GRRegs:$F),
1255 (SELECT_CC (ASHR_l2rus GRRegs:$lhs, 32), GRRegs:$F, GRRegs:$T)>;
1257 def : Pat<(setgt GRRegs:$lhs, -1),
1258 (EQ_2rus (ASHR_l2rus GRRegs:$lhs, 32), 0)>;
1260 def : Pat<(sra (shl GRRegs:$src, immBpwSubBitp:$imm), immBpwSubBitp:$imm),
1261 (SEXT_rus GRRegs:$src, (bpwsub_xform immBpwSubBitp:$imm))>;