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]>;
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,
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], []>;
177 def ADDRdpii : ComplexPattern<i32, 2, "SelectADDRdpii", [add, dprelwrapper],
179 def ADDRcpii : ComplexPattern<i32, 2, "SelectADDRcpii", [add, cprelwrapper],
183 def MEMii : Operand<i32> {
184 let PrintMethod = "printMemOperand";
185 let MIOperandInfo = (ops i32imm, i32imm);
189 def InlineJT : Operand<i32> {
190 let PrintMethod = "printInlineJT";
193 def InlineJT32 : Operand<i32> {
194 let PrintMethod = "printInlineJT32";
197 //===----------------------------------------------------------------------===//
198 // Instruction Class Templates
199 //===----------------------------------------------------------------------===//
201 // Three operand short
203 multiclass F3R_2RUS<string OpcStr, SDNode OpNode> {
205 (outs GRRegs:$dst), (ins GRRegs:$b, GRRegs:$c),
206 !strconcat(OpcStr, " $dst, $b, $c"),
207 [(set GRRegs:$dst, (OpNode GRRegs:$b, GRRegs:$c))]>;
209 (outs GRRegs:$dst), (ins GRRegs:$b, i32imm:$c),
210 !strconcat(OpcStr, " $dst, $b, $c"),
211 [(set GRRegs:$dst, (OpNode GRRegs:$b, immUs:$c))]>;
214 multiclass F3R_2RUS_np<string OpcStr> {
216 (outs GRRegs:$dst), (ins GRRegs:$b, GRRegs:$c),
217 !strconcat(OpcStr, " $dst, $b, $c"),
220 (outs GRRegs:$dst), (ins GRRegs:$b, i32imm:$c),
221 !strconcat(OpcStr, " $dst, $b, $c"),
225 multiclass F3R_2RBITP<string OpcStr, SDNode OpNode> {
227 (outs GRRegs:$dst), (ins GRRegs:$b, GRRegs:$c),
228 !strconcat(OpcStr, " $dst, $b, $c"),
229 [(set GRRegs:$dst, (OpNode GRRegs:$b, GRRegs:$c))]>;
231 (outs GRRegs:$dst), (ins GRRegs:$b, i32imm:$c),
232 !strconcat(OpcStr, " $dst, $b, $c"),
233 [(set GRRegs:$dst, (OpNode GRRegs:$b, immBitp:$c))]>;
236 class F3R<string OpcStr, SDNode OpNode> : _F3R<
237 (outs GRRegs:$dst), (ins GRRegs:$b, GRRegs:$c),
238 !strconcat(OpcStr, " $dst, $b, $c"),
239 [(set GRRegs:$dst, (OpNode GRRegs:$b, GRRegs:$c))]>;
241 class F3R_np<string OpcStr> : _F3R<
242 (outs GRRegs:$dst), (ins GRRegs:$b, GRRegs:$c),
243 !strconcat(OpcStr, " $dst, $b, $c"),
245 // Three operand long
247 /// FL3R_L2RUS multiclass - Define a normal FL3R/FL2RUS pattern in one shot.
248 multiclass FL3R_L2RUS<string OpcStr, SDNode OpNode> {
250 (outs GRRegs:$dst), (ins GRRegs:$b, GRRegs:$c),
251 !strconcat(OpcStr, " $dst, $b, $c"),
252 [(set GRRegs:$dst, (OpNode GRRegs:$b, GRRegs:$c))]>;
253 def _l2rus : _FL2RUS<
254 (outs GRRegs:$dst), (ins GRRegs:$b, i32imm:$c),
255 !strconcat(OpcStr, " $dst, $b, $c"),
256 [(set GRRegs:$dst, (OpNode GRRegs:$b, immUs:$c))]>;
259 /// FL3R_L2RUS multiclass - Define a normal FL3R/FL2RUS pattern in one shot.
260 multiclass FL3R_L2RBITP<string OpcStr, SDNode OpNode> {
262 (outs GRRegs:$dst), (ins GRRegs:$b, GRRegs:$c),
263 !strconcat(OpcStr, " $dst, $b, $c"),
264 [(set GRRegs:$dst, (OpNode GRRegs:$b, GRRegs:$c))]>;
265 def _l2rus : _FL2RUS<
266 (outs GRRegs:$dst), (ins GRRegs:$b, i32imm:$c),
267 !strconcat(OpcStr, " $dst, $b, $c"),
268 [(set GRRegs:$dst, (OpNode GRRegs:$b, immBitp:$c))]>;
271 class FL3R<string OpcStr, SDNode OpNode> : _FL3R<
272 (outs GRRegs:$dst), (ins GRRegs:$b, GRRegs:$c),
273 !strconcat(OpcStr, " $dst, $b, $c"),
274 [(set GRRegs:$dst, (OpNode GRRegs:$b, GRRegs:$c))]>;
277 // Operand register - U6
278 multiclass FRU6_LRU6_branch<string OpcStr> {
280 (outs), (ins GRRegs:$cond, brtarget:$dest),
281 !strconcat(OpcStr, " $cond, $dest"),
284 (outs), (ins GRRegs:$cond, brtarget:$dest),
285 !strconcat(OpcStr, " $cond, $dest"),
289 multiclass FRU6_LRU6_cp<string OpcStr> {
291 (outs GRRegs:$dst), (ins i32imm:$a),
292 !strconcat(OpcStr, " $dst, cp[$a]"),
295 (outs GRRegs:$dst), (ins i32imm:$a),
296 !strconcat(OpcStr, " $dst, cp[$a]"),
301 multiclass FU6_LU6<string OpcStr, SDNode OpNode> {
303 (outs), (ins i32imm:$b),
304 !strconcat(OpcStr, " $b"),
305 [(OpNode immU6:$b)]>;
307 (outs), (ins i32imm:$b),
308 !strconcat(OpcStr, " $b"),
309 [(OpNode immU16:$b)]>;
311 multiclass FU6_LU6_int<string OpcStr, Intrinsic Int> {
313 (outs), (ins i32imm:$b),
314 !strconcat(OpcStr, " $b"),
317 (outs), (ins i32imm:$b),
318 !strconcat(OpcStr, " $b"),
322 multiclass FU6_LU6_np<string OpcStr> {
324 (outs), (ins i32imm:$b),
325 !strconcat(OpcStr, " $b"),
328 (outs), (ins i32imm:$b),
329 !strconcat(OpcStr, " $b"),
334 multiclass FU10_LU10_np<string OpcStr> {
336 (outs), (ins i32imm:$b),
337 !strconcat(OpcStr, " $b"),
340 (outs), (ins i32imm:$b),
341 !strconcat(OpcStr, " $b"),
347 class F2R_np<string OpcStr> : _F2R<
348 (outs GRRegs:$dst), (ins GRRegs:$b),
349 !strconcat(OpcStr, " $dst, $b"),
354 //===----------------------------------------------------------------------===//
355 // Pseudo Instructions
356 //===----------------------------------------------------------------------===//
358 let Defs = [SP], Uses = [SP] in {
359 def ADJCALLSTACKDOWN : PseudoInstXCore<(outs), (ins i32imm:$amt),
360 "${:comment} ADJCALLSTACKDOWN $amt",
361 [(callseq_start timm:$amt)]>;
362 def ADJCALLSTACKUP : PseudoInstXCore<(outs), (ins i32imm:$amt1, i32imm:$amt2),
363 "${:comment} ADJCALLSTACKUP $amt1",
364 [(callseq_end timm:$amt1, timm:$amt2)]>;
367 def LDWFI : PseudoInstXCore<(outs GRRegs:$dst), (ins MEMii:$addr),
368 "${:comment} LDWFI $dst, $addr",
369 [(set GRRegs:$dst, (load ADDRspii:$addr))]>;
371 def LDAWFI : PseudoInstXCore<(outs GRRegs:$dst), (ins MEMii:$addr),
372 "${:comment} LDAWFI $dst, $addr",
373 [(set GRRegs:$dst, ADDRspii:$addr)]>;
375 def STWFI : PseudoInstXCore<(outs), (ins GRRegs:$src, MEMii:$addr),
376 "${:comment} STWFI $src, $addr",
377 [(store GRRegs:$src, ADDRspii:$addr)]>;
379 // SELECT_CC_* - Used to implement the SELECT_CC DAG operation. Expanded after
380 // instruction selection into a branch sequence.
381 let usesCustomInserter = 1 in {
382 def SELECT_CC : PseudoInstXCore<(outs GRRegs:$dst),
383 (ins GRRegs:$cond, GRRegs:$T, GRRegs:$F),
384 "${:comment} SELECT_CC PSEUDO!",
386 (select GRRegs:$cond, GRRegs:$T, GRRegs:$F))]>;
389 //===----------------------------------------------------------------------===//
391 //===----------------------------------------------------------------------===//
393 // Three operand short
394 defm ADD : F3R_2RUS<"add", add>;
395 defm SUB : F3R_2RUS<"sub", sub>;
396 let neverHasSideEffects = 1 in {
397 defm EQ : F3R_2RUS_np<"eq">;
398 def LSS_3r : F3R_np<"lss">;
399 def LSU_3r : F3R_np<"lsu">;
401 def AND_3r : F3R<"and", and>;
402 def OR_3r : F3R<"or", or>;
405 def LDW_3r : _F3R<(outs GRRegs:$dst), (ins GRRegs:$addr, GRRegs:$offset),
406 "ldw $dst, $addr[$offset]",
409 def LDW_2rus : _F2RUS<(outs GRRegs:$dst), (ins GRRegs:$addr, i32imm:$offset),
410 "ldw $dst, $addr[$offset]",
413 def LD16S_3r : _F3R<(outs GRRegs:$dst), (ins GRRegs:$addr, GRRegs:$offset),
414 "ld16s $dst, $addr[$offset]",
417 def LD8U_3r : _F3R<(outs GRRegs:$dst), (ins GRRegs:$addr, GRRegs:$offset),
418 "ld8u $dst, $addr[$offset]",
423 def STW_3r : _F3R<(outs), (ins GRRegs:$val, GRRegs:$addr, GRRegs:$offset),
424 "stw $val, $addr[$offset]",
427 def STW_2rus : _F2RUS<(outs), (ins GRRegs:$val, GRRegs:$addr, i32imm:$offset),
428 "stw $val, $addr[$offset]",
432 defm SHL : F3R_2RBITP<"shl", shl>;
433 defm SHR : F3R_2RBITP<"shr", srl>;
436 // Three operand long
437 def LDAWF_l3r : _FL3R<(outs GRRegs:$dst), (ins GRRegs:$addr, GRRegs:$offset),
438 "ldaw $dst, $addr[$offset]",
439 [(set GRRegs:$dst, (ldawf GRRegs:$addr, GRRegs:$offset))]>;
441 let neverHasSideEffects = 1 in
442 def LDAWF_l2rus : _FL2RUS<(outs GRRegs:$dst),
443 (ins GRRegs:$addr, i32imm:$offset),
444 "ldaw $dst, $addr[$offset]",
447 def LDAWB_l3r : _FL3R<(outs GRRegs:$dst), (ins GRRegs:$addr, GRRegs:$offset),
448 "ldaw $dst, $addr[-$offset]",
449 [(set GRRegs:$dst, (ldawb GRRegs:$addr, GRRegs:$offset))]>;
451 let neverHasSideEffects = 1 in
452 def LDAWB_l2rus : _FL2RUS<(outs GRRegs:$dst),
453 (ins GRRegs:$addr, i32imm:$offset),
454 "ldaw $dst, $addr[-$offset]",
457 def LDA16F_l3r : _FL3R<(outs GRRegs:$dst), (ins GRRegs:$addr, GRRegs:$offset),
458 "lda16 $dst, $addr[$offset]",
459 [(set GRRegs:$dst, (lda16f GRRegs:$addr, GRRegs:$offset))]>;
461 def LDA16B_l3r : _FL3R<(outs GRRegs:$dst), (ins GRRegs:$addr, GRRegs:$offset),
462 "lda16 $dst, $addr[-$offset]",
463 [(set GRRegs:$dst, (lda16b GRRegs:$addr, GRRegs:$offset))]>;
465 def MUL_l3r : FL3R<"mul", mul>;
466 // Instructions which may trap are marked as side effecting.
467 let hasSideEffects = 1 in {
468 def DIVS_l3r : FL3R<"divs", sdiv>;
469 def DIVU_l3r : FL3R<"divu", udiv>;
470 def REMS_l3r : FL3R<"rems", srem>;
471 def REMU_l3r : FL3R<"remu", urem>;
473 def XOR_l3r : FL3R<"xor", xor>;
474 defm ASHR : FL3R_L2RBITP<"ashr", sra>;
475 // TODO crc32, crc8, inpw, outpw
477 def ST16_l3r : _FL3R<(outs), (ins GRRegs:$val, GRRegs:$addr, GRRegs:$offset),
478 "st16 $val, $addr[$offset]",
481 def ST8_l3r : _FL3R<(outs), (ins GRRegs:$val, GRRegs:$addr, GRRegs:$offset),
482 "st8 $val, $addr[$offset]",
487 let Constraints = "$src1 = $dst1,$src2 = $dst2" in {
488 def MACCU_l4r : _L4R<(outs GRRegs:$dst1, GRRegs:$dst2),
489 (ins GRRegs:$src1, GRRegs:$src2, GRRegs:$src3,
491 "maccu $dst1, $dst2, $src3, $src4",
494 def MACCS_l4r : _L4R<(outs GRRegs:$dst1, GRRegs:$dst2),
495 (ins GRRegs:$src1, GRRegs:$src2, GRRegs:$src3,
497 "maccs $dst1, $dst2, $src3, $src4",
503 def LADD_l5r : _L5R<(outs GRRegs:$dst1, GRRegs:$dst2),
504 (ins GRRegs:$src1, GRRegs:$src2, GRRegs:$src3),
505 "ladd $dst1, $dst2, $src1, $src2, $src3",
508 def LSUB_l5r : _L5R<(outs GRRegs:$dst1, GRRegs:$dst2),
509 (ins GRRegs:$src1, GRRegs:$src2, GRRegs:$src3),
510 "lsub $dst1, $dst2, $src1, $src2, $src3",
513 def LDIV_l5r : _L5R<(outs GRRegs:$dst1, GRRegs:$dst2),
514 (ins GRRegs:$src1, GRRegs:$src2, GRRegs:$src3),
515 "ldiv $dst1, $dst2, $src1, $src2, $src3",
520 def LMUL_l6r : _L6R<(outs GRRegs:$dst1, GRRegs:$dst2),
521 (ins GRRegs:$src1, GRRegs:$src2, GRRegs:$src3,
523 "lmul $dst1, $dst2, $src1, $src2, $src3, $src4",
528 //let Uses = [DP] in ...
529 let neverHasSideEffects = 1, isReMaterializable = 1 in
530 def LDAWDP_ru6: _FRU6<(outs GRRegs:$dst), (ins MEMii:$a),
534 let isReMaterializable = 1 in
535 def LDAWDP_lru6: _FLRU6<
536 (outs GRRegs:$dst), (ins MEMii:$a),
538 [(set GRRegs:$dst, ADDRdpii:$a)]>;
541 def LDWDP_ru6: _FRU6<(outs GRRegs:$dst), (ins MEMii:$a),
545 def LDWDP_lru6: _FLRU6<
546 (outs GRRegs:$dst), (ins MEMii:$a),
548 [(set GRRegs:$dst, (load ADDRdpii:$a))]>;
551 def STWDP_ru6 : _FRU6<(outs), (ins GRRegs:$val, MEMii:$addr),
552 "stw $val, dp[$addr]",
555 def STWDP_lru6 : _FLRU6<(outs), (ins GRRegs:$val, MEMii:$addr),
556 "stw $val, dp[$addr]",
557 [(store GRRegs:$val, ADDRdpii:$addr)]>;
559 //let Uses = [CP] in ..
560 let mayLoad = 1, isReMaterializable = 1 in
561 defm LDWCP : FRU6_LRU6_cp<"ldw">;
565 def STWSP_ru6 : _FRU6<
566 (outs), (ins GRRegs:$val, i32imm:$index),
567 "stw $val, sp[$index]",
568 [(XCoreStwsp GRRegs:$val, immU6:$index)]>;
570 def STWSP_lru6 : _FLRU6<
571 (outs), (ins GRRegs:$val, i32imm:$index),
572 "stw $val, sp[$index]",
573 [(XCoreStwsp GRRegs:$val, immU16:$index)]>;
577 def LDWSP_ru6 : _FRU6<
578 (outs GRRegs:$dst), (ins i32imm:$b),
582 def LDWSP_lru6 : _FLRU6<
583 (outs GRRegs:$dst), (ins i32imm:$b),
588 let neverHasSideEffects = 1 in {
589 def LDAWSP_ru6 : _FRU6<
590 (outs GRRegs:$dst), (ins i32imm:$b),
594 def LDAWSP_lru6 : _FLRU6<
595 (outs GRRegs:$dst), (ins i32imm:$b),
599 def LDAWSP_ru6_RRegs : _FRU6<
600 (outs RRegs:$dst), (ins i32imm:$b),
604 def LDAWSP_lru6_RRegs : _FLRU6<
605 (outs RRegs:$dst), (ins i32imm:$b),
611 let isReMaterializable = 1 in {
613 (outs GRRegs:$dst), (ins i32imm:$b),
615 [(set GRRegs:$dst, immU6:$b)]>;
617 def LDC_lru6 : _FLRU6<
618 (outs GRRegs:$dst), (ins i32imm:$b),
620 [(set GRRegs:$dst, immU16:$b)]>;
623 def SETC_ru6 : _FRU6<(outs), (ins GRRegs:$r, i32imm:$val),
624 "setc res[$r], $val",
625 [(int_xcore_setc GRRegs:$r, immU6:$val)]>;
627 def SETC_lru6 : _FLRU6<(outs), (ins GRRegs:$r, i32imm:$val),
628 "setc res[$r], $val",
629 [(int_xcore_setc GRRegs:$r, immU16:$val)]>;
631 // Operand register - U6
632 let isBranch = 1, isTerminator = 1 in {
633 defm BRFT: FRU6_LRU6_branch<"bt">;
634 defm BRBT: FRU6_LRU6_branch<"bt">;
635 defm BRFF: FRU6_LRU6_branch<"bf">;
636 defm BRBF: FRU6_LRU6_branch<"bf">;
640 let Defs = [SP], Uses = [SP] in {
641 let neverHasSideEffects = 1 in
642 defm EXTSP : FU6_LU6_np<"extsp">;
644 defm ENTSP : FU6_LU6_np<"entsp">;
646 let isReturn = 1, isTerminator = 1, mayLoad = 1, isBarrier = 1 in {
647 defm RETSP : FU6_LU6<"retsp", XCoreRetsp>;
651 // TODO extdp, kentsp, krestsp, blat
653 let isBranch = 1, isTerminator = 1, isBarrier = 1 in {
656 (ins brtarget:$target),
660 def BRBU_lu6 : _FLU6<
662 (ins brtarget:$target),
668 (ins brtarget:$target),
672 def BRFU_lu6 : _FLU6<
674 (ins brtarget:$target),
679 //let Uses = [CP] in ...
680 let Defs = [R11], neverHasSideEffects = 1, isReMaterializable = 1 in
681 def LDAWCP_u6: _FRU6<(outs), (ins MEMii:$a),
685 let Defs = [R11], isReMaterializable = 1 in
686 def LDAWCP_lu6: _FLRU6<
687 (outs), (ins MEMii:$a),
689 [(set R11, ADDRcpii:$a)]>;
691 defm SETSR : FU6_LU6_int<"setsr", int_xcore_setsr>;
693 defm CLRSR : FU6_LU6_int<"clrsr", int_xcore_clrsr>;
695 // setsr may cause a branch if it is used to enable events. clrsr may
696 // branch if it is executed while events are enabled.
697 let isBranch=1, isIndirectBranch=1, isTerminator=1, isBarrier = 1 in {
698 defm SETSR_branch : FU6_LU6_np<"setsr">;
699 defm CLRSR_branch : FU6_LU6_np<"clrsr">;
703 // TODO ldwcpl, blacp
705 let Defs = [R11], isReMaterializable = 1, neverHasSideEffects = 1 in
706 def LDAP_u10 : _FU10<
712 let Defs = [R11], isReMaterializable = 1 in
713 def LDAP_lu10 : _FLU10<
717 [(set R11, (pcrelwrapper tglobaladdr:$addr))]>;
719 let Defs = [R11], isReMaterializable = 1 in
720 def LDAP_lu10_ba : _FLU10<(outs),
723 [(set R11, (pcrelwrapper tblockaddress:$addr))]>;
726 // All calls clobber the link register and the non-callee-saved registers:
727 Defs = [R0, R1, R2, R3, R11, LR] in {
730 (ins calltarget:$target, variable_ops),
732 [(XCoreBranchLink immU10:$target)]>;
734 def BL_lu10 : _FLU10<
736 (ins calltarget:$target, variable_ops),
738 [(XCoreBranchLink immU20:$target)]>;
742 // TODO eet, eef, testwct, tsetmr, sext (reg), zext (reg)
743 def NOT : _F2R<(outs GRRegs:$dst), (ins GRRegs:$b),
745 [(set GRRegs:$dst, (not GRRegs:$b))]>;
747 def NEG : _F2R<(outs GRRegs:$dst), (ins GRRegs:$b),
749 [(set GRRegs:$dst, (ineg GRRegs:$b))]>;
751 let Constraints = "$src1 = $dst" in {
752 let neverHasSideEffects = 1 in
753 def SEXT_rus : _FRUS<(outs GRRegs:$dst), (ins GRRegs:$src1, i32imm:$src2),
757 let neverHasSideEffects = 1 in
758 def ZEXT_rus : _FRUS<(outs GRRegs:$dst), (ins GRRegs:$src1, i32imm:$src2),
762 def ANDNOT_2r : _F2R<(outs GRRegs:$dst), (ins GRRegs:$src1, GRRegs:$src2),
763 "andnot $dst, $src2",
764 [(set GRRegs:$dst, (and GRRegs:$src1, (not GRRegs:$src2)))]>;
767 let isReMaterializable = 1, neverHasSideEffects = 1 in
768 def MKMSK_rus : _FRUS<(outs GRRegs:$dst), (ins i32imm:$size),
772 def MKMSK_2r : _FRUS<(outs GRRegs:$dst), (ins GRRegs:$size),
774 [(set GRRegs:$dst, (add (shl 1, GRRegs:$size), 0xffffffff))]>;
776 def GETR_rus : _FRUS<(outs GRRegs:$dst), (ins i32imm:$type),
778 [(set GRRegs:$dst, (int_xcore_getr immUs:$type))]>;
780 def GETTS_2r : _F2R<(outs GRRegs:$dst), (ins GRRegs:$r),
781 "getts $dst, res[$r]",
782 [(set GRRegs:$dst, (int_xcore_getts GRRegs:$r))]>;
784 def SETPT_2r : _F2R<(outs), (ins GRRegs:$r, GRRegs:$val),
785 "setpt res[$r], $val",
786 [(int_xcore_setpt GRRegs:$r, GRRegs:$val)]>;
788 def OUTCT_2r : _F2R<(outs), (ins GRRegs:$r, GRRegs:$val),
789 "outct res[$r], $val",
790 [(int_xcore_outct GRRegs:$r, GRRegs:$val)]>;
792 def OUTCT_rus : _F2R<(outs), (ins GRRegs:$r, i32imm:$val),
793 "outct res[$r], $val",
794 [(int_xcore_outct GRRegs:$r, immUs:$val)]>;
796 def OUTT_2r : _F2R<(outs), (ins GRRegs:$r, GRRegs:$val),
797 "outt res[$r], $val",
798 [(int_xcore_outt GRRegs:$r, GRRegs:$val)]>;
800 def OUT_2r : _F2R<(outs), (ins GRRegs:$r, GRRegs:$val),
802 [(int_xcore_out GRRegs:$r, GRRegs:$val)]>;
804 let Constraints = "$src = $dst" in
805 def OUTSHR_2r : _F2R<(outs GRRegs:$dst), (ins GRRegs:$r, GRRegs:$src),
806 "outshr res[$r], $src",
807 [(set GRRegs:$dst, (int_xcore_outshr GRRegs:$r, GRRegs:$src))]>;
809 def INCT_2r : _F2R<(outs GRRegs:$dst), (ins GRRegs:$r),
810 "inct $dst, res[$r]",
811 [(set GRRegs:$dst, (int_xcore_inct GRRegs:$r))]>;
813 def INT_2r : _F2R<(outs GRRegs:$dst), (ins GRRegs:$r),
815 [(set GRRegs:$dst, (int_xcore_int GRRegs:$r))]>;
817 def IN_2r : _F2R<(outs GRRegs:$dst), (ins GRRegs:$r),
819 [(set GRRegs:$dst, (int_xcore_in GRRegs:$r))]>;
821 let Constraints = "$src = $dst" in
822 def INSHR_2r : _F2R<(outs GRRegs:$dst), (ins GRRegs:$r, GRRegs:$src),
823 "inshr $dst, res[$r]",
824 [(set GRRegs:$dst, (int_xcore_inshr GRRegs:$r, GRRegs:$src))]>;
826 def CHKCT_2r : _F2R<(outs), (ins GRRegs:$r, GRRegs:$val),
827 "chkct res[$r], $val",
828 [(int_xcore_chkct GRRegs:$r, GRRegs:$val)]>;
830 def CHKCT_rus : _F2R<(outs), (ins GRRegs:$r, i32imm:$val),
831 "chkct res[$r], $val",
832 [(int_xcore_chkct GRRegs:$r, immUs:$val)]>;
834 def SETD_2r : _F2R<(outs), (ins GRRegs:$r, GRRegs:$val),
835 "setd res[$r], $val",
836 [(int_xcore_setd GRRegs:$r, GRRegs:$val)]>;
838 def GETST_2r : _F2R<(outs GRRegs:$dst), (ins GRRegs:$r),
839 "getst $dst, res[$r]",
840 [(set GRRegs:$dst, (int_xcore_getst GRRegs:$r))]>;
842 def INITSP_2r : _F2R<(outs), (ins GRRegs:$t, GRRegs:$src),
843 "init t[$t]:sp, $src",
844 [(int_xcore_initsp GRRegs:$t, GRRegs:$src)]>;
846 def INITPC_2r : _F2R<(outs), (ins GRRegs:$t, GRRegs:$src),
847 "init t[$t]:pc, $src",
848 [(int_xcore_initpc GRRegs:$t, GRRegs:$src)]>;
850 def INITCP_2r : _F2R<(outs), (ins GRRegs:$t, GRRegs:$src),
851 "init t[$t]:cp, $src",
852 [(int_xcore_initcp GRRegs:$t, GRRegs:$src)]>;
854 def INITDP_2r : _F2R<(outs), (ins GRRegs:$t, GRRegs:$src),
855 "init t[$t]:dp, $src",
856 [(int_xcore_initdp GRRegs:$t, GRRegs:$src)]>;
861 def BITREV_l2r : _FL2R<(outs GRRegs:$dst), (ins GRRegs:$src),
863 [(set GRRegs:$dst, (int_xcore_bitrev GRRegs:$src))]>;
865 def BYTEREV_l2r : _FL2R<(outs GRRegs:$dst), (ins GRRegs:$src),
866 "byterev $dst, $src",
867 [(set GRRegs:$dst, (bswap GRRegs:$src))]>;
869 def CLZ_l2r : _FL2R<(outs GRRegs:$dst), (ins GRRegs:$src),
871 [(set GRRegs:$dst, (ctlz GRRegs:$src))]>;
873 def SETC_l2r : _FL2R<(outs), (ins GRRegs:$r, GRRegs:$val),
874 "setc res[$r], $val",
875 [(int_xcore_setc GRRegs:$r, GRRegs:$val)]>;
877 def SETTW_l2r : _FL2R<(outs), (ins GRRegs:$r, GRRegs:$val),
878 "settw res[$r], $val",
879 [(int_xcore_settw GRRegs:$r, GRRegs:$val)]>;
881 def GETPS_l2r : _FL2R<(outs GRRegs:$dst), (ins GRRegs:$src),
882 "get $dst, ps[$src]",
883 [(set GRRegs:$dst, (int_xcore_getps GRRegs:$src))]>;
885 def SETPS_l2r : _FL2R<(outs), (ins GRRegs:$src1, GRRegs:$src2),
886 "set ps[$src1], $src2",
887 [(int_xcore_setps GRRegs:$src1, GRRegs:$src2)]>;
889 def INITLR_l2r : _FL2R<(outs), (ins GRRegs:$t, GRRegs:$src),
890 "init t[$t]:lr, $src",
891 [(int_xcore_initlr GRRegs:$t, GRRegs:$src)]>;
893 def SETCLK_l2r : _FL2R<(outs), (ins GRRegs:$src1, GRRegs:$src2),
894 "setclk res[$src1], $src2",
895 [(int_xcore_setclk GRRegs:$src1, GRRegs:$src2)]>;
897 def SETRDY_l2r : _FL2R<(outs), (ins GRRegs:$src1, GRRegs:$src2),
898 "setrdy res[$src1], $src2",
899 [(int_xcore_setrdy GRRegs:$src1, GRRegs:$src2)]>;
901 def SETPSC_l2r : _FL2R<(outs), (ins GRRegs:$src1, GRRegs:$src2),
902 "setpsc res[$src1], $src2",
903 [(int_xcore_setpsc GRRegs:$src1, GRRegs:$src2)]>;
906 // TODO edu, eeu, waitet, waitef, tstart, clrtp
907 // setdp, setcp, setev, kcall
909 def MSYNC_1r : _F1R<(outs), (ins GRRegs:$i),
911 [(int_xcore_msync GRRegs:$i)]>;
912 def MJOIN_1r : _F1R<(outs), (ins GRRegs:$i),
914 [(int_xcore_mjoin GRRegs:$i)]>;
916 let isBranch=1, isIndirectBranch=1, isTerminator=1, isBarrier = 1 in
917 def BAU_1r : _F1R<(outs), (ins GRRegs:$addr),
919 [(brind GRRegs:$addr)]>;
921 let isBranch=1, isIndirectBranch=1, isTerminator=1, isBarrier = 1 in
922 def BR_JT : PseudoInstXCore<(outs), (ins InlineJT:$t, GRRegs:$i),
924 [(XCoreBR_JT tjumptable:$t, GRRegs:$i)]>;
926 let isBranch=1, isIndirectBranch=1, isTerminator=1, isBarrier = 1 in
927 def BR_JT32 : PseudoInstXCore<(outs), (ins InlineJT32:$t, GRRegs:$i),
929 [(XCoreBR_JT32 tjumptable:$t, GRRegs:$i)]>;
931 let Defs=[SP], neverHasSideEffects=1 in
932 def SETSP_1r : _F1R<(outs), (ins GRRegs:$src),
936 let hasCtrlDep = 1 in
937 def ECALLT_1r : _F1R<(outs), (ins GRRegs:$src),
941 let hasCtrlDep = 1 in
942 def ECALLF_1r : _F1R<(outs), (ins GRRegs:$src),
947 // All calls clobber the link register and the non-callee-saved registers:
948 Defs = [R0, R1, R2, R3, R11, LR] in {
949 def BLA_1r : _F1R<(outs), (ins GRRegs:$addr, variable_ops),
951 [(XCoreBranchLink GRRegs:$addr)]>;
954 def SYNCR_1r : _F1R<(outs), (ins GRRegs:$r),
956 [(int_xcore_syncr GRRegs:$r)]>;
958 def FREER_1r : _F1R<(outs), (ins GRRegs:$r),
960 [(int_xcore_freer GRRegs:$r)]>;
963 def SETV_1r : _F1R<(outs), (ins GRRegs:$r),
965 [(int_xcore_setv GRRegs:$r, R11)]>;
967 def EEU_1r : _F1R<(outs), (ins GRRegs:$r),
969 [(int_xcore_eeu GRRegs:$r)]>;
971 // Zero operand short
972 // TODO freet, ldspc, stspc, ldssr, stssr, ldsed, stsed,
973 // stet, geted, getet, getkep, getksp, setkep, getid, kret, dcall, dret,
976 def CLRE_0R : _F0R<(outs), (ins), "clre", [(int_xcore_clre)]>;
979 def GETID_0R : _F0R<(outs), (ins),
981 [(set R11, (int_xcore_getid))]>;
983 def SSYNC_0r : _F0R<(outs), (ins),
985 [(int_xcore_ssync)]>;
987 let isBranch=1, isIndirectBranch=1, isTerminator=1, isBarrier = 1,
988 hasSideEffects = 1 in
989 def WAITEU_0R : _F0R<(outs), (ins),
991 [(brind (int_xcore_waitevent))]>;
993 //===----------------------------------------------------------------------===//
994 // Non-Instruction Patterns
995 //===----------------------------------------------------------------------===//
997 def : Pat<(XCoreBranchLink tglobaladdr:$addr), (BL_lu10 tglobaladdr:$addr)>;
998 def : Pat<(XCoreBranchLink texternalsym:$addr), (BL_lu10 texternalsym:$addr)>;
1001 def : Pat<(sext_inreg GRRegs:$b, i1), (SEXT_rus GRRegs:$b, 1)>;
1002 def : Pat<(sext_inreg GRRegs:$b, i8), (SEXT_rus GRRegs:$b, 8)>;
1003 def : Pat<(sext_inreg GRRegs:$b, i16), (SEXT_rus GRRegs:$b, 16)>;
1006 def : Pat<(zextloadi8 (add GRRegs:$addr, GRRegs:$offset)),
1007 (LD8U_3r GRRegs:$addr, GRRegs:$offset)>;
1008 def : Pat<(zextloadi8 GRRegs:$addr), (LD8U_3r GRRegs:$addr, (LDC_ru6 0))>;
1010 def : Pat<(sextloadi16 (lda16f GRRegs:$addr, GRRegs:$offset)),
1011 (LD16S_3r GRRegs:$addr, GRRegs:$offset)>;
1012 def : Pat<(sextloadi16 GRRegs:$addr), (LD16S_3r GRRegs:$addr, (LDC_ru6 0))>;
1014 def : Pat<(load (ldawf GRRegs:$addr, GRRegs:$offset)),
1015 (LDW_3r GRRegs:$addr, GRRegs:$offset)>;
1016 def : Pat<(load (add GRRegs:$addr, immUs4:$offset)),
1017 (LDW_2rus GRRegs:$addr, (div4_xform immUs4:$offset))>;
1018 def : Pat<(load GRRegs:$addr), (LDW_2rus GRRegs:$addr, 0)>;
1021 def : Pat<(extloadi8 (add GRRegs:$addr, GRRegs:$offset)),
1022 (LD8U_3r GRRegs:$addr, GRRegs:$offset)>;
1023 def : Pat<(extloadi8 GRRegs:$addr), (LD8U_3r GRRegs:$addr, (LDC_ru6 0))>;
1024 def : Pat<(extloadi16 (lda16f GRRegs:$addr, GRRegs:$offset)),
1025 (LD16S_3r GRRegs:$addr, GRRegs:$offset)>;
1026 def : Pat<(extloadi16 GRRegs:$addr), (LD16S_3r GRRegs:$addr, (LDC_ru6 0))>;
1029 def : Pat<(truncstorei8 GRRegs:$val, (add GRRegs:$addr, GRRegs:$offset)),
1030 (ST8_l3r GRRegs:$val, GRRegs:$addr, GRRegs:$offset)>;
1031 def : Pat<(truncstorei8 GRRegs:$val, GRRegs:$addr),
1032 (ST8_l3r GRRegs:$val, GRRegs:$addr, (LDC_ru6 0))>;
1034 def : Pat<(truncstorei16 GRRegs:$val, (lda16f GRRegs:$addr, GRRegs:$offset)),
1035 (ST16_l3r GRRegs:$val, GRRegs:$addr, GRRegs:$offset)>;
1036 def : Pat<(truncstorei16 GRRegs:$val, GRRegs:$addr),
1037 (ST16_l3r GRRegs:$val, GRRegs:$addr, (LDC_ru6 0))>;
1039 def : Pat<(store GRRegs:$val, (ldawf GRRegs:$addr, GRRegs:$offset)),
1040 (STW_3r GRRegs:$val, GRRegs:$addr, GRRegs:$offset)>;
1041 def : Pat<(store GRRegs:$val, (add GRRegs:$addr, immUs4:$offset)),
1042 (STW_2rus GRRegs:$val, GRRegs:$addr, (div4_xform immUs4:$offset))>;
1043 def : Pat<(store GRRegs:$val, GRRegs:$addr),
1044 (STW_2rus GRRegs:$val, GRRegs:$addr, 0)>;
1047 def : Pat<(cttz GRRegs:$src), (CLZ_l2r (BITREV_l2r GRRegs:$src))>;
1050 def : Pat<(trap), (ECALLF_1r (LDC_ru6 0))>;
1056 // unconditional branch
1057 def : Pat<(br bb:$addr), (BRFU_lu6 bb:$addr)>;
1059 // direct match equal/notequal zero brcond
1060 def : Pat<(brcond (setne GRRegs:$lhs, 0), bb:$dst),
1061 (BRFT_lru6 GRRegs:$lhs, bb:$dst)>;
1062 def : Pat<(brcond (seteq GRRegs:$lhs, 0), bb:$dst),
1063 (BRFF_lru6 GRRegs:$lhs, bb:$dst)>;
1065 def : Pat<(brcond (setle GRRegs:$lhs, GRRegs:$rhs), bb:$dst),
1066 (BRFF_lru6 (LSS_3r GRRegs:$rhs, GRRegs:$lhs), bb:$dst)>;
1067 def : Pat<(brcond (setule GRRegs:$lhs, GRRegs:$rhs), bb:$dst),
1068 (BRFF_lru6 (LSU_3r GRRegs:$rhs, GRRegs:$lhs), bb:$dst)>;
1069 def : Pat<(brcond (setge GRRegs:$lhs, GRRegs:$rhs), bb:$dst),
1070 (BRFF_lru6 (LSS_3r GRRegs:$lhs, GRRegs:$rhs), bb:$dst)>;
1071 def : Pat<(brcond (setuge GRRegs:$lhs, GRRegs:$rhs), bb:$dst),
1072 (BRFF_lru6 (LSU_3r GRRegs:$lhs, GRRegs:$rhs), bb:$dst)>;
1073 def : Pat<(brcond (setne GRRegs:$lhs, GRRegs:$rhs), bb:$dst),
1074 (BRFF_lru6 (EQ_3r GRRegs:$lhs, GRRegs:$rhs), bb:$dst)>;
1075 def : Pat<(brcond (setne GRRegs:$lhs, immUs:$rhs), bb:$dst),
1076 (BRFF_lru6 (EQ_2rus GRRegs:$lhs, immUs:$rhs), bb:$dst)>;
1078 // generic brcond pattern
1079 def : Pat<(brcond GRRegs:$cond, bb:$addr), (BRFT_lru6 GRRegs:$cond, bb:$addr)>;
1086 // direct match equal/notequal zero select
1087 def : Pat<(select (setne GRRegs:$lhs, 0), GRRegs:$T, GRRegs:$F),
1088 (SELECT_CC GRRegs:$lhs, GRRegs:$T, GRRegs:$F)>;
1090 def : Pat<(select (seteq GRRegs:$lhs, 0), GRRegs:$T, GRRegs:$F),
1091 (SELECT_CC GRRegs:$lhs, GRRegs:$F, GRRegs:$T)>;
1093 def : Pat<(select (setle GRRegs:$lhs, GRRegs:$rhs), GRRegs:$T, GRRegs:$F),
1094 (SELECT_CC (LSS_3r GRRegs:$rhs, GRRegs:$lhs), GRRegs:$F, GRRegs:$T)>;
1095 def : Pat<(select (setule GRRegs:$lhs, GRRegs:$rhs), GRRegs:$T, GRRegs:$F),
1096 (SELECT_CC (LSU_3r GRRegs:$rhs, GRRegs:$lhs), GRRegs:$F, GRRegs:$T)>;
1097 def : Pat<(select (setge GRRegs:$lhs, GRRegs:$rhs), GRRegs:$T, GRRegs:$F),
1098 (SELECT_CC (LSS_3r GRRegs:$lhs, GRRegs:$rhs), GRRegs:$F, GRRegs:$T)>;
1099 def : Pat<(select (setuge GRRegs:$lhs, GRRegs:$rhs), GRRegs:$T, GRRegs:$F),
1100 (SELECT_CC (LSU_3r GRRegs:$lhs, GRRegs:$rhs), GRRegs:$F, GRRegs:$T)>;
1101 def : Pat<(select (setne GRRegs:$lhs, GRRegs:$rhs), GRRegs:$T, GRRegs:$F),
1102 (SELECT_CC (EQ_3r GRRegs:$lhs, GRRegs:$rhs), GRRegs:$F, GRRegs:$T)>;
1103 def : Pat<(select (setne GRRegs:$lhs, immUs:$rhs), GRRegs:$T, GRRegs:$F),
1104 (SELECT_CC (EQ_2rus GRRegs:$lhs, immUs:$rhs), GRRegs:$F, GRRegs:$T)>;
1107 /// setcc patterns, only matched when none of the above brcond
1111 // setcc 2 register operands
1112 def : Pat<(setle GRRegs:$lhs, GRRegs:$rhs),
1113 (EQ_2rus (LSS_3r GRRegs:$rhs, GRRegs:$lhs), 0)>;
1114 def : Pat<(setule GRRegs:$lhs, GRRegs:$rhs),
1115 (EQ_2rus (LSU_3r GRRegs:$rhs, GRRegs:$lhs), 0)>;
1117 def : Pat<(setgt GRRegs:$lhs, GRRegs:$rhs),
1118 (LSS_3r GRRegs:$rhs, GRRegs:$lhs)>;
1119 def : Pat<(setugt GRRegs:$lhs, GRRegs:$rhs),
1120 (LSU_3r GRRegs:$rhs, GRRegs:$lhs)>;
1122 def : Pat<(setge GRRegs:$lhs, GRRegs:$rhs),
1123 (EQ_2rus (LSS_3r GRRegs:$lhs, GRRegs:$rhs), 0)>;
1124 def : Pat<(setuge GRRegs:$lhs, GRRegs:$rhs),
1125 (EQ_2rus (LSU_3r GRRegs:$lhs, GRRegs:$rhs), 0)>;
1127 def : Pat<(setlt GRRegs:$lhs, GRRegs:$rhs),
1128 (LSS_3r GRRegs:$lhs, GRRegs:$rhs)>;
1129 def : Pat<(setult GRRegs:$lhs, GRRegs:$rhs),
1130 (LSU_3r GRRegs:$lhs, GRRegs:$rhs)>;
1132 def : Pat<(setne GRRegs:$lhs, GRRegs:$rhs),
1133 (EQ_2rus (EQ_3r GRRegs:$lhs, GRRegs:$rhs), 0)>;
1135 def : Pat<(seteq GRRegs:$lhs, GRRegs:$rhs),
1136 (EQ_3r GRRegs:$lhs, GRRegs:$rhs)>;
1138 // setcc reg/imm operands
1139 def : Pat<(seteq GRRegs:$lhs, immUs:$rhs),
1140 (EQ_2rus GRRegs:$lhs, immUs:$rhs)>;
1141 def : Pat<(setne GRRegs:$lhs, immUs:$rhs),
1142 (EQ_2rus (EQ_2rus GRRegs:$lhs, immUs:$rhs), 0)>;
1145 def : Pat<(add GRRegs:$addr, immUs4:$offset),
1146 (LDAWF_l2rus GRRegs:$addr, (div4_xform immUs4:$offset))>;
1148 def : Pat<(sub GRRegs:$addr, immUs4:$offset),
1149 (LDAWB_l2rus GRRegs:$addr, (div4_xform immUs4:$offset))>;
1151 def : Pat<(and GRRegs:$val, immMskBitp:$mask),
1152 (ZEXT_rus GRRegs:$val, (msksize_xform immMskBitp:$mask))>;
1154 // (sub X, imm) gets canonicalized to (add X, -imm). Match this form.
1155 def : Pat<(add GRRegs:$src1, immUsNeg:$src2),
1156 (SUB_2rus GRRegs:$src1, (neg_xform immUsNeg:$src2))>;
1158 def : Pat<(add GRRegs:$src1, immUs4Neg:$src2),
1159 (LDAWB_l2rus GRRegs:$src1, (div4neg_xform immUs4Neg:$src2))>;
1165 def : Pat<(mul GRRegs:$src, 3),
1166 (LDA16F_l3r GRRegs:$src, GRRegs:$src)>;
1168 def : Pat<(mul GRRegs:$src, 5),
1169 (LDAWF_l3r GRRegs:$src, GRRegs:$src)>;
1171 def : Pat<(mul GRRegs:$src, -3),
1172 (LDAWB_l3r GRRegs:$src, GRRegs:$src)>;
1174 // ashr X, 32 is equivalent to ashr X, 31 on the XCore.
1175 def : Pat<(sra GRRegs:$src, 31),
1176 (ASHR_l2rus GRRegs:$src, 32)>;
1178 def : Pat<(brcond (setlt GRRegs:$lhs, 0), bb:$dst),
1179 (BRFT_lru6 (ASHR_l2rus GRRegs:$lhs, 32), bb:$dst)>;
1181 // setge X, 0 is canonicalized to setgt X, -1
1182 def : Pat<(brcond (setgt GRRegs:$lhs, -1), bb:$dst),
1183 (BRFF_lru6 (ASHR_l2rus GRRegs:$lhs, 32), bb:$dst)>;
1185 def : Pat<(select (setlt GRRegs:$lhs, 0), GRRegs:$T, GRRegs:$F),
1186 (SELECT_CC (ASHR_l2rus GRRegs:$lhs, 32), GRRegs:$T, GRRegs:$F)>;
1188 def : Pat<(select (setgt GRRegs:$lhs, -1), GRRegs:$T, GRRegs:$F),
1189 (SELECT_CC (ASHR_l2rus GRRegs:$lhs, 32), GRRegs:$F, GRRegs:$T)>;
1191 def : Pat<(setgt GRRegs:$lhs, -1),
1192 (EQ_2rus (ASHR_l2rus GRRegs:$lhs, 32), 0)>;
1194 def : Pat<(sra (shl GRRegs:$src, immBpwSubBitp:$imm), immBpwSubBitp:$imm),
1195 (SEXT_rus GRRegs:$src, (bpwsub_xform immBpwSubBitp:$imm))>;