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