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