comparison lib/Target/Mips/MipsInstrInfo.td @ 95:afa8332a0e37 LLVM3.8

LLVM 3.8
author Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
date Tue, 13 Oct 2015 17:48:58 +0900
parents 60c9769439b8
children 7d135dc70f03
comparison
equal deleted inserted replaced
84:f3e34b893a5f 95:afa8332a0e37
155 def HasMips3 : Predicate<"Subtarget->hasMips3()">, 155 def HasMips3 : Predicate<"Subtarget->hasMips3()">,
156 AssemblerPredicate<"FeatureMips3">; 156 AssemblerPredicate<"FeatureMips3">;
157 def HasMips4_32 : Predicate<"Subtarget->hasMips4_32()">, 157 def HasMips4_32 : Predicate<"Subtarget->hasMips4_32()">,
158 AssemblerPredicate<"FeatureMips4_32">; 158 AssemblerPredicate<"FeatureMips4_32">;
159 def NotMips4_32 : Predicate<"!Subtarget->hasMips4_32()">, 159 def NotMips4_32 : Predicate<"!Subtarget->hasMips4_32()">,
160 AssemblerPredicate<"FeatureMips4_32">; 160 AssemblerPredicate<"!FeatureMips4_32">;
161 def HasMips4_32r2 : Predicate<"Subtarget->hasMips4_32r2()">, 161 def HasMips4_32r2 : Predicate<"Subtarget->hasMips4_32r2()">,
162 AssemblerPredicate<"FeatureMips4_32r2">; 162 AssemblerPredicate<"FeatureMips4_32r2">;
163 def HasMips5_32r2 : Predicate<"Subtarget->hasMips5_32r2()">, 163 def HasMips5_32r2 : Predicate<"Subtarget->hasMips5_32r2()">,
164 AssemblerPredicate<"FeatureMips5_32r2">; 164 AssemblerPredicate<"FeatureMips5_32r2">;
165 def HasMips32 : Predicate<"Subtarget->hasMips32()">, 165 def HasMips32 : Predicate<"Subtarget->hasMips32()">,
166 AssemblerPredicate<"FeatureMips32">; 166 AssemblerPredicate<"FeatureMips32">;
167 def HasMips32r2 : Predicate<"Subtarget->hasMips32r2()">, 167 def HasMips32r2 : Predicate<"Subtarget->hasMips32r2()">,
168 AssemblerPredicate<"FeatureMips32r2">; 168 AssemblerPredicate<"FeatureMips32r2">;
169 def HasMips32r5 : Predicate<"Subtarget->hasMips32r5()">,
170 AssemblerPredicate<"FeatureMips32r5">;
169 def HasMips32r6 : Predicate<"Subtarget->hasMips32r6()">, 171 def HasMips32r6 : Predicate<"Subtarget->hasMips32r6()">,
170 AssemblerPredicate<"FeatureMips32r6">; 172 AssemblerPredicate<"FeatureMips32r6">;
171 def NotMips32r6 : Predicate<"!Subtarget->hasMips32r6()">, 173 def NotMips32r6 : Predicate<"!Subtarget->hasMips32r6()">,
172 AssemblerPredicate<"!FeatureMips32r6">; 174 AssemblerPredicate<"!FeatureMips32r6">;
173 def IsGP64bit : Predicate<"Subtarget->isGP64bit()">, 175 def IsGP64bit : Predicate<"Subtarget->isGP64bit()">,
180 AssemblerPredicate<"FeatureMips64r2">; 182 AssemblerPredicate<"FeatureMips64r2">;
181 def HasMips64r6 : Predicate<"Subtarget->hasMips64r6()">, 183 def HasMips64r6 : Predicate<"Subtarget->hasMips64r6()">,
182 AssemblerPredicate<"FeatureMips64r6">; 184 AssemblerPredicate<"FeatureMips64r6">;
183 def NotMips64r6 : Predicate<"!Subtarget->hasMips64r6()">, 185 def NotMips64r6 : Predicate<"!Subtarget->hasMips64r6()">,
184 AssemblerPredicate<"!FeatureMips64r6">; 186 AssemblerPredicate<"!FeatureMips64r6">;
187 def HasMicroMips32r6 : Predicate<"Subtarget->inMicroMips32r6Mode()">,
188 AssemblerPredicate<"FeatureMicroMips,FeatureMips32r6">;
189 def HasMicroMips64r6 : Predicate<"Subtarget->inMicroMips64r6Mode()">,
190 AssemblerPredicate<"FeatureMicroMips,FeatureMips64r6">;
185 def InMips16Mode : Predicate<"Subtarget->inMips16Mode()">, 191 def InMips16Mode : Predicate<"Subtarget->inMips16Mode()">,
186 AssemblerPredicate<"FeatureMips16">; 192 AssemblerPredicate<"FeatureMips16">;
187 def HasCnMips : Predicate<"Subtarget->hasCnMips()">, 193 def HasCnMips : Predicate<"Subtarget->hasCnMips()">,
188 AssemblerPredicate<"FeatureCnMips">; 194 AssemblerPredicate<"FeatureCnMips">;
189 def RelocStatic : Predicate<"TM.getRelocationModel() == Reloc::Static">, 195 def RelocStatic : Predicate<"TM.getRelocationModel() == Reloc::Static">;
190 AssemblerPredicate<"FeatureMips32">; 196 def RelocPIC : Predicate<"TM.getRelocationModel() == Reloc::PIC_">;
191 def RelocPIC : Predicate<"TM.getRelocationModel() == Reloc::PIC_">,
192 AssemblerPredicate<"FeatureMips32">;
193 def NoNaNsFPMath : Predicate<"TM.Options.NoNaNsFPMath">; 197 def NoNaNsFPMath : Predicate<"TM.Options.NoNaNsFPMath">;
194 def HasStdEnc : Predicate<"Subtarget->hasStandardEncoding()">, 198 def HasStdEnc : Predicate<"Subtarget->hasStandardEncoding()">,
195 AssemblerPredicate<"!FeatureMips16">; 199 AssemblerPredicate<"!FeatureMips16">;
196 def NotDSP : Predicate<"!Subtarget->hasDSP()">; 200 def NotDSP : Predicate<"!Subtarget->hasDSP()">;
197 def InMicroMips : Predicate<"Subtarget->inMicroMipsMode()">, 201 def InMicroMips : Predicate<"Subtarget->inMicroMipsMode()">,
199 def NotInMicroMips : Predicate<"!Subtarget->inMicroMipsMode()">, 203 def NotInMicroMips : Predicate<"!Subtarget->inMicroMipsMode()">,
200 AssemblerPredicate<"!FeatureMicroMips">; 204 AssemblerPredicate<"!FeatureMicroMips">;
201 def IsLE : Predicate<"Subtarget->isLittle()">; 205 def IsLE : Predicate<"Subtarget->isLittle()">;
202 def IsBE : Predicate<"!Subtarget->isLittle()">; 206 def IsBE : Predicate<"!Subtarget->isLittle()">;
203 def IsNotNaCl : Predicate<"!Subtarget->isTargetNaCl()">; 207 def IsNotNaCl : Predicate<"!Subtarget->isTargetNaCl()">;
208 def UseTCCInDIV : AssemblerPredicate<"FeatureUseTCCInDIV">;
209 def HasEVA : Predicate<"Subtarget->hasEVA()">,
210 AssemblerPredicate<"FeatureEVA,FeatureMips32r2">;
211 def HasMSA : Predicate<"Subtarget->hasMSA()">,
212 AssemblerPredicate<"FeatureMSA">;
213
204 214
205 //===----------------------------------------------------------------------===// 215 //===----------------------------------------------------------------------===//
206 // Mips GPR size adjectives. 216 // Mips GPR size adjectives.
207 // They are mutually exclusive. 217 // They are mutually exclusive.
208 //===----------------------------------------------------------------------===// 218 //===----------------------------------------------------------------------===//
240 } 250 }
241 class ISA_MIPS32R2 { list<Predicate> InsnPredicates = [HasMips32r2]; } 251 class ISA_MIPS32R2 { list<Predicate> InsnPredicates = [HasMips32r2]; }
242 class ISA_MIPS32R2_NOT_32R6_64R6 { 252 class ISA_MIPS32R2_NOT_32R6_64R6 {
243 list<Predicate> InsnPredicates = [HasMips32r2, NotMips32r6, NotMips64r6]; 253 list<Predicate> InsnPredicates = [HasMips32r2, NotMips32r6, NotMips64r6];
244 } 254 }
255 class ISA_MIPS32R5 { list<Predicate> InsnPredicates = [HasMips32r5]; }
245 class ISA_MIPS64 { list<Predicate> InsnPredicates = [HasMips64]; } 256 class ISA_MIPS64 { list<Predicate> InsnPredicates = [HasMips64]; }
246 class ISA_MIPS64_NOT_64R6 { 257 class ISA_MIPS64_NOT_64R6 {
247 list<Predicate> InsnPredicates = [HasMips64, NotMips64r6]; 258 list<Predicate> InsnPredicates = [HasMips64, NotMips64r6];
248 } 259 }
249 class ISA_MIPS64R2 { list<Predicate> InsnPredicates = [HasMips64r2]; } 260 class ISA_MIPS64R2 { list<Predicate> InsnPredicates = [HasMips64r2]; }
250 class ISA_MIPS32R6 { list<Predicate> InsnPredicates = [HasMips32r6]; } 261 class ISA_MIPS32R6 { list<Predicate> InsnPredicates = [HasMips32r6]; }
251 class ISA_MIPS64R6 { list<Predicate> InsnPredicates = [HasMips64r6]; } 262 class ISA_MIPS64R6 { list<Predicate> InsnPredicates = [HasMips64r6]; }
263 class ISA_MICROMIPS { list<Predicate> InsnPredicates = [InMicroMips]; }
264 class ISA_MICROMIPS32R6 {
265 list<Predicate> InsnPredicates = [HasMicroMips32r6];
266 }
267 class ISA_MICROMIPS64R6 {
268 list<Predicate> InsnPredicates = [HasMicroMips64r6];
269 }
270 class ISA_MICROMIPS32_NOT_MIPS32R6 {
271 list<Predicate> InsnPredicates = [InMicroMips, NotMips32r6];
272 }
273
274 class INSN_EVA { list<Predicate> InsnPredicates = [HasEVA]; }
275 class INSN_EVA_NOT_32R6_64R6 {
276 list<Predicate> InsnPredicates = [NotMips32r6, NotMips64r6, HasEVA];
277 }
252 278
253 // The portions of MIPS-III that were also added to MIPS32 279 // The portions of MIPS-III that were also added to MIPS32
254 class INSN_MIPS3_32 { list<Predicate> InsnPredicates = [HasMips3_32]; } 280 class INSN_MIPS3_32 { list<Predicate> InsnPredicates = [HasMips3_32]; }
255 281
256 // The portions of MIPS-III that were also added to MIPS32 but were removed in 282 // The portions of MIPS-III that were also added to MIPS32 but were removed in
276 302
277 // The portions of MIPS-V that were also added to MIPS32r2 but were removed in 303 // The portions of MIPS-V that were also added to MIPS32r2 but were removed in
278 // MIPS32r6 and MIPS64r6. 304 // MIPS32r6 and MIPS64r6.
279 class INSN_MIPS5_32R2_NOT_32R6_64R6 { 305 class INSN_MIPS5_32R2_NOT_32R6_64R6 {
280 list<Predicate> InsnPredicates = [HasMips5_32r2, NotMips32r6, NotMips64r6]; 306 list<Predicate> InsnPredicates = [HasMips5_32r2, NotMips32r6, NotMips64r6];
307 }
308
309 class ASE_MSA {
310 list<Predicate> InsnPredicates = [HasMSA];
311 }
312
313 class ASE_MSA64 {
314 list<Predicate> InsnPredicates = [HasMSA, HasMips64];
315 }
316
317 // Class used for separating microMIPSr6 and microMIPS (r3) instruction.
318 // It can be used only on instructions that doesn't inherit PredicateControl.
319 class ISA_MICROMIPS_NOT_32R6_64R6 : PredicateControl {
320 let InsnPredicates = [InMicroMips, NotMips32r6, NotMips64r6];
281 } 321 }
282 322
283 //===----------------------------------------------------------------------===// 323 //===----------------------------------------------------------------------===//
284 324
285 class MipsPat<dag pattern, dag result> : Pat<pattern, result>, PredicateControl { 325 class MipsPat<dag pattern, dag result> : Pat<pattern, result>, PredicateControl {
353 def calltarget : Operand<iPTR> { 393 def calltarget : Operand<iPTR> {
354 let EncoderMethod = "getJumpTargetOpValue"; 394 let EncoderMethod = "getJumpTargetOpValue";
355 let ParserMatchClass = MipsJumpTargetAsmOperand; 395 let ParserMatchClass = MipsJumpTargetAsmOperand;
356 } 396 }
357 397
398 def imm64: Operand<i64>;
399
358 def simm9 : Operand<i32>; 400 def simm9 : Operand<i32>;
359 def simm10 : Operand<i32>; 401 def simm10 : Operand<i32>;
360 def simm11 : Operand<i32>; 402 def simm11 : Operand<i32>;
361 403
362 def simm16 : Operand<i32> { 404 def simm16 : Operand<i32> {
379 } 421 }
380 422
381 def uimm20 : Operand<i32> { 423 def uimm20 : Operand<i32> {
382 } 424 }
383 425
426 def MipsUImm10AsmOperand : AsmOperandClass {
427 let Name = "UImm10";
428 let RenderMethod = "addImmOperands";
429 let ParserMethod = "parseImm";
430 let PredicateMethod = "isUImm<10>";
431 }
432
384 def uimm10 : Operand<i32> { 433 def uimm10 : Operand<i32> {
434 let ParserMatchClass = MipsUImm10AsmOperand;
385 } 435 }
386 436
387 def simm16_64 : Operand<i64> { 437 def simm16_64 : Operand<i64> {
388 let DecoderMethod = "DecodeSimm16"; 438 let DecoderMethod = "DecodeSimm16";
389 } 439 }
418 } 468 }
419 469
420 def MipsMemAsmOperand : AsmOperandClass { 470 def MipsMemAsmOperand : AsmOperandClass {
421 let Name = "Mem"; 471 let Name = "Mem";
422 let ParserMethod = "parseMemOperand"; 472 let ParserMethod = "parseMemOperand";
473 }
474
475 def MipsMemSimm9AsmOperand : AsmOperandClass {
476 let Name = "MemOffsetSimm9";
477 let SuperClasses = [MipsMemAsmOperand];
478 let RenderMethod = "addMemOperands";
479 let ParserMethod = "parseMemOperand";
480 let PredicateMethod = "isMemWithSimmOffset<9>";
481 }
482
483 def MipsMemSimm9GPRAsmOperand : AsmOperandClass {
484 let Name = "MemOffsetSimm9GPR";
485 let SuperClasses = [MipsMemAsmOperand];
486 let RenderMethod = "addMemOperands";
487 let ParserMethod = "parseMemOperand";
488 let PredicateMethod = "isMemWithSimmOffsetGPR<9>";
423 } 489 }
424 490
425 def MipsMemSimm11AsmOperand : AsmOperandClass { 491 def MipsMemSimm11AsmOperand : AsmOperandClass {
426 let Name = "MemOffsetSimm11"; 492 let Name = "MemOffsetSimm11";
427 let SuperClasses = [MipsMemAsmOperand]; 493 let SuperClasses = [MipsMemAsmOperand];
470 } 536 }
471 537
472 def mem_simm9 : mem_generic { 538 def mem_simm9 : mem_generic {
473 let MIOperandInfo = (ops ptr_rc, simm9); 539 let MIOperandInfo = (ops ptr_rc, simm9);
474 let EncoderMethod = "getMemEncoding"; 540 let EncoderMethod = "getMemEncoding";
541 let ParserMatchClass = MipsMemSimm9AsmOperand;
542 }
543
544 def mem_simm9gpr : mem_generic {
545 let MIOperandInfo = (ops ptr_rc, simm9);
546 let EncoderMethod = "getMemEncoding";
547 let ParserMatchClass = MipsMemSimm9GPRAsmOperand;
475 } 548 }
476 549
477 def mem_simm11 : mem_generic { 550 def mem_simm11 : mem_generic {
478 let MIOperandInfo = (ops ptr_rc, simm11); 551 let MIOperandInfo = (ops ptr_rc, simm11);
479 let EncoderMethod = "getMemEncoding"; 552 let EncoderMethod = "getMemEncoding";
642 InstSE<(outs RO:$rd), (ins RO:$rt, GPR32Opnd:$rs), 715 InstSE<(outs RO:$rd), (ins RO:$rt, GPR32Opnd:$rs),
643 !strconcat(opstr, "\t$rd, $rt, $rs"), 716 !strconcat(opstr, "\t$rd, $rt, $rs"),
644 [(set RO:$rd, (OpNode RO:$rt, GPR32Opnd:$rs))], itin, FrmR, 717 [(set RO:$rd, (OpNode RO:$rt, GPR32Opnd:$rs))], itin, FrmR,
645 opstr>; 718 opstr>;
646 719
647 // Load Upper Imediate 720 // Load Upper Immediate
648 class LoadUpper<string opstr, RegisterOperand RO, Operand Imm>: 721 class LoadUpper<string opstr, RegisterOperand RO, Operand Imm>:
649 InstSE<(outs RO:$rt), (ins Imm:$imm16), !strconcat(opstr, "\t$rt, $imm16"), 722 InstSE<(outs RO:$rt), (ins Imm:$imm16), !strconcat(opstr, "\t$rt, $imm16"),
650 [], II_LUI, FrmI, opstr>, IsAsCheapAsAMove { 723 [], II_LUI, FrmI, opstr>, IsAsCheapAsAMove {
651 let hasSideEffects = 0; 724 let hasSideEffects = 0;
652 let isReMaterializable = 1; 725 let isReMaterializable = 1;
660 let DecoderMethod = "DecodeMem"; 733 let DecoderMethod = "DecodeMem";
661 let canFoldAsLoad = 1; 734 let canFoldAsLoad = 1;
662 let mayLoad = 1; 735 let mayLoad = 1;
663 } 736 }
664 737
665 class Store<string opstr, DAGOperand RO, SDPatternOperator OpNode = null_frag, 738 class StoreMemory<string opstr, DAGOperand RO, DAGOperand MO,
739 SDPatternOperator OpNode = null_frag,
666 InstrItinClass Itin = NoItinerary, ComplexPattern Addr = addr> : 740 InstrItinClass Itin = NoItinerary, ComplexPattern Addr = addr> :
667 InstSE<(outs), (ins RO:$rt, mem:$addr), !strconcat(opstr, "\t$rt, $addr"), 741 InstSE<(outs), (ins RO:$rt, MO:$addr), !strconcat(opstr, "\t$rt, $addr"),
668 [(OpNode RO:$rt, Addr:$addr)], Itin, FrmI, opstr> { 742 [(OpNode RO:$rt, Addr:$addr)], Itin, FrmI, opstr> {
669 let DecoderMethod = "DecodeMem"; 743 let DecoderMethod = "DecodeMem";
670 let mayStore = 1; 744 let mayStore = 1;
671 } 745 }
746
747 class Store<string opstr, DAGOperand RO, SDPatternOperator OpNode = null_frag,
748 InstrItinClass Itin = NoItinerary, ComplexPattern Addr = addr> :
749 StoreMemory<opstr, RO, mem, OpNode, Itin, Addr>;
672 750
673 // Load/Store Left/Right 751 // Load/Store Left/Right
674 let canFoldAsLoad = 1 in 752 let canFoldAsLoad = 1 in
675 class LoadLeftRight<string opstr, SDNode OpNode, RegisterOperand RO, 753 class LoadLeftRight<string opstr, SDNode OpNode, RegisterOperand RO,
676 InstrItinClass Itin> : 754 InstrItinClass Itin> :
725 // Conditional Branch 803 // Conditional Branch
726 class CBranch<string opstr, DAGOperand opnd, PatFrag cond_op, 804 class CBranch<string opstr, DAGOperand opnd, PatFrag cond_op,
727 RegisterOperand RO, bit DelaySlot = 1> : 805 RegisterOperand RO, bit DelaySlot = 1> :
728 InstSE<(outs), (ins RO:$rs, RO:$rt, opnd:$offset), 806 InstSE<(outs), (ins RO:$rs, RO:$rt, opnd:$offset),
729 !strconcat(opstr, "\t$rs, $rt, $offset"), 807 !strconcat(opstr, "\t$rs, $rt, $offset"),
730 [(brcond (i32 (cond_op RO:$rs, RO:$rt)), bb:$offset)], IIBranch, 808 [(brcond (i32 (cond_op RO:$rs, RO:$rt)), bb:$offset)], II_BCC,
731 FrmI, opstr> { 809 FrmI, opstr> {
732 let isBranch = 1; 810 let isBranch = 1;
733 let isTerminator = 1; 811 let isTerminator = 1;
734 let hasDelaySlot = DelaySlot; 812 let hasDelaySlot = DelaySlot;
735 let Defs = [AT]; 813 let Defs = [AT];
737 815
738 class CBranchZero<string opstr, DAGOperand opnd, PatFrag cond_op, 816 class CBranchZero<string opstr, DAGOperand opnd, PatFrag cond_op,
739 RegisterOperand RO, bit DelaySlot = 1> : 817 RegisterOperand RO, bit DelaySlot = 1> :
740 InstSE<(outs), (ins RO:$rs, opnd:$offset), 818 InstSE<(outs), (ins RO:$rs, opnd:$offset),
741 !strconcat(opstr, "\t$rs, $offset"), 819 !strconcat(opstr, "\t$rs, $offset"),
742 [(brcond (i32 (cond_op RO:$rs, 0)), bb:$offset)], IIBranch, 820 [(brcond (i32 (cond_op RO:$rs, 0)), bb:$offset)], II_BCCZ,
743 FrmI, opstr> { 821 FrmI, opstr> {
744 let isBranch = 1; 822 let isBranch = 1;
745 let isTerminator = 1; 823 let isTerminator = 1;
746 let hasDelaySlot = DelaySlot; 824 let hasDelaySlot = DelaySlot;
747 let Defs = [AT]; 825 let Defs = [AT];
763 841
764 // Jump 842 // Jump
765 class JumpFJ<DAGOperand opnd, string opstr, SDPatternOperator operator, 843 class JumpFJ<DAGOperand opnd, string opstr, SDPatternOperator operator,
766 SDPatternOperator targetoperator, string bopstr> : 844 SDPatternOperator targetoperator, string bopstr> :
767 InstSE<(outs), (ins opnd:$target), !strconcat(opstr, "\t$target"), 845 InstSE<(outs), (ins opnd:$target), !strconcat(opstr, "\t$target"),
768 [(operator targetoperator:$target)], IIBranch, FrmJ, bopstr> { 846 [(operator targetoperator:$target)], II_J, FrmJ, bopstr> {
769 let isTerminator=1; 847 let isTerminator=1;
770 let isBarrier=1; 848 let isBarrier=1;
771 let hasDelaySlot = 1; 849 let hasDelaySlot = 1;
772 let DecoderMethod = "DecodeJumpTarget"; 850 let DecoderMethod = "DecodeJumpTarget";
773 let Defs = [AT]; 851 let Defs = [AT];
774 } 852 }
775 853
776 // Unconditional branch 854 // Unconditional branch
777 class UncondBranch<Instruction BEQInst> : 855 class UncondBranch<Instruction BEQInst> :
778 PseudoSE<(outs), (ins brtarget:$offset), [(br bb:$offset)], IIBranch>, 856 PseudoSE<(outs), (ins brtarget:$offset), [(br bb:$offset)], II_B>,
779 PseudoInstExpansion<(BEQInst ZERO, ZERO, brtarget:$offset)> { 857 PseudoInstExpansion<(BEQInst ZERO, ZERO, brtarget:$offset)> {
780 let isBranch = 1; 858 let isBranch = 1;
781 let isTerminator = 1; 859 let isTerminator = 1;
782 let isBarrier = 1; 860 let isBarrier = 1;
783 let hasDelaySlot = 1; 861 let hasDelaySlot = 1;
787 865
788 // Base class for indirect branch and return instruction classes. 866 // Base class for indirect branch and return instruction classes.
789 let isTerminator=1, isBarrier=1, hasDelaySlot = 1 in 867 let isTerminator=1, isBarrier=1, hasDelaySlot = 1 in
790 class JumpFR<string opstr, RegisterOperand RO, 868 class JumpFR<string opstr, RegisterOperand RO,
791 SDPatternOperator operator = null_frag>: 869 SDPatternOperator operator = null_frag>:
792 InstSE<(outs), (ins RO:$rs), "jr\t$rs", [(operator RO:$rs)], IIBranch, 870 InstSE<(outs), (ins RO:$rs), "jr\t$rs", [(operator RO:$rs)], II_JR,
793 FrmR, opstr>; 871 FrmR, opstr>;
794 872
795 // Indirect branch 873 // Indirect branch
796 class IndirectBranch<string opstr, RegisterOperand RO> : JumpFR<opstr, RO> { 874 class IndirectBranch<string opstr, RegisterOperand RO> : JumpFR<opstr, RO> {
797 let isBranch = 1; 875 let isBranch = 1;
800 878
801 // Jump and Link (Call) 879 // Jump and Link (Call)
802 let isCall=1, hasDelaySlot=1, Defs = [RA] in { 880 let isCall=1, hasDelaySlot=1, Defs = [RA] in {
803 class JumpLink<string opstr, DAGOperand opnd> : 881 class JumpLink<string opstr, DAGOperand opnd> :
804 InstSE<(outs), (ins opnd:$target), !strconcat(opstr, "\t$target"), 882 InstSE<(outs), (ins opnd:$target), !strconcat(opstr, "\t$target"),
805 [(MipsJmpLink imm:$target)], IIBranch, FrmJ, opstr> { 883 [(MipsJmpLink imm:$target)], II_JAL, FrmJ, opstr> {
806 let DecoderMethod = "DecodeJumpTarget"; 884 let DecoderMethod = "DecodeJumpTarget";
807 } 885 }
808 886
809 class JumpLinkRegPseudo<RegisterOperand RO, Instruction JALRInst, 887 class JumpLinkRegPseudo<RegisterOperand RO, Instruction JALRInst,
810 Register RetReg, RegisterOperand ResRO = RO>: 888 Register RetReg, RegisterOperand ResRO = RO>:
811 PseudoSE<(outs), (ins RO:$rs), [(MipsJmpLink RO:$rs)], IIBranch>, 889 PseudoSE<(outs), (ins RO:$rs), [(MipsJmpLink RO:$rs)], II_JALR>,
812 PseudoInstExpansion<(JALRInst RetReg, ResRO:$rs)>; 890 PseudoInstExpansion<(JALRInst RetReg, ResRO:$rs)>;
813 891
814 class JumpLinkReg<string opstr, RegisterOperand RO>: 892 class JumpLinkReg<string opstr, RegisterOperand RO>:
815 InstSE<(outs RO:$rd), (ins RO:$rs), !strconcat(opstr, "\t$rd, $rs"), 893 InstSE<(outs RO:$rd), (ins RO:$rs), !strconcat(opstr, "\t$rd, $rs"),
816 [], IIBranch, FrmR>; 894 [], II_JALR, FrmR, opstr>;
817 895
818 class BGEZAL_FT<string opstr, DAGOperand opnd, 896 class BGEZAL_FT<string opstr, DAGOperand opnd,
819 RegisterOperand RO, bit DelaySlot = 1> : 897 RegisterOperand RO, bit DelaySlot = 1> :
820 InstSE<(outs), (ins RO:$rs, opnd:$offset), 898 InstSE<(outs), (ins RO:$rs, opnd:$offset),
821 !strconcat(opstr, "\t$rs, $offset"), [], IIBranch, FrmI, opstr> { 899 !strconcat(opstr, "\t$rs, $offset"), [], II_BCCZAL, FrmI, opstr> {
822 let hasDelaySlot = DelaySlot; 900 let hasDelaySlot = DelaySlot;
823 } 901 }
824 902
825 } 903 }
826 904
827 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, hasDelaySlot = 1, 905 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, hasDelaySlot = 1,
828 hasExtraSrcRegAllocReq = 1, Defs = [AT] in { 906 hasExtraSrcRegAllocReq = 1, Defs = [AT] in {
829 class TailCall<Instruction JumpInst> : 907 class TailCall<Instruction JumpInst> :
830 PseudoSE<(outs), (ins calltarget:$target), [], IIBranch>, 908 PseudoSE<(outs), (ins calltarget:$target), [], II_J>,
831 PseudoInstExpansion<(JumpInst jmptarget:$target)>; 909 PseudoInstExpansion<(JumpInst jmptarget:$target)>;
832 910
833 class TailCallReg<RegisterOperand RO, Instruction JRInst, 911 class TailCallReg<RegisterOperand RO, Instruction JRInst,
834 RegisterOperand ResRO = RO> : 912 RegisterOperand ResRO = RO> :
835 PseudoSE<(outs), (ins RO:$rs), [(MipsTailCall RO:$rs)], IIBranch>, 913 PseudoSE<(outs), (ins RO:$rs), [(MipsTailCall RO:$rs)], II_JR>,
836 PseudoInstExpansion<(JRInst ResRO:$rs)>; 914 PseudoInstExpansion<(JRInst ResRO:$rs)>;
837 } 915 }
838 916
839 class BAL_BR_Pseudo<Instruction RealInst> : 917 class BAL_BR_Pseudo<Instruction RealInst> :
840 PseudoSE<(outs), (ins brtarget:$offset), [], IIBranch>, 918 PseudoSE<(outs), (ins brtarget:$offset), [], II_BCCZAL>,
841 PseudoInstExpansion<(RealInst ZERO, brtarget:$offset)> { 919 PseudoInstExpansion<(RealInst ZERO, brtarget:$offset)> {
842 let isBranch = 1; 920 let isBranch = 1;
843 let isTerminator = 1; 921 let isTerminator = 1;
844 let isBarrier = 1; 922 let isBarrier = 1;
845 let hasDelaySlot = 1; 923 let hasDelaySlot = 1;
982 InstrItinClass itin> : 1060 InstrItinClass itin> :
983 InstSE<(outs RO:$rd), (ins RO:$rt), !strconcat(opstr, "\t$rd, $rt"), 1061 InstSE<(outs RO:$rd), (ins RO:$rt), !strconcat(opstr, "\t$rd, $rt"),
984 [(set RO:$rd, (sext_inreg RO:$rt, vt))], itin, FrmR, opstr>; 1062 [(set RO:$rd, (sext_inreg RO:$rt, vt))], itin, FrmR, opstr>;
985 1063
986 // Subword Swap 1064 // Subword Swap
987 class SubwordSwap<string opstr, RegisterOperand RO>: 1065 class SubwordSwap<string opstr, RegisterOperand RO,
988 InstSE<(outs RO:$rd), (ins RO:$rt), !strconcat(opstr, "\t$rd, $rt"), [], 1066 InstrItinClass itin = NoItinerary>:
989 NoItinerary, FrmR, opstr> { 1067 InstSE<(outs RO:$rd), (ins RO:$rt), !strconcat(opstr, "\t$rd, $rt"), [], itin,
1068 FrmR, opstr> {
990 let hasSideEffects = 0; 1069 let hasSideEffects = 0;
991 } 1070 }
992 1071
993 // Read Hardware 1072 // Read Hardware
994 class ReadHardware<RegisterOperand CPURegOperand, RegisterOperand RO> : 1073 class ReadHardware<RegisterOperand CPURegOperand, RegisterOperand RO> :
998 // Ext and Ins 1077 // Ext and Ins
999 class ExtBase<string opstr, RegisterOperand RO, Operand PosOpnd, 1078 class ExtBase<string opstr, RegisterOperand RO, Operand PosOpnd,
1000 SDPatternOperator Op = null_frag>: 1079 SDPatternOperator Op = null_frag>:
1001 InstSE<(outs RO:$rt), (ins RO:$rs, PosOpnd:$pos, size_ext:$size), 1080 InstSE<(outs RO:$rt), (ins RO:$rs, PosOpnd:$pos, size_ext:$size),
1002 !strconcat(opstr, " $rt, $rs, $pos, $size"), 1081 !strconcat(opstr, " $rt, $rs, $pos, $size"),
1003 [(set RO:$rt, (Op RO:$rs, imm:$pos, imm:$size))], NoItinerary, 1082 [(set RO:$rt, (Op RO:$rs, imm:$pos, imm:$size))], II_EXT,
1004 FrmR, opstr>, ISA_MIPS32R2; 1083 FrmR, opstr>, ISA_MIPS32R2;
1005 1084
1006 class InsBase<string opstr, RegisterOperand RO, Operand PosOpnd, 1085 class InsBase<string opstr, RegisterOperand RO, Operand PosOpnd,
1007 SDPatternOperator Op = null_frag>: 1086 SDPatternOperator Op = null_frag>:
1008 InstSE<(outs RO:$rt), (ins RO:$rs, PosOpnd:$pos, size_ins:$size, RO:$src), 1087 InstSE<(outs RO:$rt), (ins RO:$rs, PosOpnd:$pos, size_ins:$size, RO:$src),
1009 !strconcat(opstr, " $rt, $rs, $pos, $size"), 1088 !strconcat(opstr, " $rt, $rs, $pos, $size"),
1010 [(set RO:$rt, (Op RO:$rs, imm:$pos, imm:$size, RO:$src))], 1089 [(set RO:$rt, (Op RO:$rs, imm:$pos, imm:$size, RO:$src))],
1011 NoItinerary, FrmR, opstr>, ISA_MIPS32R2 { 1090 II_INS, FrmR, opstr>, ISA_MIPS32R2 {
1012 let Constraints = "$src = $rt"; 1091 let Constraints = "$src = $rt";
1013 } 1092 }
1014 1093
1015 // Atomic instructions with 2 source operands (ATOMIC_SWAP & ATOMIC_LOAD_*). 1094 // Atomic instructions with 2 source operands (ATOMIC_SWAP & ATOMIC_LOAD_*).
1016 class Atomic2Ops<PatFrag Op, RegisterClass DRC> : 1095 class Atomic2Ops<PatFrag Op, RegisterClass DRC> :
1035 let DecoderMethod = "DecodeMem"; 1114 let DecoderMethod = "DecodeMem";
1036 let mayStore = 1; 1115 let mayStore = 1;
1037 let Constraints = "$rt = $dst"; 1116 let Constraints = "$rt = $dst";
1038 } 1117 }
1039 1118
1040 class MFC3OP<string asmstr, RegisterOperand RO> : 1119 class MFC3OP<string asmstr, RegisterOperand RO, RegisterOperand RD> :
1041 InstSE<(outs RO:$rt, RO:$rd, uimm16:$sel), (ins), 1120 InstSE<(outs RO:$rt), (ins RD:$rd, uimm16:$sel),
1121 !strconcat(asmstr, "\t$rt, $rd, $sel"), [], NoItinerary, FrmFR>;
1122
1123 class MTC3OP<string asmstr, RegisterOperand RO, RegisterOperand RD> :
1124 InstSE<(outs RO:$rd), (ins RD:$rt, uimm16:$sel),
1042 !strconcat(asmstr, "\t$rt, $rd, $sel"), [], NoItinerary, FrmFR>; 1125 !strconcat(asmstr, "\t$rt, $rd, $sel"), [], NoItinerary, FrmFR>;
1043 1126
1044 class TrapBase<Instruction RealInst> 1127 class TrapBase<Instruction RealInst>
1045 : PseudoSE<(outs), (ins), [(trap)], NoItinerary>, 1128 : PseudoSE<(outs), (ins), [(trap)], NoItinerary>,
1046 PseudoInstExpansion<(RealInst 0, 0)> { 1129 PseudoInstExpansion<(RealInst 0, 0)> {
1118 // MipsI Instructions 1201 // MipsI Instructions
1119 //===----------------------------------------------------------------------===// 1202 //===----------------------------------------------------------------------===//
1120 1203
1121 /// Arithmetic Instructions (ALU Immediate) 1204 /// Arithmetic Instructions (ALU Immediate)
1122 let AdditionalPredicates = [NotInMicroMips] in { 1205 let AdditionalPredicates = [NotInMicroMips] in {
1123 def ADDiu : MMRel, ArithLogicI<"addiu", simm16, GPR32Opnd, II_ADDIU, immSExt16, 1206 def ADDiu : MMRel, StdMMR6Rel, ArithLogicI<"addiu", simm16, GPR32Opnd,
1124 add>, ADDI_FM<0x9>, IsAsCheapAsAMove; 1207 II_ADDIU, immSExt16, add>,
1208 ADDI_FM<0x9>, IsAsCheapAsAMove;
1125 } 1209 }
1126 def ADDi : MMRel, ArithLogicI<"addi", simm16, GPR32Opnd>, ADDI_FM<0x8>, 1210 def ADDi : MMRel, ArithLogicI<"addi", simm16, GPR32Opnd>, ADDI_FM<0x8>,
1127 ISA_MIPS1_NOT_32R6_64R6; 1211 ISA_MIPS1_NOT_32R6_64R6;
1128 def SLTi : MMRel, SetCC_I<"slti", setlt, simm16, immSExt16, GPR32Opnd>, 1212 def SLTi : MMRel, SetCC_I<"slti", setlt, simm16, immSExt16, GPR32Opnd>,
1129 SLTI_FM<0xa>; 1213 SLTI_FM<0xa>;
1130 def SLTiu : MMRel, SetCC_I<"sltiu", setult, simm16, immSExt16, GPR32Opnd>, 1214 def SLTiu : MMRel, SetCC_I<"sltiu", setult, simm16, immSExt16, GPR32Opnd>,
1131 SLTI_FM<0xb>; 1215 SLTI_FM<0xb>;
1132 let AdditionalPredicates = [NotInMicroMips] in { 1216 let AdditionalPredicates = [NotInMicroMips] in {
1133 def ANDi : MMRel, ArithLogicI<"andi", uimm16, GPR32Opnd, II_ANDI, immZExt16, 1217 def ANDi : MMRel, StdMMR6Rel,
1134 and>, ADDI_FM<0xc>; 1218 ArithLogicI<"andi", uimm16, GPR32Opnd, II_ANDI, immZExt16, and>,
1135 } 1219 ADDI_FM<0xc>;
1136 def ORi : MMRel, ArithLogicI<"ori", uimm16, GPR32Opnd, II_ORI, immZExt16, 1220 }
1137 or>, 1221 def ORi : MMRel, StdMMR6Rel,
1222 ArithLogicI<"ori", uimm16, GPR32Opnd, II_ORI, immZExt16, or>,
1138 ADDI_FM<0xd>; 1223 ADDI_FM<0xd>;
1139 def XORi : MMRel, ArithLogicI<"xori", uimm16, GPR32Opnd, II_XORI, immZExt16, 1224 def XORi : MMRel, StdMMR6Rel,
1140 xor>, 1225 ArithLogicI<"xori", uimm16, GPR32Opnd, II_XORI, immZExt16, xor>,
1141 ADDI_FM<0xe>; 1226 ADDI_FM<0xe>;
1142 def LUi : MMRel, LoadUpper<"lui", GPR32Opnd, uimm16>, LUI_FM; 1227 def LUi : MMRel, LoadUpper<"lui", GPR32Opnd, uimm16>, LUI_FM;
1143 1228 let AdditionalPredicates = [NotInMicroMips] in {
1144 /// Arithmetic Instructions (3-Operand, R-Type) 1229 /// Arithmetic Instructions (3-Operand, R-Type)
1145 def ADDu : MMRel, ArithLogicR<"addu", GPR32Opnd, 1, II_ADDU, add>, 1230 def ADDu : MMRel, StdMMR6Rel, ArithLogicR<"addu", GPR32Opnd, 1, II_ADDU, add>,
1146 ADD_FM<0, 0x21>; 1231 ADD_FM<0, 0x21>;
1147 def SUBu : MMRel, ArithLogicR<"subu", GPR32Opnd, 0, II_SUBU, sub>, 1232 def SUBu : MMRel, ArithLogicR<"subu", GPR32Opnd, 0, II_SUBU, sub>,
1148 ADD_FM<0, 0x23>; 1233 ADD_FM<0, 0x23>;
1234 }
1149 let Defs = [HI0, LO0] in 1235 let Defs = [HI0, LO0] in
1150 def MUL : MMRel, ArithLogicR<"mul", GPR32Opnd, 1, II_MUL, mul>, 1236 def MUL : MMRel, ArithLogicR<"mul", GPR32Opnd, 1, II_MUL, mul>,
1151 ADD_FM<0x1c, 2>, ISA_MIPS32_NOT_32R6_64R6; 1237 ADD_FM<0x1c, 2>, ISA_MIPS32_NOT_32R6_64R6;
1152 def ADD : MMRel, ArithLogicR<"add", GPR32Opnd>, ADD_FM<0, 0x20>; 1238 def ADD : MMRel, StdMMR6Rel, ArithLogicR<"add", GPR32Opnd>, ADD_FM<0, 0x20>;
1153 def SUB : MMRel, ArithLogicR<"sub", GPR32Opnd>, ADD_FM<0, 0x22>; 1239 def SUB : MMRel, ArithLogicR<"sub", GPR32Opnd>, ADD_FM<0, 0x22>;
1154 def SLT : MMRel, SetCC_R<"slt", setlt, GPR32Opnd>, ADD_FM<0, 0x2a>; 1240 def SLT : MMRel, SetCC_R<"slt", setlt, GPR32Opnd>, ADD_FM<0, 0x2a>;
1155 def SLTu : MMRel, SetCC_R<"sltu", setult, GPR32Opnd>, ADD_FM<0, 0x2b>; 1241 def SLTu : MMRel, SetCC_R<"sltu", setult, GPR32Opnd>, ADD_FM<0, 0x2b>;
1156 def AND : MMRel, ArithLogicR<"and", GPR32Opnd, 1, II_AND, and>, 1242 let AdditionalPredicates = [NotInMicroMips] in {
1243 def AND : MMRel, StdMMR6Rel, ArithLogicR<"and", GPR32Opnd, 1, II_AND, and>,
1157 ADD_FM<0, 0x24>; 1244 ADD_FM<0, 0x24>;
1158 def OR : MMRel, ArithLogicR<"or", GPR32Opnd, 1, II_OR, or>, 1245 def OR : MMRel, StdMMR6Rel, ArithLogicR<"or", GPR32Opnd, 1, II_OR, or>,
1159 ADD_FM<0, 0x25>; 1246 ADD_FM<0, 0x25>;
1160 def XOR : MMRel, ArithLogicR<"xor", GPR32Opnd, 1, II_XOR, xor>, 1247 def XOR : MMRel, StdMMR6Rel, ArithLogicR<"xor", GPR32Opnd, 1, II_XOR, xor>,
1161 ADD_FM<0, 0x26>; 1248 ADD_FM<0, 0x26>;
1162 def NOR : MMRel, LogicNOR<"nor", GPR32Opnd>, ADD_FM<0, 0x27>; 1249 }
1250 def NOR : MMRel, StdMMR6Rel, LogicNOR<"nor", GPR32Opnd>, ADD_FM<0, 0x27>;
1163 1251
1164 /// Shift Instructions 1252 /// Shift Instructions
1165 let AdditionalPredicates = [NotInMicroMips] in { 1253 let AdditionalPredicates = [NotInMicroMips] in {
1166 def SLL : MMRel, shift_rotate_imm<"sll", uimm5, GPR32Opnd, II_SLL, shl, 1254 def SLL : MMRel, shift_rotate_imm<"sll", uimm5, GPR32Opnd, II_SLL, shl,
1167 immZExt5>, SRA_FM<0, 0>; 1255 immZExt5>, SRA_FM<0, 0>;
1191 LW_FM<0x24>; 1279 LW_FM<0x24>;
1192 def LH : Load<"lh", GPR32Opnd, sextloadi16, II_LH, addrDefault>, MMRel, 1280 def LH : Load<"lh", GPR32Opnd, sextloadi16, II_LH, addrDefault>, MMRel,
1193 LW_FM<0x21>; 1281 LW_FM<0x21>;
1194 def LHu : Load<"lhu", GPR32Opnd, zextloadi16, II_LHU>, MMRel, LW_FM<0x25>; 1282 def LHu : Load<"lhu", GPR32Opnd, zextloadi16, II_LHU>, MMRel, LW_FM<0x25>;
1195 let AdditionalPredicates = [NotInMicroMips] in { 1283 let AdditionalPredicates = [NotInMicroMips] in {
1196 def LW : Load<"lw", GPR32Opnd, load, II_LW, addrDefault>, MMRel, 1284 def LW : StdMMR6Rel, Load<"lw", GPR32Opnd, load, II_LW, addrDefault>, MMRel,
1197 LW_FM<0x23>; 1285 LW_FM<0x23>;
1198 } 1286 }
1199 def SB : Store<"sb", GPR32Opnd, truncstorei8, II_SB>, MMRel, LW_FM<0x28>; 1287 def SB : StdMMR6Rel, Store<"sb", GPR32Opnd, truncstorei8, II_SB>, MMRel,
1288 LW_FM<0x28>;
1200 def SH : Store<"sh", GPR32Opnd, truncstorei16, II_SH>, MMRel, LW_FM<0x29>; 1289 def SH : Store<"sh", GPR32Opnd, truncstorei16, II_SH>, MMRel, LW_FM<0x29>;
1201 let AdditionalPredicates = [NotInMicroMips] in { 1290 let AdditionalPredicates = [NotInMicroMips] in {
1202 def SW : Store<"sw", GPR32Opnd, store, II_SW>, MMRel, LW_FM<0x2b>; 1291 def SW : Store<"sw", GPR32Opnd, store, II_SW>, MMRel, LW_FM<0x2b>;
1203 } 1292 }
1204 1293
1238 } 1327 }
1239 1328
1240 def SYNC : MMRel, SYNC_FT<"sync">, SYNC_FM, ISA_MIPS32; 1329 def SYNC : MMRel, SYNC_FT<"sync">, SYNC_FM, ISA_MIPS32;
1241 def SYNCI : MMRel, SYNCI_FT<"synci">, SYNCI_FM, ISA_MIPS32R2; 1330 def SYNCI : MMRel, SYNCI_FT<"synci">, SYNCI_FM, ISA_MIPS32R2;
1242 1331
1243 def TEQ : MMRel, TEQ_FT<"teq", GPR32Opnd>, TEQ_FM<0x34>, ISA_MIPS2; 1332 let AdditionalPredicates = [NotInMicroMips] in {
1244 def TGE : MMRel, TEQ_FT<"tge", GPR32Opnd>, TEQ_FM<0x30>, ISA_MIPS2; 1333 def TEQ : MMRel, TEQ_FT<"teq", GPR32Opnd>, TEQ_FM<0x34>, ISA_MIPS2;
1245 def TGEU : MMRel, TEQ_FT<"tgeu", GPR32Opnd>, TEQ_FM<0x31>, ISA_MIPS2; 1334 def TGE : MMRel, TEQ_FT<"tge", GPR32Opnd>, TEQ_FM<0x30>, ISA_MIPS2;
1246 def TLT : MMRel, TEQ_FT<"tlt", GPR32Opnd>, TEQ_FM<0x32>, ISA_MIPS2; 1335 def TGEU : MMRel, TEQ_FT<"tgeu", GPR32Opnd>, TEQ_FM<0x31>, ISA_MIPS2;
1247 def TLTU : MMRel, TEQ_FT<"tltu", GPR32Opnd>, TEQ_FM<0x33>, ISA_MIPS2; 1336 def TLT : MMRel, TEQ_FT<"tlt", GPR32Opnd>, TEQ_FM<0x32>, ISA_MIPS2;
1248 def TNE : MMRel, TEQ_FT<"tne", GPR32Opnd>, TEQ_FM<0x36>, ISA_MIPS2; 1337 def TLTU : MMRel, TEQ_FT<"tltu", GPR32Opnd>, TEQ_FM<0x33>, ISA_MIPS2;
1338 def TNE : MMRel, TEQ_FT<"tne", GPR32Opnd>, TEQ_FM<0x36>, ISA_MIPS2;
1339 }
1249 1340
1250 def TEQI : MMRel, TEQI_FT<"teqi", GPR32Opnd>, TEQI_FM<0xc>, 1341 def TEQI : MMRel, TEQI_FT<"teqi", GPR32Opnd>, TEQI_FM<0xc>,
1251 ISA_MIPS2_NOT_32R6_64R6; 1342 ISA_MIPS2_NOT_32R6_64R6;
1252 def TGEI : MMRel, TEQI_FT<"tgei", GPR32Opnd>, TEQI_FM<0x8>, 1343 def TGEI : MMRel, TEQI_FT<"tgei", GPR32Opnd>, TEQI_FM<0x8>,
1253 ISA_MIPS2_NOT_32R6_64R6; 1344 ISA_MIPS2_NOT_32R6_64R6;
1258 def TTLTIU : MMRel, TEQI_FT<"tltiu", GPR32Opnd>, TEQI_FM<0xb>, 1349 def TTLTIU : MMRel, TEQI_FT<"tltiu", GPR32Opnd>, TEQI_FM<0xb>,
1259 ISA_MIPS2_NOT_32R6_64R6; 1350 ISA_MIPS2_NOT_32R6_64R6;
1260 def TNEI : MMRel, TEQI_FT<"tnei", GPR32Opnd>, TEQI_FM<0xe>, 1351 def TNEI : MMRel, TEQI_FT<"tnei", GPR32Opnd>, TEQI_FM<0xe>,
1261 ISA_MIPS2_NOT_32R6_64R6; 1352 ISA_MIPS2_NOT_32R6_64R6;
1262 1353
1263 def BREAK : MMRel, BRK_FT<"break">, BRK_FM<0xd>; 1354 let AdditionalPredicates = [NotInMicroMips] in {
1355 def BREAK : MMRel, StdMMR6Rel, BRK_FT<"break">, BRK_FM<0xd>;
1356 }
1264 def SYSCALL : MMRel, SYS_FT<"syscall">, SYS_FM<0xc>; 1357 def SYSCALL : MMRel, SYS_FT<"syscall">, SYS_FM<0xc>;
1265 def TRAP : TrapBase<BREAK>; 1358 def TRAP : TrapBase<BREAK>;
1266 def SDBBP : MMRel, SYS_FT<"sdbbp">, SDBBP_FM, ISA_MIPS32_NOT_32R6_64R6; 1359 def SDBBP : MMRel, SYS_FT<"sdbbp">, SDBBP_FM, ISA_MIPS32_NOT_32R6_64R6;
1267 1360
1268 def ERET : MMRel, ER_FT<"eret">, ER_FM<0x18>, INSN_MIPS3_32; 1361 let AdditionalPredicates = [NotInMicroMips] in {
1269 def DERET : MMRel, ER_FT<"deret">, ER_FM<0x1f>, ISA_MIPS32; 1362 def ERET : MMRel, ER_FT<"eret">, ER_FM<0x18, 0x0>, INSN_MIPS3_32;
1270 1363 def ERETNC : MMRel, ER_FT<"eretnc">, ER_FM<0x18, 0x1>, ISA_MIPS32R5;
1271 def EI : MMRel, DEI_FT<"ei", GPR32Opnd>, EI_FM<1>, ISA_MIPS32R2; 1364 }
1365 def DERET : MMRel, ER_FT<"deret">, ER_FM<0x1f, 0x0>, ISA_MIPS32;
1366
1367 let AdditionalPredicates = [NotInMicroMips] in {
1368 def EI : MMRel, StdMMR6Rel, DEI_FT<"ei", GPR32Opnd>, EI_FM<1>, ISA_MIPS32R2;
1369 }
1272 def DI : MMRel, DEI_FT<"di", GPR32Opnd>, EI_FM<0>, ISA_MIPS32R2; 1370 def DI : MMRel, DEI_FT<"di", GPR32Opnd>, EI_FM<0>, ISA_MIPS32R2;
1273 1371
1274 let EncodingPredicates = []<Predicate>, // FIXME: Lack of HasStdEnc is probably a bug 1372 let EncodingPredicates = []<Predicate>, // FIXME: Lack of HasStdEnc is probably a bug
1275 AdditionalPredicates = [NotInMicroMips] in { 1373 AdditionalPredicates = [NotInMicroMips] in {
1276 def WAIT : WAIT_FT<"wait">, WAIT_FM; 1374 def WAIT : WAIT_FT<"wait">, WAIT_FM;
1312 let AdditionalPredicates = [NotInMicroMips] in { 1410 let AdditionalPredicates = [NotInMicroMips] in {
1313 def JALR : JumpLinkReg<"jalr", GPR32Opnd>, JALR_FM; 1411 def JALR : JumpLinkReg<"jalr", GPR32Opnd>, JALR_FM;
1314 def JALRPseudo : JumpLinkRegPseudo<GPR32Opnd, JALR, RA>; 1412 def JALRPseudo : JumpLinkRegPseudo<GPR32Opnd, JALR, RA>;
1315 } 1413 }
1316 1414
1317 // FIXME: JALX really requires either MIPS16 or microMIPS in addition to MIPS32. 1415 def JALX : MMRel, JumpLink<"jalx", calltarget>, FJ<0x1D>,
1318 def JALX : JumpLink<"jalx", calltarget>, FJ<0x1D>, ISA_MIPS32_NOT_32R6_64R6; 1416 ISA_MIPS32_NOT_32R6_64R6;
1319 def BGEZAL : MMRel, BGEZAL_FT<"bgezal", brtarget, GPR32Opnd>, BGEZAL_FM<0x11>, 1417 def BGEZAL : MMRel, BGEZAL_FT<"bgezal", brtarget, GPR32Opnd>, BGEZAL_FM<0x11>,
1320 ISA_MIPS1_NOT_32R6_64R6; 1418 ISA_MIPS1_NOT_32R6_64R6;
1321 def BGEZALL : MMRel, BGEZAL_FT<"bgezall", brtarget, GPR32Opnd, 0>, 1419 def BGEZALL : MMRel, BGEZAL_FT<"bgezall", brtarget, GPR32Opnd, 0>,
1322 BGEZAL_FM<0x13>, ISA_MIPS2_NOT_32R6_64R6; 1420 BGEZAL_FM<0x13>, ISA_MIPS2_NOT_32R6_64R6;
1323 def BLTZAL : MMRel, BGEZAL_FT<"bltzal", brtarget, GPR32Opnd>, BGEZAL_FM<0x10>, 1421 def BLTZAL : MMRel, BGEZAL_FT<"bltzal", brtarget, GPR32Opnd>, BGEZAL_FM<0x10>,
1329 def TAILCALL_R : TailCallReg<GPR32Opnd, JR>; 1427 def TAILCALL_R : TailCallReg<GPR32Opnd, JR>;
1330 1428
1331 // Indirect branches are matched as PseudoIndirectBranch/PseudoIndirectBranch64 1429 // Indirect branches are matched as PseudoIndirectBranch/PseudoIndirectBranch64
1332 // then are expanded to JR, JR64, JALR, or JALR64 depending on the ISA. 1430 // then are expanded to JR, JR64, JALR, or JALR64 depending on the ISA.
1333 class PseudoIndirectBranchBase<RegisterOperand RO> : 1431 class PseudoIndirectBranchBase<RegisterOperand RO> :
1334 MipsPseudo<(outs), (ins RO:$rs), [(brind RO:$rs)], IIBranch> { 1432 MipsPseudo<(outs), (ins RO:$rs), [(brind RO:$rs)],
1433 II_IndirectBranchPseudo> {
1335 let isTerminator=1; 1434 let isTerminator=1;
1336 let isBarrier=1; 1435 let isBarrier=1;
1337 let hasDelaySlot = 1; 1436 let hasDelaySlot = 1;
1338 let isBranch = 1; 1437 let isBranch = 1;
1339 let isIndirectBranch = 1; 1438 let isIndirectBranch = 1;
1340 } 1439 }
1341 1440
1342 def PseudoIndirectBranch : PseudoIndirectBranchBase<GPR32Opnd>; 1441 def PseudoIndirectBranch : PseudoIndirectBranchBase<GPR32Opnd>;
1343 1442
1344 // Return instructions are matched as a RetRA instruction, then ar expanded 1443 // Return instructions are matched as a RetRA instruction, then are expanded
1345 // into PseudoReturn/PseudoReturn64 after register allocation. Finally, 1444 // into PseudoReturn/PseudoReturn64 after register allocation. Finally,
1346 // MipsAsmPrinter expands this into JR, JR64, JALR, or JALR64 depending on the 1445 // MipsAsmPrinter expands this into JR, JR64, JALR, or JALR64 depending on the
1347 // ISA. 1446 // ISA.
1348 class PseudoReturnBase<RegisterOperand RO> : MipsPseudo<(outs), (ins RO:$rs), 1447 class PseudoReturnBase<RegisterOperand RO> : MipsPseudo<(outs), (ins RO:$rs),
1349 [], IIBranch> { 1448 [], II_ReturnPseudo> {
1350 let isTerminator = 1; 1449 let isTerminator = 1;
1351 let isBarrier = 1; 1450 let isBarrier = 1;
1352 let hasDelaySlot = 1; 1451 let hasDelaySlot = 1;
1353 let isReturn = 1; 1452 let isReturn = 1;
1354 let isCodeGenOnly = 1; 1453 let isCodeGenOnly = 1;
1400 def MFLO : MMRel, MoveFromLOHI<"mflo", GPR32Opnd, AC0>, MFLO_FM<0x12>, 1499 def MFLO : MMRel, MoveFromLOHI<"mflo", GPR32Opnd, AC0>, MFLO_FM<0x12>,
1401 ISA_MIPS1_NOT_32R6_64R6; 1500 ISA_MIPS1_NOT_32R6_64R6;
1402 } 1501 }
1403 1502
1404 /// Sign Ext In Register Instructions. 1503 /// Sign Ext In Register Instructions.
1405 def SEB : MMRel, SignExtInReg<"seb", i8, GPR32Opnd, II_SEB>, 1504 def SEB : MMRel, StdMMR6Rel, SignExtInReg<"seb", i8, GPR32Opnd, II_SEB>,
1406 SEB_FM<0x10, 0x20>, ISA_MIPS32R2; 1505 SEB_FM<0x10, 0x20>, ISA_MIPS32R2;
1407 def SEH : MMRel, SignExtInReg<"seh", i16, GPR32Opnd, II_SEH>, 1506 def SEH : MMRel, StdMMR6Rel, SignExtInReg<"seh", i16, GPR32Opnd, II_SEH>,
1408 SEB_FM<0x18, 0x20>, ISA_MIPS32R2; 1507 SEB_FM<0x18, 0x20>, ISA_MIPS32R2;
1409 1508
1410 /// Count Leading 1509 /// Count Leading
1411 def CLZ : MMRel, CountLeading0<"clz", GPR32Opnd>, CLO_FM<0x20>, 1510 def CLZ : MMRel, CountLeading0<"clz", GPR32Opnd>, CLO_FM<0x20>,
1412 ISA_MIPS32_NOT_32R6_64R6; 1511 ISA_MIPS32_NOT_32R6_64R6;
1413 def CLO : MMRel, CountLeading1<"clo", GPR32Opnd>, CLO_FM<0x21>, 1512 def CLO : MMRel, CountLeading1<"clo", GPR32Opnd>, CLO_FM<0x21>,
1414 ISA_MIPS32_NOT_32R6_64R6; 1513 ISA_MIPS32_NOT_32R6_64R6;
1415 1514
1416 /// Word Swap Bytes Within Halfwords 1515 let AdditionalPredicates = [NotInMicroMips] in {
1417 def WSBH : MMRel, SubwordSwap<"wsbh", GPR32Opnd>, SEB_FM<2, 0x20>, ISA_MIPS32R2; 1516 /// Word Swap Bytes Within Halfwords
1517 def WSBH : MMRel, SubwordSwap<"wsbh", GPR32Opnd, II_WSBH>, SEB_FM<2, 0x20>,
1518 ISA_MIPS32R2;
1519 }
1418 1520
1419 /// No operation. 1521 /// No operation.
1420 def NOP : PseudoSE<(outs), (ins), []>, PseudoInstExpansion<(SLL ZERO, ZERO, 0)>; 1522 def NOP : PseudoSE<(outs), (ins), []>, PseudoInstExpansion<(SLL ZERO, ZERO, 0)>;
1421 1523
1422 // FrameIndexes are legalized when they are operands from load/store 1524 // FrameIndexes are legalized when they are operands from load/store
1462 1564
1463 def EXT : MMRel, ExtBase<"ext", GPR32Opnd, uimm5, MipsExt>, EXT_FM<0>; 1565 def EXT : MMRel, ExtBase<"ext", GPR32Opnd, uimm5, MipsExt>, EXT_FM<0>;
1464 def INS : MMRel, InsBase<"ins", GPR32Opnd, uimm5, MipsIns>, EXT_FM<4>; 1566 def INS : MMRel, InsBase<"ins", GPR32Opnd, uimm5, MipsIns>, EXT_FM<4>;
1465 1567
1466 /// Move Control Registers From/To CPU Registers 1568 /// Move Control Registers From/To CPU Registers
1467 def MFC0 : MFC3OP<"mfc0", GPR32Opnd>, MFC3OP_FM<0x10, 0>, ISA_MIPS32; 1569 def MFC0 : MFC3OP<"mfc0", GPR32Opnd, COP0Opnd>, MFC3OP_FM<0x10, 0>, ISA_MIPS32;
1468 def MTC0 : MFC3OP<"mtc0", GPR32Opnd>, MFC3OP_FM<0x10, 4>, ISA_MIPS32; 1570 def MTC0 : MTC3OP<"mtc0", COP0Opnd, GPR32Opnd>, MFC3OP_FM<0x10, 4>, ISA_MIPS32;
1469 def MFC2 : MFC3OP<"mfc2", GPR32Opnd>, MFC3OP_FM<0x12, 0>; 1571 def MFC2 : MFC3OP<"mfc2", GPR32Opnd, COP2Opnd>, MFC3OP_FM<0x12, 0>;
1470 def MTC2 : MFC3OP<"mtc2", GPR32Opnd>, MFC3OP_FM<0x12, 4>; 1572 def MTC2 : MTC3OP<"mtc2", COP2Opnd, GPR32Opnd>, MFC3OP_FM<0x12, 4>;
1471 1573
1472 class Barrier<string asmstr> : InstSE<(outs), (ins), asmstr, [], NoItinerary, 1574 class Barrier<string asmstr> : InstSE<(outs), (ins), asmstr, [], NoItinerary,
1473 FrmOther, asmstr>; 1575 FrmOther, asmstr>;
1474 def SSNOP : MMRel, Barrier<"ssnop">, BARRIER_FM<1>; 1576 def SSNOP : MMRel, Barrier<"ssnop">, BARRIER_FM<1>;
1475 def EHB : MMRel, Barrier<"ehb">, BARRIER_FM<3>; 1577 def EHB : MMRel, Barrier<"ehb">, BARRIER_FM<3>;
1536 1638
1537 //===----------------------------------------------------------------------===// 1639 //===----------------------------------------------------------------------===//
1538 // Instruction aliases 1640 // Instruction aliases
1539 //===----------------------------------------------------------------------===// 1641 //===----------------------------------------------------------------------===//
1540 def : MipsInstAlias<"move $dst, $src", 1642 def : MipsInstAlias<"move $dst, $src",
1541 (ADDu GPR32Opnd:$dst, GPR32Opnd:$src,ZERO), 1>, 1643 (OR GPR32Opnd:$dst, GPR32Opnd:$src, ZERO), 1>,
1644 GPR_32 {
1645 let AdditionalPredicates = [NotInMicroMips];
1646 }
1647 def : MipsInstAlias<"move $dst, $src",
1648 (ADDu GPR32Opnd:$dst, GPR32Opnd:$src, ZERO), 1>,
1542 GPR_32 { 1649 GPR_32 {
1543 let AdditionalPredicates = [NotInMicroMips]; 1650 let AdditionalPredicates = [NotInMicroMips];
1544 } 1651 }
1545 def : MipsInstAlias<"bal $offset", (BGEZAL ZERO, brtarget:$offset), 0>, 1652 def : MipsInstAlias<"bal $offset", (BGEZAL ZERO, brtarget:$offset), 0>,
1546 ISA_MIPS1_NOT_32R6_64R6; 1653 ISA_MIPS1_NOT_32R6_64R6;
1575 (SLTi GPR32Opnd:$rs, GPR32Opnd:$rt, simm16:$imm), 0>; 1682 (SLTi GPR32Opnd:$rs, GPR32Opnd:$rt, simm16:$imm), 0>;
1576 def : MipsInstAlias<"sltu $rt, $rs, $imm", 1683 def : MipsInstAlias<"sltu $rt, $rs, $imm",
1577 (SLTiu GPR32Opnd:$rt, GPR32Opnd:$rs, simm16:$imm), 0>; 1684 (SLTiu GPR32Opnd:$rt, GPR32Opnd:$rs, simm16:$imm), 0>;
1578 def : MipsInstAlias<"xor $rs, $rt, $imm", 1685 def : MipsInstAlias<"xor $rs, $rt, $imm",
1579 (XORi GPR32Opnd:$rs, GPR32Opnd:$rt, uimm16:$imm), 0>; 1686 (XORi GPR32Opnd:$rs, GPR32Opnd:$rt, uimm16:$imm), 0>;
1687 def : MipsInstAlias<"xor $rs, $imm",
1688 (XORi GPR32Opnd:$rs, GPR32Opnd:$rs, uimm16:$imm), 0>;
1580 def : MipsInstAlias<"or $rs, $rt, $imm", 1689 def : MipsInstAlias<"or $rs, $rt, $imm",
1581 (ORi GPR32Opnd:$rs, GPR32Opnd:$rt, uimm16:$imm), 0>; 1690 (ORi GPR32Opnd:$rs, GPR32Opnd:$rt, uimm16:$imm), 0>;
1582 def : MipsInstAlias<"or $rs, $imm", 1691 def : MipsInstAlias<"or $rs, $imm",
1583 (ORi GPR32Opnd:$rs, GPR32Opnd:$rs, uimm16:$imm), 0>; 1692 (ORi GPR32Opnd:$rs, GPR32Opnd:$rs, uimm16:$imm), 0>;
1693 let AdditionalPredicates = [NotInMicroMips] in {
1584 def : MipsInstAlias<"nop", (SLL ZERO, ZERO, 0), 1>; 1694 def : MipsInstAlias<"nop", (SLL ZERO, ZERO, 0), 1>;
1585 def : MipsInstAlias<"mfc0 $rt, $rd", (MFC0 GPR32Opnd:$rt, GPR32Opnd:$rd, 0), 0>; 1695 }
1586 def : MipsInstAlias<"mtc0 $rt, $rd", (MTC0 GPR32Opnd:$rt, GPR32Opnd:$rd, 0), 0>; 1696 def : MipsInstAlias<"mfc0 $rt, $rd", (MFC0 GPR32Opnd:$rt, COP0Opnd:$rd, 0), 0>;
1587 def : MipsInstAlias<"mfc2 $rt, $rd", (MFC2 GPR32Opnd:$rt, GPR32Opnd:$rd, 0), 0>; 1697 def : MipsInstAlias<"mtc0 $rt, $rd", (MTC0 COP0Opnd:$rd, GPR32Opnd:$rt, 0), 0>;
1588 def : MipsInstAlias<"mtc2 $rt, $rd", (MTC2 GPR32Opnd:$rt, GPR32Opnd:$rd, 0), 0>; 1698 def : MipsInstAlias<"mfc2 $rt, $rd", (MFC2 GPR32Opnd:$rt, COP2Opnd:$rd, 0), 0>;
1699 def : MipsInstAlias<"mtc2 $rt, $rd", (MTC2 COP2Opnd:$rd, GPR32Opnd:$rt, 0), 0>;
1589 let AdditionalPredicates = [NotInMicroMips] in { 1700 let AdditionalPredicates = [NotInMicroMips] in {
1590 def : MipsInstAlias<"b $offset", (BEQ ZERO, ZERO, brtarget:$offset), 0>; 1701 def : MipsInstAlias<"b $offset", (BEQ ZERO, ZERO, brtarget:$offset), 0>;
1591 } 1702 }
1592 def : MipsInstAlias<"bnez $rs,$offset", 1703 def : MipsInstAlias<"bnez $rs,$offset",
1593 (BNE GPR32Opnd:$rs, ZERO, brtarget:$offset), 0>; 1704 (BNE GPR32Opnd:$rs, ZERO, brtarget:$offset), 0>;
1705 def : MipsInstAlias<"bnezl $rs,$offset",
1706 (BNEL GPR32Opnd:$rs, ZERO, brtarget:$offset), 0>;
1594 def : MipsInstAlias<"beqz $rs,$offset", 1707 def : MipsInstAlias<"beqz $rs,$offset",
1595 (BEQ GPR32Opnd:$rs, ZERO, brtarget:$offset), 0>; 1708 (BEQ GPR32Opnd:$rs, ZERO, brtarget:$offset), 0>;
1709 def : MipsInstAlias<"beqzl $rs,$offset",
1710 (BEQL GPR32Opnd:$rs, ZERO, brtarget:$offset), 0>;
1596 def : MipsInstAlias<"syscall", (SYSCALL 0), 1>; 1711 def : MipsInstAlias<"syscall", (SYSCALL 0), 1>;
1597 1712
1598 def : MipsInstAlias<"break", (BREAK 0, 0), 1>; 1713 def : MipsInstAlias<"break", (BREAK 0, 0), 1>;
1599 def : MipsInstAlias<"break $imm", (BREAK uimm10:$imm, 0), 1>; 1714 def : MipsInstAlias<"break $imm", (BREAK uimm10:$imm, 0), 1>;
1715 let AdditionalPredicates = [NotInMicroMips] in {
1600 def : MipsInstAlias<"ei", (EI ZERO), 1>, ISA_MIPS32R2; 1716 def : MipsInstAlias<"ei", (EI ZERO), 1>, ISA_MIPS32R2;
1717 }
1601 def : MipsInstAlias<"di", (DI ZERO), 1>, ISA_MIPS32R2; 1718 def : MipsInstAlias<"di", (DI ZERO), 1>, ISA_MIPS32R2;
1602 1719 let AdditionalPredicates = [NotInMicroMips] in {
1603 def : MipsInstAlias<"teq $rs, $rt", 1720 def : MipsInstAlias<"teq $rs, $rt",
1604 (TEQ GPR32Opnd:$rs, GPR32Opnd:$rt, 0), 1>, ISA_MIPS2; 1721 (TEQ GPR32Opnd:$rs, GPR32Opnd:$rt, 0), 1>, ISA_MIPS2;
1605 def : MipsInstAlias<"tge $rs, $rt", 1722 def : MipsInstAlias<"tge $rs, $rt",
1606 (TGE GPR32Opnd:$rs, GPR32Opnd:$rt, 0), 1>, ISA_MIPS2; 1723 (TGE GPR32Opnd:$rs, GPR32Opnd:$rt, 0), 1>, ISA_MIPS2;
1607 def : MipsInstAlias<"tgeu $rs, $rt", 1724 def : MipsInstAlias<"tgeu $rs, $rt",
1608 (TGEU GPR32Opnd:$rs, GPR32Opnd:$rt, 0), 1>, ISA_MIPS2; 1725 (TGEU GPR32Opnd:$rs, GPR32Opnd:$rt, 0), 1>, ISA_MIPS2;
1609 def : MipsInstAlias<"tlt $rs, $rt", 1726 def : MipsInstAlias<"tlt $rs, $rt",
1610 (TLT GPR32Opnd:$rs, GPR32Opnd:$rt, 0), 1>, ISA_MIPS2; 1727 (TLT GPR32Opnd:$rs, GPR32Opnd:$rt, 0), 1>, ISA_MIPS2;
1611 def : MipsInstAlias<"tltu $rs, $rt", 1728 def : MipsInstAlias<"tltu $rs, $rt",
1612 (TLTU GPR32Opnd:$rs, GPR32Opnd:$rt, 0), 1>, ISA_MIPS2; 1729 (TLTU GPR32Opnd:$rs, GPR32Opnd:$rt, 0), 1>, ISA_MIPS2;
1613 def : MipsInstAlias<"tne $rs, $rt", 1730 def : MipsInstAlias<"tne $rs, $rt",
1614 (TNE GPR32Opnd:$rs, GPR32Opnd:$rt, 0), 1>, ISA_MIPS2; 1731 (TNE GPR32Opnd:$rs, GPR32Opnd:$rt, 0), 1>, ISA_MIPS2;
1615 1732 }
1616 def : MipsInstAlias<"sll $rd, $rt, $rs", 1733 def : MipsInstAlias<"sll $rd, $rt, $rs",
1617 (SLLV GPR32Opnd:$rd, GPR32Opnd:$rt, GPR32Opnd:$rs), 0>; 1734 (SLLV GPR32Opnd:$rd, GPR32Opnd:$rt, GPR32Opnd:$rs), 0>;
1618 def : MipsInstAlias<"sub, $rd, $rs, $imm", 1735 def : MipsInstAlias<"sub, $rd, $rs, $imm",
1619 (ADDi GPR32Opnd:$rd, GPR32Opnd:$rs, 1736 (ADDi GPR32Opnd:$rd, GPR32Opnd:$rs,
1620 InvertedImOperand:$imm), 0>, ISA_MIPS1_NOT_32R6_64R6; 1737 InvertedImOperand:$imm), 0>, ISA_MIPS1_NOT_32R6_64R6;
1635 (SYNC 0), 1>, ISA_MIPS2; 1752 (SYNC 0), 1>, ISA_MIPS2;
1636 //===----------------------------------------------------------------------===// 1753 //===----------------------------------------------------------------------===//
1637 // Assembler Pseudo Instructions 1754 // Assembler Pseudo Instructions
1638 //===----------------------------------------------------------------------===// 1755 //===----------------------------------------------------------------------===//
1639 1756
1640 class LoadImm32< string instr_asm, Operand Od, RegisterOperand RO> : 1757 class LoadImmediate32<string instr_asm, Operand Od, RegisterOperand RO> :
1641 MipsAsmPseudoInst<(outs RO:$rt), (ins Od:$imm32), 1758 MipsAsmPseudoInst<(outs RO:$rt), (ins Od:$imm32),
1642 !strconcat(instr_asm, "\t$rt, $imm32")> ; 1759 !strconcat(instr_asm, "\t$rt, $imm32")> ;
1643 def LoadImm32Reg : LoadImm32<"li", uimm5, GPR32Opnd>; 1760 def LoadImm32 : LoadImmediate32<"li", uimm5, GPR32Opnd>;
1644 1761
1645 class LoadAddress<string instr_asm, Operand MemOpnd, RegisterOperand RO> : 1762 class LoadAddressFromReg32<string instr_asm, Operand MemOpnd,
1763 RegisterOperand RO> :
1646 MipsAsmPseudoInst<(outs RO:$rt), (ins MemOpnd:$addr), 1764 MipsAsmPseudoInst<(outs RO:$rt), (ins MemOpnd:$addr),
1647 !strconcat(instr_asm, "\t$rt, $addr")> ; 1765 !strconcat(instr_asm, "\t$rt, $addr")> ;
1648 def LoadAddr32Reg : LoadAddress<"la", mem, GPR32Opnd>; 1766 def LoadAddrReg32 : LoadAddressFromReg32<"la", mem, GPR32Opnd>;
1649 1767
1650 class LoadAddressImm<string instr_asm, Operand Od, RegisterOperand RO> : 1768 class LoadAddressFromImm32<string instr_asm, Operand Od, RegisterOperand RO> :
1651 MipsAsmPseudoInst<(outs RO:$rt), (ins Od:$imm32), 1769 MipsAsmPseudoInst<(outs RO:$rt), (ins Od:$imm32),
1652 !strconcat(instr_asm, "\t$rt, $imm32")> ; 1770 !strconcat(instr_asm, "\t$rt, $imm32")> ;
1653 def LoadAddr32Imm : LoadAddressImm<"la", uimm5, GPR32Opnd>; 1771 def LoadAddrImm32 : LoadAddressFromImm32<"la", uimm5, GPR32Opnd>;
1654 1772
1655 def JalTwoReg : MipsAsmPseudoInst<(outs GPR32Opnd:$rd), (ins GPR32Opnd:$rs), 1773 def JalTwoReg : MipsAsmPseudoInst<(outs GPR32Opnd:$rd), (ins GPR32Opnd:$rs),
1656 "jal\t$rd, $rs"> ; 1774 "jal\t$rd, $rs"> ;
1657 def JalOneReg : MipsAsmPseudoInst<(outs), (ins GPR32Opnd:$rs), 1775 def JalOneReg : MipsAsmPseudoInst<(outs), (ins GPR32Opnd:$rs),
1658 "jal\t$rs"> ; 1776 "jal\t$rs"> ;
1777
1778 def NORImm : MipsAsmPseudoInst<(outs), (ins GPR32Opnd:$rs, GPR32Opnd:$rt, simm16:$imm),
1779 "nor\t$rs, $rt, $imm"> ;
1780
1781 let hasDelaySlot = 1 in {
1782 def BneImm : MipsAsmPseudoInst<(outs GPR32Opnd:$rt),
1783 (ins imm64:$imm64, brtarget:$offset),
1784 "bne\t$rt, $imm64, $offset">;
1785 def BeqImm : MipsAsmPseudoInst<(outs GPR32Opnd:$rt),
1786 (ins imm64:$imm64, brtarget:$offset),
1787 "beq\t$rt, $imm64, $offset">;
1788
1789 class CondBranchPseudo<string instr_asm> :
1790 MipsAsmPseudoInst<(outs), (ins GPR32Opnd:$rs, GPR32Opnd:$rt,
1791 brtarget:$offset),
1792 !strconcat(instr_asm, "\t$rs, $rt, $offset")>;
1793 }
1794
1795 def BLT : CondBranchPseudo<"blt">;
1796 def BLE : CondBranchPseudo<"ble">;
1797 def BGE : CondBranchPseudo<"bge">;
1798 def BGT : CondBranchPseudo<"bgt">;
1799 def BLTU : CondBranchPseudo<"bltu">;
1800 def BLEU : CondBranchPseudo<"bleu">;
1801 def BGEU : CondBranchPseudo<"bgeu">;
1802 def BGTU : CondBranchPseudo<"bgtu">;
1803 def BLTL : CondBranchPseudo<"bltl">, ISA_MIPS2_NOT_32R6_64R6;
1804 def BLEL : CondBranchPseudo<"blel">, ISA_MIPS2_NOT_32R6_64R6;
1805 def BGEL : CondBranchPseudo<"bgel">, ISA_MIPS2_NOT_32R6_64R6;
1806 def BGTL : CondBranchPseudo<"bgtl">, ISA_MIPS2_NOT_32R6_64R6;
1807 def BLTUL: CondBranchPseudo<"bltul">, ISA_MIPS2_NOT_32R6_64R6;
1808 def BLEUL: CondBranchPseudo<"bleul">, ISA_MIPS2_NOT_32R6_64R6;
1809 def BGEUL: CondBranchPseudo<"bgeul">, ISA_MIPS2_NOT_32R6_64R6;
1810 def BGTUL: CondBranchPseudo<"bgtul">, ISA_MIPS2_NOT_32R6_64R6;
1811
1812 class CondBranchImmPseudo<string instr_asm> :
1813 MipsAsmPseudoInst<(outs), (ins GPR32Opnd:$rs, imm64:$imm, brtarget:$offset),
1814 !strconcat(instr_asm, "\t$rs, $imm, $offset")>;
1815
1816 def BLTImmMacro : CondBranchImmPseudo<"blt">;
1817 def BLEImmMacro : CondBranchImmPseudo<"ble">;
1818 def BGEImmMacro : CondBranchImmPseudo<"bge">;
1819 def BGTImmMacro : CondBranchImmPseudo<"bgt">;
1820 def BLTUImmMacro : CondBranchImmPseudo<"bltu">;
1821 def BLEUImmMacro : CondBranchImmPseudo<"bleu">;
1822 def BGEUImmMacro : CondBranchImmPseudo<"bgeu">;
1823 def BGTUImmMacro : CondBranchImmPseudo<"bgtu">;
1824 def BLTLImmMacro : CondBranchImmPseudo<"bltl">, ISA_MIPS2_NOT_32R6_64R6;
1825 def BLELImmMacro : CondBranchImmPseudo<"blel">, ISA_MIPS2_NOT_32R6_64R6;
1826 def BGELImmMacro : CondBranchImmPseudo<"bgel">, ISA_MIPS2_NOT_32R6_64R6;
1827 def BGTLImmMacro : CondBranchImmPseudo<"bgtl">, ISA_MIPS2_NOT_32R6_64R6;
1828 def BLTULImmMacro : CondBranchImmPseudo<"bltul">, ISA_MIPS2_NOT_32R6_64R6;
1829 def BLEULImmMacro : CondBranchImmPseudo<"bleul">, ISA_MIPS2_NOT_32R6_64R6;
1830 def BGEULImmMacro : CondBranchImmPseudo<"bgeul">, ISA_MIPS2_NOT_32R6_64R6;
1831 def BGTULImmMacro : CondBranchImmPseudo<"bgtul">, ISA_MIPS2_NOT_32R6_64R6;
1832
1833 // FIXME: Predicates are removed because instructions are matched regardless of
1834 // predicates, because PredicateControl was not in the hierarchy. This was
1835 // done to emit more precise error message from expansion function.
1836 // Once the tablegen-erated errors are made better, this needs to be fixed and
1837 // predicates needs to be restored.
1838
1839 def SDivMacro : MipsAsmPseudoInst<(outs), (ins GPR32Opnd:$rs, GPR32Opnd:$rt),
1840 "div\t$rs, $rt">; //, ISA_MIPS1_NOT_32R6_64R6;
1841
1842 def UDivMacro : MipsAsmPseudoInst<(outs), (ins GPR32Opnd:$rs, GPR32Opnd:$rt),
1843 "divu\t$rs, $rt">; //, ISA_MIPS1_NOT_32R6_64R6;
1844
1845 def DSDivMacro : MipsAsmPseudoInst<(outs), (ins GPR32Opnd:$rs, GPR32Opnd:$rt),
1846 "ddiv\t$rs, $rt">; //, ISA_MIPS64_NOT_64R6;
1847
1848 def DUDivMacro : MipsAsmPseudoInst<(outs), (ins GPR32Opnd:$rs, GPR32Opnd:$rt),
1849 "ddivu\t$rs, $rt">; //, ISA_MIPS64_NOT_64R6;
1850
1851 def Ulhu : MipsAsmPseudoInst<(outs GPR32Opnd:$rt), (ins mem:$addr),
1852 "ulhu\t$rt, $addr">; //, ISA_MIPS1_NOT_32R6_64R6;
1853
1854 def Ulw : MipsAsmPseudoInst<(outs GPR32Opnd:$rt), (ins mem:$addr),
1855 "ulw\t$rt, $addr">; //, ISA_MIPS1_NOT_32R6_64R6;
1659 1856
1660 //===----------------------------------------------------------------------===// 1857 //===----------------------------------------------------------------------===//
1661 // Arbitrary patterns that map to one or more instructions 1858 // Arbitrary patterns that map to one or more instructions
1662 //===----------------------------------------------------------------------===// 1859 //===----------------------------------------------------------------------===//
1663 1860
1757 def : WrapperPat<texternalsym, ADDiu, GPR32>; 1954 def : WrapperPat<texternalsym, ADDiu, GPR32>;
1758 def : WrapperPat<tblockaddress, ADDiu, GPR32>; 1955 def : WrapperPat<tblockaddress, ADDiu, GPR32>;
1759 def : WrapperPat<tjumptable, ADDiu, GPR32>; 1956 def : WrapperPat<tjumptable, ADDiu, GPR32>;
1760 def : WrapperPat<tglobaltlsaddr, ADDiu, GPR32>; 1957 def : WrapperPat<tglobaltlsaddr, ADDiu, GPR32>;
1761 1958
1959 let AdditionalPredicates = [NotInMicroMips] in {
1762 // Mips does not have "not", so we expand our way 1960 // Mips does not have "not", so we expand our way
1763 def : MipsPat<(not GPR32:$in), 1961 def : MipsPat<(not GPR32:$in),
1764 (NOR GPR32Opnd:$in, ZERO)>; 1962 (NOR GPR32Opnd:$in, ZERO)>;
1963 }
1765 1964
1766 // extended loads 1965 // extended loads
1767 def : MipsPat<(i32 (extloadi1 addr:$src)), (LBu addr:$src)>; 1966 def : MipsPat<(i32 (extloadi1 addr:$src)), (LBu addr:$src)>;
1768 def : MipsPat<(i32 (extloadi8 addr:$src)), (LBu addr:$src)>; 1967 def : MipsPat<(i32 (extloadi8 addr:$src)), (LBu addr:$src)>;
1769 def : MipsPat<(i32 (extloadi16 addr:$src)), (LHu addr:$src)>; 1968 def : MipsPat<(i32 (extloadi16 addr:$src)), (LHu addr:$src)>;
1892 2091
1893 // MSA 2092 // MSA
1894 include "MipsMSAInstrFormats.td" 2093 include "MipsMSAInstrFormats.td"
1895 include "MipsMSAInstrInfo.td" 2094 include "MipsMSAInstrInfo.td"
1896 2095
2096 // EVA
2097 include "MipsEVAInstrFormats.td"
2098 include "MipsEVAInstrInfo.td"
2099
1897 // Micromips 2100 // Micromips
1898 include "MicroMipsInstrFormats.td" 2101 include "MicroMipsInstrFormats.td"
1899 include "MicroMipsInstrInfo.td" 2102 include "MicroMipsInstrInfo.td"
1900 include "MicroMipsInstrFPU.td" 2103 include "MicroMipsInstrFPU.td"
2104
2105 // Micromips r6
2106 include "MicroMips32r6InstrFormats.td"
2107 include "MicroMips32r6InstrInfo.td"
2108
2109 // Micromips64 r6
2110 include "MicroMips64r6InstrFormats.td"
2111 include "MicroMips64r6InstrInfo.td"
2112
2113 // Micromips DSP
2114 include "MicroMipsDSPInstrFormats.td"
2115 include "MicroMipsDSPInstrInfo.td"