1//===-- SparcInstrInfo.td - Target Description for Sparc Target -----------===// 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 describes the Sparc instructions in TableGen format. 10// 11//===----------------------------------------------------------------------===// 12 13//===----------------------------------------------------------------------===// 14// Instruction format superclass 15//===----------------------------------------------------------------------===// 16 17include "SparcInstrFormats.td" 18 19//===----------------------------------------------------------------------===// 20// Feature predicates. 21//===----------------------------------------------------------------------===// 22 23// True when generating 32-bit code. 24def Is32Bit : Predicate<"!Subtarget->is64Bit()">; 25 26// True when generating 64-bit code. This also implies HasV9. 27def Is64Bit : Predicate<"Subtarget->is64Bit()">; 28 29def UseSoftMulDiv : Predicate<"Subtarget->useSoftMulDiv()">, 30 AssemblerPredicate<(all_of FeatureSoftMulDiv)>; 31 32// HasV9 - This predicate is true when the target processor supports V9 33// instructions. Note that the machine may be running in 32-bit mode. 34def HasV9 : Predicate<"Subtarget->isV9()">, 35 AssemblerPredicate<(all_of FeatureV9)>; 36 37// HasNoV9 - This predicate is true when the target doesn't have V9 38// instructions. Use of this is just a hack for the isel not having proper 39// costs for V8 instructions that are more expensive than their V9 ones. 40def HasNoV9 : Predicate<"!Subtarget->isV9()">; 41 42// HasVIS - This is true when the target processor has VIS extensions. 43def HasVIS : Predicate<"Subtarget->isVIS()">, 44 AssemblerPredicate<(all_of FeatureVIS)>; 45def HasVIS2 : Predicate<"Subtarget->isVIS2()">, 46 AssemblerPredicate<(all_of FeatureVIS2)>; 47def HasVIS3 : Predicate<"Subtarget->isVIS3()">, 48 AssemblerPredicate<(all_of FeatureVIS3)>; 49 50// HasHardQuad - This is true when the target processor supports quad floating 51// point instructions. 52def HasHardQuad : Predicate<"Subtarget->hasHardQuad()">; 53 54// HasLeonCASA - This is true when the target processor supports the CASA 55// instruction 56def HasLeonCASA : Predicate<"Subtarget->hasLeonCasa()">; 57 58// HasPWRPSR - This is true when the target processor supports partial 59// writes to the PSR register that only affects the ET field. 60def HasPWRPSR : Predicate<"Subtarget->hasPWRPSR()">, 61 AssemblerPredicate<(all_of FeaturePWRPSR)>; 62 63// HasUMAC_SMAC - This is true when the target processor supports the 64// UMAC and SMAC instructions 65def HasUMAC_SMAC : Predicate<"Subtarget->hasUmacSmac()">; 66 67def HasNoFdivSqrtFix : Predicate<"!Subtarget->fixAllFDIVSQRT()">; 68def HasFMULS : Predicate<"!Subtarget->hasNoFMULS()">; 69def HasFSMULD : Predicate<"!Subtarget->hasNoFSMULD()">; 70 71// UseDeprecatedInsts - This predicate is true when the target processor is a 72// V8, or when it is V9 but the V8 deprecated instructions are efficient enough 73// to use when appropriate. In either of these cases, the instruction selector 74// will pick deprecated instructions. 75def UseDeprecatedInsts : Predicate<"Subtarget->useDeprecatedV8Instructions()">; 76 77//===----------------------------------------------------------------------===// 78// Instruction Pattern Stuff 79//===----------------------------------------------------------------------===// 80 81def simm10 : PatLeaf<(imm), [{ return isInt<10>(N->getSExtValue()); }]>; 82 83def simm11 : PatLeaf<(imm), [{ return isInt<11>(N->getSExtValue()); }]>; 84 85def simm13 : PatLeaf<(imm), [{ return isInt<13>(N->getSExtValue()); }]>; 86 87def LO10 : SDNodeXForm<imm, [{ 88 return CurDAG->getTargetConstant((unsigned)N->getZExtValue() & 1023, SDLoc(N), 89 MVT::i32); 90}]>; 91 92def HI22 : SDNodeXForm<imm, [{ 93 // Transformation function: shift the immediate value down into the low bits. 94 return CurDAG->getTargetConstant((unsigned)N->getZExtValue() >> 10, SDLoc(N), 95 MVT::i32); 96}]>; 97 98// Return the complement of a HI22 immediate value. 99def HI22_not : SDNodeXForm<imm, [{ 100 return CurDAG->getTargetConstant(~(unsigned)N->getZExtValue() >> 10, SDLoc(N), 101 MVT::i32); 102}]>; 103 104def SETHIimm : PatLeaf<(imm), [{ 105 return isShiftedUInt<22, 10>(N->getZExtValue()); 106}], HI22>; 107 108// The N->hasOneUse() prevents the immediate from being instantiated in both 109// normal and complement form. 110def SETHIimm_not : PatLeaf<(i32 imm), [{ 111 return N->hasOneUse() && isShiftedUInt<22, 10>(~(unsigned)N->getZExtValue()); 112}], HI22_not>; 113 114// Addressing modes. 115def ADDRrr : ComplexPattern<iPTR, 2, "SelectADDRrr", [], []>; 116def ADDRri : ComplexPattern<iPTR, 2, "SelectADDRri", [frameindex], []>; 117 118// Constrained operands for the shift operations. 119class ShiftAmtImmAsmOperand<int Bits> : AsmOperandClass { 120 let Name = "ShiftAmtImm" # Bits; 121 let ParserMethod = "parseShiftAmtImm<" # Bits # ">"; 122} 123def shift_imm5 : Operand<i32> { 124 let ParserMatchClass = ShiftAmtImmAsmOperand<5>; 125} 126def shift_imm6 : Operand<i32> { 127 let ParserMatchClass = ShiftAmtImmAsmOperand<6>; 128} 129 130// Address operands 131def SparcMEMrrAsmOperand : AsmOperandClass { 132 let Name = "MEMrr"; 133 let ParserMethod = "parseMEMOperand"; 134} 135 136def SparcMEMriAsmOperand : AsmOperandClass { 137 let Name = "MEMri"; 138 let ParserMethod = "parseMEMOperand"; 139} 140 141def MEMrr : Operand<iPTR> { 142 let PrintMethod = "printMemOperand"; 143 let MIOperandInfo = (ops ptr_rc, ptr_rc); 144 let ParserMatchClass = SparcMEMrrAsmOperand; 145} 146def MEMri : Operand<iPTR> { 147 let PrintMethod = "printMemOperand"; 148 let MIOperandInfo = (ops ptr_rc, i32imm); 149 let ParserMatchClass = SparcMEMriAsmOperand; 150} 151 152// Represents a tail relocation operand for instructions such as add, ld, call. 153class SparcTailRelocSymAsmOperand<string Kind> : AsmOperandClass { 154 let Name = "TailRelocSym" # Kind; 155 let RenderMethod = "addTailRelocSymOperands"; 156 let PredicateMethod = "isTailRelocSym"; 157 let ParserMethod = "parseTailRelocSym<TailRelocKind::" # Kind # ">"; 158} 159 160def TailRelocSymGOTLoad : Operand<iPTR> { 161 let ParserMatchClass = SparcTailRelocSymAsmOperand<"Load_GOT">; 162} 163 164def TailRelocSymTLSAdd : Operand<iPTR> { 165 let ParserMatchClass = SparcTailRelocSymAsmOperand<"Add_TLS">; 166} 167 168def TailRelocSymTLSLoad : Operand<iPTR> { 169 let ParserMatchClass = SparcTailRelocSymAsmOperand<"Load_TLS">; 170} 171 172def TailRelocSymTLSCall : Operand<iPTR> { 173 let ParserMatchClass = SparcTailRelocSymAsmOperand<"Call_TLS">; 174} 175 176def SparcMembarTagAsmOperand : AsmOperandClass { 177 let Name = "MembarTag"; 178 let ParserMethod = "parseMembarTag"; 179} 180 181def MembarTag : Operand<i32> { 182 let PrintMethod = "printMembarTag"; 183 let ParserMatchClass = SparcMembarTagAsmOperand; 184} 185 186// Branch targets have OtherVT type. 187def brtarget : Operand<OtherVT> { 188 let EncoderMethod = "getBranchTargetOpValue"; 189} 190 191def bprtarget : Operand<OtherVT> { 192 let EncoderMethod = "getBranchPredTargetOpValue"; 193} 194 195def bprtarget16 : Operand<OtherVT> { 196 let EncoderMethod = "getBranchOnRegTargetOpValue"; 197} 198 199def SparcCallTargetAsmOperand : AsmOperandClass { 200 let Name = "CallTarget"; 201 let ParserMethod = "parseCallTarget"; 202} 203 204def calltarget : Operand<i32> { 205 let EncoderMethod = "getCallTargetOpValue"; 206 let DecoderMethod = "DecodeCall"; 207 let ParserMatchClass = SparcCallTargetAsmOperand; 208} 209 210def simm13Op : Operand<i32> { 211 let DecoderMethod = "DecodeSIMM13"; 212 let EncoderMethod = "getSImm13OpValue"; 213} 214 215// Operand for printing out a condition code. 216let PrintMethod = "printCCOperand" in { 217 def CCOp : Operand<i32>; 218 def RegCCOp : Operand<i32>; 219} 220 221def SDTSPcmpicc : 222SDTypeProfile<0, 2, [SDTCisInt<0>, SDTCisSameAs<0, 1>]>; 223def SDTSPcmpfcc : 224SDTypeProfile<0, 2, [SDTCisFP<0>, SDTCisSameAs<0, 1>]>; 225def SDTSPbrcc : 226SDTypeProfile<0, 2, [SDTCisVT<0, OtherVT>, SDTCisVT<1, i32>]>; 227def SDTSPselectcc : 228SDTypeProfile<1, 3, [SDTCisSameAs<0, 1>, SDTCisSameAs<1, 2>, SDTCisVT<3, i32>]>; 229def SDTSPselectreg : 230SDTypeProfile<1, 4, [SDTCisSameAs<0, 1>, SDTCisSameAs<1, 2>, SDTCisVT<3, i32>, SDTCisVT<4, i64>]>; 231def SDTSPFTOI : 232SDTypeProfile<1, 1, [SDTCisVT<0, f32>, SDTCisFP<1>]>; 233def SDTSPITOF : 234SDTypeProfile<1, 1, [SDTCisFP<0>, SDTCisVT<1, f32>]>; 235def SDTSPFTOX : 236SDTypeProfile<1, 1, [SDTCisVT<0, f64>, SDTCisFP<1>]>; 237def SDTSPXTOF : 238SDTypeProfile<1, 1, [SDTCisFP<0>, SDTCisVT<1, f64>]>; 239 240def SDTSPtlsadd : 241SDTypeProfile<1, 3, [SDTCisInt<0>, SDTCisSameAs<0, 1>, SDTCisPtrTy<2>]>; 242def SDTSPtlsld : 243SDTypeProfile<1, 2, [SDTCisPtrTy<0>, SDTCisPtrTy<1>]>; 244 245def SDTSPloadgdop : 246SDTypeProfile<1, 2, [SDTCisPtrTy<0>, SDTCisPtrTy<1>]>; 247 248def SPcmpicc : SDNode<"SPISD::CMPICC", SDTSPcmpicc, [SDNPOutGlue]>; 249def SPcmpfcc : SDNode<"SPISD::CMPFCC", SDTSPcmpfcc, [SDNPOutGlue]>; 250def SPcmpfccv9 : SDNode<"SPISD::CMPFCC_V9", SDTSPcmpfcc, [SDNPOutGlue]>; 251def SPbricc : SDNode<"SPISD::BRICC", SDTSPbrcc, [SDNPHasChain, SDNPInGlue]>; 252def SPbpicc : SDNode<"SPISD::BPICC", SDTSPbrcc, [SDNPHasChain, SDNPInGlue]>; 253def SPbpxcc : SDNode<"SPISD::BPXCC", SDTSPbrcc, [SDNPHasChain, SDNPInGlue]>; 254def SPbrfcc : SDNode<"SPISD::BRFCC", SDTSPbrcc, [SDNPHasChain, SDNPInGlue]>; 255def SPbrfccv9 : SDNode<"SPISD::BRFCC_V9", SDTSPbrcc, [SDNPHasChain, SDNPInGlue]>; 256 257def SPhi : SDNode<"SPISD::Hi", SDTIntUnaryOp>; 258def SPlo : SDNode<"SPISD::Lo", SDTIntUnaryOp>; 259 260def SPftoi : SDNode<"SPISD::FTOI", SDTSPFTOI>; 261def SPitof : SDNode<"SPISD::ITOF", SDTSPITOF>; 262def SPftox : SDNode<"SPISD::FTOX", SDTSPFTOX>; 263def SPxtof : SDNode<"SPISD::XTOF", SDTSPXTOF>; 264 265def SPselecticc : SDNode<"SPISD::SELECT_ICC", SDTSPselectcc, [SDNPInGlue]>; 266def SPselectxcc : SDNode<"SPISD::SELECT_XCC", SDTSPselectcc, [SDNPInGlue]>; 267def SPselectfcc : SDNode<"SPISD::SELECT_FCC", SDTSPselectcc, [SDNPInGlue]>; 268def SPselectreg : SDNode<"SPISD::SELECT_REG", SDTSPselectreg, [SDNPInGlue]>; 269 270// These are target-independent nodes, but have target-specific formats. 271def SDT_SPCallSeqStart : SDCallSeqStart<[ SDTCisVT<0, i32>, 272 SDTCisVT<1, i32> ]>; 273def SDT_SPCallSeqEnd : SDCallSeqEnd<[ SDTCisVT<0, i32>, 274 SDTCisVT<1, i32> ]>; 275 276def callseq_start : SDNode<"ISD::CALLSEQ_START", SDT_SPCallSeqStart, 277 [SDNPHasChain, SDNPOutGlue]>; 278def callseq_end : SDNode<"ISD::CALLSEQ_END", SDT_SPCallSeqEnd, 279 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue]>; 280 281def SDT_SPCall : SDTypeProfile<0, -1, [SDTCisVT<0, i32>]>; 282def call : SDNode<"SPISD::CALL", SDT_SPCall, 283 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue, 284 SDNPVariadic]>; 285 286def tailcall : SDNode<"SPISD::TAIL_CALL", SDT_SPCall, 287 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue, 288 SDNPVariadic]>; 289 290def SDT_SPRet : SDTypeProfile<0, 1, [SDTCisVT<0, i32>]>; 291def retflag : SDNode<"SPISD::RET_FLAG", SDT_SPRet, 292 [SDNPHasChain, SDNPOptInGlue, SDNPVariadic]>; 293 294def flushw : SDNode<"SPISD::FLUSHW", SDTNone, 295 [SDNPHasChain, SDNPSideEffect, SDNPMayStore]>; 296 297def tlsadd : SDNode<"SPISD::TLS_ADD", SDTSPtlsadd>; 298def tlsld : SDNode<"SPISD::TLS_LD", SDTSPtlsld>; 299def tlscall : SDNode<"SPISD::TLS_CALL", SDT_SPCall, 300 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue, 301 SDNPVariadic]>; 302 303def load_gdop : SDNode<"SPISD::LOAD_GDOP", SDTSPloadgdop>; 304 305def getPCX : Operand<iPTR> { 306 let PrintMethod = "printGetPCX"; 307} 308 309//===----------------------------------------------------------------------===// 310// SPARC Flag Conditions 311//===----------------------------------------------------------------------===// 312 313// Note that these values must be kept in sync with the CCOp::CondCode enum 314// values. 315class ICC_VAL<int N> : PatLeaf<(i32 N)>; 316def ICC_NE : ICC_VAL< 9>; // Not Equal 317def ICC_E : ICC_VAL< 1>; // Equal 318def ICC_G : ICC_VAL<10>; // Greater 319def ICC_LE : ICC_VAL< 2>; // Less or Equal 320def ICC_GE : ICC_VAL<11>; // Greater or Equal 321def ICC_L : ICC_VAL< 3>; // Less 322def ICC_GU : ICC_VAL<12>; // Greater Unsigned 323def ICC_LEU : ICC_VAL< 4>; // Less or Equal Unsigned 324def ICC_CC : ICC_VAL<13>; // Carry Clear/Great or Equal Unsigned 325def ICC_CS : ICC_VAL< 5>; // Carry Set/Less Unsigned 326def ICC_POS : ICC_VAL<14>; // Positive 327def ICC_NEG : ICC_VAL< 6>; // Negative 328def ICC_VC : ICC_VAL<15>; // Overflow Clear 329def ICC_VS : ICC_VAL< 7>; // Overflow Set 330 331class FCC_VAL<int N> : PatLeaf<(i32 N)>; 332def FCC_U : FCC_VAL<23>; // Unordered 333def FCC_G : FCC_VAL<22>; // Greater 334def FCC_UG : FCC_VAL<21>; // Unordered or Greater 335def FCC_L : FCC_VAL<20>; // Less 336def FCC_UL : FCC_VAL<19>; // Unordered or Less 337def FCC_LG : FCC_VAL<18>; // Less or Greater 338def FCC_NE : FCC_VAL<17>; // Not Equal 339def FCC_E : FCC_VAL<25>; // Equal 340def FCC_UE : FCC_VAL<26>; // Unordered or Equal 341def FCC_GE : FCC_VAL<27>; // Greater or Equal 342def FCC_UGE : FCC_VAL<28>; // Unordered or Greater or Equal 343def FCC_LE : FCC_VAL<29>; // Less or Equal 344def FCC_ULE : FCC_VAL<30>; // Unordered or Less or Equal 345def FCC_O : FCC_VAL<31>; // Ordered 346 347class CPCC_VAL<int N> : PatLeaf<(i32 N)>; 348def CPCC_3 : CPCC_VAL<39>; // 3 349def CPCC_2 : CPCC_VAL<38>; // 2 350def CPCC_23 : CPCC_VAL<37>; // 2 or 3 351def CPCC_1 : CPCC_VAL<36>; // 1 352def CPCC_13 : CPCC_VAL<35>; // 1 or 3 353def CPCC_12 : CPCC_VAL<34>; // 1 or 2 354def CPCC_123 : CPCC_VAL<33>; // 1 or 2 or 3 355def CPCC_0 : CPCC_VAL<41>; // 0 356def CPCC_03 : CPCC_VAL<42>; // 0 or 3 357def CPCC_02 : CPCC_VAL<43>; // 0 or 2 358def CPCC_023 : CPCC_VAL<44>; // 0 or 2 or 3 359def CPCC_01 : CPCC_VAL<45>; // 0 or 1 360def CPCC_013 : CPCC_VAL<46>; // 0 or 1 or 3 361def CPCC_012 : CPCC_VAL<47>; // 0 or 1 or 2 362 363class RegCC_VAL<int N> : PatLeaf<(i32 N)>; 364def RegCC_Z : RegCC_VAL<49>; // Zero 365def RegCC_LEZ : RegCC_VAL<50>; // Lees or equal than zero 366def RegCC_LZ : RegCC_VAL<51>; // Less than zero 367def RegCC_NZ : RegCC_VAL<53>; // Not zero 368def RegCC_GZ : RegCC_VAL<54>; // Greater than zero 369def RegCC_GEZ : RegCC_VAL<55>; // Greater or equal to zero 370 371//===----------------------------------------------------------------------===// 372// Instruction Class Templates 373//===----------------------------------------------------------------------===// 374 375/// F3_12 multiclass - Define a normal F3_1/F3_2 pattern in one shot. 376multiclass F3_12<string OpcStr, bits<6> Op3Val, SDNode OpNode, 377 RegisterClass RC, ValueType Ty, Operand immOp, 378 InstrItinClass itin = IIC_iu_instr> { 379 def rr : F3_1<2, Op3Val, 380 (outs RC:$rd), (ins RC:$rs1, RC:$rs2), 381 !strconcat(OpcStr, " $rs1, $rs2, $rd"), 382 [(set Ty:$rd, (OpNode Ty:$rs1, Ty:$rs2))], 383 itin>; 384 def ri : F3_2<2, Op3Val, 385 (outs RC:$rd), (ins RC:$rs1, immOp:$simm13), 386 !strconcat(OpcStr, " $rs1, $simm13, $rd"), 387 [(set Ty:$rd, (OpNode Ty:$rs1, (Ty simm13:$simm13)))], 388 itin>; 389} 390 391/// F3_12np multiclass - Define a normal F3_1/F3_2 pattern in one shot, with no 392/// pattern. 393multiclass F3_12np<string OpcStr, bits<6> Op3Val, InstrItinClass itin = IIC_iu_instr> { 394 def rr : F3_1<2, Op3Val, 395 (outs IntRegs:$rd), (ins IntRegs:$rs1, IntRegs:$rs2), 396 !strconcat(OpcStr, " $rs1, $rs2, $rd"), [], 397 itin>; 398 def ri : F3_2<2, Op3Val, 399 (outs IntRegs:$rd), (ins IntRegs:$rs1, simm13Op:$simm13), 400 !strconcat(OpcStr, " $rs1, $simm13, $rd"), [], 401 itin>; 402} 403 404// Load multiclass - Define both Reg+Reg/Reg+Imm patterns in one shot. 405multiclass Load<string OpcStr, bits<6> Op3Val, SDPatternOperator OpNode, 406 RegisterClass RC, ValueType Ty, InstrItinClass itin = IIC_iu_instr> { 407 def rr : F3_1<3, Op3Val, 408 (outs RC:$rd), (ins (MEMrr $rs1, $rs2):$addr), 409 !strconcat(OpcStr, " [$addr], $rd"), 410 [(set Ty:$rd, (OpNode ADDRrr:$addr))], 411 itin>; 412 def ri : F3_2<3, Op3Val, 413 (outs RC:$rd), (ins (MEMri $rs1, $simm13):$addr), 414 !strconcat(OpcStr, " [$addr], $rd"), 415 [(set Ty:$rd, (OpNode ADDRri:$addr))], 416 itin>; 417} 418 419// TODO: Instructions of the LoadASI class are currently asm only; hooking up 420// CodeGen's address spaces to use these is a future task. 421class LoadASI<string OpcStr, bits<6> Op3Val, RegisterClass RC> : 422 F3_1_asi<3, Op3Val, (outs RC:$rd), (ins (MEMrr $rs1, $rs2):$addr, i8imm:$asi), 423 !strconcat(OpcStr, "a [$addr] $asi, $rd"), 424 []>; 425 426// LoadA multiclass - As above, but also define alternate address space variant 427multiclass LoadA<string OpcStr, bits<6> Op3Val, bits<6> LoadAOp3Val, 428 SDPatternOperator OpNode, RegisterClass RC, ValueType Ty, 429 InstrItinClass itin = NoItinerary> : 430 Load<OpcStr, Op3Val, OpNode, RC, Ty, itin> { 431 def Arr : LoadASI<OpcStr, LoadAOp3Val, RC>; 432} 433 434// The LDSTUB instruction is supported for asm only. 435// It is unlikely that general-purpose code could make use of it. 436// CAS is preferred for sparc v9. 437def LDSTUBrr : F3_1<3, 0b001101, (outs IntRegs:$rd), (ins (MEMrr $rs1, $rs2):$addr), 438 "ldstub [$addr], $rd", []>; 439def LDSTUBri : F3_2<3, 0b001101, (outs IntRegs:$rd), (ins (MEMri $rs1, $simm13):$addr), 440 "ldstub [$addr], $rd", []>; 441def LDSTUBArr : F3_1_asi<3, 0b011101, (outs IntRegs:$rd), 442 (ins (MEMrr $rs1, $rs2):$addr, i8imm:$asi), 443 "ldstuba [$addr] $asi, $rd", []>; 444 445// Store multiclass - Define both Reg+Reg/Reg+Imm patterns in one shot. 446multiclass Store<string OpcStr, bits<6> Op3Val, SDPatternOperator OpNode, 447 RegisterClass RC, ValueType Ty, InstrItinClass itin = IIC_st> { 448 def rr : F3_1<3, Op3Val, 449 (outs), (ins (MEMrr $rs1, $rs2):$addr, RC:$rd), 450 !strconcat(OpcStr, " $rd, [$addr]"), 451 [(OpNode Ty:$rd, ADDRrr:$addr)], 452 itin>; 453 def ri : F3_2<3, Op3Val, 454 (outs), (ins (MEMri $rs1, $simm13):$addr, RC:$rd), 455 !strconcat(OpcStr, " $rd, [$addr]"), 456 [(OpNode Ty:$rd, ADDRri:$addr)], 457 itin>; 458} 459 460// TODO: Instructions of the StoreASI class are currently asm only; hooking up 461// CodeGen's address spaces to use these is a future task. 462class StoreASI<string OpcStr, bits<6> Op3Val, RegisterClass RC, 463 InstrItinClass itin = IIC_st> : 464 F3_1_asi<3, Op3Val, (outs), (ins (MEMrr $rs1, $rs2):$addr, RC:$rd, i8imm:$asi), 465 !strconcat(OpcStr, "a $rd, [$addr] $asi"), 466 [], 467 itin>; 468 469multiclass StoreA<string OpcStr, bits<6> Op3Val, bits<6> StoreAOp3Val, 470 SDPatternOperator OpNode, RegisterClass RC, ValueType Ty> : 471 Store<OpcStr, Op3Val, OpNode, RC, Ty> { 472 def Arr : StoreASI<OpcStr, StoreAOp3Val, RC>; 473} 474 475//===----------------------------------------------------------------------===// 476// Instructions 477//===----------------------------------------------------------------------===// 478 479// Pseudo instructions. 480class Pseudo<dag outs, dag ins, string asmstr, list<dag> pattern> 481 : InstSP<outs, ins, asmstr, pattern> { 482 let isCodeGenOnly = 1; 483 let isPseudo = 1; 484} 485 486// GETPCX for PIC 487let Defs = [O7] in { 488 def GETPCX : Pseudo<(outs getPCX:$getpcseq), (ins), "$getpcseq", [] >; 489} 490 491let Defs = [O6], Uses = [O6] in { 492def ADJCALLSTACKDOWN : Pseudo<(outs), (ins i32imm:$amt1, i32imm:$amt2), 493 "!ADJCALLSTACKDOWN $amt1, $amt2", 494 [(callseq_start timm:$amt1, timm:$amt2)]>; 495def ADJCALLSTACKUP : Pseudo<(outs), (ins i32imm:$amt1, i32imm:$amt2), 496 "!ADJCALLSTACKUP $amt1", 497 [(callseq_end timm:$amt1, timm:$amt2)]>; 498} 499 500let hasSideEffects = 1, mayStore = 1 in { 501 let rd = 0, rs1 = 0, rs2 = 0 in 502 def FLUSHW : F3_1<0b10, 0b101011, (outs), (ins), 503 "flushw", 504 [(flushw)]>, Requires<[HasV9]>; 505 let rd = 8, rs1 = 0, simm13 = 3 in 506 def TA3 : F3_2<0b10, 0b111010, (outs), (ins), 507 "ta 3", 508 [(flushw)]>; 509} 510 511// SELECT_CC_* - Used to implement the SELECT_CC DAG operation. Expanded after 512// instruction selection into a branch sequence. This has to handle all 513// permutations of selection between i32/f32/f64 on ICC and FCC. 514// Expanded after instruction selection. 515let Uses = [ICC], usesCustomInserter = 1 in { 516 def SELECT_CC_Int_ICC 517 : Pseudo<(outs IntRegs:$dst), (ins IntRegs:$T, IntRegs:$F, i32imm:$Cond), 518 "; SELECT_CC_Int_ICC PSEUDO!", 519 [(set i32:$dst, (SPselecticc i32:$T, i32:$F, imm:$Cond))]>; 520 def SELECT_CC_FP_ICC 521 : Pseudo<(outs FPRegs:$dst), (ins FPRegs:$T, FPRegs:$F, i32imm:$Cond), 522 "; SELECT_CC_FP_ICC PSEUDO!", 523 [(set f32:$dst, (SPselecticc f32:$T, f32:$F, imm:$Cond))]>; 524 525 def SELECT_CC_DFP_ICC 526 : Pseudo<(outs DFPRegs:$dst), (ins DFPRegs:$T, DFPRegs:$F, i32imm:$Cond), 527 "; SELECT_CC_DFP_ICC PSEUDO!", 528 [(set f64:$dst, (SPselecticc f64:$T, f64:$F, imm:$Cond))]>; 529 530 def SELECT_CC_QFP_ICC 531 : Pseudo<(outs QFPRegs:$dst), (ins QFPRegs:$T, QFPRegs:$F, i32imm:$Cond), 532 "; SELECT_CC_QFP_ICC PSEUDO!", 533 [(set f128:$dst, (SPselecticc f128:$T, f128:$F, imm:$Cond))]>; 534} 535 536let Uses = [ICC], usesCustomInserter = 1 in { 537 def SELECT_CC_Int_XCC 538 : Pseudo<(outs IntRegs:$dst), (ins IntRegs:$T, IntRegs:$F, i32imm:$Cond), 539 "; SELECT_CC_Int_XCC PSEUDO!", 540 [(set i32:$dst, (SPselectxcc i32:$T, i32:$F, imm:$Cond))]>; 541 def SELECT_CC_FP_XCC 542 : Pseudo<(outs FPRegs:$dst), (ins FPRegs:$T, FPRegs:$F, i32imm:$Cond), 543 "; SELECT_CC_FP_XCC PSEUDO!", 544 [(set f32:$dst, (SPselectxcc f32:$T, f32:$F, imm:$Cond))]>; 545 546 def SELECT_CC_DFP_XCC 547 : Pseudo<(outs DFPRegs:$dst), (ins DFPRegs:$T, DFPRegs:$F, i32imm:$Cond), 548 "; SELECT_CC_DFP_XCC PSEUDO!", 549 [(set f64:$dst, (SPselectxcc f64:$T, f64:$F, imm:$Cond))]>; 550 551 def SELECT_CC_QFP_XCC 552 : Pseudo<(outs QFPRegs:$dst), (ins QFPRegs:$T, QFPRegs:$F, i32imm:$Cond), 553 "; SELECT_CC_QFP_XCC PSEUDO!", 554 [(set f128:$dst, (SPselectxcc f128:$T, f128:$F, imm:$Cond))]>; 555} 556 557let usesCustomInserter = 1, Uses = [FCC0] in { 558 559 def SELECT_CC_Int_FCC 560 : Pseudo<(outs IntRegs:$dst), (ins IntRegs:$T, IntRegs:$F, i32imm:$Cond), 561 "; SELECT_CC_Int_FCC PSEUDO!", 562 [(set i32:$dst, (SPselectfcc i32:$T, i32:$F, imm:$Cond))]>; 563 564 def SELECT_CC_FP_FCC 565 : Pseudo<(outs FPRegs:$dst), (ins FPRegs:$T, FPRegs:$F, i32imm:$Cond), 566 "; SELECT_CC_FP_FCC PSEUDO!", 567 [(set f32:$dst, (SPselectfcc f32:$T, f32:$F, imm:$Cond))]>; 568 def SELECT_CC_DFP_FCC 569 : Pseudo<(outs DFPRegs:$dst), (ins DFPRegs:$T, DFPRegs:$F, i32imm:$Cond), 570 "; SELECT_CC_DFP_FCC PSEUDO!", 571 [(set f64:$dst, (SPselectfcc f64:$T, f64:$F, imm:$Cond))]>; 572 def SELECT_CC_QFP_FCC 573 : Pseudo<(outs QFPRegs:$dst), (ins QFPRegs:$T, QFPRegs:$F, i32imm:$Cond), 574 "; SELECT_CC_QFP_FCC PSEUDO!", 575 [(set f128:$dst, (SPselectfcc f128:$T, f128:$F, imm:$Cond))]>; 576} 577 578// Section B.1 - Load Integer Instructions, p. 90 579defm LDSB : LoadA<"ldsb", 0b001001, 0b011001, sextloadi8, IntRegs, i32>; 580defm LDSH : LoadA<"ldsh", 0b001010, 0b011010, sextloadi16, IntRegs, i32>; 581defm LDUB : LoadA<"ldub", 0b000001, 0b010001, zextloadi8, IntRegs, i32>; 582defm LDUH : LoadA<"lduh", 0b000010, 0b010010, zextloadi16, IntRegs, i32>; 583defm LD : LoadA<"ld", 0b000000, 0b010000, load, IntRegs, i32>; 584defm LDD : LoadA<"ldd", 0b000011, 0b010011, load, IntPair, v2i32, IIC_ldd>; 585 586// Section B.2 - Load Floating-point Instructions, p. 92 587defm LDF : Load<"ld", 0b100000, load, FPRegs, f32, IIC_iu_or_fpu_instr>; 588def LDFArr : LoadASI<"ld", 0b110000, FPRegs>, 589 Requires<[HasV9]>; 590 591defm LDDF : Load<"ldd", 0b100011, load, DFPRegs, f64, IIC_ldd>; 592def LDDFArr : LoadASI<"ldd", 0b110011, DFPRegs>, 593 Requires<[HasV9]>; 594defm LDQF : LoadA<"ldq", 0b100010, 0b110010, load, QFPRegs, f128>, 595 Requires<[HasV9, HasHardQuad]>; 596 597defm LDC : Load<"ld", 0b110000, load, CoprocRegs, i32>; 598defm LDDC : Load<"ldd", 0b110011, load, CoprocPair, v2i32, IIC_ldd>; 599 600let Defs = [CPSR] in { 601 let rd = 0 in { 602 def LDCSRrr : F3_1<3, 0b110001, (outs), (ins (MEMrr $rs1, $rs2):$addr), 603 "ld [$addr], %csr", []>; 604 def LDCSRri : F3_2<3, 0b110001, (outs), (ins (MEMri $rs1, $simm13):$addr), 605 "ld [$addr], %csr", []>; 606 } 607} 608 609let Defs = [FSR] in { 610 let rd = 0 in { 611 def LDFSRrr : F3_1<3, 0b100001, (outs), (ins (MEMrr $rs1, $rs2):$addr), 612 "ld [$addr], %fsr", [], IIC_iu_or_fpu_instr>; 613 def LDFSRri : F3_2<3, 0b100001, (outs), (ins (MEMri $rs1, $simm13):$addr), 614 "ld [$addr], %fsr", [], IIC_iu_or_fpu_instr>; 615 } 616 let rd = 1 in { 617 def LDXFSRrr : F3_1<3, 0b100001, (outs), (ins (MEMrr $rs1, $rs2):$addr), 618 "ldx [$addr], %fsr", []>, Requires<[HasV9]>; 619 def LDXFSRri : F3_2<3, 0b100001, (outs), (ins (MEMri $rs1, $simm13):$addr), 620 "ldx [$addr], %fsr", []>, Requires<[HasV9]>; 621 } 622} 623 624let mayLoad = 1, isAsmParserOnly = 1 in { 625 def GDOP_LDrr : F3_1<3, 0b000000, 626 (outs IntRegs:$rd), 627 (ins (MEMrr $rs1, $rs2):$addr, TailRelocSymGOTLoad:$sym), 628 "ld [$addr], $rd, $sym", 629 [(set i32:$rd, 630 (load_gdop ADDRrr:$addr, tglobaladdr:$sym))]>; 631} 632 633// Section B.4 - Store Integer Instructions, p. 95 634defm STB : StoreA<"stb", 0b000101, 0b010101, truncstorei8, IntRegs, i32>; 635defm STH : StoreA<"sth", 0b000110, 0b010110, truncstorei16, IntRegs, i32>; 636defm ST : StoreA<"st", 0b000100, 0b010100, store, IntRegs, i32>; 637defm STD : StoreA<"std", 0b000111, 0b010111, store, IntPair, v2i32>; 638 639// Section B.5 - Store Floating-point Instructions, p. 97 640defm STF : Store<"st", 0b100100, store, FPRegs, f32>; 641def STFArr : StoreASI<"st", 0b110100, FPRegs>, 642 Requires<[HasV9]>; 643defm STDF : Store<"std", 0b100111, store, DFPRegs, f64, IIC_std>; 644def STDFArr : StoreASI<"std", 0b110111, DFPRegs>, 645 Requires<[HasV9]>; 646defm STQF : StoreA<"stq", 0b100110, 0b110110, store, QFPRegs, f128>, 647 Requires<[HasV9, HasHardQuad]>; 648 649defm STC : Store<"st", 0b110100, store, CoprocRegs, i32>; 650defm STDC : Store<"std", 0b110111, store, CoprocPair, v2i32, IIC_std>; 651 652let rd = 0 in { 653 let Defs = [CPSR] in { 654 def STCSRrr : F3_1<3, 0b110101, (outs (MEMrr $rs1, $rs2):$addr), (ins), 655 "st %csr, [$addr]", [], IIC_st>; 656 def STCSRri : F3_2<3, 0b110101, (outs (MEMri $rs1, $simm13):$addr), (ins), 657 "st %csr, [$addr]", [], IIC_st>; 658 } 659 let Defs = [CPQ] in { 660 def STDCQrr : F3_1<3, 0b110110, (outs (MEMrr $rs1, $rs2):$addr), (ins), 661 "std %cq, [$addr]", [], IIC_std>; 662 def STDCQri : F3_2<3, 0b110110, (outs (MEMri $rs1, $simm13):$addr), (ins), 663 "std %cq, [$addr]", [], IIC_std>; 664 } 665} 666 667let rd = 0 in { 668 let Defs = [FSR] in { 669 def STFSRrr : F3_1<3, 0b100101, (outs (MEMrr $rs1, $rs2):$addr), (ins), 670 "st %fsr, [$addr]", [], IIC_st>; 671 def STFSRri : F3_2<3, 0b100101, (outs (MEMri $rs1, $simm13):$addr), (ins), 672 "st %fsr, [$addr]", [], IIC_st>; 673 } 674 let Defs = [FQ] in { 675 def STDFQrr : F3_1<3, 0b100110, (outs (MEMrr $rs1, $rs2):$addr), (ins), 676 "std %fq, [$addr]", [], IIC_std>; 677 def STDFQri : F3_2<3, 0b100110, (outs (MEMri $rs1, $simm13):$addr), (ins), 678 "std %fq, [$addr]", [], IIC_std>; 679 } 680} 681let rd = 1, Defs = [FSR] in { 682 def STXFSRrr : F3_1<3, 0b100101, (outs (MEMrr $rs1, $rs2):$addr), (ins), 683 "stx %fsr, [$addr]", []>, Requires<[HasV9]>; 684 def STXFSRri : F3_2<3, 0b100101, (outs (MEMri $rs1, $simm13):$addr), (ins), 685 "stx %fsr, [$addr]", []>, Requires<[HasV9]>; 686} 687 688// Section B.8 - SWAP Register with Memory Instruction 689// (Atomic swap) 690let Constraints = "$val = $rd" in { 691 def SWAPrr : F3_1<3, 0b001111, 692 (outs IntRegs:$rd), (ins (MEMrr $rs1, $rs2):$addr, IntRegs:$val), 693 "swap [$addr], $rd", 694 [(set i32:$rd, (atomic_swap_32 ADDRrr:$addr, i32:$val))]>; 695 def SWAPri : F3_2<3, 0b001111, 696 (outs IntRegs:$rd), (ins (MEMri $rs1, $simm13):$addr, IntRegs:$val), 697 "swap [$addr], $rd", 698 [(set i32:$rd, (atomic_swap_32 ADDRri:$addr, i32:$val))]>; 699 def SWAPArr : F3_1_asi<3, 0b011111, 700 (outs IntRegs:$rd), (ins (MEMrr $rs1, $rs2):$addr, i8imm:$asi, IntRegs:$val), 701 "swapa [$addr] $asi, $rd", 702 [/*FIXME: pattern?*/]>; 703} 704 705 706// Section B.9 - SETHI Instruction, p. 104 707def SETHIi: F2_1<0b100, 708 (outs IntRegs:$rd), (ins i32imm:$imm22), 709 "sethi $imm22, $rd", 710 [(set i32:$rd, SETHIimm:$imm22)], 711 IIC_iu_instr>; 712 713// Section B.10 - NOP Instruction, p. 105 714// (It's a special case of SETHI) 715let rd = 0, imm22 = 0 in 716 def NOP : F2_1<0b100, (outs), (ins), "nop", []>; 717 718// Section B.11 - Logical Instructions, p. 106 719defm AND : F3_12<"and", 0b000001, and, IntRegs, i32, simm13Op>; 720 721def ANDNrr : F3_1<2, 0b000101, 722 (outs IntRegs:$rd), (ins IntRegs:$rs1, IntRegs:$rs2), 723 "andn $rs1, $rs2, $rd", 724 [(set i32:$rd, (and i32:$rs1, (not i32:$rs2)))]>; 725def ANDNri : F3_2<2, 0b000101, 726 (outs IntRegs:$rd), (ins IntRegs:$rs1, simm13Op:$simm13), 727 "andn $rs1, $simm13, $rd", []>; 728 729defm OR : F3_12<"or", 0b000010, or, IntRegs, i32, simm13Op>; 730 731def ORNrr : F3_1<2, 0b000110, 732 (outs IntRegs:$rd), (ins IntRegs:$rs1, IntRegs:$rs2), 733 "orn $rs1, $rs2, $rd", 734 [(set i32:$rd, (or i32:$rs1, (not i32:$rs2)))]>; 735def ORNri : F3_2<2, 0b000110, 736 (outs IntRegs:$rd), (ins IntRegs:$rs1, simm13Op:$simm13), 737 "orn $rs1, $simm13, $rd", []>; 738defm XOR : F3_12<"xor", 0b000011, xor, IntRegs, i32, simm13Op>; 739 740def XNORrr : F3_1<2, 0b000111, 741 (outs IntRegs:$rd), (ins IntRegs:$rs1, IntRegs:$rs2), 742 "xnor $rs1, $rs2, $rd", 743 [(set i32:$rd, (not (xor i32:$rs1, i32:$rs2)))]>; 744def XNORri : F3_2<2, 0b000111, 745 (outs IntRegs:$rd), (ins IntRegs:$rs1, simm13Op:$simm13), 746 "xnor $rs1, $simm13, $rd", []>; 747 748def : Pat<(and IntRegs:$rs1, SETHIimm_not:$rs2), 749 (ANDNrr i32:$rs1, (SETHIi SETHIimm_not:$rs2))>; 750 751def : Pat<(or IntRegs:$rs1, SETHIimm_not:$rs2), 752 (ORNrr i32:$rs1, (SETHIi SETHIimm_not:$rs2))>; 753 754let Defs = [ICC] in { 755 defm ANDCC : F3_12np<"andcc", 0b010001>; 756 defm ANDNCC : F3_12np<"andncc", 0b010101>; 757 defm ORCC : F3_12np<"orcc", 0b010010>; 758 defm ORNCC : F3_12np<"orncc", 0b010110>; 759 defm XORCC : F3_12np<"xorcc", 0b010011>; 760 defm XNORCC : F3_12np<"xnorcc", 0b010111>; 761} 762 763// Section B.12 - Shift Instructions, p. 107 764defm SLL : F3_S<"sll", 0b100101, 0, shl, i32, shift_imm5, IntRegs>; 765defm SRL : F3_S<"srl", 0b100110, 0, srl, i32, shift_imm5, IntRegs>; 766defm SRA : F3_S<"sra", 0b100111, 0, sra, i32, shift_imm5, IntRegs>; 767 768// Section B.13 - Add Instructions, p. 108 769defm ADD : F3_12<"add", 0b000000, add, IntRegs, i32, simm13Op>; 770 771// "LEA" forms of add (patterns to make tblgen happy) 772let Predicates = [Is32Bit], isCodeGenOnly = 1 in 773 def LEA_ADDri : F3_2<2, 0b000000, 774 (outs IntRegs:$rd), (ins (MEMri $rs1, $simm13):$addr), 775 "add ${addr:arith}, $rd", 776 [(set iPTR:$rd, ADDRri:$addr)]>; 777 778let Defs = [ICC] in 779 defm ADDCC : F3_12<"addcc", 0b010000, addc, IntRegs, i32, simm13Op>; 780 781let Uses = [ICC] in 782 defm ADDC : F3_12np<"addx", 0b001000>; 783 784let Uses = [ICC], Defs = [ICC] in 785 defm ADDE : F3_12<"addxcc", 0b011000, adde, IntRegs, i32, simm13Op>; 786 787// Section B.15 - Subtract Instructions, p. 110 788defm SUB : F3_12 <"sub" , 0b000100, sub, IntRegs, i32, simm13Op>; 789let Uses = [ICC], Defs = [ICC] in 790 defm SUBE : F3_12 <"subxcc" , 0b011100, sube, IntRegs, i32, simm13Op>; 791 792let Defs = [ICC] in 793 defm SUBCC : F3_12 <"subcc", 0b010100, subc, IntRegs, i32, simm13Op>; 794 795let Uses = [ICC] in 796 defm SUBC : F3_12np <"subx", 0b001100>; 797 798// cmp (from Section A.3) is a specialized alias for subcc 799let Defs = [ICC], rd = 0 in { 800 def CMPrr : F3_1<2, 0b010100, 801 (outs), (ins IntRegs:$rs1, IntRegs:$rs2), 802 "cmp $rs1, $rs2", 803 [(SPcmpicc i32:$rs1, i32:$rs2)]>; 804 def CMPri : F3_2<2, 0b010100, 805 (outs), (ins IntRegs:$rs1, simm13Op:$simm13), 806 "cmp $rs1, $simm13", 807 [(SPcmpicc i32:$rs1, (i32 simm13:$simm13))]>; 808} 809 810// Section B.18 - Multiply Instructions, p. 113 811let Defs = [Y] in { 812 defm UMUL : F3_12<"umul", 0b001010, umullohi, IntRegs, i32, simm13Op, IIC_iu_umul>; 813 defm SMUL : F3_12<"smul", 0b001011, smullohi, IntRegs, i32, simm13Op, IIC_iu_smul>; 814} 815 816let Defs = [Y, ICC] in { 817 defm UMULCC : F3_12np<"umulcc", 0b011010, IIC_iu_umul>; 818 defm SMULCC : F3_12np<"smulcc", 0b011011, IIC_iu_smul>; 819} 820 821let Defs = [Y, ICC], Uses = [Y, ICC] in { 822 defm MULSCC : F3_12np<"mulscc", 0b100100>; 823} 824 825// Section B.19 - Divide Instructions, p. 115 826let Uses = [Y], Defs = [Y] in { 827 defm UDIV : F3_12np<"udiv", 0b001110, IIC_iu_div>; 828 defm SDIV : F3_12np<"sdiv", 0b001111, IIC_iu_div>; 829} 830 831let Uses = [Y], Defs = [Y, ICC] in { 832 defm UDIVCC : F3_12np<"udivcc", 0b011110, IIC_iu_div>; 833 defm SDIVCC : F3_12np<"sdivcc", 0b011111, IIC_iu_div>; 834} 835 836// Section B.20 - SAVE and RESTORE, p. 117 837defm SAVE : F3_12np<"save" , 0b111100>; 838defm RESTORE : F3_12np<"restore", 0b111101>; 839 840// Section B.21 - Branch on Integer Condition Codes Instructions, p. 119 841// Section A.7 - Branch on Integer Condition Codes with Prediction (SPARC v9) 842 843let isBranch = 1, isTerminator = 1, hasDelaySlot = 1, isBarrier = 1 in { 844// unconditional branch class. 845class BranchAlways<dag ins, string asmstr, list<dag> pattern> 846 : F2_2<0b010, 0, (outs), ins, asmstr, pattern>; 847 848// Same as BranchAlways but uses the new v9 encoding 849class BranchPredictAlways<dag ins, string asmstr, list<dag> pattern> 850 : F2_3<0b001, 0, 1, (outs), ins, asmstr, pattern>; 851} 852 853let cond = 8 in { 854 // If we're compiling for v9, prefer BPA rather than BA 855 // TODO: Disallow BA emission when FeatureV8Deprecated isn't enabled 856 let Predicates = [HasV9], cc = 0b00 in 857 def BPA : BranchPredictAlways<(ins bprtarget:$imm19), 858 "ba %icc, $imm19", [(br bb:$imm19)]>; 859 860 def BA : BranchAlways<(ins brtarget:$imm22), "ba $imm22", [(br bb:$imm22)]>; 861} 862 863let isBranch = 1, isTerminator = 1, hasDelaySlot = 1 in { 864 865// conditional branch class: 866class BranchSP<dag ins, string asmstr, list<dag> pattern> 867 : F2_2<0b010, 0, (outs), ins, asmstr, pattern, IIC_iu_instr>; 868 869// conditional branch with annul class: 870class BranchSPA<dag ins, string asmstr, list<dag> pattern> 871 : F2_2<0b010, 1, (outs), ins, asmstr, pattern, IIC_iu_instr>; 872 873// Conditional branch class on %icc|%xcc with predication: 874multiclass IPredBranch<string regstr, list<dag> CCPattern> { 875 def CC : F2_3<0b001, 0, 1, (outs), (ins bprtarget:$imm19, CCOp:$cond), 876 !strconcat("b$cond ", !strconcat(regstr, ", $imm19")), 877 CCPattern, 878 IIC_iu_instr>; 879 def CCA : F2_3<0b001, 1, 1, (outs), (ins bprtarget:$imm19, CCOp:$cond), 880 !strconcat("b$cond,a ", !strconcat(regstr, ", $imm19")), 881 [], 882 IIC_iu_instr>; 883 def CCNT : F2_3<0b001, 0, 0, (outs), (ins bprtarget:$imm19, CCOp:$cond), 884 !strconcat("b$cond,pn ", !strconcat(regstr, ", $imm19")), 885 [], 886 IIC_iu_instr>; 887 def CCANT : F2_3<0b001, 1, 0, (outs), (ins bprtarget:$imm19, CCOp:$cond), 888 !strconcat("b$cond,a,pn ", !strconcat(regstr, ", $imm19")), 889 [], 890 IIC_iu_instr>; 891} 892 893} // let isBranch = 1, isTerminator = 1, hasDelaySlot = 1 894 895 896// Indirect branch instructions. 897let isTerminator = 1, isBarrier = 1, hasDelaySlot = 1, isBranch =1, 898 isIndirectBranch = 1, rd = 0, isCodeGenOnly = 1 in { 899 def BINDrr : F3_1<2, 0b111000, 900 (outs), (ins (MEMrr $rs1, $rs2):$addr), 901 "jmp $addr", 902 [(brind ADDRrr:$addr)]>; 903 def BINDri : F3_2<2, 0b111000, 904 (outs), (ins (MEMri $rs1, $simm13):$addr), 905 "jmp $addr", 906 [(brind ADDRri:$addr)]>; 907} 908 909let Uses = [ICC] in { 910 def BCOND : BranchSP<(ins brtarget:$imm22, CCOp:$cond), 911 "b$cond $imm22", 912 [(SPbricc bb:$imm22, imm:$cond)]>; 913 def BCONDA : BranchSPA<(ins brtarget:$imm22, CCOp:$cond), 914 "b$cond,a $imm22", []>; 915 916 let Predicates = [HasV9], cc = 0b00 in 917 defm BPI : IPredBranch<"%icc", [(SPbpicc bb:$imm19, imm:$cond)]>; 918} 919 920// Section B.22 - Branch on Floating-point Condition Codes Instructions, p. 121 921 922let isBranch = 1, isTerminator = 1, hasDelaySlot = 1 in { 923 924// floating-point conditional branch class: 925class FPBranchSP<dag ins, string asmstr, list<dag> pattern> 926 : F2_2<0b110, 0, (outs), ins, asmstr, pattern, IIC_fpu_normal_instr>; 927 928// floating-point conditional branch with annul class: 929class FPBranchSPA<dag ins, string asmstr, list<dag> pattern> 930 : F2_2<0b110, 1, (outs), ins, asmstr, pattern, IIC_fpu_normal_instr>; 931 932// Conditional branch class on %fcc0-%fcc3 with predication: 933multiclass FPredBranch { 934 def CC : F2_3<0b101, 0, 1, (outs), (ins bprtarget:$imm19, CCOp:$cond, 935 FCCRegs:$cc), 936 "fb$cond $cc, $imm19", [], IIC_fpu_normal_instr>; 937 def CCA : F2_3<0b101, 1, 1, (outs), (ins bprtarget:$imm19, CCOp:$cond, 938 FCCRegs:$cc), 939 "fb$cond,a $cc, $imm19", [], IIC_fpu_normal_instr>; 940 def CCNT : F2_3<0b101, 0, 0, (outs), (ins bprtarget:$imm19, CCOp:$cond, 941 FCCRegs:$cc), 942 "fb$cond,pn $cc, $imm19", [], IIC_fpu_normal_instr>; 943 def CCANT : F2_3<0b101, 1, 0, (outs), (ins bprtarget:$imm19, CCOp:$cond, 944 FCCRegs:$cc), 945 "fb$cond,a,pn $cc, $imm19", [], IIC_fpu_normal_instr>; 946} 947} // let isBranch = 1, isTerminator = 1, hasDelaySlot = 1 948 949let Uses = [FCC0] in { 950 def FBCOND : FPBranchSP<(ins brtarget:$imm22, CCOp:$cond), 951 "fb$cond $imm22", 952 [(SPbrfcc bb:$imm22, imm:$cond)]>; 953 def FBCONDA : FPBranchSPA<(ins brtarget:$imm22, CCOp:$cond), 954 "fb$cond,a $imm22", []>; 955} 956 957// Variants of FBCOND that uses V9 opcode 958let Predicates = [HasV9], Uses = [FCC0], cc = 0, 959 isBranch = 1, isTerminator = 1, hasDelaySlot = 1 in { 960 def FBCOND_V9 : F2_3<0b101, 0, 1, (outs), 961 (ins bprtarget:$imm19, CCOp:$cond), 962 "fb$cond %fcc0, $imm19", 963 [(SPbrfccv9 bb:$imm19, imm:$cond)], IIC_fpu_normal_instr>; 964 def FBCONDA_V9 : F2_3<0b101, 1, 1, (outs), 965 (ins bprtarget:$imm19, CCOp:$cond), 966 "fb$cond,a %fcc0, $imm19", 967 [(SPbrfccv9 bb:$imm19, imm:$cond)], IIC_fpu_normal_instr>; 968} 969 970let Predicates = [HasV9] in 971 defm BPF : FPredBranch; 972 973// Section B.22 - Branch on Co-processor Condition Codes Instructions, p. 123 974let isBranch = 1, isTerminator = 1, hasDelaySlot = 1 in { 975 976// co-processor conditional branch class: 977class CPBranchSP<dag ins, string asmstr, list<dag> pattern> 978 : F2_2<0b111, 0, (outs), ins, asmstr, pattern>; 979 980// co-processor conditional branch with annul class: 981class CPBranchSPA<dag ins, string asmstr, list<dag> pattern> 982 : F2_2<0b111, 1, (outs), ins, asmstr, pattern>; 983 984} // let isBranch = 1, isTerminator = 1, hasDelaySlot = 1 985 986def CBCOND : CPBranchSP<(ins brtarget:$imm22, CCOp:$cond), 987 "cb$cond $imm22", 988 [(SPbrfcc bb:$imm22, imm:$cond)]>; 989def CBCONDA : CPBranchSPA<(ins brtarget:$imm22, CCOp:$cond), 990 "cb$cond,a $imm22", []>; 991 992// Section B.24 - Call and Link Instruction, p. 125 993// This is the only Format 1 instruction 994let Uses = [O6], 995 hasDelaySlot = 1, isCall = 1 in { 996 def CALL : InstSP<(outs), (ins calltarget:$disp, variable_ops), 997 "call $disp", 998 [], 999 IIC_jmp_or_call> { 1000 bits<30> disp; 1001 let op = 1; 1002 let Inst{29-0} = disp; 1003 } 1004 1005 // indirect calls: special cases of JMPL. 1006 let isCodeGenOnly = 1, rd = 15 in { 1007 def CALLrr : F3_1<2, 0b111000, 1008 (outs), (ins (MEMrr $rs1, $rs2):$addr, variable_ops), 1009 "call $addr", 1010 [(call ADDRrr:$addr)], 1011 IIC_jmp_or_call>; 1012 def CALLri : F3_2<2, 0b111000, 1013 (outs), (ins (MEMri $rs1, $simm13):$addr, variable_ops), 1014 "call $addr", 1015 [(call ADDRri:$addr)], 1016 IIC_jmp_or_call>; 1017 } 1018} 1019 1020// Section B.25 - Jump and Link Instruction 1021 1022// JMPL Instruction. 1023let isTerminator = 1, hasDelaySlot = 1, isBarrier = 1 in { 1024 def JMPLrr: F3_1<2, 0b111000, 1025 (outs IntRegs:$rd), (ins (MEMrr $rs1, $rs2):$addr), 1026 "jmpl $addr, $rd", 1027 [], 1028 IIC_jmp_or_call>; 1029 def JMPLri: F3_2<2, 0b111000, 1030 (outs IntRegs:$rd), (ins (MEMri $rs1, $simm13):$addr), 1031 "jmpl $addr, $rd", 1032 [], 1033 IIC_jmp_or_call>; 1034} 1035 1036// Section A.3 - Synthetic Instructions, p. 85 1037// special cases of JMPL: 1038let isReturn = 1, isTerminator = 1, hasDelaySlot = 1, isBarrier = 1, 1039 isCodeGenOnly = 1 in { 1040 let rd = 0, rs1 = 15 in 1041 def RETL: F3_2<2, 0b111000, 1042 (outs), (ins i32imm:$simm13), 1043 "jmp %o7+$simm13", 1044 [(retflag simm13:$simm13)], 1045 IIC_jmp_or_call>; 1046 1047 let rd = 0, rs1 = 31 in 1048 def RET: F3_2<2, 0b111000, 1049 (outs), (ins i32imm:$simm13), 1050 "jmp %i7+$simm13", 1051 [], 1052 IIC_jmp_or_call>; 1053} 1054 1055// Section B.26 - Return from Trap Instruction 1056let isReturn = 1, isTerminator = 1, hasDelaySlot = 1, 1057 isBarrier = 1, rd = 0 in { 1058 def RETTrr : F3_1<2, 0b111001, 1059 (outs), (ins (MEMrr $rs1, $rs2):$addr), 1060 "rett $addr", 1061 [], 1062 IIC_jmp_or_call>; 1063 def RETTri : F3_2<2, 0b111001, 1064 (outs), (ins (MEMri $rs1, $simm13):$addr), 1065 "rett $addr", 1066 [], 1067 IIC_jmp_or_call>; 1068} 1069 1070 1071// Section B.27 - Trap on Integer Condition Codes Instruction 1072// conditional branch class: 1073let DecoderNamespace = "SparcV8", hasSideEffects = 1, Uses = [ICC], cc = 0b00 in 1074{ 1075 def TRAPrr : TRAPSPrr<0b111010, 1076 (outs), (ins IntRegs:$rs1, IntRegs:$rs2, CCOp:$cond), 1077 "t$cond $rs1 + $rs2", 1078 []>; 1079 def TRAPri : TRAPSPri<0b111010, 1080 (outs), (ins IntRegs:$rs1, i32imm:$imm, CCOp:$cond), 1081 "t$cond $rs1 + $imm", 1082 []>; 1083} 1084 1085multiclass TRAP<string regStr> { 1086 def rr : TRAPSPrr<0b111010, 1087 (outs), (ins IntRegs:$rs1, IntRegs:$rs2, CCOp:$cond), 1088 !strconcat(!strconcat("t$cond ", regStr), ", $rs1 + $rs2"), 1089 []>; 1090 def ri : TRAPSPri<0b111010, 1091 (outs), (ins IntRegs:$rs1, i32imm:$imm, CCOp:$cond), 1092 !strconcat(!strconcat("t$cond ", regStr), ", $rs1 + $imm"), 1093 []>; 1094} 1095 1096let DecoderNamespace = "SparcV9", Predicates = [HasV9], hasSideEffects = 1, Uses = [ICC], cc = 0b00 in 1097 defm TICC : TRAP<"%icc">; 1098 1099 1100let isBarrier = 1, isTerminator = 1, rd = 0b01000, rs1 = 0, simm13 = 5 in 1101 def TA5 : F3_2<0b10, 0b111010, (outs), (ins), "ta 5", [(trap)]>; 1102 1103let hasSideEffects = 1, rd = 0b01000, rs1 = 0, simm13 = 1 in 1104 def TA1 : F3_2<0b10, 0b111010, (outs), (ins), "ta 1", [(debugtrap)]>; 1105 1106// Section B.28 - Read State Register Instructions 1107let rs2 = 0 in 1108 def RDASR : F3_1<2, 0b101000, 1109 (outs IntRegs:$rd), (ins ASRRegs:$rs1), 1110 "rd $rs1, $rd", []>; 1111 1112// PSR, WIM, and TBR don't exist on the SparcV9, only the V8. 1113let Predicates = [HasNoV9] in { 1114 let rs2 = 0, rs1 = 0, Uses=[PSR] in 1115 def RDPSR : F3_1<2, 0b101001, 1116 (outs IntRegs:$rd), (ins), 1117 "rd %psr, $rd", []>; 1118 1119 let rs2 = 0, rs1 = 0, Uses=[WIM] in 1120 def RDWIM : F3_1<2, 0b101010, 1121 (outs IntRegs:$rd), (ins), 1122 "rd %wim, $rd", []>; 1123 1124 let rs2 = 0, rs1 = 0, Uses=[TBR] in 1125 def RDTBR : F3_1<2, 0b101011, 1126 (outs IntRegs:$rd), (ins), 1127 "rd %tbr, $rd", []>; 1128} 1129 1130// PC don't exist on the SparcV8, only the V9. 1131let Predicates = [HasV9] in { 1132 let rs2 = 0, rs1 = 5 in 1133 def RDPC : F3_1<2, 0b101000, 1134 (outs IntRegs:$rd), (ins), 1135 "rd %pc, $rd", []>; 1136} 1137 1138// Section B.29 - Write State Register Instructions 1139def WRASRrr : F3_1<2, 0b110000, 1140 (outs ASRRegs:$rd), (ins IntRegs:$rs1, IntRegs:$rs2), 1141 "wr $rs1, $rs2, $rd", []>; 1142def WRASRri : F3_2<2, 0b110000, 1143 (outs ASRRegs:$rd), (ins IntRegs:$rs1, simm13Op:$simm13), 1144 "wr $rs1, $simm13, $rd", []>; 1145 1146// PSR, WIM, and TBR don't exist on the SparcV9, only the V8. 1147let Predicates = [HasNoV9] in { 1148 let Defs = [PSR], rd=0 in { 1149 def WRPSRrr : F3_1<2, 0b110001, 1150 (outs), (ins IntRegs:$rs1, IntRegs:$rs2), 1151 "wr $rs1, $rs2, %psr", []>; 1152 def WRPSRri : F3_2<2, 0b110001, 1153 (outs), (ins IntRegs:$rs1, simm13Op:$simm13), 1154 "wr $rs1, $simm13, %psr", []>; 1155 } 1156 1157 let Defs = [WIM], rd=0 in { 1158 def WRWIMrr : F3_1<2, 0b110010, 1159 (outs), (ins IntRegs:$rs1, IntRegs:$rs2), 1160 "wr $rs1, $rs2, %wim", []>; 1161 def WRWIMri : F3_2<2, 0b110010, 1162 (outs), (ins IntRegs:$rs1, simm13Op:$simm13), 1163 "wr $rs1, $simm13, %wim", []>; 1164 } 1165 1166 let Defs = [TBR], rd=0 in { 1167 def WRTBRrr : F3_1<2, 0b110011, 1168 (outs), (ins IntRegs:$rs1, IntRegs:$rs2), 1169 "wr $rs1, $rs2, %tbr", []>; 1170 def WRTBRri : F3_2<2, 0b110011, 1171 (outs), (ins IntRegs:$rs1, simm13Op:$simm13), 1172 "wr $rs1, $simm13, %tbr", []>; 1173 } 1174} 1175 1176// Section B.30 - STBAR Instruction 1177let hasSideEffects = 1, rd = 0, rs1 = 0b01111, rs2 = 0 in 1178 def STBAR : F3_1<2, 0b101000, (outs), (ins), "stbar", []>; 1179 1180 1181// Section B.31 - Unimplemented Instruction 1182let rd = 0 in 1183 def UNIMP : F2_1<0b000, (outs), (ins i32imm:$imm22), 1184 "unimp $imm22", []>; 1185 1186// Section B.32 - Flush Instruction Memory 1187let rd = 0 in { 1188 def FLUSHrr : F3_1<2, 0b111011, (outs), (ins (MEMrr $rs1, $rs2):$addr), 1189 "flush $addr", []>; 1190 def FLUSHri : F3_2<2, 0b111011, (outs), (ins (MEMri $rs1, $simm13):$addr), 1191 "flush $addr", []>; 1192 1193 // The no-arg FLUSH is only here for the benefit of the InstAlias 1194 // "flush", which cannot seem to use FLUSHrr, due to the inability 1195 // to construct a MEMrr with fixed G0 registers. 1196 let rs1 = 0, rs2 = 0 in 1197 def FLUSH : F3_1<2, 0b111011, (outs), (ins), "flush %g0", []>; 1198} 1199 1200// Section B.33 - Floating-point Operate (FPop) Instructions 1201 1202// Convert Integer to Floating-point Instructions, p. 141 1203def FITOS : F3_3u<2, 0b110100, 0b011000100, 1204 (outs FPRegs:$rd), (ins FPRegs:$rs2), 1205 "fitos $rs2, $rd", 1206 [(set FPRegs:$rd, (SPitof FPRegs:$rs2))], 1207 IIC_fpu_fast_instr>; 1208def FITOD : F3_3u<2, 0b110100, 0b011001000, 1209 (outs DFPRegs:$rd), (ins FPRegs:$rs2), 1210 "fitod $rs2, $rd", 1211 [(set DFPRegs:$rd, (SPitof FPRegs:$rs2))], 1212 IIC_fpu_fast_instr>; 1213def FITOQ : F3_3u<2, 0b110100, 0b011001100, 1214 (outs QFPRegs:$rd), (ins FPRegs:$rs2), 1215 "fitoq $rs2, $rd", 1216 [(set QFPRegs:$rd, (SPitof FPRegs:$rs2))]>, 1217 Requires<[HasHardQuad]>; 1218 1219// Convert Floating-point to Integer Instructions, p. 142 1220def FSTOI : F3_3u<2, 0b110100, 0b011010001, 1221 (outs FPRegs:$rd), (ins FPRegs:$rs2), 1222 "fstoi $rs2, $rd", 1223 [(set FPRegs:$rd, (SPftoi FPRegs:$rs2))], 1224 IIC_fpu_fast_instr>; 1225def FDTOI : F3_3u<2, 0b110100, 0b011010010, 1226 (outs FPRegs:$rd), (ins DFPRegs:$rs2), 1227 "fdtoi $rs2, $rd", 1228 [(set FPRegs:$rd, (SPftoi DFPRegs:$rs2))], 1229 IIC_fpu_fast_instr>; 1230def FQTOI : F3_3u<2, 0b110100, 0b011010011, 1231 (outs FPRegs:$rd), (ins QFPRegs:$rs2), 1232 "fqtoi $rs2, $rd", 1233 [(set FPRegs:$rd, (SPftoi QFPRegs:$rs2))]>, 1234 Requires<[HasHardQuad]>; 1235 1236// Convert between Floating-point Formats Instructions, p. 143 1237def FSTOD : F3_3u<2, 0b110100, 0b011001001, 1238 (outs DFPRegs:$rd), (ins FPRegs:$rs2), 1239 "fstod $rs2, $rd", 1240 [(set f64:$rd, (fpextend f32:$rs2))], 1241 IIC_fpu_stod>; 1242def FSTOQ : F3_3u<2, 0b110100, 0b011001101, 1243 (outs QFPRegs:$rd), (ins FPRegs:$rs2), 1244 "fstoq $rs2, $rd", 1245 [(set f128:$rd, (fpextend f32:$rs2))]>, 1246 Requires<[HasHardQuad]>; 1247def FDTOS : F3_3u<2, 0b110100, 0b011000110, 1248 (outs FPRegs:$rd), (ins DFPRegs:$rs2), 1249 "fdtos $rs2, $rd", 1250 [(set f32:$rd, (fpround f64:$rs2))], 1251 IIC_fpu_fast_instr>; 1252def FDTOQ : F3_3u<2, 0b110100, 0b011001110, 1253 (outs QFPRegs:$rd), (ins DFPRegs:$rs2), 1254 "fdtoq $rs2, $rd", 1255 [(set f128:$rd, (fpextend f64:$rs2))]>, 1256 Requires<[HasHardQuad]>; 1257def FQTOS : F3_3u<2, 0b110100, 0b011000111, 1258 (outs FPRegs:$rd), (ins QFPRegs:$rs2), 1259 "fqtos $rs2, $rd", 1260 [(set f32:$rd, (fpround f128:$rs2))]>, 1261 Requires<[HasHardQuad]>; 1262def FQTOD : F3_3u<2, 0b110100, 0b011001011, 1263 (outs DFPRegs:$rd), (ins QFPRegs:$rs2), 1264 "fqtod $rs2, $rd", 1265 [(set f64:$rd, (fpround f128:$rs2))]>, 1266 Requires<[HasHardQuad]>; 1267 1268// Floating-point Move Instructions, p. 144 1269def FMOVS : F3_3u<2, 0b110100, 0b000000001, 1270 (outs FPRegs:$rd), (ins FPRegs:$rs2), 1271 "fmovs $rs2, $rd", []>; 1272def FNEGS : F3_3u<2, 0b110100, 0b000000101, 1273 (outs FPRegs:$rd), (ins FPRegs:$rs2), 1274 "fnegs $rs2, $rd", 1275 [(set f32:$rd, (fneg f32:$rs2))], 1276 IIC_fpu_negs>; 1277def FABSS : F3_3u<2, 0b110100, 0b000001001, 1278 (outs FPRegs:$rd), (ins FPRegs:$rs2), 1279 "fabss $rs2, $rd", 1280 [(set f32:$rd, (fabs f32:$rs2))], 1281 IIC_fpu_abs>; 1282 1283 1284// Floating-point Square Root Instructions, p.145 1285// FSQRTS generates an erratum on LEON processors, so by disabling this instruction 1286// this will be promoted to use FSQRTD with doubles instead. 1287let Predicates = [HasNoFdivSqrtFix] in 1288def FSQRTS : F3_3u<2, 0b110100, 0b000101001, 1289 (outs FPRegs:$rd), (ins FPRegs:$rs2), 1290 "fsqrts $rs2, $rd", 1291 [(set f32:$rd, (fsqrt f32:$rs2))], 1292 IIC_fpu_sqrts>; 1293def FSQRTD : F3_3u<2, 0b110100, 0b000101010, 1294 (outs DFPRegs:$rd), (ins DFPRegs:$rs2), 1295 "fsqrtd $rs2, $rd", 1296 [(set f64:$rd, (fsqrt f64:$rs2))], 1297 IIC_fpu_sqrtd>; 1298def FSQRTQ : F3_3u<2, 0b110100, 0b000101011, 1299 (outs QFPRegs:$rd), (ins QFPRegs:$rs2), 1300 "fsqrtq $rs2, $rd", 1301 [(set f128:$rd, (fsqrt f128:$rs2))]>, 1302 Requires<[HasHardQuad]>; 1303 1304 1305 1306// Floating-point Add and Subtract Instructions, p. 146 1307def FADDS : F3_3<2, 0b110100, 0b001000001, 1308 (outs FPRegs:$rd), (ins FPRegs:$rs1, FPRegs:$rs2), 1309 "fadds $rs1, $rs2, $rd", 1310 [(set f32:$rd, (fadd f32:$rs1, f32:$rs2))], 1311 IIC_fpu_fast_instr>; 1312def FADDD : F3_3<2, 0b110100, 0b001000010, 1313 (outs DFPRegs:$rd), (ins DFPRegs:$rs1, DFPRegs:$rs2), 1314 "faddd $rs1, $rs2, $rd", 1315 [(set f64:$rd, (fadd f64:$rs1, f64:$rs2))], 1316 IIC_fpu_fast_instr>; 1317def FADDQ : F3_3<2, 0b110100, 0b001000011, 1318 (outs QFPRegs:$rd), (ins QFPRegs:$rs1, QFPRegs:$rs2), 1319 "faddq $rs1, $rs2, $rd", 1320 [(set f128:$rd, (fadd f128:$rs1, f128:$rs2))]>, 1321 Requires<[HasHardQuad]>; 1322 1323def FSUBS : F3_3<2, 0b110100, 0b001000101, 1324 (outs FPRegs:$rd), (ins FPRegs:$rs1, FPRegs:$rs2), 1325 "fsubs $rs1, $rs2, $rd", 1326 [(set f32:$rd, (fsub f32:$rs1, f32:$rs2))], 1327 IIC_fpu_fast_instr>; 1328def FSUBD : F3_3<2, 0b110100, 0b001000110, 1329 (outs DFPRegs:$rd), (ins DFPRegs:$rs1, DFPRegs:$rs2), 1330 "fsubd $rs1, $rs2, $rd", 1331 [(set f64:$rd, (fsub f64:$rs1, f64:$rs2))], 1332 IIC_fpu_fast_instr>; 1333def FSUBQ : F3_3<2, 0b110100, 0b001000111, 1334 (outs QFPRegs:$rd), (ins QFPRegs:$rs1, QFPRegs:$rs2), 1335 "fsubq $rs1, $rs2, $rd", 1336 [(set f128:$rd, (fsub f128:$rs1, f128:$rs2))]>, 1337 Requires<[HasHardQuad]>; 1338 1339 1340// Floating-point Multiply and Divide Instructions, p. 147 1341def FMULS : F3_3<2, 0b110100, 0b001001001, 1342 (outs FPRegs:$rd), (ins FPRegs:$rs1, FPRegs:$rs2), 1343 "fmuls $rs1, $rs2, $rd", 1344 [(set f32:$rd, (fmul f32:$rs1, f32:$rs2))], 1345 IIC_fpu_muls>, 1346 Requires<[HasFMULS]>; 1347def FMULD : F3_3<2, 0b110100, 0b001001010, 1348 (outs DFPRegs:$rd), (ins DFPRegs:$rs1, DFPRegs:$rs2), 1349 "fmuld $rs1, $rs2, $rd", 1350 [(set f64:$rd, (fmul f64:$rs1, f64:$rs2))], 1351 IIC_fpu_muld>; 1352def FMULQ : F3_3<2, 0b110100, 0b001001011, 1353 (outs QFPRegs:$rd), (ins QFPRegs:$rs1, QFPRegs:$rs2), 1354 "fmulq $rs1, $rs2, $rd", 1355 [(set f128:$rd, (fmul f128:$rs1, f128:$rs2))]>, 1356 Requires<[HasHardQuad]>; 1357 1358def FSMULD : F3_3<2, 0b110100, 0b001101001, 1359 (outs DFPRegs:$rd), (ins FPRegs:$rs1, FPRegs:$rs2), 1360 "fsmuld $rs1, $rs2, $rd", 1361 [(set f64:$rd, (fmul (fpextend f32:$rs1), 1362 (fpextend f32:$rs2)))], 1363 IIC_fpu_muld>, 1364 Requires<[HasFSMULD]>; 1365def FDMULQ : F3_3<2, 0b110100, 0b001101110, 1366 (outs QFPRegs:$rd), (ins DFPRegs:$rs1, DFPRegs:$rs2), 1367 "fdmulq $rs1, $rs2, $rd", 1368 [(set f128:$rd, (fmul (fpextend f64:$rs1), 1369 (fpextend f64:$rs2)))]>, 1370 Requires<[HasHardQuad]>; 1371 1372// FDIVS generates an erratum on LEON processors, so by disabling this instruction 1373// this will be promoted to use FDIVD with doubles instead. 1374def FDIVS : F3_3<2, 0b110100, 0b001001101, 1375 (outs FPRegs:$rd), (ins FPRegs:$rs1, FPRegs:$rs2), 1376 "fdivs $rs1, $rs2, $rd", 1377 [(set f32:$rd, (fdiv f32:$rs1, f32:$rs2))], 1378 IIC_fpu_divs>; 1379def FDIVD : F3_3<2, 0b110100, 0b001001110, 1380 (outs DFPRegs:$rd), (ins DFPRegs:$rs1, DFPRegs:$rs2), 1381 "fdivd $rs1, $rs2, $rd", 1382 [(set f64:$rd, (fdiv f64:$rs1, f64:$rs2))], 1383 IIC_fpu_divd>; 1384def FDIVQ : F3_3<2, 0b110100, 0b001001111, 1385 (outs QFPRegs:$rd), (ins QFPRegs:$rs1, QFPRegs:$rs2), 1386 "fdivq $rs1, $rs2, $rd", 1387 [(set f128:$rd, (fdiv f128:$rs1, f128:$rs2))]>, 1388 Requires<[HasHardQuad]>; 1389 1390// Floating-point Compare Instructions, p. 148 1391// Note: the 2nd template arg is different for these guys. 1392// Note 2: the result of a FCMP is not available until the 2nd cycle 1393// after the instr is retired, but there is no interlock in Sparc V8. 1394// This behavior is modeled with a forced noop after the instruction in 1395// DelaySlotFiller. 1396 1397let Defs = [FCC0], rd = 0, isCodeGenOnly = 1 in { 1398 def FCMPS : F3_3c<2, 0b110101, 0b001010001, 1399 (outs), (ins FPRegs:$rs1, FPRegs:$rs2), 1400 "fcmps $rs1, $rs2", 1401 [(SPcmpfcc f32:$rs1, f32:$rs2)], 1402 IIC_fpu_fast_instr>; 1403 def FCMPD : F3_3c<2, 0b110101, 0b001010010, 1404 (outs), (ins DFPRegs:$rs1, DFPRegs:$rs2), 1405 "fcmpd $rs1, $rs2", 1406 [(SPcmpfcc f64:$rs1, f64:$rs2)], 1407 IIC_fpu_fast_instr>; 1408 def FCMPQ : F3_3c<2, 0b110101, 0b001010011, 1409 (outs), (ins QFPRegs:$rs1, QFPRegs:$rs2), 1410 "fcmpq $rs1, $rs2", 1411 [(SPcmpfcc f128:$rs1, f128:$rs2)]>, 1412 Requires<[HasHardQuad]>; 1413} 1414 1415// A.13 Floating-Point Compare (SPARC v9) 1416// Note that these always write to %fcc0 instead of having its destination 1417// allocated automatically. 1418// This avoids complications with the scheduler sometimes wanting to spill 1419// the contents of an FCC, since SPARC v9 doesn't have facilities to spill 1420// an individual FCC. 1421 1422let Predicates = [HasV9], Defs = [FCC0], rd = 0, isCodeGenOnly = 1 in { 1423 def FCMPS_V9 : F3_3c<2, 0b110101, 0b001010001, 1424 (outs), (ins FPRegs:$rs1, FPRegs:$rs2), 1425 "fcmps %fcc0, $rs1, $rs2", 1426 [(SPcmpfccv9 f32:$rs1, f32:$rs2)], 1427 IIC_fpu_fast_instr>; 1428 def FCMPD_V9 : F3_3c<2, 0b110101, 0b001010010, 1429 (outs), (ins DFPRegs:$rs1, DFPRegs:$rs2), 1430 "fcmpd %fcc0, $rs1, $rs2", 1431 [(SPcmpfccv9 f64:$rs1, f64:$rs2)], 1432 IIC_fpu_fast_instr>; 1433 def FCMPQ_V9 : F3_3c<2, 0b110101, 0b001010011, 1434 (outs), (ins QFPRegs:$rs1, QFPRegs:$rs2), 1435 "fcmpq %fcc0, $rs1, $rs2", 1436 [(SPcmpfccv9 f128:$rs1, f128:$rs2)]>, 1437 Requires<[HasHardQuad]>; 1438} 1439 1440//===----------------------------------------------------------------------===// 1441// Instructions for Thread Local Storage(TLS). 1442//===----------------------------------------------------------------------===// 1443let isAsmParserOnly = 1 in { 1444def TLS_ADDrr : F3_1<2, 0b000000, 1445 (outs IntRegs:$rd), 1446 (ins IntRegs:$rs1, IntRegs:$rs2, TailRelocSymTLSAdd:$sym), 1447 "add $rs1, $rs2, $rd, $sym", 1448 [(set i32:$rd, 1449 (tlsadd i32:$rs1, i32:$rs2, tglobaltlsaddr:$sym))]>; 1450 1451let mayLoad = 1 in { 1452 def TLS_LDrr : F3_1<3, 0b000000, 1453 (outs IntRegs:$rd), 1454 (ins (MEMrr $rs1, $rs2):$addr, TailRelocSymTLSLoad:$sym), 1455 "ld [$addr], $rd, $sym", 1456 [(set i32:$rd, 1457 (tlsld ADDRrr:$addr, tglobaltlsaddr:$sym))]>; 1458} 1459 1460let Uses = [O6], isCall = 1, hasDelaySlot = 1 in 1461 def TLS_CALL : InstSP<(outs), 1462 (ins calltarget:$disp, TailRelocSymTLSCall:$sym, 1463 variable_ops), 1464 "call $disp, $sym", 1465 [(tlscall texternalsym:$disp, tglobaltlsaddr:$sym)], 1466 IIC_jmp_or_call> { 1467 bits<30> disp; 1468 let op = 1; 1469 let Inst{29-0} = disp; 1470} 1471} 1472 1473//===----------------------------------------------------------------------===// 1474// Instructions for tail calls. 1475//===----------------------------------------------------------------------===// 1476let isCodeGenOnly = 1, isReturn = 1, hasDelaySlot = 1, 1477 isTerminator = 1, isBarrier = 1 in { 1478 def TAIL_CALL : InstSP<(outs), (ins calltarget:$disp, variable_ops), 1479 "call $disp", 1480 [(tailcall tglobaladdr:$disp)]> { 1481 bits<30> disp; 1482 let op = 1; 1483 let Inst{29-0} = disp; 1484 } 1485} 1486 1487def : Pat<(tailcall (iPTR texternalsym:$dst)), 1488 (TAIL_CALL texternalsym:$dst)>; 1489 1490let isCodeGenOnly = 1, isReturn = 1, hasDelaySlot = 1, isTerminator = 1, 1491 isBarrier = 1, rd = 0 in { 1492 def TAIL_CALLri : F3_2<2, 0b111000, 1493 (outs), (ins (MEMri $rs1, $simm13):$addr, variable_ops), 1494 "jmp $addr", 1495 [(tailcall ADDRri:$addr)]>; 1496} 1497 1498//===----------------------------------------------------------------------===// 1499// V9 Instructions 1500//===----------------------------------------------------------------------===// 1501 1502// V9 Conditional Moves. 1503let Predicates = [HasV9], Constraints = "$f = $rd" in { 1504 // Move Integer Register on Condition (MOVcc) p. 194 of the V9 manual. 1505 let Uses = [ICC], intcc = 1, cc = 0b00 in { 1506 def MOVICCrr 1507 : F4_1<0b101100, (outs IntRegs:$rd), 1508 (ins IntRegs:$rs2, IntRegs:$f, CCOp:$cond), 1509 "mov$cond %icc, $rs2, $rd", 1510 [(set i32:$rd, (SPselecticc i32:$rs2, i32:$f, imm:$cond))]>; 1511 1512 def MOVICCri 1513 : F4_2<0b101100, (outs IntRegs:$rd), 1514 (ins i32imm:$simm11, IntRegs:$f, CCOp:$cond), 1515 "mov$cond %icc, $simm11, $rd", 1516 [(set i32:$rd, 1517 (SPselecticc simm11:$simm11, i32:$f, imm:$cond))]>; 1518 } 1519 1520 let Uses = [FCC0], intcc = 0, cc = 0b00 in { 1521 def MOVFCCrr 1522 : F4_1<0b101100, (outs IntRegs:$rd), 1523 (ins IntRegs:$rs2, IntRegs:$f, CCOp:$cond), 1524 "mov$cond %fcc0, $rs2, $rd", 1525 [(set i32:$rd, (SPselectfcc i32:$rs2, i32:$f, imm:$cond))]>; 1526 def MOVFCCri 1527 : F4_2<0b101100, (outs IntRegs:$rd), 1528 (ins i32imm:$simm11, IntRegs:$f, CCOp:$cond), 1529 "mov$cond %fcc0, $simm11, $rd", 1530 [(set i32:$rd, 1531 (SPselectfcc simm11:$simm11, i32:$f, imm:$cond))]>; 1532 } 1533 1534 let Uses = [ICC], intcc = 1, opf_cc = 0b00 in { 1535 def FMOVS_ICC 1536 : F4_3<0b110101, 0b000001, (outs FPRegs:$rd), 1537 (ins FPRegs:$rs2, FPRegs:$f, CCOp:$cond), 1538 "fmovs$cond %icc, $rs2, $rd", 1539 [(set f32:$rd, (SPselecticc f32:$rs2, f32:$f, imm:$cond))]>; 1540 def FMOVD_ICC 1541 : F4_3<0b110101, 0b000010, (outs DFPRegs:$rd), 1542 (ins DFPRegs:$rs2, DFPRegs:$f, CCOp:$cond), 1543 "fmovd$cond %icc, $rs2, $rd", 1544 [(set f64:$rd, (SPselecticc f64:$rs2, f64:$f, imm:$cond))]>; 1545 let Predicates = [HasV9, HasHardQuad] in 1546 def FMOVQ_ICC 1547 : F4_3<0b110101, 0b000011, (outs QFPRegs:$rd), 1548 (ins QFPRegs:$rs2, QFPRegs:$f, CCOp:$cond), 1549 "fmovq$cond %icc, $rs2, $rd", 1550 [(set f128:$rd, (SPselecticc f128:$rs2, f128:$f, imm:$cond))]>; 1551 } 1552 1553 let Uses = [FCC0], intcc = 0, opf_cc = 0b00 in { 1554 def FMOVS_FCC 1555 : F4_3<0b110101, 0b000001, (outs FPRegs:$rd), 1556 (ins FPRegs:$rs2, FPRegs:$f, CCOp:$cond), 1557 "fmovs$cond %fcc0, $rs2, $rd", 1558 [(set f32:$rd, (SPselectfcc f32:$rs2, f32:$f, imm:$cond))]>; 1559 def FMOVD_FCC 1560 : F4_3<0b110101, 0b000010, (outs DFPRegs:$rd), 1561 (ins DFPRegs:$rs2, DFPRegs:$f, CCOp:$cond), 1562 "fmovd$cond %fcc0, $rs2, $rd", 1563 [(set f64:$rd, (SPselectfcc f64:$rs2, f64:$f, imm:$cond))]>; 1564 let Predicates = [HasV9, HasHardQuad] in 1565 def FMOVQ_FCC 1566 : F4_3<0b110101, 0b000011, (outs QFPRegs:$rd), 1567 (ins QFPRegs:$rs2, QFPRegs:$f, CCOp:$cond), 1568 "fmovq$cond %fcc0, $rs2, $rd", 1569 [(set f128:$rd, (SPselectfcc f128:$rs2, f128:$f, imm:$cond))]>; 1570 } 1571 1572} 1573 1574// Floating-Point Move Instructions, p. 164 of the V9 manual. 1575let Predicates = [HasV9] in { 1576 def FMOVD : F3_3u<2, 0b110100, 0b000000010, 1577 (outs DFPRegs:$rd), (ins DFPRegs:$rs2), 1578 "fmovd $rs2, $rd", []>; 1579 let Predicates = [HasV9, HasHardQuad] in 1580 def FMOVQ : F3_3u<2, 0b110100, 0b000000011, 1581 (outs QFPRegs:$rd), (ins QFPRegs:$rs2), 1582 "fmovq $rs2, $rd", []>; 1583 def FNEGD : F3_3u<2, 0b110100, 0b000000110, 1584 (outs DFPRegs:$rd), (ins DFPRegs:$rs2), 1585 "fnegd $rs2, $rd", 1586 [(set f64:$rd, (fneg f64:$rs2))]>; 1587 let Predicates = [HasV9, HasHardQuad] in 1588 def FNEGQ : F3_3u<2, 0b110100, 0b000000111, 1589 (outs QFPRegs:$rd), (ins QFPRegs:$rs2), 1590 "fnegq $rs2, $rd", 1591 [(set f128:$rd, (fneg f128:$rs2))]>; 1592 def FABSD : F3_3u<2, 0b110100, 0b000001010, 1593 (outs DFPRegs:$rd), (ins DFPRegs:$rs2), 1594 "fabsd $rs2, $rd", 1595 [(set f64:$rd, (fabs f64:$rs2))]>; 1596 let Predicates = [HasV9, HasHardQuad] in 1597 def FABSQ : F3_3u<2, 0b110100, 0b000001011, 1598 (outs QFPRegs:$rd), (ins QFPRegs:$rs2), 1599 "fabsq $rs2, $rd", 1600 [(set f128:$rd, (fabs f128:$rs2))]>; 1601} 1602 1603// Floating-point compare instruction with %fcc0-%fcc3. 1604def V9FCMPS : F3_3c<2, 0b110101, 0b001010001, 1605 (outs FCCRegs:$rd), (ins FPRegs:$rs1, FPRegs:$rs2), 1606 "fcmps $rd, $rs1, $rs2", []>; 1607def V9FCMPD : F3_3c<2, 0b110101, 0b001010010, 1608 (outs FCCRegs:$rd), (ins DFPRegs:$rs1, DFPRegs:$rs2), 1609 "fcmpd $rd, $rs1, $rs2", []>; 1610def V9FCMPQ : F3_3c<2, 0b110101, 0b001010011, 1611 (outs FCCRegs:$rd), (ins QFPRegs:$rs1, QFPRegs:$rs2), 1612 "fcmpq $rd, $rs1, $rs2", []>, 1613 Requires<[HasHardQuad]>; 1614 1615let hasSideEffects = 1 in { 1616 def V9FCMPES : F3_3c<2, 0b110101, 0b001010101, 1617 (outs FCCRegs:$rd), (ins FPRegs:$rs1, FPRegs:$rs2), 1618 "fcmpes $rd, $rs1, $rs2", []>; 1619 def V9FCMPED : F3_3c<2, 0b110101, 0b001010110, 1620 (outs FCCRegs:$rd), (ins DFPRegs:$rs1, DFPRegs:$rs2), 1621 "fcmped $rd, $rs1, $rs2", []>; 1622 def V9FCMPEQ : F3_3c<2, 0b110101, 0b001010111, 1623 (outs FCCRegs:$rd), (ins QFPRegs:$rs1, QFPRegs:$rs2), 1624 "fcmpeq $rd, $rs1, $rs2", []>, 1625 Requires<[HasHardQuad]>; 1626} 1627 1628// Floating point conditional move instrucitons with %fcc0-%fcc3. 1629let Predicates = [HasV9] in { 1630 let Constraints = "$f = $rd", intcc = 0 in { 1631 def V9MOVFCCrr 1632 : F4_1<0b101100, (outs IntRegs:$rd), 1633 (ins FCCRegs:$cc, IntRegs:$rs2, IntRegs:$f, CCOp:$cond), 1634 "mov$cond $cc, $rs2, $rd", []>; 1635 def V9MOVFCCri 1636 : F4_2<0b101100, (outs IntRegs:$rd), 1637 (ins FCCRegs:$cc, i32imm:$simm11, IntRegs:$f, CCOp:$cond), 1638 "mov$cond $cc, $simm11, $rd", []>; 1639 def V9FMOVS_FCC 1640 : F4_3<0b110101, 0b000001, (outs FPRegs:$rd), 1641 (ins FCCRegs:$opf_cc, FPRegs:$rs2, FPRegs:$f, CCOp:$cond), 1642 "fmovs$cond $opf_cc, $rs2, $rd", []>; 1643 def V9FMOVD_FCC 1644 : F4_3<0b110101, 0b000010, (outs DFPRegs:$rd), 1645 (ins FCCRegs:$opf_cc, DFPRegs:$rs2, DFPRegs:$f, CCOp:$cond), 1646 "fmovd$cond $opf_cc, $rs2, $rd", []>; 1647 let Predicates = [HasV9, HasHardQuad] in 1648 def V9FMOVQ_FCC 1649 : F4_3<0b110101, 0b000011, (outs QFPRegs:$rd), 1650 (ins FCCRegs:$opf_cc, QFPRegs:$rs2, QFPRegs:$f, CCOp:$cond), 1651 "fmovq$cond $opf_cc, $rs2, $rd", []>; 1652 } // Constraints = "$f = $rd", ... 1653} // let Predicates = [hasV9] 1654 1655 1656// POPCrr - This does a ctpop of a 64-bit register. As such, we have to clear 1657// the top 32-bits before using it. To do this clearing, we use a SRLri X,0. 1658let rs1 = 0 in 1659 def POPCrr : F3_1<2, 0b101110, 1660 (outs IntRegs:$rd), (ins IntRegs:$rs2), 1661 "popc $rs2, $rd", []>, Requires<[HasV9]>; 1662def : Pat<(i32 (ctpop i32:$src)), 1663 (POPCrr (SRLri $src, 0))>; 1664 1665let Predicates = [HasV9], hasSideEffects = 1, rd = 0, rs1 = 0b01111 in 1666 def MEMBARi : F3_2<2, 0b101000, (outs), (ins MembarTag:$simm13), 1667 "membar $simm13", []>; 1668 1669let Predicates = [HasV9], rd = 15, rs1 = 0b00000 in 1670 def SIR: F3_2<2, 0b110000, (outs), 1671 (ins simm13Op:$simm13), 1672 "sir $simm13", []>; 1673 1674// The CAS instruction, unlike other instructions, only comes in a 1675// form which requires an ASI be provided. The ASI value hardcoded 1676// here is ASI_PRIMARY, the default unprivileged ASI for SparcV9. 1677let Predicates = [HasV9], Constraints = "$swap = $rd", asi = 0b10000000 in 1678 def CASrr: F3_1_asi<3, 0b111100, 1679 (outs IntRegs:$rd), (ins IntRegs:$rs1, IntRegs:$rs2, 1680 IntRegs:$swap), 1681 "cas [$rs1], $rs2, $rd", 1682 [(set i32:$rd, 1683 (atomic_cmp_swap_32 iPTR:$rs1, i32:$rs2, i32:$swap))]>; 1684 1685 1686// CASA is supported as an instruction on some LEON3 and all LEON4 processors. 1687// This version can be automatically lowered from C code, selecting ASI 10 1688let Predicates = [HasLeonCASA], Constraints = "$swap = $rd", asi = 0b00001010 in 1689 def CASAasi10: F3_1_asi<3, 0b111100, 1690 (outs IntRegs:$rd), (ins IntRegs:$rs1, IntRegs:$rs2, 1691 IntRegs:$swap), 1692 "casa [$rs1] 10, $rs2, $rd", 1693 [(set i32:$rd, 1694 (atomic_cmp_swap_32 iPTR:$rs1, i32:$rs2, i32:$swap))]>; 1695 1696// CASA supported on some LEON3 and all LEON4 processors. Same pattern as 1697// CASrr, above, but with a different ASI. This version is supported for 1698// inline assembly lowering only. 1699let Predicates = [HasLeonCASA], Constraints = "$swap = $rd" in 1700 def CASArr: F3_1_asi<3, 0b111100, 1701 (outs IntRegs:$rd), (ins IntRegs:$rs1, IntRegs:$rs2, 1702 IntRegs:$swap, i8imm:$asi), 1703 "casa [$rs1] $asi, $rs2, $rd", []>; 1704 1705// TODO: Add DAG sequence to lower these instructions. Currently, only provided 1706// as inline assembler-supported instructions. 1707let Predicates = [HasUMAC_SMAC], Defs = [Y, ASR18], Uses = [Y, ASR18] in { 1708 def SMACrr : F3_1<2, 0b111111, 1709 (outs IntRegs:$rd), (ins IntRegs:$rs1, IntRegs:$rs2, ASRRegs:$asr18), 1710 "smac $rs1, $rs2, $rd", 1711 [], IIC_smac_umac>; 1712 1713 def SMACri : F3_2<2, 0b111111, 1714 (outs IntRegs:$rd), (ins IntRegs:$rs1, simm13Op:$simm13, ASRRegs:$asr18), 1715 "smac $rs1, $simm13, $rd", 1716 [], IIC_smac_umac>; 1717 1718 def UMACrr : F3_1<2, 0b111110, 1719 (outs IntRegs:$rd), (ins IntRegs:$rs1, IntRegs:$rs2, ASRRegs:$asr18), 1720 "umac $rs1, $rs2, $rd", 1721 [], IIC_smac_umac>; 1722 1723 def UMACri : F3_2<2, 0b111110, 1724 (outs IntRegs:$rd), (ins IntRegs:$rs1, simm13Op:$simm13, ASRRegs:$asr18), 1725 "umac $rs1, $simm13, $rd", 1726 [], IIC_smac_umac>; 1727} 1728 1729// The partial write WRPSR instruction has a non-zero destination 1730// register value to separate it from the standard instruction. 1731let Predicates = [HasPWRPSR], Defs = [PSR], rd=1 in { 1732 def PWRPSRrr : F3_1<2, 0b110001, 1733 (outs), (ins IntRegs:$rs1, IntRegs:$rs2), 1734 "pwr $rs1, $rs2, %psr", []>; 1735 def PWRPSRri : F3_2<2, 0b110001, 1736 (outs), (ins IntRegs:$rs1, simm13Op:$simm13), 1737 "pwr $rs1, $simm13, %psr", []>; 1738} 1739 1740let Defs = [ICC] in { 1741defm TADDCC : F3_12np<"taddcc", 0b100000>; 1742defm TSUBCC : F3_12np<"tsubcc", 0b100001>; 1743 1744let hasSideEffects = 1 in { 1745 defm TADDCCTV : F3_12np<"taddcctv", 0b100010>; 1746 defm TSUBCCTV : F3_12np<"tsubcctv", 0b100011>; 1747} 1748} 1749 1750// Section A.42 - Prefetch Data 1751let Predicates = [HasV9] in { 1752 def PREFETCHr : F3_1<3, 0b101101, 1753 (outs), (ins (MEMrr $rs1, $rs2):$addr, shift_imm5:$rd), 1754 "prefetch [$addr], $rd", []>; 1755 def PREFETCHi : F3_2<3, 0b101101, 1756 (outs), (ins (MEMri $rs1, $simm13):$addr, shift_imm5:$rd), 1757 "prefetch [$addr], $rd", []>; 1758} 1759 1760 1761 1762// Section A.43 - Read Privileged Register Instructions 1763let Predicates = [HasV9] in { 1764let rs2 = 0 in 1765 def RDPR : F3_1<2, 0b101010, 1766 (outs IntRegs:$rd), (ins PRRegs:$rs1), 1767 "rdpr $rs1, $rd", []>; 1768} 1769 1770// Section A.62 - Write Privileged Register Instructions 1771let Predicates = [HasV9] in { 1772 def WRPRrr : F3_1<2, 0b110010, 1773 (outs PRRegs:$rd), (ins IntRegs:$rs1, IntRegs:$rs2), 1774 "wrpr $rs1, $rs2, $rd", []>; 1775 def WRPRri : F3_2<2, 0b110010, 1776 (outs PRRegs:$rd), (ins IntRegs:$rs1, simm13Op:$simm13), 1777 "wrpr $rs1, $simm13, $rd", []>; 1778} 1779 1780//===----------------------------------------------------------------------===// 1781// Non-Instruction Patterns 1782//===----------------------------------------------------------------------===// 1783 1784// Zero immediate. 1785def : Pat<(i32 0), (COPY (i32 G0))>; 1786// Small immediates. 1787def : Pat<(i32 simm13:$val), 1788 (ORri (i32 G0), imm:$val)>; 1789// Arbitrary immediates. 1790def : Pat<(i32 imm:$val), 1791 (ORri (SETHIi (HI22 imm:$val)), (LO10 imm:$val))>; 1792 1793 1794// Global addresses, constant pool entries 1795let Predicates = [Is32Bit] in { 1796 1797def : Pat<(SPhi tglobaladdr:$in), (SETHIi tglobaladdr:$in)>; 1798def : Pat<(SPlo tglobaladdr:$in), (ORri (i32 G0), tglobaladdr:$in)>; 1799def : Pat<(SPhi tconstpool:$in), (SETHIi tconstpool:$in)>; 1800def : Pat<(SPlo tconstpool:$in), (ORri (i32 G0), tconstpool:$in)>; 1801 1802// GlobalTLS addresses 1803def : Pat<(SPhi tglobaltlsaddr:$in), (SETHIi tglobaltlsaddr:$in)>; 1804def : Pat<(SPlo tglobaltlsaddr:$in), (ORri (i32 G0), tglobaltlsaddr:$in)>; 1805def : Pat<(add (SPhi tglobaltlsaddr:$in1), (SPlo tglobaltlsaddr:$in2)), 1806 (ADDri (SETHIi tglobaltlsaddr:$in1), (tglobaltlsaddr:$in2))>; 1807def : Pat<(xor (SPhi tglobaltlsaddr:$in1), (SPlo tglobaltlsaddr:$in2)), 1808 (XORri (SETHIi tglobaltlsaddr:$in1), (tglobaltlsaddr:$in2))>; 1809 1810// Blockaddress 1811def : Pat<(SPhi tblockaddress:$in), (SETHIi tblockaddress:$in)>; 1812def : Pat<(SPlo tblockaddress:$in), (ORri (i32 G0), tblockaddress:$in)>; 1813 1814// Add reg, lo. This is used when taking the addr of a global/constpool entry. 1815def : Pat<(add iPTR:$r, (SPlo tglobaladdr:$in)), (ADDri $r, tglobaladdr:$in)>; 1816def : Pat<(add iPTR:$r, (SPlo tconstpool:$in)), (ADDri $r, tconstpool:$in)>; 1817def : Pat<(add iPTR:$r, (SPlo tblockaddress:$in)), 1818 (ADDri $r, tblockaddress:$in)>; 1819} 1820 1821// Calls: 1822def : Pat<(call tglobaladdr:$dst), 1823 (CALL tglobaladdr:$dst)>; 1824def : Pat<(call texternalsym:$dst), 1825 (CALL texternalsym:$dst)>; 1826 1827// Map integer extload's to zextloads. 1828def : Pat<(i32 (extloadi1 ADDRrr:$src)), (LDUBrr ADDRrr:$src)>; 1829def : Pat<(i32 (extloadi1 ADDRri:$src)), (LDUBri ADDRri:$src)>; 1830def : Pat<(i32 (extloadi8 ADDRrr:$src)), (LDUBrr ADDRrr:$src)>; 1831def : Pat<(i32 (extloadi8 ADDRri:$src)), (LDUBri ADDRri:$src)>; 1832def : Pat<(i32 (extloadi16 ADDRrr:$src)), (LDUHrr ADDRrr:$src)>; 1833def : Pat<(i32 (extloadi16 ADDRri:$src)), (LDUHri ADDRri:$src)>; 1834 1835// zextload bool -> zextload byte 1836def : Pat<(i32 (zextloadi1 ADDRrr:$src)), (LDUBrr ADDRrr:$src)>; 1837def : Pat<(i32 (zextloadi1 ADDRri:$src)), (LDUBri ADDRri:$src)>; 1838 1839// store 0, addr -> store %g0, addr 1840def : Pat<(store (i32 0), ADDRrr:$dst), (STrr ADDRrr:$dst, (i32 G0))>; 1841def : Pat<(store (i32 0), ADDRri:$dst), (STri ADDRri:$dst, (i32 G0))>; 1842 1843// store bar for all atomic_fence in V8. 1844let Predicates = [HasNoV9] in 1845 def : Pat<(atomic_fence timm, timm), (STBAR)>; 1846 1847let Predicates = [HasV9] in 1848 def : Pat<(atomic_fence timm, timm), (MEMBARi 0xf)>; 1849 1850// atomic_load addr -> load addr 1851def : Pat<(i32 (atomic_load_8 ADDRrr:$src)), (LDUBrr ADDRrr:$src)>; 1852def : Pat<(i32 (atomic_load_8 ADDRri:$src)), (LDUBri ADDRri:$src)>; 1853def : Pat<(i32 (atomic_load_16 ADDRrr:$src)), (LDUHrr ADDRrr:$src)>; 1854def : Pat<(i32 (atomic_load_16 ADDRri:$src)), (LDUHri ADDRri:$src)>; 1855def : Pat<(i32 (atomic_load_32 ADDRrr:$src)), (LDrr ADDRrr:$src)>; 1856def : Pat<(i32 (atomic_load_32 ADDRri:$src)), (LDri ADDRri:$src)>; 1857 1858// atomic_store val, addr -> store val, addr 1859def : Pat<(atomic_store_8 ADDRrr:$dst, i32:$val), (STBrr ADDRrr:$dst, $val)>; 1860def : Pat<(atomic_store_8 ADDRri:$dst, i32:$val), (STBri ADDRri:$dst, $val)>; 1861def : Pat<(atomic_store_16 ADDRrr:$dst, i32:$val), (STHrr ADDRrr:$dst, $val)>; 1862def : Pat<(atomic_store_16 ADDRri:$dst, i32:$val), (STHri ADDRri:$dst, $val)>; 1863def : Pat<(atomic_store_32 ADDRrr:$dst, i32:$val), (STrr ADDRrr:$dst, $val)>; 1864def : Pat<(atomic_store_32 ADDRri:$dst, i32:$val), (STri ADDRri:$dst, $val)>; 1865 1866// A register pair with zero upper half. 1867// The upper part is done with ORrr instead of `COPY G0` 1868// or a normal register copy, since `COPY G0`s in that place 1869// will be converted into `COPY G0_G1` later on, which is not 1870// what we want in this case. 1871def : Pat<(build_vector (i32 0), (i32 IntRegs:$a2)), 1872 (INSERT_SUBREG (INSERT_SUBREG (v2i32 (IMPLICIT_DEF)), 1873 (ORrr (i32 G0), (i32 G0)), sub_even), 1874 (i32 IntRegs:$a2), sub_odd)>; 1875 1876// extract_vector 1877def : Pat<(extractelt (v2i32 IntPair:$Rn), 0), 1878 (i32 (EXTRACT_SUBREG IntPair:$Rn, sub_even))>; 1879def : Pat<(extractelt (v2i32 IntPair:$Rn), 1), 1880 (i32 (EXTRACT_SUBREG IntPair:$Rn, sub_odd))>; 1881 1882// build_vector 1883def : Pat<(build_vector (i32 IntRegs:$a1), (i32 IntRegs:$a2)), 1884 (INSERT_SUBREG 1885 (INSERT_SUBREG (v2i32 (IMPLICIT_DEF)), (i32 IntRegs:$a1), sub_even), 1886 (i32 IntRegs:$a2), sub_odd)>; 1887 1888 1889include "SparcInstr64Bit.td" 1890include "SparcInstrVIS.td" 1891include "SparcInstrAliases.td" 1892