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 //===----------------------------------------------------------------------===//
15 //===----------------------------------------------------------------------===//
16 // Mips profiles and nodes
17 //===----------------------------------------------------------------------===//
19 def SDT_MipsJmpLink : SDTypeProfile<0, 1, [SDTCisVT<0, iPTR>]>;
20 def SDT_MipsCMov : SDTypeProfile<1, 4, [SDTCisSameAs<0, 1>,
24 def SDT_MipsCallSeqStart : SDCallSeqStart<[SDTCisVT<0, i32>]>;
25 def SDT_MipsCallSeqEnd : SDCallSeqEnd<[SDTCisVT<0, i32>, SDTCisVT<1, i32>]>;
26 def SDT_ExtractLOHI : SDTypeProfile<1, 2, [SDTCisInt<0>, SDTCisVT<1, untyped>,
28 def SDT_InsertLOHI : SDTypeProfile<1, 2, [SDTCisVT<0, untyped>,
31 def SDT_MipsMultDiv : SDTypeProfile<1, 2, [SDTCisVT<0, untyped>, SDTCisInt<1>,
33 def SDT_MipsMAddMSub : SDTypeProfile<1, 3,
34 [SDTCisVT<0, untyped>, SDTCisSameAs<0, 3>,
35 SDTCisVT<1, i32>, SDTCisSameAs<1, 2>]>;
36 def SDT_MipsDivRem16 : SDTypeProfile<0, 2, [SDTCisInt<0>, SDTCisSameAs<0, 1>]>;
38 def SDT_MipsThreadPointer : SDTypeProfile<1, 0, [SDTCisPtrTy<0>]>;
40 def SDT_Sync : SDTypeProfile<0, 1, [SDTCisVT<0, i32>]>;
42 def SDT_Ext : SDTypeProfile<1, 3, [SDTCisInt<0>, SDTCisSameAs<0, 1>,
43 SDTCisVT<2, i32>, SDTCisSameAs<2, 3>]>;
44 def SDT_Ins : SDTypeProfile<1, 4, [SDTCisInt<0>, SDTCisSameAs<0, 1>,
45 SDTCisVT<2, i32>, SDTCisSameAs<2, 3>,
48 def SDTMipsLoadLR : SDTypeProfile<1, 2,
49 [SDTCisInt<0>, SDTCisPtrTy<1>,
53 def MipsJmpLink : SDNode<"MipsISD::JmpLink",SDT_MipsJmpLink,
54 [SDNPHasChain, SDNPOutGlue, SDNPOptInGlue,
58 def MipsTailCall : SDNode<"MipsISD::TailCall", SDT_MipsJmpLink,
59 [SDNPHasChain, SDNPOptInGlue, SDNPVariadic]>;
61 // Hi and Lo nodes are used to handle global addresses. Used on
62 // MipsISelLowering to lower stuff like GlobalAddress, ExternalSymbol
63 // static model. (nothing to do with Mips Registers Hi and Lo)
64 def MipsHi : SDNode<"MipsISD::Hi", SDTIntUnaryOp>;
65 def MipsLo : SDNode<"MipsISD::Lo", SDTIntUnaryOp>;
66 def MipsGPRel : SDNode<"MipsISD::GPRel", SDTIntUnaryOp>;
68 // TlsGd node is used to handle General Dynamic TLS
69 def MipsTlsGd : SDNode<"MipsISD::TlsGd", SDTIntUnaryOp>;
71 // TprelHi and TprelLo nodes are used to handle Local Exec TLS
72 def MipsTprelHi : SDNode<"MipsISD::TprelHi", SDTIntUnaryOp>;
73 def MipsTprelLo : SDNode<"MipsISD::TprelLo", SDTIntUnaryOp>;
76 def MipsThreadPointer: SDNode<"MipsISD::ThreadPointer", SDT_MipsThreadPointer>;
79 def MipsRet : SDNode<"MipsISD::Ret", SDTNone,
80 [SDNPHasChain, SDNPOptInGlue, SDNPVariadic]>;
82 // These are target-independent nodes, but have target-specific formats.
83 def callseq_start : SDNode<"ISD::CALLSEQ_START", SDT_MipsCallSeqStart,
84 [SDNPHasChain, SDNPSideEffect, SDNPOutGlue]>;
85 def callseq_end : SDNode<"ISD::CALLSEQ_END", SDT_MipsCallSeqEnd,
86 [SDNPHasChain, SDNPSideEffect,
87 SDNPOptInGlue, SDNPOutGlue]>;
89 // Node used to extract integer from LO/HI register.
90 def ExtractLOHI : SDNode<"MipsISD::ExtractLOHI", SDT_ExtractLOHI>;
92 // Node used to insert 32-bit integers to LOHI register pair.
93 def InsertLOHI : SDNode<"MipsISD::InsertLOHI", SDT_InsertLOHI>;
96 def MipsMult : SDNode<"MipsISD::Mult", SDT_MipsMultDiv>;
97 def MipsMultu : SDNode<"MipsISD::Multu", SDT_MipsMultDiv>;
100 def MipsMAdd : SDNode<"MipsISD::MAdd", SDT_MipsMAddMSub>;
101 def MipsMAddu : SDNode<"MipsISD::MAddu", SDT_MipsMAddMSub>;
102 def MipsMSub : SDNode<"MipsISD::MSub", SDT_MipsMAddMSub>;
103 def MipsMSubu : SDNode<"MipsISD::MSubu", SDT_MipsMAddMSub>;
106 def MipsDivRem : SDNode<"MipsISD::DivRem", SDT_MipsMultDiv>;
107 def MipsDivRemU : SDNode<"MipsISD::DivRemU", SDT_MipsMultDiv>;
108 def MipsDivRem16 : SDNode<"MipsISD::DivRem16", SDT_MipsDivRem16,
110 def MipsDivRemU16 : SDNode<"MipsISD::DivRemU16", SDT_MipsDivRem16,
113 // Target constant nodes that are not part of any isel patterns and remain
114 // unchanged can cause instructions with illegal operands to be emitted.
115 // Wrapper node patterns give the instruction selector a chance to replace
116 // target constant nodes that would otherwise remain unchanged with ADDiu
117 // nodes. Without these wrapper node patterns, the following conditional move
118 // instrucion is emitted when function cmov2 in test/CodeGen/Mips/cmov.ll is
120 // movn %got(d)($gp), %got(c)($gp), $4
121 // This instruction is illegal since movn can take only register operands.
123 def MipsWrapper : SDNode<"MipsISD::Wrapper", SDTIntBinOp>;
125 def MipsSync : SDNode<"MipsISD::Sync", SDT_Sync, [SDNPHasChain,SDNPSideEffect]>;
127 def MipsExt : SDNode<"MipsISD::Ext", SDT_Ext>;
128 def MipsIns : SDNode<"MipsISD::Ins", SDT_Ins>;
130 def MipsLWL : SDNode<"MipsISD::LWL", SDTMipsLoadLR,
131 [SDNPHasChain, SDNPMayLoad, SDNPMemOperand]>;
132 def MipsLWR : SDNode<"MipsISD::LWR", SDTMipsLoadLR,
133 [SDNPHasChain, SDNPMayLoad, SDNPMemOperand]>;
134 def MipsSWL : SDNode<"MipsISD::SWL", SDTStore,
135 [SDNPHasChain, SDNPMayStore, SDNPMemOperand]>;
136 def MipsSWR : SDNode<"MipsISD::SWR", SDTStore,
137 [SDNPHasChain, SDNPMayStore, SDNPMemOperand]>;
138 def MipsLDL : SDNode<"MipsISD::LDL", SDTMipsLoadLR,
139 [SDNPHasChain, SDNPMayLoad, SDNPMemOperand]>;
140 def MipsLDR : SDNode<"MipsISD::LDR", SDTMipsLoadLR,
141 [SDNPHasChain, SDNPMayLoad, SDNPMemOperand]>;
142 def MipsSDL : SDNode<"MipsISD::SDL", SDTStore,
143 [SDNPHasChain, SDNPMayStore, SDNPMemOperand]>;
144 def MipsSDR : SDNode<"MipsISD::SDR", SDTStore,
145 [SDNPHasChain, SDNPMayStore, SDNPMemOperand]>;
147 //===----------------------------------------------------------------------===//
148 // Mips Instruction Predicate Definitions.
149 //===----------------------------------------------------------------------===//
150 def HasSEInReg : Predicate<"Subtarget.hasSEInReg()">,
151 AssemblerPredicate<"FeatureSEInReg">;
152 def HasBitCount : Predicate<"Subtarget.hasBitCount()">,
153 AssemblerPredicate<"FeatureBitCount">;
154 def HasSwap : Predicate<"Subtarget.hasSwap()">,
155 AssemblerPredicate<"FeatureSwap">;
156 def HasCondMov : Predicate<"Subtarget.hasCondMov()">,
157 AssemblerPredicate<"FeatureCondMov">;
158 def HasFPIdx : Predicate<"Subtarget.hasFPIdx()">,
159 AssemblerPredicate<"FeatureFPIdx">;
160 def HasMips32 : Predicate<"Subtarget.hasMips32()">,
161 AssemblerPredicate<"FeatureMips32">;
162 def HasMips32r2 : Predicate<"Subtarget.hasMips32r2()">,
163 AssemblerPredicate<"FeatureMips32r2">;
164 def HasMips64 : Predicate<"Subtarget.hasMips64()">,
165 AssemblerPredicate<"FeatureMips64">;
166 def NotMips64 : Predicate<"!Subtarget.hasMips64()">,
167 AssemblerPredicate<"!FeatureMips64">;
168 def HasMips64r2 : Predicate<"Subtarget.hasMips64r2()">,
169 AssemblerPredicate<"FeatureMips64r2">;
170 def IsN64 : Predicate<"Subtarget.isABI_N64()">,
171 AssemblerPredicate<"FeatureN64">;
172 def NotN64 : Predicate<"!Subtarget.isABI_N64()">,
173 AssemblerPredicate<"!FeatureN64">;
174 def InMips16Mode : Predicate<"Subtarget.inMips16Mode()">,
175 AssemblerPredicate<"FeatureMips16">;
176 def RelocStatic : Predicate<"TM.getRelocationModel() == Reloc::Static">,
177 AssemblerPredicate<"FeatureMips32">;
178 def RelocPIC : Predicate<"TM.getRelocationModel() == Reloc::PIC_">,
179 AssemblerPredicate<"FeatureMips32">;
180 def NoNaNsFPMath : Predicate<"TM.Options.NoNaNsFPMath">,
181 AssemblerPredicate<"FeatureMips32">;
182 def HasStdEnc : Predicate<"Subtarget.hasStandardEncoding()">,
183 AssemblerPredicate<"!FeatureMips16">;
184 def NotDSP : Predicate<"!Subtarget.hasDSP()">;
185 def InMicroMips : Predicate<"Subtarget.inMicroMipsMode()">,
186 AssemblerPredicate<"FeatureMicroMips">;
187 def NotInMicroMips : Predicate<"!Subtarget.inMicroMipsMode()">,
188 AssemblerPredicate<"!FeatureMicroMips">;
190 class MipsPat<dag pattern, dag result> : Pat<pattern, result> {
191 let Predicates = [HasStdEnc];
195 bit isCommutable = 1;
212 bit isTerminator = 1;
215 bit hasExtraSrcRegAllocReq = 1;
216 bit isCodeGenOnly = 1;
219 class IsAsCheapAsAMove {
220 bit isAsCheapAsAMove = 1;
223 class NeverHasSideEffects {
224 bit neverHasSideEffects = 1;
227 //===----------------------------------------------------------------------===//
228 // Instruction format superclass
229 //===----------------------------------------------------------------------===//
231 include "MipsInstrFormats.td"
233 //===----------------------------------------------------------------------===//
234 // Mips Operand, Complex Patterns and Transformations Definitions.
235 //===----------------------------------------------------------------------===//
237 // Instruction operand types
238 def jmptarget : Operand<OtherVT> {
239 let EncoderMethod = "getJumpTargetOpValue";
241 def brtarget : Operand<OtherVT> {
242 let EncoderMethod = "getBranchTargetOpValue";
243 let OperandType = "OPERAND_PCREL";
244 let DecoderMethod = "DecodeBranchTarget";
246 def calltarget : Operand<iPTR> {
247 let EncoderMethod = "getJumpTargetOpValue";
249 def calltarget64: Operand<i64>;
250 def simm16 : Operand<i32> {
251 let DecoderMethod= "DecodeSimm16";
254 def simm20 : Operand<i32> {
257 def uimm20 : Operand<i32> {
260 def uimm10 : Operand<i32> {
263 def simm16_64 : Operand<i64>;
264 def shamt : Operand<i32>;
267 def uimm5 : Operand<i32> {
268 let PrintMethod = "printUnsignedImm";
271 def uimm16 : Operand<i32> {
272 let PrintMethod = "printUnsignedImm";
275 def MipsMemAsmOperand : AsmOperandClass {
277 let ParserMethod = "parseMemOperand";
281 def mem : Operand<i32> {
282 let PrintMethod = "printMemOperand";
283 let MIOperandInfo = (ops GPR32, simm16);
284 let EncoderMethod = "getMemEncoding";
285 let ParserMatchClass = MipsMemAsmOperand;
286 let OperandType = "OPERAND_MEMORY";
289 def mem64 : Operand<i64> {
290 let PrintMethod = "printMemOperand";
291 let MIOperandInfo = (ops GPR64, simm16_64);
292 let EncoderMethod = "getMemEncoding";
293 let ParserMatchClass = MipsMemAsmOperand;
294 let OperandType = "OPERAND_MEMORY";
297 def mem_ea : Operand<i32> {
298 let PrintMethod = "printMemOperandEA";
299 let MIOperandInfo = (ops GPR32, simm16);
300 let EncoderMethod = "getMemEncoding";
301 let OperandType = "OPERAND_MEMORY";
304 def mem_ea_64 : Operand<i64> {
305 let PrintMethod = "printMemOperandEA";
306 let MIOperandInfo = (ops GPR64, simm16_64);
307 let EncoderMethod = "getMemEncoding";
308 let OperandType = "OPERAND_MEMORY";
311 // size operand of ext instruction
312 def size_ext : Operand<i32> {
313 let EncoderMethod = "getSizeExtEncoding";
314 let DecoderMethod = "DecodeExtSize";
317 // size operand of ins instruction
318 def size_ins : Operand<i32> {
319 let EncoderMethod = "getSizeInsEncoding";
320 let DecoderMethod = "DecodeInsSize";
323 // Transformation Function - get the lower 16 bits.
324 def LO16 : SDNodeXForm<imm, [{
325 return getImm(N, N->getZExtValue() & 0xFFFF);
328 // Transformation Function - get the higher 16 bits.
329 def HI16 : SDNodeXForm<imm, [{
330 return getImm(N, (N->getZExtValue() >> 16) & 0xFFFF);
334 def Plus1 : SDNodeXForm<imm, [{ return getImm(N, N->getSExtValue() + 1); }]>;
336 // Node immediate fits as 16-bit sign extended on target immediate.
338 def immSExt8 : PatLeaf<(imm), [{ return isInt<8>(N->getSExtValue()); }]>;
340 // Node immediate fits as 16-bit sign extended on target immediate.
342 def immSExt16 : PatLeaf<(imm), [{ return isInt<16>(N->getSExtValue()); }]>;
344 // Node immediate fits as 15-bit sign extended on target immediate.
346 def immSExt15 : PatLeaf<(imm), [{ return isInt<15>(N->getSExtValue()); }]>;
348 // Node immediate fits as 16-bit zero extended on target immediate.
349 // The LO16 param means that only the lower 16 bits of the node
350 // immediate are caught.
352 def immZExt16 : PatLeaf<(imm), [{
353 if (N->getValueType(0) == MVT::i32)
354 return (uint32_t)N->getZExtValue() == (unsigned short)N->getZExtValue();
356 return (uint64_t)N->getZExtValue() == (unsigned short)N->getZExtValue();
359 // Immediate can be loaded with LUi (32-bit int with lower 16-bit cleared).
360 def immLow16Zero : PatLeaf<(imm), [{
361 int64_t Val = N->getSExtValue();
362 return isInt<32>(Val) && !(Val & 0xffff);
365 // shamt field must fit in 5 bits.
366 def immZExt5 : ImmLeaf<i32, [{return Imm == (Imm & 0x1f);}]>;
368 // True if (N + 1) fits in 16-bit field.
369 def immSExt16Plus1 : PatLeaf<(imm), [{
370 return isInt<17>(N->getSExtValue()) && isInt<16>(N->getSExtValue() + 1);
373 // Mips Address Mode! SDNode frameindex could possibily be a match
374 // since load and store instructions from stack used it.
376 ComplexPattern<iPTR, 2, "selectIntAddr", [frameindex]>;
379 ComplexPattern<iPTR, 2, "selectAddrRegImm", [frameindex]>;
382 ComplexPattern<iPTR, 2, "selectAddrDefault", [frameindex]>;
384 //===----------------------------------------------------------------------===//
385 // Instructions specific format
386 //===----------------------------------------------------------------------===//
388 // Arithmetic and logical instructions with 3 register operands.
389 class ArithLogicR<string opstr, RegisterOperand RO, bit isComm = 0,
390 InstrItinClass Itin = NoItinerary,
391 SDPatternOperator OpNode = null_frag>:
392 InstSE<(outs RO:$rd), (ins RO:$rs, RO:$rt),
393 !strconcat(opstr, "\t$rd, $rs, $rt"),
394 [(set RO:$rd, (OpNode RO:$rs, RO:$rt))], Itin, FrmR, opstr> {
395 let isCommutable = isComm;
396 let isReMaterializable = 1;
399 // Arithmetic and logical instructions with 2 register operands.
400 class ArithLogicI<string opstr, Operand Od, RegisterOperand RO,
401 InstrItinClass Itin = NoItinerary,
402 SDPatternOperator imm_type = null_frag,
403 SDPatternOperator OpNode = null_frag> :
404 InstSE<(outs RO:$rt), (ins RO:$rs, Od:$imm16),
405 !strconcat(opstr, "\t$rt, $rs, $imm16"),
406 [(set RO:$rt, (OpNode RO:$rs, imm_type:$imm16))],
408 let isReMaterializable = 1;
409 let TwoOperandAliasConstraint = "$rs = $rt";
412 // Arithmetic Multiply ADD/SUB
413 class MArithR<string opstr, bit isComm = 0> :
414 InstSE<(outs), (ins GPR32Opnd:$rs, GPR32Opnd:$rt),
415 !strconcat(opstr, "\t$rs, $rt"), [], IIImult, FrmR> {
416 let Defs = [HI0, LO0];
417 let Uses = [HI0, LO0];
418 let isCommutable = isComm;
422 class LogicNOR<string opstr, RegisterOperand RO>:
423 InstSE<(outs RO:$rd), (ins RO:$rs, RO:$rt),
424 !strconcat(opstr, "\t$rd, $rs, $rt"),
425 [(set RO:$rd, (not (or RO:$rs, RO:$rt)))], IIArith, FrmR, opstr> {
426 let isCommutable = 1;
430 class shift_rotate_imm<string opstr, Operand ImmOpnd,
431 RegisterOperand RO, SDPatternOperator OpNode = null_frag,
432 SDPatternOperator PF = null_frag> :
433 InstSE<(outs RO:$rd), (ins RO:$rt, ImmOpnd:$shamt),
434 !strconcat(opstr, "\t$rd, $rt, $shamt"),
435 [(set RO:$rd, (OpNode RO:$rt, PF:$shamt))], IIArith, FrmR, opstr>;
437 class shift_rotate_reg<string opstr, RegisterOperand RO,
438 SDPatternOperator OpNode = null_frag>:
439 InstSE<(outs RO:$rd), (ins RO:$rt, GPR32Opnd:$rs),
440 !strconcat(opstr, "\t$rd, $rt, $rs"),
441 [(set RO:$rd, (OpNode RO:$rt, GPR32Opnd:$rs))], IIArith, FrmR, opstr>;
443 // Load Upper Imediate
444 class LoadUpper<string opstr, RegisterOperand RO, Operand Imm>:
445 InstSE<(outs RO:$rt), (ins Imm:$imm16), !strconcat(opstr, "\t$rt, $imm16"),
446 [], IIArith, FrmI>, IsAsCheapAsAMove {
447 let neverHasSideEffects = 1;
448 let isReMaterializable = 1;
451 class FMem<bits<6> op, dag outs, dag ins, string asmstr, list<dag> pattern,
452 InstrItinClass itin>: FFI<op, outs, ins, asmstr, pattern> {
454 let Inst{25-21} = addr{20-16};
455 let Inst{15-0} = addr{15-0};
456 let DecoderMethod = "DecodeMem";
460 class Load<string opstr, SDPatternOperator OpNode, DAGOperand RO,
461 InstrItinClass Itin, Operand MemOpnd, ComplexPattern Addr,
463 InstSE<(outs RO:$rt), (ins MemOpnd:$addr), !strconcat(opstr, "\t$rt, $addr"),
464 [(set RO:$rt, (OpNode Addr:$addr))], NoItinerary, FrmI,
465 !strconcat(opstr, ofsuffix)> {
466 let DecoderMethod = "DecodeMem";
467 let canFoldAsLoad = 1;
471 class Store<string opstr, SDPatternOperator OpNode, DAGOperand RO,
472 InstrItinClass Itin, Operand MemOpnd, ComplexPattern Addr,
474 InstSE<(outs), (ins RO:$rt, MemOpnd:$addr), !strconcat(opstr, "\t$rt, $addr"),
475 [(OpNode RO:$rt, Addr:$addr)], NoItinerary, FrmI,
476 !strconcat(opstr, ofsuffix)> {
477 let DecoderMethod = "DecodeMem";
481 multiclass LoadM<string opstr, DAGOperand RO,
482 SDPatternOperator OpNode = null_frag,
483 InstrItinClass Itin = NoItinerary,
484 ComplexPattern Addr = addr> {
485 def NAME : Load<opstr, OpNode, RO, Itin, mem, Addr, "">,
486 Requires<[NotN64, HasStdEnc]>;
487 def _P8 : Load<opstr, OpNode, RO, Itin, mem64, Addr, "_p8">,
488 Requires<[IsN64, HasStdEnc]> {
489 let DecoderNamespace = "Mips64";
490 let isCodeGenOnly = 1;
494 multiclass StoreM<string opstr, DAGOperand RO,
495 SDPatternOperator OpNode = null_frag,
496 InstrItinClass Itin = NoItinerary,
497 ComplexPattern Addr = addr> {
498 def NAME : Store<opstr, OpNode, RO, Itin, mem, Addr, "">,
499 Requires<[NotN64, HasStdEnc]>;
500 def _P8 : Store<opstr, OpNode, RO, Itin, mem64, Addr, "_p8">,
501 Requires<[IsN64, HasStdEnc]> {
502 let DecoderNamespace = "Mips64";
503 let isCodeGenOnly = 1;
507 // Load/Store Left/Right
508 let canFoldAsLoad = 1 in
509 class LoadLeftRight<string opstr, SDNode OpNode, RegisterOperand RO,
511 InstSE<(outs RO:$rt), (ins MemOpnd:$addr, RO:$src),
512 !strconcat(opstr, "\t$rt, $addr"),
513 [(set RO:$rt, (OpNode addr:$addr, RO:$src))], NoItinerary, FrmI> {
514 let DecoderMethod = "DecodeMem";
515 string Constraints = "$src = $rt";
518 class StoreLeftRight<string opstr, SDNode OpNode, RegisterOperand RO,
520 InstSE<(outs), (ins RO:$rt, MemOpnd:$addr), !strconcat(opstr, "\t$rt, $addr"),
521 [(OpNode RO:$rt, addr:$addr)], NoItinerary, FrmI> {
522 let DecoderMethod = "DecodeMem";
525 multiclass LoadLeftRightM<string opstr, SDNode OpNode, RegisterOperand RO> {
526 def NAME : LoadLeftRight<opstr, OpNode, RO, mem>,
527 Requires<[NotN64, HasStdEnc, NotInMicroMips]>;
528 def _P8 : LoadLeftRight<opstr, OpNode, RO, mem64>,
529 Requires<[IsN64, HasStdEnc]> {
530 let DecoderNamespace = "Mips64";
531 let isCodeGenOnly = 1;
535 multiclass StoreLeftRightM<string opstr, SDNode OpNode, RegisterOperand RO> {
536 def NAME : StoreLeftRight<opstr, OpNode, RO, mem>,
537 Requires<[NotN64, HasStdEnc, NotInMicroMips]>;
538 def _P8 : StoreLeftRight<opstr, OpNode, RO, mem64>,
539 Requires<[IsN64, HasStdEnc]> {
540 let DecoderNamespace = "Mips64";
541 let isCodeGenOnly = 1;
545 // Conditional Branch
546 class CBranch<string opstr, PatFrag cond_op, RegisterOperand RO> :
547 InstSE<(outs), (ins RO:$rs, RO:$rt, brtarget:$offset),
548 !strconcat(opstr, "\t$rs, $rt, $offset"),
549 [(brcond (i32 (cond_op RO:$rs, RO:$rt)), bb:$offset)], IIBranch,
552 let isTerminator = 1;
553 let hasDelaySlot = 1;
557 class CBranchZero<string opstr, PatFrag cond_op, RegisterOperand RO> :
558 InstSE<(outs), (ins RO:$rs, brtarget:$offset),
559 !strconcat(opstr, "\t$rs, $offset"),
560 [(brcond (i32 (cond_op RO:$rs, 0)), bb:$offset)], IIBranch, FrmI> {
562 let isTerminator = 1;
563 let hasDelaySlot = 1;
568 class SetCC_R<string opstr, PatFrag cond_op, RegisterOperand RO> :
569 InstSE<(outs GPR32Opnd:$rd), (ins RO:$rs, RO:$rt),
570 !strconcat(opstr, "\t$rd, $rs, $rt"),
571 [(set GPR32Opnd:$rd, (cond_op RO:$rs, RO:$rt))],
574 class SetCC_I<string opstr, PatFrag cond_op, Operand Od, PatLeaf imm_type,
576 InstSE<(outs GPR32Opnd:$rt), (ins RO:$rs, Od:$imm16),
577 !strconcat(opstr, "\t$rt, $rs, $imm16"),
578 [(set GPR32Opnd:$rt, (cond_op RO:$rs, imm_type:$imm16))],
582 class JumpFJ<DAGOperand opnd, string opstr, SDPatternOperator operator,
583 SDPatternOperator targetoperator> :
584 InstSE<(outs), (ins opnd:$target), !strconcat(opstr, "\t$target"),
585 [(operator targetoperator:$target)], IIBranch, FrmJ> {
588 let hasDelaySlot = 1;
589 let DecoderMethod = "DecodeJumpTarget";
593 // Unconditional branch
594 class UncondBranch<string opstr> :
595 InstSE<(outs), (ins brtarget:$offset), !strconcat(opstr, "\t$offset"),
596 [(br bb:$offset)], IIBranch, FrmI> {
598 let isTerminator = 1;
600 let hasDelaySlot = 1;
601 let Predicates = [RelocPIC, HasStdEnc];
605 // Base class for indirect branch and return instruction classes.
606 let isTerminator=1, isBarrier=1, hasDelaySlot = 1 in
607 class JumpFR<RegisterOperand RO, SDPatternOperator operator = null_frag>:
608 InstSE<(outs), (ins RO:$rs), "jr\t$rs", [(operator RO:$rs)], IIBranch, FrmR>;
611 class IndirectBranch<RegisterOperand RO>: JumpFR<RO, brind> {
613 let isIndirectBranch = 1;
616 // Return instruction
617 class RetBase<RegisterOperand RO>: JumpFR<RO> {
619 let isCodeGenOnly = 1;
621 let hasExtraSrcRegAllocReq = 1;
624 // Jump and Link (Call)
625 let isCall=1, hasDelaySlot=1, Defs = [RA] in {
626 class JumpLink<string opstr> :
627 InstSE<(outs), (ins calltarget:$target), !strconcat(opstr, "\t$target"),
628 [(MipsJmpLink imm:$target)], IIBranch, FrmJ> {
629 let DecoderMethod = "DecodeJumpTarget";
632 class JumpLinkRegPseudo<RegisterOperand RO, Instruction JALRInst,
633 Register RetReg, RegisterOperand ResRO = RO>:
634 PseudoSE<(outs), (ins RO:$rs), [(MipsJmpLink RO:$rs)], IIBranch>,
635 PseudoInstExpansion<(JALRInst RetReg, ResRO:$rs)>;
637 class JumpLinkReg<string opstr, RegisterOperand RO>:
638 InstSE<(outs RO:$rd), (ins RO:$rs), !strconcat(opstr, "\t$rd, $rs"),
641 class BGEZAL_FT<string opstr, RegisterOperand RO> :
642 InstSE<(outs), (ins RO:$rs, brtarget:$offset),
643 !strconcat(opstr, "\t$rs, $offset"), [], IIBranch, FrmI>;
647 class BAL_BR_Pseudo<Instruction RealInst> :
648 PseudoSE<(outs), (ins brtarget:$offset), [], IIBranch>,
649 PseudoInstExpansion<(RealInst ZERO, brtarget:$offset)> {
651 let isTerminator = 1;
653 let hasDelaySlot = 1;
658 class SYS_FT<string opstr> :
659 InstSE<(outs), (ins uimm20:$code_),
660 !strconcat(opstr, "\t$code_"), [], NoItinerary, FrmI>;
662 class BRK_FT<string opstr> :
663 InstSE<(outs), (ins uimm10:$code_1, uimm10:$code_2),
664 !strconcat(opstr, "\t$code_1, $code_2"), [], NoItinerary, FrmOther>;
667 class ER_FT<string opstr> :
668 InstSE<(outs), (ins),
669 opstr, [], NoItinerary, FrmOther>;
672 class DEI_FT<string opstr, RegisterOperand RO> :
673 InstSE<(outs RO:$rt), (ins),
674 !strconcat(opstr, "\t$rt"), [], NoItinerary, FrmOther>;
677 let hasSideEffects = 1 in
679 InstSE<(outs), (ins i32imm:$stype), "sync $stype", [(MipsSync imm:$stype)],
680 NoItinerary, FrmOther>;
682 let hasSideEffects = 1 in
683 class TEQ_FT<string opstr, RegisterOperand RO> :
684 InstSE<(outs), (ins RO:$rs, RO:$rt, uimm16:$code_),
685 !strconcat(opstr, "\t$rs, $rt, $code_"), [], NoItinerary, FrmI>;
688 class Mult<string opstr, InstrItinClass itin, RegisterOperand RO,
689 list<Register> DefRegs> :
690 InstSE<(outs), (ins RO:$rs, RO:$rt), !strconcat(opstr, "\t$rs, $rt"), [],
692 let isCommutable = 1;
694 let neverHasSideEffects = 1;
697 // Pseudo multiply/divide instruction with explicit accumulator register
699 class MultDivPseudo<Instruction RealInst, RegisterClass R0, RegisterOperand R1,
700 SDPatternOperator OpNode, InstrItinClass Itin,
701 bit IsComm = 1, bit HasSideEffects = 0,
702 bit UsesCustomInserter = 0> :
703 PseudoSE<(outs R0:$ac), (ins R1:$rs, R1:$rt),
704 [(set R0:$ac, (OpNode R1:$rs, R1:$rt))], Itin>,
705 PseudoInstExpansion<(RealInst R1:$rs, R1:$rt)> {
706 let isCommutable = IsComm;
707 let hasSideEffects = HasSideEffects;
708 let usesCustomInserter = UsesCustomInserter;
711 // Pseudo multiply add/sub instruction with explicit accumulator register
713 class MAddSubPseudo<Instruction RealInst, SDPatternOperator OpNode>
714 : PseudoSE<(outs ACC64:$ac),
715 (ins GPR32Opnd:$rs, GPR32Opnd:$rt, ACC64:$acin),
717 (OpNode GPR32Opnd:$rs, GPR32Opnd:$rt, ACC64:$acin))],
719 PseudoInstExpansion<(RealInst GPR32Opnd:$rs, GPR32Opnd:$rt)> {
720 string Constraints = "$acin = $ac";
723 class Div<string opstr, InstrItinClass itin, RegisterOperand RO,
724 list<Register> DefRegs> :
725 InstSE<(outs), (ins RO:$rs, RO:$rt), !strconcat(opstr, "\t$$zero, $rs, $rt"),
731 class MoveFromLOHI<string opstr, RegisterOperand RO, list<Register> UseRegs>:
732 InstSE<(outs RO:$rd), (ins), !strconcat(opstr, "\t$rd"), [], IIHiLo, FrmR> {
734 let neverHasSideEffects = 1;
737 class MoveToLOHI<string opstr, RegisterOperand RO, list<Register> DefRegs>:
738 InstSE<(outs), (ins RO:$rs), !strconcat(opstr, "\t$rs"), [], IIHiLo, FrmR> {
740 let neverHasSideEffects = 1;
743 class EffectiveAddress<string opstr, RegisterOperand RO, Operand Mem> :
744 InstSE<(outs RO:$rt), (ins Mem:$addr), !strconcat(opstr, "\t$rt, $addr"),
745 [(set RO:$rt, addr:$addr)], NoItinerary, FrmI> {
746 let isCodeGenOnly = 1;
747 let DecoderMethod = "DecodeMem";
750 // Count Leading Ones/Zeros in Word
751 class CountLeading0<string opstr, RegisterOperand RO>:
752 InstSE<(outs RO:$rd), (ins RO:$rs), !strconcat(opstr, "\t$rd, $rs"),
753 [(set RO:$rd, (ctlz RO:$rs))], IIArith, FrmR>,
754 Requires<[HasBitCount, HasStdEnc]>;
756 class CountLeading1<string opstr, RegisterOperand RO>:
757 InstSE<(outs RO:$rd), (ins RO:$rs), !strconcat(opstr, "\t$rd, $rs"),
758 [(set RO:$rd, (ctlz (not RO:$rs)))], IIArith, FrmR>,
759 Requires<[HasBitCount, HasStdEnc]>;
762 // Sign Extend in Register.
763 class SignExtInReg<string opstr, ValueType vt, RegisterOperand RO> :
764 InstSE<(outs RO:$rd), (ins RO:$rt), !strconcat(opstr, "\t$rd, $rt"),
765 [(set RO:$rd, (sext_inreg RO:$rt, vt))], IIseb, FrmR> {
766 let Predicates = [HasSEInReg, HasStdEnc];
770 class SubwordSwap<string opstr, RegisterOperand RO>:
771 InstSE<(outs RO:$rd), (ins RO:$rt), !strconcat(opstr, "\t$rd, $rt"), [],
773 let Predicates = [HasSwap, HasStdEnc];
774 let neverHasSideEffects = 1;
778 class ReadHardware<RegisterOperand CPURegOperand, RegisterOperand RO> :
779 InstSE<(outs CPURegOperand:$rt), (ins RO:$rd), "rdhwr\t$rt, $rd", [],
783 class ExtBase<string opstr, RegisterOperand RO>:
784 InstSE<(outs RO:$rt), (ins RO:$rs, uimm16:$pos, size_ext:$size),
785 !strconcat(opstr, " $rt, $rs, $pos, $size"),
786 [(set RO:$rt, (MipsExt RO:$rs, imm:$pos, imm:$size))], NoItinerary,
788 let Predicates = [HasMips32r2, HasStdEnc];
791 class InsBase<string opstr, RegisterOperand RO>:
792 InstSE<(outs RO:$rt), (ins RO:$rs, uimm16:$pos, size_ins:$size, RO:$src),
793 !strconcat(opstr, " $rt, $rs, $pos, $size"),
794 [(set RO:$rt, (MipsIns RO:$rs, imm:$pos, imm:$size, RO:$src))],
796 let Predicates = [HasMips32r2, HasStdEnc];
797 let Constraints = "$src = $rt";
800 // Atomic instructions with 2 source operands (ATOMIC_SWAP & ATOMIC_LOAD_*).
801 class Atomic2Ops<PatFrag Op, RegisterClass DRC, RegisterClass PRC> :
802 PseudoSE<(outs DRC:$dst), (ins PRC:$ptr, DRC:$incr),
803 [(set DRC:$dst, (Op PRC:$ptr, DRC:$incr))]>;
805 multiclass Atomic2Ops32<PatFrag Op> {
806 def NAME : Atomic2Ops<Op, GPR32, GPR32>, Requires<[NotN64, HasStdEnc]>;
807 def _P8 : Atomic2Ops<Op, GPR32, GPR64>, Requires<[IsN64, HasStdEnc]>;
810 // Atomic Compare & Swap.
811 class AtomicCmpSwap<PatFrag Op, RegisterClass DRC, RegisterClass PRC> :
812 PseudoSE<(outs DRC:$dst), (ins PRC:$ptr, DRC:$cmp, DRC:$swap),
813 [(set DRC:$dst, (Op PRC:$ptr, DRC:$cmp, DRC:$swap))]>;
815 multiclass AtomicCmpSwap32<PatFrag Op> {
816 def NAME : AtomicCmpSwap<Op, GPR32, GPR32>,
817 Requires<[NotN64, HasStdEnc]>;
818 def _P8 : AtomicCmpSwap<Op, GPR32, GPR64>,
819 Requires<[IsN64, HasStdEnc]>;
822 class LLBase<string opstr, RegisterOperand RO, Operand Mem> :
823 InstSE<(outs RO:$rt), (ins Mem:$addr), !strconcat(opstr, "\t$rt, $addr"),
824 [], NoItinerary, FrmI> {
825 let DecoderMethod = "DecodeMem";
829 class SCBase<string opstr, RegisterOperand RO, Operand Mem> :
830 InstSE<(outs RO:$dst), (ins RO:$rt, Mem:$addr),
831 !strconcat(opstr, "\t$rt, $addr"), [], NoItinerary, FrmI> {
832 let DecoderMethod = "DecodeMem";
834 let Constraints = "$rt = $dst";
837 class MFC3OP<dag outs, dag ins, string asmstr> :
838 InstSE<outs, ins, asmstr, [], NoItinerary, FrmFR>;
840 let isBarrier = 1, isTerminator = 1, isCodeGenOnly = 1 in
841 def TRAP : InstSE<(outs), (ins), "break", [(trap)], NoItinerary, FrmOther> {
842 let Inst = 0x0000000d;
845 //===----------------------------------------------------------------------===//
846 // Pseudo instructions
847 //===----------------------------------------------------------------------===//
850 let isReturn=1, isTerminator=1, hasDelaySlot=1, isBarrier=1, hasCtrlDep=1 in
851 def RetRA : PseudoSE<(outs), (ins), [(MipsRet)]>;
853 let Defs = [SP], Uses = [SP], hasSideEffects = 1 in {
854 def ADJCALLSTACKDOWN : MipsPseudo<(outs), (ins i32imm:$amt),
855 [(callseq_start timm:$amt)]>;
856 def ADJCALLSTACKUP : MipsPseudo<(outs), (ins i32imm:$amt1, i32imm:$amt2),
857 [(callseq_end timm:$amt1, timm:$amt2)]>;
860 let usesCustomInserter = 1 in {
861 defm ATOMIC_LOAD_ADD_I8 : Atomic2Ops32<atomic_load_add_8>;
862 defm ATOMIC_LOAD_ADD_I16 : Atomic2Ops32<atomic_load_add_16>;
863 defm ATOMIC_LOAD_ADD_I32 : Atomic2Ops32<atomic_load_add_32>;
864 defm ATOMIC_LOAD_SUB_I8 : Atomic2Ops32<atomic_load_sub_8>;
865 defm ATOMIC_LOAD_SUB_I16 : Atomic2Ops32<atomic_load_sub_16>;
866 defm ATOMIC_LOAD_SUB_I32 : Atomic2Ops32<atomic_load_sub_32>;
867 defm ATOMIC_LOAD_AND_I8 : Atomic2Ops32<atomic_load_and_8>;
868 defm ATOMIC_LOAD_AND_I16 : Atomic2Ops32<atomic_load_and_16>;
869 defm ATOMIC_LOAD_AND_I32 : Atomic2Ops32<atomic_load_and_32>;
870 defm ATOMIC_LOAD_OR_I8 : Atomic2Ops32<atomic_load_or_8>;
871 defm ATOMIC_LOAD_OR_I16 : Atomic2Ops32<atomic_load_or_16>;
872 defm ATOMIC_LOAD_OR_I32 : Atomic2Ops32<atomic_load_or_32>;
873 defm ATOMIC_LOAD_XOR_I8 : Atomic2Ops32<atomic_load_xor_8>;
874 defm ATOMIC_LOAD_XOR_I16 : Atomic2Ops32<atomic_load_xor_16>;
875 defm ATOMIC_LOAD_XOR_I32 : Atomic2Ops32<atomic_load_xor_32>;
876 defm ATOMIC_LOAD_NAND_I8 : Atomic2Ops32<atomic_load_nand_8>;
877 defm ATOMIC_LOAD_NAND_I16 : Atomic2Ops32<atomic_load_nand_16>;
878 defm ATOMIC_LOAD_NAND_I32 : Atomic2Ops32<atomic_load_nand_32>;
880 defm ATOMIC_SWAP_I8 : Atomic2Ops32<atomic_swap_8>;
881 defm ATOMIC_SWAP_I16 : Atomic2Ops32<atomic_swap_16>;
882 defm ATOMIC_SWAP_I32 : Atomic2Ops32<atomic_swap_32>;
884 defm ATOMIC_CMP_SWAP_I8 : AtomicCmpSwap32<atomic_cmp_swap_8>;
885 defm ATOMIC_CMP_SWAP_I16 : AtomicCmpSwap32<atomic_cmp_swap_16>;
886 defm ATOMIC_CMP_SWAP_I32 : AtomicCmpSwap32<atomic_cmp_swap_32>;
889 /// Pseudo instructions for loading and storing accumulator registers.
890 let isPseudo = 1, isCodeGenOnly = 1 in {
891 defm LOAD_ACC64 : LoadM<"", ACC64>;
892 defm STORE_ACC64 : StoreM<"", ACC64>;
895 //===----------------------------------------------------------------------===//
896 // Instruction definition
897 //===----------------------------------------------------------------------===//
898 //===----------------------------------------------------------------------===//
899 // MipsI Instructions
900 //===----------------------------------------------------------------------===//
902 /// Arithmetic Instructions (ALU Immediate)
903 def ADDiu : MMRel, ArithLogicI<"addiu", simm16, GPR32Opnd, IIArith, immSExt16,
905 ADDI_FM<0x9>, IsAsCheapAsAMove;
906 def ADDi : MMRel, ArithLogicI<"addi", simm16, GPR32Opnd>, ADDI_FM<0x8>;
907 def SLTi : MMRel, SetCC_I<"slti", setlt, simm16, immSExt16, GPR32Opnd>,
909 def SLTiu : MMRel, SetCC_I<"sltiu", setult, simm16, immSExt16, GPR32Opnd>,
911 def ANDi : MMRel, ArithLogicI<"andi", uimm16, GPR32Opnd, IILogic, immZExt16,
914 def ORi : MMRel, ArithLogicI<"ori", uimm16, GPR32Opnd, IILogic, immZExt16,
917 def XORi : MMRel, ArithLogicI<"xori", uimm16, GPR32Opnd, IILogic, immZExt16,
920 def LUi : MMRel, LoadUpper<"lui", GPR32Opnd, uimm16>, LUI_FM;
922 /// Arithmetic Instructions (3-Operand, R-Type)
923 def ADDu : MMRel, ArithLogicR<"addu", GPR32Opnd, 1, IIArith, add>,
925 def SUBu : MMRel, ArithLogicR<"subu", GPR32Opnd, 0, IIArith, sub>,
927 def MUL : MMRel, ArithLogicR<"mul", GPR32Opnd, 1, IIImul, mul>,
929 def ADD : MMRel, ArithLogicR<"add", GPR32Opnd>, ADD_FM<0, 0x20>;
930 def SUB : MMRel, ArithLogicR<"sub", GPR32Opnd>, ADD_FM<0, 0x22>;
931 def SLT : MMRel, SetCC_R<"slt", setlt, GPR32Opnd>, ADD_FM<0, 0x2a>;
932 def SLTu : MMRel, SetCC_R<"sltu", setult, GPR32Opnd>, ADD_FM<0, 0x2b>;
933 def AND : MMRel, ArithLogicR<"and", GPR32Opnd, 1, IILogic, and>,
935 def OR : MMRel, ArithLogicR<"or", GPR32Opnd, 1, IILogic, or>,
937 def XOR : MMRel, ArithLogicR<"xor", GPR32Opnd, 1, IILogic, xor>,
939 def NOR : MMRel, LogicNOR<"nor", GPR32Opnd>, ADD_FM<0, 0x27>;
941 /// Shift Instructions
942 def SLL : MMRel, shift_rotate_imm<"sll", shamt, GPR32Opnd, shl, immZExt5>,
944 def SRL : MMRel, shift_rotate_imm<"srl", shamt, GPR32Opnd, srl, immZExt5>,
946 def SRA : MMRel, shift_rotate_imm<"sra", shamt, GPR32Opnd, sra, immZExt5>,
948 def SLLV : MMRel, shift_rotate_reg<"sllv", GPR32Opnd, shl>, SRLV_FM<4, 0>;
949 def SRLV : MMRel, shift_rotate_reg<"srlv", GPR32Opnd, srl>, SRLV_FM<6, 0>;
950 def SRAV : MMRel, shift_rotate_reg<"srav", GPR32Opnd, sra>, SRLV_FM<7, 0>;
952 // Rotate Instructions
953 let Predicates = [HasMips32r2, HasStdEnc] in {
954 def ROTR : MMRel, shift_rotate_imm<"rotr", shamt, GPR32Opnd, rotr,
957 def ROTRV : MMRel, shift_rotate_reg<"rotrv", GPR32Opnd, rotr>,
961 /// Load and Store Instructions
963 defm LB : LoadM<"lb", GPR32Opnd, sextloadi8, IILoad>, MMRel, LW_FM<0x20>;
964 defm LBu : LoadM<"lbu", GPR32Opnd, zextloadi8, IILoad, addrDefault>, MMRel,
966 defm LH : LoadM<"lh", GPR32Opnd, sextloadi16, IILoad, addrDefault>, MMRel,
968 defm LHu : LoadM<"lhu", GPR32Opnd, zextloadi16, IILoad>, MMRel, LW_FM<0x25>;
969 defm LW : LoadM<"lw", GPR32Opnd, load, IILoad, addrDefault>, MMRel,
971 defm SB : StoreM<"sb", GPR32Opnd, truncstorei8, IIStore>, MMRel, LW_FM<0x28>;
972 defm SH : StoreM<"sh", GPR32Opnd, truncstorei16, IIStore>, MMRel, LW_FM<0x29>;
973 defm SW : StoreM<"sw", GPR32Opnd, store, IIStore>, MMRel, LW_FM<0x2b>;
975 /// load/store left/right
976 defm LWL : LoadLeftRightM<"lwl", MipsLWL, GPR32Opnd>, LW_FM<0x22>;
977 defm LWR : LoadLeftRightM<"lwr", MipsLWR, GPR32Opnd>, LW_FM<0x26>;
978 defm SWL : StoreLeftRightM<"swl", MipsSWL, GPR32Opnd>, LW_FM<0x2a>;
979 defm SWR : StoreLeftRightM<"swr", MipsSWR, GPR32Opnd>, LW_FM<0x2e>;
981 def SYNC : SYNC_FT, SYNC_FM;
982 def TEQ : TEQ_FT<"teq", GPR32Opnd>, TEQ_FM<0x34>;
984 def BREAK : BRK_FT<"break">, BRK_FM<0xd>;
985 def SYSCALL : SYS_FT<"syscall">, SYS_FM<0xc>;
987 def ERET : ER_FT<"eret">, ER_FM<0x18>;
988 def DERET : ER_FT<"deret">, ER_FM<0x1f>;
990 def EI : DEI_FT<"ei", GPR32Opnd>, EI_FM<1>;
991 def DI : DEI_FT<"di", GPR32Opnd>, EI_FM<0>;
993 /// Load-linked, Store-conditional
994 let Predicates = [NotN64, HasStdEnc] in {
995 def LL : LLBase<"ll", GPR32Opnd, mem>, LW_FM<0x30>;
996 def SC : SCBase<"sc", GPR32Opnd, mem>, LW_FM<0x38>;
999 let Predicates = [IsN64, HasStdEnc], DecoderNamespace = "Mips64" in {
1000 def LL_P8 : LLBase<"ll", GPR32Opnd, mem64>, LW_FM<0x30>;
1001 def SC_P8 : SCBase<"sc", GPR32Opnd, mem64>, LW_FM<0x38>;
1004 /// Jump and Branch Instructions
1005 def J : JumpFJ<jmptarget, "j", br, bb>, FJ<2>,
1006 Requires<[RelocStatic, HasStdEnc]>, IsBranch;
1007 def JR : IndirectBranch<GPR32Opnd>, MTLO_FM<8>;
1008 def B : UncondBranch<"b">, B_FM;
1009 def BEQ : CBranch<"beq", seteq, GPR32Opnd>, BEQ_FM<4>;
1010 def BNE : CBranch<"bne", setne, GPR32Opnd>, BEQ_FM<5>;
1011 def BGEZ : CBranchZero<"bgez", setge, GPR32Opnd>, BGEZ_FM<1, 1>;
1012 def BGTZ : CBranchZero<"bgtz", setgt, GPR32Opnd>, BGEZ_FM<7, 0>;
1013 def BLEZ : CBranchZero<"blez", setle, GPR32Opnd>, BGEZ_FM<6, 0>;
1014 def BLTZ : CBranchZero<"bltz", setlt, GPR32Opnd>, BGEZ_FM<1, 0>;
1016 def JAL : JumpLink<"jal">, FJ<3>;
1017 def JALR : JumpLinkReg<"jalr", GPR32Opnd>, JALR_FM;
1018 def JALRPseudo : JumpLinkRegPseudo<GPR32Opnd, JALR, RA>;
1019 def BGEZAL : BGEZAL_FT<"bgezal", GPR32Opnd>, BGEZAL_FM<0x11>;
1020 def BLTZAL : BGEZAL_FT<"bltzal", GPR32Opnd>, BGEZAL_FM<0x10>;
1021 def BAL_BR : BAL_BR_Pseudo<BGEZAL>;
1022 def TAILCALL : JumpFJ<calltarget, "j", MipsTailCall, imm>, FJ<2>, IsTailCall;
1023 def TAILCALL_R : JumpFR<GPR32Opnd, MipsTailCall>, MTLO_FM<8>, IsTailCall;
1025 def RET : RetBase<GPR32Opnd>, MTLO_FM<8>;
1027 // Exception handling related node and instructions.
1028 // The conversion sequence is:
1029 // ISD::EH_RETURN -> MipsISD::EH_RETURN ->
1030 // MIPSeh_return -> (stack change + indirect branch)
1032 // MIPSeh_return takes the place of regular return instruction
1033 // but takes two arguments (V1, V0) which are used for storing
1034 // the offset and return address respectively.
1035 def SDT_MipsEHRET : SDTypeProfile<0, 2, [SDTCisInt<0>, SDTCisPtrTy<1>]>;
1037 def MIPSehret : SDNode<"MipsISD::EH_RETURN", SDT_MipsEHRET,
1038 [SDNPHasChain, SDNPOptInGlue, SDNPVariadic]>;
1040 let Uses = [V0, V1], isTerminator = 1, isReturn = 1, isBarrier = 1 in {
1041 def MIPSeh_return32 : MipsPseudo<(outs), (ins GPR32:$spoff, GPR32:$dst),
1042 [(MIPSehret GPR32:$spoff, GPR32:$dst)]>;
1043 def MIPSeh_return64 : MipsPseudo<(outs), (ins GPR64:$spoff,
1045 [(MIPSehret GPR64:$spoff, GPR64:$dst)]>;
1048 /// Multiply and Divide Instructions.
1049 def MULT : MMRel, Mult<"mult", IIImult, GPR32Opnd, [HI0, LO0]>,
1051 def MULTu : MMRel, Mult<"multu", IIImult, GPR32Opnd, [HI0, LO0]>,
1053 def PseudoMULT : MultDivPseudo<MULT, ACC64, GPR32Opnd, MipsMult, IIImult>;
1054 def PseudoMULTu : MultDivPseudo<MULTu, ACC64, GPR32Opnd, MipsMultu, IIImult>;
1055 def SDIV : Div<"div", IIIdiv, GPR32Opnd, [HI0, LO0]>, MULT_FM<0, 0x1a>;
1056 def UDIV : Div<"divu", IIIdiv, GPR32Opnd, [HI0, LO0]>, MULT_FM<0, 0x1b>;
1057 def PseudoSDIV : MultDivPseudo<SDIV, ACC64, GPR32Opnd, MipsDivRem, IIIdiv,
1059 def PseudoUDIV : MultDivPseudo<UDIV, ACC64, GPR32Opnd, MipsDivRemU, IIIdiv,
1062 def MTHI : MoveToLOHI<"mthi", GPR32Opnd, [HI0]>, MTLO_FM<0x11>;
1063 def MTLO : MoveToLOHI<"mtlo", GPR32Opnd, [LO0]>, MTLO_FM<0x13>;
1064 def MFHI : MoveFromLOHI<"mfhi", GPR32Opnd, [HI0]>, MFLO_FM<0x10>;
1065 def MFLO : MoveFromLOHI<"mflo", GPR32Opnd, [LO0]>, MFLO_FM<0x12>;
1067 /// Sign Ext In Register Instructions.
1068 def SEB : SignExtInReg<"seb", i8, GPR32Opnd>, SEB_FM<0x10, 0x20>;
1069 def SEH : SignExtInReg<"seh", i16, GPR32Opnd>, SEB_FM<0x18, 0x20>;
1072 def CLZ : CountLeading0<"clz", GPR32Opnd>, CLO_FM<0x20>;
1073 def CLO : CountLeading1<"clo", GPR32Opnd>, CLO_FM<0x21>;
1075 /// Word Swap Bytes Within Halfwords
1076 def WSBH : SubwordSwap<"wsbh", GPR32Opnd>, SEB_FM<2, 0x20>;
1079 def NOP : PseudoSE<(outs), (ins), []>, PseudoInstExpansion<(SLL ZERO, ZERO, 0)>;
1081 // FrameIndexes are legalized when they are operands from load/store
1082 // instructions. The same not happens for stack address copies, so an
1083 // add op with mem ComplexPattern is used and the stack address copy
1084 // can be matched. It's similar to Sparc LEA_ADDRi
1085 def LEA_ADDiu : EffectiveAddress<"addiu", GPR32Opnd, mem_ea>, LW_FM<9>;
1088 def MADD : MArithR<"madd", 1>, MULT_FM<0x1c, 0>;
1089 def MADDU : MArithR<"maddu", 1>, MULT_FM<0x1c, 1>;
1090 def MSUB : MArithR<"msub">, MULT_FM<0x1c, 4>;
1091 def MSUBU : MArithR<"msubu">, MULT_FM<0x1c, 5>;
1092 def PseudoMADD : MAddSubPseudo<MADD, MipsMAdd>;
1093 def PseudoMADDU : MAddSubPseudo<MADDU, MipsMAddu>;
1094 def PseudoMSUB : MAddSubPseudo<MSUB, MipsMSub>;
1095 def PseudoMSUBU : MAddSubPseudo<MSUBU, MipsMSubu>;
1097 def RDHWR : ReadHardware<GPR32Opnd, HWRegsOpnd>, RDHWR_FM;
1099 def EXT : ExtBase<"ext", GPR32Opnd>, EXT_FM<0>;
1100 def INS : InsBase<"ins", GPR32Opnd>, EXT_FM<4>;
1102 /// Move Control Registers From/To CPU Registers
1103 def MFC0_3OP : MFC3OP<(outs GPR32Opnd:$rt),
1104 (ins GPR32Opnd:$rd, uimm16:$sel),
1105 "mfc0\t$rt, $rd, $sel">, MFC3OP_FM<0x10, 0>;
1107 def MTC0_3OP : MFC3OP<(outs GPR32Opnd:$rd, uimm16:$sel),
1108 (ins GPR32Opnd:$rt),
1109 "mtc0\t$rt, $rd, $sel">, MFC3OP_FM<0x10, 4>;
1111 def MFC2_3OP : MFC3OP<(outs GPR32Opnd:$rt),
1112 (ins GPR32Opnd:$rd, uimm16:$sel),
1113 "mfc2\t$rt, $rd, $sel">, MFC3OP_FM<0x12, 0>;
1115 def MTC2_3OP : MFC3OP<(outs GPR32Opnd:$rd, uimm16:$sel),
1116 (ins GPR32Opnd:$rt),
1117 "mtc2\t$rt, $rd, $sel">, MFC3OP_FM<0x12, 4>;
1119 //===----------------------------------------------------------------------===//
1120 // Instruction aliases
1121 //===----------------------------------------------------------------------===//
1122 def : InstAlias<"move $dst, $src",
1123 (ADDu GPR32Opnd:$dst, GPR32Opnd:$src,ZERO), 1>,
1124 Requires<[NotMips64]>;
1125 def : InstAlias<"bal $offset", (BGEZAL ZERO, brtarget:$offset), 0>;
1126 def : InstAlias<"addu $rs, $rt, $imm",
1127 (ADDiu GPR32Opnd:$rs, GPR32Opnd:$rt, simm16:$imm), 0>;
1128 def : InstAlias<"add $rs, $rt, $imm",
1129 (ADDi GPR32Opnd:$rs, GPR32Opnd:$rt, simm16:$imm), 0>;
1130 def : InstAlias<"and $rs, $rt, $imm",
1131 (ANDi GPR32Opnd:$rs, GPR32Opnd:$rt, simm16:$imm), 0>;
1132 def : InstAlias<"j $rs", (JR GPR32Opnd:$rs), 0>;
1133 def : InstAlias<"jalr $rs", (JALR RA, GPR32Opnd:$rs), 0>;
1134 def : InstAlias<"jal $rs", (JALR RA, GPR32Opnd:$rs), 0>;
1135 def : InstAlias<"jal $rd,$rs", (JALR GPR32Opnd:$rd, GPR32Opnd:$rs), 0>;
1136 def : InstAlias<"not $rt, $rs",
1137 (NOR GPR32Opnd:$rt, GPR32Opnd:$rs, ZERO), 0>;
1138 def : InstAlias<"neg $rt, $rs",
1139 (SUB GPR32Opnd:$rt, ZERO, GPR32Opnd:$rs), 1>;
1140 def : InstAlias<"negu $rt, $rs",
1141 (SUBu GPR32Opnd:$rt, ZERO, GPR32Opnd:$rs), 1>;
1142 def : InstAlias<"slt $rs, $rt, $imm",
1143 (SLTi GPR32Opnd:$rs, GPR32Opnd:$rt, simm16:$imm), 0>;
1144 def : InstAlias<"xor $rs, $rt, $imm",
1145 (XORi GPR32Opnd:$rs, GPR32Opnd:$rt, uimm16:$imm), 0>;
1146 def : InstAlias<"or $rs, $rt, $imm",
1147 (ORi GPR32Opnd:$rs, GPR32Opnd:$rt, uimm16:$imm), 0>;
1148 def : InstAlias<"nop", (SLL ZERO, ZERO, 0), 1>;
1149 def : InstAlias<"mfc0 $rt, $rd",
1150 (MFC0_3OP GPR32Opnd:$rt, GPR32Opnd:$rd, 0), 0>;
1151 def : InstAlias<"mtc0 $rt, $rd",
1152 (MTC0_3OP GPR32Opnd:$rd, 0, GPR32Opnd:$rt), 0>;
1153 def : InstAlias<"mfc2 $rt, $rd",
1154 (MFC2_3OP GPR32Opnd:$rt, GPR32Opnd:$rd, 0), 0>;
1155 def : InstAlias<"mtc2 $rt, $rd",
1156 (MTC2_3OP GPR32Opnd:$rd, 0, GPR32Opnd:$rt), 0>;
1157 def : InstAlias<"bnez $rs,$offset",
1158 (BNE GPR32Opnd:$rs, ZERO, brtarget:$offset), 0>;
1159 def : InstAlias<"beqz $rs,$offset",
1160 (BEQ GPR32Opnd:$rs, ZERO, brtarget:$offset), 0>;
1161 def : InstAlias<"syscall", (SYSCALL 0), 1>;
1163 def : InstAlias<"break $imm", (BREAK uimm10:$imm, 0), 1>;
1164 def : InstAlias<"break", (BREAK 0, 0), 1>;
1165 def : InstAlias<"ei", (EI ZERO), 1>;
1166 def : InstAlias<"di", (DI ZERO), 1>;
1167 //===----------------------------------------------------------------------===//
1168 // Assembler Pseudo Instructions
1169 //===----------------------------------------------------------------------===//
1171 class LoadImm32< string instr_asm, Operand Od, RegisterOperand RO> :
1172 MipsAsmPseudoInst<(outs RO:$rt), (ins Od:$imm32),
1173 !strconcat(instr_asm, "\t$rt, $imm32")> ;
1174 def LoadImm32Reg : LoadImm32<"li", shamt,GPR32Opnd>;
1176 class LoadAddress<string instr_asm, Operand MemOpnd, RegisterOperand RO> :
1177 MipsAsmPseudoInst<(outs RO:$rt), (ins MemOpnd:$addr),
1178 !strconcat(instr_asm, "\t$rt, $addr")> ;
1179 def LoadAddr32Reg : LoadAddress<"la", mem, GPR32Opnd>;
1181 class LoadAddressImm<string instr_asm, Operand Od, RegisterOperand RO> :
1182 MipsAsmPseudoInst<(outs RO:$rt), (ins Od:$imm32),
1183 !strconcat(instr_asm, "\t$rt, $imm32")> ;
1184 def LoadAddr32Imm : LoadAddressImm<"la", shamt,GPR32Opnd>;
1188 //===----------------------------------------------------------------------===//
1189 // Arbitrary patterns that map to one or more instructions
1190 //===----------------------------------------------------------------------===//
1192 // Load/store pattern templates.
1193 class LoadRegImmPat<Instruction LoadInst, ValueType ValTy, PatFrag Node> :
1194 MipsPat<(ValTy (Node addrRegImm:$a)), (LoadInst addrRegImm:$a)>;
1196 class StoreRegImmPat<Instruction StoreInst, ValueType ValTy> :
1197 MipsPat<(store ValTy:$v, addrRegImm:$a), (StoreInst ValTy:$v, addrRegImm:$a)>;
1200 def : MipsPat<(i32 immSExt16:$in),
1201 (ADDiu ZERO, imm:$in)>;
1202 def : MipsPat<(i32 immZExt16:$in),
1203 (ORi ZERO, imm:$in)>;
1204 def : MipsPat<(i32 immLow16Zero:$in),
1205 (LUi (HI16 imm:$in))>;
1207 // Arbitrary immediates
1208 def : MipsPat<(i32 imm:$imm),
1209 (ORi (LUi (HI16 imm:$imm)), (LO16 imm:$imm))>;
1211 // Carry MipsPatterns
1212 def : MipsPat<(subc GPR32:$lhs, GPR32:$rhs),
1213 (SUBu GPR32:$lhs, GPR32:$rhs)>;
1214 let Predicates = [HasStdEnc, NotDSP] in {
1215 def : MipsPat<(addc GPR32:$lhs, GPR32:$rhs),
1216 (ADDu GPR32:$lhs, GPR32:$rhs)>;
1217 def : MipsPat<(addc GPR32:$src, immSExt16:$imm),
1218 (ADDiu GPR32:$src, imm:$imm)>;
1222 def : MipsPat<(MipsJmpLink (i32 tglobaladdr:$dst)),
1223 (JAL tglobaladdr:$dst)>;
1224 def : MipsPat<(MipsJmpLink (i32 texternalsym:$dst)),
1225 (JAL texternalsym:$dst)>;
1226 //def : MipsPat<(MipsJmpLink GPR32:$dst),
1227 // (JALR GPR32:$dst)>;
1230 def : MipsPat<(MipsTailCall (iPTR tglobaladdr:$dst)),
1231 (TAILCALL tglobaladdr:$dst)>;
1232 def : MipsPat<(MipsTailCall (iPTR texternalsym:$dst)),
1233 (TAILCALL texternalsym:$dst)>;
1235 def : MipsPat<(MipsHi tglobaladdr:$in), (LUi tglobaladdr:$in)>;
1236 def : MipsPat<(MipsHi tblockaddress:$in), (LUi tblockaddress:$in)>;
1237 def : MipsPat<(MipsHi tjumptable:$in), (LUi tjumptable:$in)>;
1238 def : MipsPat<(MipsHi tconstpool:$in), (LUi tconstpool:$in)>;
1239 def : MipsPat<(MipsHi tglobaltlsaddr:$in), (LUi tglobaltlsaddr:$in)>;
1240 def : MipsPat<(MipsHi texternalsym:$in), (LUi texternalsym:$in)>;
1242 def : MipsPat<(MipsLo tglobaladdr:$in), (ADDiu ZERO, tglobaladdr:$in)>;
1243 def : MipsPat<(MipsLo tblockaddress:$in), (ADDiu ZERO, tblockaddress:$in)>;
1244 def : MipsPat<(MipsLo tjumptable:$in), (ADDiu ZERO, tjumptable:$in)>;
1245 def : MipsPat<(MipsLo tconstpool:$in), (ADDiu ZERO, tconstpool:$in)>;
1246 def : MipsPat<(MipsLo tglobaltlsaddr:$in), (ADDiu ZERO, tglobaltlsaddr:$in)>;
1247 def : MipsPat<(MipsLo texternalsym:$in), (ADDiu ZERO, texternalsym:$in)>;
1249 def : MipsPat<(add GPR32:$hi, (MipsLo tglobaladdr:$lo)),
1250 (ADDiu GPR32:$hi, tglobaladdr:$lo)>;
1251 def : MipsPat<(add GPR32:$hi, (MipsLo tblockaddress:$lo)),
1252 (ADDiu GPR32:$hi, tblockaddress:$lo)>;
1253 def : MipsPat<(add GPR32:$hi, (MipsLo tjumptable:$lo)),
1254 (ADDiu GPR32:$hi, tjumptable:$lo)>;
1255 def : MipsPat<(add GPR32:$hi, (MipsLo tconstpool:$lo)),
1256 (ADDiu GPR32:$hi, tconstpool:$lo)>;
1257 def : MipsPat<(add GPR32:$hi, (MipsLo tglobaltlsaddr:$lo)),
1258 (ADDiu GPR32:$hi, tglobaltlsaddr:$lo)>;
1261 def : MipsPat<(add GPR32:$gp, (MipsGPRel tglobaladdr:$in)),
1262 (ADDiu GPR32:$gp, tglobaladdr:$in)>;
1263 def : MipsPat<(add GPR32:$gp, (MipsGPRel tconstpool:$in)),
1264 (ADDiu GPR32:$gp, tconstpool:$in)>;
1267 class WrapperPat<SDNode node, Instruction ADDiuOp, RegisterClass RC>:
1268 MipsPat<(MipsWrapper RC:$gp, node:$in),
1269 (ADDiuOp RC:$gp, node:$in)>;
1271 def : WrapperPat<tglobaladdr, ADDiu, GPR32>;
1272 def : WrapperPat<tconstpool, ADDiu, GPR32>;
1273 def : WrapperPat<texternalsym, ADDiu, GPR32>;
1274 def : WrapperPat<tblockaddress, ADDiu, GPR32>;
1275 def : WrapperPat<tjumptable, ADDiu, GPR32>;
1276 def : WrapperPat<tglobaltlsaddr, ADDiu, GPR32>;
1278 // Mips does not have "not", so we expand our way
1279 def : MipsPat<(not GPR32:$in),
1280 (NOR GPR32Opnd:$in, ZERO)>;
1283 let Predicates = [NotN64, HasStdEnc] in {
1284 def : MipsPat<(i32 (extloadi1 addr:$src)), (LBu addr:$src)>;
1285 def : MipsPat<(i32 (extloadi8 addr:$src)), (LBu addr:$src)>;
1286 def : MipsPat<(i32 (extloadi16 addr:$src)), (LHu addr:$src)>;
1288 let Predicates = [IsN64, HasStdEnc] in {
1289 def : MipsPat<(i32 (extloadi1 addr:$src)), (LBu_P8 addr:$src)>;
1290 def : MipsPat<(i32 (extloadi8 addr:$src)), (LBu_P8 addr:$src)>;
1291 def : MipsPat<(i32 (extloadi16 addr:$src)), (LHu_P8 addr:$src)>;
1295 let Predicates = [NotN64, HasStdEnc] in {
1296 def : MipsPat<(store (i32 0), addr:$dst), (SW ZERO, addr:$dst)>;
1298 let Predicates = [IsN64, HasStdEnc] in {
1299 def : MipsPat<(store (i32 0), addr:$dst), (SW_P8 ZERO, addr:$dst)>;
1303 multiclass BrcondPats<RegisterClass RC, Instruction BEQOp, Instruction BNEOp,
1304 Instruction SLTOp, Instruction SLTuOp, Instruction SLTiOp,
1305 Instruction SLTiuOp, Register ZEROReg> {
1306 def : MipsPat<(brcond (i32 (setne RC:$lhs, 0)), bb:$dst),
1307 (BNEOp RC:$lhs, ZEROReg, bb:$dst)>;
1308 def : MipsPat<(brcond (i32 (seteq RC:$lhs, 0)), bb:$dst),
1309 (BEQOp RC:$lhs, ZEROReg, bb:$dst)>;
1311 def : MipsPat<(brcond (i32 (setge RC:$lhs, RC:$rhs)), bb:$dst),
1312 (BEQ (SLTOp RC:$lhs, RC:$rhs), ZERO, bb:$dst)>;
1313 def : MipsPat<(brcond (i32 (setuge RC:$lhs, RC:$rhs)), bb:$dst),
1314 (BEQ (SLTuOp RC:$lhs, RC:$rhs), ZERO, bb:$dst)>;
1315 def : MipsPat<(brcond (i32 (setge RC:$lhs, immSExt16:$rhs)), bb:$dst),
1316 (BEQ (SLTiOp RC:$lhs, immSExt16:$rhs), ZERO, bb:$dst)>;
1317 def : MipsPat<(brcond (i32 (setuge RC:$lhs, immSExt16:$rhs)), bb:$dst),
1318 (BEQ (SLTiuOp RC:$lhs, immSExt16:$rhs), ZERO, bb:$dst)>;
1319 def : MipsPat<(brcond (i32 (setgt RC:$lhs, immSExt16Plus1:$rhs)), bb:$dst),
1320 (BEQ (SLTiOp RC:$lhs, (Plus1 imm:$rhs)), ZERO, bb:$dst)>;
1321 def : MipsPat<(brcond (i32 (setugt RC:$lhs, immSExt16Plus1:$rhs)), bb:$dst),
1322 (BEQ (SLTiuOp RC:$lhs, (Plus1 imm:$rhs)), ZERO, bb:$dst)>;
1324 def : MipsPat<(brcond (i32 (setle RC:$lhs, RC:$rhs)), bb:$dst),
1325 (BEQ (SLTOp RC:$rhs, RC:$lhs), ZERO, bb:$dst)>;
1326 def : MipsPat<(brcond (i32 (setule RC:$lhs, RC:$rhs)), bb:$dst),
1327 (BEQ (SLTuOp RC:$rhs, RC:$lhs), ZERO, bb:$dst)>;
1329 def : MipsPat<(brcond RC:$cond, bb:$dst),
1330 (BNEOp RC:$cond, ZEROReg, bb:$dst)>;
1333 defm : BrcondPats<GPR32, BEQ, BNE, SLT, SLTu, SLTi, SLTiu, ZERO>;
1335 def : MipsPat<(brcond (i32 (setlt i32:$lhs, 1)), bb:$dst),
1336 (BLEZ i32:$lhs, bb:$dst)>;
1337 def : MipsPat<(brcond (i32 (setgt i32:$lhs, -1)), bb:$dst),
1338 (BGEZ i32:$lhs, bb:$dst)>;
1341 multiclass SeteqPats<RegisterClass RC, Instruction SLTiuOp, Instruction XOROp,
1342 Instruction SLTuOp, Register ZEROReg> {
1343 def : MipsPat<(seteq RC:$lhs, 0),
1344 (SLTiuOp RC:$lhs, 1)>;
1345 def : MipsPat<(setne RC:$lhs, 0),
1346 (SLTuOp ZEROReg, RC:$lhs)>;
1347 def : MipsPat<(seteq RC:$lhs, RC:$rhs),
1348 (SLTiuOp (XOROp RC:$lhs, RC:$rhs), 1)>;
1349 def : MipsPat<(setne RC:$lhs, RC:$rhs),
1350 (SLTuOp ZEROReg, (XOROp RC:$lhs, RC:$rhs))>;
1353 multiclass SetlePats<RegisterClass RC, Instruction SLTOp, Instruction SLTuOp> {
1354 def : MipsPat<(setle RC:$lhs, RC:$rhs),
1355 (XORi (SLTOp RC:$rhs, RC:$lhs), 1)>;
1356 def : MipsPat<(setule RC:$lhs, RC:$rhs),
1357 (XORi (SLTuOp RC:$rhs, RC:$lhs), 1)>;
1360 multiclass SetgtPats<RegisterClass RC, Instruction SLTOp, Instruction SLTuOp> {
1361 def : MipsPat<(setgt RC:$lhs, RC:$rhs),
1362 (SLTOp RC:$rhs, RC:$lhs)>;
1363 def : MipsPat<(setugt RC:$lhs, RC:$rhs),
1364 (SLTuOp RC:$rhs, RC:$lhs)>;
1367 multiclass SetgePats<RegisterClass RC, Instruction SLTOp, Instruction SLTuOp> {
1368 def : MipsPat<(setge RC:$lhs, RC:$rhs),
1369 (XORi (SLTOp RC:$lhs, RC:$rhs), 1)>;
1370 def : MipsPat<(setuge RC:$lhs, RC:$rhs),
1371 (XORi (SLTuOp RC:$lhs, RC:$rhs), 1)>;
1374 multiclass SetgeImmPats<RegisterClass RC, Instruction SLTiOp,
1375 Instruction SLTiuOp> {
1376 def : MipsPat<(setge RC:$lhs, immSExt16:$rhs),
1377 (XORi (SLTiOp RC:$lhs, immSExt16:$rhs), 1)>;
1378 def : MipsPat<(setuge RC:$lhs, immSExt16:$rhs),
1379 (XORi (SLTiuOp RC:$lhs, immSExt16:$rhs), 1)>;
1382 defm : SeteqPats<GPR32, SLTiu, XOR, SLTu, ZERO>;
1383 defm : SetlePats<GPR32, SLT, SLTu>;
1384 defm : SetgtPats<GPR32, SLT, SLTu>;
1385 defm : SetgePats<GPR32, SLT, SLTu>;
1386 defm : SetgeImmPats<GPR32, SLTi, SLTiu>;
1389 def : MipsPat<(bswap GPR32:$rt), (ROTR (WSBH GPR32:$rt), 16)>;
1391 // mflo/hi patterns.
1392 def : MipsPat<(i32 (ExtractLOHI ACC64:$ac, imm:$lohi_idx)),
1393 (EXTRACT_SUBREG ACC64:$ac, imm:$lohi_idx)>;
1395 // Load halfword/word patterns.
1396 let AddedComplexity = 40 in {
1397 let Predicates = [NotN64, HasStdEnc] in {
1398 def : LoadRegImmPat<LBu, i32, zextloadi8>;
1399 def : LoadRegImmPat<LH, i32, sextloadi16>;
1400 def : LoadRegImmPat<LW, i32, load>;
1402 let Predicates = [IsN64, HasStdEnc] in {
1403 def : LoadRegImmPat<LBu_P8, i32, zextloadi8>;
1404 def : LoadRegImmPat<LH_P8, i32, sextloadi16>;
1405 def : LoadRegImmPat<LW_P8, i32, load>;
1409 //===----------------------------------------------------------------------===//
1410 // Floating Point Support
1411 //===----------------------------------------------------------------------===//
1413 include "MipsInstrFPU.td"
1414 include "Mips64InstrInfo.td"
1415 include "MipsCondMov.td"
1420 include "Mips16InstrFormats.td"
1421 include "Mips16InstrInfo.td"
1424 include "MipsDSPInstrFormats.td"
1425 include "MipsDSPInstrInfo.td"
1428 include "MipsMSAInstrFormats.td"
1429 include "MipsMSAInstrInfo.td"
1432 include "MicroMipsInstrFormats.td"
1433 include "MicroMipsInstrInfo.td"