1 //===- MipsInstrInfo.td - Target Description for Mips Target -*- 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 contains the Mips implementation of the TargetInstrInfo class.
12 //===----------------------------------------------------------------------===//
14 //===----------------------------------------------------------------------===//
15 // Instruction format superclass
16 //===----------------------------------------------------------------------===//
18 include "MipsInstrFormats.td"
20 //===----------------------------------------------------------------------===//
21 // Mips profiles and nodes
22 //===----------------------------------------------------------------------===//
24 def SDT_MipsRet : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
25 def SDT_MipsJmpLink : SDTypeProfile<0, 1, [SDTCisVT<0, iPTR>]>;
26 def SDT_MipsCMov : SDTypeProfile<1, 4, [SDTCisSameAs<0, 1>,
30 def SDT_MipsCallSeqStart : SDCallSeqStart<[SDTCisVT<0, i32>]>;
31 def SDT_MipsCallSeqEnd : SDCallSeqEnd<[SDTCisVT<0, i32>, SDTCisVT<1, i32>]>;
32 def SDT_MipsMAddMSub : SDTypeProfile<0, 4,
33 [SDTCisVT<0, i32>, SDTCisSameAs<0, 1>,
36 def SDT_MipsDivRem : SDTypeProfile<0, 2,
40 def SDT_MipsThreadPointer : SDTypeProfile<1, 0, [SDTCisPtrTy<0>]>;
42 def SDT_MipsDynAlloc : SDTypeProfile<1, 1, [SDTCisVT<0, i32>,
44 def SDT_Sync : SDTypeProfile<0, 1, [SDTCisVT<0, i32>]>;
46 def SDT_Ext : SDTypeProfile<1, 3, [SDTCisInt<0>, SDTCisSameAs<0, 1>,
47 SDTCisVT<2, i32>, SDTCisSameAs<2, 3>]>;
48 def SDT_Ins : SDTypeProfile<1, 4, [SDTCisInt<0>, SDTCisSameAs<0, 1>,
49 SDTCisVT<2, i32>, SDTCisSameAs<2, 3>,
53 def MipsJmpLink : SDNode<"MipsISD::JmpLink",SDT_MipsJmpLink,
54 [SDNPHasChain, SDNPOutGlue, SDNPOptInGlue,
57 // Hi and Lo nodes are used to handle global addresses. Used on
58 // MipsISelLowering to lower stuff like GlobalAddress, ExternalSymbol
59 // static model. (nothing to do with Mips Registers Hi and Lo)
60 def MipsHi : SDNode<"MipsISD::Hi", SDTIntUnaryOp>;
61 def MipsLo : SDNode<"MipsISD::Lo", SDTIntUnaryOp>;
62 def MipsGPRel : SDNode<"MipsISD::GPRel", SDTIntUnaryOp>;
64 // TlsGd node is used to handle General Dynamic TLS
65 def MipsTlsGd : SDNode<"MipsISD::TlsGd", SDTIntUnaryOp>;
67 // TprelHi and TprelLo nodes are used to handle Local Exec TLS
68 def MipsTprelHi : SDNode<"MipsISD::TprelHi", SDTIntUnaryOp>;
69 def MipsTprelLo : SDNode<"MipsISD::TprelLo", SDTIntUnaryOp>;
72 def MipsThreadPointer: SDNode<"MipsISD::ThreadPointer", SDT_MipsThreadPointer>;
75 def MipsRet : SDNode<"MipsISD::Ret", SDT_MipsRet, [SDNPHasChain,
78 // These are target-independent nodes, but have target-specific formats.
79 def callseq_start : SDNode<"ISD::CALLSEQ_START", SDT_MipsCallSeqStart,
80 [SDNPHasChain, SDNPOutGlue]>;
81 def callseq_end : SDNode<"ISD::CALLSEQ_END", SDT_MipsCallSeqEnd,
82 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue]>;
85 def MipsMAdd : SDNode<"MipsISD::MAdd", SDT_MipsMAddMSub,
86 [SDNPOptInGlue, SDNPOutGlue]>;
87 def MipsMAddu : SDNode<"MipsISD::MAddu", SDT_MipsMAddMSub,
88 [SDNPOptInGlue, SDNPOutGlue]>;
89 def MipsMSub : SDNode<"MipsISD::MSub", SDT_MipsMAddMSub,
90 [SDNPOptInGlue, SDNPOutGlue]>;
91 def MipsMSubu : SDNode<"MipsISD::MSubu", SDT_MipsMAddMSub,
92 [SDNPOptInGlue, SDNPOutGlue]>;
95 def MipsDivRem : SDNode<"MipsISD::DivRem", SDT_MipsDivRem,
97 def MipsDivRemU : SDNode<"MipsISD::DivRemU", SDT_MipsDivRem,
100 // Target constant nodes that are not part of any isel patterns and remain
101 // unchanged can cause instructions with illegal operands to be emitted.
102 // Wrapper node patterns give the instruction selector a chance to replace
103 // target constant nodes that would otherwise remain unchanged with ADDiu
104 // nodes. Without these wrapper node patterns, the following conditional move
105 // instrucion is emitted when function cmov2 in test/CodeGen/Mips/cmov.ll is
107 // movn %got(d)($gp), %got(c)($gp), $4
108 // This instruction is illegal since movn can take only register operands.
110 def MipsWrapperPIC : SDNode<"MipsISD::WrapperPIC", SDTIntUnaryOp>;
112 // Pointer to dynamically allocated stack area.
113 def MipsDynAlloc : SDNode<"MipsISD::DynAlloc", SDT_MipsDynAlloc,
114 [SDNPHasChain, SDNPInGlue]>;
116 def MipsSync : SDNode<"MipsISD::Sync", SDT_Sync, [SDNPHasChain]>;
118 def MipsExt : SDNode<"MipsISD::Ext", SDT_Ext>;
119 def MipsIns : SDNode<"MipsISD::Ins", SDT_Ins>;
121 //===----------------------------------------------------------------------===//
122 // Mips Instruction Predicate Definitions.
123 //===----------------------------------------------------------------------===//
124 def HasSEInReg : Predicate<"Subtarget.hasSEInReg()">;
125 def HasBitCount : Predicate<"Subtarget.hasBitCount()">;
126 def HasSwap : Predicate<"Subtarget.hasSwap()">;
127 def HasCondMov : Predicate<"Subtarget.hasCondMov()">;
128 def HasMips32 : Predicate<"Subtarget.hasMips32()">;
129 def HasMips32r2 : Predicate<"Subtarget.hasMips32r2()">;
130 def HasMips64 : Predicate<"Subtarget.hasMips64()">;
131 def NotMips64 : Predicate<"!Subtarget.hasMips64()">;
132 def HasMips64r2 : Predicate<"Subtarget.hasMips64r2()">;
133 def IsN64 : Predicate<"Subtarget.isABI_N64()">;
134 def NotN64 : Predicate<"!Subtarget.isABI_N64()">;
136 //===----------------------------------------------------------------------===//
137 // Mips Operand, Complex Patterns and Transformations Definitions.
138 //===----------------------------------------------------------------------===//
140 // Instruction operand types
141 def brtarget : Operand<OtherVT>;
142 def calltarget : Operand<i32>;
143 def simm16 : Operand<i32>;
144 def simm16_64 : Operand<i64>;
145 def shamt : Operand<i32>;
148 def uimm16 : Operand<i32> {
149 let PrintMethod = "printUnsignedImm";
153 def mem : Operand<i32> {
154 let PrintMethod = "printMemOperand";
155 let MIOperandInfo = (ops CPURegs, simm16);
156 let EncoderMethod = "getMemEncoding";
159 def mem64 : Operand<i64> {
160 let PrintMethod = "printMemOperand";
161 let MIOperandInfo = (ops CPU64Regs, simm16_64);
164 def mem_ea : Operand<i32> {
165 let PrintMethod = "printMemOperandEA";
166 let MIOperandInfo = (ops CPURegs, simm16);
167 let EncoderMethod = "getMemEncoding";
170 // size operand of ext instruction
171 def size_ext : Operand<i32> {
172 let EncoderMethod = "getSizeExtEncoding";
175 // size operand of ins instruction
176 def size_ins : Operand<i32> {
177 let EncoderMethod = "getSizeInsEncoding";
180 // Transformation Function - get the lower 16 bits.
181 def LO16 : SDNodeXForm<imm, [{
182 return getI32Imm((unsigned)N->getZExtValue() & 0xFFFF);
185 // Transformation Function - get the higher 16 bits.
186 def HI16 : SDNodeXForm<imm, [{
187 return getI32Imm((unsigned)N->getZExtValue() >> 16);
190 // Node immediate fits as 16-bit sign extended on target immediate.
192 def immSExt16 : PatLeaf<(imm), [{ return isInt<16>(N->getSExtValue()); }]>;
194 // Node immediate fits as 16-bit zero extended on target immediate.
195 // The LO16 param means that only the lower 16 bits of the node
196 // immediate are caught.
198 def immZExt16 : PatLeaf<(imm), [{
199 if (N->getValueType(0) == MVT::i32)
200 return (uint32_t)N->getZExtValue() == (unsigned short)N->getZExtValue();
202 return (uint64_t)N->getZExtValue() == (unsigned short)N->getZExtValue();
205 // shamt field must fit in 5 bits.
206 def immZExt5 : ImmLeaf<i32, [{return Imm == (Imm & 0x1f);}]>;
208 // Mips Address Mode! SDNode frameindex could possibily be a match
209 // since load and store instructions from stack used it.
210 def addr : ComplexPattern<iPTR, 2, "SelectAddr", [frameindex], []>;
212 //===----------------------------------------------------------------------===//
213 // Pattern fragment for load/store
214 //===----------------------------------------------------------------------===//
215 class UnalignedLoad<PatFrag Node> : PatFrag<(ops node:$ptr), (Node node:$ptr), [{
216 LoadSDNode *LD = cast<LoadSDNode>(N);
217 return LD->getMemoryVT().getSizeInBits()/8 > LD->getAlignment();
220 class AlignedLoad<PatFrag Node> : PatFrag<(ops node:$ptr), (Node node:$ptr), [{
221 LoadSDNode *LD = cast<LoadSDNode>(N);
222 return LD->getMemoryVT().getSizeInBits()/8 <= LD->getAlignment();
225 class UnalignedStore<PatFrag Node> : PatFrag<(ops node:$val, node:$ptr),
226 (Node node:$val, node:$ptr), [{
227 StoreSDNode *SD = cast<StoreSDNode>(N);
228 return SD->getMemoryVT().getSizeInBits()/8 > SD->getAlignment();
231 class AlignedStore<PatFrag Node> : PatFrag<(ops node:$val, node:$ptr),
232 (Node node:$val, node:$ptr), [{
233 StoreSDNode *SD = cast<StoreSDNode>(N);
234 return SD->getMemoryVT().getSizeInBits()/8 <= SD->getAlignment();
237 // Load/Store PatFrags.
238 def sextloadi16_a : AlignedLoad<sextloadi16>;
239 def zextloadi16_a : AlignedLoad<zextloadi16>;
240 def extloadi16_a : AlignedLoad<extloadi16>;
241 def load_a : AlignedLoad<load>;
242 def sextloadi32_a : AlignedLoad<sextloadi32>;
243 def zextloadi32_a : AlignedLoad<zextloadi32>;
244 def extloadi32_a : AlignedLoad<extloadi32>;
245 def truncstorei16_a : AlignedStore<truncstorei16>;
246 def store_a : AlignedStore<store>;
247 def truncstorei32_a : AlignedStore<truncstorei32>;
248 def sextloadi16_u : UnalignedLoad<sextloadi16>;
249 def zextloadi16_u : UnalignedLoad<zextloadi16>;
250 def extloadi16_u : UnalignedLoad<extloadi16>;
251 def load_u : UnalignedLoad<load>;
252 def sextloadi32_u : UnalignedLoad<sextloadi32>;
253 def zextloadi32_u : UnalignedLoad<zextloadi32>;
254 def extloadi32_u : UnalignedLoad<extloadi32>;
255 def truncstorei16_u : UnalignedStore<truncstorei16>;
256 def store_u : UnalignedStore<store>;
257 def truncstorei32_u : UnalignedStore<truncstorei32>;
259 //===----------------------------------------------------------------------===//
260 // Instructions specific format
261 //===----------------------------------------------------------------------===//
263 // Arithmetic and logical instructions with 3 register operands.
264 class ArithLogicR<bits<6> op, bits<6> func, string instr_asm, SDNode OpNode,
265 InstrItinClass itin, RegisterClass RC, bit isComm = 0>:
266 FR<op, func, (outs RC:$rd), (ins RC:$rs, RC:$rt),
267 !strconcat(instr_asm, "\t$rd, $rs, $rt"),
268 [(set RC:$rd, (OpNode RC:$rs, RC:$rt))], itin> {
270 let isCommutable = isComm;
273 class ArithOverflowR<bits<6> op, bits<6> func, string instr_asm,
274 InstrItinClass itin, RegisterClass RC, bit isComm = 0>:
275 FR<op, func, (outs RC:$rd), (ins RC:$rs, RC:$rt),
276 !strconcat(instr_asm, "\t$rd, $rs, $rt"), [], itin> {
278 let isCommutable = isComm;
281 // Arithmetic and logical instructions with 2 register operands.
282 class ArithLogicI<bits<6> op, string instr_asm, SDNode OpNode,
283 Operand Od, PatLeaf imm_type, RegisterClass RC> :
284 FI<op, (outs RC:$rt), (ins RC:$rs, Od:$imm16),
285 !strconcat(instr_asm, "\t$rt, $rs, $imm16"),
286 [(set RC:$rt, (OpNode RC:$rs, imm_type:$imm16))], IIAlu>;
288 class ArithOverflowI<bits<6> op, string instr_asm, SDNode OpNode,
289 Operand Od, PatLeaf imm_type, RegisterClass RC> :
290 FI<op, (outs RC:$rt), (ins RC:$rs, Od:$imm16),
291 !strconcat(instr_asm, "\t$rt, $rs, $imm16"), [], IIAlu>;
293 // Arithmetic Multiply ADD/SUB
294 let rd = 0, shamt = 0, Defs = [HI, LO], Uses = [HI, LO] in
295 class MArithR<bits<6> func, string instr_asm, SDNode op, bit isComm = 0> :
296 FR<0x1c, func, (outs), (ins CPURegs:$rs, CPURegs:$rt),
297 !strconcat(instr_asm, "\t$rs, $rt"),
298 [(op CPURegs:$rs, CPURegs:$rt, LO, HI)], IIImul> {
301 let isCommutable = isComm;
305 class LogicNOR<bits<6> op, bits<6> func, string instr_asm, RegisterClass RC>:
306 FR<op, func, (outs RC:$rd), (ins RC:$rs, RC:$rt),
307 !strconcat(instr_asm, "\t$rd, $rs, $rt"),
308 [(set RC:$rd, (not (or RC:$rs, RC:$rt)))], IIAlu> {
310 let isCommutable = 1;
314 class shift_rotate_imm<bits<6> func, bits<5> isRotate, string instr_asm,
315 SDNode OpNode, PatFrag PF, Operand ImmOpnd,
317 FR<0x00, func, (outs RC:$rd), (ins RC:$rt, ImmOpnd:$shamt),
318 !strconcat(instr_asm, "\t$rd, $rt, $shamt"),
319 [(set RC:$rd, (OpNode RC:$rt, PF:$shamt))], IIAlu> {
323 // 32-bit shift instructions.
324 class shift_rotate_imm32<bits<6> func, bits<5> isRotate, string instr_asm,
326 shift_rotate_imm<func, isRotate, instr_asm, OpNode, immZExt5, shamt, CPURegs>;
328 class shift_rotate_reg<bits<6> func, bits<5> isRotate, string instr_asm,
329 SDNode OpNode, RegisterClass RC>:
330 FR<0x00, func, (outs RC:$rd), (ins CPURegs:$rs, RC:$rt),
331 !strconcat(instr_asm, "\t$rd, $rt, $rs"),
332 [(set RC:$rd, (OpNode RC:$rt, CPURegs:$rs))], IIAlu> {
333 let shamt = isRotate;
336 // Load Upper Imediate
337 class LoadUpper<bits<6> op, string instr_asm, RegisterClass RC, Operand Imm>:
338 FI<op, (outs RC:$rt), (ins Imm:$imm16),
339 !strconcat(instr_asm, "\t$rt, $imm16"), [], IIAlu> {
343 class FMem<bits<6> op, dag outs, dag ins, string asmstr, list<dag> pattern,
344 InstrItinClass itin>: FFI<op, outs, ins, asmstr, pattern> {
346 let Inst{25-21} = addr{20-16};
347 let Inst{15-0} = addr{15-0};
351 let canFoldAsLoad = 1 in
352 class LoadM<bits<6> op, string instr_asm, PatFrag OpNode, RegisterClass RC,
353 Operand MemOpnd, bit Pseudo>:
354 FMem<op, (outs RC:$rt), (ins MemOpnd:$addr),
355 !strconcat(instr_asm, "\t$rt, $addr"),
356 [(set RC:$rt, (OpNode addr:$addr))], IILoad> {
357 let isPseudo = Pseudo;
360 class StoreM<bits<6> op, string instr_asm, PatFrag OpNode, RegisterClass RC,
361 Operand MemOpnd, bit Pseudo>:
362 FMem<op, (outs), (ins RC:$rt, MemOpnd:$addr),
363 !strconcat(instr_asm, "\t$rt, $addr"),
364 [(OpNode RC:$rt, addr:$addr)], IIStore> {
365 let isPseudo = Pseudo;
369 multiclass LoadM32<bits<6> op, string instr_asm, PatFrag OpNode,
371 def #NAME# : LoadM<op, instr_asm, OpNode, CPURegs, mem, Pseudo>,
373 def _P8 : LoadM<op, instr_asm, OpNode, CPURegs, mem64, Pseudo>,
378 multiclass LoadM64<bits<6> op, string instr_asm, PatFrag OpNode,
380 def #NAME# : LoadM<op, instr_asm, OpNode, CPU64Regs, mem, Pseudo>,
382 def _P8 : LoadM<op, instr_asm, OpNode, CPU64Regs, mem64, Pseudo>,
387 multiclass StoreM32<bits<6> op, string instr_asm, PatFrag OpNode,
389 def #NAME# : StoreM<op, instr_asm, OpNode, CPURegs, mem, Pseudo>,
391 def _P8 : StoreM<op, instr_asm, OpNode, CPURegs, mem64, Pseudo>,
396 multiclass StoreM64<bits<6> op, string instr_asm, PatFrag OpNode,
398 def #NAME# : StoreM<op, instr_asm, OpNode, CPU64Regs, mem, Pseudo>,
400 def _P8 : StoreM<op, instr_asm, OpNode, CPU64Regs, mem64, Pseudo>,
404 // Conditional Branch
405 class CBranch<bits<6> op, string instr_asm, PatFrag cond_op, RegisterClass RC>:
406 CBranchBase<op, (outs), (ins RC:$rs, RC:$rt, brtarget:$imm16),
407 !strconcat(instr_asm, "\t$rs, $rt, $imm16"),
408 [(brcond (i32 (cond_op RC:$rs, RC:$rt)), bb:$imm16)], IIBranch> {
410 let isTerminator = 1;
411 let hasDelaySlot = 1;
414 class CBranchZero<bits<6> op, bits<5> _rt, string instr_asm, PatFrag cond_op,
416 CBranchBase<op, (outs), (ins RC:$rs, brtarget:$imm16),
417 !strconcat(instr_asm, "\t$rs, $imm16"),
418 [(brcond (i32 (cond_op RC:$rs, 0)), bb:$imm16)], IIBranch> {
421 let isTerminator = 1;
422 let hasDelaySlot = 1;
426 class SetCC_R<bits<6> op, bits<6> func, string instr_asm, PatFrag cond_op,
428 FR<op, func, (outs CPURegs:$rd), (ins RC:$rs, RC:$rt),
429 !strconcat(instr_asm, "\t$rd, $rs, $rt"),
430 [(set CPURegs:$rd, (cond_op RC:$rs, RC:$rt))],
435 class SetCC_I<bits<6> op, string instr_asm, PatFrag cond_op, Operand Od,
436 PatLeaf imm_type, RegisterClass RC>:
437 FI<op, (outs CPURegs:$rt), (ins RC:$rs, Od:$imm16),
438 !strconcat(instr_asm, "\t$rt, $rs, $imm16"),
439 [(set CPURegs:$rt, (cond_op RC:$rs, imm_type:$imm16))],
442 // Unconditional branch
443 let isBranch=1, isTerminator=1, isBarrier=1, hasDelaySlot = 1 in
444 class JumpFJ<bits<6> op, string instr_asm>:
445 FJ<op, (outs), (ins brtarget:$target),
446 !strconcat(instr_asm, "\t$target"), [(br bb:$target)], IIBranch>;
448 let isBranch=1, isTerminator=1, isBarrier=1, rd=0, hasDelaySlot = 1 in
449 class JumpFR<bits<6> op, bits<6> func, string instr_asm>:
450 FR<op, func, (outs), (ins CPURegs:$rs),
451 !strconcat(instr_asm, "\t$rs"), [(brind CPURegs:$rs)], IIBranch> {
457 // Jump and Link (Call)
458 let isCall=1, hasDelaySlot=1,
459 // All calls clobber the non-callee saved registers...
460 Defs = [AT, V0, V1, A0, A1, A2, A3, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9,
461 K0, K1, D0, D1, D2, D3, D4, D5, D6, D7, D8, D9], Uses = [GP] in {
462 class JumpLink<bits<6> op, string instr_asm>:
463 FJ<op, (outs), (ins calltarget:$target, variable_ops),
464 !strconcat(instr_asm, "\t$target"), [(MipsJmpLink imm:$target)],
467 class JumpLinkReg<bits<6> op, bits<6> func, string instr_asm>:
468 FR<op, func, (outs), (ins CPURegs:$rs, variable_ops),
469 !strconcat(instr_asm, "\t$rs"), [(MipsJmpLink CPURegs:$rs)], IIBranch> {
475 class BranchLink<string instr_asm>:
476 FI<0x1, (outs), (ins CPURegs:$rs, brtarget:$imm16, variable_ops),
477 !strconcat(instr_asm, "\t$rs, $imm16"), [], IIBranch>;
481 class Mult<bits<6> func, string instr_asm, InstrItinClass itin,
482 RegisterClass RC, list<Register> DefRegs>:
483 FR<0x00, func, (outs), (ins RC:$rs, RC:$rt),
484 !strconcat(instr_asm, "\t$rs, $rt"), [], itin> {
487 let isCommutable = 1;
491 class Mult32<bits<6> func, string instr_asm, InstrItinClass itin>:
492 Mult<func, instr_asm, itin, CPURegs, [HI, LO]>;
494 class Div<SDNode op, bits<6> func, string instr_asm, InstrItinClass itin,
495 RegisterClass RC, list<Register> DefRegs>:
496 FR<0x00, func, (outs), (ins RC:$rs, RC:$rt),
497 !strconcat(instr_asm, "\t$$zero, $rs, $rt"),
498 [(op RC:$rs, RC:$rt)], itin> {
504 class Div32<SDNode op, bits<6> func, string instr_asm, InstrItinClass itin>:
505 Div<op, func, instr_asm, itin, CPURegs, [HI, LO]>;
508 class MoveFromLOHI<bits<6> func, string instr_asm, RegisterClass RC,
509 list<Register> UseRegs>:
510 FR<0x00, func, (outs RC:$rd), (ins),
511 !strconcat(instr_asm, "\t$rd"), [], IIHiLo> {
518 class MoveToLOHI<bits<6> func, string instr_asm, RegisterClass RC,
519 list<Register> DefRegs>:
520 FR<0x00, func, (outs), (ins RC:$rs),
521 !strconcat(instr_asm, "\t$rs"), [], IIHiLo> {
528 class EffectiveAddress<string instr_asm> :
529 FMem<0x09, (outs CPURegs:$rt), (ins mem_ea:$addr),
530 instr_asm, [(set CPURegs:$rt, addr:$addr)], IIAlu>;
532 // Count Leading Ones/Zeros in Word
533 class CountLeading0<bits<6> func, string instr_asm, RegisterClass RC>:
534 FR<0x1c, func, (outs RC:$rd), (ins RC:$rs),
535 !strconcat(instr_asm, "\t$rd, $rs"),
536 [(set RC:$rd, (ctlz RC:$rs))], IIAlu>,
537 Requires<[HasBitCount]> {
542 class CountLeading1<bits<6> func, string instr_asm, RegisterClass RC>:
543 FR<0x1c, func, (outs RC:$rd), (ins RC:$rs),
544 !strconcat(instr_asm, "\t$rd, $rs"),
545 [(set RC:$rd, (ctlz (not RC:$rs)))], IIAlu>,
546 Requires<[HasBitCount]> {
551 // Sign Extend in Register.
552 class SignExtInReg<bits<5> sa, string instr_asm, ValueType vt>:
553 FR<0x1f, 0x20, (outs CPURegs:$rd), (ins CPURegs:$rt),
554 !strconcat(instr_asm, "\t$rd, $rt"),
555 [(set CPURegs:$rd, (sext_inreg CPURegs:$rt, vt))], NoItinerary> {
558 let Predicates = [HasSEInReg];
562 class ByteSwap<bits<6> func, bits<5> sa, string instr_asm>:
563 FR<0x1f, func, (outs CPURegs:$rd), (ins CPURegs:$rt),
564 !strconcat(instr_asm, "\t$rd, $rt"),
565 [(set CPURegs:$rd, (bswap CPURegs:$rt))], NoItinerary> {
568 let Predicates = [HasSwap];
572 class ReadHardware: FR<0x1f, 0x3b, (outs CPURegs:$rt), (ins HWRegs:$rd),
573 "rdhwr\t$rt, $rd", [], IIAlu> {
579 class ExtIns<bits<6> _funct, string instr_asm, dag outs, dag ins,
580 list<dag> pattern, InstrItinClass itin>:
581 FR<0x1f, _funct, outs, ins, !strconcat(instr_asm, " $rt, $rs, $pos, $sz"),
582 pattern, itin>, Requires<[HasMips32r2]> {
589 // Atomic instructions with 2 source operands (ATOMIC_SWAP & ATOMIC_LOAD_*).
590 class Atomic2Ops<PatFrag Op, string Opstr> :
591 MipsPseudo<(outs CPURegs:$dst), (ins CPURegs:$ptr, CPURegs:$incr),
592 !strconcat("atomic_", Opstr, "\t$dst, $ptr, $incr"),
594 (Op CPURegs:$ptr, CPURegs:$incr))]>;
596 // Atomic Compare & Swap.
597 class AtomicCmpSwap<PatFrag Op, string Width> :
598 MipsPseudo<(outs CPURegs:$dst),
599 (ins CPURegs:$ptr, CPURegs:$cmp, CPURegs:$swap),
600 !strconcat("atomic_cmp_swap_", Width,
601 "\t$dst, $ptr, $cmp, $swap"),
603 (Op CPURegs:$ptr, CPURegs:$cmp, CPURegs:$swap))]>;
605 //===----------------------------------------------------------------------===//
606 // Pseudo instructions
607 //===----------------------------------------------------------------------===//
609 // As stack alignment is always done with addiu, we need a 16-bit immediate
610 let Defs = [SP], Uses = [SP] in {
611 def ADJCALLSTACKDOWN : MipsPseudo<(outs), (ins uimm16:$amt),
612 "!ADJCALLSTACKDOWN $amt",
613 [(callseq_start timm:$amt)]>;
614 def ADJCALLSTACKUP : MipsPseudo<(outs), (ins uimm16:$amt1, uimm16:$amt2),
615 "!ADJCALLSTACKUP $amt1",
616 [(callseq_end timm:$amt1, timm:$amt2)]>;
619 // Some assembly macros need to avoid pseudoinstructions and assembler
620 // automatic reodering, we should reorder ourselves.
621 def MACRO : MipsPseudo<(outs), (ins), ".set\tmacro", []>;
622 def REORDER : MipsPseudo<(outs), (ins), ".set\treorder", []>;
623 def NOMACRO : MipsPseudo<(outs), (ins), ".set\tnomacro", []>;
624 def NOREORDER : MipsPseudo<(outs), (ins), ".set\tnoreorder", []>;
626 // These macros are inserted to prevent GAS from complaining
627 // when using the AT register.
628 def NOAT : MipsPseudo<(outs), (ins), ".set\tnoat", []>;
629 def ATMACRO : MipsPseudo<(outs), (ins), ".set\tat", []>;
631 // When handling PIC code the assembler needs .cpload and .cprestore
632 // directives. If the real instructions corresponding these directives
633 // are used, we have the same behavior, but get also a bunch of warnings
634 // from the assembler.
635 def CPLOAD : MipsPseudo<(outs), (ins CPURegs:$picreg), ".cpload\t$picreg", []>;
636 def CPRESTORE : MipsPseudo<(outs), (ins i32imm:$loc), ".cprestore\t$loc", []>;
638 let usesCustomInserter = 1 in {
639 def ATOMIC_LOAD_ADD_I8 : Atomic2Ops<atomic_load_add_8, "load_add_8">;
640 def ATOMIC_LOAD_ADD_I16 : Atomic2Ops<atomic_load_add_16, "load_add_16">;
641 def ATOMIC_LOAD_ADD_I32 : Atomic2Ops<atomic_load_add_32, "load_add_32">;
642 def ATOMIC_LOAD_SUB_I8 : Atomic2Ops<atomic_load_sub_8, "load_sub_8">;
643 def ATOMIC_LOAD_SUB_I16 : Atomic2Ops<atomic_load_sub_16, "load_sub_16">;
644 def ATOMIC_LOAD_SUB_I32 : Atomic2Ops<atomic_load_sub_32, "load_sub_32">;
645 def ATOMIC_LOAD_AND_I8 : Atomic2Ops<atomic_load_and_8, "load_and_8">;
646 def ATOMIC_LOAD_AND_I16 : Atomic2Ops<atomic_load_and_16, "load_and_16">;
647 def ATOMIC_LOAD_AND_I32 : Atomic2Ops<atomic_load_and_32, "load_and_32">;
648 def ATOMIC_LOAD_OR_I8 : Atomic2Ops<atomic_load_or_8, "load_or_8">;
649 def ATOMIC_LOAD_OR_I16 : Atomic2Ops<atomic_load_or_16, "load_or_16">;
650 def ATOMIC_LOAD_OR_I32 : Atomic2Ops<atomic_load_or_32, "load_or_32">;
651 def ATOMIC_LOAD_XOR_I8 : Atomic2Ops<atomic_load_xor_8, "load_xor_8">;
652 def ATOMIC_LOAD_XOR_I16 : Atomic2Ops<atomic_load_xor_16, "load_xor_16">;
653 def ATOMIC_LOAD_XOR_I32 : Atomic2Ops<atomic_load_xor_32, "load_xor_32">;
654 def ATOMIC_LOAD_NAND_I8 : Atomic2Ops<atomic_load_nand_8, "load_nand_8">;
655 def ATOMIC_LOAD_NAND_I16 : Atomic2Ops<atomic_load_nand_16, "load_nand_16">;
656 def ATOMIC_LOAD_NAND_I32 : Atomic2Ops<atomic_load_nand_32, "load_nand_32">;
658 def ATOMIC_SWAP_I8 : Atomic2Ops<atomic_swap_8, "swap_8">;
659 def ATOMIC_SWAP_I16 : Atomic2Ops<atomic_swap_16, "swap_16">;
660 def ATOMIC_SWAP_I32 : Atomic2Ops<atomic_swap_32, "swap_32">;
662 def ATOMIC_CMP_SWAP_I8 : AtomicCmpSwap<atomic_cmp_swap_8, "8">;
663 def ATOMIC_CMP_SWAP_I16 : AtomicCmpSwap<atomic_cmp_swap_16, "16">;
664 def ATOMIC_CMP_SWAP_I32 : AtomicCmpSwap<atomic_cmp_swap_32, "32">;
667 //===----------------------------------------------------------------------===//
668 // Instruction definition
669 //===----------------------------------------------------------------------===//
671 //===----------------------------------------------------------------------===//
672 // MipsI Instructions
673 //===----------------------------------------------------------------------===//
675 /// Arithmetic Instructions (ALU Immediate)
676 def ADDiu : ArithLogicI<0x09, "addiu", add, simm16, immSExt16, CPURegs>;
677 def ADDi : ArithOverflowI<0x08, "addi", add, simm16, immSExt16, CPURegs>;
678 def SLTi : SetCC_I<0x0a, "slti", setlt, simm16, immSExt16, CPURegs>;
679 def SLTiu : SetCC_I<0x0b, "sltiu", setult, simm16, immSExt16, CPURegs>;
680 def ANDi : ArithLogicI<0x0c, "andi", and, uimm16, immZExt16, CPURegs>;
681 def ORi : ArithLogicI<0x0d, "ori", or, uimm16, immZExt16, CPURegs>;
682 def XORi : ArithLogicI<0x0e, "xori", xor, uimm16, immZExt16, CPURegs>;
683 def LUi : LoadUpper<0x0f, "lui", CPURegs, uimm16>;
685 /// Arithmetic Instructions (3-Operand, R-Type)
686 def ADDu : ArithLogicR<0x00, 0x21, "addu", add, IIAlu, CPURegs, 1>;
687 def SUBu : ArithLogicR<0x00, 0x23, "subu", sub, IIAlu, CPURegs>;
688 def ADD : ArithOverflowR<0x00, 0x20, "add", IIAlu, CPURegs, 1>;
689 def SUB : ArithOverflowR<0x00, 0x22, "sub", IIAlu, CPURegs>;
690 def SLT : SetCC_R<0x00, 0x2a, "slt", setlt, CPURegs>;
691 def SLTu : SetCC_R<0x00, 0x2b, "sltu", setult, CPURegs>;
692 def AND : ArithLogicR<0x00, 0x24, "and", and, IIAlu, CPURegs, 1>;
693 def OR : ArithLogicR<0x00, 0x25, "or", or, IIAlu, CPURegs, 1>;
694 def XOR : ArithLogicR<0x00, 0x26, "xor", xor, IIAlu, CPURegs, 1>;
695 def NOR : LogicNOR<0x00, 0x27, "nor", CPURegs>;
697 /// Shift Instructions
698 def SLL : shift_rotate_imm32<0x00, 0x00, "sll", shl>;
699 def SRL : shift_rotate_imm32<0x02, 0x00, "srl", srl>;
700 def SRA : shift_rotate_imm32<0x03, 0x00, "sra", sra>;
701 def SLLV : shift_rotate_reg<0x04, 0x00, "sllv", shl, CPURegs>;
702 def SRLV : shift_rotate_reg<0x06, 0x00, "srlv", srl, CPURegs>;
703 def SRAV : shift_rotate_reg<0x07, 0x00, "srav", sra, CPURegs>;
705 // Rotate Instructions
706 let Predicates = [HasMips32r2] in {
707 def ROTR : shift_rotate_imm32<0x02, 0x01, "rotr", rotr>;
708 def ROTRV : shift_rotate_reg<0x06, 0x01, "rotrv", rotr, CPURegs>;
711 /// Load and Store Instructions
713 defm LB : LoadM32<0x20, "lb", sextloadi8>;
714 defm LBu : LoadM32<0x24, "lbu", zextloadi8>;
715 defm LH : LoadM32<0x21, "lh", sextloadi16_a>;
716 defm LHu : LoadM32<0x25, "lhu", zextloadi16_a>;
717 defm LW : LoadM32<0x23, "lw", load_a>;
718 defm SB : StoreM32<0x28, "sb", truncstorei8>;
719 defm SH : StoreM32<0x29, "sh", truncstorei16_a>;
720 defm SW : StoreM32<0x2b, "sw", store_a>;
723 defm ULH : LoadM32<0x21, "ulh", sextloadi16_u, 1>;
724 defm ULHu : LoadM32<0x25, "ulhu", zextloadi16_u, 1>;
725 defm ULW : LoadM32<0x23, "ulw", load_u, 1>;
726 defm USH : StoreM32<0x29, "ush", truncstorei16_u, 1>;
727 defm USW : StoreM32<0x2b, "usw", store_u, 1>;
729 let hasSideEffects = 1 in
730 def SYNC : MipsInst<(outs), (ins i32imm:$stype), "sync $stype",
731 [(MipsSync imm:$stype)], NoItinerary, FrmOther>
736 let Inst{10-6} = stype;
740 /// Load-linked, Store-conditional
742 def LL : FMem<0x30, (outs CPURegs:$rt), (ins mem:$addr),
743 "ll\t$rt, $addr", [], IILoad>;
744 let mayStore = 1, Constraints = "$rt = $dst" in
745 def SC : FMem<0x38, (outs CPURegs:$dst), (ins CPURegs:$rt, mem:$addr),
746 "sc\t$rt, $addr", [], IIStore>;
748 /// Jump and Branch Instructions
749 def J : JumpFJ<0x02, "j">;
750 let isIndirectBranch = 1 in
751 def JR : JumpFR<0x00, 0x08, "jr">;
752 def JAL : JumpLink<0x03, "jal">;
753 def JALR : JumpLinkReg<0x00, 0x09, "jalr">;
754 def BEQ : CBranch<0x04, "beq", seteq, CPURegs>;
755 def BNE : CBranch<0x05, "bne", setne, CPURegs>;
756 def BGEZ : CBranchZero<0x01, 1, "bgez", setge, CPURegs>;
757 def BGTZ : CBranchZero<0x07, 0, "bgtz", setgt, CPURegs>;
758 def BLEZ : CBranchZero<0x06, 0, "blez", setle, CPURegs>;
759 def BLTZ : CBranchZero<0x01, 0, "bltz", setlt, CPURegs>;
762 def BGEZAL : BranchLink<"bgezal">;
764 def BLTZAL : BranchLink<"bltzal">;
766 let isReturn=1, isTerminator=1, hasDelaySlot=1,
767 isBarrier=1, hasCtrlDep=1, rd=0, rt=0, shamt=0 in
768 def RET : FR <0x00, 0x08, (outs), (ins CPURegs:$target),
769 "jr\t$target", [(MipsRet CPURegs:$target)], IIBranch>;
771 /// Multiply and Divide Instructions.
772 def MULT : Mult32<0x18, "mult", IIImul>;
773 def MULTu : Mult32<0x19, "multu", IIImul>;
774 def SDIV : Div32<MipsDivRem, 0x1a, "div", IIIdiv>;
775 def UDIV : Div32<MipsDivRemU, 0x1b, "divu", IIIdiv>;
777 def MTHI : MoveToLOHI<0x11, "mthi", CPURegs, [HI]>;
778 def MTLO : MoveToLOHI<0x13, "mtlo", CPURegs, [LO]>;
779 def MFHI : MoveFromLOHI<0x10, "mfhi", CPURegs, [HI]>;
780 def MFLO : MoveFromLOHI<0x12, "mflo", CPURegs, [LO]>;
782 /// Sign Ext In Register Instructions.
783 def SEB : SignExtInReg<0x10, "seb", i8>;
784 def SEH : SignExtInReg<0x18, "seh", i16>;
787 def CLZ : CountLeading0<0x20, "clz", CPURegs>;
788 def CLO : CountLeading1<0x21, "clo", CPURegs>;
791 def WSBW : ByteSwap<0x20, 0x2, "wsbw">;
795 def NOP : FJ<0, (outs), (ins), "nop", [], IIAlu>;
797 // FrameIndexes are legalized when they are operands from load/store
798 // instructions. The same not happens for stack address copies, so an
799 // add op with mem ComplexPattern is used and the stack address copy
800 // can be matched. It's similar to Sparc LEA_ADDRi
801 def LEA_ADDiu : EffectiveAddress<"addiu\t$rt, $addr">;
803 // DynAlloc node points to dynamically allocated stack space.
804 // $sp is added to the list of implicitly used registers to prevent dead code
805 // elimination from removing instructions that modify $sp.
807 def DynAlloc : EffectiveAddress<"addiu\t$rt, $addr">;
810 def MADD : MArithR<0, "madd", MipsMAdd, 1>;
811 def MADDU : MArithR<1, "maddu", MipsMAddu, 1>;
812 def MSUB : MArithR<4, "msub", MipsMSub>;
813 def MSUBU : MArithR<5, "msubu", MipsMSubu>;
815 // MUL is a assembly macro in the current used ISAs. In recent ISA's
816 // it is a real instruction.
817 def MUL : ArithLogicR<0x1c, 0x02, "mul", mul, IIImul, CPURegs, 1>,
818 Requires<[HasMips32]>;
820 def RDHWR : ReadHardware;
822 def EXT : ExtIns<0, "ext", (outs CPURegs:$rt),
823 (ins CPURegs:$rs, uimm16:$pos, size_ext:$sz),
825 (MipsExt CPURegs:$rs, immZExt5:$pos, immZExt5:$sz))],
828 let Constraints = "$src = $rt" in
829 def INS : ExtIns<4, "ins", (outs CPURegs:$rt),
830 (ins CPURegs:$rs, uimm16:$pos, size_ins:$sz, CPURegs:$src),
832 (MipsIns CPURegs:$rs, immZExt5:$pos, immZExt5:$sz,
836 //===----------------------------------------------------------------------===//
837 // Arbitrary patterns that map to one or more instructions
838 //===----------------------------------------------------------------------===//
841 def : Pat<(i32 immSExt16:$in),
842 (ADDiu ZERO, imm:$in)>;
843 def : Pat<(i32 immZExt16:$in),
844 (ORi ZERO, imm:$in)>;
846 // Arbitrary immediates
847 def : Pat<(i32 imm:$imm),
848 (ORi (LUi (HI16 imm:$imm)), (LO16 imm:$imm))>;
851 def : Pat<(subc CPURegs:$lhs, CPURegs:$rhs),
852 (SUBu CPURegs:$lhs, CPURegs:$rhs)>;
853 def : Pat<(addc CPURegs:$lhs, CPURegs:$rhs),
854 (ADDu CPURegs:$lhs, CPURegs:$rhs)>;
855 def : Pat<(addc CPURegs:$src, immSExt16:$imm),
856 (ADDiu CPURegs:$src, imm:$imm)>;
859 def : Pat<(MipsJmpLink (i32 tglobaladdr:$dst)),
860 (JAL tglobaladdr:$dst)>;
861 def : Pat<(MipsJmpLink (i32 texternalsym:$dst)),
862 (JAL texternalsym:$dst)>;
863 //def : Pat<(MipsJmpLink CPURegs:$dst),
864 // (JALR CPURegs:$dst)>;
867 def : Pat<(MipsHi tglobaladdr:$in), (LUi tglobaladdr:$in)>;
868 def : Pat<(MipsHi tblockaddress:$in), (LUi tblockaddress:$in)>;
869 def : Pat<(MipsLo tglobaladdr:$in), (ADDiu ZERO, tglobaladdr:$in)>;
870 def : Pat<(MipsLo tblockaddress:$in), (ADDiu ZERO, tblockaddress:$in)>;
871 def : Pat<(add CPURegs:$hi, (MipsLo tglobaladdr:$lo)),
872 (ADDiu CPURegs:$hi, tglobaladdr:$lo)>;
873 def : Pat<(add CPURegs:$hi, (MipsLo tblockaddress:$lo)),
874 (ADDiu CPURegs:$hi, tblockaddress:$lo)>;
876 def : Pat<(MipsHi tjumptable:$in), (LUi tjumptable:$in)>;
877 def : Pat<(MipsLo tjumptable:$in), (ADDiu ZERO, tjumptable:$in)>;
878 def : Pat<(add CPURegs:$hi, (MipsLo tjumptable:$lo)),
879 (ADDiu CPURegs:$hi, tjumptable:$lo)>;
881 def : Pat<(MipsHi tconstpool:$in), (LUi tconstpool:$in)>;
882 def : Pat<(MipsLo tconstpool:$in), (ADDiu ZERO, tconstpool:$in)>;
883 def : Pat<(add CPURegs:$hi, (MipsLo tconstpool:$lo)),
884 (ADDiu CPURegs:$hi, tconstpool:$lo)>;
887 def : Pat<(add CPURegs:$gp, (MipsGPRel tglobaladdr:$in)),
888 (ADDiu CPURegs:$gp, tglobaladdr:$in)>;
889 def : Pat<(add CPURegs:$gp, (MipsGPRel tconstpool:$in)),
890 (ADDiu CPURegs:$gp, tconstpool:$in)>;
893 def : Pat<(add CPURegs:$gp, (MipsTlsGd tglobaltlsaddr:$in)),
894 (ADDiu CPURegs:$gp, tglobaltlsaddr:$in)>;
897 def : Pat<(MipsTprelHi tglobaltlsaddr:$in), (LUi tglobaltlsaddr:$in)>;
898 def : Pat<(MipsTprelLo tglobaltlsaddr:$in), (ADDiu ZERO, tglobaltlsaddr:$in)>;
899 def : Pat<(add CPURegs:$hi, (MipsTprelLo tglobaltlsaddr:$lo)),
900 (ADDiu CPURegs:$hi, tglobaltlsaddr:$lo)>;
903 class WrapperPICPat<SDNode node>:
904 Pat<(MipsWrapperPIC node:$in),
905 (ADDiu GP, node:$in)>;
907 def : WrapperPICPat<tglobaladdr>;
908 def : WrapperPICPat<tconstpool>;
909 def : WrapperPICPat<texternalsym>;
910 def : WrapperPICPat<tblockaddress>;
911 def : WrapperPICPat<tjumptable>;
913 // Mips does not have "not", so we expand our way
914 def : Pat<(not CPURegs:$in),
915 (NOR CPURegs:$in, ZERO)>;
917 // extended load and stores
918 def : Pat<(extloadi1 addr:$src), (LBu addr:$src)>;
919 def : Pat<(extloadi8 addr:$src), (LBu addr:$src)>;
920 def : Pat<(extloadi16_a addr:$src), (LHu addr:$src)>;
921 def : Pat<(extloadi16_u addr:$src), (ULHu addr:$src)>;
924 def : Pat<(store (i32 0), addr:$dst), (SW ZERO, addr:$dst)>;
927 multiclass BrcondPats<RegisterClass RC, Instruction BEQOp, Instruction BNEOp,
928 Instruction SLTOp, Instruction SLTuOp, Instruction SLTiOp,
929 Instruction SLTiuOp, Register ZEROReg> {
930 def : Pat<(brcond (i32 (setne RC:$lhs, 0)), bb:$dst),
931 (BNEOp RC:$lhs, ZEROReg, bb:$dst)>;
932 def : Pat<(brcond (i32 (seteq RC:$lhs, 0)), bb:$dst),
933 (BEQOp RC:$lhs, ZEROReg, bb:$dst)>;
935 def : Pat<(brcond (i32 (setge RC:$lhs, RC:$rhs)), bb:$dst),
936 (BEQ (SLTOp RC:$lhs, RC:$rhs), ZERO, bb:$dst)>;
937 def : Pat<(brcond (i32 (setuge RC:$lhs, RC:$rhs)), bb:$dst),
938 (BEQ (SLTuOp RC:$lhs, RC:$rhs), ZERO, bb:$dst)>;
939 def : Pat<(brcond (i32 (setge RC:$lhs, immSExt16:$rhs)), bb:$dst),
940 (BEQ (SLTiOp RC:$lhs, immSExt16:$rhs), ZERO, bb:$dst)>;
941 def : Pat<(brcond (i32 (setuge RC:$lhs, immSExt16:$rhs)), bb:$dst),
942 (BEQ (SLTiuOp RC:$lhs, immSExt16:$rhs), ZERO, bb:$dst)>;
944 def : Pat<(brcond (i32 (setle RC:$lhs, RC:$rhs)), bb:$dst),
945 (BEQ (SLTOp RC:$rhs, RC:$lhs), ZERO, bb:$dst)>;
946 def : Pat<(brcond (i32 (setule RC:$lhs, RC:$rhs)), bb:$dst),
947 (BEQ (SLTuOp RC:$rhs, RC:$lhs), ZERO, bb:$dst)>;
949 def : Pat<(brcond RC:$cond, bb:$dst),
950 (BNEOp RC:$cond, ZEROReg, bb:$dst)>;
953 defm : BrcondPats<CPURegs, BEQ, BNE, SLT, SLTu, SLTi, SLTiu, ZERO>;
956 multiclass SeteqPats<RegisterClass RC, Instruction SLTiuOp, Instruction XOROp,
957 Instruction SLTuOp, Register ZEROReg> {
958 def : Pat<(seteq RC:$lhs, RC:$rhs),
959 (SLTiuOp (XOROp RC:$lhs, RC:$rhs), 1)>;
960 def : Pat<(setne RC:$lhs, RC:$rhs),
961 (SLTuOp ZEROReg, (XOROp RC:$lhs, RC:$rhs))>;
964 multiclass SetlePats<RegisterClass RC, Instruction SLTOp, Instruction SLTuOp> {
965 def : Pat<(setle RC:$lhs, RC:$rhs),
966 (XORi (SLTOp RC:$rhs, RC:$lhs), 1)>;
967 def : Pat<(setule RC:$lhs, RC:$rhs),
968 (XORi (SLTuOp RC:$rhs, RC:$lhs), 1)>;
971 multiclass SetgtPats<RegisterClass RC, Instruction SLTOp, Instruction SLTuOp> {
972 def : Pat<(setgt RC:$lhs, RC:$rhs),
973 (SLTOp RC:$rhs, RC:$lhs)>;
974 def : Pat<(setugt RC:$lhs, RC:$rhs),
975 (SLTuOp RC:$rhs, RC:$lhs)>;
978 multiclass SetgePats<RegisterClass RC, Instruction SLTOp, Instruction SLTuOp> {
979 def : Pat<(setge RC:$lhs, RC:$rhs),
980 (XORi (SLTOp RC:$lhs, RC:$rhs), 1)>;
981 def : Pat<(setuge RC:$lhs, RC:$rhs),
982 (XORi (SLTuOp RC:$lhs, RC:$rhs), 1)>;
985 multiclass SetgeImmPats<RegisterClass RC, Instruction SLTiOp,
986 Instruction SLTiuOp> {
987 def : Pat<(setge RC:$lhs, immSExt16:$rhs),
988 (XORi (SLTiOp RC:$lhs, immSExt16:$rhs), 1)>;
989 def : Pat<(setuge RC:$lhs, immSExt16:$rhs),
990 (XORi (SLTiuOp RC:$lhs, immSExt16:$rhs), 1)>;
993 defm : SeteqPats<CPURegs, SLTiu, XOR, SLTu, ZERO>;
994 defm : SetlePats<CPURegs, SLT, SLTu>;
995 defm : SetgtPats<CPURegs, SLT, SLTu>;
996 defm : SetgePats<CPURegs, SLT, SLTu>;
997 defm : SetgeImmPats<CPURegs, SLTi, SLTiu>;
999 // select MipsDynAlloc
1000 def : Pat<(MipsDynAlloc addr:$f), (DynAlloc addr:$f)>;
1002 //===----------------------------------------------------------------------===//
1003 // Floating Point Support
1004 //===----------------------------------------------------------------------===//
1006 include "MipsInstrFPU.td"
1007 include "Mips64InstrInfo.td"
1008 include "MipsCondMov.td"