1 //===- MipsInstrInfo.td - Mips Register defs --------------------*- C++ -*-===//
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 //===----------------------------------------------------------------------===//
11 // Instruction format superclass
12 //===----------------------------------------------------------------------===//
14 include "MipsInstrFormats.td"
16 //===----------------------------------------------------------------------===//
17 // Mips profiles and nodes
18 //===----------------------------------------------------------------------===//
20 def SDT_MipsRet : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
21 def SDT_MipsJmpLink : SDTypeProfile<0, 1, [SDTCisVT<0, iPTR>]>;
22 def SDT_MipsSelectCC : SDTypeProfile<1, 3, [SDTCisSameAs<0, 1>,
23 SDTCisSameAs<1, 2>, SDTCisInt<3>]>;
24 def SDT_MipsCallSeqStart : SDCallSeqStart<[SDTCisVT<0, i32>]>;
25 def SDT_MipsCallSeqEnd : SDCallSeqEnd<[SDTCisVT<0, i32>, SDTCisVT<1, i32>]>;
28 def MipsJmpLink : SDNode<"MipsISD::JmpLink",SDT_MipsJmpLink, [SDNPHasChain,
31 // Hi and Lo nodes are used to handle global addresses. Used on
32 // MipsISelLowering to lower stuff like GlobalAddress, ExternalSymbol
33 // static model. (nothing to do with Mips Registers Hi and Lo)
34 def MipsHi : SDNode<"MipsISD::Hi", SDTIntUnaryOp, [SDNPOutFlag]>;
35 def MipsLo : SDNode<"MipsISD::Lo", SDTIntUnaryOp>;
38 def MipsRet : SDNode<"MipsISD::Ret", SDT_MipsRet, [SDNPHasChain,
41 // These are target-independent nodes, but have target-specific formats.
42 def callseq_start : SDNode<"ISD::CALLSEQ_START", SDT_MipsCallSeqStart,
43 [SDNPHasChain, SDNPOutFlag]>;
44 def callseq_end : SDNode<"ISD::CALLSEQ_END", SDT_MipsCallSeqEnd,
45 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
47 // Select Condition Code
48 def MipsSelectCC : SDNode<"MipsISD::SelectCC", SDT_MipsSelectCC>;
50 //===----------------------------------------------------------------------===//
51 // Mips Instruction Predicate Definitions.
52 //===----------------------------------------------------------------------===//
53 def IsAllegrex : Predicate<"Subtarget.isAllegrex()">;
55 //===----------------------------------------------------------------------===//
56 // Mips Operand, Complex Patterns and Transformations Definitions.
57 //===----------------------------------------------------------------------===//
59 // Instruction operand types
60 def brtarget : Operand<OtherVT>;
61 def calltarget : Operand<i32>;
62 def uimm16 : Operand<i32>;
63 def simm16 : Operand<i32>;
64 def shamt : Operand<i32>;
67 def mem : Operand<i32> {
68 let PrintMethod = "printMemOperand";
69 let MIOperandInfo = (ops simm16, CPURegs);
72 // Transformation Function - get the lower 16 bits.
73 def LO16 : SDNodeXForm<imm, [{
74 return getI32Imm((unsigned)N->getValue() & 0xFFFF);
77 // Transformation Function - get the higher 16 bits.
78 def HI16 : SDNodeXForm<imm, [{
79 return getI32Imm((unsigned)N->getValue() >> 16);
82 // Node immediate fits as 16-bit sign extended on target immediate.
84 def immSExt16 : PatLeaf<(imm), [{
85 if (N->getValueType(0) == MVT::i32)
86 return (int32_t)N->getValue() == (short)N->getValue();
88 return (int64_t)N->getValue() == (short)N->getValue();
91 // Node immediate fits as 16-bit zero extended on target immediate.
92 // The LO16 param means that only the lower 16 bits of the node
93 // immediate are caught.
95 def immZExt16 : PatLeaf<(imm), [{
96 if (N->getValueType(0) == MVT::i32)
97 return (uint32_t)N->getValue() == (unsigned short)N->getValue();
99 return (uint64_t)N->getValue() == (unsigned short)N->getValue();
102 // Node immediate fits as 32-bit zero extended on target immediate.
103 //def immZExt32 : PatLeaf<(imm), [{
104 // return (uint64_t)N->getValue() == (uint32_t)N->getValue();
107 // shamt field must fit in 5 bits.
108 def immZExt5 : PatLeaf<(imm), [{
109 return N->getValue() == ((N->getValue()) & 0x1f) ;
112 // Mips Address Mode! SDNode frameindex could possibily be a match
113 // since load and store instructions from stack used it.
114 def addr : ComplexPattern<i32, 2, "SelectAddr", [frameindex], []>;
116 //===----------------------------------------------------------------------===//
117 // Instructions specific format
118 //===----------------------------------------------------------------------===//
120 // Arithmetic 3 register operands
121 let isCommutable = 1 in
122 class ArithR<bits<6> op, bits<6> func, string instr_asm, SDNode OpNode,
123 InstrItinClass itin>:
127 (ins CPURegs:$b, CPURegs:$c),
128 !strconcat(instr_asm, " $dst, $b, $c"),
129 [(set CPURegs:$dst, (OpNode CPURegs:$b, CPURegs:$c))], itin>;
131 let isCommutable = 1 in
132 class ArithOverflowR<bits<6> op, bits<6> func, string instr_asm>:
136 (ins CPURegs:$b, CPURegs:$c),
137 !strconcat(instr_asm, " $dst, $b, $c"),
140 // Arithmetic 2 register operands
141 class ArithI<bits<6> op, string instr_asm, SDNode OpNode,
142 Operand Od, PatLeaf imm_type> :
145 (ins CPURegs:$b, Od:$c),
146 !strconcat(instr_asm, " $dst, $b, $c"),
147 [(set CPURegs:$dst, (OpNode CPURegs:$b, imm_type:$c))], IIAlu>;
149 // Arithmetic Multiply ADD/SUB
151 class MArithR<bits<6> func, string instr_asm> :
156 !strconcat(instr_asm, " $rs, $rt"),
160 class LogicR<bits<6> func, string instr_asm, SDNode OpNode>:
164 (ins CPURegs:$b, CPURegs:$c),
165 !strconcat(instr_asm, " $dst, $b, $c"),
166 [(set CPURegs:$dst, (OpNode CPURegs:$b, CPURegs:$c))], IIAlu>;
168 class LogicI<bits<6> op, string instr_asm, SDNode OpNode>:
171 (ins CPURegs:$b, uimm16:$c),
172 !strconcat(instr_asm, " $dst, $b, $c"),
173 [(set CPURegs:$dst, (OpNode CPURegs:$b, immZExt16:$c))], IIAlu>;
175 class LogicNOR<bits<6> op, bits<6> func, string instr_asm>:
179 (ins CPURegs:$b, CPURegs:$c),
180 !strconcat(instr_asm, " $dst, $b, $c"),
181 [(set CPURegs:$dst, (not (or CPURegs:$b, CPURegs:$c)))], IIAlu>;
185 class LogicR_shift_imm<bits<6> func, string instr_asm, SDNode OpNode>:
189 (ins CPURegs:$b, shamt:$c),
190 !strconcat(instr_asm, " $dst, $b, $c"),
191 [(set CPURegs:$dst, (OpNode CPURegs:$b, immZExt5:$c))], IIAlu>;
193 class LogicR_shift_reg<bits<6> func, string instr_asm, SDNode OpNode>:
197 (ins CPURegs:$b, CPURegs:$c),
198 !strconcat(instr_asm, " $dst, $b, $c"),
199 [(set CPURegs:$dst, (OpNode CPURegs:$b, CPURegs:$c))], IIAlu>;
201 // Load Upper Imediate
202 class LoadUpper<bits<6> op, string instr_asm>:
206 !strconcat(instr_asm, " $dst, $imm"),
210 let isSimpleLoad = 1, hasDelaySlot = 1 in
211 class LoadM<bits<6> op, string instr_asm, PatFrag OpNode>:
215 !strconcat(instr_asm, " $dst, $addr"),
216 [(set CPURegs:$dst, (OpNode addr:$addr))], IILoad>;
218 class StoreM<bits<6> op, string instr_asm, PatFrag OpNode>:
221 (ins CPURegs:$dst, mem:$addr),
222 !strconcat(instr_asm, " $dst, $addr"),
223 [(OpNode CPURegs:$dst, addr:$addr)], IIStore>;
225 // Conditional Branch
226 let isBranch = 1, isTerminator=1, hasDelaySlot = 1 in {
227 class CBranch<bits<6> op, string instr_asm, PatFrag cond_op>:
230 (ins CPURegs:$a, CPURegs:$b, brtarget:$offset),
231 !strconcat(instr_asm, " $a, $b, $offset"),
232 [(brcond (cond_op CPURegs:$a, CPURegs:$b), bb:$offset)],
236 class CBranchZero<bits<6> op, string instr_asm, PatFrag cond_op>:
239 (ins CPURegs:$src, brtarget:$offset),
240 !strconcat(instr_asm, " $src, $offset"),
241 [(brcond (cond_op CPURegs:$src, 0), bb:$offset)],
246 class SetCC_R<bits<6> op, bits<6> func, string instr_asm,
251 (ins CPURegs:$b, CPURegs:$c),
252 !strconcat(instr_asm, " $dst, $b, $c"),
253 [(set CPURegs:$dst, (cond_op CPURegs:$b, CPURegs:$c))],
256 class SetCC_I<bits<6> op, string instr_asm, PatFrag cond_op,
257 Operand Od, PatLeaf imm_type>:
260 (ins CPURegs:$b, Od:$c),
261 !strconcat(instr_asm, " $dst, $b, $c"),
262 [(set CPURegs:$dst, (cond_op CPURegs:$b, imm_type:$c))],
265 // Unconditional branch
266 let isBranch=1, isTerminator=1, isBarrier=1, hasDelaySlot = 1 in
267 class JumpFJ<bits<6> op, string instr_asm>:
270 (ins brtarget:$target),
271 !strconcat(instr_asm, " $target"),
272 [(br bb:$target)], IIBranch>;
274 let isBranch=1, isTerminator=1, isBarrier=1, rd=0, hasDelaySlot = 1 in
275 class JumpFR<bits<6> op, bits<6> func, string instr_asm>:
279 (ins CPURegs:$target),
280 !strconcat(instr_asm, " $target"),
281 [(brind CPURegs:$target)], IIBranch>;
283 // Jump and Link (Call)
284 let isCall=1, hasDelaySlot=1,
285 // All calls clobber the non-callee saved registers...
286 Defs = [AT, V0, V1, A0, A1, A2, A3, T0, T1, T2,
287 T3, T4, T5, T6, T7, T8, T9, K0, K1], Uses = [GP] in {
288 class JumpLink<bits<6> op, string instr_asm>:
291 (ins calltarget:$target),
292 !strconcat(instr_asm, " $target"),
293 [(MipsJmpLink imm:$target)], IIBranch>;
296 class JumpLinkReg<bits<6> op, bits<6> func, string instr_asm>:
301 !strconcat(instr_asm, " $rs"),
302 [(MipsJmpLink CPURegs:$rs)], IIBranch>;
304 class BranchLink<string instr_asm>:
307 (ins CPURegs:$rs, brtarget:$target),
308 !strconcat(instr_asm, " $rs, $target"),
313 class MulDiv<bits<6> func, string instr_asm, InstrItinClass itin>:
317 (ins CPURegs:$a, CPURegs:$b),
318 !strconcat(instr_asm, " $a, $b"),
322 class MoveFromTo<bits<6> func, string instr_asm>:
327 !strconcat(instr_asm, " $dst"),
330 // Count Leading Ones/Zeros in Word
331 class CountLeading<bits<6> func, string instr_asm>:
336 !strconcat(instr_asm, " $dst, $src"),
339 class EffectiveAddress<string instr_asm> :
344 [(set CPURegs:$dst, addr:$addr)], IIAlu>;
346 class SignExtInReg<bits<6> func, string instr_asm, ValueType vt>:
347 FR< 0x3f, func, (outs CPURegs:$dst), (ins CPURegs:$src),
348 !strconcat(instr_asm, " $dst, $src"),
349 [(set CPURegs:$dst, (sext_inreg CPURegs:$src, vt))], NoItinerary>;
352 //===----------------------------------------------------------------------===//
353 // Pseudo instructions
354 //===----------------------------------------------------------------------===//
356 // As stack alignment is always done with addiu, we need a 16-bit immediate
357 let Defs = [SP], Uses = [SP] in {
358 def ADJCALLSTACKDOWN : MipsPseudo<(outs), (ins uimm16:$amt),
359 "!ADJCALLSTACKDOWN $amt",
360 [(callseq_start imm:$amt)]>;
361 def ADJCALLSTACKUP : MipsPseudo<(outs), (ins uimm16:$amt1, uimm16:$amt2),
362 "!ADJCALLSTACKUP $amt1",
363 [(callseq_end imm:$amt1, imm:$amt2)]>;
366 // When handling PIC code the assembler needs .cpload and .cprestore
367 // directives. If the real instructions corresponding these directives
368 // are used, we have the same behavior, but get also a bunch of warnings
369 // from the assembler.
370 def CPLOAD : MipsPseudo<(outs), (ins CPURegs:$reg),
371 ".set noreorder\n\t.cpload $reg\n\t.set reorder\n",
373 def CPRESTORE : MipsPseudo<(outs), (ins uimm16:$loc),
374 ".cprestore $loc\n", []>;
376 // The supported Mips ISAs dont have any instruction close to the SELECT_CC
377 // operation. The solution is to create a Mips pseudo SELECT_CC instruction
378 // (MipsSelectCC), use LowerSELECT_CC to generate this instruction and finally
379 // replace it for real supported nodes into EmitInstrWithCustomInserter
380 let usesCustomDAGSchedInserter = 1 in {
381 def Select_CC : MipsPseudo<(outs CPURegs:$dst),
382 (ins CPURegs:$CmpRes, CPURegs:$T, CPURegs:$F), "# MipsSelect_CC",
383 [(set CPURegs:$dst, (MipsSelectCC CPURegs:$CmpRes,
384 CPURegs:$T, CPURegs:$F))]>;
387 //===----------------------------------------------------------------------===//
388 // Instruction definition
389 //===----------------------------------------------------------------------===//
391 //===----------------------------------------------------------------------===//
392 // MipsI Instructions
393 //===----------------------------------------------------------------------===//
397 // ADDiu just accept 16-bit immediates but we handle this on Pat's.
398 // immZExt32 is used here so it can match GlobalAddress immediates.
399 // MUL is a assembly macro in the current used ISAs.
400 def ADDiu : ArithI<0x09, "addiu", add, uimm16, immZExt16>;
401 def ADDi : ArithI<0x08, "addi", add, simm16, immSExt16>;
402 //def MUL : ArithR<0x1c, 0x02, "mul", mul, IIImul>;
403 def ADDu : ArithR<0x00, 0x21, "addu", add, IIAlu>;
404 def SUBu : ArithR<0x00, 0x23, "subu", sub, IIAlu>;
405 def ADD : ArithOverflowR<0x00, 0x20, "add">;
406 def SUB : ArithOverflowR<0x00, 0x22, "sub">;
409 def AND : LogicR<0x24, "and", and>;
410 def OR : LogicR<0x25, "or", or>;
411 def XOR : LogicR<0x26, "xor", xor>;
412 def ANDi : LogicI<0x0c, "andi", and>;
413 def ORi : LogicI<0x0d, "ori", or>;
414 def XORi : LogicI<0x0e, "xori", xor>;
415 def NOR : LogicNOR<0x00, 0x27, "nor">;
418 def SLL : LogicR_shift_imm<0x00, "sll", shl>;
419 def SRL : LogicR_shift_imm<0x02, "srl", srl>;
420 def SRA : LogicR_shift_imm<0x03, "sra", sra>;
421 def SLLV : LogicR_shift_reg<0x04, "sllv", shl>;
422 def SRLV : LogicR_shift_reg<0x06, "srlv", srl>;
423 def SRAV : LogicR_shift_reg<0x07, "srav", sra>;
425 // Load Upper Immediate
426 def LUi : LoadUpper<0x0f, "lui">;
429 def LB : LoadM<0x20, "lb", sextloadi8>;
430 def LBu : LoadM<0x24, "lbu", zextloadi8>;
431 def LH : LoadM<0x21, "lh", sextloadi16>;
432 def LHu : LoadM<0x25, "lhu", zextloadi16>;
433 def LW : LoadM<0x23, "lw", load>;
434 def SB : StoreM<0x28, "sb", truncstorei8>;
435 def SH : StoreM<0x29, "sh", truncstorei16>;
436 def SW : StoreM<0x2b, "sw", store>;
438 // Conditional Branch
439 def BEQ : CBranch<0x04, "beq", seteq>;
440 def BNE : CBranch<0x05, "bne", setne>;
443 def BGEZ : CBranchZero<0x01, "bgez", setge>;
446 def BGTZ : CBranchZero<0x07, "bgtz", setgt>;
447 def BLEZ : CBranchZero<0x07, "blez", setle>;
448 def BLTZ : CBranchZero<0x01, "bltz", setlt>;
451 // Set Condition Code
452 def SLT : SetCC_R<0x00, 0x2a, "slt", setlt>;
453 def SLTu : SetCC_R<0x00, 0x2b, "sltu", setult>;
454 def SLTi : SetCC_I<0x0a, "slti", setlt, simm16, immSExt16>;
455 def SLTiu : SetCC_I<0x0b, "sltiu", setult, uimm16, immZExt16>;
457 // Unconditional jump
458 def J : JumpFJ<0x02, "j">;
459 def JR : JumpFR<0x00, 0x08, "jr">;
461 // Jump and Link (Call)
462 def JAL : JumpLink<0x03, "jal">;
463 def JALR : JumpLinkReg<0x00, 0x09, "jalr">;
464 def BGEZAL : BranchLink<"bgezal">;
465 def BLTZAL : BranchLink<"bltzal">;
467 // MulDiv and Move From Hi/Lo operations, have
468 // their correpondent SDNodes created on ISelDAG.
469 // Special Mul, Div operations
470 def MULT : MulDiv<0x18, "mult", IIImul>;
471 def MULTu : MulDiv<0x19, "multu", IIImul>;
472 def DIV : MulDiv<0x1a, "div", IIIdiv>;
473 def DIVu : MulDiv<0x1b, "divu", IIIdiv>;
476 def MFHI : MoveFromTo<0x10, "mfhi">;
477 def MFLO : MoveFromTo<0x12, "mflo">;
478 def MTHI : MoveFromTo<0x11, "mthi">;
479 def MTLO : MoveFromTo<0x13, "mtlo">;
483 def NOP : FJ<0, (outs), (ins), "nop", [], IIAlu>;
485 // Ret instruction - as mips does not have "ret" a
486 // jr $ra must be generated.
487 let isReturn=1, isTerminator=1, hasDelaySlot=1,
488 isBarrier=1, hasCtrlDep=1, rs=0, rt=0, shamt=0 in
490 def RET : FR <0x00, 0x02, (outs), (ins CPURegs:$target),
491 "jr $target", [(MipsRet CPURegs:$target)], IIBranch>;
494 // FrameIndexes are legalized when they are operands from load/store
495 // instructions. The same not happens for stack address copies, so an
496 // add op with mem ComplexPattern is used and the stack address copy
497 // can be matched. It's similar to Sparc LEA_ADDRi
498 def LEA_ADDiu : EffectiveAddress<"addiu $dst, ${addr:stackloc}">;
501 // CLO/CLZ are part of the newer MIPS32(tm) instruction
502 // set and not older Mips I keep this for future use
504 //def CLO : CountLeading<0x21, "clo">;
505 //def CLZ : CountLeading<0x20, "clz">;
507 // MADD*/MSUB* are not part of MipsI either.
508 //def MADD : MArithR<0x00, "madd">;
509 //def MADDU : MArithR<0x01, "maddu">;
510 //def MSUB : MArithR<0x04, "msub">;
511 //def MSUBU : MArithR<0x05, "msubu">;
513 let Predicates = [IsAllegrex] in {
514 let shamt = 0x10, rs = 0 in
515 def SEB : SignExtInReg<0x21, "seb", i8>;
517 let shamt = 0x18, rs = 0 in
518 def SEH : SignExtInReg<0x20, "seh", i16>;
521 //===----------------------------------------------------------------------===//
522 // Arbitrary patterns that map to one or more instructions
523 //===----------------------------------------------------------------------===//
526 def : Pat<(i32 immSExt16:$in),
527 (ADDiu ZERO, imm:$in)>;
528 def : Pat<(i32 immZExt16:$in),
529 (ORi ZERO, imm:$in)>;
531 // Arbitrary immediates
532 def : Pat<(i32 imm:$imm),
533 (ORi (LUi (HI16 imm:$imm)), (LO16 imm:$imm))>;
536 def : Pat<(subc CPURegs:$lhs, CPURegs:$rhs),
537 (SUBu CPURegs:$lhs, CPURegs:$rhs)>;
538 def : Pat<(addc CPURegs:$lhs, CPURegs:$rhs),
539 (ADDu CPURegs:$lhs, CPURegs:$rhs)>;
540 def : Pat<(addc CPURegs:$src, imm:$imm),
541 (ADDiu CPURegs:$src, imm:$imm)>;
544 def : Pat<(MipsJmpLink (i32 tglobaladdr:$dst)),
545 (JAL tglobaladdr:$dst)>;
546 def : Pat<(MipsJmpLink (i32 texternalsym:$dst)),
547 (JAL texternalsym:$dst)>;
548 def : Pat<(MipsJmpLink CPURegs:$dst),
549 (JALR CPURegs:$dst)>;
551 // GlobalAddress, Constant Pool, ExternalSymbol, and JumpTable
552 def : Pat<(MipsHi tglobaladdr:$in), (LUi tglobaladdr:$in)>;
553 def : Pat<(MipsLo tglobaladdr:$in), (ADDiu ZERO, tglobaladdr:$in)>;
554 def : Pat<(add CPURegs:$hi, (MipsLo tglobaladdr:$lo)),
555 (ADDiu CPURegs:$hi, tglobaladdr:$lo)>;
556 def : Pat<(MipsHi tjumptable:$in), (LUi tjumptable:$in)>;
557 def : Pat<(MipsLo tjumptable:$in), (ADDiu ZERO, tjumptable:$in)>;
558 def : Pat<(add CPURegs:$hi, (MipsLo tjumptable:$lo)),
559 (ADDiu CPURegs:$hi, tjumptable:$lo)>;
561 // Mips does not have "not", so we expand our way
562 def : Pat<(not CPURegs:$in),
563 (NOR CPURegs:$in, ZERO)>;
565 // extended load and stores
566 def : Pat<(i32 (extloadi1 addr:$src)), (LBu addr:$src)>;
567 def : Pat<(i32 (extloadi8 addr:$src)), (LBu addr:$src)>;
568 def : Pat<(i32 (extloadi16 addr:$src)), (LHu addr:$src)>;
571 def : Pat<(store (i32 0), addr:$dst), (SW ZERO, addr:$dst)>;
574 // direct match equal/notequal zero branches
575 def : Pat<(brcond (setne CPURegs:$lhs, 0), bb:$dst),
576 (BNE CPURegs:$lhs, ZERO, bb:$dst)>;
577 def : Pat<(brcond (seteq CPURegs:$lhs, 0), bb:$dst),
578 (BEQ CPURegs:$lhs, ZERO, bb:$dst)>;
580 def : Pat<(brcond (setge CPURegs:$lhs, CPURegs:$rhs), bb:$dst),
581 (BGEZ (SUB CPURegs:$lhs, CPURegs:$rhs), bb:$dst)>;
582 def : Pat<(brcond (setuge CPURegs:$lhs, CPURegs:$rhs), bb:$dst),
583 (BGEZ (SUBu CPURegs:$lhs, CPURegs:$rhs), bb:$dst)>;
585 def : Pat<(brcond (setgt CPURegs:$lhs, CPURegs:$rhs), bb:$dst),
586 (BGTZ (SUB CPURegs:$lhs, CPURegs:$rhs), bb:$dst)>;
587 def : Pat<(brcond (setugt CPURegs:$lhs, CPURegs:$rhs), bb:$dst),
588 (BGTZ (SUBu CPURegs:$lhs, CPURegs:$rhs), bb:$dst)>;
590 def : Pat<(brcond (setle CPURegs:$lhs, CPURegs:$rhs), bb:$dst),
591 (BLEZ (SUB CPURegs:$lhs, CPURegs:$rhs), bb:$dst)>;
592 def : Pat<(brcond (setule CPURegs:$lhs, CPURegs:$rhs), bb:$dst),
593 (BLEZ (SUBu CPURegs:$lhs, CPURegs:$rhs), bb:$dst)>;
595 def : Pat<(brcond (setlt CPURegs:$lhs, immSExt16:$rhs), bb:$dst),
596 (BNE (SLTi CPURegs:$lhs, immSExt16:$rhs), ZERO, bb:$dst)>;
597 def : Pat<(brcond (setult CPURegs:$lhs, immZExt16:$rhs), bb:$dst),
598 (BNE (SLTiu CPURegs:$lhs, immZExt16:$rhs), ZERO, bb:$dst)>;
599 def : Pat<(brcond (setlt CPURegs:$lhs, CPURegs:$rhs), bb:$dst),
600 (BNE (SLT CPURegs:$lhs, CPURegs:$rhs), ZERO, bb:$dst)>;
601 def : Pat<(brcond (setult CPURegs:$lhs, CPURegs:$rhs), bb:$dst),
602 (BNE (SLTu CPURegs:$lhs, CPURegs:$rhs), ZERO, bb:$dst)>;
604 def : Pat<(brcond (setlt CPURegs:$lhs, CPURegs:$rhs), bb:$dst),
605 (BLTZ (SUB CPURegs:$lhs, CPURegs:$rhs), bb:$dst)>;
606 def : Pat<(brcond (setult CPURegs:$lhs, CPURegs:$rhs), bb:$dst),
607 (BLTZ (SUBu CPURegs:$lhs, CPURegs:$rhs), bb:$dst)>;
609 // generic brcond pattern
610 def : Pat<(brcond CPURegs:$cond, bb:$dst),
611 (BNE CPURegs:$cond, ZERO, bb:$dst)>;
613 /// setcc patterns, only matched when there
614 /// is no brcond following a setcc operation
615 def : Pat<(setle CPURegs:$lhs, CPURegs:$rhs),
616 (XORi (SLT CPURegs:$rhs, CPURegs:$lhs), 1)>;
617 def : Pat<(setule CPURegs:$lhs, CPURegs:$rhs),
618 (XORi (SLTu CPURegs:$rhs, CPURegs:$lhs), 1)>;
620 def : Pat<(setgt CPURegs:$lhs, CPURegs:$rhs),
621 (SLT CPURegs:$rhs, CPURegs:$lhs)>;
622 def : Pat<(setugt CPURegs:$lhs, CPURegs:$rhs),
623 (SLTu CPURegs:$rhs, CPURegs:$lhs)>;
625 def : Pat<(setge CPURegs:$lhs, CPURegs:$rhs),
626 (XORi (SLT CPURegs:$lhs, CPURegs:$rhs), 1)>;
627 def : Pat<(setuge CPURegs:$lhs, CPURegs:$rhs),
628 (XORi (SLTu CPURegs:$lhs, CPURegs:$rhs), 1)>;
630 def : Pat<(setne CPURegs:$lhs, CPURegs:$rhs),
631 (OR (SLT CPURegs:$lhs, CPURegs:$rhs),
632 (SLT CPURegs:$rhs, CPURegs:$lhs))>;
634 def : Pat<(seteq CPURegs:$lhs, CPURegs:$rhs),
635 (XORi (OR (SLT CPURegs:$lhs, CPURegs:$rhs),
636 (SLT CPURegs:$rhs, CPURegs:$lhs)), 1)>;
638 def : Pat<(setge CPURegs:$lhs, immSExt16:$rhs),
639 (XORi (SLTi CPURegs:$lhs, immSExt16:$rhs), 1)>;
640 def : Pat<(setuge CPURegs:$lhs, immZExt16:$rhs),
641 (XORi (SLTiu CPURegs:$lhs, immZExt16:$rhs), 1)>;
643 //===----------------------------------------------------------------------===//
644 // Floating Point Support
645 //===----------------------------------------------------------------------===//
647 include "MipsInstrFPU.td"