1//===- MipsInstrInfo.td - Target Description for Mips Target -*- tablegen -*-=// 2// 3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4// See https://llvm.org/LICENSE.txt for license information. 5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6// 7//===----------------------------------------------------------------------===// 8// 9// This file contains the Mips implementation of the TargetInstrInfo class. 10// 11//===----------------------------------------------------------------------===// 12 13 14//===----------------------------------------------------------------------===// 15// Mips profiles and nodes 16//===----------------------------------------------------------------------===// 17 18def SDT_MipsJmpLink : SDTypeProfile<0, 1, [SDTCisVT<0, iPTR>]>; 19def SDT_MipsCMov : SDTypeProfile<1, 4, [SDTCisSameAs<0, 1>, 20 SDTCisSameAs<1, 2>, 21 SDTCisSameAs<3, 4>, 22 SDTCisInt<4>]>; 23def SDT_MipsCallSeqStart : SDCallSeqStart<[SDTCisVT<0, i32>, SDTCisVT<1, i32>]>; 24def SDT_MipsCallSeqEnd : SDCallSeqEnd<[SDTCisVT<0, i32>, SDTCisVT<1, i32>]>; 25def SDT_MFLOHI : SDTypeProfile<1, 1, [SDTCisInt<0>, SDTCisVT<1, untyped>]>; 26def SDT_MTLOHI : SDTypeProfile<1, 2, [SDTCisVT<0, untyped>, 27 SDTCisInt<1>, SDTCisSameAs<1, 2>]>; 28def SDT_MipsMultDiv : SDTypeProfile<1, 2, [SDTCisVT<0, untyped>, SDTCisInt<1>, 29 SDTCisSameAs<1, 2>]>; 30def SDT_MipsMAddMSub : SDTypeProfile<1, 3, 31 [SDTCisVT<0, untyped>, SDTCisSameAs<0, 3>, 32 SDTCisVT<1, i32>, SDTCisSameAs<1, 2>]>; 33def SDT_MipsDivRem16 : SDTypeProfile<0, 2, [SDTCisInt<0>, SDTCisSameAs<0, 1>]>; 34 35def SDT_MipsThreadPointer : SDTypeProfile<1, 0, [SDTCisPtrTy<0>]>; 36 37def SDT_Sync : SDTypeProfile<0, 1, [SDTCisVT<0, i32>]>; 38 39def SDT_Ext : SDTypeProfile<1, 3, [SDTCisInt<0>, SDTCisSameAs<0, 1>, 40 SDTCisVT<2, i32>, SDTCisSameAs<2, 3>]>; 41def SDT_Ins : SDTypeProfile<1, 4, [SDTCisInt<0>, SDTCisSameAs<0, 1>, 42 SDTCisVT<2, i32>, SDTCisSameAs<2, 3>, 43 SDTCisSameAs<0, 4>]>; 44 45def SDTMipsLoadLR : SDTypeProfile<1, 2, 46 [SDTCisInt<0>, SDTCisPtrTy<1>, 47 SDTCisSameAs<0, 2>]>; 48 49// Call 50def MipsJmpLink : SDNode<"MipsISD::JmpLink",SDT_MipsJmpLink, 51 [SDNPHasChain, SDNPOutGlue, SDNPOptInGlue, 52 SDNPVariadic]>; 53 54// Tail call 55def MipsTailCall : SDNode<"MipsISD::TailCall", SDT_MipsJmpLink, 56 [SDNPHasChain, SDNPOptInGlue, SDNPVariadic]>; 57 58// Hi and Lo nodes are used to handle global addresses. Used on 59// MipsISelLowering to lower stuff like GlobalAddress, ExternalSymbol 60// static model. (nothing to do with Mips Registers Hi and Lo) 61 62// Hi is the odd node out, on MIPS64 it can expand to either daddiu when 63// using static relocations with 64 bit symbols, or lui when using 32 bit 64// symbols. 65def MipsHigher : SDNode<"MipsISD::Higher", SDTIntUnaryOp>; 66def MipsHighest : SDNode<"MipsISD::Highest", SDTIntUnaryOp>; 67def MipsHi : SDNode<"MipsISD::Hi", SDTIntUnaryOp>; 68def MipsLo : SDNode<"MipsISD::Lo", SDTIntUnaryOp>; 69 70def MipsGPRel : SDNode<"MipsISD::GPRel", SDTIntUnaryOp>; 71 72// Hi node for accessing the GOT. 73def MipsGotHi : SDNode<"MipsISD::GotHi", SDTIntUnaryOp>; 74 75// Hi node for handling TLS offsets 76def MipsTlsHi : SDNode<"MipsISD::TlsHi", SDTIntUnaryOp>; 77 78// Thread pointer 79def MipsThreadPointer: SDNode<"MipsISD::ThreadPointer", SDT_MipsThreadPointer>; 80 81// Return 82def MipsRet : SDNode<"MipsISD::Ret", SDTNone, 83 [SDNPHasChain, SDNPOptInGlue, SDNPVariadic]>; 84 85def MipsERet : SDNode<"MipsISD::ERet", SDTNone, 86 [SDNPHasChain, SDNPOptInGlue, SDNPSideEffect]>; 87 88// These are target-independent nodes, but have target-specific formats. 89def callseq_start : SDNode<"ISD::CALLSEQ_START", SDT_MipsCallSeqStart, 90 [SDNPHasChain, SDNPSideEffect, SDNPOutGlue]>; 91def callseq_end : SDNode<"ISD::CALLSEQ_END", SDT_MipsCallSeqEnd, 92 [SDNPHasChain, SDNPSideEffect, 93 SDNPOptInGlue, SDNPOutGlue]>; 94 95// Nodes used to extract LO/HI registers. 96def MipsMFHI : SDNode<"MipsISD::MFHI", SDT_MFLOHI>; 97def MipsMFLO : SDNode<"MipsISD::MFLO", SDT_MFLOHI>; 98 99// Node used to insert 32-bit integers to LOHI register pair. 100def MipsMTLOHI : SDNode<"MipsISD::MTLOHI", SDT_MTLOHI>; 101 102// Mult nodes. 103def MipsMult : SDNode<"MipsISD::Mult", SDT_MipsMultDiv>; 104def MipsMultu : SDNode<"MipsISD::Multu", SDT_MipsMultDiv>; 105 106// MAdd*/MSub* nodes 107def MipsMAdd : SDNode<"MipsISD::MAdd", SDT_MipsMAddMSub>; 108def MipsMAddu : SDNode<"MipsISD::MAddu", SDT_MipsMAddMSub>; 109def MipsMSub : SDNode<"MipsISD::MSub", SDT_MipsMAddMSub>; 110def MipsMSubu : SDNode<"MipsISD::MSubu", SDT_MipsMAddMSub>; 111 112// DivRem(u) nodes 113def MipsDivRem : SDNode<"MipsISD::DivRem", SDT_MipsMultDiv>; 114def MipsDivRemU : SDNode<"MipsISD::DivRemU", SDT_MipsMultDiv>; 115def MipsDivRem16 : SDNode<"MipsISD::DivRem16", SDT_MipsDivRem16, 116 [SDNPOutGlue]>; 117def MipsDivRemU16 : SDNode<"MipsISD::DivRemU16", SDT_MipsDivRem16, 118 [SDNPOutGlue]>; 119 120// Target constant nodes that are not part of any isel patterns and remain 121// unchanged can cause instructions with illegal operands to be emitted. 122// Wrapper node patterns give the instruction selector a chance to replace 123// target constant nodes that would otherwise remain unchanged with ADDiu 124// nodes. Without these wrapper node patterns, the following conditional move 125// instruction is emitted when function cmov2 in test/CodeGen/Mips/cmov.ll is 126// compiled: 127// movn %got(d)($gp), %got(c)($gp), $4 128// This instruction is illegal since movn can take only register operands. 129 130def MipsWrapper : SDNode<"MipsISD::Wrapper", SDTIntBinOp>; 131 132def MipsSync : SDNode<"MipsISD::Sync", SDT_Sync, [SDNPHasChain,SDNPSideEffect]>; 133 134def MipsExt : SDNode<"MipsISD::Ext", SDT_Ext>; 135def MipsIns : SDNode<"MipsISD::Ins", SDT_Ins>; 136def MipsCIns : SDNode<"MipsISD::CIns", SDT_Ext>; 137 138def MipsLWL : SDNode<"MipsISD::LWL", SDTMipsLoadLR, 139 [SDNPHasChain, SDNPMayLoad, SDNPMemOperand]>; 140def MipsLWR : SDNode<"MipsISD::LWR", SDTMipsLoadLR, 141 [SDNPHasChain, SDNPMayLoad, SDNPMemOperand]>; 142def MipsSWL : SDNode<"MipsISD::SWL", SDTStore, 143 [SDNPHasChain, SDNPMayStore, SDNPMemOperand]>; 144def MipsSWR : SDNode<"MipsISD::SWR", SDTStore, 145 [SDNPHasChain, SDNPMayStore, SDNPMemOperand]>; 146def MipsLDL : SDNode<"MipsISD::LDL", SDTMipsLoadLR, 147 [SDNPHasChain, SDNPMayLoad, SDNPMemOperand]>; 148def MipsLDR : SDNode<"MipsISD::LDR", SDTMipsLoadLR, 149 [SDNPHasChain, SDNPMayLoad, SDNPMemOperand]>; 150def MipsSDL : SDNode<"MipsISD::SDL", SDTStore, 151 [SDNPHasChain, SDNPMayStore, SDNPMemOperand]>; 152def MipsSDR : SDNode<"MipsISD::SDR", SDTStore, 153 [SDNPHasChain, SDNPMayStore, SDNPMemOperand]>; 154 155//===----------------------------------------------------------------------===// 156// Mips Instruction Predicate Definitions. 157//===----------------------------------------------------------------------===// 158def HasMips2 : Predicate<"Subtarget->hasMips2()">, 159 AssemblerPredicate<"FeatureMips2">; 160def HasMips3_32 : Predicate<"Subtarget->hasMips3_32()">, 161 AssemblerPredicate<"FeatureMips3_32">; 162def HasMips3_32r2 : Predicate<"Subtarget->hasMips3_32r2()">, 163 AssemblerPredicate<"FeatureMips3_32r2">; 164def HasMips3 : Predicate<"Subtarget->hasMips3()">, 165 AssemblerPredicate<"FeatureMips3">; 166def NotMips3 : Predicate<"!Subtarget->hasMips3()">, 167 AssemblerPredicate<"!FeatureMips3">; 168def HasMips4_32 : Predicate<"Subtarget->hasMips4_32()">, 169 AssemblerPredicate<"FeatureMips4_32">; 170def NotMips4_32 : Predicate<"!Subtarget->hasMips4_32()">, 171 AssemblerPredicate<"!FeatureMips4_32">; 172def HasMips4_32r2 : Predicate<"Subtarget->hasMips4_32r2()">, 173 AssemblerPredicate<"FeatureMips4_32r2">; 174def HasMips5_32r2 : Predicate<"Subtarget->hasMips5_32r2()">, 175 AssemblerPredicate<"FeatureMips5_32r2">; 176def HasMips32 : Predicate<"Subtarget->hasMips32()">, 177 AssemblerPredicate<"FeatureMips32">; 178def HasMips32r2 : Predicate<"Subtarget->hasMips32r2()">, 179 AssemblerPredicate<"FeatureMips32r2">; 180def HasMips32r5 : Predicate<"Subtarget->hasMips32r5()">, 181 AssemblerPredicate<"FeatureMips32r5">; 182def HasMips32r6 : Predicate<"Subtarget->hasMips32r6()">, 183 AssemblerPredicate<"FeatureMips32r6">; 184def NotMips32r6 : Predicate<"!Subtarget->hasMips32r6()">, 185 AssemblerPredicate<"!FeatureMips32r6">; 186def IsGP64bit : Predicate<"Subtarget->isGP64bit()">, 187 AssemblerPredicate<"FeatureGP64Bit">; 188def IsGP32bit : Predicate<"!Subtarget->isGP64bit()">, 189 AssemblerPredicate<"!FeatureGP64Bit">; 190def IsPTR64bit : Predicate<"Subtarget->isABI_N64()">, 191 AssemblerPredicate<"FeaturePTR64Bit">; 192def IsPTR32bit : Predicate<"!Subtarget->isABI_N64()">, 193 AssemblerPredicate<"!FeaturePTR64Bit">; 194def HasMips64 : Predicate<"Subtarget->hasMips64()">, 195 AssemblerPredicate<"FeatureMips64">; 196def NotMips64 : Predicate<"!Subtarget->hasMips64()">, 197 AssemblerPredicate<"!FeatureMips64">; 198def HasMips64r2 : Predicate<"Subtarget->hasMips64r2()">, 199 AssemblerPredicate<"FeatureMips64r2">; 200def HasMips64r5 : Predicate<"Subtarget->hasMips64r5()">, 201 AssemblerPredicate<"FeatureMips64r5">; 202def HasMips64r6 : Predicate<"Subtarget->hasMips64r6()">, 203 AssemblerPredicate<"FeatureMips64r6">; 204def NotMips64r6 : Predicate<"!Subtarget->hasMips64r6()">, 205 AssemblerPredicate<"!FeatureMips64r6">; 206def InMips16Mode : Predicate<"Subtarget->inMips16Mode()">, 207 AssemblerPredicate<"FeatureMips16">; 208def NotInMips16Mode : Predicate<"!Subtarget->inMips16Mode()">, 209 AssemblerPredicate<"!FeatureMips16">; 210def HasCnMips : Predicate<"Subtarget->hasCnMips()">, 211 AssemblerPredicate<"FeatureCnMips">; 212def NotCnMips : Predicate<"!Subtarget->hasCnMips()">, 213 AssemblerPredicate<"!FeatureCnMips">; 214def IsSym32 : Predicate<"Subtarget->hasSym32()">, 215 AssemblerPredicate<"FeatureSym32">; 216def IsSym64 : Predicate<"!Subtarget->hasSym32()">, 217 AssemblerPredicate<"!FeatureSym32">; 218def IsN64 : Predicate<"Subtarget->isABI_N64()">; 219def IsNotN64 : Predicate<"!Subtarget->isABI_N64()">; 220def RelocNotPIC : Predicate<"!TM.isPositionIndependent()">; 221def RelocPIC : Predicate<"TM.isPositionIndependent()">; 222def NoNaNsFPMath : Predicate<"TM.Options.NoNaNsFPMath">; 223def UseAbs : Predicate<"Subtarget->inAbs2008Mode() ||" 224 "TM.Options.NoNaNsFPMath">; 225def HasStdEnc : Predicate<"Subtarget->hasStandardEncoding()">, 226 AssemblerPredicate<"!FeatureMips16">; 227def NotDSP : Predicate<"!Subtarget->hasDSP()">; 228def InMicroMips : Predicate<"Subtarget->inMicroMipsMode()">, 229 AssemblerPredicate<"FeatureMicroMips">; 230def NotInMicroMips : Predicate<"!Subtarget->inMicroMipsMode()">, 231 AssemblerPredicate<"!FeatureMicroMips">; 232def IsLE : Predicate<"Subtarget->isLittle()">; 233def IsBE : Predicate<"!Subtarget->isLittle()">; 234def IsNotNaCl : Predicate<"!Subtarget->isTargetNaCl()">; 235def UseTCCInDIV : AssemblerPredicate<"FeatureUseTCCInDIV">; 236def HasEVA : Predicate<"Subtarget->hasEVA()">, 237 AssemblerPredicate<"FeatureEVA">; 238def HasMSA : Predicate<"Subtarget->hasMSA()">, 239 AssemblerPredicate<"FeatureMSA">; 240def HasMadd4 : Predicate<"!Subtarget->disableMadd4()">, 241 AssemblerPredicate<"!FeatureMadd4">; 242def HasMT : Predicate<"Subtarget->hasMT()">, 243 AssemblerPredicate<"FeatureMT">; 244def UseIndirectJumpsHazard : Predicate<"Subtarget->useIndirectJumpsHazard()">, 245 AssemblerPredicate<"FeatureUseIndirectJumpsHazard">; 246def NoIndirectJumpGuards : Predicate<"!Subtarget->useIndirectJumpsHazard()">, 247 AssemblerPredicate<"!FeatureUseIndirectJumpsHazard">; 248def HasCRC : Predicate<"Subtarget->hasCRC()">, 249 AssemblerPredicate<"FeatureCRC">; 250def HasVirt : Predicate<"Subtarget->hasVirt()">, 251 AssemblerPredicate<"FeatureVirt">; 252def HasGINV : Predicate<"Subtarget->hasGINV()">, 253 AssemblerPredicate<"FeatureGINV">; 254// TODO: Add support for FPOpFusion::Standard 255def AllowFPOpFusion : Predicate<"TM.Options.AllowFPOpFusion ==" 256 " FPOpFusion::Fast">; 257//===----------------------------------------------------------------------===// 258// Mips GPR size adjectives. 259// They are mutually exclusive. 260//===----------------------------------------------------------------------===// 261 262class GPR_32 { list<Predicate> GPRPredicates = [IsGP32bit]; } 263class GPR_64 { list<Predicate> GPRPredicates = [IsGP64bit]; } 264 265class PTR_32 { list<Predicate> PTRPredicates = [IsPTR32bit]; } 266class PTR_64 { list<Predicate> PTRPredicates = [IsPTR64bit]; } 267 268//===----------------------------------------------------------------------===// 269// Mips Symbol size adjectives. 270// They are mutally exculsive. 271//===----------------------------------------------------------------------===// 272 273class SYM_32 { list<Predicate> SYMPredicates = [IsSym32]; } 274class SYM_64 { list<Predicate> SYMPredicates = [IsSym64]; } 275 276//===----------------------------------------------------------------------===// 277// Mips ISA/ASE membership and instruction group membership adjectives. 278// They are mutually exclusive. 279//===----------------------------------------------------------------------===// 280 281// FIXME: I'd prefer to use additive predicates to build the instruction sets 282// but we are short on assembler feature bits at the moment. Using a 283// subtractive predicate will hopefully keep us under the 32 predicate 284// limit long enough to develop an alternative way to handle P1||P2 285// predicates. 286class ISA_MIPS1 { 287 list<Predicate> EncodingPredicates = [HasStdEnc]; 288} 289class ISA_MIPS1_NOT_MIPS3 { 290 list<Predicate> InsnPredicates = [NotMips3]; 291 list<Predicate> EncodingPredicates = [HasStdEnc]; 292} 293class ISA_MIPS1_NOT_4_32 { 294 list<Predicate> InsnPredicates = [NotMips4_32]; 295 list<Predicate> EncodingPredicates = [HasStdEnc]; 296} 297class ISA_MIPS1_NOT_32R6_64R6 { 298 list<Predicate> InsnPredicates = [NotMips32r6, NotMips64r6]; 299 list<Predicate> EncodingPredicates = [HasStdEnc]; 300} 301class ISA_MIPS2 { 302 list<Predicate> InsnPredicates = [HasMips2]; 303 list<Predicate> EncodingPredicates = [HasStdEnc]; 304} 305class ISA_MIPS2_NOT_32R6_64R6 { 306 list<Predicate> InsnPredicates = [HasMips2, NotMips32r6, NotMips64r6]; 307 list<Predicate> EncodingPredicates = [HasStdEnc]; 308} 309class ISA_MIPS3 { 310 list<Predicate> InsnPredicates = [HasMips3]; 311 list<Predicate> EncodingPredicates = [HasStdEnc]; 312} 313class ISA_MIPS3_NOT_32R6_64R6 { 314 list<Predicate> InsnPredicates = [HasMips3, NotMips32r6, NotMips64r6]; 315 list<Predicate> EncodingPredicates = [HasStdEnc]; 316} 317class ISA_MIPS32 { 318 list<Predicate> InsnPredicates = [HasMips32]; 319 list<Predicate> EncodingPredicates = [HasStdEnc]; 320} 321class ISA_MIPS32_NOT_32R6_64R6 { 322 list<Predicate> InsnPredicates = [HasMips32, NotMips32r6, NotMips64r6]; 323 list<Predicate> EncodingPredicates = [HasStdEnc]; 324} 325class ISA_MIPS32R2 { 326 list<Predicate> InsnPredicates = [HasMips32r2]; 327 list<Predicate> EncodingPredicates = [HasStdEnc]; 328} 329class ISA_MIPS32R2_NOT_32R6_64R6 { 330 list<Predicate> InsnPredicates = [HasMips32r2, NotMips32r6, NotMips64r6]; 331 list<Predicate> EncodingPredicates = [HasStdEnc]; 332} 333class ISA_MIPS32R5 { 334 list<Predicate> InsnPredicates = [HasMips32r5]; 335 list<Predicate> EncodingPredicates = [HasStdEnc]; 336} 337class ISA_MIPS64 { 338 list<Predicate> InsnPredicates = [HasMips64]; 339 list<Predicate> EncodingPredicates = [HasStdEnc]; 340} 341class ISA_MIPS64_NOT_64R6 { 342 list<Predicate> InsnPredicates = [HasMips64, NotMips64r6]; 343 list<Predicate> EncodingPredicates = [HasStdEnc]; 344} 345class ISA_MIPS64R2 { 346 list<Predicate> InsnPredicates = [HasMips64r2]; 347 list<Predicate> EncodingPredicates = [HasStdEnc]; 348} 349class ISA_MIPS64R5 { 350 list<Predicate> InsnPredicates = [HasMips64r5]; 351 list<Predicate> EncodingPredicates = [HasStdEnc]; 352} 353class ISA_MIPS32R6 { 354 list<Predicate> InsnPredicates = [HasMips32r6]; 355 list<Predicate> EncodingPredicates = [HasStdEnc]; 356} 357class ISA_MIPS64R6 { 358 list<Predicate> InsnPredicates = [HasMips64r6]; 359 list<Predicate> EncodingPredicates = [HasStdEnc]; 360} 361class ISA_MICROMIPS { 362 list<Predicate> EncodingPredicates = [InMicroMips]; 363} 364class ISA_MICROMIPS32R5 { 365 list<Predicate> InsnPredicates = [HasMips32r5]; 366 list<Predicate> EncodingPredicates = [InMicroMips]; 367} 368class ISA_MICROMIPS32R6 { 369 list<Predicate> InsnPredicates = [HasMips32r6]; 370 list<Predicate> EncodingPredicates = [InMicroMips]; 371} 372class ISA_MICROMIPS64R6 { 373 list<Predicate> InsnPredicates = [HasMips64r6]; 374 list<Predicate> EncodingPredicates = [InMicroMips]; 375} 376class ISA_MICROMIPS32_NOT_MIPS32R6 { 377 list<Predicate> InsnPredicates = [NotMips32r6]; 378 list<Predicate> EncodingPredicates = [InMicroMips]; 379} 380class ASE_EVA { list<Predicate> ASEPredicate = [HasEVA]; } 381 382// The portions of MIPS-III that were also added to MIPS32 383class INSN_MIPS3_32 { 384 list<Predicate> InsnPredicates = [HasMips3_32]; 385 list<Predicate> EncodingPredicates = [HasStdEnc]; 386} 387 388// The portions of MIPS-III that were also added to MIPS32 but were removed in 389// MIPS32r6 and MIPS64r6. 390class INSN_MIPS3_32_NOT_32R6_64R6 { 391 list<Predicate> InsnPredicates = [HasMips3_32, NotMips32r6, NotMips64r6]; 392 list<Predicate> EncodingPredicates = [HasStdEnc]; 393} 394 395// The portions of MIPS-III that were also added to MIPS32 396class INSN_MIPS3_32R2 { 397 list<Predicate> InsnPredicates = [HasMips3_32r2]; 398 list<Predicate> EncodingPredicates = [HasStdEnc]; 399} 400 401// The portions of MIPS-IV that were also added to MIPS32. 402class INSN_MIPS4_32 { 403 list <Predicate> InsnPredicates = [HasMips4_32]; 404 list<Predicate> EncodingPredicates = [HasStdEnc]; 405} 406 407// The portions of MIPS-IV that were also added to MIPS32 but were removed in 408// MIPS32r6 and MIPS64r6. 409class INSN_MIPS4_32_NOT_32R6_64R6 { 410 list<Predicate> InsnPredicates = [HasMips4_32, NotMips32r6, NotMips64r6]; 411 list<Predicate> EncodingPredicates = [HasStdEnc]; 412} 413 414// The portions of MIPS-IV that were also added to MIPS32r2 but were removed in 415// MIPS32r6 and MIPS64r6. 416class INSN_MIPS4_32R2_NOT_32R6_64R6 { 417 list<Predicate> InsnPredicates = [HasMips4_32r2, NotMips32r6, NotMips64r6]; 418 list<Predicate> EncodingPredicates = [HasStdEnc]; 419} 420 421// The portions of MIPS-IV that were also added to MIPS32r2. 422class INSN_MIPS4_32R2 { 423 list<Predicate> InsnPredicates = [HasMips4_32r2]; 424 list<Predicate> EncodingPredicates = [HasStdEnc]; 425} 426 427// The portions of MIPS-V that were also added to MIPS32r2 but were removed in 428// MIPS32r6 and MIPS64r6. 429class INSN_MIPS5_32R2_NOT_32R6_64R6 { 430 list<Predicate> InsnPredicates = [HasMips5_32r2, NotMips32r6, NotMips64r6]; 431 list<Predicate> EncodingPredicates = [HasStdEnc]; 432} 433 434class ASE_CNMIPS { 435 list<Predicate> ASEPredicate = [HasCnMips]; 436} 437 438class NOT_ASE_CNMIPS { 439 list<Predicate> ASEPredicate = [NotCnMips]; 440} 441 442class ASE_MIPS64_CNMIPS { 443 list<Predicate> ASEPredicate = [HasMips64, HasCnMips]; 444} 445 446class ASE_MSA { 447 list<Predicate> ASEPredicate = [HasMSA]; 448} 449 450class ASE_MSA_NOT_MSA64 { 451 list<Predicate> ASEPredicate = [HasMSA, NotMips64]; 452} 453 454class ASE_MSA64 { 455 list<Predicate> ASEPredicate = [HasMSA, HasMips64]; 456} 457 458class ASE_MT { 459 list <Predicate> ASEPredicate = [HasMT]; 460} 461 462class ASE_CRC { 463 list <Predicate> ASEPredicate = [HasCRC]; 464} 465 466class ASE_VIRT { 467 list <Predicate> ASEPredicate = [HasVirt]; 468} 469 470class ASE_GINV { 471 list <Predicate> ASEPredicate = [HasGINV]; 472} 473 474// Class used for separating microMIPSr6 and microMIPS (r3) instruction. 475// It can be used only on instructions that doesn't inherit PredicateControl. 476class ISA_MICROMIPS_NOT_32R6 : PredicateControl { 477 let InsnPredicates = [NotMips32r6]; 478 let EncodingPredicates = [InMicroMips]; 479} 480 481class ASE_NOT_DSP { 482 list<Predicate> ASEPredicate = [NotDSP]; 483} 484 485class MADD4 { 486 list<Predicate> AdditionalPredicates = [HasMadd4]; 487} 488 489// Classses used for separating expansions that differ based on the ABI in 490// use. 491class ABI_N64 { 492 list<Predicate> AdditionalPredicates = [IsN64]; 493} 494 495class ABI_NOT_N64 { 496 list<Predicate> AdditionalPredicates = [IsNotN64]; 497} 498 499class FPOP_FUSION_FAST { 500 list <Predicate> AdditionalPredicates = [AllowFPOpFusion]; 501} 502 503//===----------------------------------------------------------------------===// 504 505class MipsPat<dag pattern, dag result> : Pat<pattern, result>, PredicateControl; 506 507class MipsInstAlias<string Asm, dag Result, bit Emit = 0b1> : 508 InstAlias<Asm, Result, Emit>, PredicateControl; 509 510class IsCommutable { 511 bit isCommutable = 1; 512} 513 514class IsBranch { 515 bit isBranch = 1; 516 bit isCTI = 1; 517} 518 519class IsReturn { 520 bit isReturn = 1; 521 bit isCTI = 1; 522} 523 524class IsCall { 525 bit isCall = 1; 526 bit isCTI = 1; 527} 528 529class IsTailCall { 530 bit isCall = 1; 531 bit isTerminator = 1; 532 bit isReturn = 1; 533 bit isBarrier = 1; 534 bit hasExtraSrcRegAllocReq = 1; 535 bit isCodeGenOnly = 1; 536 bit isCTI = 1; 537} 538 539class IsAsCheapAsAMove { 540 bit isAsCheapAsAMove = 1; 541} 542 543class NeverHasSideEffects { 544 bit hasSideEffects = 0; 545} 546 547//===----------------------------------------------------------------------===// 548// Instruction format superclass 549//===----------------------------------------------------------------------===// 550 551include "MipsInstrFormats.td" 552 553//===----------------------------------------------------------------------===// 554// Mips Operand, Complex Patterns and Transformations Definitions. 555//===----------------------------------------------------------------------===// 556 557class ConstantSImmAsmOperandClass<int Bits, list<AsmOperandClass> Supers = [], 558 int Offset = 0> : AsmOperandClass { 559 let Name = "ConstantSImm" # Bits # "_" # Offset; 560 let RenderMethod = "addConstantSImmOperands<" # Bits # ", " # Offset # ">"; 561 let PredicateMethod = "isConstantSImm<" # Bits # ", " # Offset # ">"; 562 let SuperClasses = Supers; 563 let DiagnosticType = "SImm" # Bits # "_" # Offset; 564} 565 566class SimmLslAsmOperandClass<int Bits, list<AsmOperandClass> Supers = [], 567 int Shift = 0> : AsmOperandClass { 568 let Name = "Simm" # Bits # "_Lsl" # Shift; 569 let RenderMethod = "addImmOperands"; 570 let PredicateMethod = "isScaledSImm<" # Bits # ", " # Shift # ">"; 571 let SuperClasses = Supers; 572 let DiagnosticType = "SImm" # Bits # "_Lsl" # Shift; 573} 574 575class ConstantUImmAsmOperandClass<int Bits, list<AsmOperandClass> Supers = [], 576 int Offset = 0> : AsmOperandClass { 577 let Name = "ConstantUImm" # Bits # "_" # Offset; 578 let RenderMethod = "addConstantUImmOperands<" # Bits # ", " # Offset # ">"; 579 let PredicateMethod = "isConstantUImm<" # Bits # ", " # Offset # ">"; 580 let SuperClasses = Supers; 581 let DiagnosticType = "UImm" # Bits # "_" # Offset; 582} 583 584class ConstantUImmRangeAsmOperandClass<int Bottom, int Top, 585 list<AsmOperandClass> Supers = []> 586 : AsmOperandClass { 587 let Name = "ConstantUImmRange" # Bottom # "_" # Top; 588 let RenderMethod = "addImmOperands"; 589 let PredicateMethod = "isConstantUImmRange<" # Bottom # ", " # Top # ">"; 590 let SuperClasses = Supers; 591 let DiagnosticType = "UImmRange" # Bottom # "_" # Top; 592} 593 594class SImmAsmOperandClass<int Bits, list<AsmOperandClass> Supers = []> 595 : AsmOperandClass { 596 let Name = "SImm" # Bits; 597 let RenderMethod = "addSImmOperands<" # Bits # ">"; 598 let PredicateMethod = "isSImm<" # Bits # ">"; 599 let SuperClasses = Supers; 600 let DiagnosticType = "SImm" # Bits; 601} 602 603class UImmAsmOperandClass<int Bits, list<AsmOperandClass> Supers = []> 604 : AsmOperandClass { 605 let Name = "UImm" # Bits; 606 let RenderMethod = "addUImmOperands<" # Bits # ">"; 607 let PredicateMethod = "isUImm<" # Bits # ">"; 608 let SuperClasses = Supers; 609 let DiagnosticType = "UImm" # Bits; 610} 611 612// Generic case - only to support certain assembly pseudo instructions. 613class UImmAnyAsmOperandClass<int Bits, list<AsmOperandClass> Supers = []> 614 : AsmOperandClass { 615 let Name = "ImmAny"; 616 let RenderMethod = "addConstantUImmOperands<32>"; 617 let PredicateMethod = "isSImm<" # Bits # ">"; 618 let SuperClasses = Supers; 619 let DiagnosticType = "ImmAny"; 620} 621 622// AsmOperandClasses require a strict ordering which is difficult to manage 623// as a hierarchy. Instead, we use a linear ordering and impose an order that 624// is in some places arbitrary. 625// 626// Here the rules that are in use: 627// * Wider immediates are a superset of narrower immediates: 628// uimm4 < uimm5 < uimm6 629// * For the same bit-width, unsigned immediates are a superset of signed 630// immediates:: 631// simm4 < uimm4 < simm5 < uimm5 632// * For the same upper-bound, signed immediates are a superset of unsigned 633// immediates: 634// uimm3 < simm4 < uimm4 < simm4 635// * Modified immediates are a superset of ordinary immediates: 636// uimm5 < uimm5_plus1 (1..32) < uimm5_plus32 (32..63) < uimm6 637// The term 'superset' starts to break down here since the uimm5_plus* classes 638// are not true supersets of uimm5 (but they are still subsets of uimm6). 639// * 'Relaxed' immediates are supersets of the corresponding unsigned immediate. 640// uimm16 < uimm16_relaxed 641// * The codeGen pattern type is arbitrarily ordered. 642// uimm5 < uimm5_64, and uimm5 < vsplat_uimm5 643// This is entirely arbitrary. We need an ordering and what we pick is 644// unimportant since only one is possible for a given mnemonic. 645 646def UImm32CoercedAsmOperandClass : UImmAnyAsmOperandClass<33, []> { 647 let Name = "UImm32_Coerced"; 648 let DiagnosticType = "UImm32_Coerced"; 649} 650def SImm32RelaxedAsmOperandClass 651 : SImmAsmOperandClass<32, [UImm32CoercedAsmOperandClass]> { 652 let Name = "SImm32_Relaxed"; 653 let PredicateMethod = "isAnyImm<33>"; 654 let DiagnosticType = "SImm32_Relaxed"; 655} 656def SImm32AsmOperandClass 657 : SImmAsmOperandClass<32, [SImm32RelaxedAsmOperandClass]>; 658def ConstantUImm26AsmOperandClass 659 : ConstantUImmAsmOperandClass<26, [SImm32AsmOperandClass]>; 660def ConstantUImm20AsmOperandClass 661 : ConstantUImmAsmOperandClass<20, [ConstantUImm26AsmOperandClass]>; 662def ConstantSImm19Lsl2AsmOperandClass : AsmOperandClass { 663 let Name = "SImm19Lsl2"; 664 let RenderMethod = "addImmOperands"; 665 let PredicateMethod = "isScaledSImm<19, 2>"; 666 let SuperClasses = [ConstantUImm20AsmOperandClass]; 667 let DiagnosticType = "SImm19_Lsl2"; 668} 669def UImm16RelaxedAsmOperandClass 670 : UImmAsmOperandClass<16, [ConstantUImm20AsmOperandClass]> { 671 let Name = "UImm16_Relaxed"; 672 let PredicateMethod = "isAnyImm<16>"; 673 let DiagnosticType = "UImm16_Relaxed"; 674} 675// Similar to the relaxed classes which take an SImm and render it as 676// an UImm, this takes a UImm and renders it as an SImm. 677def UImm16AltRelaxedAsmOperandClass 678 : SImmAsmOperandClass<16, [UImm16RelaxedAsmOperandClass]> { 679 let Name = "UImm16_AltRelaxed"; 680 let PredicateMethod = "isUImm<16>"; 681 let DiagnosticType = "UImm16_AltRelaxed"; 682} 683// FIXME: One of these should probably have UImm16AsmOperandClass as the 684// superclass instead of UImm16RelaxedasmOPerandClass. 685def UImm16AsmOperandClass 686 : UImmAsmOperandClass<16, [UImm16RelaxedAsmOperandClass]>; 687def SImm16RelaxedAsmOperandClass 688 : SImmAsmOperandClass<16, [UImm16RelaxedAsmOperandClass]> { 689 let Name = "SImm16_Relaxed"; 690 let PredicateMethod = "isAnyImm<16>"; 691 let DiagnosticType = "SImm16_Relaxed"; 692} 693def SImm16AsmOperandClass 694 : SImmAsmOperandClass<16, [SImm16RelaxedAsmOperandClass]>; 695def ConstantSImm10Lsl3AsmOperandClass : AsmOperandClass { 696 let Name = "SImm10Lsl3"; 697 let RenderMethod = "addImmOperands"; 698 let PredicateMethod = "isScaledSImm<10, 3>"; 699 let SuperClasses = [SImm16AsmOperandClass]; 700 let DiagnosticType = "SImm10_Lsl3"; 701} 702def ConstantSImm10Lsl2AsmOperandClass : AsmOperandClass { 703 let Name = "SImm10Lsl2"; 704 let RenderMethod = "addImmOperands"; 705 let PredicateMethod = "isScaledSImm<10, 2>"; 706 let SuperClasses = [ConstantSImm10Lsl3AsmOperandClass]; 707 let DiagnosticType = "SImm10_Lsl2"; 708} 709def ConstantSImm11AsmOperandClass 710 : ConstantSImmAsmOperandClass<11, [ConstantSImm10Lsl2AsmOperandClass]>; 711def ConstantSImm10Lsl1AsmOperandClass : AsmOperandClass { 712 let Name = "SImm10Lsl1"; 713 let RenderMethod = "addImmOperands"; 714 let PredicateMethod = "isScaledSImm<10, 1>"; 715 let SuperClasses = [ConstantSImm11AsmOperandClass]; 716 let DiagnosticType = "SImm10_Lsl1"; 717} 718def ConstantUImm10AsmOperandClass 719 : ConstantUImmAsmOperandClass<10, [ConstantSImm10Lsl1AsmOperandClass]>; 720def ConstantSImm10AsmOperandClass 721 : ConstantSImmAsmOperandClass<10, [ConstantUImm10AsmOperandClass]>; 722def ConstantSImm9AsmOperandClass 723 : ConstantSImmAsmOperandClass<9, [ConstantSImm10AsmOperandClass]>; 724def ConstantSImm7Lsl2AsmOperandClass : AsmOperandClass { 725 let Name = "SImm7Lsl2"; 726 let RenderMethod = "addImmOperands"; 727 let PredicateMethod = "isScaledSImm<7, 2>"; 728 let SuperClasses = [ConstantSImm9AsmOperandClass]; 729 let DiagnosticType = "SImm7_Lsl2"; 730} 731def ConstantUImm8AsmOperandClass 732 : ConstantUImmAsmOperandClass<8, [ConstantSImm7Lsl2AsmOperandClass]>; 733def ConstantUImm7Sub1AsmOperandClass 734 : ConstantUImmAsmOperandClass<7, [ConstantUImm8AsmOperandClass], -1> { 735 // Specify the names since the -1 offset causes invalid identifiers otherwise. 736 let Name = "UImm7_N1"; 737 let DiagnosticType = "UImm7_N1"; 738} 739def ConstantUImm7AsmOperandClass 740 : ConstantUImmAsmOperandClass<7, [ConstantUImm7Sub1AsmOperandClass]>; 741def ConstantUImm6Lsl2AsmOperandClass : AsmOperandClass { 742 let Name = "UImm6Lsl2"; 743 let RenderMethod = "addImmOperands"; 744 let PredicateMethod = "isScaledUImm<6, 2>"; 745 let SuperClasses = [ConstantUImm7AsmOperandClass]; 746 let DiagnosticType = "UImm6_Lsl2"; 747} 748def ConstantUImm6AsmOperandClass 749 : ConstantUImmAsmOperandClass<6, [ConstantUImm6Lsl2AsmOperandClass]>; 750def ConstantSImm6AsmOperandClass 751 : ConstantSImmAsmOperandClass<6, [ConstantUImm6AsmOperandClass]>; 752def ConstantUImm5Lsl2AsmOperandClass : AsmOperandClass { 753 let Name = "UImm5Lsl2"; 754 let RenderMethod = "addImmOperands"; 755 let PredicateMethod = "isScaledUImm<5, 2>"; 756 let SuperClasses = [ConstantSImm6AsmOperandClass]; 757 let DiagnosticType = "UImm5_Lsl2"; 758} 759def ConstantUImm5_Range2_64AsmOperandClass 760 : ConstantUImmRangeAsmOperandClass<2, 64, [ConstantUImm5Lsl2AsmOperandClass]>; 761def ConstantUImm5Plus33AsmOperandClass 762 : ConstantUImmAsmOperandClass<5, [ConstantUImm5_Range2_64AsmOperandClass], 763 33>; 764def ConstantUImm5ReportUImm6AsmOperandClass 765 : ConstantUImmAsmOperandClass<5, [ConstantUImm5Plus33AsmOperandClass]> { 766 let Name = "ConstantUImm5_0_Report_UImm6"; 767 let DiagnosticType = "UImm5_0_Report_UImm6"; 768} 769def ConstantUImm5Plus32AsmOperandClass 770 : ConstantUImmAsmOperandClass< 771 5, [ConstantUImm5ReportUImm6AsmOperandClass], 32>; 772def ConstantUImm5Plus32NormalizeAsmOperandClass 773 : ConstantUImmAsmOperandClass<5, [ConstantUImm5Plus32AsmOperandClass], 32> { 774 let Name = "ConstantUImm5_32_Norm"; 775 // We must also subtract 32 when we render the operand. 776 let RenderMethod = "addConstantUImmOperands<5, 32, -32>"; 777} 778def ConstantUImm5Plus1ReportUImm6AsmOperandClass 779 : ConstantUImmAsmOperandClass< 780 5, [ConstantUImm5Plus32NormalizeAsmOperandClass], 1>{ 781 let Name = "ConstantUImm5_Plus1_Report_UImm6"; 782} 783def ConstantUImm5Plus1AsmOperandClass 784 : ConstantUImmAsmOperandClass< 785 5, [ConstantUImm5Plus1ReportUImm6AsmOperandClass], 1>; 786def ConstantUImm5AsmOperandClass 787 : ConstantUImmAsmOperandClass<5, [ConstantUImm5Plus1AsmOperandClass]>; 788def ConstantSImm5AsmOperandClass 789 : ConstantSImmAsmOperandClass<5, [ConstantUImm5AsmOperandClass]>; 790def ConstantUImm4AsmOperandClass 791 : ConstantUImmAsmOperandClass<4, [ConstantSImm5AsmOperandClass]>; 792def ConstantSImm4AsmOperandClass 793 : ConstantSImmAsmOperandClass<4, [ConstantUImm4AsmOperandClass]>; 794def ConstantUImm3AsmOperandClass 795 : ConstantUImmAsmOperandClass<3, [ConstantSImm4AsmOperandClass]>; 796def ConstantUImm2Plus1AsmOperandClass 797 : ConstantUImmAsmOperandClass<2, [ConstantUImm3AsmOperandClass], 1>; 798def ConstantUImm2AsmOperandClass 799 : ConstantUImmAsmOperandClass<2, [ConstantUImm3AsmOperandClass]>; 800def ConstantUImm1AsmOperandClass 801 : ConstantUImmAsmOperandClass<1, [ConstantUImm2AsmOperandClass]>; 802def ConstantImmzAsmOperandClass : AsmOperandClass { 803 let Name = "ConstantImmz"; 804 let RenderMethod = "addConstantUImmOperands<1>"; 805 let PredicateMethod = "isConstantImmz"; 806 let SuperClasses = [ConstantUImm1AsmOperandClass]; 807 let DiagnosticType = "Immz"; 808} 809 810def Simm19Lsl2AsmOperand 811 : SimmLslAsmOperandClass<19, [], 2>; 812 813def MipsJumpTargetAsmOperand : AsmOperandClass { 814 let Name = "JumpTarget"; 815 let ParserMethod = "parseJumpTarget"; 816 let PredicateMethod = "isImm"; 817 let RenderMethod = "addImmOperands"; 818} 819 820// Instruction operand types 821def jmptarget : Operand<OtherVT> { 822 let EncoderMethod = "getJumpTargetOpValue"; 823 let ParserMatchClass = MipsJumpTargetAsmOperand; 824} 825def brtarget : Operand<OtherVT> { 826 let EncoderMethod = "getBranchTargetOpValue"; 827 let OperandType = "OPERAND_PCREL"; 828 let DecoderMethod = "DecodeBranchTarget"; 829 let ParserMatchClass = MipsJumpTargetAsmOperand; 830} 831def brtarget1SImm16 : Operand<OtherVT> { 832 let EncoderMethod = "getBranchTargetOpValue1SImm16"; 833 let OperandType = "OPERAND_PCREL"; 834 let DecoderMethod = "DecodeBranchTarget1SImm16"; 835 let ParserMatchClass = MipsJumpTargetAsmOperand; 836} 837def calltarget : Operand<iPTR> { 838 let EncoderMethod = "getJumpTargetOpValue"; 839 let ParserMatchClass = MipsJumpTargetAsmOperand; 840} 841 842def imm64: Operand<i64>; 843 844def simm19_lsl2 : Operand<i32> { 845 let EncoderMethod = "getSimm19Lsl2Encoding"; 846 let DecoderMethod = "DecodeSimm19Lsl2"; 847 let ParserMatchClass = Simm19Lsl2AsmOperand; 848} 849 850def simm18_lsl3 : Operand<i32> { 851 let EncoderMethod = "getSimm18Lsl3Encoding"; 852 let DecoderMethod = "DecodeSimm18Lsl3"; 853 let ParserMatchClass = MipsJumpTargetAsmOperand; 854} 855 856// Zero 857def uimmz : Operand<i32> { 858 let PrintMethod = "printUImm<0>"; 859 let ParserMatchClass = ConstantImmzAsmOperandClass; 860} 861 862// size operand of ins instruction 863def uimm_range_2_64 : Operand<i32> { 864 let PrintMethod = "printUImm<6, 2>"; 865 let EncoderMethod = "getSizeInsEncoding"; 866 let DecoderMethod = "DecodeInsSize"; 867 let ParserMatchClass = ConstantUImm5_Range2_64AsmOperandClass; 868} 869 870// Unsigned Operands 871foreach I = {1, 2, 3, 4, 5, 6, 7, 8, 10, 20, 26} in 872 def uimm # I : Operand<i32> { 873 let PrintMethod = "printUImm<" # I # ">"; 874 let ParserMatchClass = 875 !cast<AsmOperandClass>("ConstantUImm" # I # "AsmOperandClass"); 876 } 877 878def uimm2_plus1 : Operand<i32> { 879 let PrintMethod = "printUImm<2, 1>"; 880 let EncoderMethod = "getUImmWithOffsetEncoding<2, 1>"; 881 let DecoderMethod = "DecodeUImmWithOffset<2, 1>"; 882 let ParserMatchClass = ConstantUImm2Plus1AsmOperandClass; 883} 884 885def uimm5_plus1 : Operand<i32> { 886 let PrintMethod = "printUImm<5, 1>"; 887 let EncoderMethod = "getUImmWithOffsetEncoding<5, 1>"; 888 let DecoderMethod = "DecodeUImmWithOffset<5, 1>"; 889 let ParserMatchClass = ConstantUImm5Plus1AsmOperandClass; 890} 891 892def uimm5_plus1_report_uimm6 : Operand<i32> { 893 let PrintMethod = "printUImm<6, 1>"; 894 let EncoderMethod = "getUImmWithOffsetEncoding<5, 1>"; 895 let DecoderMethod = "DecodeUImmWithOffset<5, 1>"; 896 let ParserMatchClass = ConstantUImm5Plus1ReportUImm6AsmOperandClass; 897} 898 899def uimm5_plus32 : Operand<i32> { 900 let PrintMethod = "printUImm<5, 32>"; 901 let ParserMatchClass = ConstantUImm5Plus32AsmOperandClass; 902} 903 904def uimm5_plus33 : Operand<i32> { 905 let PrintMethod = "printUImm<5, 33>"; 906 let EncoderMethod = "getUImmWithOffsetEncoding<5, 1>"; 907 let DecoderMethod = "DecodeUImmWithOffset<5, 1>"; 908 let ParserMatchClass = ConstantUImm5Plus33AsmOperandClass; 909} 910 911def uimm5_inssize_plus1 : Operand<i32> { 912 let PrintMethod = "printUImm<6>"; 913 let ParserMatchClass = ConstantUImm5Plus1AsmOperandClass; 914 let EncoderMethod = "getSizeInsEncoding"; 915 let DecoderMethod = "DecodeInsSize"; 916} 917 918def uimm5_plus32_normalize : Operand<i32> { 919 let PrintMethod = "printUImm<5>"; 920 let ParserMatchClass = ConstantUImm5Plus32NormalizeAsmOperandClass; 921} 922 923def uimm5_lsl2 : Operand<OtherVT> { 924 let EncoderMethod = "getUImm5Lsl2Encoding"; 925 let DecoderMethod = "DecodeUImmWithOffsetAndScale<5, 0, 4>"; 926 let ParserMatchClass = ConstantUImm5Lsl2AsmOperandClass; 927} 928 929def uimm5_plus32_normalize_64 : Operand<i64> { 930 let PrintMethod = "printUImm<5>"; 931 let ParserMatchClass = ConstantUImm5Plus32NormalizeAsmOperandClass; 932} 933 934def uimm6_lsl2 : Operand<OtherVT> { 935 let EncoderMethod = "getUImm6Lsl2Encoding"; 936 let DecoderMethod = "DecodeUImmWithOffsetAndScale<6, 0, 4>"; 937 let ParserMatchClass = ConstantUImm6Lsl2AsmOperandClass; 938} 939 940foreach I = {16} in 941 def uimm # I : Operand<i32> { 942 let PrintMethod = "printUImm<" # I # ">"; 943 let ParserMatchClass = 944 !cast<AsmOperandClass>("UImm" # I # "AsmOperandClass"); 945 } 946 947// Like uimm16_64 but coerces simm16 to uimm16. 948def uimm16_relaxed : Operand<i32> { 949 let PrintMethod = "printUImm<16>"; 950 let ParserMatchClass = 951 !cast<AsmOperandClass>("UImm16RelaxedAsmOperandClass"); 952} 953 954foreach I = {5} in 955 def uimm # I # _64 : Operand<i64> { 956 let PrintMethod = "printUImm<" # I # ">"; 957 let ParserMatchClass = 958 !cast<AsmOperandClass>("ConstantUImm" # I # "AsmOperandClass"); 959 } 960 961foreach I = {16} in 962 def uimm # I # _64 : Operand<i64> { 963 let PrintMethod = "printUImm<" # I # ">"; 964 let ParserMatchClass = 965 !cast<AsmOperandClass>("UImm" # I # "AsmOperandClass"); 966 } 967 968// Like uimm16_64 but coerces simm16 to uimm16. 969def uimm16_64_relaxed : Operand<i64> { 970 let PrintMethod = "printUImm<16>"; 971 let ParserMatchClass = 972 !cast<AsmOperandClass>("UImm16RelaxedAsmOperandClass"); 973} 974 975def uimm16_altrelaxed : Operand<i32> { 976 let PrintMethod = "printUImm<16>"; 977 let ParserMatchClass = 978 !cast<AsmOperandClass>("UImm16AltRelaxedAsmOperandClass"); 979} 980// Like uimm5 but reports a less confusing error for 32-63 when 981// an instruction alias permits that. 982def uimm5_report_uimm6 : Operand<i32> { 983 let PrintMethod = "printUImm<6>"; 984 let ParserMatchClass = ConstantUImm5ReportUImm6AsmOperandClass; 985} 986 987// Like uimm5_64 but reports a less confusing error for 32-63 when 988// an instruction alias permits that. 989def uimm5_64_report_uimm6 : Operand<i64> { 990 let PrintMethod = "printUImm<5>"; 991 let ParserMatchClass = ConstantUImm5ReportUImm6AsmOperandClass; 992} 993 994foreach I = {1, 2, 3, 4} in 995 def uimm # I # _ptr : Operand<iPTR> { 996 let PrintMethod = "printUImm<" # I # ">"; 997 let ParserMatchClass = 998 !cast<AsmOperandClass>("ConstantUImm" # I # "AsmOperandClass"); 999 } 1000 1001foreach I = {1, 2, 3, 4, 5, 6, 8} in 1002 def vsplat_uimm # I : Operand<vAny> { 1003 let PrintMethod = "printUImm<" # I # ">"; 1004 let ParserMatchClass = 1005 !cast<AsmOperandClass>("ConstantUImm" # I # "AsmOperandClass"); 1006 } 1007 1008// Signed operands 1009foreach I = {4, 5, 6, 9, 10, 11} in 1010 def simm # I : Operand<i32> { 1011 let DecoderMethod = "DecodeSImmWithOffsetAndScale<" # I # ">"; 1012 let ParserMatchClass = 1013 !cast<AsmOperandClass>("ConstantSImm" # I # "AsmOperandClass"); 1014 } 1015 1016foreach I = {1, 2, 3} in 1017 def simm10_lsl # I : Operand<i32> { 1018 let DecoderMethod = "DecodeSImmWithOffsetAndScale<10, " # I # ">"; 1019 let ParserMatchClass = 1020 !cast<AsmOperandClass>("ConstantSImm10Lsl" # I # "AsmOperandClass"); 1021 } 1022 1023foreach I = {10} in 1024 def simm # I # _64 : Operand<i64> { 1025 let DecoderMethod = "DecodeSImmWithOffsetAndScale<" # I # ">"; 1026 let ParserMatchClass = 1027 !cast<AsmOperandClass>("ConstantSImm" # I # "AsmOperandClass"); 1028 } 1029 1030foreach I = {5, 10} in 1031 def vsplat_simm # I : Operand<vAny> { 1032 let ParserMatchClass = 1033 !cast<AsmOperandClass>("ConstantSImm" # I # "AsmOperandClass"); 1034 } 1035 1036def simm7_lsl2 : Operand<OtherVT> { 1037 let EncoderMethod = "getSImm7Lsl2Encoding"; 1038 let DecoderMethod = "DecodeSImmWithOffsetAndScale<" # I # ", 0, 4>"; 1039 let ParserMatchClass = ConstantSImm7Lsl2AsmOperandClass; 1040} 1041 1042foreach I = {16, 32} in 1043 def simm # I : Operand<i32> { 1044 let DecoderMethod = "DecodeSImmWithOffsetAndScale<" # I # ">"; 1045 let ParserMatchClass = !cast<AsmOperandClass>("SImm" # I # "AsmOperandClass"); 1046 } 1047 1048// Like simm16 but coerces uimm16 to simm16. 1049def simm16_relaxed : Operand<i32> { 1050 let DecoderMethod = "DecodeSImmWithOffsetAndScale<16>"; 1051 let ParserMatchClass = !cast<AsmOperandClass>("SImm16RelaxedAsmOperandClass"); 1052} 1053 1054def simm16_64 : Operand<i64> { 1055 let DecoderMethod = "DecodeSImmWithOffsetAndScale<16>"; 1056 let ParserMatchClass = !cast<AsmOperandClass>("SImm16AsmOperandClass"); 1057} 1058 1059// like simm32 but coerces simm32 to uimm32. 1060def uimm32_coerced : Operand<i32> { 1061 let ParserMatchClass = !cast<AsmOperandClass>("UImm32CoercedAsmOperandClass"); 1062} 1063// Like simm32 but coerces uimm32 to simm32. 1064def simm32_relaxed : Operand<i32> { 1065 let DecoderMethod = "DecodeSImmWithOffsetAndScale<32>"; 1066 let ParserMatchClass = !cast<AsmOperandClass>("SImm32RelaxedAsmOperandClass"); 1067} 1068 1069// This is almost the same as a uimm7 but 0x7f is interpreted as -1. 1070def li16_imm : Operand<i32> { 1071 let DecoderMethod = "DecodeLi16Imm"; 1072 let ParserMatchClass = ConstantUImm7Sub1AsmOperandClass; 1073} 1074 1075def MipsMemAsmOperand : AsmOperandClass { 1076 let Name = "Mem"; 1077 let ParserMethod = "parseMemOperand"; 1078} 1079 1080def MipsMemSimm9AsmOperand : AsmOperandClass { 1081 let Name = "MemOffsetSimm9"; 1082 let SuperClasses = [MipsMemAsmOperand]; 1083 let RenderMethod = "addMemOperands"; 1084 let ParserMethod = "parseMemOperand"; 1085 let PredicateMethod = "isMemWithSimmOffset<9>"; 1086 let DiagnosticType = "MemSImm9"; 1087} 1088 1089def MipsMemSimm10AsmOperand : AsmOperandClass { 1090 let Name = "MemOffsetSimm10"; 1091 let SuperClasses = [MipsMemAsmOperand]; 1092 let RenderMethod = "addMemOperands"; 1093 let ParserMethod = "parseMemOperand"; 1094 let PredicateMethod = "isMemWithSimmOffset<10>"; 1095 let DiagnosticType = "MemSImm10"; 1096} 1097 1098def MipsMemSimm12AsmOperand : AsmOperandClass { 1099 let Name = "MemOffsetSimm12"; 1100 let SuperClasses = [MipsMemAsmOperand]; 1101 let RenderMethod = "addMemOperands"; 1102 let ParserMethod = "parseMemOperand"; 1103 let PredicateMethod = "isMemWithSimmOffset<12>"; 1104 let DiagnosticType = "MemSImm12"; 1105} 1106 1107foreach I = {1, 2, 3} in 1108 def MipsMemSimm10Lsl # I # AsmOperand : AsmOperandClass { 1109 let Name = "MemOffsetSimm10_" # I; 1110 let SuperClasses = [MipsMemAsmOperand]; 1111 let RenderMethod = "addMemOperands"; 1112 let ParserMethod = "parseMemOperand"; 1113 let PredicateMethod = "isMemWithSimmOffset<10, " # I # ">"; 1114 let DiagnosticType = "MemSImm10Lsl" # I; 1115 } 1116 1117def MipsMemSimm11AsmOperand : AsmOperandClass { 1118 let Name = "MemOffsetSimm11"; 1119 let SuperClasses = [MipsMemAsmOperand]; 1120 let RenderMethod = "addMemOperands"; 1121 let ParserMethod = "parseMemOperand"; 1122 let PredicateMethod = "isMemWithSimmOffset<11>"; 1123 let DiagnosticType = "MemSImm11"; 1124} 1125 1126def MipsMemSimm16AsmOperand : AsmOperandClass { 1127 let Name = "MemOffsetSimm16"; 1128 let SuperClasses = [MipsMemAsmOperand]; 1129 let RenderMethod = "addMemOperands"; 1130 let ParserMethod = "parseMemOperand"; 1131 let PredicateMethod = "isMemWithSimmOffset<16>"; 1132 let DiagnosticType = "MemSImm16"; 1133} 1134 1135def MipsMemSimmPtrAsmOperand : AsmOperandClass { 1136 let Name = "MemOffsetSimmPtr"; 1137 let SuperClasses = [MipsMemAsmOperand]; 1138 let RenderMethod = "addMemOperands"; 1139 let ParserMethod = "parseMemOperand"; 1140 let PredicateMethod = "isMemWithPtrSizeOffset"; 1141 let DiagnosticType = "MemSImmPtr"; 1142} 1143 1144def MipsInvertedImmoperand : AsmOperandClass { 1145 let Name = "InvNum"; 1146 let RenderMethod = "addImmOperands"; 1147 let ParserMethod = "parseInvNum"; 1148} 1149 1150def InvertedImOperand : Operand<i32> { 1151 let ParserMatchClass = MipsInvertedImmoperand; 1152} 1153 1154def InvertedImOperand64 : Operand<i64> { 1155 let ParserMatchClass = MipsInvertedImmoperand; 1156} 1157 1158class mem_generic : Operand<iPTR> { 1159 let PrintMethod = "printMemOperand"; 1160 let MIOperandInfo = (ops ptr_rc, simm16); 1161 let EncoderMethod = "getMemEncoding"; 1162 let ParserMatchClass = MipsMemAsmOperand; 1163 let OperandType = "OPERAND_MEMORY"; 1164} 1165 1166// Address operand 1167def mem : mem_generic; 1168 1169// MSA specific address operand 1170def mem_msa : mem_generic { 1171 let MIOperandInfo = (ops ptr_rc, simm10); 1172 let EncoderMethod = "getMSAMemEncoding"; 1173} 1174 1175def simm12 : Operand<i32> { 1176 let DecoderMethod = "DecodeSimm12"; 1177} 1178 1179def mem_simm9 : mem_generic { 1180 let MIOperandInfo = (ops ptr_rc, simm9); 1181 let EncoderMethod = "getMemEncoding"; 1182 let ParserMatchClass = MipsMemSimm9AsmOperand; 1183} 1184 1185def mem_simm10 : mem_generic { 1186 let MIOperandInfo = (ops ptr_rc, simm10); 1187 let EncoderMethod = "getMemEncoding"; 1188 let ParserMatchClass = MipsMemSimm10AsmOperand; 1189} 1190 1191foreach I = {1, 2, 3} in 1192 def mem_simm10_lsl # I : mem_generic { 1193 let MIOperandInfo = (ops ptr_rc, !cast<Operand>("simm10_lsl" # I)); 1194 let EncoderMethod = "getMemEncoding<" # I # ">"; 1195 let ParserMatchClass = 1196 !cast<AsmOperandClass>("MipsMemSimm10Lsl" # I # "AsmOperand"); 1197 } 1198 1199def mem_simm11 : mem_generic { 1200 let MIOperandInfo = (ops ptr_rc, simm11); 1201 let EncoderMethod = "getMemEncoding"; 1202 let ParserMatchClass = MipsMemSimm11AsmOperand; 1203} 1204 1205def mem_simm12 : mem_generic { 1206 let MIOperandInfo = (ops ptr_rc, simm12); 1207 let EncoderMethod = "getMemEncoding"; 1208 let ParserMatchClass = MipsMemSimm12AsmOperand; 1209} 1210 1211def mem_simm16 : mem_generic { 1212 let MIOperandInfo = (ops ptr_rc, simm16); 1213 let EncoderMethod = "getMemEncoding"; 1214 let ParserMatchClass = MipsMemSimm16AsmOperand; 1215} 1216 1217def mem_simmptr : mem_generic { 1218 let ParserMatchClass = MipsMemSimmPtrAsmOperand; 1219} 1220 1221def mem_ea : Operand<iPTR> { 1222 let PrintMethod = "printMemOperandEA"; 1223 let MIOperandInfo = (ops ptr_rc, simm16); 1224 let EncoderMethod = "getMemEncoding"; 1225 let OperandType = "OPERAND_MEMORY"; 1226} 1227 1228def PtrRC : Operand<iPTR> { 1229 let MIOperandInfo = (ops ptr_rc); 1230 let DecoderMethod = "DecodePtrRegisterClass"; 1231 let ParserMatchClass = GPR32AsmOperand; 1232} 1233 1234// size operand of ins instruction 1235def size_ins : Operand<i32> { 1236 let EncoderMethod = "getSizeInsEncoding"; 1237 let DecoderMethod = "DecodeInsSize"; 1238} 1239 1240// Transformation Function - get the lower 16 bits. 1241def LO16 : SDNodeXForm<imm, [{ 1242 return getImm(N, N->getZExtValue() & 0xFFFF); 1243}]>; 1244 1245// Transformation Function - get the higher 16 bits. 1246def HI16 : SDNodeXForm<imm, [{ 1247 return getImm(N, (N->getZExtValue() >> 16) & 0xFFFF); 1248}]>; 1249 1250// Plus 1. 1251def Plus1 : SDNodeXForm<imm, [{ return getImm(N, N->getSExtValue() + 1); }]>; 1252 1253// Node immediate is zero (e.g. insve.d) 1254def immz : PatLeaf<(imm), [{ return N->getSExtValue() == 0; }]>; 1255 1256// Node immediate fits as 16-bit sign extended on target immediate. 1257// e.g. addi, andi 1258def immSExt8 : PatLeaf<(imm), [{ return isInt<8>(N->getSExtValue()); }]>; 1259 1260// Node immediate fits as 16-bit sign extended on target immediate. 1261// e.g. addi, andi 1262def immSExt16 : PatLeaf<(imm), [{ return isInt<16>(N->getSExtValue()); }]>; 1263 1264// Node immediate fits as 7-bit zero extended on target immediate. 1265def immZExt7 : PatLeaf<(imm), [{ return isUInt<7>(N->getZExtValue()); }]>; 1266def timmZExt7 : PatLeaf<(timm), [{ return isUInt<7>(N->getZExtValue()); }]>; 1267 1268// Node immediate fits as 16-bit zero extended on target immediate. 1269// The LO16 param means that only the lower 16 bits of the node 1270// immediate are caught. 1271// e.g. addiu, sltiu 1272def immZExt16 : PatLeaf<(imm), [{ 1273 if (N->getValueType(0) == MVT::i32) 1274 return (uint32_t)N->getZExtValue() == (unsigned short)N->getZExtValue(); 1275 else 1276 return (uint64_t)N->getZExtValue() == (unsigned short)N->getZExtValue(); 1277}], LO16>; 1278 1279// Immediate can be loaded with LUi (32-bit int with lower 16-bit cleared). 1280def immSExt32Low16Zero : PatLeaf<(imm), [{ 1281 int64_t Val = N->getSExtValue(); 1282 return isInt<32>(Val) && !(Val & 0xffff); 1283}]>; 1284 1285// Zero-extended 32-bit unsigned int with lower 16-bit cleared. 1286def immZExt32Low16Zero : PatLeaf<(imm), [{ 1287 uint64_t Val = N->getZExtValue(); 1288 return isUInt<32>(Val) && !(Val & 0xffff); 1289}]>; 1290 1291// Note immediate fits as a 32 bit signed extended on target immediate. 1292def immSExt32 : PatLeaf<(imm), [{ return isInt<32>(N->getSExtValue()); }]>; 1293 1294// Note immediate fits as a 32 bit zero extended on target immediate. 1295def immZExt32 : PatLeaf<(imm), [{ return isUInt<32>(N->getZExtValue()); }]>; 1296 1297// shamt field must fit in 5 bits. 1298def immZExt5 : ImmLeaf<i32, [{return Imm == (Imm & 0x1f);}]>; 1299def timmZExt5 : TImmLeaf<i32, [{return Imm == (Imm & 0x1f);}]>; 1300 1301def immZExt5Plus1 : PatLeaf<(imm), [{ 1302 return isUInt<5>(N->getZExtValue() - 1); 1303}]>; 1304def immZExt5Plus32 : PatLeaf<(imm), [{ 1305 return isUInt<5>(N->getZExtValue() - 32); 1306}]>; 1307def immZExt5Plus33 : PatLeaf<(imm), [{ 1308 return isUInt<5>(N->getZExtValue() - 33); 1309}]>; 1310 1311def immZExt5To31 : SDNodeXForm<imm, [{ 1312 return getImm(N, 31 - N->getZExtValue()); 1313}]>; 1314 1315// True if (N + 1) fits in 16-bit field. 1316def immSExt16Plus1 : PatLeaf<(imm), [{ 1317 return isInt<17>(N->getSExtValue()) && isInt<16>(N->getSExtValue() + 1); 1318}]>; 1319 1320def immZExtRange2To64 : PatLeaf<(imm), [{ 1321 return isUInt<7>(N->getZExtValue()) && (N->getZExtValue() >= 2) && 1322 (N->getZExtValue() <= 64); 1323}]>; 1324 1325def ORiPred : PatLeaf<(imm), [{ 1326 return isUInt<16>(N->getZExtValue()) && !isInt<16>(N->getSExtValue()); 1327}], LO16>; 1328 1329def LUiPred : PatLeaf<(imm), [{ 1330 int64_t Val = N->getSExtValue(); 1331 return !isInt<16>(Val) && isInt<32>(Val) && !(Val & 0xffff); 1332}]>; 1333 1334def LUiORiPred : PatLeaf<(imm), [{ 1335 int64_t SVal = N->getSExtValue(); 1336 return isInt<32>(SVal) && (SVal & 0xffff); 1337}]>; 1338 1339// Mips Address Mode! SDNode frameindex could possibily be a match 1340// since load and store instructions from stack used it. 1341def addr : 1342 ComplexPattern<iPTR, 2, "selectIntAddr", [frameindex]>; 1343 1344def addrRegImm : 1345 ComplexPattern<iPTR, 2, "selectAddrRegImm", [frameindex]>; 1346 1347def addrDefault : 1348 ComplexPattern<iPTR, 2, "selectAddrDefault", [frameindex]>; 1349 1350def addrimm10 : ComplexPattern<iPTR, 2, "selectIntAddrSImm10", [frameindex]>; 1351def addrimm10lsl1 : ComplexPattern<iPTR, 2, "selectIntAddrSImm10Lsl1", 1352 [frameindex]>; 1353def addrimm10lsl2 : ComplexPattern<iPTR, 2, "selectIntAddrSImm10Lsl2", 1354 [frameindex]>; 1355def addrimm10lsl3 : ComplexPattern<iPTR, 2, "selectIntAddrSImm10Lsl3", 1356 [frameindex]>; 1357 1358//===----------------------------------------------------------------------===// 1359// Instructions specific format 1360//===----------------------------------------------------------------------===// 1361 1362// Arithmetic and logical instructions with 3 register operands. 1363class ArithLogicR<string opstr, RegisterOperand RO, bit isComm = 0, 1364 InstrItinClass Itin = NoItinerary, 1365 SDPatternOperator OpNode = null_frag>: 1366 InstSE<(outs RO:$rd), (ins RO:$rs, RO:$rt), 1367 !strconcat(opstr, "\t$rd, $rs, $rt"), 1368 [(set RO:$rd, (OpNode RO:$rs, RO:$rt))], Itin, FrmR, opstr> { 1369 let isCommutable = isComm; 1370 let isReMaterializable = 1; 1371 let TwoOperandAliasConstraint = "$rd = $rs"; 1372} 1373 1374// Arithmetic and logical instructions with 2 register operands. 1375class ArithLogicI<string opstr, Operand Od, RegisterOperand RO, 1376 InstrItinClass Itin = NoItinerary, 1377 SDPatternOperator imm_type = null_frag, 1378 SDPatternOperator OpNode = null_frag> : 1379 InstSE<(outs RO:$rt), (ins RO:$rs, Od:$imm16), 1380 !strconcat(opstr, "\t$rt, $rs, $imm16"), 1381 [(set RO:$rt, (OpNode RO:$rs, imm_type:$imm16))], 1382 Itin, FrmI, opstr> { 1383 let isReMaterializable = 1; 1384 let TwoOperandAliasConstraint = "$rs = $rt"; 1385} 1386 1387// Arithmetic Multiply ADD/SUB 1388class MArithR<string opstr, InstrItinClass itin, bit isComm = 0> : 1389 InstSE<(outs), (ins GPR32Opnd:$rs, GPR32Opnd:$rt), 1390 !strconcat(opstr, "\t$rs, $rt"), [], itin, FrmR, opstr> { 1391 let Defs = [HI0, LO0]; 1392 let Uses = [HI0, LO0]; 1393 let isCommutable = isComm; 1394} 1395 1396// Logical 1397class LogicNOR<string opstr, RegisterOperand RO>: 1398 InstSE<(outs RO:$rd), (ins RO:$rs, RO:$rt), 1399 !strconcat(opstr, "\t$rd, $rs, $rt"), 1400 [(set RO:$rd, (not (or RO:$rs, RO:$rt)))], II_NOR, FrmR, opstr> { 1401 let isCommutable = 1; 1402} 1403 1404// Shifts 1405class shift_rotate_imm<string opstr, Operand ImmOpnd, 1406 RegisterOperand RO, InstrItinClass itin, 1407 SDPatternOperator OpNode = null_frag, 1408 SDPatternOperator PF = null_frag> : 1409 InstSE<(outs RO:$rd), (ins RO:$rt, ImmOpnd:$shamt), 1410 !strconcat(opstr, "\t$rd, $rt, $shamt"), 1411 [(set RO:$rd, (OpNode RO:$rt, PF:$shamt))], itin, FrmR, opstr> { 1412 let TwoOperandAliasConstraint = "$rt = $rd"; 1413} 1414 1415class shift_rotate_reg<string opstr, RegisterOperand RO, InstrItinClass itin, 1416 SDPatternOperator OpNode = null_frag>: 1417 InstSE<(outs RO:$rd), (ins RO:$rt, GPR32Opnd:$rs), 1418 !strconcat(opstr, "\t$rd, $rt, $rs"), 1419 [(set RO:$rd, (OpNode RO:$rt, GPR32Opnd:$rs))], itin, FrmR, 1420 opstr>; 1421 1422// Load Upper Immediate 1423class LoadUpper<string opstr, RegisterOperand RO, Operand Imm>: 1424 InstSE<(outs RO:$rt), (ins Imm:$imm16), !strconcat(opstr, "\t$rt, $imm16"), 1425 [], II_LUI, FrmI, opstr>, IsAsCheapAsAMove { 1426 let hasSideEffects = 0; 1427 let isReMaterializable = 1; 1428} 1429 1430// Memory Load/Store 1431class LoadMemory<string opstr, DAGOperand RO, DAGOperand MO, 1432 SDPatternOperator OpNode = null_frag, 1433 InstrItinClass Itin = NoItinerary, 1434 ComplexPattern Addr = addr> : 1435 InstSE<(outs RO:$rt), (ins MO:$addr), !strconcat(opstr, "\t$rt, $addr"), 1436 [(set RO:$rt, (OpNode Addr:$addr))], Itin, FrmI, opstr> { 1437 let DecoderMethod = "DecodeMem"; 1438 let canFoldAsLoad = 1; 1439 string BaseOpcode = opstr; 1440 let mayLoad = 1; 1441} 1442 1443class Load<string opstr, DAGOperand RO, SDPatternOperator OpNode = null_frag, 1444 InstrItinClass Itin = NoItinerary, ComplexPattern Addr = addr> : 1445 LoadMemory<opstr, RO, mem, OpNode, Itin, Addr>; 1446 1447class StoreMemory<string opstr, DAGOperand RO, DAGOperand MO, 1448 SDPatternOperator OpNode = null_frag, 1449 InstrItinClass Itin = NoItinerary, ComplexPattern Addr = addr> : 1450 InstSE<(outs), (ins RO:$rt, MO:$addr), !strconcat(opstr, "\t$rt, $addr"), 1451 [(OpNode RO:$rt, Addr:$addr)], Itin, FrmI, opstr> { 1452 let DecoderMethod = "DecodeMem"; 1453 string BaseOpcode = opstr; 1454 let mayStore = 1; 1455} 1456 1457class Store<string opstr, DAGOperand RO, SDPatternOperator OpNode = null_frag, 1458 InstrItinClass Itin = NoItinerary, ComplexPattern Addr = addr, 1459 DAGOperand MO = mem> : 1460 StoreMemory<opstr, RO, MO, OpNode, Itin, Addr>; 1461 1462// Load/Store Left/Right 1463let canFoldAsLoad = 1 in 1464class LoadLeftRight<string opstr, SDNode OpNode, RegisterOperand RO, 1465 InstrItinClass Itin> : 1466 InstSE<(outs RO:$rt), (ins mem:$addr, RO:$src), 1467 !strconcat(opstr, "\t$rt, $addr"), 1468 [(set RO:$rt, (OpNode addr:$addr, RO:$src))], Itin, FrmI> { 1469 let DecoderMethod = "DecodeMem"; 1470 string Constraints = "$src = $rt"; 1471 let BaseOpcode = opstr; 1472} 1473 1474class StoreLeftRight<string opstr, SDNode OpNode, RegisterOperand RO, 1475 InstrItinClass Itin> : 1476 InstSE<(outs), (ins RO:$rt, mem:$addr), !strconcat(opstr, "\t$rt, $addr"), 1477 [(OpNode RO:$rt, addr:$addr)], Itin, FrmI> { 1478 let DecoderMethod = "DecodeMem"; 1479 let BaseOpcode = opstr; 1480} 1481 1482// COP2 Load/Store 1483class LW_FT2<string opstr, RegisterOperand RC, InstrItinClass Itin, 1484 SDPatternOperator OpNode= null_frag> : 1485 InstSE<(outs RC:$rt), (ins mem_simm16:$addr), 1486 !strconcat(opstr, "\t$rt, $addr"), 1487 [(set RC:$rt, (OpNode addrDefault:$addr))], Itin, FrmFI, opstr> { 1488 let DecoderMethod = "DecodeFMem2"; 1489 let mayLoad = 1; 1490} 1491 1492class SW_FT2<string opstr, RegisterOperand RC, InstrItinClass Itin, 1493 SDPatternOperator OpNode= null_frag> : 1494 InstSE<(outs), (ins RC:$rt, mem_simm16:$addr), 1495 !strconcat(opstr, "\t$rt, $addr"), 1496 [(OpNode RC:$rt, addrDefault:$addr)], Itin, FrmFI, opstr> { 1497 let DecoderMethod = "DecodeFMem2"; 1498 let mayStore = 1; 1499} 1500 1501// COP3 Load/Store 1502class LW_FT3<string opstr, RegisterOperand RC, InstrItinClass Itin, 1503 SDPatternOperator OpNode= null_frag> : 1504 InstSE<(outs RC:$rt), (ins mem:$addr), !strconcat(opstr, "\t$rt, $addr"), 1505 [(set RC:$rt, (OpNode addrDefault:$addr))], Itin, FrmFI, opstr> { 1506 let DecoderMethod = "DecodeFMem3"; 1507 let mayLoad = 1; 1508} 1509 1510class SW_FT3<string opstr, RegisterOperand RC, InstrItinClass Itin, 1511 SDPatternOperator OpNode= null_frag> : 1512 InstSE<(outs), (ins RC:$rt, mem:$addr), !strconcat(opstr, "\t$rt, $addr"), 1513 [(OpNode RC:$rt, addrDefault:$addr)], Itin, FrmFI, opstr> { 1514 let DecoderMethod = "DecodeFMem3"; 1515 let mayStore = 1; 1516} 1517 1518// Conditional Branch 1519class CBranch<string opstr, DAGOperand opnd, PatFrag cond_op, 1520 RegisterOperand RO> : 1521 InstSE<(outs), (ins RO:$rs, RO:$rt, opnd:$offset), 1522 !strconcat(opstr, "\t$rs, $rt, $offset"), 1523 [(brcond (i32 (cond_op RO:$rs, RO:$rt)), bb:$offset)], II_BCC, 1524 FrmI, opstr> { 1525 let isBranch = 1; 1526 let isTerminator = 1; 1527 let hasDelaySlot = 1; 1528 let Defs = [AT]; 1529 bit isCTI = 1; 1530} 1531 1532class CBranchLikely<string opstr, DAGOperand opnd, RegisterOperand RO> : 1533 InstSE<(outs), (ins RO:$rs, RO:$rt, opnd:$offset), 1534 !strconcat(opstr, "\t$rs, $rt, $offset"), [], II_BCC, FrmI, opstr> { 1535 let isBranch = 1; 1536 let isTerminator = 1; 1537 let hasDelaySlot = 1; 1538 let Defs = [AT]; 1539 bit isCTI = 1; 1540} 1541 1542class CBranchZero<string opstr, DAGOperand opnd, PatFrag cond_op, 1543 RegisterOperand RO> : 1544 InstSE<(outs), (ins RO:$rs, opnd:$offset), 1545 !strconcat(opstr, "\t$rs, $offset"), 1546 [(brcond (i32 (cond_op RO:$rs, 0)), bb:$offset)], II_BCCZ, 1547 FrmI, opstr> { 1548 let isBranch = 1; 1549 let isTerminator = 1; 1550 let hasDelaySlot = 1; 1551 let Defs = [AT]; 1552 bit isCTI = 1; 1553} 1554 1555class CBranchZeroLikely<string opstr, DAGOperand opnd, RegisterOperand RO> : 1556 InstSE<(outs), (ins RO:$rs, opnd:$offset), 1557 !strconcat(opstr, "\t$rs, $offset"), [], II_BCCZ, FrmI, opstr> { 1558 let isBranch = 1; 1559 let isTerminator = 1; 1560 let hasDelaySlot = 1; 1561 let Defs = [AT]; 1562 bit isCTI = 1; 1563} 1564 1565// SetCC 1566class SetCC_R<string opstr, PatFrag cond_op, RegisterOperand RO> : 1567 InstSE<(outs GPR32Opnd:$rd), (ins RO:$rs, RO:$rt), 1568 !strconcat(opstr, "\t$rd, $rs, $rt"), 1569 [(set GPR32Opnd:$rd, (cond_op RO:$rs, RO:$rt))], 1570 II_SLT_SLTU, FrmR, opstr>; 1571 1572class SetCC_I<string opstr, PatFrag cond_op, Operand Od, PatLeaf imm_type, 1573 RegisterOperand RO>: 1574 InstSE<(outs GPR32Opnd:$rt), (ins RO:$rs, Od:$imm16), 1575 !strconcat(opstr, "\t$rt, $rs, $imm16"), 1576 [(set GPR32Opnd:$rt, (cond_op RO:$rs, imm_type:$imm16))], 1577 II_SLTI_SLTIU, FrmI, opstr>; 1578 1579// Jump 1580class JumpFJ<DAGOperand opnd, string opstr, SDPatternOperator operator, 1581 SDPatternOperator targetoperator, string bopstr> : 1582 InstSE<(outs), (ins opnd:$target), !strconcat(opstr, "\t$target"), 1583 [(operator targetoperator:$target)], II_J, FrmJ, bopstr> { 1584 let isTerminator=1; 1585 let isBarrier=1; 1586 let hasDelaySlot = 1; 1587 let DecoderMethod = "DecodeJumpTarget"; 1588 let Defs = [AT]; 1589 bit isCTI = 1; 1590} 1591 1592// Unconditional branch 1593class UncondBranch<Instruction BEQInst, DAGOperand opnd> : 1594 PseudoSE<(outs), (ins brtarget:$offset), [(br bb:$offset)], II_B>, 1595 PseudoInstExpansion<(BEQInst ZERO, ZERO, opnd:$offset)> { 1596 let isBranch = 1; 1597 let isTerminator = 1; 1598 let isBarrier = 1; 1599 let hasDelaySlot = 1; 1600 let AdditionalPredicates = [RelocPIC]; 1601 let Defs = [AT]; 1602 bit isCTI = 1; 1603} 1604 1605// Base class for indirect branch and return instruction classes. 1606let isTerminator=1, isBarrier=1, hasDelaySlot = 1, isCTI = 1 in 1607class JumpFR<string opstr, RegisterOperand RO, 1608 SDPatternOperator operator = null_frag>: 1609 InstSE<(outs), (ins RO:$rs), "jr\t$rs", [(operator RO:$rs)], II_JR, 1610 FrmR, opstr>; 1611 1612// Indirect branch 1613class IndirectBranch<string opstr, RegisterOperand RO> : JumpFR<opstr, RO> { 1614 let isBranch = 1; 1615 let isIndirectBranch = 1; 1616} 1617 1618// Jump and Link (Call) 1619let isCall=1, hasDelaySlot=1, isCTI=1, Defs = [RA] in { 1620 class JumpLink<string opstr, DAGOperand opnd> : 1621 InstSE<(outs), (ins opnd:$target), !strconcat(opstr, "\t$target"), 1622 [(MipsJmpLink tglobaladdr:$target)], II_JAL, FrmJ, opstr> { 1623 let DecoderMethod = "DecodeJumpTarget"; 1624 } 1625 1626 class JumpLinkRegPseudo<RegisterOperand RO, Instruction JALRInst, 1627 Register RetReg, RegisterOperand ResRO = RO>: 1628 PseudoSE<(outs), (ins RO:$rs), [(MipsJmpLink RO:$rs)], II_JALR>, 1629 PseudoInstExpansion<(JALRInst RetReg, ResRO:$rs)> { 1630 let hasPostISelHook = 1; 1631 } 1632 1633 class JumpLinkReg<string opstr, RegisterOperand RO>: 1634 InstSE<(outs RO:$rd), (ins RO:$rs), !strconcat(opstr, "\t$rd, $rs"), 1635 [], II_JALR, FrmR, opstr> { 1636 let hasPostISelHook = 1; 1637 } 1638 1639 class BGEZAL_FT<string opstr, DAGOperand opnd, 1640 RegisterOperand RO> : 1641 InstSE<(outs), (ins RO:$rs, opnd:$offset), 1642 !strconcat(opstr, "\t$rs, $offset"), [], II_BCCZAL, FrmI, opstr> { 1643 let hasDelaySlot = 1; 1644 } 1645 1646} 1647 1648let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, hasDelaySlot = 1, 1649 hasExtraSrcRegAllocReq = 1, isCTI = 1, Defs = [AT] in { 1650 class TailCall<Instruction JumpInst, DAGOperand Opnd> : 1651 PseudoSE<(outs), (ins calltarget:$target), [], II_J>, 1652 PseudoInstExpansion<(JumpInst Opnd:$target)>; 1653 1654 class TailCallReg<Instruction JumpInst, RegisterOperand RO> : 1655 PseudoSE<(outs), (ins RO:$rs), [(MipsTailCall RO:$rs)], II_JR>, 1656 PseudoInstExpansion<(JumpInst RO:$rs)> { 1657 let hasPostISelHook = 1; 1658 } 1659} 1660 1661class BAL_BR_Pseudo<Instruction RealInst, DAGOperand opnd> : 1662 PseudoSE<(outs), (ins opnd:$offset), [], II_BCCZAL>, 1663 PseudoInstExpansion<(RealInst ZERO, opnd:$offset)> { 1664 let isBranch = 1; 1665 let isTerminator = 1; 1666 let isBarrier = 1; 1667 let hasDelaySlot = 1; 1668 let Defs = [RA]; 1669 bit isCTI = 1; 1670} 1671 1672let isCTI = 1 in { 1673// Syscall 1674class SYS_FT<string opstr, Operand ImmOp, InstrItinClass itin = NoItinerary> : 1675 InstSE<(outs), (ins ImmOp:$code_), 1676 !strconcat(opstr, "\t$code_"), [], itin, FrmI, opstr>; 1677// Break 1678class BRK_FT<string opstr> : 1679 InstSE<(outs), (ins uimm10:$code_1, uimm10:$code_2), 1680 !strconcat(opstr, "\t$code_1, $code_2"), [], II_BREAK, 1681 FrmOther, opstr>; 1682 1683// (D)Eret 1684class ER_FT<string opstr, InstrItinClass itin = NoItinerary> : 1685 InstSE<(outs), (ins), 1686 opstr, [], itin, FrmOther, opstr>; 1687 1688// Wait 1689class WAIT_FT<string opstr> : 1690 InstSE<(outs), (ins), opstr, [], II_WAIT, FrmOther, opstr>; 1691} 1692 1693// Interrupts 1694class DEI_FT<string opstr, RegisterOperand RO, 1695 InstrItinClass itin = NoItinerary> : 1696 InstSE<(outs RO:$rt), (ins), 1697 !strconcat(opstr, "\t$rt"), [], itin, FrmOther, opstr>; 1698 1699// Sync 1700let hasSideEffects = 1 in 1701class SYNC_FT<string opstr> : 1702 InstSE<(outs), (ins uimm5:$stype), "sync $stype", 1703 [(MipsSync immZExt5:$stype)], II_SYNC, FrmOther, opstr>; 1704 1705class SYNCI_FT<string opstr, DAGOperand MO> : 1706 InstSE<(outs), (ins MO:$addr), !strconcat(opstr, "\t$addr"), [], 1707 II_SYNCI, FrmOther, opstr> { 1708 let hasSideEffects = 1; 1709 let DecoderMethod = "DecodeSyncI"; 1710} 1711 1712let hasSideEffects = 1, isCTI = 1 in { 1713class TEQ_FT<string opstr, RegisterOperand RO, Operand ImmOp, 1714 InstrItinClass itin = NoItinerary> : 1715 InstSE<(outs), (ins RO:$rs, RO:$rt, ImmOp:$code_), 1716 !strconcat(opstr, "\t$rs, $rt, $code_"), [], itin, FrmI, opstr>; 1717 1718class TEQI_FT<string opstr, RegisterOperand RO, 1719 InstrItinClass itin = NoItinerary> : 1720 InstSE<(outs), (ins RO:$rs, simm16:$imm16), 1721 !strconcat(opstr, "\t$rs, $imm16"), [], itin, FrmOther, opstr>; 1722} 1723 1724// Mul, Div 1725class Mult<string opstr, InstrItinClass itin, RegisterOperand RO, 1726 list<Register> DefRegs> : 1727 InstSE<(outs), (ins RO:$rs, RO:$rt), !strconcat(opstr, "\t$rs, $rt"), [], 1728 itin, FrmR, opstr> { 1729 let isCommutable = 1; 1730 let Defs = DefRegs; 1731 let hasSideEffects = 0; 1732} 1733 1734// Pseudo multiply/divide instruction with explicit accumulator register 1735// operands. 1736class MultDivPseudo<Instruction RealInst, RegisterClass R0, RegisterOperand R1, 1737 SDPatternOperator OpNode, InstrItinClass Itin, 1738 bit IsComm = 1, bit HasSideEffects = 0, 1739 bit UsesCustomInserter = 0> : 1740 PseudoSE<(outs R0:$ac), (ins R1:$rs, R1:$rt), 1741 [(set R0:$ac, (OpNode R1:$rs, R1:$rt))], Itin>, 1742 PseudoInstExpansion<(RealInst R1:$rs, R1:$rt)> { 1743 let isCommutable = IsComm; 1744 let hasSideEffects = HasSideEffects; 1745 let usesCustomInserter = UsesCustomInserter; 1746} 1747 1748// Pseudo multiply add/sub instruction with explicit accumulator register 1749// operands. 1750class MAddSubPseudo<Instruction RealInst, SDPatternOperator OpNode, 1751 InstrItinClass itin> 1752 : PseudoSE<(outs ACC64:$ac), 1753 (ins GPR32Opnd:$rs, GPR32Opnd:$rt, ACC64:$acin), 1754 [(set ACC64:$ac, 1755 (OpNode GPR32Opnd:$rs, GPR32Opnd:$rt, ACC64:$acin))], 1756 itin>, 1757 PseudoInstExpansion<(RealInst GPR32Opnd:$rs, GPR32Opnd:$rt)> { 1758 string Constraints = "$acin = $ac"; 1759} 1760 1761class Div<string opstr, InstrItinClass itin, RegisterOperand RO, 1762 list<Register> DefRegs> : 1763 InstSE<(outs), (ins RO:$rs, RO:$rt), !strconcat(opstr, "\t$$zero, $rs, $rt"), 1764 [], itin, FrmR, opstr> { 1765 let Defs = DefRegs; 1766} 1767 1768// Move from Hi/Lo 1769class PseudoMFLOHI<RegisterClass DstRC, RegisterClass SrcRC, SDNode OpNode> 1770 : PseudoSE<(outs DstRC:$rd), (ins SrcRC:$hilo), 1771 [(set DstRC:$rd, (OpNode SrcRC:$hilo))], II_MFHI_MFLO>; 1772 1773class MoveFromLOHI<string opstr, RegisterOperand RO, Register UseReg>: 1774 InstSE<(outs RO:$rd), (ins), !strconcat(opstr, "\t$rd"), [], II_MFHI_MFLO, 1775 FrmR, opstr> { 1776 let Uses = [UseReg]; 1777 let hasSideEffects = 0; 1778 let isMoveReg = 1; 1779} 1780 1781class PseudoMTLOHI<RegisterClass DstRC, RegisterClass SrcRC> 1782 : PseudoSE<(outs DstRC:$lohi), (ins SrcRC:$lo, SrcRC:$hi), 1783 [(set DstRC:$lohi, (MipsMTLOHI SrcRC:$lo, SrcRC:$hi))], 1784 II_MTHI_MTLO>; 1785 1786class MoveToLOHI<string opstr, RegisterOperand RO, list<Register> DefRegs>: 1787 InstSE<(outs), (ins RO:$rs), !strconcat(opstr, "\t$rs"), [], II_MTHI_MTLO, 1788 FrmR, opstr> { 1789 let Defs = DefRegs; 1790 let hasSideEffects = 0; 1791 let isMoveReg = 1; 1792} 1793 1794class EffectiveAddress<string opstr, RegisterOperand RO> : 1795 InstSE<(outs RO:$rt), (ins mem_ea:$addr), !strconcat(opstr, "\t$rt, $addr"), 1796 [(set RO:$rt, addr:$addr)], II_ADDIU, FrmI, 1797 !strconcat(opstr, "_lea")> { 1798 let isCodeGenOnly = 1; 1799 let hasNoSchedulingInfo = 1; 1800 let DecoderMethod = "DecodeMem"; 1801} 1802 1803// Count Leading Ones/Zeros in Word 1804class CountLeading0<string opstr, RegisterOperand RO, 1805 InstrItinClass itin = NoItinerary>: 1806 InstSE<(outs RO:$rd), (ins RO:$rs), !strconcat(opstr, "\t$rd, $rs"), 1807 [(set RO:$rd, (ctlz RO:$rs))], itin, FrmR, opstr>; 1808 1809class CountLeading1<string opstr, RegisterOperand RO, 1810 InstrItinClass itin = NoItinerary>: 1811 InstSE<(outs RO:$rd), (ins RO:$rs), !strconcat(opstr, "\t$rd, $rs"), 1812 [(set RO:$rd, (ctlz (not RO:$rs)))], itin, FrmR, opstr>; 1813 1814// Sign Extend in Register. 1815class SignExtInReg<string opstr, ValueType vt, RegisterOperand RO, 1816 InstrItinClass itin> : 1817 InstSE<(outs RO:$rd), (ins RO:$rt), !strconcat(opstr, "\t$rd, $rt"), 1818 [(set RO:$rd, (sext_inreg RO:$rt, vt))], itin, FrmR, opstr>; 1819 1820// Subword Swap 1821class SubwordSwap<string opstr, RegisterOperand RO, 1822 InstrItinClass itin = NoItinerary>: 1823 InstSE<(outs RO:$rd), (ins RO:$rt), !strconcat(opstr, "\t$rd, $rt"), [], itin, 1824 FrmR, opstr> { 1825 let hasSideEffects = 0; 1826} 1827 1828// Read Hardware 1829class ReadHardware<RegisterOperand CPURegOperand, RegisterOperand RO> : 1830 InstSE<(outs CPURegOperand:$rt), (ins RO:$rd, uimm8:$sel), 1831 "rdhwr\t$rt, $rd, $sel", [], II_RDHWR, FrmR, "rdhwr">; 1832 1833// Ext and Ins 1834class ExtBase<string opstr, RegisterOperand RO, Operand PosOpnd, 1835 Operand SizeOpnd, PatFrag PosImm, PatFrag SizeImm, 1836 SDPatternOperator Op = null_frag> : 1837 InstSE<(outs RO:$rt), (ins RO:$rs, PosOpnd:$pos, SizeOpnd:$size), 1838 !strconcat(opstr, "\t$rt, $rs, $pos, $size"), 1839 [(set RO:$rt, (Op RO:$rs, PosImm:$pos, SizeImm:$size))], II_EXT, 1840 FrmR, opstr>; 1841 1842// 'ins' and its' 64 bit variants are matched by C++ code. 1843class InsBase<string opstr, RegisterOperand RO, Operand PosOpnd, 1844 Operand SizeOpnd, PatFrag PosImm, PatFrag SizeImm>: 1845 InstSE<(outs RO:$rt), (ins RO:$rs, PosOpnd:$pos, SizeOpnd:$size, RO:$src), 1846 !strconcat(opstr, "\t$rt, $rs, $pos, $size"), 1847 [(set RO:$rt, (null_frag RO:$rs, PosImm:$pos, SizeImm:$size, 1848 RO:$src))], 1849 II_INS, FrmR, opstr> { 1850 let Constraints = "$src = $rt"; 1851} 1852 1853// Atomic instructions with 2 source operands (ATOMIC_SWAP & ATOMIC_LOAD_*). 1854class Atomic2Ops<PatFrag Op, RegisterClass DRC> : 1855 PseudoSE<(outs DRC:$dst), (ins PtrRC:$ptr, DRC:$incr), 1856 [(set DRC:$dst, (Op iPTR:$ptr, DRC:$incr))]> { 1857 let hasNoSchedulingInfo = 1; 1858} 1859 1860class Atomic2OpsPostRA<RegisterClass RC> : 1861 PseudoSE<(outs RC:$dst), (ins PtrRC:$ptr, RC:$incr), []> { 1862 let mayLoad = 1; 1863 let mayStore = 1; 1864} 1865 1866class Atomic2OpsSubwordPostRA<RegisterClass RC> : 1867 PseudoSE<(outs RC:$dst), (ins PtrRC:$ptr, RC:$incr, RC:$mask, RC:$mask2, 1868 RC:$shiftamnt), []>; 1869 1870// Atomic Compare & Swap. 1871// Atomic compare and swap is lowered into two stages. The first stage happens 1872// during ISelLowering, which produces the PostRA version of this instruction. 1873class AtomicCmpSwap<PatFrag Op, RegisterClass DRC> : 1874 PseudoSE<(outs DRC:$dst), (ins PtrRC:$ptr, DRC:$cmp, DRC:$swap), 1875 [(set DRC:$dst, (Op iPTR:$ptr, DRC:$cmp, DRC:$swap))]> { 1876 let hasNoSchedulingInfo = 1; 1877} 1878 1879class AtomicCmpSwapPostRA<RegisterClass RC> : 1880 PseudoSE<(outs RC:$dst), (ins PtrRC:$ptr, RC:$cmp, RC:$swap), []> { 1881 let mayLoad = 1; 1882 let mayStore = 1; 1883} 1884 1885class AtomicCmpSwapSubwordPostRA<RegisterClass RC> : 1886 PseudoSE<(outs RC:$dst), (ins PtrRC:$ptr, RC:$mask, RC:$ShiftCmpVal, 1887 RC:$mask2, RC:$ShiftNewVal, RC:$ShiftAmt), []> { 1888 let mayLoad = 1; 1889 let mayStore = 1; 1890} 1891 1892class LLBase<string opstr, RegisterOperand RO, DAGOperand MO = mem> : 1893 InstSE<(outs RO:$rt), (ins MO:$addr), !strconcat(opstr, "\t$rt, $addr"), 1894 [], II_LL, FrmI, opstr> { 1895 let DecoderMethod = "DecodeMem"; 1896 let mayLoad = 1; 1897} 1898 1899class SCBase<string opstr, RegisterOperand RO> : 1900 InstSE<(outs RO:$dst), (ins RO:$rt, mem:$addr), 1901 !strconcat(opstr, "\t$rt, $addr"), [], II_SC, FrmI> { 1902 let DecoderMethod = "DecodeMem"; 1903 let mayStore = 1; 1904 let Constraints = "$rt = $dst"; 1905} 1906 1907class MFC3OP<string asmstr, RegisterOperand RO, RegisterOperand RD, 1908 InstrItinClass itin> : 1909 InstSE<(outs RO:$rt), (ins RD:$rd, uimm3:$sel), 1910 !strconcat(asmstr, "\t$rt, $rd, $sel"), [], itin, FrmFR> { 1911 let BaseOpcode = asmstr; 1912} 1913 1914class MTC3OP<string asmstr, RegisterOperand RO, RegisterOperand RD, 1915 InstrItinClass itin> : 1916 InstSE<(outs RO:$rd), (ins RD:$rt, uimm3:$sel), 1917 !strconcat(asmstr, "\t$rt, $rd, $sel"), [], itin, FrmFR> { 1918 let BaseOpcode = asmstr; 1919} 1920 1921class TrapBase<Instruction RealInst> 1922 : PseudoSE<(outs), (ins), [(trap)], II_TRAP>, 1923 PseudoInstExpansion<(RealInst 0, 0)> { 1924 let isBarrier = 1; 1925 let isTerminator = 1; 1926 let isCodeGenOnly = 1; 1927 let isCTI = 1; 1928} 1929 1930//===----------------------------------------------------------------------===// 1931// Pseudo instructions 1932//===----------------------------------------------------------------------===// 1933 1934// Return RA. 1935let isReturn=1, isTerminator=1, isBarrier=1, hasCtrlDep=1, isCTI=1 in { 1936 let hasDelaySlot=1 in 1937 def RetRA : PseudoSE<(outs), (ins), [(MipsRet)]>; 1938 1939 let hasSideEffects=1 in 1940 def ERet : PseudoSE<(outs), (ins), [(MipsERet)]>; 1941} 1942 1943let Defs = [SP], Uses = [SP], hasSideEffects = 1, hasNoSchedulingInfo = 1 in { 1944def ADJCALLSTACKDOWN : MipsPseudo<(outs), (ins i32imm:$amt1, i32imm:$amt2), 1945 [(callseq_start timm:$amt1, timm:$amt2)]>; 1946def ADJCALLSTACKUP : MipsPseudo<(outs), (ins i32imm:$amt1, i32imm:$amt2), 1947 [(callseq_end timm:$amt1, timm:$amt2)]>; 1948} 1949 1950let usesCustomInserter = 1 in { 1951 def ATOMIC_LOAD_ADD_I8 : Atomic2Ops<atomic_load_add_8, GPR32>; 1952 def ATOMIC_LOAD_ADD_I16 : Atomic2Ops<atomic_load_add_16, GPR32>; 1953 def ATOMIC_LOAD_ADD_I32 : Atomic2Ops<atomic_load_add_32, GPR32>; 1954 def ATOMIC_LOAD_SUB_I8 : Atomic2Ops<atomic_load_sub_8, GPR32>; 1955 def ATOMIC_LOAD_SUB_I16 : Atomic2Ops<atomic_load_sub_16, GPR32>; 1956 def ATOMIC_LOAD_SUB_I32 : Atomic2Ops<atomic_load_sub_32, GPR32>; 1957 def ATOMIC_LOAD_AND_I8 : Atomic2Ops<atomic_load_and_8, GPR32>; 1958 def ATOMIC_LOAD_AND_I16 : Atomic2Ops<atomic_load_and_16, GPR32>; 1959 def ATOMIC_LOAD_AND_I32 : Atomic2Ops<atomic_load_and_32, GPR32>; 1960 def ATOMIC_LOAD_OR_I8 : Atomic2Ops<atomic_load_or_8, GPR32>; 1961 def ATOMIC_LOAD_OR_I16 : Atomic2Ops<atomic_load_or_16, GPR32>; 1962 def ATOMIC_LOAD_OR_I32 : Atomic2Ops<atomic_load_or_32, GPR32>; 1963 def ATOMIC_LOAD_XOR_I8 : Atomic2Ops<atomic_load_xor_8, GPR32>; 1964 def ATOMIC_LOAD_XOR_I16 : Atomic2Ops<atomic_load_xor_16, GPR32>; 1965 def ATOMIC_LOAD_XOR_I32 : Atomic2Ops<atomic_load_xor_32, GPR32>; 1966 def ATOMIC_LOAD_NAND_I8 : Atomic2Ops<atomic_load_nand_8, GPR32>; 1967 def ATOMIC_LOAD_NAND_I16 : Atomic2Ops<atomic_load_nand_16, GPR32>; 1968 def ATOMIC_LOAD_NAND_I32 : Atomic2Ops<atomic_load_nand_32, GPR32>; 1969 1970 def ATOMIC_SWAP_I8 : Atomic2Ops<atomic_swap_8, GPR32>; 1971 def ATOMIC_SWAP_I16 : Atomic2Ops<atomic_swap_16, GPR32>; 1972 def ATOMIC_SWAP_I32 : Atomic2Ops<atomic_swap_32, GPR32>; 1973 1974 def ATOMIC_CMP_SWAP_I8 : AtomicCmpSwap<atomic_cmp_swap_8, GPR32>; 1975 def ATOMIC_CMP_SWAP_I16 : AtomicCmpSwap<atomic_cmp_swap_16, GPR32>; 1976 def ATOMIC_CMP_SWAP_I32 : AtomicCmpSwap<atomic_cmp_swap_32, GPR32>; 1977 1978} 1979 1980def ATOMIC_LOAD_ADD_I8_POSTRA : Atomic2OpsSubwordPostRA<GPR32>; 1981def ATOMIC_LOAD_ADD_I16_POSTRA : Atomic2OpsSubwordPostRA<GPR32>; 1982def ATOMIC_LOAD_ADD_I32_POSTRA : Atomic2OpsPostRA<GPR32>; 1983def ATOMIC_LOAD_SUB_I8_POSTRA : Atomic2OpsSubwordPostRA<GPR32>; 1984def ATOMIC_LOAD_SUB_I16_POSTRA : Atomic2OpsSubwordPostRA<GPR32>; 1985def ATOMIC_LOAD_SUB_I32_POSTRA : Atomic2OpsPostRA<GPR32>; 1986def ATOMIC_LOAD_AND_I8_POSTRA : Atomic2OpsSubwordPostRA<GPR32>; 1987def ATOMIC_LOAD_AND_I16_POSTRA : Atomic2OpsSubwordPostRA<GPR32>; 1988def ATOMIC_LOAD_AND_I32_POSTRA : Atomic2OpsPostRA<GPR32>; 1989def ATOMIC_LOAD_OR_I8_POSTRA : Atomic2OpsSubwordPostRA<GPR32>; 1990def ATOMIC_LOAD_OR_I16_POSTRA : Atomic2OpsSubwordPostRA<GPR32>; 1991def ATOMIC_LOAD_OR_I32_POSTRA : Atomic2OpsPostRA<GPR32>; 1992def ATOMIC_LOAD_XOR_I8_POSTRA : Atomic2OpsSubwordPostRA<GPR32>; 1993def ATOMIC_LOAD_XOR_I16_POSTRA : Atomic2OpsSubwordPostRA<GPR32>; 1994def ATOMIC_LOAD_XOR_I32_POSTRA : Atomic2OpsPostRA<GPR32>; 1995def ATOMIC_LOAD_NAND_I8_POSTRA : Atomic2OpsSubwordPostRA<GPR32>; 1996def ATOMIC_LOAD_NAND_I16_POSTRA : Atomic2OpsSubwordPostRA<GPR32>; 1997def ATOMIC_LOAD_NAND_I32_POSTRA : Atomic2OpsPostRA<GPR32>; 1998 1999def ATOMIC_SWAP_I8_POSTRA : Atomic2OpsSubwordPostRA<GPR32>; 2000def ATOMIC_SWAP_I16_POSTRA : Atomic2OpsSubwordPostRA<GPR32>; 2001def ATOMIC_SWAP_I32_POSTRA : Atomic2OpsPostRA<GPR32>; 2002 2003def ATOMIC_CMP_SWAP_I8_POSTRA : AtomicCmpSwapSubwordPostRA<GPR32>; 2004def ATOMIC_CMP_SWAP_I16_POSTRA : AtomicCmpSwapSubwordPostRA<GPR32>; 2005def ATOMIC_CMP_SWAP_I32_POSTRA : AtomicCmpSwapPostRA<GPR32>; 2006 2007/// Pseudo instructions for loading and storing accumulator registers. 2008let isPseudo = 1, isCodeGenOnly = 1, hasNoSchedulingInfo = 1 in { 2009 def LOAD_ACC64 : Load<"", ACC64>; 2010 def STORE_ACC64 : Store<"", ACC64>; 2011} 2012 2013// We need these two pseudo instructions to avoid offset calculation for long 2014// branches. See the comment in file MipsLongBranch.cpp for detailed 2015// explanation. 2016 2017// Expands to: lui $dst, %highest/%higher/%hi/%lo($tgt - $baltgt) 2018def LONG_BRANCH_LUi : PseudoSE<(outs GPR32Opnd:$dst), 2019 (ins brtarget:$tgt, brtarget:$baltgt), []> { 2020 bit hasNoSchedulingInfo = 1; 2021} 2022// Expands to: lui $dst, highest/%higher/%hi/%lo($tgt) 2023def LONG_BRANCH_LUi2Op : PseudoSE<(outs GPR32Opnd:$dst), 2024 (ins brtarget:$tgt), []> { 2025 bit hasNoSchedulingInfo = 1; 2026} 2027 2028// Expands to: addiu $dst, $src, %highest/%higher/%hi/%lo($tgt - $baltgt) 2029def LONG_BRANCH_ADDiu : PseudoSE<(outs GPR32Opnd:$dst), 2030 (ins GPR32Opnd:$src, brtarget:$tgt, brtarget:$baltgt), []> { 2031 bit hasNoSchedulingInfo = 1; 2032} 2033// Expands to: addiu $dst, $src, %highest/%higher/%hi/%lo($tgt) 2034def LONG_BRANCH_ADDiu2Op : PseudoSE<(outs GPR32Opnd:$dst), 2035 (ins GPR32Opnd:$src, brtarget:$tgt), []> { 2036 bit hasNoSchedulingInfo = 1; 2037} 2038 2039//===----------------------------------------------------------------------===// 2040// Instruction definition 2041//===----------------------------------------------------------------------===// 2042//===----------------------------------------------------------------------===// 2043// MipsI Instructions 2044//===----------------------------------------------------------------------===// 2045 2046/// Arithmetic Instructions (ALU Immediate) 2047let AdditionalPredicates = [NotInMicroMips] in { 2048 def ADDiu : MMRel, StdMMR6Rel, ArithLogicI<"addiu", simm16_relaxed, GPR32Opnd, 2049 II_ADDIU, immSExt16, add>, 2050 ADDI_FM<0x9>, IsAsCheapAsAMove, ISA_MIPS1; 2051 2052 def ANDi : MMRel, StdMMR6Rel, 2053 ArithLogicI<"andi", uimm16, GPR32Opnd, II_ANDI, immZExt16, and>, 2054 ADDI_FM<0xc>, ISA_MIPS1; 2055 def ORi : MMRel, StdMMR6Rel, 2056 ArithLogicI<"ori", uimm16, GPR32Opnd, II_ORI, immZExt16, or>, 2057 ADDI_FM<0xd>, ISA_MIPS1; 2058 def XORi : MMRel, StdMMR6Rel, 2059 ArithLogicI<"xori", uimm16, GPR32Opnd, II_XORI, immZExt16, xor>, 2060 ADDI_FM<0xe>, ISA_MIPS1; 2061 def ADDi : MMRel, ArithLogicI<"addi", simm16_relaxed, GPR32Opnd, II_ADDI>, 2062 ADDI_FM<0x8>, ISA_MIPS1_NOT_32R6_64R6; 2063 def SLTi : MMRel, SetCC_I<"slti", setlt, simm16, immSExt16, GPR32Opnd>, 2064 SLTI_FM<0xa>, ISA_MIPS1; 2065 def SLTiu : MMRel, SetCC_I<"sltiu", setult, simm16, immSExt16, GPR32Opnd>, 2066 SLTI_FM<0xb>, ISA_MIPS1; 2067 2068 def LUi : MMRel, LoadUpper<"lui", GPR32Opnd, uimm16_relaxed>, LUI_FM, 2069 ISA_MIPS1; 2070 2071 /// Arithmetic Instructions (3-Operand, R-Type) 2072 def ADDu : MMRel, StdMMR6Rel, ArithLogicR<"addu", GPR32Opnd, 1, II_ADDU, add>, 2073 ADD_FM<0, 0x21>, ISA_MIPS1; 2074 def SUBu : MMRel, StdMMR6Rel, ArithLogicR<"subu", GPR32Opnd, 0, II_SUBU, sub>, 2075 ADD_FM<0, 0x23>, ISA_MIPS1; 2076 2077 let Defs = [HI0, LO0] in 2078 def MUL : MMRel, ArithLogicR<"mul", GPR32Opnd, 1, II_MUL, mul>, 2079 ADD_FM<0x1c, 2>, ISA_MIPS32_NOT_32R6_64R6; 2080 2081 def ADD : MMRel, StdMMR6Rel, ArithLogicR<"add", GPR32Opnd, 1, II_ADD>, 2082 ADD_FM<0, 0x20>, ISA_MIPS1; 2083 def SUB : MMRel, StdMMR6Rel, ArithLogicR<"sub", GPR32Opnd, 0, II_SUB>, 2084 ADD_FM<0, 0x22>, ISA_MIPS1; 2085 2086 def SLT : MMRel, SetCC_R<"slt", setlt, GPR32Opnd>, ADD_FM<0, 0x2a>, 2087 ISA_MIPS1; 2088 def SLTu : MMRel, SetCC_R<"sltu", setult, GPR32Opnd>, ADD_FM<0, 0x2b>, 2089 ISA_MIPS1; 2090 def AND : MMRel, StdMMR6Rel, ArithLogicR<"and", GPR32Opnd, 1, II_AND, and>, 2091 ADD_FM<0, 0x24>, ISA_MIPS1; 2092 def OR : MMRel, StdMMR6Rel, ArithLogicR<"or", GPR32Opnd, 1, II_OR, or>, 2093 ADD_FM<0, 0x25>, ISA_MIPS1; 2094 def XOR : MMRel, StdMMR6Rel, ArithLogicR<"xor", GPR32Opnd, 1, II_XOR, xor>, 2095 ADD_FM<0, 0x26>, ISA_MIPS1; 2096 def NOR : MMRel, StdMMR6Rel, LogicNOR<"nor", GPR32Opnd>, ADD_FM<0, 0x27>, 2097 ISA_MIPS1; 2098} 2099 2100let AdditionalPredicates = [NotInMicroMips] in { 2101 /// Shift Instructions 2102 def SLL : MMRel, shift_rotate_imm<"sll", uimm5, GPR32Opnd, II_SLL, shl, 2103 immZExt5>, SRA_FM<0, 0>, ISA_MIPS1; 2104 def SRL : MMRel, shift_rotate_imm<"srl", uimm5, GPR32Opnd, II_SRL, srl, 2105 immZExt5>, SRA_FM<2, 0>, ISA_MIPS1; 2106 def SRA : MMRel, shift_rotate_imm<"sra", uimm5, GPR32Opnd, II_SRA, sra, 2107 immZExt5>, SRA_FM<3, 0>, ISA_MIPS1; 2108 def SLLV : MMRel, shift_rotate_reg<"sllv", GPR32Opnd, II_SLLV, shl>, 2109 SRLV_FM<4, 0>, ISA_MIPS1; 2110 def SRLV : MMRel, shift_rotate_reg<"srlv", GPR32Opnd, II_SRLV, srl>, 2111 SRLV_FM<6, 0>, ISA_MIPS1; 2112 def SRAV : MMRel, shift_rotate_reg<"srav", GPR32Opnd, II_SRAV, sra>, 2113 SRLV_FM<7, 0>, ISA_MIPS1; 2114 2115 // Rotate Instructions 2116 def ROTR : MMRel, shift_rotate_imm<"rotr", uimm5, GPR32Opnd, II_ROTR, rotr, 2117 immZExt5>, 2118 SRA_FM<2, 1>, ISA_MIPS32R2; 2119 def ROTRV : MMRel, shift_rotate_reg<"rotrv", GPR32Opnd, II_ROTRV, rotr>, 2120 SRLV_FM<6, 1>, ISA_MIPS32R2; 2121} 2122 2123/// Load and Store Instructions 2124/// aligned 2125let AdditionalPredicates = [NotInMicroMips] in { 2126 def LB : LoadMemory<"lb", GPR32Opnd, mem_simmptr, sextloadi8, II_LB>, MMRel, 2127 LW_FM<0x20>, ISA_MIPS1; 2128 def LBu : LoadMemory<"lbu", GPR32Opnd, mem_simmptr, zextloadi8, II_LBU, 2129 addrDefault>, MMRel, LW_FM<0x24>, ISA_MIPS1; 2130 def LH : LoadMemory<"lh", GPR32Opnd, mem_simmptr, sextloadi16, II_LH, 2131 addrDefault>, MMRel, LW_FM<0x21>, ISA_MIPS1; 2132 def LHu : LoadMemory<"lhu", GPR32Opnd, mem_simmptr, zextloadi16, II_LHU>, 2133 MMRel, LW_FM<0x25>, ISA_MIPS1; 2134 def LW : StdMMR6Rel, Load<"lw", GPR32Opnd, load, II_LW, addrDefault>, MMRel, 2135 LW_FM<0x23>, ISA_MIPS1; 2136 def SB : StdMMR6Rel, Store<"sb", GPR32Opnd, truncstorei8, II_SB>, MMRel, 2137 LW_FM<0x28>, ISA_MIPS1; 2138 def SH : Store<"sh", GPR32Opnd, truncstorei16, II_SH>, MMRel, LW_FM<0x29>, 2139 ISA_MIPS1; 2140 def SW : StdMMR6Rel, Store<"sw", GPR32Opnd, store, II_SW>, 2141 MMRel, LW_FM<0x2b>, ISA_MIPS1; 2142} 2143 2144/// load/store left/right 2145let AdditionalPredicates = [NotInMicroMips] in { 2146def LWL : MMRel, LoadLeftRight<"lwl", MipsLWL, GPR32Opnd, II_LWL>, LW_FM<0x22>, 2147 ISA_MIPS1_NOT_32R6_64R6; 2148def LWR : MMRel, LoadLeftRight<"lwr", MipsLWR, GPR32Opnd, II_LWR>, LW_FM<0x26>, 2149 ISA_MIPS1_NOT_32R6_64R6; 2150def SWL : MMRel, StoreLeftRight<"swl", MipsSWL, GPR32Opnd, II_SWL>, LW_FM<0x2a>, 2151 ISA_MIPS1_NOT_32R6_64R6; 2152def SWR : MMRel, StoreLeftRight<"swr", MipsSWR, GPR32Opnd, II_SWR>, LW_FM<0x2e>, 2153 ISA_MIPS1_NOT_32R6_64R6; 2154 2155// COP2 Memory Instructions 2156def LWC2 : StdMMR6Rel, LW_FT2<"lwc2", COP2Opnd, II_LWC2, load>, LW_FM<0x32>, 2157 ISA_MIPS1_NOT_32R6_64R6; 2158def SWC2 : StdMMR6Rel, SW_FT2<"swc2", COP2Opnd, II_SWC2, store>, 2159 LW_FM<0x3a>, ISA_MIPS1_NOT_32R6_64R6; 2160def LDC2 : StdMMR6Rel, LW_FT2<"ldc2", COP2Opnd, II_LDC2, load>, LW_FM<0x36>, 2161 ISA_MIPS2_NOT_32R6_64R6; 2162def SDC2 : StdMMR6Rel, SW_FT2<"sdc2", COP2Opnd, II_SDC2, store>, 2163 LW_FM<0x3e>, ISA_MIPS2_NOT_32R6_64R6; 2164 2165// COP3 Memory Instructions 2166let DecoderNamespace = "COP3_" in { 2167 def LWC3 : LW_FT3<"lwc3", COP3Opnd, II_LWC3, load>, LW_FM<0x33>, 2168 ISA_MIPS1_NOT_32R6_64R6, NOT_ASE_CNMIPS; 2169 def SWC3 : SW_FT3<"swc3", COP3Opnd, II_SWC3, store>, LW_FM<0x3b>, 2170 ISA_MIPS1_NOT_32R6_64R6, NOT_ASE_CNMIPS; 2171 def LDC3 : LW_FT3<"ldc3", COP3Opnd, II_LDC3, load>, LW_FM<0x37>, 2172 ISA_MIPS2, NOT_ASE_CNMIPS; 2173 def SDC3 : SW_FT3<"sdc3", COP3Opnd, II_SDC3, store>, LW_FM<0x3f>, 2174 ISA_MIPS2, NOT_ASE_CNMIPS; 2175} 2176 2177 def SYNC : MMRel, StdMMR6Rel, SYNC_FT<"sync">, SYNC_FM, ISA_MIPS2; 2178 def SYNCI : MMRel, StdMMR6Rel, SYNCI_FT<"synci", mem_simm16>, SYNCI_FM, 2179 ISA_MIPS32R2; 2180} 2181 2182let AdditionalPredicates = [NotInMicroMips] in { 2183 def TEQ : MMRel, TEQ_FT<"teq", GPR32Opnd, uimm10, II_TEQ>, TEQ_FM<0x34>, 2184 ISA_MIPS2; 2185 def TGE : MMRel, TEQ_FT<"tge", GPR32Opnd, uimm10, II_TGE>, TEQ_FM<0x30>, 2186 ISA_MIPS2; 2187 def TGEU : MMRel, TEQ_FT<"tgeu", GPR32Opnd, uimm10, II_TGEU>, TEQ_FM<0x31>, 2188 ISA_MIPS2; 2189 def TLT : MMRel, TEQ_FT<"tlt", GPR32Opnd, uimm10, II_TLT>, TEQ_FM<0x32>, 2190 ISA_MIPS2; 2191 def TLTU : MMRel, TEQ_FT<"tltu", GPR32Opnd, uimm10, II_TLTU>, TEQ_FM<0x33>, 2192 ISA_MIPS2; 2193 def TNE : MMRel, TEQ_FT<"tne", GPR32Opnd, uimm10, II_TNE>, TEQ_FM<0x36>, 2194 ISA_MIPS2; 2195 2196 def TEQI : MMRel, TEQI_FT<"teqi", GPR32Opnd, II_TEQI>, TEQI_FM<0xc>, 2197 ISA_MIPS2_NOT_32R6_64R6; 2198 def TGEI : MMRel, TEQI_FT<"tgei", GPR32Opnd, II_TGEI>, TEQI_FM<0x8>, 2199 ISA_MIPS2_NOT_32R6_64R6; 2200 def TGEIU : MMRel, TEQI_FT<"tgeiu", GPR32Opnd, II_TGEIU>, TEQI_FM<0x9>, 2201 ISA_MIPS2_NOT_32R6_64R6; 2202 def TLTI : MMRel, TEQI_FT<"tlti", GPR32Opnd, II_TLTI>, TEQI_FM<0xa>, 2203 ISA_MIPS2_NOT_32R6_64R6; 2204 def TTLTIU : MMRel, TEQI_FT<"tltiu", GPR32Opnd, II_TTLTIU>, TEQI_FM<0xb>, 2205 ISA_MIPS2_NOT_32R6_64R6; 2206 def TNEI : MMRel, TEQI_FT<"tnei", GPR32Opnd, II_TNEI>, TEQI_FM<0xe>, 2207 ISA_MIPS2_NOT_32R6_64R6; 2208} 2209 2210let AdditionalPredicates = [NotInMicroMips] in { 2211 def BREAK : MMRel, StdMMR6Rel, BRK_FT<"break">, BRK_FM<0xd>, ISA_MIPS1; 2212 def SYSCALL : MMRel, SYS_FT<"syscall", uimm20, II_SYSCALL>, SYS_FM<0xc>, 2213 ISA_MIPS1; 2214 def TRAP : TrapBase<BREAK>, ISA_MIPS1; 2215 def SDBBP : MMRel, SYS_FT<"sdbbp", uimm20, II_SDBBP>, SDBBP_FM, 2216 ISA_MIPS32_NOT_32R6_64R6; 2217 2218 def ERET : MMRel, ER_FT<"eret", II_ERET>, ER_FM<0x18, 0x0>, INSN_MIPS3_32; 2219 def ERETNC : MMRel, ER_FT<"eretnc", II_ERETNC>, ER_FM<0x18, 0x1>, 2220 ISA_MIPS32R5; 2221 def DERET : MMRel, ER_FT<"deret", II_DERET>, ER_FM<0x1f, 0x0>, ISA_MIPS32; 2222 2223 def EI : MMRel, StdMMR6Rel, DEI_FT<"ei", GPR32Opnd, II_EI>, EI_FM<1>, 2224 ISA_MIPS32R2; 2225 def DI : MMRel, StdMMR6Rel, DEI_FT<"di", GPR32Opnd, II_DI>, EI_FM<0>, 2226 ISA_MIPS32R2; 2227 2228 def WAIT : MMRel, StdMMR6Rel, WAIT_FT<"wait">, WAIT_FM, INSN_MIPS3_32; 2229} 2230 2231let AdditionalPredicates = [NotInMicroMips] in { 2232/// Load-linked, Store-conditional 2233def LL : LLBase<"ll", GPR32Opnd>, LW_FM<0x30>, PTR_32, ISA_MIPS2_NOT_32R6_64R6; 2234def SC : SCBase<"sc", GPR32Opnd>, LW_FM<0x38>, PTR_32, ISA_MIPS2_NOT_32R6_64R6; 2235} 2236/// Jump and Branch Instructions 2237let AdditionalPredicates = [NotInMicroMips, RelocNotPIC] in 2238def J : MMRel, JumpFJ<jmptarget, "j", br, bb, "j">, FJ<2>, 2239 IsBranch, ISA_MIPS1; 2240 2241let AdditionalPredicates = [NotInMicroMips] in { 2242def JR : MMRel, IndirectBranch<"jr", GPR32Opnd>, MTLO_FM<8>, 2243 ISA_MIPS1_NOT_32R6_64R6; 2244def BEQ : MMRel, CBranch<"beq", brtarget, seteq, GPR32Opnd>, BEQ_FM<4>, 2245 ISA_MIPS1; 2246def BEQL : MMRel, CBranchLikely<"beql", brtarget, GPR32Opnd>, 2247 BEQ_FM<20>, ISA_MIPS2_NOT_32R6_64R6; 2248def BNE : MMRel, CBranch<"bne", brtarget, setne, GPR32Opnd>, BEQ_FM<5>, 2249 ISA_MIPS1; 2250def BNEL : MMRel, CBranchLikely<"bnel", brtarget, GPR32Opnd>, 2251 BEQ_FM<21>, ISA_MIPS2_NOT_32R6_64R6; 2252def BGEZ : MMRel, CBranchZero<"bgez", brtarget, setge, GPR32Opnd>, 2253 BGEZ_FM<1, 1>, ISA_MIPS1; 2254def BGEZL : MMRel, CBranchZeroLikely<"bgezl", brtarget, GPR32Opnd>, 2255 BGEZ_FM<1, 3>, ISA_MIPS2_NOT_32R6_64R6; 2256def BGTZ : MMRel, CBranchZero<"bgtz", brtarget, setgt, GPR32Opnd>, 2257 BGEZ_FM<7, 0>, ISA_MIPS1; 2258def BGTZL : MMRel, CBranchZeroLikely<"bgtzl", brtarget, GPR32Opnd>, 2259 BGEZ_FM<23, 0>, ISA_MIPS2_NOT_32R6_64R6; 2260def BLEZ : MMRel, CBranchZero<"blez", brtarget, setle, GPR32Opnd>, 2261 BGEZ_FM<6, 0>, ISA_MIPS1; 2262def BLEZL : MMRel, CBranchZeroLikely<"blezl", brtarget, GPR32Opnd>, 2263 BGEZ_FM<22, 0>, ISA_MIPS2_NOT_32R6_64R6; 2264def BLTZ : MMRel, CBranchZero<"bltz", brtarget, setlt, GPR32Opnd>, 2265 BGEZ_FM<1, 0>, ISA_MIPS1; 2266def BLTZL : MMRel, CBranchZeroLikely<"bltzl", brtarget, GPR32Opnd>, 2267 BGEZ_FM<1, 2>, ISA_MIPS2_NOT_32R6_64R6; 2268def B : UncondBranch<BEQ, brtarget>, ISA_MIPS1; 2269 2270def JAL : MMRel, JumpLink<"jal", calltarget>, FJ<3>, ISA_MIPS1; 2271 2272} 2273 2274let AdditionalPredicates = [NotInMicroMips, NoIndirectJumpGuards] in { 2275 def JALR : JumpLinkReg<"jalr", GPR32Opnd>, JALR_FM, ISA_MIPS1; 2276 def JALRPseudo : JumpLinkRegPseudo<GPR32Opnd, JALR, RA>, ISA_MIPS1; 2277} 2278 2279let AdditionalPredicates = [NotInMicroMips] in { 2280 def JALX : MMRel, JumpLink<"jalx", calltarget>, FJ<0x1D>, 2281 ISA_MIPS32_NOT_32R6_64R6; 2282 def BGEZAL : MMRel, BGEZAL_FT<"bgezal", brtarget, GPR32Opnd>, BGEZAL_FM<0x11>, 2283 ISA_MIPS1_NOT_32R6_64R6; 2284 def BGEZALL : MMRel, BGEZAL_FT<"bgezall", brtarget, GPR32Opnd>, 2285 BGEZAL_FM<0x13>, ISA_MIPS2_NOT_32R6_64R6; 2286 def BLTZAL : MMRel, BGEZAL_FT<"bltzal", brtarget, GPR32Opnd>, BGEZAL_FM<0x10>, 2287 ISA_MIPS1_NOT_32R6_64R6; 2288 def BLTZALL : MMRel, BGEZAL_FT<"bltzall", brtarget, GPR32Opnd>, 2289 BGEZAL_FM<0x12>, ISA_MIPS2_NOT_32R6_64R6; 2290 def BAL_BR : BAL_BR_Pseudo<BGEZAL, brtarget>, ISA_MIPS1; 2291} 2292let AdditionalPredicates = [NotInMips16Mode, NotInMicroMips] in { 2293 def TAILCALL : TailCall<J, jmptarget>, ISA_MIPS1; 2294} 2295let AdditionalPredicates = [NotInMips16Mode, NotInMicroMips, 2296 NoIndirectJumpGuards] in 2297 def TAILCALLREG : TailCallReg<JR, GPR32Opnd>, ISA_MIPS1_NOT_32R6_64R6; 2298 2299// Indirect branches are matched as PseudoIndirectBranch/PseudoIndirectBranch64 2300// then are expanded to JR, JR64, JALR, or JALR64 depending on the ISA. 2301class PseudoIndirectBranchBase<Instruction JumpInst, RegisterOperand RO> : 2302 MipsPseudo<(outs), (ins RO:$rs), [(brind RO:$rs)], 2303 II_IndirectBranchPseudo>, 2304 PseudoInstExpansion<(JumpInst RO:$rs)> { 2305 let isTerminator=1; 2306 let isBarrier=1; 2307 let hasDelaySlot = 1; 2308 let isBranch = 1; 2309 let isIndirectBranch = 1; 2310 bit isCTI = 1; 2311} 2312 2313let AdditionalPredicates = [NotInMips16Mode, NotInMicroMips, 2314 NoIndirectJumpGuards] in 2315 def PseudoIndirectBranch : PseudoIndirectBranchBase<JR, GPR32Opnd>, 2316 ISA_MIPS1_NOT_32R6_64R6; 2317 2318// Return instructions are matched as a RetRA instruction, then are expanded 2319// into PseudoReturn/PseudoReturn64 after register allocation. Finally, 2320// MipsAsmPrinter expands this into JR, JR64, JALR, or JALR64 depending on the 2321// ISA. 2322class PseudoReturnBase<RegisterOperand RO> : MipsPseudo<(outs), (ins RO:$rs), 2323 [], II_ReturnPseudo> { 2324 let isTerminator = 1; 2325 let isBarrier = 1; 2326 let hasDelaySlot = 1; 2327 let isReturn = 1; 2328 let isCodeGenOnly = 1; 2329 let hasCtrlDep = 1; 2330 let hasExtraSrcRegAllocReq = 1; 2331 bit isCTI = 1; 2332} 2333 2334def PseudoReturn : PseudoReturnBase<GPR32Opnd>; 2335 2336// Exception handling related node and instructions. 2337// The conversion sequence is: 2338// ISD::EH_RETURN -> MipsISD::EH_RETURN -> 2339// MIPSeh_return -> (stack change + indirect branch) 2340// 2341// MIPSeh_return takes the place of regular return instruction 2342// but takes two arguments (V1, V0) which are used for storing 2343// the offset and return address respectively. 2344def SDT_MipsEHRET : SDTypeProfile<0, 2, [SDTCisInt<0>, SDTCisPtrTy<1>]>; 2345 2346def MIPSehret : SDNode<"MipsISD::EH_RETURN", SDT_MipsEHRET, 2347 [SDNPHasChain, SDNPOptInGlue, SDNPVariadic]>; 2348 2349let Uses = [V0, V1], isTerminator = 1, isReturn = 1, 2350 isBarrier = 1, isCTI = 1, hasNoSchedulingInfo = 1 in { 2351 def MIPSeh_return32 : MipsPseudo<(outs), (ins GPR32:$spoff, GPR32:$dst), 2352 [(MIPSehret GPR32:$spoff, GPR32:$dst)]>; 2353 def MIPSeh_return64 : MipsPseudo<(outs), (ins GPR64:$spoff, GPR64:$dst), 2354 [(MIPSehret GPR64:$spoff, GPR64:$dst)]>; 2355} 2356 2357/// Multiply and Divide Instructions. 2358let AdditionalPredicates = [NotInMicroMips] in { 2359 def MULT : MMRel, Mult<"mult", II_MULT, GPR32Opnd, [HI0, LO0]>, 2360 MULT_FM<0, 0x18>, ISA_MIPS1_NOT_32R6_64R6; 2361 def MULTu : MMRel, Mult<"multu", II_MULTU, GPR32Opnd, [HI0, LO0]>, 2362 MULT_FM<0, 0x19>, ISA_MIPS1_NOT_32R6_64R6; 2363 def SDIV : MMRel, Div<"div", II_DIV, GPR32Opnd, [HI0, LO0]>, 2364 MULT_FM<0, 0x1a>, ISA_MIPS1_NOT_32R6_64R6; 2365 def UDIV : MMRel, Div<"divu", II_DIVU, GPR32Opnd, [HI0, LO0]>, 2366 MULT_FM<0, 0x1b>, ISA_MIPS1_NOT_32R6_64R6; 2367 def MTHI : MMRel, MoveToLOHI<"mthi", GPR32Opnd, [HI0]>, MTLO_FM<0x11>, 2368 ISA_MIPS1_NOT_32R6_64R6; 2369 def MTLO : MMRel, MoveToLOHI<"mtlo", GPR32Opnd, [LO0]>, MTLO_FM<0x13>, 2370 ISA_MIPS1_NOT_32R6_64R6; 2371 def MFHI : MMRel, MoveFromLOHI<"mfhi", GPR32Opnd, AC0>, MFLO_FM<0x10>, 2372 ISA_MIPS1_NOT_32R6_64R6; 2373 def MFLO : MMRel, MoveFromLOHI<"mflo", GPR32Opnd, AC0>, MFLO_FM<0x12>, 2374 ISA_MIPS1_NOT_32R6_64R6; 2375 2376 /// Sign Ext In Register Instructions. 2377 def SEB : MMRel, StdMMR6Rel, SignExtInReg<"seb", i8, GPR32Opnd, II_SEB>, 2378 SEB_FM<0x10, 0x20>, ISA_MIPS32R2; 2379 def SEH : MMRel, StdMMR6Rel, SignExtInReg<"seh", i16, GPR32Opnd, II_SEH>, 2380 SEB_FM<0x18, 0x20>, ISA_MIPS32R2; 2381 2382 /// Count Leading 2383 def CLZ : MMRel, CountLeading0<"clz", GPR32Opnd, II_CLZ>, CLO_FM<0x20>, 2384 ISA_MIPS32_NOT_32R6_64R6; 2385 def CLO : MMRel, CountLeading1<"clo", GPR32Opnd, II_CLO>, CLO_FM<0x21>, 2386 ISA_MIPS32_NOT_32R6_64R6; 2387 2388 /// Word Swap Bytes Within Halfwords 2389 def WSBH : MMRel, SubwordSwap<"wsbh", GPR32Opnd, II_WSBH>, SEB_FM<2, 0x20>, 2390 ISA_MIPS32R2; 2391 2392 /// No operation. 2393 def NOP : PseudoSE<(outs), (ins), []>, 2394 PseudoInstExpansion<(SLL ZERO, ZERO, 0)>, ISA_MIPS1; 2395 2396 // FrameIndexes are legalized when they are operands from load/store 2397 // instructions. The same not happens for stack address copies, so an 2398 // add op with mem ComplexPattern is used and the stack address copy 2399 // can be matched. It's similar to Sparc LEA_ADDRi 2400 let AdditionalPredicates = [NotInMicroMips] in 2401 def LEA_ADDiu : MMRel, EffectiveAddress<"addiu", GPR32Opnd>, LW_FM<9>, 2402 ISA_MIPS1; 2403 2404 // MADD*/MSUB* 2405 def MADD : MMRel, MArithR<"madd", II_MADD, 1>, MULT_FM<0x1c, 0>, 2406 ISA_MIPS32_NOT_32R6_64R6; 2407 def MADDU : MMRel, MArithR<"maddu", II_MADDU, 1>, MULT_FM<0x1c, 1>, 2408 ISA_MIPS32_NOT_32R6_64R6; 2409 def MSUB : MMRel, MArithR<"msub", II_MSUB>, MULT_FM<0x1c, 4>, 2410 ISA_MIPS32_NOT_32R6_64R6; 2411 def MSUBU : MMRel, MArithR<"msubu", II_MSUBU>, MULT_FM<0x1c, 5>, 2412 ISA_MIPS32_NOT_32R6_64R6; 2413} 2414 2415let AdditionalPredicates = [NotDSP] in { 2416def PseudoMULT : MultDivPseudo<MULT, ACC64, GPR32Opnd, MipsMult, II_MULT>, 2417 ISA_MIPS1_NOT_32R6_64R6; 2418def PseudoMULTu : MultDivPseudo<MULTu, ACC64, GPR32Opnd, MipsMultu, II_MULTU>, 2419 ISA_MIPS1_NOT_32R6_64R6; 2420def PseudoMFHI : PseudoMFLOHI<GPR32, ACC64, MipsMFHI>, ISA_MIPS1_NOT_32R6_64R6; 2421def PseudoMFLO : PseudoMFLOHI<GPR32, ACC64, MipsMFLO>, ISA_MIPS1_NOT_32R6_64R6; 2422def PseudoMTLOHI : PseudoMTLOHI<ACC64, GPR32>, ISA_MIPS1_NOT_32R6_64R6; 2423def PseudoMADD : MAddSubPseudo<MADD, MipsMAdd, II_MADD>, 2424 ISA_MIPS32_NOT_32R6_64R6; 2425def PseudoMADDU : MAddSubPseudo<MADDU, MipsMAddu, II_MADDU>, 2426 ISA_MIPS32_NOT_32R6_64R6; 2427def PseudoMSUB : MAddSubPseudo<MSUB, MipsMSub, II_MSUB>, 2428 ISA_MIPS32_NOT_32R6_64R6; 2429def PseudoMSUBU : MAddSubPseudo<MSUBU, MipsMSubu, II_MSUBU>, 2430 ISA_MIPS32_NOT_32R6_64R6; 2431} 2432 2433let AdditionalPredicates = [NotInMicroMips] in { 2434 def PseudoSDIV : MultDivPseudo<SDIV, ACC64, GPR32Opnd, MipsDivRem, II_DIV, 2435 0, 1, 1>, ISA_MIPS1_NOT_32R6_64R6; 2436 def PseudoUDIV : MultDivPseudo<UDIV, ACC64, GPR32Opnd, MipsDivRemU, II_DIVU, 2437 0, 1, 1>, ISA_MIPS1_NOT_32R6_64R6; 2438 def RDHWR : MMRel, ReadHardware<GPR32Opnd, HWRegsOpnd>, RDHWR_FM, ISA_MIPS1; 2439 // TODO: Add '0 < pos+size <= 32' constraint check to ext instruction 2440 def EXT : MMRel, StdMMR6Rel, ExtBase<"ext", GPR32Opnd, uimm5, uimm5_plus1, 2441 immZExt5, immZExt5Plus1, MipsExt>, 2442 EXT_FM<0>, ISA_MIPS32R2; 2443 def INS : MMRel, StdMMR6Rel, InsBase<"ins", GPR32Opnd, uimm5, 2444 uimm5_inssize_plus1, immZExt5, 2445 immZExt5Plus1>, 2446 EXT_FM<4>, ISA_MIPS32R2; 2447} 2448/// Move Control Registers From/To CPU Registers 2449let AdditionalPredicates = [NotInMicroMips] in { 2450 def MTC0 : MTC3OP<"mtc0", COP0Opnd, GPR32Opnd, II_MTC0>, 2451 MFC3OP_FM<0x10, 4, 0>, ISA_MIPS1; 2452 def MFC0 : MFC3OP<"mfc0", GPR32Opnd, COP0Opnd, II_MFC0>, 2453 MFC3OP_FM<0x10, 0, 0>, ISA_MIPS1; 2454 def MFC2 : MFC3OP<"mfc2", GPR32Opnd, COP2Opnd, II_MFC2>, 2455 MFC3OP_FM<0x12, 0, 0>, ISA_MIPS1; 2456 def MTC2 : MTC3OP<"mtc2", COP2Opnd, GPR32Opnd, II_MTC2>, 2457 MFC3OP_FM<0x12, 4, 0>, ISA_MIPS1; 2458} 2459 2460class Barrier<string asmstr, InstrItinClass itin = NoItinerary> : 2461 InstSE<(outs), (ins), asmstr, [], itin, FrmOther, asmstr>; 2462let AdditionalPredicates = [NotInMicroMips] in { 2463 def SSNOP : MMRel, StdMMR6Rel, Barrier<"ssnop", II_SSNOP>, BARRIER_FM<1>, 2464 ISA_MIPS1; 2465 def EHB : MMRel, Barrier<"ehb", II_EHB>, BARRIER_FM<3>, ISA_MIPS1; 2466 2467 let isCTI = 1 in 2468 def PAUSE : MMRel, StdMMR6Rel, Barrier<"pause", II_PAUSE>, BARRIER_FM<5>, 2469 ISA_MIPS32R2; 2470} 2471 2472// JR_HB and JALR_HB are defined here using the new style naming 2473// scheme because some of this code is shared with Mips32r6InstrInfo.td 2474// and because of that it doesn't follow the naming convention of the 2475// rest of the file. To avoid a mixture of old vs new style, the new 2476// style was chosen. 2477class JR_HB_DESC_BASE<string instr_asm, RegisterOperand GPROpnd> { 2478 dag OutOperandList = (outs); 2479 dag InOperandList = (ins GPROpnd:$rs); 2480 string AsmString = !strconcat(instr_asm, "\t$rs"); 2481 list<dag> Pattern = []; 2482} 2483 2484class JALR_HB_DESC_BASE<string instr_asm, RegisterOperand GPROpnd> { 2485 dag OutOperandList = (outs GPROpnd:$rd); 2486 dag InOperandList = (ins GPROpnd:$rs); 2487 string AsmString = !strconcat(instr_asm, "\t$rd, $rs"); 2488 list<dag> Pattern = []; 2489} 2490 2491class JR_HB_DESC<RegisterOperand RO> : 2492 InstSE<(outs), (ins), "", [], II_JR_HB, FrmJ>, JR_HB_DESC_BASE<"jr.hb", RO> { 2493 let isBranch=1; 2494 let isIndirectBranch=1; 2495 let hasDelaySlot=1; 2496 let isTerminator=1; 2497 let isBarrier=1; 2498 bit isCTI = 1; 2499} 2500 2501class JALR_HB_DESC<RegisterOperand RO> : 2502 InstSE<(outs), (ins), "", [], II_JALR_HB, FrmJ>, JALR_HB_DESC_BASE<"jalr.hb", 2503 RO> { 2504 let isIndirectBranch=1; 2505 let hasDelaySlot=1; 2506 bit isCTI = 1; 2507} 2508 2509class JR_HB_ENC : JR_HB_FM<8>; 2510class JALR_HB_ENC : JALR_HB_FM<9>; 2511 2512def JR_HB : JR_HB_DESC<GPR32Opnd>, JR_HB_ENC, ISA_MIPS32R2_NOT_32R6_64R6; 2513def JALR_HB : JALR_HB_DESC<GPR32Opnd>, JALR_HB_ENC, ISA_MIPS32; 2514 2515let AdditionalPredicates = [NotInMicroMips, UseIndirectJumpsHazard] in 2516 def JALRHBPseudo : JumpLinkRegPseudo<GPR32Opnd, JALR_HB, RA>; 2517 2518 2519let AdditionalPredicates = [NotInMips16Mode, NotInMicroMips, 2520 UseIndirectJumpsHazard] in { 2521 def TAILCALLREGHB : TailCallReg<JR_HB, GPR32Opnd>, ISA_MIPS32_NOT_32R6_64R6; 2522 def PseudoIndirectHazardBranch : PseudoIndirectBranchBase<JR_HB, GPR32Opnd>, 2523 ISA_MIPS32R2_NOT_32R6_64R6; 2524} 2525 2526class TLB<string asmstr, InstrItinClass itin = NoItinerary> : 2527 InstSE<(outs), (ins), asmstr, [], itin, FrmOther, asmstr>; 2528let AdditionalPredicates = [NotInMicroMips] in { 2529 def TLBP : MMRel, TLB<"tlbp", II_TLBP>, COP0_TLB_FM<0x08>, ISA_MIPS1; 2530 def TLBR : MMRel, TLB<"tlbr", II_TLBR>, COP0_TLB_FM<0x01>, ISA_MIPS1; 2531 def TLBWI : MMRel, TLB<"tlbwi", II_TLBWI>, COP0_TLB_FM<0x02>, ISA_MIPS1; 2532 def TLBWR : MMRel, TLB<"tlbwr", II_TLBWR>, COP0_TLB_FM<0x06>, ISA_MIPS1; 2533} 2534class CacheOp<string instr_asm, Operand MemOpnd, 2535 InstrItinClass itin = NoItinerary> : 2536 InstSE<(outs), (ins MemOpnd:$addr, uimm5:$hint), 2537 !strconcat(instr_asm, "\t$hint, $addr"), [], itin, FrmOther, 2538 instr_asm> { 2539 let DecoderMethod = "DecodeCacheOp"; 2540} 2541 2542let AdditionalPredicates = [NotInMicroMips] in { 2543 def CACHE : MMRel, CacheOp<"cache", mem, II_CACHE>, CACHEOP_FM<0b101111>, 2544 INSN_MIPS3_32_NOT_32R6_64R6; 2545 def PREF : MMRel, CacheOp<"pref", mem, II_PREF>, CACHEOP_FM<0b110011>, 2546 INSN_MIPS3_32_NOT_32R6_64R6; 2547} 2548// FIXME: We are missing the prefx instruction. 2549def ROL : MipsAsmPseudoInst<(outs), 2550 (ins GPR32Opnd:$rs, GPR32Opnd:$rt, GPR32Opnd:$rd), 2551 "rol\t$rs, $rt, $rd">; 2552def ROLImm : MipsAsmPseudoInst<(outs), 2553 (ins GPR32Opnd:$rs, GPR32Opnd:$rt, simm16:$imm), 2554 "rol\t$rs, $rt, $imm">; 2555def : MipsInstAlias<"rol $rd, $rs", 2556 (ROL GPR32Opnd:$rd, GPR32Opnd:$rd, GPR32Opnd:$rs), 0>; 2557def : MipsInstAlias<"rol $rd, $imm", 2558 (ROLImm GPR32Opnd:$rd, GPR32Opnd:$rd, simm16:$imm), 0>; 2559 2560def ROR : MipsAsmPseudoInst<(outs), 2561 (ins GPR32Opnd:$rs, GPR32Opnd:$rt, GPR32Opnd:$rd), 2562 "ror\t$rs, $rt, $rd">; 2563def RORImm : MipsAsmPseudoInst<(outs), 2564 (ins GPR32Opnd:$rs, GPR32Opnd:$rt, simm16:$imm), 2565 "ror\t$rs, $rt, $imm">; 2566def : MipsInstAlias<"ror $rd, $rs", 2567 (ROR GPR32Opnd:$rd, GPR32Opnd:$rd, GPR32Opnd:$rs), 0>; 2568def : MipsInstAlias<"ror $rd, $imm", 2569 (RORImm GPR32Opnd:$rd, GPR32Opnd:$rd, simm16:$imm), 0>; 2570 2571def DROL : MipsAsmPseudoInst<(outs), 2572 (ins GPR32Opnd:$rs, GPR32Opnd:$rt, GPR32Opnd:$rd), 2573 "drol\t$rs, $rt, $rd">, ISA_MIPS64; 2574def DROLImm : MipsAsmPseudoInst<(outs), 2575 (ins GPR32Opnd:$rs, GPR32Opnd:$rt, simm16:$imm), 2576 "drol\t$rs, $rt, $imm">, ISA_MIPS64; 2577def : MipsInstAlias<"drol $rd, $rs", 2578 (DROL GPR32Opnd:$rd, GPR32Opnd:$rd, GPR32Opnd:$rs), 0>, 2579 ISA_MIPS64; 2580def : MipsInstAlias<"drol $rd, $imm", 2581 (DROLImm GPR32Opnd:$rd, GPR32Opnd:$rd, simm16:$imm), 0>, 2582 ISA_MIPS64; 2583 2584def DROR : MipsAsmPseudoInst<(outs), 2585 (ins GPR32Opnd:$rs, GPR32Opnd:$rt, GPR32Opnd:$rd), 2586 "dror\t$rs, $rt, $rd">, ISA_MIPS64; 2587def DRORImm : MipsAsmPseudoInst<(outs), 2588 (ins GPR32Opnd:$rs, GPR32Opnd:$rt, simm16:$imm), 2589 "dror\t$rs, $rt, $imm">, ISA_MIPS64; 2590def : MipsInstAlias<"dror $rd, $rs", 2591 (DROR GPR32Opnd:$rd, GPR32Opnd:$rd, GPR32Opnd:$rs), 0>, 2592 ISA_MIPS64; 2593def : MipsInstAlias<"dror $rd, $imm", 2594 (DRORImm GPR32Opnd:$rd, GPR32Opnd:$rd, simm16:$imm), 0>, 2595 ISA_MIPS64; 2596 2597def ABSMacro : MipsAsmPseudoInst<(outs GPR32Opnd:$rd), (ins GPR32Opnd:$rs), 2598 "abs\t$rd, $rs">; 2599 2600def SEQMacro : MipsAsmPseudoInst<(outs GPR32Opnd:$rd), 2601 (ins GPR32Opnd:$rs, GPR32Opnd:$rt), 2602 "seq $rd, $rs, $rt">, NOT_ASE_CNMIPS; 2603 2604def : MipsInstAlias<"seq $rd, $rs", 2605 (SEQMacro GPR32Opnd:$rd, GPR32Opnd:$rd, GPR32Opnd:$rs), 0>, 2606 NOT_ASE_CNMIPS; 2607 2608def SEQIMacro : MipsAsmPseudoInst<(outs GPR32Opnd:$rd), 2609 (ins GPR32Opnd:$rs, simm32_relaxed:$imm), 2610 "seq $rd, $rs, $imm">, NOT_ASE_CNMIPS; 2611 2612def : MipsInstAlias<"seq $rd, $imm", 2613 (SEQIMacro GPR32Opnd:$rd, GPR32Opnd:$rd, simm32:$imm), 0>, 2614 NOT_ASE_CNMIPS; 2615 2616def MULImmMacro : MipsAsmPseudoInst<(outs), (ins GPR32Opnd:$rd, GPR32Opnd:$rs, 2617 simm32_relaxed:$imm), 2618 "mul\t$rd, $rs, $imm">, 2619 ISA_MIPS1_NOT_32R6_64R6; 2620def MULOMacro : MipsAsmPseudoInst<(outs), (ins GPR32Opnd:$rd, GPR32Opnd:$rs, 2621 GPR32Opnd:$rt), 2622 "mulo\t$rd, $rs, $rt">, 2623 ISA_MIPS1_NOT_32R6_64R6; 2624def MULOUMacro : MipsAsmPseudoInst<(outs), (ins GPR32Opnd:$rd, GPR32Opnd:$rs, 2625 GPR32Opnd:$rt), 2626 "mulou\t$rd, $rs, $rt">, 2627 ISA_MIPS1_NOT_32R6_64R6; 2628 2629// Virtualization ASE 2630class HYPCALL_FT<string opstr> : 2631 InstSE<(outs), (ins uimm10:$code_), 2632 !strconcat(opstr, "\t$code_"), [], II_HYPCALL, FrmOther, opstr> { 2633 let BaseOpcode = opstr; 2634} 2635 2636let AdditionalPredicates = [NotInMicroMips] in { 2637 def MFGC0 : MMRel, MFC3OP<"mfgc0", GPR32Opnd, COP0Opnd, II_MFGC0>, 2638 MFC3OP_FM<0x10, 3, 0>, ISA_MIPS32R5, ASE_VIRT; 2639 def MTGC0 : MMRel, MTC3OP<"mtgc0", COP0Opnd, GPR32Opnd, II_MTGC0>, 2640 MFC3OP_FM<0x10, 3, 2>, ISA_MIPS32R5, ASE_VIRT; 2641 def MFHGC0 : MMRel, MFC3OP<"mfhgc0", GPR32Opnd, COP0Opnd, II_MFHGC0>, 2642 MFC3OP_FM<0x10, 3, 4>, ISA_MIPS32R5, ASE_VIRT; 2643 def MTHGC0 : MMRel, MTC3OP<"mthgc0", COP0Opnd, GPR32Opnd, II_MTHGC0>, 2644 MFC3OP_FM<0x10, 3, 6>, ISA_MIPS32R5, ASE_VIRT; 2645 def TLBGINV : MMRel, TLB<"tlbginv", II_TLBGINV>, COP0_TLB_FM<0b001011>, 2646 ISA_MIPS32R5, ASE_VIRT; 2647 def TLBGINVF : MMRel, TLB<"tlbginvf", II_TLBGINVF>, COP0_TLB_FM<0b001100>, 2648 ISA_MIPS32R5, ASE_VIRT; 2649 def TLBGP : MMRel, TLB<"tlbgp", II_TLBGP>, COP0_TLB_FM<0b010000>, 2650 ISA_MIPS32R5, ASE_VIRT; 2651 def TLBGR : MMRel, TLB<"tlbgr", II_TLBGR>, COP0_TLB_FM<0b001001>, 2652 ISA_MIPS32R5, ASE_VIRT; 2653 def TLBGWI : MMRel, TLB<"tlbgwi", II_TLBGWI>, COP0_TLB_FM<0b001010>, 2654 ISA_MIPS32R5, ASE_VIRT; 2655 def TLBGWR : MMRel, TLB<"tlbgwr", II_TLBGWR>, COP0_TLB_FM<0b001110>, 2656 ISA_MIPS32R5, ASE_VIRT; 2657 def HYPCALL : MMRel, HYPCALL_FT<"hypcall">, 2658 HYPCALL_FM<0b101000>, ISA_MIPS32R5, ASE_VIRT; 2659} 2660 2661//===----------------------------------------------------------------------===// 2662// Instruction aliases 2663//===----------------------------------------------------------------------===// 2664 2665multiclass OneOrTwoOperandMacroImmediateAlias<string Memnomic, 2666 Instruction Opcode, 2667 RegisterOperand RO = GPR32Opnd, 2668 Operand Imm = simm32_relaxed> { 2669 def : MipsInstAlias<!strconcat(Memnomic, " $rs, $rt, $imm"), 2670 (Opcode RO:$rs, 2671 RO:$rt, 2672 Imm:$imm), 0>; 2673 def : MipsInstAlias<!strconcat(Memnomic, " $rs, $imm"), 2674 (Opcode RO:$rs, 2675 RO:$rs, 2676 Imm:$imm), 0>; 2677} 2678 2679let AdditionalPredicates = [NotInMicroMips] in { 2680 def : MipsInstAlias<"move $dst, $src", 2681 (OR GPR32Opnd:$dst, GPR32Opnd:$src, ZERO), 1>, 2682 GPR_32, ISA_MIPS1; 2683 def : MipsInstAlias<"move $dst, $src", 2684 (ADDu GPR32Opnd:$dst, GPR32Opnd:$src, ZERO), 1>, 2685 GPR_32, ISA_MIPS1; 2686 2687 def : MipsInstAlias<"bal $offset", (BGEZAL ZERO, brtarget:$offset), 1>, 2688 ISA_MIPS1_NOT_32R6_64R6; 2689 2690 def : MipsInstAlias<"j $rs", (JR GPR32Opnd:$rs), 0>, ISA_MIPS1; 2691 2692 def : MipsInstAlias<"jalr $rs", (JALR RA, GPR32Opnd:$rs), 0>; 2693 2694 def : MipsInstAlias<"jalr.hb $rs", (JALR_HB RA, GPR32Opnd:$rs), 1>, 2695 ISA_MIPS32; 2696 2697 def : MipsInstAlias<"neg $rt, $rs", 2698 (SUB GPR32Opnd:$rt, ZERO, GPR32Opnd:$rs), 1>, ISA_MIPS1; 2699 def : MipsInstAlias<"neg $rt", 2700 (SUB GPR32Opnd:$rt, ZERO, GPR32Opnd:$rt), 1>, ISA_MIPS1; 2701 def : MipsInstAlias<"negu $rt, $rs", 2702 (SUBu GPR32Opnd:$rt, ZERO, GPR32Opnd:$rs), 1>, ISA_MIPS1; 2703 def : MipsInstAlias<"negu $rt", 2704 (SUBu GPR32Opnd:$rt, ZERO, GPR32Opnd:$rt), 1>, ISA_MIPS1; 2705 2706 def SGE : MipsAsmPseudoInst<(outs GPR32Opnd:$rd), 2707 (ins GPR32Opnd:$rs, GPR32Opnd:$rt), 2708 "sge\t$rd, $rs, $rt">, ISA_MIPS1; 2709 def : MipsInstAlias<"sge $rs, $rt", 2710 (SGE GPR32Opnd:$rs, GPR32Opnd:$rs, GPR32Opnd:$rt), 0>, 2711 ISA_MIPS1; 2712 def SGEImm : MipsAsmPseudoInst<(outs GPR32Opnd:$rd), 2713 (ins GPR32Opnd:$rs, simm32:$imm), 2714 "sge\t$rd, $rs, $imm">, GPR_32; 2715 def : MipsInstAlias<"sge $rs, $imm", (SGEImm GPR32Opnd:$rs, 2716 GPR32Opnd:$rs, 2717 simm32:$imm), 0>, 2718 GPR_32; 2719 2720 def SGEU : MipsAsmPseudoInst<(outs GPR32Opnd:$rd), 2721 (ins GPR32Opnd:$rs, GPR32Opnd:$rt), 2722 "sgeu\t$rd, $rs, $rt">, ISA_MIPS1; 2723 def : MipsInstAlias<"sgeu $rs, $rt", 2724 (SGEU GPR32Opnd:$rs, GPR32Opnd:$rs, GPR32Opnd:$rt), 0>, 2725 ISA_MIPS1; 2726 def SGEUImm : MipsAsmPseudoInst<(outs GPR32Opnd:$rd), 2727 (ins GPR32Opnd:$rs, uimm32_coerced:$imm), 2728 "sgeu\t$rd, $rs, $imm">, GPR_32; 2729 def : MipsInstAlias<"sgeu $rs, $imm", (SGEUImm GPR32Opnd:$rs, 2730 GPR32Opnd:$rs, 2731 uimm32_coerced:$imm), 0>, 2732 GPR_32; 2733 2734 def : MipsInstAlias< 2735 "sgt $rd, $rs, $rt", 2736 (SLT GPR32Opnd:$rd, GPR32Opnd:$rt, GPR32Opnd:$rs), 0>, ISA_MIPS1; 2737 def : MipsInstAlias< 2738 "sgt $rs, $rt", 2739 (SLT GPR32Opnd:$rs, GPR32Opnd:$rt, GPR32Opnd:$rs), 0>, ISA_MIPS1; 2740 2741 def SGTImm : MipsAsmPseudoInst<(outs GPR32Opnd:$rd), 2742 (ins GPR32Opnd:$rs, simm32:$imm), 2743 "sgt\t$rd, $rs, $imm">, GPR_32; 2744 def : MipsInstAlias<"sgt $rs, $imm", (SGTImm GPR32Opnd:$rs, 2745 GPR32Opnd:$rs, 2746 simm32:$imm), 0>, 2747 GPR_32; 2748 def : MipsInstAlias< 2749 "sgtu $rd, $rs, $rt", 2750 (SLTu GPR32Opnd:$rd, GPR32Opnd:$rt, GPR32Opnd:$rs), 0>, ISA_MIPS1; 2751 def : MipsInstAlias< 2752 "sgtu $$rs, $rt", 2753 (SLTu GPR32Opnd:$rs, GPR32Opnd:$rt, GPR32Opnd:$rs), 0>, ISA_MIPS1; 2754 2755 def SGTUImm : MipsAsmPseudoInst<(outs GPR32Opnd:$rd), 2756 (ins GPR32Opnd:$rs, uimm32_coerced:$imm), 2757 "sgtu\t$rd, $rs, $imm">, GPR_32; 2758 def : MipsInstAlias<"sgtu $rs, $imm", (SGTUImm GPR32Opnd:$rs, 2759 GPR32Opnd:$rs, 2760 uimm32_coerced:$imm), 0>, 2761 GPR_32; 2762 2763 def : MipsInstAlias< 2764 "not $rt, $rs", 2765 (NOR GPR32Opnd:$rt, GPR32Opnd:$rs, ZERO), 0>, ISA_MIPS1; 2766 def : MipsInstAlias< 2767 "not $rt", 2768 (NOR GPR32Opnd:$rt, GPR32Opnd:$rt, ZERO), 0>, ISA_MIPS1; 2769 2770 def : MipsInstAlias<"nop", (SLL ZERO, ZERO, 0), 1>, ISA_MIPS1; 2771 2772 defm : OneOrTwoOperandMacroImmediateAlias<"add", ADDi>, 2773 ISA_MIPS1_NOT_32R6_64R6; 2774 2775 defm : OneOrTwoOperandMacroImmediateAlias<"addu", ADDiu>, ISA_MIPS1; 2776 2777 defm : OneOrTwoOperandMacroImmediateAlias<"and", ANDi>, ISA_MIPS1, GPR_32; 2778 2779 defm : OneOrTwoOperandMacroImmediateAlias<"or", ORi>, ISA_MIPS1, GPR_32; 2780 2781 defm : OneOrTwoOperandMacroImmediateAlias<"xor", XORi>, ISA_MIPS1, GPR_32; 2782 2783 defm : OneOrTwoOperandMacroImmediateAlias<"slt", SLTi>, ISA_MIPS1, GPR_32; 2784 2785 defm : OneOrTwoOperandMacroImmediateAlias<"sltu", SLTiu>, ISA_MIPS1, GPR_32; 2786 2787 def : MipsInstAlias<"mfgc0 $rt, $rd", 2788 (MFGC0 GPR32Opnd:$rt, COP0Opnd:$rd, 0), 0>, 2789 ISA_MIPS32R5, ASE_VIRT; 2790 def : MipsInstAlias<"mtgc0 $rt, $rd", 2791 (MTGC0 COP0Opnd:$rd, GPR32Opnd:$rt, 0), 0>, 2792 ISA_MIPS32R5, ASE_VIRT; 2793 def : MipsInstAlias<"mfhgc0 $rt, $rd", 2794 (MFHGC0 GPR32Opnd:$rt, COP0Opnd:$rd, 0), 0>, 2795 ISA_MIPS32R5, ASE_VIRT; 2796 def : MipsInstAlias<"mthgc0 $rt, $rd", 2797 (MTHGC0 COP0Opnd:$rd, GPR32Opnd:$rt, 0), 0>, 2798 ISA_MIPS32R5, ASE_VIRT; 2799 def : MipsInstAlias<"mfc0 $rt, $rd", (MFC0 GPR32Opnd:$rt, COP0Opnd:$rd, 0), 0>, 2800 ISA_MIPS1; 2801 def : MipsInstAlias<"mtc0 $rt, $rd", (MTC0 COP0Opnd:$rd, GPR32Opnd:$rt, 0), 0>, 2802 ISA_MIPS1; 2803 def : MipsInstAlias<"mfc2 $rt, $rd", (MFC2 GPR32Opnd:$rt, COP2Opnd:$rd, 0), 0>, 2804 ISA_MIPS1; 2805 def : MipsInstAlias<"mtc2 $rt, $rd", (MTC2 COP2Opnd:$rd, GPR32Opnd:$rt, 0), 0>, 2806 ISA_MIPS1; 2807 2808 def : MipsInstAlias<"b $offset", (BEQ ZERO, ZERO, brtarget:$offset), 0>, 2809 ISA_MIPS1; 2810 2811 def : MipsInstAlias<"bnez $rs,$offset", 2812 (BNE GPR32Opnd:$rs, ZERO, brtarget:$offset), 0>, 2813 ISA_MIPS1; 2814 def : MipsInstAlias<"bnezl $rs, $offset", 2815 (BNEL GPR32Opnd:$rs, ZERO, brtarget:$offset), 1>, 2816 ISA_MIPS2; 2817 def : MipsInstAlias<"beqz $rs,$offset", 2818 (BEQ GPR32Opnd:$rs, ZERO, brtarget:$offset), 0>, 2819 ISA_MIPS1; 2820 def : MipsInstAlias<"beqzl $rs, $offset", 2821 (BEQL GPR32Opnd:$rs, ZERO, brtarget:$offset), 1>, 2822 ISA_MIPS2; 2823 2824 def : MipsInstAlias<"syscall", (SYSCALL 0), 1>, ISA_MIPS1; 2825 2826 def : MipsInstAlias<"break", (BREAK 0, 0), 1>, ISA_MIPS1; 2827 def : MipsInstAlias<"break $imm", (BREAK uimm10:$imm, 0), 1>, ISA_MIPS1; 2828 def : MipsInstAlias<"ei", (EI ZERO), 1>, ISA_MIPS32R2; 2829 def : MipsInstAlias<"di", (DI ZERO), 1>, ISA_MIPS32R2; 2830 2831 def : MipsInstAlias<"teq $rs, $rt", 2832 (TEQ GPR32Opnd:$rs, GPR32Opnd:$rt, 0), 1>, ISA_MIPS2; 2833 def : MipsInstAlias<"tge $rs, $rt", 2834 (TGE GPR32Opnd:$rs, GPR32Opnd:$rt, 0), 1>, ISA_MIPS2; 2835 def : MipsInstAlias<"tgeu $rs, $rt", 2836 (TGEU GPR32Opnd:$rs, GPR32Opnd:$rt, 0), 1>, ISA_MIPS2; 2837 def : MipsInstAlias<"tlt $rs, $rt", 2838 (TLT GPR32Opnd:$rs, GPR32Opnd:$rt, 0), 1>, ISA_MIPS2; 2839 def : MipsInstAlias<"tltu $rs, $rt", 2840 (TLTU GPR32Opnd:$rs, GPR32Opnd:$rt, 0), 1>, ISA_MIPS2; 2841 def : MipsInstAlias<"tne $rs, $rt", 2842 (TNE GPR32Opnd:$rs, GPR32Opnd:$rt, 0), 1>, ISA_MIPS2; 2843 def : MipsInstAlias<"rdhwr $rt, $rs", 2844 (RDHWR GPR32Opnd:$rt, HWRegsOpnd:$rs, 0), 1>, ISA_MIPS1; 2845 2846} 2847def : MipsInstAlias<"sub, $rd, $rs, $imm", 2848 (ADDi GPR32Opnd:$rd, GPR32Opnd:$rs, 2849 InvertedImOperand:$imm), 0>, ISA_MIPS1_NOT_32R6_64R6; 2850def : MipsInstAlias<"sub $rs, $imm", 2851 (ADDi GPR32Opnd:$rs, GPR32Opnd:$rs, InvertedImOperand:$imm), 2852 0>, ISA_MIPS1_NOT_32R6_64R6; 2853def : MipsInstAlias<"subu, $rd, $rs, $imm", 2854 (ADDiu GPR32Opnd:$rd, GPR32Opnd:$rs, 2855 InvertedImOperand:$imm), 0>; 2856def : MipsInstAlias<"subu $rs, $imm", (ADDiu GPR32Opnd:$rs, GPR32Opnd:$rs, 2857 InvertedImOperand:$imm), 0>; 2858let AdditionalPredicates = [NotInMicroMips] in { 2859 def : MipsInstAlias<"sll $rd, $rt, $rs", 2860 (SLLV GPR32Opnd:$rd, GPR32Opnd:$rt, GPR32Opnd:$rs), 0>; 2861 def : MipsInstAlias<"sra $rd, $rt, $rs", 2862 (SRAV GPR32Opnd:$rd, GPR32Opnd:$rt, GPR32Opnd:$rs), 0>; 2863 def : MipsInstAlias<"srl $rd, $rt, $rs", 2864 (SRLV GPR32Opnd:$rd, GPR32Opnd:$rt, GPR32Opnd:$rs), 0>; 2865 def : MipsInstAlias<"sll $rd, $rt", 2866 (SLLV GPR32Opnd:$rd, GPR32Opnd:$rd, GPR32Opnd:$rt), 0>; 2867 def : MipsInstAlias<"sra $rd, $rt", 2868 (SRAV GPR32Opnd:$rd, GPR32Opnd:$rd, GPR32Opnd:$rt), 0>; 2869 def : MipsInstAlias<"srl $rd, $rt", 2870 (SRLV GPR32Opnd:$rd, GPR32Opnd:$rd, GPR32Opnd:$rt), 0>; 2871 def : MipsInstAlias<"seh $rd", (SEH GPR32Opnd:$rd, GPR32Opnd:$rd), 0>, 2872 ISA_MIPS32R2; 2873 def : MipsInstAlias<"seb $rd", (SEB GPR32Opnd:$rd, GPR32Opnd:$rd), 0>, 2874 ISA_MIPS32R2; 2875} 2876def : MipsInstAlias<"sdbbp", (SDBBP 0)>, ISA_MIPS32_NOT_32R6_64R6; 2877let AdditionalPredicates = [NotInMicroMips] in 2878 def : MipsInstAlias<"sync", (SYNC 0), 1>, ISA_MIPS2; 2879 2880def : MipsInstAlias<"mulo $rs, $rt", 2881 (MULOMacro GPR32Opnd:$rs, GPR32Opnd:$rs, GPR32Opnd:$rt), 0>, 2882 ISA_MIPS1_NOT_32R6_64R6; 2883def : MipsInstAlias<"mulou $rs, $rt", 2884 (MULOUMacro GPR32Opnd:$rs, GPR32Opnd:$rs, GPR32Opnd:$rt), 0>, 2885 ISA_MIPS1_NOT_32R6_64R6; 2886 2887let AdditionalPredicates = [NotInMicroMips] in 2888 def : MipsInstAlias<"hypcall", (HYPCALL 0), 1>, ISA_MIPS32R5, ASE_VIRT; 2889 2890//===----------------------------------------------------------------------===// 2891// Assembler Pseudo Instructions 2892//===----------------------------------------------------------------------===// 2893 2894// We use uimm32_coerced to accept a 33 bit signed number that is rendered into 2895// a 32 bit number. 2896class LoadImmediate32<string instr_asm, Operand Od, RegisterOperand RO> : 2897 MipsAsmPseudoInst<(outs RO:$rt), (ins Od:$imm32), 2898 !strconcat(instr_asm, "\t$rt, $imm32")> ; 2899def LoadImm32 : LoadImmediate32<"li", uimm32_coerced, GPR32Opnd>; 2900 2901class LoadAddressFromReg32<string instr_asm, Operand MemOpnd, 2902 RegisterOperand RO> : 2903 MipsAsmPseudoInst<(outs RO:$rt), (ins MemOpnd:$addr), 2904 !strconcat(instr_asm, "\t$rt, $addr")> ; 2905def LoadAddrReg32 : LoadAddressFromReg32<"la", mem, GPR32Opnd>; 2906 2907class LoadAddressFromImm32<string instr_asm, Operand Od, RegisterOperand RO> : 2908 MipsAsmPseudoInst<(outs RO:$rt), (ins Od:$imm32), 2909 !strconcat(instr_asm, "\t$rt, $imm32")> ; 2910def LoadAddrImm32 : LoadAddressFromImm32<"la", i32imm, GPR32Opnd>; 2911 2912def JalTwoReg : MipsAsmPseudoInst<(outs GPR32Opnd:$rd), (ins GPR32Opnd:$rs), 2913 "jal\t$rd, $rs"> ; 2914def JalOneReg : MipsAsmPseudoInst<(outs), (ins GPR32Opnd:$rs), 2915 "jal\t$rs"> ; 2916 2917class NORIMM_DESC_BASE<RegisterOperand RO, DAGOperand Imm> : 2918 MipsAsmPseudoInst<(outs RO:$rs), (ins RO:$rt, Imm:$imm), 2919 "nor\t$rs, $rt, $imm">; 2920def NORImm : NORIMM_DESC_BASE<GPR32Opnd, simm32_relaxed>, GPR_32; 2921def : MipsInstAlias<"nor\t$rs, $imm", (NORImm GPR32Opnd:$rs, GPR32Opnd:$rs, 2922 simm32_relaxed:$imm)>, GPR_32; 2923 2924let hasDelaySlot = 1, isCTI = 1 in { 2925def BneImm : MipsAsmPseudoInst<(outs GPR32Opnd:$rt), 2926 (ins imm64:$imm64, brtarget:$offset), 2927 "bne\t$rt, $imm64, $offset">; 2928def BeqImm : MipsAsmPseudoInst<(outs GPR32Opnd:$rt), 2929 (ins imm64:$imm64, brtarget:$offset), 2930 "beq\t$rt, $imm64, $offset">; 2931 2932class CondBranchPseudo<string instr_asm> : 2933 MipsAsmPseudoInst<(outs), (ins GPR32Opnd:$rs, GPR32Opnd:$rt, 2934 brtarget:$offset), 2935 !strconcat(instr_asm, "\t$rs, $rt, $offset")>; 2936} 2937 2938def BLT : CondBranchPseudo<"blt">; 2939def BLE : CondBranchPseudo<"ble">; 2940def BGE : CondBranchPseudo<"bge">; 2941def BGT : CondBranchPseudo<"bgt">; 2942def BLTU : CondBranchPseudo<"bltu">; 2943def BLEU : CondBranchPseudo<"bleu">; 2944def BGEU : CondBranchPseudo<"bgeu">; 2945def BGTU : CondBranchPseudo<"bgtu">; 2946def BLTL : CondBranchPseudo<"bltl">, ISA_MIPS2_NOT_32R6_64R6; 2947def BLEL : CondBranchPseudo<"blel">, ISA_MIPS2_NOT_32R6_64R6; 2948def BGEL : CondBranchPseudo<"bgel">, ISA_MIPS2_NOT_32R6_64R6; 2949def BGTL : CondBranchPseudo<"bgtl">, ISA_MIPS2_NOT_32R6_64R6; 2950def BLTUL: CondBranchPseudo<"bltul">, ISA_MIPS2_NOT_32R6_64R6; 2951def BLEUL: CondBranchPseudo<"bleul">, ISA_MIPS2_NOT_32R6_64R6; 2952def BGEUL: CondBranchPseudo<"bgeul">, ISA_MIPS2_NOT_32R6_64R6; 2953def BGTUL: CondBranchPseudo<"bgtul">, ISA_MIPS2_NOT_32R6_64R6; 2954 2955let isCTI = 1 in 2956class CondBranchImmPseudo<string instr_asm> : 2957 MipsAsmPseudoInst<(outs), (ins GPR32Opnd:$rs, imm64:$imm, brtarget:$offset), 2958 !strconcat(instr_asm, "\t$rs, $imm, $offset")>; 2959 2960def BEQLImmMacro : CondBranchImmPseudo<"beql">, ISA_MIPS2_NOT_32R6_64R6; 2961def BNELImmMacro : CondBranchImmPseudo<"bnel">, ISA_MIPS2_NOT_32R6_64R6; 2962 2963def BLTImmMacro : CondBranchImmPseudo<"blt">; 2964def BLEImmMacro : CondBranchImmPseudo<"ble">; 2965def BGEImmMacro : CondBranchImmPseudo<"bge">; 2966def BGTImmMacro : CondBranchImmPseudo<"bgt">; 2967def BLTUImmMacro : CondBranchImmPseudo<"bltu">; 2968def BLEUImmMacro : CondBranchImmPseudo<"bleu">; 2969def BGEUImmMacro : CondBranchImmPseudo<"bgeu">; 2970def BGTUImmMacro : CondBranchImmPseudo<"bgtu">; 2971def BLTLImmMacro : CondBranchImmPseudo<"bltl">, ISA_MIPS2_NOT_32R6_64R6; 2972def BLELImmMacro : CondBranchImmPseudo<"blel">, ISA_MIPS2_NOT_32R6_64R6; 2973def BGELImmMacro : CondBranchImmPseudo<"bgel">, ISA_MIPS2_NOT_32R6_64R6; 2974def BGTLImmMacro : CondBranchImmPseudo<"bgtl">, ISA_MIPS2_NOT_32R6_64R6; 2975def BLTULImmMacro : CondBranchImmPseudo<"bltul">, ISA_MIPS2_NOT_32R6_64R6; 2976def BLEULImmMacro : CondBranchImmPseudo<"bleul">, ISA_MIPS2_NOT_32R6_64R6; 2977def BGEULImmMacro : CondBranchImmPseudo<"bgeul">, ISA_MIPS2_NOT_32R6_64R6; 2978def BGTULImmMacro : CondBranchImmPseudo<"bgtul">, ISA_MIPS2_NOT_32R6_64R6; 2979 2980// FIXME: Predicates are removed because instructions are matched regardless of 2981// predicates, because PredicateControl was not in the hierarchy. This was 2982// done to emit more precise error message from expansion function. 2983// Once the tablegen-erated errors are made better, this needs to be fixed and 2984// predicates needs to be restored. 2985 2986def SDivMacro : MipsAsmPseudoInst<(outs GPR32NonZeroOpnd:$rd), 2987 (ins GPR32Opnd:$rs, GPR32Opnd:$rt), 2988 "div\t$rd, $rs, $rt">, 2989 ISA_MIPS1_NOT_32R6_64R6; 2990def SDivIMacro : MipsAsmPseudoInst<(outs GPR32Opnd:$rd), 2991 (ins GPR32Opnd:$rs, simm32:$imm), 2992 "div\t$rd, $rs, $imm">, 2993 ISA_MIPS1_NOT_32R6_64R6; 2994def UDivMacro : MipsAsmPseudoInst<(outs GPR32Opnd:$rd), 2995 (ins GPR32Opnd:$rs, GPR32Opnd:$rt), 2996 "divu\t$rd, $rs, $rt">, 2997 ISA_MIPS1_NOT_32R6_64R6; 2998def UDivIMacro : MipsAsmPseudoInst<(outs GPR32Opnd:$rd), 2999 (ins GPR32Opnd:$rs, simm32:$imm), 3000 "divu\t$rd, $rs, $imm">, 3001 ISA_MIPS1_NOT_32R6_64R6; 3002 3003 3004def : MipsInstAlias<"div $rs, $rt", (SDIV GPR32ZeroOpnd:$rs, 3005 GPR32Opnd:$rt), 0>, 3006 ISA_MIPS1_NOT_32R6_64R6; 3007def : MipsInstAlias<"div $rs, $rt", (SDivMacro GPR32NonZeroOpnd:$rs, 3008 GPR32NonZeroOpnd:$rs, 3009 GPR32Opnd:$rt), 0>, 3010 ISA_MIPS1_NOT_32R6_64R6; 3011def : MipsInstAlias<"div $rd, $imm", (SDivIMacro GPR32Opnd:$rd, GPR32Opnd:$rd, 3012 simm32:$imm), 0>, 3013 ISA_MIPS1_NOT_32R6_64R6; 3014 3015def : MipsInstAlias<"divu $rt, $rs", (UDIV GPR32ZeroOpnd:$rt, 3016 GPR32Opnd:$rs), 0>, 3017 ISA_MIPS1_NOT_32R6_64R6; 3018def : MipsInstAlias<"divu $rt, $rs", (UDivMacro GPR32NonZeroOpnd:$rt, 3019 GPR32NonZeroOpnd:$rt, 3020 GPR32Opnd:$rs), 0>, 3021 ISA_MIPS1_NOT_32R6_64R6; 3022 3023def : MipsInstAlias<"divu $rd, $imm", (UDivIMacro GPR32Opnd:$rd, GPR32Opnd:$rd, 3024 simm32:$imm), 0>, 3025 ISA_MIPS1_NOT_32R6_64R6; 3026 3027def SRemMacro : MipsAsmPseudoInst<(outs GPR32Opnd:$rd), 3028 (ins GPR32Opnd:$rs, GPR32Opnd:$rt), 3029 "rem\t$rd, $rs, $rt">, 3030 ISA_MIPS1_NOT_32R6_64R6; 3031def SRemIMacro : MipsAsmPseudoInst<(outs GPR32Opnd:$rd), 3032 (ins GPR32Opnd:$rs, simm32_relaxed:$imm), 3033 "rem\t$rd, $rs, $imm">, 3034 ISA_MIPS1_NOT_32R6_64R6; 3035def URemMacro : MipsAsmPseudoInst<(outs GPR32Opnd:$rd), 3036 (ins GPR32Opnd:$rs, GPR32Opnd:$rt), 3037 "remu\t$rd, $rs, $rt">, 3038 ISA_MIPS1_NOT_32R6_64R6; 3039def URemIMacro : MipsAsmPseudoInst<(outs GPR32Opnd:$rd), 3040 (ins GPR32Opnd:$rs, simm32_relaxed:$imm), 3041 "remu\t$rd, $rs, $imm">, 3042 ISA_MIPS1_NOT_32R6_64R6; 3043 3044def : MipsInstAlias<"rem $rt, $rs", (SRemMacro GPR32Opnd:$rt, GPR32Opnd:$rt, 3045 GPR32Opnd:$rs), 0>, 3046 ISA_MIPS1_NOT_32R6_64R6; 3047def : MipsInstAlias<"rem $rd, $imm", (SRemIMacro GPR32Opnd:$rd, GPR32Opnd:$rd, 3048 simm32_relaxed:$imm), 0>, 3049 ISA_MIPS1_NOT_32R6_64R6; 3050def : MipsInstAlias<"remu $rt, $rs", (URemMacro GPR32Opnd:$rt, GPR32Opnd:$rt, 3051 GPR32Opnd:$rs), 0>, 3052 ISA_MIPS1_NOT_32R6_64R6; 3053def : MipsInstAlias<"remu $rd, $imm", (URemIMacro GPR32Opnd:$rd, GPR32Opnd:$rd, 3054 simm32_relaxed:$imm), 0>, 3055 ISA_MIPS1_NOT_32R6_64R6; 3056 3057def Ulh : MipsAsmPseudoInst<(outs GPR32Opnd:$rt), (ins mem:$addr), 3058 "ulh\t$rt, $addr">; //, ISA_MIPS1_NOT_32R6_64R6; 3059 3060def Ulhu : MipsAsmPseudoInst<(outs GPR32Opnd:$rt), (ins mem:$addr), 3061 "ulhu\t$rt, $addr">; //, ISA_MIPS1_NOT_32R6_64R6; 3062 3063def Ulw : MipsAsmPseudoInst<(outs GPR32Opnd:$rt), (ins mem:$addr), 3064 "ulw\t$rt, $addr">; //, ISA_MIPS1_NOT_32R6_64R6; 3065 3066def Ush : MipsAsmPseudoInst<(outs GPR32Opnd:$rt), (ins mem:$addr), 3067 "ush\t$rt, $addr">; //, ISA_MIPS1_NOT_32R6_64R6; 3068 3069def Usw : MipsAsmPseudoInst<(outs GPR32Opnd:$rt), (ins mem:$addr), 3070 "usw\t$rt, $addr">; //, ISA_MIPS1_NOT_32R6_64R6; 3071 3072def LDMacro : MipsAsmPseudoInst<(outs GPR32Opnd:$rt), 3073 (ins mem_simm16:$addr), "ld $rt, $addr">, 3074 ISA_MIPS1_NOT_MIPS3; 3075def SDMacro : MipsAsmPseudoInst<(outs GPR32Opnd:$rt), 3076 (ins mem_simm16:$addr), "sd $rt, $addr">, 3077 ISA_MIPS1_NOT_MIPS3; 3078//===----------------------------------------------------------------------===// 3079// Arbitrary patterns that map to one or more instructions 3080//===----------------------------------------------------------------------===// 3081 3082// Load/store pattern templates. 3083class LoadRegImmPat<Instruction LoadInst, ValueType ValTy, PatFrag Node> : 3084 MipsPat<(ValTy (Node addrRegImm:$a)), (LoadInst addrRegImm:$a)>; 3085 3086class StoreRegImmPat<Instruction StoreInst, ValueType ValTy> : 3087 MipsPat<(store ValTy:$v, addrRegImm:$a), (StoreInst ValTy:$v, addrRegImm:$a)>; 3088 3089// Materialize constants. 3090multiclass MaterializeImms<ValueType VT, Register ZEROReg, 3091 Instruction ADDiuOp, Instruction LUiOp, 3092 Instruction ORiOp> { 3093 3094// Constant synthesis previously relied on the ordering of the patterns below. 3095// By making the predicates they use non-overlapping, the patterns were 3096// reordered so that the effect of the newly introduced predicates can be 3097// observed. 3098 3099// Arbitrary immediates 3100def : MipsPat<(VT LUiORiPred:$imm), 3101 (ORiOp (LUiOp (HI16 imm:$imm)), (LO16 imm:$imm))>; 3102 3103// Bits 32-16 set, sign/zero extended. 3104def : MipsPat<(VT LUiPred:$imm), (LUiOp (HI16 imm:$imm))>; 3105 3106// Small immediates 3107def : MipsPat<(VT ORiPred:$imm), (ORiOp ZEROReg, imm:$imm)>; 3108def : MipsPat<(VT immSExt16:$imm), (ADDiuOp ZEROReg, imm:$imm)>; 3109} 3110 3111let AdditionalPredicates = [NotInMicroMips] in 3112 defm : MaterializeImms<i32, ZERO, ADDiu, LUi, ORi>, ISA_MIPS1; 3113 3114// Carry MipsPatterns 3115let AdditionalPredicates = [NotInMicroMips] in { 3116 def : MipsPat<(subc GPR32:$lhs, GPR32:$rhs), 3117 (SUBu GPR32:$lhs, GPR32:$rhs)>, ISA_MIPS1; 3118} 3119def : MipsPat<(addc GPR32:$lhs, GPR32:$rhs), 3120 (ADDu GPR32:$lhs, GPR32:$rhs)>, ISA_MIPS1, ASE_NOT_DSP; 3121def : MipsPat<(addc GPR32:$src, immSExt16:$imm), 3122 (ADDiu GPR32:$src, imm:$imm)>, ISA_MIPS1, ASE_NOT_DSP; 3123 3124// Support multiplication for pre-Mips32 targets that don't have 3125// the MUL instruction. 3126def : MipsPat<(mul GPR32:$lhs, GPR32:$rhs), 3127 (PseudoMFLO (PseudoMULT GPR32:$lhs, GPR32:$rhs))>, 3128 ISA_MIPS1_NOT_32R6_64R6; 3129 3130// SYNC 3131def : MipsPat<(MipsSync (i32 immz)), 3132 (SYNC 0)>, ISA_MIPS2; 3133 3134// Call 3135def : MipsPat<(MipsJmpLink (i32 texternalsym:$dst)), 3136 (JAL texternalsym:$dst)>, ISA_MIPS1; 3137//def : MipsPat<(MipsJmpLink GPR32:$dst), 3138// (JALR GPR32:$dst)>; 3139 3140// Tail call 3141let AdditionalPredicates = [NotInMicroMips] in { 3142 def : MipsPat<(MipsTailCall (iPTR tglobaladdr:$dst)), 3143 (TAILCALL tglobaladdr:$dst)>, ISA_MIPS1; 3144 def : MipsPat<(MipsTailCall (iPTR texternalsym:$dst)), 3145 (TAILCALL texternalsym:$dst)>, ISA_MIPS1; 3146} 3147// hi/lo relocs 3148multiclass MipsHiLoRelocs<Instruction Lui, Instruction Addiu, 3149 Register ZeroReg, RegisterOperand GPROpnd> { 3150 def : MipsPat<(MipsHi tglobaladdr:$in), (Lui tglobaladdr:$in)>; 3151 def : MipsPat<(MipsHi tblockaddress:$in), (Lui tblockaddress:$in)>; 3152 def : MipsPat<(MipsHi tjumptable:$in), (Lui tjumptable:$in)>; 3153 def : MipsPat<(MipsHi tconstpool:$in), (Lui tconstpool:$in)>; 3154 def : MipsPat<(MipsHi texternalsym:$in), (Lui texternalsym:$in)>; 3155 3156 def : MipsPat<(MipsLo tglobaladdr:$in), 3157 (Addiu ZeroReg, tglobaladdr:$in)>; 3158 def : MipsPat<(MipsLo tblockaddress:$in), 3159 (Addiu ZeroReg, tblockaddress:$in)>; 3160 def : MipsPat<(MipsLo tjumptable:$in), 3161 (Addiu ZeroReg, tjumptable:$in)>; 3162 def : MipsPat<(MipsLo tconstpool:$in), 3163 (Addiu ZeroReg, tconstpool:$in)>; 3164 def : MipsPat<(MipsLo tglobaltlsaddr:$in), 3165 (Addiu ZeroReg, tglobaltlsaddr:$in)>; 3166 def : MipsPat<(MipsLo texternalsym:$in), 3167 (Addiu ZeroReg, texternalsym:$in)>; 3168 3169 def : MipsPat<(add GPROpnd:$hi, (MipsLo tglobaladdr:$lo)), 3170 (Addiu GPROpnd:$hi, tglobaladdr:$lo)>; 3171 def : MipsPat<(add GPROpnd:$hi, (MipsLo tblockaddress:$lo)), 3172 (Addiu GPROpnd:$hi, tblockaddress:$lo)>; 3173 def : MipsPat<(add GPROpnd:$hi, (MipsLo tjumptable:$lo)), 3174 (Addiu GPROpnd:$hi, tjumptable:$lo)>; 3175 def : MipsPat<(add GPROpnd:$hi, (MipsLo tconstpool:$lo)), 3176 (Addiu GPROpnd:$hi, tconstpool:$lo)>; 3177 def : MipsPat<(add GPROpnd:$hi, (MipsLo tglobaltlsaddr:$lo)), 3178 (Addiu GPROpnd:$hi, tglobaltlsaddr:$lo)>; 3179 def : MipsPat<(add GPROpnd:$hi, (MipsLo texternalsym:$lo)), 3180 (Addiu GPROpnd:$hi, texternalsym:$lo)>; 3181} 3182 3183// wrapper_pic 3184class WrapperPat<SDNode node, Instruction ADDiuOp, RegisterClass RC>: 3185 MipsPat<(MipsWrapper RC:$gp, node:$in), (ADDiuOp RC:$gp, node:$in)>; 3186 3187let AdditionalPredicates = [NotInMicroMips] in { 3188 defm : MipsHiLoRelocs<LUi, ADDiu, ZERO, GPR32Opnd>, ISA_MIPS1; 3189 3190 def : MipsPat<(MipsGotHi tglobaladdr:$in), (LUi tglobaladdr:$in)>, ISA_MIPS1; 3191 def : MipsPat<(MipsGotHi texternalsym:$in), (LUi texternalsym:$in)>, 3192 ISA_MIPS1; 3193 3194 def : MipsPat<(MipsTlsHi tglobaltlsaddr:$in), (LUi tglobaltlsaddr:$in)>, 3195 ISA_MIPS1; 3196 3197 // gp_rel relocs 3198 def : MipsPat<(add GPR32:$gp, (MipsGPRel tglobaladdr:$in)), 3199 (ADDiu GPR32:$gp, tglobaladdr:$in)>, ISA_MIPS1, ABI_NOT_N64; 3200 def : MipsPat<(add GPR32:$gp, (MipsGPRel tconstpool:$in)), 3201 (ADDiu GPR32:$gp, tconstpool:$in)>, ISA_MIPS1, ABI_NOT_N64; 3202 3203 def : WrapperPat<tglobaladdr, ADDiu, GPR32>, ISA_MIPS1; 3204 def : WrapperPat<tconstpool, ADDiu, GPR32>, ISA_MIPS1; 3205 def : WrapperPat<texternalsym, ADDiu, GPR32>, ISA_MIPS1; 3206 def : WrapperPat<tblockaddress, ADDiu, GPR32>, ISA_MIPS1; 3207 def : WrapperPat<tjumptable, ADDiu, GPR32>, ISA_MIPS1; 3208 def : WrapperPat<tglobaltlsaddr, ADDiu, GPR32>, ISA_MIPS1; 3209 3210 // Mips does not have "not", so we expand our way 3211 def : MipsPat<(not GPR32:$in), 3212 (NOR GPR32Opnd:$in, ZERO)>, ISA_MIPS1; 3213} 3214 3215// extended loads 3216let AdditionalPredicates = [NotInMicroMips] in { 3217 def : MipsPat<(i32 (extloadi1 addr:$src)), (LBu addr:$src)>, ISA_MIPS1; 3218 def : MipsPat<(i32 (extloadi8 addr:$src)), (LBu addr:$src)>, ISA_MIPS1; 3219 def : MipsPat<(i32 (extloadi16 addr:$src)), (LHu addr:$src)>, ISA_MIPS1; 3220 3221 // peepholes 3222 def : MipsPat<(store (i32 0), addr:$dst), (SW ZERO, addr:$dst)>, ISA_MIPS1; 3223} 3224 3225// brcond patterns 3226multiclass BrcondPats<RegisterClass RC, Instruction BEQOp, Instruction BEQOp1, 3227 Instruction BNEOp, Instruction SLTOp, Instruction SLTuOp, 3228 Instruction SLTiOp, Instruction SLTiuOp, 3229 Register ZEROReg> { 3230def : MipsPat<(brcond (i32 (setne RC:$lhs, 0)), bb:$dst), 3231 (BNEOp RC:$lhs, ZEROReg, bb:$dst)>; 3232def : MipsPat<(brcond (i32 (seteq RC:$lhs, 0)), bb:$dst), 3233 (BEQOp RC:$lhs, ZEROReg, bb:$dst)>; 3234 3235def : MipsPat<(brcond (i32 (setge RC:$lhs, RC:$rhs)), bb:$dst), 3236 (BEQOp1 (SLTOp RC:$lhs, RC:$rhs), ZERO, bb:$dst)>; 3237def : MipsPat<(brcond (i32 (setuge RC:$lhs, RC:$rhs)), bb:$dst), 3238 (BEQOp1 (SLTuOp RC:$lhs, RC:$rhs), ZERO, bb:$dst)>; 3239def : MipsPat<(brcond (i32 (setge RC:$lhs, immSExt16:$rhs)), bb:$dst), 3240 (BEQOp1 (SLTiOp RC:$lhs, immSExt16:$rhs), ZERO, bb:$dst)>; 3241def : MipsPat<(brcond (i32 (setuge RC:$lhs, immSExt16:$rhs)), bb:$dst), 3242 (BEQOp1 (SLTiuOp RC:$lhs, immSExt16:$rhs), ZERO, bb:$dst)>; 3243def : MipsPat<(brcond (i32 (setgt RC:$lhs, immSExt16Plus1:$rhs)), bb:$dst), 3244 (BEQOp1 (SLTiOp RC:$lhs, (Plus1 imm:$rhs)), ZERO, bb:$dst)>; 3245def : MipsPat<(brcond (i32 (setugt RC:$lhs, immSExt16Plus1:$rhs)), bb:$dst), 3246 (BEQOp1 (SLTiuOp RC:$lhs, (Plus1 imm:$rhs)), ZERO, bb:$dst)>; 3247 3248def : MipsPat<(brcond (i32 (setle RC:$lhs, RC:$rhs)), bb:$dst), 3249 (BEQOp1 (SLTOp RC:$rhs, RC:$lhs), ZERO, bb:$dst)>; 3250def : MipsPat<(brcond (i32 (setule RC:$lhs, RC:$rhs)), bb:$dst), 3251 (BEQOp1 (SLTuOp RC:$rhs, RC:$lhs), ZERO, bb:$dst)>; 3252 3253def : MipsPat<(brcond RC:$cond, bb:$dst), 3254 (BNEOp RC:$cond, ZEROReg, bb:$dst)>; 3255} 3256let AdditionalPredicates = [NotInMicroMips] in { 3257 defm : BrcondPats<GPR32, BEQ, BEQ, BNE, SLT, SLTu, SLTi, SLTiu, ZERO>, 3258 ISA_MIPS1; 3259 def : MipsPat<(brcond (i32 (setlt i32:$lhs, 1)), bb:$dst), 3260 (BLEZ i32:$lhs, bb:$dst)>, ISA_MIPS1; 3261 def : MipsPat<(brcond (i32 (setgt i32:$lhs, -1)), bb:$dst), 3262 (BGEZ i32:$lhs, bb:$dst)>, ISA_MIPS1; 3263} 3264 3265// setcc patterns 3266multiclass SeteqPats<RegisterClass RC, Instruction SLTiuOp, Instruction XOROp, 3267 Instruction SLTuOp, Register ZEROReg> { 3268 def : MipsPat<(seteq RC:$lhs, 0), 3269 (SLTiuOp RC:$lhs, 1)>; 3270 def : MipsPat<(setne RC:$lhs, 0), 3271 (SLTuOp ZEROReg, RC:$lhs)>; 3272 def : MipsPat<(seteq RC:$lhs, RC:$rhs), 3273 (SLTiuOp (XOROp RC:$lhs, RC:$rhs), 1)>; 3274 def : MipsPat<(setne RC:$lhs, RC:$rhs), 3275 (SLTuOp ZEROReg, (XOROp RC:$lhs, RC:$rhs))>; 3276} 3277 3278multiclass SetlePats<RegisterClass RC, Instruction XORiOp, Instruction SLTOp, 3279 Instruction SLTuOp> { 3280 def : MipsPat<(setle RC:$lhs, RC:$rhs), 3281 (XORiOp (SLTOp RC:$rhs, RC:$lhs), 1)>; 3282 def : MipsPat<(setule RC:$lhs, RC:$rhs), 3283 (XORiOp (SLTuOp RC:$rhs, RC:$lhs), 1)>; 3284} 3285 3286multiclass SetgtPats<RegisterClass RC, Instruction SLTOp, Instruction SLTuOp> { 3287 def : MipsPat<(setgt RC:$lhs, RC:$rhs), 3288 (SLTOp RC:$rhs, RC:$lhs)>; 3289 def : MipsPat<(setugt RC:$lhs, RC:$rhs), 3290 (SLTuOp RC:$rhs, RC:$lhs)>; 3291} 3292 3293multiclass SetgePats<RegisterClass RC, Instruction XORiOp, Instruction SLTOp, 3294 Instruction SLTuOp> { 3295 def : MipsPat<(setge RC:$lhs, RC:$rhs), 3296 (XORiOp (SLTOp RC:$lhs, RC:$rhs), 1)>; 3297 def : MipsPat<(setuge RC:$lhs, RC:$rhs), 3298 (XORiOp (SLTuOp RC:$lhs, RC:$rhs), 1)>; 3299} 3300 3301multiclass SetgeImmPats<RegisterClass RC, Instruction XORiOp, 3302 Instruction SLTiOp, Instruction SLTiuOp> { 3303 def : MipsPat<(setge RC:$lhs, immSExt16:$rhs), 3304 (XORiOp (SLTiOp RC:$lhs, immSExt16:$rhs), 1)>; 3305 def : MipsPat<(setuge RC:$lhs, immSExt16:$rhs), 3306 (XORiOp (SLTiuOp RC:$lhs, immSExt16:$rhs), 1)>; 3307} 3308 3309let AdditionalPredicates = [NotInMicroMips] in { 3310 defm : SeteqPats<GPR32, SLTiu, XOR, SLTu, ZERO>, ISA_MIPS1; 3311 defm : SetlePats<GPR32, XORi, SLT, SLTu>, ISA_MIPS1; 3312 defm : SetgtPats<GPR32, SLT, SLTu>, ISA_MIPS1; 3313 defm : SetgePats<GPR32, XORi, SLT, SLTu>, ISA_MIPS1; 3314 defm : SetgeImmPats<GPR32, XORi, SLTi, SLTiu>, ISA_MIPS1; 3315 3316 // bswap pattern 3317 def : MipsPat<(bswap GPR32:$rt), (ROTR (WSBH GPR32:$rt), 16)>, ISA_MIPS32R2; 3318} 3319 3320// Load halfword/word patterns. 3321let AdditionalPredicates = [NotInMicroMips] in { 3322 let AddedComplexity = 40 in { 3323 def : LoadRegImmPat<LBu, i32, zextloadi8>, ISA_MIPS1; 3324 def : LoadRegImmPat<LHu, i32, zextloadi16>, ISA_MIPS1; 3325 def : LoadRegImmPat<LB, i32, sextloadi8>, ISA_MIPS1; 3326 def : LoadRegImmPat<LH, i32, sextloadi16>, ISA_MIPS1; 3327 def : LoadRegImmPat<LW, i32, load>, ISA_MIPS1; 3328 } 3329 3330 // Atomic load patterns. 3331 def : MipsPat<(atomic_load_8 addr:$a), (LB addr:$a)>, ISA_MIPS1; 3332 def : MipsPat<(atomic_load_16 addr:$a), (LH addr:$a)>, ISA_MIPS1; 3333 def : MipsPat<(atomic_load_32 addr:$a), (LW addr:$a)>, ISA_MIPS1; 3334 3335 // Atomic store patterns. 3336 def : MipsPat<(atomic_store_8 addr:$a, GPR32:$v), (SB GPR32:$v, addr:$a)>, 3337 ISA_MIPS1; 3338 def : MipsPat<(atomic_store_16 addr:$a, GPR32:$v), (SH GPR32:$v, addr:$a)>, 3339 ISA_MIPS1; 3340 def : MipsPat<(atomic_store_32 addr:$a, GPR32:$v), (SW GPR32:$v, addr:$a)>, 3341 ISA_MIPS1; 3342} 3343 3344//===----------------------------------------------------------------------===// 3345// Floating Point Support 3346//===----------------------------------------------------------------------===// 3347 3348include "MipsInstrFPU.td" 3349include "Mips64InstrInfo.td" 3350include "MipsCondMov.td" 3351 3352include "Mips32r6InstrInfo.td" 3353include "Mips64r6InstrInfo.td" 3354 3355// 3356// Mips16 3357 3358include "Mips16InstrFormats.td" 3359include "Mips16InstrInfo.td" 3360 3361// DSP 3362include "MipsDSPInstrFormats.td" 3363include "MipsDSPInstrInfo.td" 3364 3365// MSA 3366include "MipsMSAInstrFormats.td" 3367include "MipsMSAInstrInfo.td" 3368 3369// EVA 3370include "MipsEVAInstrFormats.td" 3371include "MipsEVAInstrInfo.td" 3372 3373// MT 3374include "MipsMTInstrFormats.td" 3375include "MipsMTInstrInfo.td" 3376 3377// Micromips 3378include "MicroMipsInstrFormats.td" 3379include "MicroMipsInstrInfo.td" 3380include "MicroMipsInstrFPU.td" 3381 3382// Micromips r6 3383include "MicroMips32r6InstrFormats.td" 3384include "MicroMips32r6InstrInfo.td" 3385 3386// Micromips DSP 3387include "MicroMipsDSPInstrFormats.td" 3388include "MicroMipsDSPInstrInfo.td" 3389