XCoreInstrInfo.td revision 251662
1234353Sdim//===-- XCoreInstrInfo.td - Target Description for XCore ---*- tablegen -*-===// 2193323Sed// 3193323Sed// The LLVM Compiler Infrastructure 4193323Sed// 5193323Sed// This file is distributed under the University of Illinois Open Source 6193323Sed// License. See LICENSE.TXT for details. 7193323Sed// 8193323Sed//===----------------------------------------------------------------------===// 9193323Sed// 10193323Sed// This file describes the XCore instructions in TableGen format. 11193323Sed// 12193323Sed//===----------------------------------------------------------------------===// 13193323Sed 14193323Sed// Uses of CP, DP are not currently reflected in the patterns, since 15193323Sed// having a physical register as an operand prevents loop hoisting and 16193323Sed// since the value of these registers never changes during the life of the 17193323Sed// function. 18193323Sed 19193323Sed//===----------------------------------------------------------------------===// 20193323Sed// Instruction format superclass. 21193323Sed//===----------------------------------------------------------------------===// 22193323Sed 23193323Sedinclude "XCoreInstrFormats.td" 24193323Sed 25193323Sed//===----------------------------------------------------------------------===// 26193323Sed// XCore specific DAG Nodes. 27193323Sed// 28193323Sed 29193323Sed// Call 30193323Seddef SDT_XCoreBranchLink : SDTypeProfile<0, 1, [SDTCisPtrTy<0>]>; 31193323Seddef XCoreBranchLink : SDNode<"XCoreISD::BL",SDT_XCoreBranchLink, 32218893Sdim [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue, 33205407Srdivacky SDNPVariadic]>; 34193323Sed 35249423Sdimdef XCoreRetsp : SDNode<"XCoreISD::RETSP", SDTBrind, 36249423Sdim [SDNPHasChain, SDNPOptInGlue, SDNPMayLoad, SDNPVariadic]>; 37193323Sed 38204642Srdivackydef SDT_XCoreBR_JT : SDTypeProfile<0, 2, 39204642Srdivacky [SDTCisVT<0, i32>, SDTCisVT<1, i32>]>; 40204642Srdivacky 41204642Srdivackydef XCoreBR_JT : SDNode<"XCoreISD::BR_JT", SDT_XCoreBR_JT, 42204642Srdivacky [SDNPHasChain]>; 43204642Srdivacky 44204642Srdivackydef XCoreBR_JT32 : SDNode<"XCoreISD::BR_JT32", SDT_XCoreBR_JT, 45204642Srdivacky [SDNPHasChain]>; 46204642Srdivacky 47193323Seddef SDT_XCoreAddress : SDTypeProfile<1, 1, 48193323Sed [SDTCisSameAs<0, 1>, SDTCisPtrTy<0>]>; 49193323Sed 50193323Seddef pcrelwrapper : SDNode<"XCoreISD::PCRelativeWrapper", SDT_XCoreAddress, 51193323Sed []>; 52193323Sed 53193323Seddef dprelwrapper : SDNode<"XCoreISD::DPRelativeWrapper", SDT_XCoreAddress, 54193323Sed []>; 55193323Sed 56193323Seddef cprelwrapper : SDNode<"XCoreISD::CPRelativeWrapper", SDT_XCoreAddress, 57193323Sed []>; 58193323Sed 59193323Seddef SDT_XCoreStwsp : SDTypeProfile<0, 2, [SDTCisInt<1>]>; 60193323Seddef XCoreStwsp : SDNode<"XCoreISD::STWSP", SDT_XCoreStwsp, 61243830Sdim [SDNPHasChain, SDNPMayStore]>; 62193323Sed 63193323Sed// These are target-independent nodes, but have target-specific formats. 64193323Seddef SDT_XCoreCallSeqStart : SDCallSeqStart<[ SDTCisVT<0, i32> ]>; 65193323Seddef SDT_XCoreCallSeqEnd : SDCallSeqEnd<[ SDTCisVT<0, i32>, 66193323Sed SDTCisVT<1, i32> ]>; 67193323Sed 68193323Seddef callseq_start : SDNode<"ISD::CALLSEQ_START", SDT_XCoreCallSeqStart, 69218893Sdim [SDNPHasChain, SDNPOutGlue]>; 70193323Seddef callseq_end : SDNode<"ISD::CALLSEQ_END", SDT_XCoreCallSeqEnd, 71218893Sdim [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue]>; 72193323Sed 73193323Sed//===----------------------------------------------------------------------===// 74193323Sed// Instruction Pattern Stuff 75193323Sed//===----------------------------------------------------------------------===// 76193323Sed 77193323Seddef div4_xform : SDNodeXForm<imm, [{ 78193323Sed // Transformation function: imm/4 79193323Sed assert(N->getZExtValue() % 4 == 0); 80193323Sed return getI32Imm(N->getZExtValue()/4); 81193323Sed}]>; 82193323Sed 83193323Seddef msksize_xform : SDNodeXForm<imm, [{ 84193323Sed // Transformation function: get the size of a mask 85193323Sed assert(isMask_32(N->getZExtValue())); 86193323Sed // look for the first non-zero bit 87193323Sed return getI32Imm(32 - CountLeadingZeros_32(N->getZExtValue())); 88193323Sed}]>; 89193323Sed 90193323Seddef neg_xform : SDNodeXForm<imm, [{ 91193323Sed // Transformation function: -imm 92193323Sed uint32_t value = N->getZExtValue(); 93193323Sed return getI32Imm(-value); 94193323Sed}]>; 95193323Sed 96198090Srdivackydef bpwsub_xform : SDNodeXForm<imm, [{ 97198090Srdivacky // Transformation function: 32-imm 98198090Srdivacky uint32_t value = N->getZExtValue(); 99198090Srdivacky return getI32Imm(32-value); 100198090Srdivacky}]>; 101198090Srdivacky 102193323Seddef div4neg_xform : SDNodeXForm<imm, [{ 103193323Sed // Transformation function: -imm/4 104193323Sed uint32_t value = N->getZExtValue(); 105193323Sed assert(-value % 4 == 0); 106193323Sed return getI32Imm(-value/4); 107193323Sed}]>; 108193323Sed 109193323Seddef immUs4Neg : PatLeaf<(imm), [{ 110193323Sed uint32_t value = (uint32_t)N->getZExtValue(); 111193323Sed return (-value)%4 == 0 && (-value)/4 <= 11; 112193323Sed}]>; 113193323Sed 114193323Seddef immUs4 : PatLeaf<(imm), [{ 115193323Sed uint32_t value = (uint32_t)N->getZExtValue(); 116193323Sed return value%4 == 0 && value/4 <= 11; 117193323Sed}]>; 118193323Sed 119193323Seddef immUsNeg : PatLeaf<(imm), [{ 120193323Sed return -((uint32_t)N->getZExtValue()) <= 11; 121193323Sed}]>; 122193323Sed 123193323Seddef immUs : PatLeaf<(imm), [{ 124193323Sed return (uint32_t)N->getZExtValue() <= 11; 125193323Sed}]>; 126193323Sed 127193323Seddef immU6 : PatLeaf<(imm), [{ 128193323Sed return (uint32_t)N->getZExtValue() < (1 << 6); 129193323Sed}]>; 130193323Sed 131193323Seddef immU10 : PatLeaf<(imm), [{ 132193323Sed return (uint32_t)N->getZExtValue() < (1 << 10); 133193323Sed}]>; 134193323Sed 135193323Seddef immU16 : PatLeaf<(imm), [{ 136193323Sed return (uint32_t)N->getZExtValue() < (1 << 16); 137193323Sed}]>; 138193323Sed 139193323Seddef immU20 : PatLeaf<(imm), [{ 140193323Sed return (uint32_t)N->getZExtValue() < (1 << 20); 141193323Sed}]>; 142193323Sed 143212904Sdimdef immMskBitp : PatLeaf<(imm), [{ return immMskBitp(N); }]>; 144193323Sed 145193323Seddef immBitp : PatLeaf<(imm), [{ 146193323Sed uint32_t value = (uint32_t)N->getZExtValue(); 147193323Sed return (value >= 1 && value <= 8) 148193323Sed || value == 16 149193323Sed || value == 24 150193323Sed || value == 32; 151193323Sed}]>; 152193323Sed 153198090Srdivackydef immBpwSubBitp : PatLeaf<(imm), [{ 154198090Srdivacky uint32_t value = (uint32_t)N->getZExtValue(); 155198090Srdivacky return (value >= 24 && value <= 31) 156198090Srdivacky || value == 16 157198090Srdivacky || value == 8 158198090Srdivacky || value == 0; 159198090Srdivacky}]>; 160198090Srdivacky 161193323Seddef lda16f : PatFrag<(ops node:$addr, node:$offset), 162193323Sed (add node:$addr, (shl node:$offset, 1))>; 163193323Seddef lda16b : PatFrag<(ops node:$addr, node:$offset), 164193323Sed (sub node:$addr, (shl node:$offset, 1))>; 165193323Seddef ldawf : PatFrag<(ops node:$addr, node:$offset), 166193323Sed (add node:$addr, (shl node:$offset, 2))>; 167193323Seddef ldawb : PatFrag<(ops node:$addr, node:$offset), 168193323Sed (sub node:$addr, (shl node:$offset, 2))>; 169193323Sed 170193323Sed// Instruction operand types 171251662Sdimdef pcrel_imm : Operand<i32>; 172251662Sdimdef pcrel_imm_neg : Operand<i32> { 173251662Sdim let DecoderMethod = "DecodeNegImmOperand"; 174251662Sdim} 175193323Seddef brtarget : Operand<OtherVT>; 176251662Sdimdef brtarget_neg : Operand<OtherVT> { 177251662Sdim let DecoderMethod = "DecodeNegImmOperand"; 178251662Sdim} 179193323Sed 180193323Sed// Addressing modes 181193323Seddef ADDRspii : ComplexPattern<i32, 2, "SelectADDRspii", [add, frameindex], []>; 182193323Sed 183193323Sed// Address operands 184193323Seddef MEMii : Operand<i32> { 185193323Sed let MIOperandInfo = (ops i32imm, i32imm); 186193323Sed} 187193323Sed 188204642Srdivacky// Jump tables. 189204642Srdivackydef InlineJT : Operand<i32> { 190204642Srdivacky let PrintMethod = "printInlineJT"; 191204642Srdivacky} 192204642Srdivacky 193204642Srdivackydef InlineJT32 : Operand<i32> { 194204642Srdivacky let PrintMethod = "printInlineJT32"; 195204642Srdivacky} 196204642Srdivacky 197193323Sed//===----------------------------------------------------------------------===// 198193323Sed// Instruction Class Templates 199193323Sed//===----------------------------------------------------------------------===// 200193323Sed 201193323Sed// Three operand short 202193323Sed 203249423Sdimmulticlass F3R_2RUS<bits<5> opc1, bits<5> opc2, string OpcStr, SDNode OpNode> { 204249423Sdim def _3r: _F3R<opc1, (outs GRRegs:$dst), (ins GRRegs:$b, GRRegs:$c), 205249423Sdim !strconcat(OpcStr, " $dst, $b, $c"), 206249423Sdim [(set GRRegs:$dst, (OpNode GRRegs:$b, GRRegs:$c))]>; 207249423Sdim def _2rus : _F2RUS<opc2, (outs GRRegs:$dst), (ins GRRegs:$b, i32imm:$c), 208249423Sdim !strconcat(OpcStr, " $dst, $b, $c"), 209249423Sdim [(set GRRegs:$dst, (OpNode GRRegs:$b, immUs:$c))]>; 210193323Sed} 211193323Sed 212249423Sdimmulticlass F3R_2RUS_np<bits<5> opc1, bits<5> opc2, string OpcStr> { 213249423Sdim def _3r: _F3R<opc1, (outs GRRegs:$dst), (ins GRRegs:$b, GRRegs:$c), 214249423Sdim !strconcat(OpcStr, " $dst, $b, $c"), []>; 215249423Sdim def _2rus : _F2RUS<opc2, (outs GRRegs:$dst), (ins GRRegs:$b, i32imm:$c), 216249423Sdim !strconcat(OpcStr, " $dst, $b, $c"), []>; 217193323Sed} 218193323Sed 219249423Sdimmulticlass F3R_2RBITP<bits<5> opc1, bits<5> opc2, string OpcStr, 220249423Sdim SDNode OpNode> { 221249423Sdim def _3r: _F3R<opc1, (outs GRRegs:$dst), (ins GRRegs:$b, GRRegs:$c), 222249423Sdim !strconcat(OpcStr, " $dst, $b, $c"), 223249423Sdim [(set GRRegs:$dst, (OpNode GRRegs:$b, GRRegs:$c))]>; 224249423Sdim def _2rus : _F2RUSBitp<opc2, (outs GRRegs:$dst), (ins GRRegs:$b, i32imm:$c), 225249423Sdim !strconcat(OpcStr, " $dst, $b, $c"), 226249423Sdim [(set GRRegs:$dst, (OpNode GRRegs:$b, immBitp:$c))]>; 227193323Sed} 228193323Sed 229249423Sdimclass F3R<bits<5> opc, string OpcStr, SDNode OpNode> : 230249423Sdim _F3R<opc, (outs GRRegs:$dst), (ins GRRegs:$b, GRRegs:$c), 231249423Sdim !strconcat(OpcStr, " $dst, $b, $c"), 232249423Sdim [(set GRRegs:$dst, (OpNode GRRegs:$b, GRRegs:$c))]>; 233193323Sed 234249423Sdimclass F3R_np<bits<5> opc, string OpcStr> : 235249423Sdim _F3R<opc, (outs GRRegs:$dst), (ins GRRegs:$b, GRRegs:$c), 236249423Sdim !strconcat(OpcStr, " $dst, $b, $c"), []>; 237193323Sed// Three operand long 238193323Sed 239193323Sed/// FL3R_L2RUS multiclass - Define a normal FL3R/FL2RUS pattern in one shot. 240249423Sdimmulticlass FL3R_L2RUS<bits<9> opc1, bits<9> opc2, string OpcStr, 241249423Sdim SDNode OpNode> { 242249423Sdim def _l3r: _FL3R<opc1, (outs GRRegs:$dst), (ins GRRegs:$b, GRRegs:$c), 243249423Sdim !strconcat(OpcStr, " $dst, $b, $c"), 244249423Sdim [(set GRRegs:$dst, (OpNode GRRegs:$b, GRRegs:$c))]>; 245249423Sdim def _l2rus : _FL2RUS<opc2, (outs GRRegs:$dst), (ins GRRegs:$b, i32imm:$c), 246249423Sdim !strconcat(OpcStr, " $dst, $b, $c"), 247249423Sdim [(set GRRegs:$dst, (OpNode GRRegs:$b, immUs:$c))]>; 248193323Sed} 249193323Sed 250193323Sed/// FL3R_L2RUS multiclass - Define a normal FL3R/FL2RUS pattern in one shot. 251249423Sdimmulticlass FL3R_L2RBITP<bits<9> opc1, bits<9> opc2, string OpcStr, 252249423Sdim SDNode OpNode> { 253249423Sdim def _l3r: _FL3R<opc1, (outs GRRegs:$dst), (ins GRRegs:$b, GRRegs:$c), 254249423Sdim !strconcat(OpcStr, " $dst, $b, $c"), 255249423Sdim [(set GRRegs:$dst, (OpNode GRRegs:$b, GRRegs:$c))]>; 256249423Sdim def _l2rus : _FL2RUSBitp<opc2, (outs GRRegs:$dst), (ins GRRegs:$b, i32imm:$c), 257249423Sdim !strconcat(OpcStr, " $dst, $b, $c"), 258249423Sdim [(set GRRegs:$dst, (OpNode GRRegs:$b, immBitp:$c))]>; 259193323Sed} 260193323Sed 261249423Sdimclass FL3R<bits<9> opc, string OpcStr, SDNode OpNode> : 262249423Sdim _FL3R<opc, (outs GRRegs:$dst), (ins GRRegs:$b, GRRegs:$c), 263249423Sdim !strconcat(OpcStr, " $dst, $b, $c"), 264249423Sdim [(set GRRegs:$dst, (OpNode GRRegs:$b, GRRegs:$c))]>; 265193323Sed 266193323Sed// Register - U6 267193323Sed// Operand register - U6 268249423Sdimmulticlass FRU6_LRU6_branch<bits<6> opc, string OpcStr> { 269249423Sdim def _ru6: _FRU6<opc, (outs), (ins GRRegs:$a, brtarget:$b), 270249423Sdim !strconcat(OpcStr, " $a, $b"), []>; 271249423Sdim def _lru6: _FLRU6<opc, (outs), (ins GRRegs:$a, brtarget:$b), 272249423Sdim !strconcat(OpcStr, " $a, $b"), []>; 273193323Sed} 274193323Sed 275249423Sdimmulticlass FRU6_LRU6_backwards_branch<bits<6> opc, string OpcStr> { 276251662Sdim def _ru6: _FRU6<opc, (outs), (ins GRRegs:$a, brtarget_neg:$b), 277251662Sdim !strconcat(OpcStr, " $a, $b"), []>; 278251662Sdim def _lru6: _FLRU6<opc, (outs), (ins GRRegs:$a, brtarget_neg:$b), 279251662Sdim !strconcat(OpcStr, " $a, $b"), []>; 280193323Sed} 281193323Sed 282249423Sdimmulticlass FRU6_LRU6_cp<bits<6> opc, string OpcStr> { 283249423Sdim def _ru6: _FRU6<opc, (outs RRegs:$a), (ins i32imm:$b), 284249423Sdim !strconcat(OpcStr, " $a, cp[$b]"), []>; 285249423Sdim def _lru6: _FLRU6<opc, (outs RRegs:$a), (ins i32imm:$b), 286249423Sdim !strconcat(OpcStr, " $a, cp[$b]"), []>; 287249423Sdim} 288249423Sdim 289193323Sed// U6 290249423Sdimmulticlass FU6_LU6<bits<10> opc, string OpcStr, SDNode OpNode> { 291249423Sdim def _u6: _FU6<opc, (outs), (ins i32imm:$a), !strconcat(OpcStr, " $a"), 292249423Sdim [(OpNode immU6:$a)]>; 293249423Sdim def _lu6: _FLU6<opc, (outs), (ins i32imm:$a), !strconcat(OpcStr, " $a"), 294249423Sdim [(OpNode immU16:$a)]>; 295193323Sed} 296193323Sed 297249423Sdimmulticlass FU6_LU6_int<bits<10> opc, string OpcStr, Intrinsic Int> { 298249423Sdim def _u6: _FU6<opc, (outs), (ins i32imm:$a), !strconcat(OpcStr, " $a"), 299249423Sdim [(Int immU6:$a)]>; 300249423Sdim def _lu6: _FLU6<opc, (outs), (ins i32imm:$a), !strconcat(OpcStr, " $a"), 301249423Sdim [(Int immU16:$a)]>; 302193323Sed} 303193323Sed 304249423Sdimmulticlass FU6_LU6_np<bits<10> opc, string OpcStr> { 305249423Sdim def _u6: _FU6<opc, (outs), (ins i32imm:$a), !strconcat(OpcStr, " $a"), []>; 306249423Sdim def _lu6: _FLU6<opc, (outs), (ins i32imm:$a), !strconcat(OpcStr, " $a"), []>; 307193323Sed} 308193323Sed 309193323Sed// Two operand short 310193323Sed 311249423Sdimclass F2R_np<bits<6> opc, string OpcStr> : 312249423Sdim _F2R<opc, (outs GRRegs:$dst), (ins GRRegs:$b), 313249423Sdim !strconcat(OpcStr, " $dst, $b"), []>; 314193323Sed 315193323Sed// Two operand long 316193323Sed 317193323Sed//===----------------------------------------------------------------------===// 318193323Sed// Pseudo Instructions 319193323Sed//===----------------------------------------------------------------------===// 320193323Sed 321193323Sedlet Defs = [SP], Uses = [SP] in { 322193323Seddef ADJCALLSTACKDOWN : PseudoInstXCore<(outs), (ins i32imm:$amt), 323249423Sdim "# ADJCALLSTACKDOWN $amt", 324193323Sed [(callseq_start timm:$amt)]>; 325193323Seddef ADJCALLSTACKUP : PseudoInstXCore<(outs), (ins i32imm:$amt1, i32imm:$amt2), 326249423Sdim "# ADJCALLSTACKUP $amt1", 327193323Sed [(callseq_end timm:$amt1, timm:$amt2)]>; 328193323Sed} 329193323Sed 330193323Seddef LDWFI : PseudoInstXCore<(outs GRRegs:$dst), (ins MEMii:$addr), 331249423Sdim "# LDWFI $dst, $addr", 332193323Sed [(set GRRegs:$dst, (load ADDRspii:$addr))]>; 333193323Sed 334193323Seddef LDAWFI : PseudoInstXCore<(outs GRRegs:$dst), (ins MEMii:$addr), 335249423Sdim "# LDAWFI $dst, $addr", 336193323Sed [(set GRRegs:$dst, ADDRspii:$addr)]>; 337193323Sed 338193323Seddef STWFI : PseudoInstXCore<(outs), (ins GRRegs:$src, MEMii:$addr), 339249423Sdim "# STWFI $src, $addr", 340193323Sed [(store GRRegs:$src, ADDRspii:$addr)]>; 341193323Sed 342198892Srdivacky// SELECT_CC_* - Used to implement the SELECT_CC DAG operation. Expanded after 343198892Srdivacky// instruction selection into a branch sequence. 344198892Srdivackylet usesCustomInserter = 1 in { 345193323Sed def SELECT_CC : PseudoInstXCore<(outs GRRegs:$dst), 346193323Sed (ins GRRegs:$cond, GRRegs:$T, GRRegs:$F), 347249423Sdim "# SELECT_CC PSEUDO!", 348193323Sed [(set GRRegs:$dst, 349193323Sed (select GRRegs:$cond, GRRegs:$T, GRRegs:$F))]>; 350193323Sed} 351193323Sed 352193323Sed//===----------------------------------------------------------------------===// 353193323Sed// Instructions 354193323Sed//===----------------------------------------------------------------------===// 355193323Sed 356193323Sed// Three operand short 357249423Sdimdefm ADD : F3R_2RUS<0b00010, 0b10010, "add", add>; 358249423Sdimdefm SUB : F3R_2RUS<0b00011, 0b10011, "sub", sub>; 359193323Sedlet neverHasSideEffects = 1 in { 360249423Sdimdefm EQ : F3R_2RUS_np<0b00110, 0b10110, "eq">; 361249423Sdimdef LSS_3r : F3R_np<0b11000, "lss">; 362249423Sdimdef LSU_3r : F3R_np<0b11001, "lsu">; 363193323Sed} 364249423Sdimdef AND_3r : F3R<0b00111, "and", and>; 365249423Sdimdef OR_3r : F3R<0b01000, "or", or>; 366193323Sed 367193323Sedlet mayLoad=1 in { 368249423Sdimdef LDW_3r : _F3R<0b01001, (outs GRRegs:$dst), 369249423Sdim (ins GRRegs:$addr, GRRegs:$offset), 370249423Sdim "ldw $dst, $addr[$offset]", []>; 371193323Sed 372249423Sdimdef LDW_2rus : _F2RUS<0b00001, (outs GRRegs:$dst), 373249423Sdim (ins GRRegs:$addr, i32imm:$offset), 374249423Sdim "ldw $dst, $addr[$offset]", []>; 375193323Sed 376249423Sdimdef LD16S_3r : _F3R<0b10000, (outs GRRegs:$dst), 377249423Sdim (ins GRRegs:$addr, GRRegs:$offset), 378249423Sdim "ld16s $dst, $addr[$offset]", []>; 379193323Sed 380249423Sdimdef LD8U_3r : _F3R<0b10001, (outs GRRegs:$dst), 381249423Sdim (ins GRRegs:$addr, GRRegs:$offset), 382249423Sdim "ld8u $dst, $addr[$offset]", []>; 383193323Sed} 384193323Sed 385193323Sedlet mayStore=1 in { 386249423Sdimdef STW_l3r : _FL3R<0b000001100, (outs), 387249423Sdim (ins GRRegs:$val, GRRegs:$addr, GRRegs:$offset), 388249423Sdim "stw $val, $addr[$offset]", []>; 389193323Sed 390249423Sdimdef STW_2rus : _F2RUS<0b0000, (outs), 391249423Sdim (ins GRRegs:$val, GRRegs:$addr, i32imm:$offset), 392249423Sdim "stw $val, $addr[$offset]", []>; 393193323Sed} 394193323Sed 395249423Sdimdefm SHL : F3R_2RBITP<0b00100, 0b10100, "shl", shl>; 396249423Sdimdefm SHR : F3R_2RBITP<0b00101, 0b10101, "shr", srl>; 397193323Sed 398249423Sdim// The first operand is treated as an immediate since it refers to a register 399249423Sdim// number in another thread. 400249423Sdimdef TSETR_3r : _F3RImm<0b10111, (outs), (ins i32imm:$a, GRRegs:$b, GRRegs:$c), 401249423Sdim "set t[$c]:r$a, $b", []>; 402249423Sdim 403193323Sed// Three operand long 404249423Sdimdef LDAWF_l3r : _FL3R<0b000111100, (outs GRRegs:$dst), 405249423Sdim (ins GRRegs:$addr, GRRegs:$offset), 406249423Sdim "ldaw $dst, $addr[$offset]", 407249423Sdim [(set GRRegs:$dst, 408249423Sdim (ldawf GRRegs:$addr, GRRegs:$offset))]>; 409193323Sed 410193323Sedlet neverHasSideEffects = 1 in 411249423Sdimdef LDAWF_l2rus : _FL2RUS<0b100111100, (outs GRRegs:$dst), 412249423Sdim (ins GRRegs:$addr, i32imm:$offset), 413249423Sdim "ldaw $dst, $addr[$offset]", []>; 414193323Sed 415249423Sdimdef LDAWB_l3r : _FL3R<0b001001100, (outs GRRegs:$dst), 416249423Sdim (ins GRRegs:$addr, GRRegs:$offset), 417249423Sdim "ldaw $dst, $addr[-$offset]", 418249423Sdim [(set GRRegs:$dst, 419249423Sdim (ldawb GRRegs:$addr, GRRegs:$offset))]>; 420193323Sed 421193323Sedlet neverHasSideEffects = 1 in 422249423Sdimdef LDAWB_l2rus : _FL2RUS<0b101001100, (outs GRRegs:$dst), 423249423Sdim (ins GRRegs:$addr, i32imm:$offset), 424249423Sdim "ldaw $dst, $addr[-$offset]", []>; 425193323Sed 426249423Sdimdef LDA16F_l3r : _FL3R<0b001011100, (outs GRRegs:$dst), 427249423Sdim (ins GRRegs:$addr, GRRegs:$offset), 428249423Sdim "lda16 $dst, $addr[$offset]", 429249423Sdim [(set GRRegs:$dst, 430249423Sdim (lda16f GRRegs:$addr, GRRegs:$offset))]>; 431193323Sed 432249423Sdimdef LDA16B_l3r : _FL3R<0b001101100, (outs GRRegs:$dst), 433249423Sdim (ins GRRegs:$addr, GRRegs:$offset), 434249423Sdim "lda16 $dst, $addr[-$offset]", 435249423Sdim [(set GRRegs:$dst, 436249423Sdim (lda16b GRRegs:$addr, GRRegs:$offset))]>; 437193323Sed 438249423Sdimdef MUL_l3r : FL3R<0b001111100, "mul", mul>; 439193323Sed// Instructions which may trap are marked as side effecting. 440193323Sedlet hasSideEffects = 1 in { 441249423Sdimdef DIVS_l3r : FL3R<0b010001100, "divs", sdiv>; 442249423Sdimdef DIVU_l3r : FL3R<0b010011100, "divu", udiv>; 443249423Sdimdef REMS_l3r : FL3R<0b110001100, "rems", srem>; 444249423Sdimdef REMU_l3r : FL3R<0b110011100, "remu", urem>; 445193323Sed} 446249423Sdimdef XOR_l3r : FL3R<0b000011100, "xor", xor>; 447249423Sdimdefm ASHR : FL3R_L2RBITP<0b000101100, 0b100101100, "ashr", sra>; 448223017Sdim 449223017Sdimlet Constraints = "$src1 = $dst" in 450249423Sdimdef CRC_l3r : _FL3RSrcDst<0b101011100, (outs GRRegs:$dst), 451249423Sdim (ins GRRegs:$src1, GRRegs:$src2, GRRegs:$src3), 452249423Sdim "crc32 $dst, $src2, $src3", 453249423Sdim [(set GRRegs:$dst, 454249423Sdim (int_xcore_crc32 GRRegs:$src1, GRRegs:$src2, 455249423Sdim GRRegs:$src3))]>; 456223017Sdim 457193323Sedlet mayStore=1 in { 458249423Sdimdef ST16_l3r : _FL3R<0b100001100, (outs), 459249423Sdim (ins GRRegs:$val, GRRegs:$addr, GRRegs:$offset), 460249423Sdim "st16 $val, $addr[$offset]", []>; 461193323Sed 462249423Sdimdef ST8_l3r : _FL3R<0b100011100, (outs), 463249423Sdim (ins GRRegs:$val, GRRegs:$addr, GRRegs:$offset), 464249423Sdim "st8 $val, $addr[$offset]", []>; 465193323Sed} 466193323Sed 467249423Sdimdef INPW_l2rus : _FL2RUSBitp<0b100101110, (outs GRRegs:$a), 468249423Sdim (ins GRRegs:$b, i32imm:$c), "inpw $a, res[$b], $c", 469249423Sdim []>; 470249423Sdim 471249423Sdimdef OUTPW_l2rus : _FL2RUSBitp<0b100101101, (outs), 472249423Sdim (ins GRRegs:$a, GRRegs:$b, i32imm:$c), 473249423Sdim "outpw res[$b], $a, $c", []>; 474249423Sdim 475193323Sed// Four operand long 476249423Sdimlet Constraints = "$e = $a,$f = $b" in { 477249423Sdimdef MACCU_l4r : _FL4RSrcDstSrcDst< 478249423Sdim 0b000001, (outs GRRegs:$a, GRRegs:$b), 479249423Sdim (ins GRRegs:$e, GRRegs:$f, GRRegs:$c, GRRegs:$d), "maccu $a, $b, $c, $d", []>; 480193323Sed 481249423Sdimdef MACCS_l4r : _FL4RSrcDstSrcDst< 482249423Sdim 0b000010, (outs GRRegs:$a, GRRegs:$b), 483249423Sdim (ins GRRegs:$e, GRRegs:$f, GRRegs:$c, GRRegs:$d), "maccs $a, $b, $c, $d", []>; 484193323Sed} 485193323Sed 486249423Sdimlet Constraints = "$e = $b" in 487249423Sdimdef CRC8_l4r : _FL4RSrcDst<0b000000, (outs GRRegs:$a, GRRegs:$b), 488249423Sdim (ins GRRegs:$e, GRRegs:$c, GRRegs:$d), 489249423Sdim "crc8 $b, $a, $c, $d", []>; 490223017Sdim 491193323Sed// Five operand long 492193323Sed 493249423Sdimdef LADD_l5r : _FL5R<0b000001, (outs GRRegs:$dst1, GRRegs:$dst2), 494249423Sdim (ins GRRegs:$src1, GRRegs:$src2, GRRegs:$src3), 495249423Sdim "ladd $dst2, $dst1, $src1, $src2, $src3", 496249423Sdim []>; 497193323Sed 498249423Sdimdef LSUB_l5r : _FL5R<0b000010, (outs GRRegs:$dst1, GRRegs:$dst2), 499249423Sdim (ins GRRegs:$src1, GRRegs:$src2, GRRegs:$src3), 500249423Sdim "lsub $dst2, $dst1, $src1, $src2, $src3", []>; 501193323Sed 502249423Sdimdef LDIVU_l5r : _FL5R<0b000000, (outs GRRegs:$dst1, GRRegs:$dst2), 503249423Sdim (ins GRRegs:$src1, GRRegs:$src2, GRRegs:$src3), 504249423Sdim "ldivu $dst1, $dst2, $src3, $src1, $src2", []>; 505193323Sed 506193323Sed// Six operand long 507193323Sed 508249423Sdimdef LMUL_l6r : _FL6R< 509249423Sdim 0b00000, (outs GRRegs:$dst1, GRRegs:$dst2), 510249423Sdim (ins GRRegs:$src1, GRRegs:$src2, GRRegs:$src3, GRRegs:$src4), 511249423Sdim "lmul $dst1, $dst2, $src1, $src2, $src3, $src4", []>; 512193323Sed 513193323Sed// Register - U6 514193323Sed 515193323Sed//let Uses = [DP] in ... 516193323Sedlet neverHasSideEffects = 1, isReMaterializable = 1 in 517251662Sdimdef LDAWDP_ru6: _FRU6<0b011000, (outs RRegs:$a), (ins i32imm:$b), 518249423Sdim "ldaw $a, dp[$b]", []>; 519193323Sed 520193323Sedlet isReMaterializable = 1 in 521251662Sdimdef LDAWDP_lru6: _FLRU6<0b011000, (outs RRegs:$a), (ins i32imm:$b), 522249423Sdim "ldaw $a, dp[$b]", 523251662Sdim [(set RRegs:$a, (dprelwrapper tglobaladdr:$b))]>; 524193323Sed 525193323Sedlet mayLoad=1 in 526251662Sdimdef LDWDP_ru6: _FRU6<0b010110, (outs RRegs:$a), (ins i32imm:$b), 527249423Sdim "ldw $a, dp[$b]", []>; 528193323Sed 529251662Sdimdef LDWDP_lru6: _FLRU6<0b010110, (outs RRegs:$a), (ins i32imm:$b), 530249423Sdim "ldw $a, dp[$b]", 531251662Sdim [(set RRegs:$a, (load (dprelwrapper tglobaladdr:$b)))]>; 532249423Sdim 533193323Sedlet mayStore=1 in 534251662Sdimdef STWDP_ru6 : _FRU6<0b010100, (outs), (ins RRegs:$a, i32imm:$b), 535249423Sdim "stw $a, dp[$b]", []>; 536193323Sed 537251662Sdimdef STWDP_lru6 : _FLRU6<0b010100, (outs), (ins RRegs:$a, i32imm:$b), 538249423Sdim "stw $a, dp[$b]", 539251662Sdim [(store RRegs:$a, (dprelwrapper tglobaladdr:$b))]>; 540193323Sed 541193323Sed//let Uses = [CP] in .. 542226633Sdimlet mayLoad = 1, isReMaterializable = 1, neverHasSideEffects = 1 in 543249423Sdimdefm LDWCP : FRU6_LRU6_cp<0b011011, "ldw">; 544193323Sed 545193323Sedlet Uses = [SP] in { 546193323Sedlet mayStore=1 in { 547249423Sdimdef STWSP_ru6 : _FRU6<0b010101, (outs), (ins RRegs:$a, i32imm:$b), 548249423Sdim "stw $a, sp[$b]", 549249423Sdim [(XCoreStwsp RRegs:$a, immU6:$b)]>; 550193323Sed 551249423Sdimdef STWSP_lru6 : _FLRU6<0b010101, (outs), (ins RRegs:$a, i32imm:$b), 552249423Sdim "stw $a, sp[$b]", 553249423Sdim [(XCoreStwsp RRegs:$a, immU16:$b)]>; 554193323Sed} 555193323Sed 556193323Sedlet mayLoad=1 in { 557249423Sdimdef LDWSP_ru6 : _FRU6<0b010111, (outs RRegs:$a), (ins i32imm:$b), 558249423Sdim "ldw $a, sp[$b]", []>; 559193323Sed 560249423Sdimdef LDWSP_lru6 : _FLRU6<0b010111, (outs RRegs:$a), (ins i32imm:$b), 561249423Sdim "ldw $a, sp[$b]", []>; 562193323Sed} 563193323Sed 564193323Sedlet neverHasSideEffects = 1 in { 565249423Sdimdef LDAWSP_ru6 : _FRU6<0b011001, (outs RRegs:$a), (ins i32imm:$b), 566249423Sdim "ldaw $a, sp[$b]", []>; 567193323Sed 568249423Sdimdef LDAWSP_lru6 : _FLRU6<0b011001, (outs RRegs:$a), (ins i32imm:$b), 569249423Sdim "ldaw $a, sp[$b]", []>; 570193323Sed} 571193323Sed} 572193323Sed 573193323Sedlet isReMaterializable = 1 in { 574249423Sdimdef LDC_ru6 : _FRU6<0b011010, (outs RRegs:$a), (ins i32imm:$b), 575249423Sdim "ldc $a, $b", [(set RRegs:$a, immU6:$b)]>; 576193323Sed 577249423Sdimdef LDC_lru6 : _FLRU6<0b011010, (outs RRegs:$a), (ins i32imm:$b), 578249423Sdim "ldc $a, $b", [(set RRegs:$a, immU16:$b)]>; 579193323Sed} 580193323Sed 581249423Sdimdef SETC_ru6 : _FRU6<0b111010, (outs), (ins GRRegs:$a, i32imm:$b), 582249423Sdim "setc res[$a], $b", 583249423Sdim [(int_xcore_setc GRRegs:$a, immU6:$b)]>; 584218893Sdim 585249423Sdimdef SETC_lru6 : _FLRU6<0b111010, (outs), (ins GRRegs:$a, i32imm:$b), 586249423Sdim "setc res[$a], $b", 587249423Sdim [(int_xcore_setc GRRegs:$a, immU16:$b)]>; 588218893Sdim 589193323Sed// Operand register - U6 590193323Sedlet isBranch = 1, isTerminator = 1 in { 591249423Sdimdefm BRFT: FRU6_LRU6_branch<0b011100, "bt">; 592249423Sdimdefm BRBT: FRU6_LRU6_backwards_branch<0b011101, "bt">; 593249423Sdimdefm BRFF: FRU6_LRU6_branch<0b011110, "bf">; 594249423Sdimdefm BRBF: FRU6_LRU6_backwards_branch<0b011111, "bf">; 595193323Sed} 596193323Sed 597193323Sed// U6 598193323Sedlet Defs = [SP], Uses = [SP] in { 599193323Sedlet neverHasSideEffects = 1 in 600249423Sdimdefm EXTSP : FU6_LU6_np<0b0111011110, "extsp">; 601249423Sdim 602193323Sedlet mayStore = 1 in 603249423Sdimdefm ENTSP : FU6_LU6_np<0b0111011101, "entsp">; 604193323Sed 605199481Srdivackylet isReturn = 1, isTerminator = 1, mayLoad = 1, isBarrier = 1 in { 606249423Sdimdefm RETSP : FU6_LU6<0b0111011111, "retsp", XCoreRetsp>; 607193323Sed} 608193323Sed} 609193323Sed 610249423Sdimlet neverHasSideEffects = 1 in 611249423Sdimdefm EXTDP : FU6_LU6_np<0b0111001110, "extdp">; 612249423Sdim 613249423Sdimlet Uses = [R11], isCall=1 in 614249423Sdimdefm BLAT : FU6_LU6_np<0b0111001101, "blat">; 615249423Sdim 616204642Srdivackylet isBranch = 1, isTerminator = 1, isBarrier = 1 in { 617251662Sdimdef BRBU_u6 : _FU6<0b0111011100, (outs), (ins brtarget_neg:$a), "bu $a", []>; 618193323Sed 619251662Sdimdef BRBU_lu6 : _FLU6<0b0111011100, (outs), (ins brtarget_neg:$a), "bu $a", []>; 620193323Sed 621249423Sdimdef BRFU_u6 : _FU6<0b0111001100, (outs), (ins brtarget:$a), "bu $a", []>; 622193323Sed 623249423Sdimdef BRFU_lu6 : _FLU6<0b0111001100, (outs), (ins brtarget:$a), "bu $a", []>; 624193323Sed} 625193323Sed 626193323Sed//let Uses = [CP] in ... 627198090Srdivackylet Defs = [R11], neverHasSideEffects = 1, isReMaterializable = 1 in 628251662Sdimdef LDAWCP_u6: _FU6<0b0111111101, (outs), (ins i32imm:$a), "ldaw r11, cp[$a]", 629193323Sed []>; 630193323Sed 631198090Srdivackylet Defs = [R11], isReMaterializable = 1 in 632251662Sdimdef LDAWCP_lu6: _FLU6<0b0111111101, (outs), (ins i32imm:$a), "ldaw r11, cp[$a]", 633251662Sdim [(set R11, (cprelwrapper tglobaladdr:$a))]>; 634193323Sed 635249423Sdimlet Defs = [R11] in 636249423Sdimdefm GETSR : FU6_LU6_np<0b0111111100, "getsr r11,">; 637221345Sdim 638249423Sdimdefm SETSR : FU6_LU6_int<0b0111101101, "setsr", int_xcore_setsr>; 639221345Sdim 640249423Sdimdefm CLRSR : FU6_LU6_int<0b0111101100, "clrsr", int_xcore_clrsr>; 641249423Sdim 642221345Sdim// setsr may cause a branch if it is used to enable events. clrsr may 643221345Sdim// branch if it is executed while events are enabled. 644249423Sdimlet isBranch=1, isIndirectBranch=1, isTerminator=1, isBarrier = 1, 645249423Sdim isCodeGenOnly = 1 in { 646249423Sdimdefm SETSR_branch : FU6_LU6_np<0b0111101101, "setsr">; 647249423Sdimdefm CLRSR_branch : FU6_LU6_np<0b0111101100, "clrsr">; 648221345Sdim} 649221345Sdim 650249423Sdimdefm KCALL : FU6_LU6_np<0b0111001111, "kcall">; 651249423Sdim 652249423Sdimlet Uses = [SP], Defs = [SP], mayStore = 1 in 653249423Sdimdefm KENTSP : FU6_LU6_np<0b0111101110, "kentsp">; 654249423Sdim 655249423Sdimlet Uses = [SP], Defs = [SP], mayLoad = 1 in 656249423Sdimdefm KRESTSP : FU6_LU6_np<0b0111101111, "krestsp">; 657249423Sdim 658193323Sed// U10 659193323Sed 660251662Sdimlet Defs = [R11], isReMaterializable = 1 in { 661251662Sdimlet neverHasSideEffects = 1 in 662251662Sdimdef LDAPF_u10 : _FU10<0b110110, (outs), (ins pcrel_imm:$a), "ldap r11, $a", []>; 663193323Sed 664251662Sdimdef LDAPF_lu10 : _FLU10<0b110110, (outs), (ins pcrel_imm:$a), "ldap r11, $a", 665249423Sdim [(set R11, (pcrelwrapper tglobaladdr:$a))]>; 666193323Sed 667251662Sdimlet neverHasSideEffects = 1 in 668251662Sdimdef LDAPB_u10 : _FU10<0b110111, (outs), (ins pcrel_imm_neg:$a), "ldap r11, $a", 669251662Sdim []>; 670251662Sdim 671251662Sdimlet neverHasSideEffects = 1 in 672251662Sdimdef LDAPB_lu10 : _FLU10<0b110111, (outs), (ins pcrel_imm_neg:$a), 673251662Sdim "ldap r11, $a", 674251662Sdim [(set R11, (pcrelwrapper tglobaladdr:$a))]>; 675251662Sdim 676251662Sdimlet isCodeGenOnly = 1 in 677251662Sdimdef LDAPF_lu10_ba : _FLU10<0b110110, (outs), (ins pcrel_imm:$a), "ldap r11, $a", 678249423Sdim [(set R11, (pcrelwrapper tblockaddress:$a))]>; 679251662Sdim} 680199511Srdivacky 681193323Sedlet isCall=1, 682203954Srdivacky// All calls clobber the link register and the non-callee-saved registers: 683226633SdimDefs = [R0, R1, R2, R3, R11, LR], Uses = [SP] in { 684249423Sdimdef BLACP_u10 : _FU10<0b111000, (outs), (ins i32imm:$a), "bla cp[$a]", []>; 685193323Sed 686249423Sdimdef BLACP_lu10 : _FLU10<0b111000, (outs), (ins i32imm:$a), "bla cp[$a]", []>; 687249423Sdim 688251662Sdimdef BLRF_u10 : _FU10<0b110100, (outs), (ins pcrel_imm:$a), "bl $a", 689249423Sdim [(XCoreBranchLink immU10:$a)]>; 690249423Sdim 691251662Sdimdef BLRF_lu10 : _FLU10<0b110100, (outs), (ins pcrel_imm:$a), "bl $a", 692249423Sdim [(XCoreBranchLink immU20:$a)]>; 693251662Sdim 694251662Sdimdef BLRB_u10 : _FU10<0b110101, (outs), (ins pcrel_imm_neg:$a), "bl $a", []>; 695251662Sdim 696251662Sdimdef BLRB_lu10 : _FLU10<0b110101, (outs), (ins pcrel_imm_neg:$a), "bl $a", []>; 697193323Sed} 698193323Sed 699249423Sdimlet Defs = [R11], mayLoad = 1, isReMaterializable = 1, 700249423Sdim neverHasSideEffects = 1 in { 701249423Sdimdef LDWCP_u10 : _FU10<0b111001, (outs), (ins i32imm:$a), "ldw r11, cp[$a]", []>; 702249423Sdim 703249423Sdimdef LDWCP_lu10 : _FLU10<0b111001, (outs), (ins i32imm:$a), "ldw r11, cp[$a]", 704249423Sdim []>; 705249423Sdim} 706249423Sdim 707193323Sed// Two operand short 708249423Sdimdef NOT : _F2R<0b100010, (outs GRRegs:$dst), (ins GRRegs:$b), 709249423Sdim "not $dst, $b", [(set GRRegs:$dst, (not GRRegs:$b))]>; 710193323Sed 711249423Sdimdef NEG : _F2R<0b100100, (outs GRRegs:$dst), (ins GRRegs:$b), 712249423Sdim "neg $dst, $b", [(set GRRegs:$dst, (ineg GRRegs:$b))]>; 713193323Sed 714210299Sedlet Constraints = "$src1 = $dst" in { 715249423Sdimdef SEXT_rus : 716249423Sdim _FRUSSrcDstBitp<0b001101, (outs GRRegs:$dst), (ins GRRegs:$src1, i32imm:$src2), 717249423Sdim "sext $dst, $src2", 718249423Sdim [(set GRRegs:$dst, (int_xcore_sext GRRegs:$src1, 719249423Sdim immBitp:$src2))]>; 720193323Sed 721249423Sdimdef SEXT_2r : 722249423Sdim _F2RSrcDst<0b001100, (outs GRRegs:$dst), (ins GRRegs:$src1, GRRegs:$src2), 723249423Sdim "sext $dst, $src2", 724249423Sdim [(set GRRegs:$dst, (int_xcore_sext GRRegs:$src1, GRRegs:$src2))]>; 725226633Sdim 726249423Sdimdef ZEXT_rus : 727249423Sdim _FRUSSrcDstBitp<0b010001, (outs GRRegs:$dst), (ins GRRegs:$src1, i32imm:$src2), 728249423Sdim "zext $dst, $src2", 729249423Sdim [(set GRRegs:$dst, (int_xcore_zext GRRegs:$src1, 730249423Sdim immBitp:$src2))]>; 731193323Sed 732249423Sdimdef ZEXT_2r : 733249423Sdim _F2RSrcDst<0b010000, (outs GRRegs:$dst), (ins GRRegs:$src1, GRRegs:$src2), 734249423Sdim "zext $dst, $src2", 735249423Sdim [(set GRRegs:$dst, (int_xcore_zext GRRegs:$src1, GRRegs:$src2))]>; 736226633Sdim 737249423Sdimdef ANDNOT_2r : 738249423Sdim _F2RSrcDst<0b001010, (outs GRRegs:$dst), (ins GRRegs:$src1, GRRegs:$src2), 739249423Sdim "andnot $dst, $src2", 740249423Sdim [(set GRRegs:$dst, (and GRRegs:$src1, (not GRRegs:$src2)))]>; 741193323Sed} 742193323Sed 743193323Sedlet isReMaterializable = 1, neverHasSideEffects = 1 in 744249423Sdimdef MKMSK_rus : _FRUSBitp<0b101001, (outs GRRegs:$dst), (ins i32imm:$size), 745249423Sdim "mkmsk $dst, $size", []>; 746193323Sed 747249423Sdimdef MKMSK_2r : _F2R<0b101000, (outs GRRegs:$dst), (ins GRRegs:$size), 748249423Sdim "mkmsk $dst, $size", 749249423Sdim [(set GRRegs:$dst, (add (shl 1, GRRegs:$size), -1))]>; 750193323Sed 751249423Sdimdef GETR_rus : _FRUS<0b100000, (outs GRRegs:$dst), (ins i32imm:$type), 752249423Sdim "getr $dst, $type", 753249423Sdim [(set GRRegs:$dst, (int_xcore_getr immUs:$type))]>; 754218893Sdim 755249423Sdimdef GETTS_2r : _F2R<0b001110, (outs GRRegs:$dst), (ins GRRegs:$r), 756249423Sdim "getts $dst, res[$r]", 757249423Sdim [(set GRRegs:$dst, (int_xcore_getts GRRegs:$r))]>; 758219077Sdim 759249423Sdimdef SETPT_2r : _FR2R<0b001111, (outs), (ins GRRegs:$r, GRRegs:$val), 760249423Sdim "setpt res[$r], $val", 761249423Sdim [(int_xcore_setpt GRRegs:$r, GRRegs:$val)]>; 762219077Sdim 763249423Sdimdef OUTCT_2r : _F2R<0b010010, (outs), (ins GRRegs:$r, GRRegs:$val), 764249423Sdim "outct res[$r], $val", 765249423Sdim [(int_xcore_outct GRRegs:$r, GRRegs:$val)]>; 766218893Sdim 767249423Sdimdef OUTCT_rus : _FRUS<0b010011, (outs), (ins GRRegs:$r, i32imm:$val), 768249423Sdim "outct res[$r], $val", 769249423Sdim [(int_xcore_outct GRRegs:$r, immUs:$val)]>; 770218893Sdim 771249423Sdimdef OUTT_2r : _FR2R<0b000011, (outs), (ins GRRegs:$r, GRRegs:$val), 772249423Sdim "outt res[$r], $val", 773249423Sdim [(int_xcore_outt GRRegs:$r, GRRegs:$val)]>; 774218893Sdim 775249423Sdimdef OUT_2r : _FR2R<0b101010, (outs), (ins GRRegs:$r, GRRegs:$val), 776249423Sdim "out res[$r], $val", 777249423Sdim [(int_xcore_out GRRegs:$r, GRRegs:$val)]>; 778218893Sdim 779219077Sdimlet Constraints = "$src = $dst" in 780249423Sdimdef OUTSHR_2r : 781249423Sdim _F2RSrcDst<0b101011, (outs GRRegs:$dst), (ins GRRegs:$src, GRRegs:$r), 782249423Sdim "outshr res[$r], $src", 783249423Sdim [(set GRRegs:$dst, (int_xcore_outshr GRRegs:$r, GRRegs:$src))]>; 784219077Sdim 785249423Sdimdef INCT_2r : _F2R<0b100001, (outs GRRegs:$dst), (ins GRRegs:$r), 786249423Sdim "inct $dst, res[$r]", 787249423Sdim [(set GRRegs:$dst, (int_xcore_inct GRRegs:$r))]>; 788218893Sdim 789249423Sdimdef INT_2r : _F2R<0b100011, (outs GRRegs:$dst), (ins GRRegs:$r), 790249423Sdim "int $dst, res[$r]", 791249423Sdim [(set GRRegs:$dst, (int_xcore_int GRRegs:$r))]>; 792218893Sdim 793249423Sdimdef IN_2r : _F2R<0b101100, (outs GRRegs:$dst), (ins GRRegs:$r), 794218893Sdim "in $dst, res[$r]", 795218893Sdim [(set GRRegs:$dst, (int_xcore_in GRRegs:$r))]>; 796218893Sdim 797219077Sdimlet Constraints = "$src = $dst" in 798249423Sdimdef INSHR_2r : 799249423Sdim _F2RSrcDst<0b101101, (outs GRRegs:$dst), (ins GRRegs:$src, GRRegs:$r), 800249423Sdim "inshr $dst, res[$r]", 801249423Sdim [(set GRRegs:$dst, (int_xcore_inshr GRRegs:$r, GRRegs:$src))]>; 802219077Sdim 803249423Sdimdef CHKCT_2r : _F2R<0b110010, (outs), (ins GRRegs:$r, GRRegs:$val), 804249423Sdim "chkct res[$r], $val", 805249423Sdim [(int_xcore_chkct GRRegs:$r, GRRegs:$val)]>; 806218893Sdim 807249423Sdimdef CHKCT_rus : _FRUSBitp<0b110011, (outs), (ins GRRegs:$r, i32imm:$val), 808249423Sdim "chkct res[$r], $val", 809249423Sdim [(int_xcore_chkct GRRegs:$r, immUs:$val)]>; 810218893Sdim 811249423Sdimdef TESTCT_2r : _F2R<0b101111, (outs GRRegs:$dst), (ins GRRegs:$src), 812226633Sdim "testct $dst, res[$src]", 813226633Sdim [(set GRRegs:$dst, (int_xcore_testct GRRegs:$src))]>; 814226633Sdim 815249423Sdimdef TESTWCT_2r : _F2R<0b110001, (outs GRRegs:$dst), (ins GRRegs:$src), 816226633Sdim "testwct $dst, res[$src]", 817226633Sdim [(set GRRegs:$dst, (int_xcore_testwct GRRegs:$src))]>; 818226633Sdim 819249423Sdimdef SETD_2r : _FR2R<0b000101, (outs), (ins GRRegs:$r, GRRegs:$val), 820249423Sdim "setd res[$r], $val", 821249423Sdim [(int_xcore_setd GRRegs:$r, GRRegs:$val)]>; 822218893Sdim 823249423Sdimdef SETPSC_2r : _FR2R<0b110000, (outs), (ins GRRegs:$src1, GRRegs:$src2), 824249423Sdim "setpsc res[$src1], $src2", 825249423Sdim [(int_xcore_setpsc GRRegs:$src1, GRRegs:$src2)]>; 826249423Sdim 827249423Sdimdef GETST_2r : _F2R<0b000001, (outs GRRegs:$dst), (ins GRRegs:$r), 828221345Sdim "getst $dst, res[$r]", 829221345Sdim [(set GRRegs:$dst, (int_xcore_getst GRRegs:$r))]>; 830221345Sdim 831249423Sdimdef INITSP_2r : _F2R<0b000100, (outs), (ins GRRegs:$src, GRRegs:$t), 832221345Sdim "init t[$t]:sp, $src", 833221345Sdim [(int_xcore_initsp GRRegs:$t, GRRegs:$src)]>; 834221345Sdim 835249423Sdimdef INITPC_2r : _F2R<0b000000, (outs), (ins GRRegs:$src, GRRegs:$t), 836221345Sdim "init t[$t]:pc, $src", 837221345Sdim [(int_xcore_initpc GRRegs:$t, GRRegs:$src)]>; 838221345Sdim 839249423Sdimdef INITCP_2r : _F2R<0b000110, (outs), (ins GRRegs:$src, GRRegs:$t), 840221345Sdim "init t[$t]:cp, $src", 841221345Sdim [(int_xcore_initcp GRRegs:$t, GRRegs:$src)]>; 842221345Sdim 843249423Sdimdef INITDP_2r : _F2R<0b000010, (outs), (ins GRRegs:$src, GRRegs:$t), 844221345Sdim "init t[$t]:dp, $src", 845221345Sdim [(int_xcore_initdp GRRegs:$t, GRRegs:$src)]>; 846221345Sdim 847249423Sdimdef PEEK_2r : _F2R<0b101110, (outs GRRegs:$dst), (ins GRRegs:$src), 848249423Sdim "peek $dst, res[$src]", 849249423Sdim [(set GRRegs:$dst, (int_xcore_peek GRRegs:$src))]>; 850249423Sdim 851249423Sdimdef ENDIN_2r : _F2R<0b100101, (outs GRRegs:$dst), (ins GRRegs:$src), 852249423Sdim "endin $dst, res[$src]", 853249423Sdim [(set GRRegs:$dst, (int_xcore_endin GRRegs:$src))]>; 854249423Sdim 855249423Sdimdef EEF_2r : _F2R<0b001011, (outs), (ins GRRegs:$a, GRRegs:$b), 856249423Sdim "eef $a, res[$b]", []>; 857249423Sdim 858249423Sdimdef EET_2r : _F2R<0b001001, (outs), (ins GRRegs:$a, GRRegs:$b), 859249423Sdim "eet $a, res[$b]", []>; 860249423Sdim 861249423Sdimdef TSETMR_2r : _F2RImm<0b000111, (outs), (ins i32imm:$a, GRRegs:$b), 862249423Sdim "tsetmr r$a, $b", []>; 863249423Sdim 864193323Sed// Two operand long 865249423Sdimdef BITREV_l2r : _FL2R<0b0000011000, (outs GRRegs:$dst), (ins GRRegs:$src), 866249423Sdim "bitrev $dst, $src", 867249423Sdim [(set GRRegs:$dst, (int_xcore_bitrev GRRegs:$src))]>; 868193323Sed 869249423Sdimdef BYTEREV_l2r : _FL2R<0b0000011001, (outs GRRegs:$dst), (ins GRRegs:$src), 870249423Sdim "byterev $dst, $src", 871249423Sdim [(set GRRegs:$dst, (bswap GRRegs:$src))]>; 872193323Sed 873249423Sdimdef CLZ_l2r : _FL2R<0b000111000, (outs GRRegs:$dst), (ins GRRegs:$src), 874249423Sdim "clz $dst, $src", 875249423Sdim [(set GRRegs:$dst, (ctlz GRRegs:$src))]>; 876193323Sed 877249423Sdimdef GETD_l2r : _FL2R<0b0001111001, (outs GRRegs:$dst), (ins GRRegs:$src), 878249423Sdim "getd $dst, res[$src]", []>; 879218893Sdim 880249423Sdimdef GETN_l2r : _FL2R<0b0011011001, (outs GRRegs:$dst), (ins GRRegs:$src), 881249423Sdim "getn $dst, res[$src]", []>; 882219077Sdim 883249423Sdimdef SETC_l2r : _FL2R<0b0010111001, (outs), (ins GRRegs:$r, GRRegs:$val), 884249423Sdim "setc res[$r], $val", 885249423Sdim [(int_xcore_setc GRRegs:$r, GRRegs:$val)]>; 886221345Sdim 887249423Sdimdef SETTW_l2r : _FLR2R<0b0010011001, (outs), (ins GRRegs:$r, GRRegs:$val), 888249423Sdim "settw res[$r], $val", 889249423Sdim [(int_xcore_settw GRRegs:$r, GRRegs:$val)]>; 890221345Sdim 891249423Sdimdef GETPS_l2r : _FL2R<0b0001011001, (outs GRRegs:$dst), (ins GRRegs:$src), 892249423Sdim "get $dst, ps[$src]", 893249423Sdim [(set GRRegs:$dst, (int_xcore_getps GRRegs:$src))]>; 894249423Sdim 895249423Sdimdef SETPS_l2r : _FLR2R<0b0001111000, (outs), (ins GRRegs:$src1, GRRegs:$src2), 896249423Sdim "set ps[$src1], $src2", 897249423Sdim [(int_xcore_setps GRRegs:$src1, GRRegs:$src2)]>; 898249423Sdim 899249423Sdimdef INITLR_l2r : _FL2R<0b0001011000, (outs), (ins GRRegs:$src, GRRegs:$t), 900221345Sdim "init t[$t]:lr, $src", 901221345Sdim [(int_xcore_initlr GRRegs:$t, GRRegs:$src)]>; 902221345Sdim 903249423Sdimdef SETCLK_l2r : _FLR2R<0b0000111001, (outs), (ins GRRegs:$src1, GRRegs:$src2), 904249423Sdim "setclk res[$src1], $src2", 905249423Sdim [(int_xcore_setclk GRRegs:$src1, GRRegs:$src2)]>; 906221345Sdim 907249423Sdimdef SETN_l2r : _FLR2R<0b0011011000, (outs), (ins GRRegs:$src1, GRRegs:$src2), 908249423Sdim "setn res[$src1], $src2", []>; 909221345Sdim 910249423Sdimdef SETRDY_l2r : _FLR2R<0b0010111000, (outs), (ins GRRegs:$src1, GRRegs:$src2), 911249423Sdim "setrdy res[$src1], $src2", 912249423Sdim [(int_xcore_setrdy GRRegs:$src1, GRRegs:$src2)]>; 913221345Sdim 914249423Sdimdef TESTLCL_l2r : _FL2R<0b0010011000, (outs GRRegs:$dst), (ins GRRegs:$src), 915249423Sdim "testlcl $dst, res[$src]", []>; 916226633Sdim 917193323Sed// One operand short 918249423Sdimdef MSYNC_1r : _F1R<0b000111, (outs), (ins GRRegs:$a), 919249423Sdim "msync res[$a]", 920249423Sdim [(int_xcore_msync GRRegs:$a)]>; 921249423Sdimdef MJOIN_1r : _F1R<0b000101, (outs), (ins GRRegs:$a), 922249423Sdim "mjoin res[$a]", 923249423Sdim [(int_xcore_mjoin GRRegs:$a)]>; 924221345Sdim 925204642Srdivackylet isBranch=1, isIndirectBranch=1, isTerminator=1, isBarrier = 1 in 926249423Sdimdef BAU_1r : _F1R<0b001001, (outs), (ins GRRegs:$a), 927249423Sdim "bau $a", 928249423Sdim [(brind GRRegs:$a)]>; 929193323Sed 930204642Srdivackylet isBranch=1, isIndirectBranch=1, isTerminator=1, isBarrier = 1 in 931204642Srdivackydef BR_JT : PseudoInstXCore<(outs), (ins InlineJT:$t, GRRegs:$i), 932204642Srdivacky "bru $i\n$t", 933204642Srdivacky [(XCoreBR_JT tjumptable:$t, GRRegs:$i)]>; 934204642Srdivacky 935204642Srdivackylet isBranch=1, isIndirectBranch=1, isTerminator=1, isBarrier = 1 in 936204642Srdivackydef BR_JT32 : PseudoInstXCore<(outs), (ins InlineJT32:$t, GRRegs:$i), 937204642Srdivacky "bru $i\n$t", 938204642Srdivacky [(XCoreBR_JT32 tjumptable:$t, GRRegs:$i)]>; 939204642Srdivacky 940249423Sdimlet isBranch=1, isIndirectBranch=1, isTerminator=1, isBarrier = 1 in 941249423Sdimdef BRU_1r : _F1R<0b001010, (outs), (ins GRRegs:$a), "bru $a", []>; 942249423Sdim 943193323Sedlet Defs=[SP], neverHasSideEffects=1 in 944249423Sdimdef SETSP_1r : _F1R<0b001011, (outs), (ins GRRegs:$a), "set sp, $a", []>; 945193323Sed 946249423Sdimlet neverHasSideEffects=1 in 947249423Sdimdef SETDP_1r : _F1R<0b001100, (outs), (ins GRRegs:$a), "set dp, $a", []>; 948249423Sdim 949249423Sdimlet neverHasSideEffects=1 in 950249423Sdimdef SETCP_1r : _F1R<0b001101, (outs), (ins GRRegs:$a), "set cp, $a", []>; 951249423Sdim 952204642Srdivackylet hasCtrlDep = 1 in 953249423Sdimdef ECALLT_1r : _F1R<0b010011, (outs), (ins GRRegs:$a), 954249423Sdim "ecallt $a", 955193323Sed []>; 956193323Sed 957204642Srdivackylet hasCtrlDep = 1 in 958249423Sdimdef ECALLF_1r : _F1R<0b010010, (outs), (ins GRRegs:$a), 959249423Sdim "ecallf $a", 960193323Sed []>; 961193323Sed 962193323Sedlet isCall=1, 963203954Srdivacky// All calls clobber the link register and the non-callee-saved registers: 964226633SdimDefs = [R0, R1, R2, R3, R11, LR], Uses = [SP] in { 965249423Sdimdef BLA_1r : _F1R<0b001000, (outs), (ins GRRegs:$a), 966249423Sdim "bla $a", 967249423Sdim [(XCoreBranchLink GRRegs:$a)]>; 968193323Sed} 969193323Sed 970249423Sdimdef SYNCR_1r : _F1R<0b100001, (outs), (ins GRRegs:$a), 971249423Sdim "syncr res[$a]", 972249423Sdim [(int_xcore_syncr GRRegs:$a)]>; 973219077Sdim 974249423Sdimdef FREER_1r : _F1R<0b000100, (outs), (ins GRRegs:$a), 975249423Sdim "freer res[$a]", 976249423Sdim [(int_xcore_freer GRRegs:$a)]>; 977218893Sdim 978226633Sdimlet Uses=[R11] in { 979249423Sdimdef SETV_1r : _F1R<0b010001, (outs), (ins GRRegs:$a), 980249423Sdim "setv res[$a], r11", 981249423Sdim [(int_xcore_setv GRRegs:$a, R11)]>; 982219077Sdim 983249423Sdimdef SETEV_1r : _F1R<0b001111, (outs), (ins GRRegs:$a), 984249423Sdim "setev res[$a], r11", 985249423Sdim [(int_xcore_setev GRRegs:$a, R11)]>; 986226633Sdim} 987226633Sdim 988249423Sdimdef DGETREG_1r : _F1R<0b001110, (outs GRRegs:$a), (ins), "dgetreg $a", []>; 989219077Sdim 990249423Sdimdef EDU_1r : _F1R<0b000000, (outs), (ins GRRegs:$a), "edu res[$a]", []>; 991249423Sdim 992249423Sdimdef EEU_1r : _F1R<0b000001, (outs), (ins GRRegs:$a), 993249423Sdim "eeu res[$a]", 994249423Sdim [(int_xcore_eeu GRRegs:$a)]>; 995249423Sdim 996249423Sdimdef KCALL_1r : _F1R<0b010000, (outs), (ins GRRegs:$a), "kcall $a", []>; 997249423Sdim 998249423Sdimdef WAITEF_1R : _F1R<0b000011, (outs), (ins GRRegs:$a), "waitef $a", []>; 999249423Sdim 1000249423Sdimdef WAITET_1R : _F1R<0b000010, (outs), (ins GRRegs:$a), "waitet $a", []>; 1001249423Sdim 1002249423Sdimdef TSTART_1R : _F1R<0b000110, (outs), (ins GRRegs:$a), "start t[$a]", []>; 1003249423Sdim 1004249423Sdimdef CLRPT_1R : _F1R<0b100000, (outs), (ins GRRegs:$a), "clrpt res[$a]", []>; 1005249423Sdim 1006193323Sed// Zero operand short 1007193323Sed 1008249423Sdimdef CLRE_0R : _F0R<0b0000001101, (outs), (ins), "clre", [(int_xcore_clre)]>; 1009219077Sdim 1010249423Sdimdef DCALL_0R : _F0R<0b0000011100, (outs), (ins), "dcall", []>; 1011249423Sdim 1012249423Sdimlet Defs = [SP], Uses = [SP] in 1013249423Sdimdef DENTSP_0R : _F0R<0b0001001100, (outs), (ins), "dentsp", []>; 1014249423Sdim 1015249423Sdimlet Defs = [SP] in 1016249423Sdimdef DRESTSP_0R : _F0R<0b0001001101, (outs), (ins), "drestsp", []>; 1017249423Sdim 1018249423Sdimdef DRET_0R : _F0R<0b0000011110, (outs), (ins), "dret", []>; 1019249423Sdim 1020249423Sdimdef FREET_0R : _F0R<0b0000001111, (outs), (ins), "freet", []>; 1021249423Sdim 1022226633Sdimlet Defs = [R11] in { 1023249423Sdimdef GETID_0R : _F0R<0b0001001110, (outs), (ins), 1024226633Sdim "get r11, id", 1025226633Sdim [(set R11, (int_xcore_getid))]>; 1026193323Sed 1027249423Sdimdef GETED_0R : _F0R<0b0000111110, (outs), (ins), 1028226633Sdim "get r11, ed", 1029226633Sdim [(set R11, (int_xcore_geted))]>; 1030226633Sdim 1031249423Sdimdef GETET_0R : _F0R<0b0000111111, (outs), (ins), 1032226633Sdim "get r11, et", 1033226633Sdim [(set R11, (int_xcore_getet))]>; 1034249423Sdim 1035249423Sdimdef GETKEP_0R : _F0R<0b0001001111, (outs), (ins), 1036249423Sdim "get r11, kep", []>; 1037249423Sdim 1038249423Sdimdef GETKSP_0R : _F0R<0b0001011100, (outs), (ins), 1039249423Sdim "get r11, ksp", []>; 1040226633Sdim} 1041226633Sdim 1042249423Sdimlet Defs = [SP] in 1043249423Sdimdef KRET_0R : _F0R<0b0000011101, (outs), (ins), "kret", []>; 1044249423Sdim 1045249423Sdimlet Uses = [SP], mayLoad = 1 in { 1046249423Sdimdef LDET_0R : _F0R<0b0001011110, (outs), (ins), "ldw et, sp[4]", []>; 1047249423Sdim 1048249423Sdimdef LDSED_0R : _F0R<0b0001011101, (outs), (ins), "ldw sed, sp[3]", []>; 1049249423Sdim 1050249423Sdimdef LDSPC_0R : _F0R<0b0000101100, (outs), (ins), "ldw spc, sp[1]", []>; 1051249423Sdim 1052249423Sdimdef LDSSR_0R : _F0R<0b0000101110, (outs), (ins), "ldw ssr, sp[2]", []>; 1053249423Sdim} 1054249423Sdim 1055249423Sdimlet Uses=[R11] in 1056249423Sdimdef SETKEP_0R : _F0R<0b0000011111, (outs), (ins), "set kep, r11", []>; 1057249423Sdim 1058249423Sdimdef SSYNC_0r : _F0R<0b0000001110, (outs), (ins), 1059221345Sdim "ssync", 1060239462Sdim [(int_xcore_ssync)]>; 1061221345Sdim 1062249423Sdimlet Uses = [SP], mayStore = 1 in { 1063249423Sdimdef STET_0R : _F0R<0b0000111101, (outs), (ins), "stw et, sp[4]", []>; 1064249423Sdim 1065249423Sdimdef STSED_0R : _F0R<0b0000111100, (outs), (ins), "stw sed, sp[3]", []>; 1066249423Sdim 1067249423Sdimdef STSPC_0R : _F0R<0b0000101101, (outs), (ins), "stw spc, sp[1]", []>; 1068249423Sdim 1069249423Sdimdef STSSR_0R : _F0R<0b0000101111, (outs), (ins), "stw ssr, sp[2]", []>; 1070249423Sdim} 1071249423Sdim 1072219077Sdimlet isBranch=1, isIndirectBranch=1, isTerminator=1, isBarrier = 1, 1073219077Sdim hasSideEffects = 1 in 1074249423Sdimdef WAITEU_0R : _F0R<0b0000001100, (outs), (ins), 1075249423Sdim "waiteu", 1076249423Sdim [(brind (int_xcore_waitevent))]>; 1077219077Sdim 1078193323Sed//===----------------------------------------------------------------------===// 1079193323Sed// Non-Instruction Patterns 1080193323Sed//===----------------------------------------------------------------------===// 1081193323Sed 1082249423Sdimdef : Pat<(XCoreBranchLink tglobaladdr:$addr), (BLRF_lu10 tglobaladdr:$addr)>; 1083249423Sdimdef : Pat<(XCoreBranchLink texternalsym:$addr), (BLRF_lu10 texternalsym:$addr)>; 1084193323Sed 1085193323Sed/// sext_inreg 1086193323Seddef : Pat<(sext_inreg GRRegs:$b, i1), (SEXT_rus GRRegs:$b, 1)>; 1087193323Seddef : Pat<(sext_inreg GRRegs:$b, i8), (SEXT_rus GRRegs:$b, 8)>; 1088193323Seddef : Pat<(sext_inreg GRRegs:$b, i16), (SEXT_rus GRRegs:$b, 16)>; 1089193323Sed 1090193323Sed/// loads 1091193323Seddef : Pat<(zextloadi8 (add GRRegs:$addr, GRRegs:$offset)), 1092193323Sed (LD8U_3r GRRegs:$addr, GRRegs:$offset)>; 1093193323Seddef : Pat<(zextloadi8 GRRegs:$addr), (LD8U_3r GRRegs:$addr, (LDC_ru6 0))>; 1094193323Sed 1095198090Srdivackydef : Pat<(sextloadi16 (lda16f GRRegs:$addr, GRRegs:$offset)), 1096193323Sed (LD16S_3r GRRegs:$addr, GRRegs:$offset)>; 1097193323Seddef : Pat<(sextloadi16 GRRegs:$addr), (LD16S_3r GRRegs:$addr, (LDC_ru6 0))>; 1098193323Sed 1099193323Seddef : Pat<(load (ldawf GRRegs:$addr, GRRegs:$offset)), 1100193323Sed (LDW_3r GRRegs:$addr, GRRegs:$offset)>; 1101193323Seddef : Pat<(load (add GRRegs:$addr, immUs4:$offset)), 1102193323Sed (LDW_2rus GRRegs:$addr, (div4_xform immUs4:$offset))>; 1103193323Seddef : Pat<(load GRRegs:$addr), (LDW_2rus GRRegs:$addr, 0)>; 1104193323Sed 1105193323Sed/// anyext 1106193323Seddef : Pat<(extloadi8 (add GRRegs:$addr, GRRegs:$offset)), 1107193323Sed (LD8U_3r GRRegs:$addr, GRRegs:$offset)>; 1108193323Seddef : Pat<(extloadi8 GRRegs:$addr), (LD8U_3r GRRegs:$addr, (LDC_ru6 0))>; 1109193323Seddef : Pat<(extloadi16 (lda16f GRRegs:$addr, GRRegs:$offset)), 1110193323Sed (LD16S_3r GRRegs:$addr, GRRegs:$offset)>; 1111193323Seddef : Pat<(extloadi16 GRRegs:$addr), (LD16S_3r GRRegs:$addr, (LDC_ru6 0))>; 1112193323Sed 1113193323Sed/// stores 1114193323Seddef : Pat<(truncstorei8 GRRegs:$val, (add GRRegs:$addr, GRRegs:$offset)), 1115193323Sed (ST8_l3r GRRegs:$val, GRRegs:$addr, GRRegs:$offset)>; 1116193323Seddef : Pat<(truncstorei8 GRRegs:$val, GRRegs:$addr), 1117193323Sed (ST8_l3r GRRegs:$val, GRRegs:$addr, (LDC_ru6 0))>; 1118193323Sed 1119193323Seddef : Pat<(truncstorei16 GRRegs:$val, (lda16f GRRegs:$addr, GRRegs:$offset)), 1120193323Sed (ST16_l3r GRRegs:$val, GRRegs:$addr, GRRegs:$offset)>; 1121193323Seddef : Pat<(truncstorei16 GRRegs:$val, GRRegs:$addr), 1122193323Sed (ST16_l3r GRRegs:$val, GRRegs:$addr, (LDC_ru6 0))>; 1123193323Sed 1124193323Seddef : Pat<(store GRRegs:$val, (ldawf GRRegs:$addr, GRRegs:$offset)), 1125249423Sdim (STW_l3r GRRegs:$val, GRRegs:$addr, GRRegs:$offset)>; 1126193323Seddef : Pat<(store GRRegs:$val, (add GRRegs:$addr, immUs4:$offset)), 1127193323Sed (STW_2rus GRRegs:$val, GRRegs:$addr, (div4_xform immUs4:$offset))>; 1128193323Seddef : Pat<(store GRRegs:$val, GRRegs:$addr), 1129193323Sed (STW_2rus GRRegs:$val, GRRegs:$addr, 0)>; 1130193323Sed 1131193323Sed/// cttz 1132193323Seddef : Pat<(cttz GRRegs:$src), (CLZ_l2r (BITREV_l2r GRRegs:$src))>; 1133193323Sed 1134193323Sed/// trap 1135193323Seddef : Pat<(trap), (ECALLF_1r (LDC_ru6 0))>; 1136193323Sed 1137193323Sed/// 1138193323Sed/// branch patterns 1139193323Sed/// 1140193323Sed 1141193323Sed// unconditional branch 1142193323Seddef : Pat<(br bb:$addr), (BRFU_lu6 bb:$addr)>; 1143193323Sed 1144193323Sed// direct match equal/notequal zero brcond 1145193323Seddef : Pat<(brcond (setne GRRegs:$lhs, 0), bb:$dst), 1146193323Sed (BRFT_lru6 GRRegs:$lhs, bb:$dst)>; 1147193323Seddef : Pat<(brcond (seteq GRRegs:$lhs, 0), bb:$dst), 1148193323Sed (BRFF_lru6 GRRegs:$lhs, bb:$dst)>; 1149193323Sed 1150193323Seddef : Pat<(brcond (setle GRRegs:$lhs, GRRegs:$rhs), bb:$dst), 1151193323Sed (BRFF_lru6 (LSS_3r GRRegs:$rhs, GRRegs:$lhs), bb:$dst)>; 1152193323Seddef : Pat<(brcond (setule GRRegs:$lhs, GRRegs:$rhs), bb:$dst), 1153193323Sed (BRFF_lru6 (LSU_3r GRRegs:$rhs, GRRegs:$lhs), bb:$dst)>; 1154193323Seddef : Pat<(brcond (setge GRRegs:$lhs, GRRegs:$rhs), bb:$dst), 1155193323Sed (BRFF_lru6 (LSS_3r GRRegs:$lhs, GRRegs:$rhs), bb:$dst)>; 1156193323Seddef : Pat<(brcond (setuge GRRegs:$lhs, GRRegs:$rhs), bb:$dst), 1157193323Sed (BRFF_lru6 (LSU_3r GRRegs:$lhs, GRRegs:$rhs), bb:$dst)>; 1158193323Seddef : Pat<(brcond (setne GRRegs:$lhs, GRRegs:$rhs), bb:$dst), 1159193323Sed (BRFF_lru6 (EQ_3r GRRegs:$lhs, GRRegs:$rhs), bb:$dst)>; 1160193323Seddef : Pat<(brcond (setne GRRegs:$lhs, immUs:$rhs), bb:$dst), 1161193323Sed (BRFF_lru6 (EQ_2rus GRRegs:$lhs, immUs:$rhs), bb:$dst)>; 1162193323Sed 1163193323Sed// generic brcond pattern 1164193323Seddef : Pat<(brcond GRRegs:$cond, bb:$addr), (BRFT_lru6 GRRegs:$cond, bb:$addr)>; 1165193323Sed 1166193323Sed 1167193323Sed/// 1168193323Sed/// Select patterns 1169193323Sed/// 1170193323Sed 1171193323Sed// direct match equal/notequal zero select 1172193323Seddef : Pat<(select (setne GRRegs:$lhs, 0), GRRegs:$T, GRRegs:$F), 1173193323Sed (SELECT_CC GRRegs:$lhs, GRRegs:$T, GRRegs:$F)>; 1174193323Sed 1175193323Seddef : Pat<(select (seteq GRRegs:$lhs, 0), GRRegs:$T, GRRegs:$F), 1176193323Sed (SELECT_CC GRRegs:$lhs, GRRegs:$F, GRRegs:$T)>; 1177193323Sed 1178193323Seddef : Pat<(select (setle GRRegs:$lhs, GRRegs:$rhs), GRRegs:$T, GRRegs:$F), 1179193323Sed (SELECT_CC (LSS_3r GRRegs:$rhs, GRRegs:$lhs), GRRegs:$F, GRRegs:$T)>; 1180193323Seddef : Pat<(select (setule GRRegs:$lhs, GRRegs:$rhs), GRRegs:$T, GRRegs:$F), 1181193323Sed (SELECT_CC (LSU_3r GRRegs:$rhs, GRRegs:$lhs), GRRegs:$F, GRRegs:$T)>; 1182193323Seddef : Pat<(select (setge GRRegs:$lhs, GRRegs:$rhs), GRRegs:$T, GRRegs:$F), 1183193323Sed (SELECT_CC (LSS_3r GRRegs:$lhs, GRRegs:$rhs), GRRegs:$F, GRRegs:$T)>; 1184193323Seddef : Pat<(select (setuge GRRegs:$lhs, GRRegs:$rhs), GRRegs:$T, GRRegs:$F), 1185193323Sed (SELECT_CC (LSU_3r GRRegs:$lhs, GRRegs:$rhs), GRRegs:$F, GRRegs:$T)>; 1186193323Seddef : Pat<(select (setne GRRegs:$lhs, GRRegs:$rhs), GRRegs:$T, GRRegs:$F), 1187193323Sed (SELECT_CC (EQ_3r GRRegs:$lhs, GRRegs:$rhs), GRRegs:$F, GRRegs:$T)>; 1188193323Seddef : Pat<(select (setne GRRegs:$lhs, immUs:$rhs), GRRegs:$T, GRRegs:$F), 1189193323Sed (SELECT_CC (EQ_2rus GRRegs:$lhs, immUs:$rhs), GRRegs:$F, GRRegs:$T)>; 1190193323Sed 1191193323Sed/// 1192193323Sed/// setcc patterns, only matched when none of the above brcond 1193193323Sed/// patterns match 1194193323Sed/// 1195193323Sed 1196193323Sed// setcc 2 register operands 1197193323Seddef : Pat<(setle GRRegs:$lhs, GRRegs:$rhs), 1198193323Sed (EQ_2rus (LSS_3r GRRegs:$rhs, GRRegs:$lhs), 0)>; 1199193323Seddef : Pat<(setule GRRegs:$lhs, GRRegs:$rhs), 1200193323Sed (EQ_2rus (LSU_3r GRRegs:$rhs, GRRegs:$lhs), 0)>; 1201193323Sed 1202193323Seddef : Pat<(setgt GRRegs:$lhs, GRRegs:$rhs), 1203193323Sed (LSS_3r GRRegs:$rhs, GRRegs:$lhs)>; 1204193323Seddef : Pat<(setugt GRRegs:$lhs, GRRegs:$rhs), 1205193323Sed (LSU_3r GRRegs:$rhs, GRRegs:$lhs)>; 1206193323Sed 1207193323Seddef : Pat<(setge GRRegs:$lhs, GRRegs:$rhs), 1208193323Sed (EQ_2rus (LSS_3r GRRegs:$lhs, GRRegs:$rhs), 0)>; 1209193323Seddef : Pat<(setuge GRRegs:$lhs, GRRegs:$rhs), 1210193323Sed (EQ_2rus (LSU_3r GRRegs:$lhs, GRRegs:$rhs), 0)>; 1211193323Sed 1212193323Seddef : Pat<(setlt GRRegs:$lhs, GRRegs:$rhs), 1213193323Sed (LSS_3r GRRegs:$lhs, GRRegs:$rhs)>; 1214193323Seddef : Pat<(setult GRRegs:$lhs, GRRegs:$rhs), 1215193323Sed (LSU_3r GRRegs:$lhs, GRRegs:$rhs)>; 1216193323Sed 1217193323Seddef : Pat<(setne GRRegs:$lhs, GRRegs:$rhs), 1218193323Sed (EQ_2rus (EQ_3r GRRegs:$lhs, GRRegs:$rhs), 0)>; 1219193323Sed 1220193323Seddef : Pat<(seteq GRRegs:$lhs, GRRegs:$rhs), 1221193323Sed (EQ_3r GRRegs:$lhs, GRRegs:$rhs)>; 1222193323Sed 1223193323Sed// setcc reg/imm operands 1224193323Seddef : Pat<(seteq GRRegs:$lhs, immUs:$rhs), 1225193323Sed (EQ_2rus GRRegs:$lhs, immUs:$rhs)>; 1226193323Seddef : Pat<(setne GRRegs:$lhs, immUs:$rhs), 1227193323Sed (EQ_2rus (EQ_2rus GRRegs:$lhs, immUs:$rhs), 0)>; 1228193323Sed 1229193323Sed// misc 1230193323Seddef : Pat<(add GRRegs:$addr, immUs4:$offset), 1231193323Sed (LDAWF_l2rus GRRegs:$addr, (div4_xform immUs4:$offset))>; 1232193323Sed 1233193323Seddef : Pat<(sub GRRegs:$addr, immUs4:$offset), 1234193323Sed (LDAWB_l2rus GRRegs:$addr, (div4_xform immUs4:$offset))>; 1235193323Sed 1236193323Seddef : Pat<(and GRRegs:$val, immMskBitp:$mask), 1237193323Sed (ZEXT_rus GRRegs:$val, (msksize_xform immMskBitp:$mask))>; 1238193323Sed 1239193323Sed// (sub X, imm) gets canonicalized to (add X, -imm). Match this form. 1240193323Seddef : Pat<(add GRRegs:$src1, immUsNeg:$src2), 1241193323Sed (SUB_2rus GRRegs:$src1, (neg_xform immUsNeg:$src2))>; 1242193323Sed 1243193323Seddef : Pat<(add GRRegs:$src1, immUs4Neg:$src2), 1244193323Sed (LDAWB_l2rus GRRegs:$src1, (div4neg_xform immUs4Neg:$src2))>; 1245193323Sed 1246193323Sed/// 1247193323Sed/// Some peepholes 1248193323Sed/// 1249193323Sed 1250193323Seddef : Pat<(mul GRRegs:$src, 3), 1251193323Sed (LDA16F_l3r GRRegs:$src, GRRegs:$src)>; 1252193323Sed 1253193323Seddef : Pat<(mul GRRegs:$src, 5), 1254193323Sed (LDAWF_l3r GRRegs:$src, GRRegs:$src)>; 1255193323Sed 1256193323Seddef : Pat<(mul GRRegs:$src, -3), 1257193323Sed (LDAWB_l3r GRRegs:$src, GRRegs:$src)>; 1258193323Sed 1259193323Sed// ashr X, 32 is equivalent to ashr X, 31 on the XCore. 1260193323Seddef : Pat<(sra GRRegs:$src, 31), 1261193323Sed (ASHR_l2rus GRRegs:$src, 32)>; 1262193323Sed 1263198090Srdivackydef : Pat<(brcond (setlt GRRegs:$lhs, 0), bb:$dst), 1264198090Srdivacky (BRFT_lru6 (ASHR_l2rus GRRegs:$lhs, 32), bb:$dst)>; 1265198090Srdivacky 1266198090Srdivacky// setge X, 0 is canonicalized to setgt X, -1 1267198090Srdivackydef : Pat<(brcond (setgt GRRegs:$lhs, -1), bb:$dst), 1268198090Srdivacky (BRFF_lru6 (ASHR_l2rus GRRegs:$lhs, 32), bb:$dst)>; 1269198090Srdivacky 1270198090Srdivackydef : Pat<(select (setlt GRRegs:$lhs, 0), GRRegs:$T, GRRegs:$F), 1271198090Srdivacky (SELECT_CC (ASHR_l2rus GRRegs:$lhs, 32), GRRegs:$T, GRRegs:$F)>; 1272198090Srdivacky 1273198090Srdivackydef : Pat<(select (setgt GRRegs:$lhs, -1), GRRegs:$T, GRRegs:$F), 1274198090Srdivacky (SELECT_CC (ASHR_l2rus GRRegs:$lhs, 32), GRRegs:$F, GRRegs:$T)>; 1275198090Srdivacky 1276198090Srdivackydef : Pat<(setgt GRRegs:$lhs, -1), 1277198090Srdivacky (EQ_2rus (ASHR_l2rus GRRegs:$lhs, 32), 0)>; 1278198090Srdivacky 1279198090Srdivackydef : Pat<(sra (shl GRRegs:$src, immBpwSubBitp:$imm), immBpwSubBitp:$imm), 1280198090Srdivacky (SEXT_rus GRRegs:$src, (bpwsub_xform immBpwSubBitp:$imm))>; 1281