1 //===-- SparcInstrInfo.td - Target Description for Sparc Target -----------===//
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
7 //===----------------------------------------------------------------------===//
9 // This file describes the Sparc instructions in TableGen format.
11 //===----------------------------------------------------------------------===//
13 //===----------------------------------------------------------------------===//
14 // Instruction format superclass
15 //===----------------------------------------------------------------------===//
17 include "SparcInstrFormats.td"
19 //===----------------------------------------------------------------------===//
20 // Feature predicates.
21 //===----------------------------------------------------------------------===//
23 // True when generating 32-bit code.
24 def Is32Bit : Predicate<"!Subtarget->is64Bit()">;
26 // True when generating 64-bit code. This also implies HasV9.
27 def Is64Bit : Predicate<"Subtarget->is64Bit()">;
29 def UseSoftMulDiv : Predicate<"Subtarget->useSoftMulDiv()">,
30 AssemblerPredicate<(all_of FeatureSoftMulDiv)>;
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.
34 def HasV9 : Predicate<"Subtarget->isV9()">,
35 AssemblerPredicate<(all_of FeatureV9)>;
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.
40 def HasNoV9 : Predicate<"!Subtarget->isV9()">;
42 // HasVIS - This is true when the target processor has VIS extensions.
43 def HasVIS : Predicate<"Subtarget->isVIS()">,
44 AssemblerPredicate<(all_of FeatureVIS)>;
45 def HasVIS2 : Predicate<"Subtarget->isVIS2()">,
46 AssemblerPredicate<(all_of FeatureVIS2)>;
47 def HasVIS3 : Predicate<"Subtarget->isVIS3()">,
48 AssemblerPredicate<(all_of FeatureVIS3)>;
50 // HasHardQuad - This is true when the target processor supports quad floating
51 // point instructions.
52 def HasHardQuad : Predicate<"Subtarget->hasHardQuad()">;
54 // HasLeonCASA - This is true when the target processor supports the Leon CASA
56 def HasLeonCASA : Predicate<"Subtarget->hasLeonCasa()">;
58 // HasCASA - This is true when the target processor supports CASA instruction.
59 def HasCASA : Predicate<"Subtarget->hasLeonCasa() || Subtarget->isV9()">,
60 AssemblerPredicate<(any_of LeonCASA, FeatureV9)>;
62 // HasPWRPSR - This is true when the target processor supports partial
63 // writes to the PSR register that only affects the ET field.
64 def HasPWRPSR : Predicate<"Subtarget->hasPWRPSR()">,
65 AssemblerPredicate<(all_of FeaturePWRPSR)>;
67 // HasUMAC_SMAC - This is true when the target processor supports the
68 // UMAC and SMAC instructions
69 def HasUMAC_SMAC : Predicate<"Subtarget->hasUmacSmac()">;
71 def HasNoFdivSqrtFix : Predicate<"!Subtarget->fixAllFDIVSQRT()">;
72 def HasFMULS : Predicate<"!Subtarget->hasNoFMULS()">;
73 def HasFSMULD : Predicate<"!Subtarget->hasNoFSMULD()">;
75 // UseDeprecatedInsts - This predicate is true when the target processor is a
76 // V8, or when it is V9 but the V8 deprecated instructions are efficient enough
77 // to use when appropriate. In either of these cases, the instruction selector
78 // will pick deprecated instructions.
79 def UseDeprecatedInsts : Predicate<"Subtarget->useV8DeprecatedInsts()">;
81 //===----------------------------------------------------------------------===//
82 // Instruction Pattern Stuff
83 //===----------------------------------------------------------------------===//
85 def simm10 : PatLeaf<(imm), [{ return isInt<10>(N->getSExtValue()); }]>;
87 def simm11 : PatLeaf<(imm), [{ return isInt<11>(N->getSExtValue()); }]>;
89 def simm13 : PatLeaf<(imm), [{ return isInt<13>(N->getSExtValue()); }]>;
91 def LO10 : SDNodeXForm<imm, [{
92 return CurDAG->getTargetConstant((unsigned)N->getZExtValue() & 1023, SDLoc(N),
96 def HI22 : SDNodeXForm<imm, [{
97 // Transformation function: shift the immediate value down into the low bits.
98 return CurDAG->getTargetConstant((unsigned)N->getZExtValue() >> 10, SDLoc(N),
102 // Return the complement of a HI22 immediate value.
103 def HI22_not : SDNodeXForm<imm, [{
104 return CurDAG->getTargetConstant(~(unsigned)N->getZExtValue() >> 10, SDLoc(N),
108 def SETHIimm : PatLeaf<(imm), [{
109 return isShiftedUInt<22, 10>(N->getZExtValue());
112 // The N->hasOneUse() prevents the immediate from being instantiated in both
113 // normal and complement form.
114 def SETHIimm_not : PatLeaf<(i32 imm), [{
115 return N->hasOneUse() && isShiftedUInt<22, 10>(~(unsigned)N->getZExtValue());
119 def ADDRrr : ComplexPattern<iPTR, 2, "SelectADDRrr", [], []>;
120 def ADDRri : ComplexPattern<iPTR, 2, "SelectADDRri", [], []>;
122 // Constrained operands for the shift operations.
123 class ShiftAmtImmAsmOperand<int Bits> : AsmOperandClass {
124 let Name = "ShiftAmtImm" # Bits;
125 let ParserMethod = "parseShiftAmtImm<" # Bits # ">";
127 def shift_imm5 : Operand<i32> {
128 let ParserMatchClass = ShiftAmtImmAsmOperand<5>;
130 def shift_imm6 : Operand<i32> {
131 let ParserMatchClass = ShiftAmtImmAsmOperand<6>;
135 def SparcMEMrrAsmOperand : AsmOperandClass {
137 let ParserMethod = "parseMEMOperand";
140 def SparcMEMriAsmOperand : AsmOperandClass {
142 let ParserMethod = "parseMEMOperand";
145 def MEMrr : Operand<iPTR> {
146 let PrintMethod = "printMemOperand";
147 let MIOperandInfo = (ops ptr_rc, ptr_rc);
148 let ParserMatchClass = SparcMEMrrAsmOperand;
150 def MEMri : Operand<iPTR> {
151 let PrintMethod = "printMemOperand";
152 let MIOperandInfo = (ops ptr_rc, i32imm);
153 let ParserMatchClass = SparcMEMriAsmOperand;
156 // Represents a tail relocation operand for instructions such as add, ld, call.
157 class SparcTailRelocSymAsmOperand<string Kind> : AsmOperandClass {
158 let Name = "TailRelocSym" # Kind;
159 let RenderMethod = "addTailRelocSymOperands";
160 let PredicateMethod = "isTailRelocSym";
161 let ParserMethod = "parseTailRelocSym<TailRelocKind::" # Kind # ">";
164 def TailRelocSymGOTLoad : Operand<iPTR> {
165 let ParserMatchClass = SparcTailRelocSymAsmOperand<"Load_GOT">;
168 def TailRelocSymTLSAdd : Operand<iPTR> {
169 let ParserMatchClass = SparcTailRelocSymAsmOperand<"Add_TLS">;
172 def TailRelocSymTLSLoad : Operand<iPTR> {
173 let ParserMatchClass = SparcTailRelocSymAsmOperand<"Load_TLS">;
176 def TailRelocSymTLSCall : Operand<iPTR> {
177 let ParserMatchClass = SparcTailRelocSymAsmOperand<"Call_TLS">;
180 def SparcMembarTagAsmOperand : AsmOperandClass {
181 let Name = "MembarTag";
182 let ParserMethod = "parseMembarTag";
185 def MembarTag : Operand<i32> {
186 let PrintMethod = "printMembarTag";
187 let ParserMatchClass = SparcMembarTagAsmOperand;
190 def SparcASITagAsmOperand : AsmOperandClass {
192 let ParserMethod = "parseASITag";
195 def ASITag : Operand<i32> {
196 let PrintMethod = "printASITag";
197 let ParserMatchClass = SparcASITagAsmOperand;
200 // Branch targets have OtherVT type.
201 def brtarget : Operand<OtherVT> {
202 let EncoderMethod = "getBranchTargetOpValue";
205 def bprtarget : Operand<OtherVT> {
206 let EncoderMethod = "getBranchPredTargetOpValue";
209 def bprtarget16 : Operand<OtherVT> {
210 let EncoderMethod = "getBranchOnRegTargetOpValue";
213 def SparcCallTargetAsmOperand : AsmOperandClass {
214 let Name = "CallTarget";
215 let ParserMethod = "parseCallTarget";
218 def calltarget : Operand<i32> {
219 let EncoderMethod = "getCallTargetOpValue";
220 let DecoderMethod = "DecodeCall";
221 let ParserMatchClass = SparcCallTargetAsmOperand;
224 def simm13Op : Operand<iPTR> {
225 let OperandType = "OPERAND_IMMEDIATE";
226 let DecoderMethod = "DecodeSIMM13";
227 let EncoderMethod = "getSImm13OpValue";
230 // Operand for printing out a condition code.
231 let PrintMethod = "printCCOperand" in {
232 def CCOp : Operand<i32>;
233 def RegCCOp : Operand<i32>;
237 SDTypeProfile<0, 2, [SDTCisInt<0>, SDTCisSameAs<0, 1>]>;
239 SDTypeProfile<0, 2, [SDTCisFP<0>, SDTCisSameAs<0, 1>]>;
241 SDTypeProfile<0, 2, [SDTCisVT<0, OtherVT>, SDTCisVT<1, i32>]>;
243 SDTypeProfile<0, 3, [SDTCisVT<0, OtherVT>, SDTCisVT<1, i32>, SDTCisVT<2, i64>]>;
245 SDTypeProfile<1, 3, [SDTCisSameAs<0, 1>, SDTCisSameAs<1, 2>, SDTCisVT<3, i32>]>;
247 SDTypeProfile<1, 4, [SDTCisSameAs<0, 1>, SDTCisSameAs<1, 2>, SDTCisVT<3, i32>, SDTCisVT<4, i64>]>;
249 SDTypeProfile<1, 1, [SDTCisVT<0, f32>, SDTCisFP<1>]>;
251 SDTypeProfile<1, 1, [SDTCisFP<0>, SDTCisVT<1, f32>]>;
253 SDTypeProfile<1, 1, [SDTCisVT<0, f64>, SDTCisFP<1>]>;
255 SDTypeProfile<1, 1, [SDTCisFP<0>, SDTCisVT<1, f64>]>;
258 SDTypeProfile<1, 3, [SDTCisInt<0>, SDTCisSameAs<0, 1>, SDTCisPtrTy<2>]>;
260 SDTypeProfile<1, 2, [SDTCisPtrTy<0>, SDTCisPtrTy<1>]>;
263 SDTypeProfile<1, 2, [SDTCisPtrTy<0>, SDTCisPtrTy<1>]>;
265 def SPcmpicc : SDNode<"SPISD::CMPICC", SDTSPcmpicc, [SDNPOutGlue]>;
266 def SPcmpfcc : SDNode<"SPISD::CMPFCC", SDTSPcmpfcc, [SDNPOutGlue]>;
267 def SPcmpfccv9 : SDNode<"SPISD::CMPFCC_V9", SDTSPcmpfcc, [SDNPOutGlue]>;
268 def SPbricc : SDNode<"SPISD::BRICC", SDTSPbrcc, [SDNPHasChain, SDNPInGlue]>;
269 def SPbpicc : SDNode<"SPISD::BPICC", SDTSPbrcc, [SDNPHasChain, SDNPInGlue]>;
270 def SPbpxcc : SDNode<"SPISD::BPXCC", SDTSPbrcc, [SDNPHasChain, SDNPInGlue]>;
271 def SPbrfcc : SDNode<"SPISD::BRFCC", SDTSPbrcc, [SDNPHasChain, SDNPInGlue]>;
272 def SPbrfccv9 : SDNode<"SPISD::BRFCC_V9", SDTSPbrcc, [SDNPHasChain, SDNPInGlue]>;
273 def SPbrreg : SDNode<"SPISD::BR_REG", SDTSPbrreg, [SDNPHasChain, SDNPInGlue]>;
275 def SPhi : SDNode<"SPISD::Hi", SDTIntUnaryOp>;
276 def SPlo : SDNode<"SPISD::Lo", SDTIntUnaryOp>;
278 def SPftoi : SDNode<"SPISD::FTOI", SDTSPFTOI>;
279 def SPitof : SDNode<"SPISD::ITOF", SDTSPITOF>;
280 def SPftox : SDNode<"SPISD::FTOX", SDTSPFTOX>;
281 def SPxtof : SDNode<"SPISD::XTOF", SDTSPXTOF>;
283 def SPselecticc : SDNode<"SPISD::SELECT_ICC", SDTSPselectcc, [SDNPInGlue]>;
284 def SPselectxcc : SDNode<"SPISD::SELECT_XCC", SDTSPselectcc, [SDNPInGlue]>;
285 def SPselectfcc : SDNode<"SPISD::SELECT_FCC", SDTSPselectcc, [SDNPInGlue]>;
286 def SPselectreg : SDNode<"SPISD::SELECT_REG", SDTSPselectreg, [SDNPInGlue]>;
288 // These are target-independent nodes, but have target-specific formats.
289 def SDT_SPCallSeqStart : SDCallSeqStart<[ SDTCisVT<0, i32>,
291 def SDT_SPCallSeqEnd : SDCallSeqEnd<[ SDTCisVT<0, i32>,
294 def callseq_start : SDNode<"ISD::CALLSEQ_START", SDT_SPCallSeqStart,
295 [SDNPHasChain, SDNPOutGlue]>;
296 def callseq_end : SDNode<"ISD::CALLSEQ_END", SDT_SPCallSeqEnd,
297 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue]>;
299 def SDT_SPCall : SDTypeProfile<0, -1, [SDTCisVT<0, i32>]>;
300 def call : SDNode<"SPISD::CALL", SDT_SPCall,
301 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
304 def tailcall : SDNode<"SPISD::TAIL_CALL", SDT_SPCall,
305 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
308 def SDT_SPRet : SDTypeProfile<0, 1, [SDTCisVT<0, i32>]>;
309 def retglue : SDNode<"SPISD::RET_GLUE", SDT_SPRet,
310 [SDNPHasChain, SDNPOptInGlue, SDNPVariadic]>;
312 def flushw : SDNode<"SPISD::FLUSHW", SDTNone,
313 [SDNPHasChain, SDNPSideEffect, SDNPMayStore]>;
315 def tlsadd : SDNode<"SPISD::TLS_ADD", SDTSPtlsadd>;
316 def tlsld : SDNode<"SPISD::TLS_LD", SDTSPtlsld>;
317 def tlscall : SDNode<"SPISD::TLS_CALL", SDT_SPCall,
318 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
321 def load_gdop : SDNode<"SPISD::LOAD_GDOP", SDTSPloadgdop>;
323 def getPCX : Operand<iPTR> {
324 let PrintMethod = "printGetPCX";
327 //===----------------------------------------------------------------------===//
328 // SPARC Flag Conditions
329 //===----------------------------------------------------------------------===//
331 // Note that these values must be kept in sync with the CCOp::CondCode enum
333 class ICC_VAL<int N> : PatLeaf<(i32 N)>;
334 def ICC_NE : ICC_VAL< 9>; // Not Equal
335 def ICC_E : ICC_VAL< 1>; // Equal
336 def ICC_G : ICC_VAL<10>; // Greater
337 def ICC_LE : ICC_VAL< 2>; // Less or Equal
338 def ICC_GE : ICC_VAL<11>; // Greater or Equal
339 def ICC_L : ICC_VAL< 3>; // Less
340 def ICC_GU : ICC_VAL<12>; // Greater Unsigned
341 def ICC_LEU : ICC_VAL< 4>; // Less or Equal Unsigned
342 def ICC_CC : ICC_VAL<13>; // Carry Clear/Great or Equal Unsigned
343 def ICC_CS : ICC_VAL< 5>; // Carry Set/Less Unsigned
344 def ICC_POS : ICC_VAL<14>; // Positive
345 def ICC_NEG : ICC_VAL< 6>; // Negative
346 def ICC_VC : ICC_VAL<15>; // Overflow Clear
347 def ICC_VS : ICC_VAL< 7>; // Overflow Set
349 class FCC_VAL<int N> : PatLeaf<(i32 N)>;
350 def FCC_U : FCC_VAL<23>; // Unordered
351 def FCC_G : FCC_VAL<22>; // Greater
352 def FCC_UG : FCC_VAL<21>; // Unordered or Greater
353 def FCC_L : FCC_VAL<20>; // Less
354 def FCC_UL : FCC_VAL<19>; // Unordered or Less
355 def FCC_LG : FCC_VAL<18>; // Less or Greater
356 def FCC_NE : FCC_VAL<17>; // Not Equal
357 def FCC_E : FCC_VAL<25>; // Equal
358 def FCC_UE : FCC_VAL<26>; // Unordered or Equal
359 def FCC_GE : FCC_VAL<27>; // Greater or Equal
360 def FCC_UGE : FCC_VAL<28>; // Unordered or Greater or Equal
361 def FCC_LE : FCC_VAL<29>; // Less or Equal
362 def FCC_ULE : FCC_VAL<30>; // Unordered or Less or Equal
363 def FCC_O : FCC_VAL<31>; // Ordered
365 class CPCC_VAL<int N> : PatLeaf<(i32 N)>;
366 def CPCC_3 : CPCC_VAL<39>; // 3
367 def CPCC_2 : CPCC_VAL<38>; // 2
368 def CPCC_23 : CPCC_VAL<37>; // 2 or 3
369 def CPCC_1 : CPCC_VAL<36>; // 1
370 def CPCC_13 : CPCC_VAL<35>; // 1 or 3
371 def CPCC_12 : CPCC_VAL<34>; // 1 or 2
372 def CPCC_123 : CPCC_VAL<33>; // 1 or 2 or 3
373 def CPCC_0 : CPCC_VAL<41>; // 0
374 def CPCC_03 : CPCC_VAL<42>; // 0 or 3
375 def CPCC_02 : CPCC_VAL<43>; // 0 or 2
376 def CPCC_023 : CPCC_VAL<44>; // 0 or 2 or 3
377 def CPCC_01 : CPCC_VAL<45>; // 0 or 1
378 def CPCC_013 : CPCC_VAL<46>; // 0 or 1 or 3
379 def CPCC_012 : CPCC_VAL<47>; // 0 or 1 or 2
381 class RegCC_VAL<int N> : PatLeaf<(i32 N)>;
382 def RegCC_Z : RegCC_VAL<49>; // Zero
383 def RegCC_LEZ : RegCC_VAL<50>; // Lees or equal than zero
384 def RegCC_LZ : RegCC_VAL<51>; // Less than zero
385 def RegCC_NZ : RegCC_VAL<53>; // Not zero
386 def RegCC_GZ : RegCC_VAL<54>; // Greater than zero
387 def RegCC_GEZ : RegCC_VAL<55>; // Greater or equal to zero
389 //===----------------------------------------------------------------------===//
390 // Instruction Class Templates
391 //===----------------------------------------------------------------------===//
393 /// F3_12 multiclass - Define a normal F3_1/F3_2 pattern in one shot.
394 multiclass F3_12<string OpcStr, bits<6> Op3Val, SDNode OpNode,
395 RegisterClass RC, ValueType Ty, Operand immOp,
396 InstrItinClass itin = IIC_iu_instr> {
397 def rr : F3_1<2, Op3Val,
398 (outs RC:$rd), (ins RC:$rs1, RC:$rs2),
399 !strconcat(OpcStr, " $rs1, $rs2, $rd"),
400 [(set Ty:$rd, (OpNode Ty:$rs1, Ty:$rs2))],
402 def ri : F3_2<2, Op3Val,
403 (outs RC:$rd), (ins RC:$rs1, immOp:$simm13),
404 !strconcat(OpcStr, " $rs1, $simm13, $rd"),
405 [(set Ty:$rd, (OpNode Ty:$rs1, (Ty simm13:$simm13)))],
409 /// F3_12np multiclass - Define a normal F3_1/F3_2 pattern in one shot, with no
411 multiclass F3_12np<string OpcStr, bits<6> Op3Val, InstrItinClass itin = IIC_iu_instr> {
412 def rr : F3_1<2, Op3Val,
413 (outs IntRegs:$rd), (ins IntRegs:$rs1, IntRegs:$rs2),
414 !strconcat(OpcStr, " $rs1, $rs2, $rd"), [],
416 def ri : F3_2<2, Op3Val,
417 (outs IntRegs:$rd), (ins IntRegs:$rs1, simm13Op:$simm13),
418 !strconcat(OpcStr, " $rs1, $simm13, $rd"), [],
422 // Load multiclass - Define both Reg+Reg/Reg+Imm patterns in one shot.
423 multiclass Load<string OpcStr, bits<6> Op3Val, SDPatternOperator OpNode,
424 RegisterClass RC, ValueType Ty, InstrItinClass itin = IIC_iu_instr> {
425 def rr : F3_1<3, Op3Val,
426 (outs RC:$rd), (ins (MEMrr $rs1, $rs2):$addr),
427 !strconcat(OpcStr, " [$addr], $rd"),
428 [(set Ty:$rd, (OpNode ADDRrr:$addr))],
430 def ri : F3_2<3, Op3Val,
431 (outs RC:$rd), (ins (MEMri $rs1, $simm13):$addr),
432 !strconcat(OpcStr, " [$addr], $rd"),
433 [(set Ty:$rd, (OpNode ADDRri:$addr))],
437 // TODO: Instructions of the LoadASI class are currently asm only; hooking up
438 // CodeGen's address spaces to use these is a future task.
439 multiclass LoadASI<string OpcStr, bits<6> Op3Val, RegisterClass RC> {
440 def rr : F3_1_asi<3, Op3Val, (outs RC:$rd), (ins (MEMrr $rs1, $rs2):$addr, ASITag:$asi),
441 !strconcat(OpcStr, "a [$addr] $asi, $rd"),
444 let Predicates = [HasV9], Uses = [ASR3] in
445 def ri : F3_2<3, Op3Val, (outs RC:$rd), (ins (MEMri $rs1, $simm13):$addr),
446 !strconcat(OpcStr, "a [$addr] %asi, $rd"),
450 // LoadA multiclass - As above, but also define alternate address space variant
451 multiclass LoadA<string OpcStr, bits<6> Op3Val, bits<6> LoadAOp3Val,
452 SDPatternOperator OpNode, RegisterClass RC, ValueType Ty,
453 InstrItinClass itin = NoItinerary> :
454 Load<OpcStr, Op3Val, OpNode, RC, Ty, itin> {
455 defm A : LoadASI<OpcStr, LoadAOp3Val, RC>;
459 // The LDSTUB instruction is supported for asm only.
460 // It is unlikely that general-purpose code could make use of it.
461 // CAS is preferred for sparc v9.
462 def LDSTUBrr : F3_1<3, 0b001101, (outs IntRegs:$rd), (ins (MEMrr $rs1, $rs2):$addr),
463 "ldstub [$addr], $rd", []>;
464 def LDSTUBri : F3_2<3, 0b001101, (outs IntRegs:$rd), (ins (MEMri $rs1, $simm13):$addr),
465 "ldstub [$addr], $rd", []>;
466 def LDSTUBArr : F3_1_asi<3, 0b011101, (outs IntRegs:$rd),
467 (ins (MEMrr $rs1, $rs2):$addr, ASITag:$asi),
468 "ldstuba [$addr] $asi, $rd", []>;
469 let Predicates = [HasV9], Uses = [ASR3] in
470 def LDSTUBAri : F3_2<3, 0b011101, (outs IntRegs:$rd),
471 (ins (MEMri $rs1, $simm13):$addr),
472 "ldstuba [$addr] %asi, $rd", []>;
474 // Store multiclass - Define both Reg+Reg/Reg+Imm patterns in one shot.
475 multiclass Store<string OpcStr, bits<6> Op3Val, SDPatternOperator OpNode,
476 RegisterClass RC, ValueType Ty, InstrItinClass itin = IIC_st> {
477 def rr : F3_1<3, Op3Val,
478 (outs), (ins (MEMrr $rs1, $rs2):$addr, RC:$rd),
479 !strconcat(OpcStr, " $rd, [$addr]"),
480 [(OpNode Ty:$rd, ADDRrr:$addr)],
482 def ri : F3_2<3, Op3Val,
483 (outs), (ins (MEMri $rs1, $simm13):$addr, RC:$rd),
484 !strconcat(OpcStr, " $rd, [$addr]"),
485 [(OpNode Ty:$rd, ADDRri:$addr)],
489 // TODO: Instructions of the StoreASI class are currently asm only; hooking up
490 // CodeGen's address spaces to use these is a future task.
491 multiclass StoreASI<string OpcStr, bits<6> Op3Val, RegisterClass RC,
492 InstrItinClass itin = IIC_st> {
493 def rr : F3_1_asi<3, Op3Val, (outs), (ins (MEMrr $rs1, $rs2):$addr, RC:$rd, ASITag:$asi),
494 !strconcat(OpcStr, "a $rd, [$addr] $asi"),
498 let Predicates = [HasV9], Uses = [ASR3] in
499 def ri : F3_2<3, Op3Val, (outs), (ins (MEMri $rs1, $simm13):$addr, RC:$rd),
500 !strconcat(OpcStr, "a $rd, [$addr] %asi"),
505 multiclass StoreA<string OpcStr, bits<6> Op3Val, bits<6> StoreAOp3Val,
506 SDPatternOperator OpNode, RegisterClass RC, ValueType Ty> :
507 Store<OpcStr, Op3Val, OpNode, RC, Ty> {
508 defm A : StoreASI<OpcStr, StoreAOp3Val, RC>;
511 //===----------------------------------------------------------------------===//
513 //===----------------------------------------------------------------------===//
515 // Pseudo instructions.
516 class Pseudo<dag outs, dag ins, string asmstr, list<dag> pattern>
517 : InstSP<outs, ins, asmstr, pattern> {
518 let isCodeGenOnly = 1;
524 def GETPCX : Pseudo<(outs getPCX:$getpcseq), (ins), "$getpcseq", [] >;
527 let Defs = [O6], Uses = [O6] in {
528 def ADJCALLSTACKDOWN : Pseudo<(outs), (ins i32imm:$amt1, i32imm:$amt2),
529 "!ADJCALLSTACKDOWN $amt1, $amt2",
530 [(callseq_start timm:$amt1, timm:$amt2)]>;
531 def ADJCALLSTACKUP : Pseudo<(outs), (ins i32imm:$amt1, i32imm:$amt2),
532 "!ADJCALLSTACKUP $amt1",
533 [(callseq_end timm:$amt1, timm:$amt2)]>;
536 let hasSideEffects = 1, mayStore = 1 in {
537 let rd = 0, rs1 = 0, rs2 = 0 in
538 def FLUSHW : F3_1<0b10, 0b101011, (outs), (ins),
540 [(flushw)]>, Requires<[HasV9]>;
541 let rd = 8, rs1 = 0, simm13 = 3 in
542 def TA3 : F3_2<0b10, 0b111010, (outs), (ins),
547 // SELECT_CC_* - Used to implement the SELECT_CC DAG operation. Expanded after
548 // instruction selection into a branch sequence. This has to handle all
549 // permutations of selection between i32/f32/f64 on ICC and FCC.
550 // Expanded after instruction selection.
551 let Uses = [ICC], usesCustomInserter = 1 in {
552 def SELECT_CC_Int_ICC
553 : Pseudo<(outs IntRegs:$dst), (ins IntRegs:$T, IntRegs:$F, i32imm:$Cond),
554 "; SELECT_CC_Int_ICC PSEUDO!",
555 [(set i32:$dst, (SPselecticc i32:$T, i32:$F, imm:$Cond))]>;
557 : Pseudo<(outs FPRegs:$dst), (ins FPRegs:$T, FPRegs:$F, i32imm:$Cond),
558 "; SELECT_CC_FP_ICC PSEUDO!",
559 [(set f32:$dst, (SPselecticc f32:$T, f32:$F, imm:$Cond))]>;
561 def SELECT_CC_DFP_ICC
562 : Pseudo<(outs DFPRegs:$dst), (ins DFPRegs:$T, DFPRegs:$F, i32imm:$Cond),
563 "; SELECT_CC_DFP_ICC PSEUDO!",
564 [(set f64:$dst, (SPselecticc f64:$T, f64:$F, imm:$Cond))]>;
566 def SELECT_CC_QFP_ICC
567 : Pseudo<(outs QFPRegs:$dst), (ins QFPRegs:$T, QFPRegs:$F, i32imm:$Cond),
568 "; SELECT_CC_QFP_ICC PSEUDO!",
569 [(set f128:$dst, (SPselecticc f128:$T, f128:$F, imm:$Cond))]>;
572 let Uses = [ICC], usesCustomInserter = 1 in {
573 def SELECT_CC_Int_XCC
574 : Pseudo<(outs IntRegs:$dst), (ins IntRegs:$T, IntRegs:$F, i32imm:$Cond),
575 "; SELECT_CC_Int_XCC PSEUDO!",
576 [(set i32:$dst, (SPselectxcc i32:$T, i32:$F, imm:$Cond))]>;
578 : Pseudo<(outs FPRegs:$dst), (ins FPRegs:$T, FPRegs:$F, i32imm:$Cond),
579 "; SELECT_CC_FP_XCC PSEUDO!",
580 [(set f32:$dst, (SPselectxcc f32:$T, f32:$F, imm:$Cond))]>;
582 def SELECT_CC_DFP_XCC
583 : Pseudo<(outs DFPRegs:$dst), (ins DFPRegs:$T, DFPRegs:$F, i32imm:$Cond),
584 "; SELECT_CC_DFP_XCC PSEUDO!",
585 [(set f64:$dst, (SPselectxcc f64:$T, f64:$F, imm:$Cond))]>;
587 def SELECT_CC_QFP_XCC
588 : Pseudo<(outs QFPRegs:$dst), (ins QFPRegs:$T, QFPRegs:$F, i32imm:$Cond),
589 "; SELECT_CC_QFP_XCC PSEUDO!",
590 [(set f128:$dst, (SPselectxcc f128:$T, f128:$F, imm:$Cond))]>;
593 let usesCustomInserter = 1, Uses = [FCC0] in {
595 def SELECT_CC_Int_FCC
596 : Pseudo<(outs IntRegs:$dst), (ins IntRegs:$T, IntRegs:$F, i32imm:$Cond),
597 "; SELECT_CC_Int_FCC PSEUDO!",
598 [(set i32:$dst, (SPselectfcc i32:$T, i32:$F, imm:$Cond))]>;
601 : Pseudo<(outs FPRegs:$dst), (ins FPRegs:$T, FPRegs:$F, i32imm:$Cond),
602 "; SELECT_CC_FP_FCC PSEUDO!",
603 [(set f32:$dst, (SPselectfcc f32:$T, f32:$F, imm:$Cond))]>;
604 def SELECT_CC_DFP_FCC
605 : Pseudo<(outs DFPRegs:$dst), (ins DFPRegs:$T, DFPRegs:$F, i32imm:$Cond),
606 "; SELECT_CC_DFP_FCC PSEUDO!",
607 [(set f64:$dst, (SPselectfcc f64:$T, f64:$F, imm:$Cond))]>;
608 def SELECT_CC_QFP_FCC
609 : Pseudo<(outs QFPRegs:$dst), (ins QFPRegs:$T, QFPRegs:$F, i32imm:$Cond),
610 "; SELECT_CC_QFP_FCC PSEUDO!",
611 [(set f128:$dst, (SPselectfcc f128:$T, f128:$F, imm:$Cond))]>;
614 // Section B.1 - Load Integer Instructions, p. 90
615 defm LDSB : LoadA<"ldsb", 0b001001, 0b011001, sextloadi8, IntRegs, i32>;
616 defm LDSH : LoadA<"ldsh", 0b001010, 0b011010, sextloadi16, IntRegs, i32>;
617 defm LDUB : LoadA<"ldub", 0b000001, 0b010001, zextloadi8, IntRegs, i32>;
618 defm LDUH : LoadA<"lduh", 0b000010, 0b010010, zextloadi16, IntRegs, i32>;
619 defm LD : LoadA<"ld", 0b000000, 0b010000, load, IntRegs, i32>;
620 defm LDD : LoadA<"ldd", 0b000011, 0b010011, load, IntPair, v2i32, IIC_ldd>;
622 // Section B.2 - Load Floating-point Instructions, p. 92
623 defm LDF : Load<"ld", 0b100000, load, FPRegs, f32, IIC_iu_or_fpu_instr>;
624 defm LDDF : Load<"ldd", 0b100011, load, DFPRegs, f64, IIC_ldd>;
626 let DecoderNamespace = "SparcV9", Predicates = [HasV9] in {
627 defm LDFA : LoadASI<"ld", 0b110000, FPRegs>;
628 defm LDDFA : LoadASI<"ldd", 0b110011, DFPRegs>;
629 defm LDQF : LoadA<"ldq", 0b100010, 0b110010, load, QFPRegs, f128>,
630 Requires<[HasHardQuad]>;
633 // Coprocessor instructions were removed in v9.
634 let DecoderNamespace = "SparcV8", Predicates = [HasNoV9] in {
635 defm LDC : Load<"ld", 0b110000, load, CoprocRegs, i32>;
636 defm LDDC : Load<"ldd", 0b110011, load, CoprocPair, v2i32, IIC_ldd>;
639 let Defs = [CPSR] in {
641 def LDCSRrr : F3_1<3, 0b110001, (outs), (ins (MEMrr $rs1, $rs2):$addr),
642 "ld [$addr], %csr", []>;
643 def LDCSRri : F3_2<3, 0b110001, (outs), (ins (MEMri $rs1, $simm13):$addr),
644 "ld [$addr], %csr", []>;
648 let Defs = [FSR] in {
650 def LDFSRrr : F3_1<3, 0b100001, (outs), (ins (MEMrr $rs1, $rs2):$addr),
651 "ld [$addr], %fsr", [], IIC_iu_or_fpu_instr>;
652 def LDFSRri : F3_2<3, 0b100001, (outs), (ins (MEMri $rs1, $simm13):$addr),
653 "ld [$addr], %fsr", [], IIC_iu_or_fpu_instr>;
656 def LDXFSRrr : F3_1<3, 0b100001, (outs), (ins (MEMrr $rs1, $rs2):$addr),
657 "ldx [$addr], %fsr", []>, Requires<[HasV9]>;
658 def LDXFSRri : F3_2<3, 0b100001, (outs), (ins (MEMri $rs1, $simm13):$addr),
659 "ldx [$addr], %fsr", []>, Requires<[HasV9]>;
663 let mayLoad = 1, isAsmParserOnly = 1 in {
664 def GDOP_LDrr : F3_1<3, 0b000000,
666 (ins (MEMrr $rs1, $rs2):$addr, TailRelocSymGOTLoad:$sym),
667 "ld [$addr], $rd, $sym",
669 (load_gdop ADDRrr:$addr, tglobaladdr:$sym))]>;
672 // Section B.4 - Store Integer Instructions, p. 95
673 defm STB : StoreA<"stb", 0b000101, 0b010101, truncstorei8, IntRegs, i32>;
674 defm STH : StoreA<"sth", 0b000110, 0b010110, truncstorei16, IntRegs, i32>;
675 defm ST : StoreA<"st", 0b000100, 0b010100, store, IntRegs, i32>;
676 defm STD : StoreA<"std", 0b000111, 0b010111, store, IntPair, v2i32>;
678 // Section B.5 - Store Floating-point Instructions, p. 97
679 defm STF : Store<"st", 0b100100, store, FPRegs, f32>;
680 defm STDF : Store<"std", 0b100111, store, DFPRegs, f64, IIC_std>;
682 let DecoderNamespace = "SparcV9", Predicates = [HasV9] in {
683 defm STFA : StoreASI<"st", 0b110100, FPRegs>;
684 defm STDFA : StoreASI<"std", 0b110111, DFPRegs>;
685 defm STQF : StoreA<"stq", 0b100110, 0b110110, store, QFPRegs, f128>,
686 Requires<[HasHardQuad]>;
689 // Coprocessor instructions were removed in v9.
690 let DecoderNamespace = "SparcV8", Predicates = [HasNoV9] in {
691 defm STC : Store<"st", 0b110100, store, CoprocRegs, i32>;
692 defm STDC : Store<"std", 0b110111, store, CoprocPair, v2i32, IIC_std>;
696 let Defs = [CPSR] in {
697 def STCSRrr : F3_1<3, 0b110101, (outs (MEMrr $rs1, $rs2):$addr), (ins),
698 "st %csr, [$addr]", [], IIC_st>;
699 def STCSRri : F3_2<3, 0b110101, (outs (MEMri $rs1, $simm13):$addr), (ins),
700 "st %csr, [$addr]", [], IIC_st>;
702 let Defs = [CPQ] in {
703 def STDCQrr : F3_1<3, 0b110110, (outs (MEMrr $rs1, $rs2):$addr), (ins),
704 "std %cq, [$addr]", [], IIC_std>;
705 def STDCQri : F3_2<3, 0b110110, (outs (MEMri $rs1, $simm13):$addr), (ins),
706 "std %cq, [$addr]", [], IIC_std>;
711 let Defs = [FSR] in {
712 def STFSRrr : F3_1<3, 0b100101, (outs (MEMrr $rs1, $rs2):$addr), (ins),
713 "st %fsr, [$addr]", [], IIC_st>;
714 def STFSRri : F3_2<3, 0b100101, (outs (MEMri $rs1, $simm13):$addr), (ins),
715 "st %fsr, [$addr]", [], IIC_st>;
718 def STDFQrr : F3_1<3, 0b100110, (outs (MEMrr $rs1, $rs2):$addr), (ins),
719 "std %fq, [$addr]", [], IIC_std>;
720 def STDFQri : F3_2<3, 0b100110, (outs (MEMri $rs1, $simm13):$addr), (ins),
721 "std %fq, [$addr]", [], IIC_std>;
724 let rd = 1, Defs = [FSR] in {
725 def STXFSRrr : F3_1<3, 0b100101, (outs (MEMrr $rs1, $rs2):$addr), (ins),
726 "stx %fsr, [$addr]", []>, Requires<[HasV9]>;
727 def STXFSRri : F3_2<3, 0b100101, (outs (MEMri $rs1, $simm13):$addr), (ins),
728 "stx %fsr, [$addr]", []>, Requires<[HasV9]>;
731 // Section B.8 - SWAP Register with Memory Instruction
733 let Constraints = "$val = $rd" in {
734 def SWAPrr : F3_1<3, 0b001111,
735 (outs IntRegs:$rd), (ins (MEMrr $rs1, $rs2):$addr, IntRegs:$val),
737 [(set i32:$rd, (atomic_swap_32 ADDRrr:$addr, i32:$val))]>;
738 def SWAPri : F3_2<3, 0b001111,
739 (outs IntRegs:$rd), (ins (MEMri $rs1, $simm13):$addr, IntRegs:$val),
741 [(set i32:$rd, (atomic_swap_32 ADDRri:$addr, i32:$val))]>;
742 def SWAPArr : F3_1_asi<3, 0b011111,
743 (outs IntRegs:$rd), (ins (MEMrr $rs1, $rs2):$addr, ASITag:$asi, IntRegs:$val),
744 "swapa [$addr] $asi, $rd",
745 [/*FIXME: pattern?*/]>;
746 let Predicates = [HasV9], Uses = [ASR3] in
747 def SWAPAri : F3_2<3, 0b011111,
748 (outs IntRegs:$rd), (ins (MEMri $rs1, $simm13):$addr, IntRegs:$val),
749 "swapa [$addr] %asi, $rd",
750 [/*FIXME: pattern?*/]>;
754 // Section B.9 - SETHI Instruction, p. 104
755 def SETHIi: F2_1<0b100,
756 (outs IntRegs:$rd), (ins i32imm:$imm22),
758 [(set i32:$rd, SETHIimm:$imm22)],
761 // Section B.10 - NOP Instruction, p. 105
762 // (It's a special case of SETHI)
763 let rd = 0, imm22 = 0 in
764 def NOP : F2_1<0b100, (outs), (ins), "nop", []>;
766 // Section B.11 - Logical Instructions, p. 106
767 defm AND : F3_12<"and", 0b000001, and, IntRegs, i32, simm13Op>;
769 def ANDNrr : F3_1<2, 0b000101,
770 (outs IntRegs:$rd), (ins IntRegs:$rs1, IntRegs:$rs2),
771 "andn $rs1, $rs2, $rd",
772 [(set i32:$rd, (and i32:$rs1, (not i32:$rs2)))]>;
773 def ANDNri : F3_2<2, 0b000101,
774 (outs IntRegs:$rd), (ins IntRegs:$rs1, simm13Op:$simm13),
775 "andn $rs1, $simm13, $rd", []>;
777 defm OR : F3_12<"or", 0b000010, or, IntRegs, i32, simm13Op>;
779 def ORNrr : F3_1<2, 0b000110,
780 (outs IntRegs:$rd), (ins IntRegs:$rs1, IntRegs:$rs2),
781 "orn $rs1, $rs2, $rd",
782 [(set i32:$rd, (or i32:$rs1, (not i32:$rs2)))]>;
783 def ORNri : F3_2<2, 0b000110,
784 (outs IntRegs:$rd), (ins IntRegs:$rs1, simm13Op:$simm13),
785 "orn $rs1, $simm13, $rd", []>;
786 defm XOR : F3_12<"xor", 0b000011, xor, IntRegs, i32, simm13Op>;
788 def XNORrr : F3_1<2, 0b000111,
789 (outs IntRegs:$rd), (ins IntRegs:$rs1, IntRegs:$rs2),
790 "xnor $rs1, $rs2, $rd",
791 [(set i32:$rd, (not (xor i32:$rs1, i32:$rs2)))]>;
792 def XNORri : F3_2<2, 0b000111,
793 (outs IntRegs:$rd), (ins IntRegs:$rs1, simm13Op:$simm13),
794 "xnor $rs1, $simm13, $rd", []>;
796 def : Pat<(and IntRegs:$rs1, SETHIimm_not:$rs2),
797 (ANDNrr i32:$rs1, (SETHIi SETHIimm_not:$rs2))>;
799 def : Pat<(or IntRegs:$rs1, SETHIimm_not:$rs2),
800 (ORNrr i32:$rs1, (SETHIi SETHIimm_not:$rs2))>;
802 let Defs = [ICC] in {
803 defm ANDCC : F3_12np<"andcc", 0b010001>;
804 defm ANDNCC : F3_12np<"andncc", 0b010101>;
805 defm ORCC : F3_12np<"orcc", 0b010010>;
806 defm ORNCC : F3_12np<"orncc", 0b010110>;
807 defm XORCC : F3_12np<"xorcc", 0b010011>;
808 defm XNORCC : F3_12np<"xnorcc", 0b010111>;
811 // Section B.12 - Shift Instructions, p. 107
812 defm SLL : F3_S<"sll", 0b100101, 0, shl, i32, shift_imm5, IntRegs>;
813 defm SRL : F3_S<"srl", 0b100110, 0, srl, i32, shift_imm5, IntRegs>;
814 defm SRA : F3_S<"sra", 0b100111, 0, sra, i32, shift_imm5, IntRegs>;
816 // Section B.13 - Add Instructions, p. 108
817 defm ADD : F3_12<"add", 0b000000, add, IntRegs, i32, simm13Op>;
820 defm ADDCC : F3_12<"addcc", 0b010000, addc, IntRegs, i32, simm13Op>;
823 defm ADDC : F3_12np<"addx", 0b001000>;
825 let Uses = [ICC], Defs = [ICC] in
826 defm ADDE : F3_12<"addxcc", 0b011000, adde, IntRegs, i32, simm13Op>;
828 // Section B.15 - Subtract Instructions, p. 110
829 defm SUB : F3_12 <"sub" , 0b000100, sub, IntRegs, i32, simm13Op>;
830 let Uses = [ICC], Defs = [ICC] in
831 defm SUBE : F3_12 <"subxcc" , 0b011100, sube, IntRegs, i32, simm13Op>;
833 let Defs = [ICC], hasPostISelHook = true in
834 defm SUBCC : F3_12 <"subcc", 0b010100, subc, IntRegs, i32, simm13Op>;
837 defm SUBC : F3_12np <"subx", 0b001100>;
839 def : Pat<(SPcmpicc i32:$lhs, i32:$rhs), (SUBCCrr $lhs, $rhs)>;
840 def : Pat<(SPcmpicc i32:$lhs, (i32 simm13:$rhs)), (SUBCCri $lhs, imm:$rhs)>;
842 // Section B.18 - Multiply Instructions, p. 113
844 defm UMUL : F3_12<"umul", 0b001010, umullohi, IntRegs, i32, simm13Op, IIC_iu_umul>;
845 defm SMUL : F3_12<"smul", 0b001011, smullohi, IntRegs, i32, simm13Op, IIC_iu_smul>;
848 let Defs = [Y, ICC] in {
849 defm UMULCC : F3_12np<"umulcc", 0b011010, IIC_iu_umul>;
850 defm SMULCC : F3_12np<"smulcc", 0b011011, IIC_iu_smul>;
853 let Defs = [Y, ICC], Uses = [Y, ICC] in {
854 defm MULSCC : F3_12np<"mulscc", 0b100100>;
857 // Section B.19 - Divide Instructions, p. 115
858 let Uses = [Y], Defs = [Y] in {
859 defm UDIV : F3_12np<"udiv", 0b001110, IIC_iu_div>;
860 defm SDIV : F3_12np<"sdiv", 0b001111, IIC_iu_div>;
863 let Uses = [Y], Defs = [Y, ICC] in {
864 defm UDIVCC : F3_12np<"udivcc", 0b011110, IIC_iu_div>;
865 defm SDIVCC : F3_12np<"sdivcc", 0b011111, IIC_iu_div>;
868 // Section B.20 - SAVE and RESTORE, p. 117
869 defm SAVE : F3_12np<"save" , 0b111100>;
870 defm RESTORE : F3_12np<"restore", 0b111101>;
872 // Section B.21 - Branch on Integer Condition Codes Instructions, p. 119
873 // Section A.7 - Branch on Integer Condition Codes with Prediction (SPARC v9)
875 let isBranch = 1, isTerminator = 1, hasDelaySlot = 1, isBarrier = 1 in {
876 // unconditional branch class.
877 class BranchAlways<dag ins, string asmstr, list<dag> pattern>
878 : F2_2<0b010, 0, (outs), ins, asmstr, pattern>;
880 // Same as BranchAlways but uses the new v9 encoding
881 class BranchPredictAlways<dag ins, string asmstr, list<dag> pattern>
882 : F2_3<0b001, 0, 1, (outs), ins, asmstr, pattern>;
886 def BA : BranchAlways<(ins brtarget:$imm22), "ba $imm22", [(br bb:$imm22)]>;
888 let isBranch = 1, isTerminator = 1, hasDelaySlot = 1 in {
890 // conditional branch class:
891 class BranchSP<dag ins, string asmstr, list<dag> pattern>
892 : F2_2<0b010, 0, (outs), ins, asmstr, pattern, IIC_iu_instr>;
894 // conditional branch with annul class:
895 class BranchSPA<dag ins, string asmstr, list<dag> pattern>
896 : F2_2<0b010, 1, (outs), ins, asmstr, pattern, IIC_iu_instr>;
898 // Conditional branch class on %icc|%xcc with predication:
899 multiclass IPredBranch<string regstr, list<dag> CCPattern> {
900 def CC : F2_3<0b001, 0, 1, (outs), (ins bprtarget:$imm19, CCOp:$cond),
901 !strconcat("b$cond ", !strconcat(regstr, ", $imm19")),
904 def CCA : F2_3<0b001, 1, 1, (outs), (ins bprtarget:$imm19, CCOp:$cond),
905 !strconcat("b$cond,a ", !strconcat(regstr, ", $imm19")),
908 def CCNT : F2_3<0b001, 0, 0, (outs), (ins bprtarget:$imm19, CCOp:$cond),
909 !strconcat("b$cond,pn ", !strconcat(regstr, ", $imm19")),
912 def CCANT : F2_3<0b001, 1, 0, (outs), (ins bprtarget:$imm19, CCOp:$cond),
913 !strconcat("b$cond,a,pn ", !strconcat(regstr, ", $imm19")),
918 } // let isBranch = 1, isTerminator = 1, hasDelaySlot = 1
921 // Indirect branch instructions.
922 let isTerminator = 1, isBarrier = 1, hasDelaySlot = 1, isBranch =1,
923 isIndirectBranch = 1, rd = 0, isCodeGenOnly = 1 in {
924 def BINDrr : F3_1<2, 0b111000,
925 (outs), (ins (MEMrr $rs1, $rs2):$addr),
927 [(brind ADDRrr:$addr)]>;
928 def BINDri : F3_2<2, 0b111000,
929 (outs), (ins (MEMri $rs1, $simm13):$addr),
931 [(brind ADDRri:$addr)]>;
934 let Uses = [ICC] in {
935 def BCOND : BranchSP<(ins brtarget:$imm22, CCOp:$cond),
937 [(SPbricc bb:$imm22, imm:$cond)]>;
938 def BCONDA : BranchSPA<(ins brtarget:$imm22, CCOp:$cond),
939 "b$cond,a $imm22", []>;
941 let Predicates = [HasV9], cc = 0b00 in
942 defm BPI : IPredBranch<"%icc", [(SPbpicc bb:$imm19, imm:$cond)]>;
945 // Section B.22 - Branch on Floating-point Condition Codes Instructions, p. 121
947 let isBranch = 1, isTerminator = 1, hasDelaySlot = 1 in {
949 // floating-point conditional branch class:
950 class FPBranchSP<dag ins, string asmstr, list<dag> pattern>
951 : F2_2<0b110, 0, (outs), ins, asmstr, pattern, IIC_fpu_normal_instr>;
953 // floating-point conditional branch with annul class:
954 class FPBranchSPA<dag ins, string asmstr, list<dag> pattern>
955 : F2_2<0b110, 1, (outs), ins, asmstr, pattern, IIC_fpu_normal_instr>;
957 // Conditional branch class on %fcc0-%fcc3 with predication:
958 multiclass FPredBranch {
959 def CC : F2_3<0b101, 0, 1, (outs), (ins bprtarget:$imm19, CCOp:$cond,
961 "fb$cond $cc, $imm19", [], IIC_fpu_normal_instr>;
962 def CCA : F2_3<0b101, 1, 1, (outs), (ins bprtarget:$imm19, CCOp:$cond,
964 "fb$cond,a $cc, $imm19", [], IIC_fpu_normal_instr>;
965 def CCNT : F2_3<0b101, 0, 0, (outs), (ins bprtarget:$imm19, CCOp:$cond,
967 "fb$cond,pn $cc, $imm19", [], IIC_fpu_normal_instr>;
968 def CCANT : F2_3<0b101, 1, 0, (outs), (ins bprtarget:$imm19, CCOp:$cond,
970 "fb$cond,a,pn $cc, $imm19", [], IIC_fpu_normal_instr>;
972 } // let isBranch = 1, isTerminator = 1, hasDelaySlot = 1
974 let Uses = [FCC0] in {
975 def FBCOND : FPBranchSP<(ins brtarget:$imm22, CCOp:$cond),
977 [(SPbrfcc bb:$imm22, imm:$cond)]>;
978 def FBCONDA : FPBranchSPA<(ins brtarget:$imm22, CCOp:$cond),
979 "fb$cond,a $imm22", []>;
982 // Variants of FBCOND that uses V9 opcode
983 let Predicates = [HasV9], Uses = [FCC0], cc = 0,
984 isBranch = 1, isTerminator = 1, hasDelaySlot = 1 in {
985 def FBCOND_V9 : F2_3<0b101, 0, 1, (outs),
986 (ins bprtarget:$imm19, CCOp:$cond),
987 "fb$cond %fcc0, $imm19",
988 [(SPbrfccv9 bb:$imm19, imm:$cond)], IIC_fpu_normal_instr>;
989 def FBCONDA_V9 : F2_3<0b101, 1, 1, (outs),
990 (ins bprtarget:$imm19, CCOp:$cond),
991 "fb$cond,a %fcc0, $imm19",
992 [(SPbrfccv9 bb:$imm19, imm:$cond)], IIC_fpu_normal_instr>;
995 let Predicates = [HasV9] in
996 defm BPF : FPredBranch;
998 // Section B.22 - Branch on Co-processor Condition Codes Instructions, p. 123
999 let isBranch = 1, isTerminator = 1, hasDelaySlot = 1 in {
1001 // co-processor conditional branch class:
1002 class CPBranchSP<dag ins, string asmstr, list<dag> pattern>
1003 : F2_2<0b111, 0, (outs), ins, asmstr, pattern>;
1005 // co-processor conditional branch with annul class:
1006 class CPBranchSPA<dag ins, string asmstr, list<dag> pattern>
1007 : F2_2<0b111, 1, (outs), ins, asmstr, pattern>;
1009 } // let isBranch = 1, isTerminator = 1, hasDelaySlot = 1
1011 def CBCOND : CPBranchSP<(ins brtarget:$imm22, CCOp:$cond),
1013 [(SPbrfcc bb:$imm22, imm:$cond)]>;
1014 def CBCONDA : CPBranchSPA<(ins brtarget:$imm22, CCOp:$cond),
1015 "cb$cond,a $imm22", []>;
1017 // Section B.24 - Call and Link Instruction, p. 125
1018 // This is the only Format 1 instruction
1020 hasDelaySlot = 1, isCall = 1 in {
1021 def CALL : InstSP<(outs), (ins calltarget:$disp, variable_ops),
1027 let Inst{29-0} = disp;
1030 // indirect calls: special cases of JMPL.
1031 let isCodeGenOnly = 1, rd = 15 in {
1032 def CALLrr : F3_1<2, 0b111000,
1033 (outs), (ins (MEMrr $rs1, $rs2):$addr, variable_ops),
1035 [(call ADDRrr:$addr)],
1037 def CALLri : F3_2<2, 0b111000,
1038 (outs), (ins (MEMri $rs1, $simm13):$addr, variable_ops),
1040 [(call ADDRri:$addr)],
1045 // Section B.25 - Jump and Link Instruction
1047 // JMPL Instruction.
1048 let isTerminator = 1, hasDelaySlot = 1, isBarrier = 1 in {
1049 def JMPLrr: F3_1<2, 0b111000,
1050 (outs IntRegs:$rd), (ins (MEMrr $rs1, $rs2):$addr),
1054 def JMPLri: F3_2<2, 0b111000,
1055 (outs IntRegs:$rd), (ins (MEMri $rs1, $simm13):$addr),
1061 // Section A.3 - Synthetic Instructions, p. 85
1062 // special cases of JMPL:
1063 let isReturn = 1, isTerminator = 1, hasDelaySlot = 1, isBarrier = 1,
1064 isCodeGenOnly = 1 in {
1065 let rd = 0, rs1 = 15 in
1066 def RETL: F3_2<2, 0b111000,
1067 (outs), (ins i32imm:$simm13),
1069 [(retglue simm13:$simm13)],
1072 let rd = 0, rs1 = 31 in
1073 def RET: F3_2<2, 0b111000,
1074 (outs), (ins i32imm:$simm13),
1080 // Section B.26 - Return from Trap Instruction
1081 let isReturn = 1, isTerminator = 1, hasDelaySlot = 1,
1082 isBarrier = 1, rd = 0 in {
1083 def RETTrr : F3_1<2, 0b111001,
1084 (outs), (ins (MEMrr $rs1, $rs2):$addr),
1088 def RETTri : F3_2<2, 0b111001,
1089 (outs), (ins (MEMri $rs1, $simm13):$addr),
1096 // Section B.27 - Trap on Integer Condition Codes Instruction
1097 // conditional branch class:
1098 let DecoderNamespace = "SparcV8", hasSideEffects = 1, Uses = [ICC], cc = 0b00 in
1100 def TRAPrr : TRAPSPrr<0b111010,
1101 (outs), (ins IntRegs:$rs1, IntRegs:$rs2, CCOp:$cond),
1102 "t$cond $rs1 + $rs2",
1104 def TRAPri : TRAPSPri<0b111010,
1105 (outs), (ins IntRegs:$rs1, i32imm:$imm, CCOp:$cond),
1106 "t$cond $rs1 + $imm",
1110 multiclass TRAP<string regStr> {
1111 def rr : TRAPSPrr<0b111010,
1112 (outs), (ins IntRegs:$rs1, IntRegs:$rs2, CCOp:$cond),
1113 !strconcat(!strconcat("t$cond ", regStr), ", $rs1 + $rs2"),
1115 def ri : TRAPSPri<0b111010,
1116 (outs), (ins IntRegs:$rs1, i32imm:$imm, CCOp:$cond),
1117 !strconcat(!strconcat("t$cond ", regStr), ", $rs1 + $imm"),
1121 let DecoderNamespace = "SparcV9", Predicates = [HasV9], hasSideEffects = 1, Uses = [ICC], cc = 0b00 in
1122 defm TICC : TRAP<"%icc">;
1125 let isBarrier = 1, isTerminator = 1, rd = 0b01000, rs1 = 0, simm13 = 5 in
1126 def TA5 : F3_2<0b10, 0b111010, (outs), (ins), "ta 5", [(trap)]>;
1128 let hasSideEffects = 1, rd = 0b01000, rs1 = 0, simm13 = 1 in
1129 def TA1 : F3_2<0b10, 0b111010, (outs), (ins), "ta 1", [(debugtrap)]>;
1131 // Section B.28 - Read State Register Instructions
1133 def RDASR : F3_1<2, 0b101000,
1134 (outs IntRegs:$rd), (ins ASRRegs:$rs1),
1135 "rd $rs1, $rd", []>;
1137 // PSR, WIM, and TBR don't exist on the SparcV9, only the V8.
1138 let Predicates = [HasNoV9] in {
1139 let rs2 = 0, rs1 = 0, Uses=[PSR] in
1140 def RDPSR : F3_1<2, 0b101001,
1141 (outs IntRegs:$rd), (ins),
1142 "rd %psr, $rd", []>;
1144 let rs2 = 0, rs1 = 0, Uses=[WIM] in
1145 def RDWIM : F3_1<2, 0b101010,
1146 (outs IntRegs:$rd), (ins),
1147 "rd %wim, $rd", []>;
1149 let rs2 = 0, rs1 = 0, Uses=[TBR] in
1150 def RDTBR : F3_1<2, 0b101011,
1151 (outs IntRegs:$rd), (ins),
1152 "rd %tbr, $rd", []>;
1155 // Section B.29 - Write State Register Instructions
1156 def WRASRrr : F3_1<2, 0b110000,
1157 (outs ASRRegs:$rd), (ins IntRegs:$rs1, IntRegs:$rs2),
1158 "wr $rs1, $rs2, $rd", []>;
1159 def WRASRri : F3_2<2, 0b110000,
1160 (outs ASRRegs:$rd), (ins IntRegs:$rs1, simm13Op:$simm13),
1161 "wr $rs1, $simm13, $rd", []>;
1163 // PSR, WIM, and TBR don't exist on the SparcV9, only the V8.
1164 let Predicates = [HasNoV9] in {
1165 let Defs = [PSR], rd=0 in {
1166 def WRPSRrr : F3_1<2, 0b110001,
1167 (outs), (ins IntRegs:$rs1, IntRegs:$rs2),
1168 "wr $rs1, $rs2, %psr", []>;
1169 def WRPSRri : F3_2<2, 0b110001,
1170 (outs), (ins IntRegs:$rs1, simm13Op:$simm13),
1171 "wr $rs1, $simm13, %psr", []>;
1174 let Defs = [WIM], rd=0 in {
1175 def WRWIMrr : F3_1<2, 0b110010,
1176 (outs), (ins IntRegs:$rs1, IntRegs:$rs2),
1177 "wr $rs1, $rs2, %wim", []>;
1178 def WRWIMri : F3_2<2, 0b110010,
1179 (outs), (ins IntRegs:$rs1, simm13Op:$simm13),
1180 "wr $rs1, $simm13, %wim", []>;
1183 let Defs = [TBR], rd=0 in {
1184 def WRTBRrr : F3_1<2, 0b110011,
1185 (outs), (ins IntRegs:$rs1, IntRegs:$rs2),
1186 "wr $rs1, $rs2, %tbr", []>;
1187 def WRTBRri : F3_2<2, 0b110011,
1188 (outs), (ins IntRegs:$rs1, simm13Op:$simm13),
1189 "wr $rs1, $simm13, %tbr", []>;
1193 // Section B.30 - STBAR Instruction
1194 let hasSideEffects = 1, rd = 0, rs1 = 0b01111, rs2 = 0 in
1195 def STBAR : F3_1<2, 0b101000, (outs), (ins), "stbar", []>;
1198 // Section B.31 - Unimplemented Instruction
1200 def UNIMP : F2_1<0b000, (outs), (ins i32imm:$imm22),
1201 "unimp $imm22", []>;
1203 // Section B.32 - Flush Instruction Memory
1205 def FLUSHrr : F3_1<2, 0b111011, (outs), (ins (MEMrr $rs1, $rs2):$addr),
1207 def FLUSHri : F3_2<2, 0b111011, (outs), (ins (MEMri $rs1, $simm13):$addr),
1210 // The no-arg FLUSH is only here for the benefit of the InstAlias
1211 // "flush", which cannot seem to use FLUSHrr, due to the inability
1212 // to construct a MEMrr with fixed G0 registers.
1213 let rs1 = 0, rs2 = 0 in
1214 def FLUSH : F3_1<2, 0b111011, (outs), (ins), "flush %g0", []>;
1217 // Section B.33 - Floating-point Operate (FPop) Instructions
1219 // Convert Integer to Floating-point Instructions, p. 141
1220 def FITOS : F3_3u<2, 0b110100, 0b011000100,
1221 (outs FPRegs:$rd), (ins FPRegs:$rs2),
1223 [(set FPRegs:$rd, (SPitof FPRegs:$rs2))],
1224 IIC_fpu_fast_instr>;
1225 def FITOD : F3_3u<2, 0b110100, 0b011001000,
1226 (outs DFPRegs:$rd), (ins FPRegs:$rs2),
1228 [(set DFPRegs:$rd, (SPitof FPRegs:$rs2))],
1229 IIC_fpu_fast_instr>;
1230 def FITOQ : F3_3u<2, 0b110100, 0b011001100,
1231 (outs QFPRegs:$rd), (ins FPRegs:$rs2),
1233 [(set QFPRegs:$rd, (SPitof FPRegs:$rs2))]>,
1234 Requires<[HasHardQuad]>;
1236 // Convert Floating-point to Integer Instructions, p. 142
1237 def FSTOI : F3_3u<2, 0b110100, 0b011010001,
1238 (outs FPRegs:$rd), (ins FPRegs:$rs2),
1240 [(set FPRegs:$rd, (SPftoi FPRegs:$rs2))],
1241 IIC_fpu_fast_instr>;
1242 def FDTOI : F3_3u<2, 0b110100, 0b011010010,
1243 (outs FPRegs:$rd), (ins DFPRegs:$rs2),
1245 [(set FPRegs:$rd, (SPftoi DFPRegs:$rs2))],
1246 IIC_fpu_fast_instr>;
1247 def FQTOI : F3_3u<2, 0b110100, 0b011010011,
1248 (outs FPRegs:$rd), (ins QFPRegs:$rs2),
1250 [(set FPRegs:$rd, (SPftoi QFPRegs:$rs2))]>,
1251 Requires<[HasHardQuad]>;
1253 // Convert between Floating-point Formats Instructions, p. 143
1254 def FSTOD : F3_3u<2, 0b110100, 0b011001001,
1255 (outs DFPRegs:$rd), (ins FPRegs:$rs2),
1257 [(set f64:$rd, (fpextend f32:$rs2))],
1259 def FSTOQ : F3_3u<2, 0b110100, 0b011001101,
1260 (outs QFPRegs:$rd), (ins FPRegs:$rs2),
1262 [(set f128:$rd, (fpextend f32:$rs2))]>,
1263 Requires<[HasHardQuad]>;
1264 def FDTOS : F3_3u<2, 0b110100, 0b011000110,
1265 (outs FPRegs:$rd), (ins DFPRegs:$rs2),
1267 [(set f32:$rd, (fpround f64:$rs2))],
1268 IIC_fpu_fast_instr>;
1269 def FDTOQ : F3_3u<2, 0b110100, 0b011001110,
1270 (outs QFPRegs:$rd), (ins DFPRegs:$rs2),
1272 [(set f128:$rd, (fpextend f64:$rs2))]>,
1273 Requires<[HasHardQuad]>;
1274 def FQTOS : F3_3u<2, 0b110100, 0b011000111,
1275 (outs FPRegs:$rd), (ins QFPRegs:$rs2),
1277 [(set f32:$rd, (fpround f128:$rs2))]>,
1278 Requires<[HasHardQuad]>;
1279 def FQTOD : F3_3u<2, 0b110100, 0b011001011,
1280 (outs DFPRegs:$rd), (ins QFPRegs:$rs2),
1282 [(set f64:$rd, (fpround f128:$rs2))]>,
1283 Requires<[HasHardQuad]>;
1285 // Floating-point Move Instructions, p. 144
1286 def FMOVS : F3_3u<2, 0b110100, 0b000000001,
1287 (outs FPRegs:$rd), (ins FPRegs:$rs2),
1288 "fmovs $rs2, $rd", []>;
1289 def FNEGS : F3_3u<2, 0b110100, 0b000000101,
1290 (outs FPRegs:$rd), (ins FPRegs:$rs2),
1292 [(set f32:$rd, (fneg f32:$rs2))],
1294 def FABSS : F3_3u<2, 0b110100, 0b000001001,
1295 (outs FPRegs:$rd), (ins FPRegs:$rs2),
1297 [(set f32:$rd, (fabs f32:$rs2))],
1301 // Floating-point Square Root Instructions, p.145
1302 // FSQRTS generates an erratum on LEON processors, so by disabling this instruction
1303 // this will be promoted to use FSQRTD with doubles instead.
1304 let Predicates = [HasNoFdivSqrtFix] in
1305 def FSQRTS : F3_3u<2, 0b110100, 0b000101001,
1306 (outs FPRegs:$rd), (ins FPRegs:$rs2),
1308 [(set f32:$rd, (fsqrt f32:$rs2))],
1310 def FSQRTD : F3_3u<2, 0b110100, 0b000101010,
1311 (outs DFPRegs:$rd), (ins DFPRegs:$rs2),
1313 [(set f64:$rd, (fsqrt f64:$rs2))],
1315 def FSQRTQ : F3_3u<2, 0b110100, 0b000101011,
1316 (outs QFPRegs:$rd), (ins QFPRegs:$rs2),
1318 [(set f128:$rd, (fsqrt f128:$rs2))]>,
1319 Requires<[HasHardQuad]>;
1323 // Floating-point Add and Subtract Instructions, p. 146
1324 def FADDS : F3_3<2, 0b110100, 0b001000001,
1325 (outs FPRegs:$rd), (ins FPRegs:$rs1, FPRegs:$rs2),
1326 "fadds $rs1, $rs2, $rd",
1327 [(set f32:$rd, (fadd f32:$rs1, f32:$rs2))],
1328 IIC_fpu_fast_instr>;
1329 def FADDD : F3_3<2, 0b110100, 0b001000010,
1330 (outs DFPRegs:$rd), (ins DFPRegs:$rs1, DFPRegs:$rs2),
1331 "faddd $rs1, $rs2, $rd",
1332 [(set f64:$rd, (fadd f64:$rs1, f64:$rs2))],
1333 IIC_fpu_fast_instr>;
1334 def FADDQ : F3_3<2, 0b110100, 0b001000011,
1335 (outs QFPRegs:$rd), (ins QFPRegs:$rs1, QFPRegs:$rs2),
1336 "faddq $rs1, $rs2, $rd",
1337 [(set f128:$rd, (fadd f128:$rs1, f128:$rs2))]>,
1338 Requires<[HasHardQuad]>;
1340 def FSUBS : F3_3<2, 0b110100, 0b001000101,
1341 (outs FPRegs:$rd), (ins FPRegs:$rs1, FPRegs:$rs2),
1342 "fsubs $rs1, $rs2, $rd",
1343 [(set f32:$rd, (fsub f32:$rs1, f32:$rs2))],
1344 IIC_fpu_fast_instr>;
1345 def FSUBD : F3_3<2, 0b110100, 0b001000110,
1346 (outs DFPRegs:$rd), (ins DFPRegs:$rs1, DFPRegs:$rs2),
1347 "fsubd $rs1, $rs2, $rd",
1348 [(set f64:$rd, (fsub f64:$rs1, f64:$rs2))],
1349 IIC_fpu_fast_instr>;
1350 def FSUBQ : F3_3<2, 0b110100, 0b001000111,
1351 (outs QFPRegs:$rd), (ins QFPRegs:$rs1, QFPRegs:$rs2),
1352 "fsubq $rs1, $rs2, $rd",
1353 [(set f128:$rd, (fsub f128:$rs1, f128:$rs2))]>,
1354 Requires<[HasHardQuad]>;
1357 // Floating-point Multiply and Divide Instructions, p. 147
1358 def FMULS : F3_3<2, 0b110100, 0b001001001,
1359 (outs FPRegs:$rd), (ins FPRegs:$rs1, FPRegs:$rs2),
1360 "fmuls $rs1, $rs2, $rd",
1361 [(set f32:$rd, (fmul f32:$rs1, f32:$rs2))],
1363 Requires<[HasFMULS]>;
1364 def FMULD : F3_3<2, 0b110100, 0b001001010,
1365 (outs DFPRegs:$rd), (ins DFPRegs:$rs1, DFPRegs:$rs2),
1366 "fmuld $rs1, $rs2, $rd",
1367 [(set f64:$rd, (fmul f64:$rs1, f64:$rs2))],
1369 def FMULQ : F3_3<2, 0b110100, 0b001001011,
1370 (outs QFPRegs:$rd), (ins QFPRegs:$rs1, QFPRegs:$rs2),
1371 "fmulq $rs1, $rs2, $rd",
1372 [(set f128:$rd, (fmul f128:$rs1, f128:$rs2))]>,
1373 Requires<[HasHardQuad]>;
1375 def FSMULD : F3_3<2, 0b110100, 0b001101001,
1376 (outs DFPRegs:$rd), (ins FPRegs:$rs1, FPRegs:$rs2),
1377 "fsmuld $rs1, $rs2, $rd",
1378 [(set f64:$rd, (fmul (fpextend f32:$rs1),
1379 (fpextend f32:$rs2)))],
1381 Requires<[HasFSMULD]>;
1382 def FDMULQ : F3_3<2, 0b110100, 0b001101110,
1383 (outs QFPRegs:$rd), (ins DFPRegs:$rs1, DFPRegs:$rs2),
1384 "fdmulq $rs1, $rs2, $rd",
1385 [(set f128:$rd, (fmul (fpextend f64:$rs1),
1386 (fpextend f64:$rs2)))]>,
1387 Requires<[HasHardQuad]>;
1389 // FDIVS generates an erratum on LEON processors, so by disabling this instruction
1390 // this will be promoted to use FDIVD with doubles instead.
1391 def FDIVS : F3_3<2, 0b110100, 0b001001101,
1392 (outs FPRegs:$rd), (ins FPRegs:$rs1, FPRegs:$rs2),
1393 "fdivs $rs1, $rs2, $rd",
1394 [(set f32:$rd, (fdiv f32:$rs1, f32:$rs2))],
1396 def FDIVD : F3_3<2, 0b110100, 0b001001110,
1397 (outs DFPRegs:$rd), (ins DFPRegs:$rs1, DFPRegs:$rs2),
1398 "fdivd $rs1, $rs2, $rd",
1399 [(set f64:$rd, (fdiv f64:$rs1, f64:$rs2))],
1401 def FDIVQ : F3_3<2, 0b110100, 0b001001111,
1402 (outs QFPRegs:$rd), (ins QFPRegs:$rs1, QFPRegs:$rs2),
1403 "fdivq $rs1, $rs2, $rd",
1404 [(set f128:$rd, (fdiv f128:$rs1, f128:$rs2))]>,
1405 Requires<[HasHardQuad]>;
1407 // Floating-point Compare Instructions, p. 148
1408 // Note: the 2nd template arg is different for these guys.
1409 // Note 2: the result of a FCMP is not available until the 2nd cycle
1410 // after the instr is retired, but there is no interlock in Sparc V8.
1411 // This behavior is modeled with a forced noop after the instruction in
1414 let Defs = [FCC0], rd = 0, isCodeGenOnly = 1 in {
1415 def FCMPS : F3_3c<2, 0b110101, 0b001010001,
1416 (outs), (ins FPRegs:$rs1, FPRegs:$rs2),
1418 [(SPcmpfcc f32:$rs1, f32:$rs2)],
1419 IIC_fpu_fast_instr>;
1420 def FCMPD : F3_3c<2, 0b110101, 0b001010010,
1421 (outs), (ins DFPRegs:$rs1, DFPRegs:$rs2),
1423 [(SPcmpfcc f64:$rs1, f64:$rs2)],
1424 IIC_fpu_fast_instr>;
1425 def FCMPQ : F3_3c<2, 0b110101, 0b001010011,
1426 (outs), (ins QFPRegs:$rs1, QFPRegs:$rs2),
1428 [(SPcmpfcc f128:$rs1, f128:$rs2)]>,
1429 Requires<[HasHardQuad]>;
1432 // A.13 Floating-Point Compare (SPARC v9)
1433 // Note that these always write to %fcc0 instead of having its destination
1434 // allocated automatically.
1435 // This avoids complications with the scheduler sometimes wanting to spill
1436 // the contents of an FCC, since SPARC v9 doesn't have facilities to spill
1437 // an individual FCC.
1439 let Predicates = [HasV9], Defs = [FCC0], rd = 0, isCodeGenOnly = 1 in {
1440 def FCMPS_V9 : F3_3c<2, 0b110101, 0b001010001,
1441 (outs), (ins FPRegs:$rs1, FPRegs:$rs2),
1442 "fcmps %fcc0, $rs1, $rs2",
1443 [(SPcmpfccv9 f32:$rs1, f32:$rs2)],
1444 IIC_fpu_fast_instr>;
1445 def FCMPD_V9 : F3_3c<2, 0b110101, 0b001010010,
1446 (outs), (ins DFPRegs:$rs1, DFPRegs:$rs2),
1447 "fcmpd %fcc0, $rs1, $rs2",
1448 [(SPcmpfccv9 f64:$rs1, f64:$rs2)],
1449 IIC_fpu_fast_instr>;
1450 def FCMPQ_V9 : F3_3c<2, 0b110101, 0b001010011,
1451 (outs), (ins QFPRegs:$rs1, QFPRegs:$rs2),
1452 "fcmpq %fcc0, $rs1, $rs2",
1453 [(SPcmpfccv9 f128:$rs1, f128:$rs2)]>,
1454 Requires<[HasHardQuad]>;
1457 //===----------------------------------------------------------------------===//
1458 // Instructions for Thread Local Storage(TLS).
1459 //===----------------------------------------------------------------------===//
1460 let isAsmParserOnly = 1 in {
1461 def TLS_ADDrr : F3_1<2, 0b000000,
1463 (ins IntRegs:$rs1, IntRegs:$rs2, TailRelocSymTLSAdd:$sym),
1464 "add $rs1, $rs2, $rd, $sym",
1466 (tlsadd i32:$rs1, i32:$rs2, tglobaltlsaddr:$sym))]>;
1468 let mayLoad = 1 in {
1469 def TLS_LDrr : F3_1<3, 0b000000,
1471 (ins (MEMrr $rs1, $rs2):$addr, TailRelocSymTLSLoad:$sym),
1472 "ld [$addr], $rd, $sym",
1474 (tlsld ADDRrr:$addr, tglobaltlsaddr:$sym))]>;
1477 let Uses = [O6], isCall = 1, hasDelaySlot = 1 in
1478 def TLS_CALL : InstSP<(outs),
1479 (ins calltarget:$disp, TailRelocSymTLSCall:$sym,
1482 [(tlscall texternalsym:$disp, tglobaltlsaddr:$sym)],
1486 let Inst{29-0} = disp;
1490 //===----------------------------------------------------------------------===//
1491 // Instructions for tail calls.
1492 //===----------------------------------------------------------------------===//
1493 let isCodeGenOnly = 1, isReturn = 1, hasDelaySlot = 1,
1494 isTerminator = 1, isBarrier = 1 in {
1495 def TAIL_CALL : InstSP<(outs), (ins calltarget:$disp, variable_ops),
1497 [(tailcall tglobaladdr:$disp)]> {
1500 let Inst{29-0} = disp;
1504 def : Pat<(tailcall (iPTR texternalsym:$dst)),
1505 (TAIL_CALL texternalsym:$dst)>;
1507 let isCodeGenOnly = 1, isReturn = 1, hasDelaySlot = 1, isTerminator = 1,
1508 isBarrier = 1, rd = 0 in {
1509 def TAIL_CALLri : F3_2<2, 0b111000,
1510 (outs), (ins (MEMri $rs1, $simm13):$addr, variable_ops),
1512 [(tailcall ADDRri:$addr)]>;
1515 //===----------------------------------------------------------------------===//
1517 //===----------------------------------------------------------------------===//
1519 // V9 Conditional Moves.
1520 let Predicates = [HasV9], Constraints = "$f = $rd" in {
1521 // Move Integer Register on Condition (MOVcc) p. 194 of the V9 manual.
1522 let Uses = [ICC], intcc = 1, cc = 0b00 in {
1524 : F4_1<0b101100, (outs IntRegs:$rd),
1525 (ins IntRegs:$rs2, IntRegs:$f, CCOp:$cond),
1526 "mov$cond %icc, $rs2, $rd",
1527 [(set i32:$rd, (SPselecticc i32:$rs2, i32:$f, imm:$cond))]>;
1530 : F4_2<0b101100, (outs IntRegs:$rd),
1531 (ins i32imm:$simm11, IntRegs:$f, CCOp:$cond),
1532 "mov$cond %icc, $simm11, $rd",
1534 (SPselecticc simm11:$simm11, i32:$f, imm:$cond))]>;
1537 let Uses = [FCC0], intcc = 0, cc = 0b00 in {
1539 : F4_1<0b101100, (outs IntRegs:$rd),
1540 (ins IntRegs:$rs2, IntRegs:$f, CCOp:$cond),
1541 "mov$cond %fcc0, $rs2, $rd",
1542 [(set i32:$rd, (SPselectfcc i32:$rs2, i32:$f, imm:$cond))]>;
1544 : F4_2<0b101100, (outs IntRegs:$rd),
1545 (ins i32imm:$simm11, IntRegs:$f, CCOp:$cond),
1546 "mov$cond %fcc0, $simm11, $rd",
1548 (SPselectfcc simm11:$simm11, i32:$f, imm:$cond))]>;
1551 let Uses = [ICC], intcc = 1, opf_cc = 0b00 in {
1553 : F4_3<0b110101, 0b000001, (outs FPRegs:$rd),
1554 (ins FPRegs:$rs2, FPRegs:$f, CCOp:$cond),
1555 "fmovs$cond %icc, $rs2, $rd",
1556 [(set f32:$rd, (SPselecticc f32:$rs2, f32:$f, imm:$cond))]>;
1558 : F4_3<0b110101, 0b000010, (outs DFPRegs:$rd),
1559 (ins DFPRegs:$rs2, DFPRegs:$f, CCOp:$cond),
1560 "fmovd$cond %icc, $rs2, $rd",
1561 [(set f64:$rd, (SPselecticc f64:$rs2, f64:$f, imm:$cond))]>;
1562 let Predicates = [HasV9, HasHardQuad] in
1564 : F4_3<0b110101, 0b000011, (outs QFPRegs:$rd),
1565 (ins QFPRegs:$rs2, QFPRegs:$f, CCOp:$cond),
1566 "fmovq$cond %icc, $rs2, $rd",
1567 [(set f128:$rd, (SPselecticc f128:$rs2, f128:$f, imm:$cond))]>;
1570 let Uses = [FCC0], intcc = 0, opf_cc = 0b00 in {
1572 : F4_3<0b110101, 0b000001, (outs FPRegs:$rd),
1573 (ins FPRegs:$rs2, FPRegs:$f, CCOp:$cond),
1574 "fmovs$cond %fcc0, $rs2, $rd",
1575 [(set f32:$rd, (SPselectfcc f32:$rs2, f32:$f, imm:$cond))]>;
1577 : F4_3<0b110101, 0b000010, (outs DFPRegs:$rd),
1578 (ins DFPRegs:$rs2, DFPRegs:$f, CCOp:$cond),
1579 "fmovd$cond %fcc0, $rs2, $rd",
1580 [(set f64:$rd, (SPselectfcc f64:$rs2, f64:$f, imm:$cond))]>;
1581 let Predicates = [HasV9, HasHardQuad] in
1583 : F4_3<0b110101, 0b000011, (outs QFPRegs:$rd),
1584 (ins QFPRegs:$rs2, QFPRegs:$f, CCOp:$cond),
1585 "fmovq$cond %fcc0, $rs2, $rd",
1586 [(set f128:$rd, (SPselectfcc f128:$rs2, f128:$f, imm:$cond))]>;
1591 // Floating-Point Move Instructions, p. 164 of the V9 manual.
1592 let Predicates = [HasV9] in {
1593 def FMOVD : F3_3u<2, 0b110100, 0b000000010,
1594 (outs DFPRegs:$rd), (ins DFPRegs:$rs2),
1595 "fmovd $rs2, $rd", []>;
1596 let Predicates = [HasV9, HasHardQuad] in
1597 def FMOVQ : F3_3u<2, 0b110100, 0b000000011,
1598 (outs QFPRegs:$rd), (ins QFPRegs:$rs2),
1599 "fmovq $rs2, $rd", []>;
1600 def FNEGD : F3_3u<2, 0b110100, 0b000000110,
1601 (outs DFPRegs:$rd), (ins DFPRegs:$rs2),
1603 [(set f64:$rd, (fneg f64:$rs2))]>;
1604 let Predicates = [HasV9, HasHardQuad] in
1605 def FNEGQ : F3_3u<2, 0b110100, 0b000000111,
1606 (outs QFPRegs:$rd), (ins QFPRegs:$rs2),
1608 [(set f128:$rd, (fneg f128:$rs2))]>;
1609 def FABSD : F3_3u<2, 0b110100, 0b000001010,
1610 (outs DFPRegs:$rd), (ins DFPRegs:$rs2),
1612 [(set f64:$rd, (fabs f64:$rs2))]>;
1613 let Predicates = [HasV9, HasHardQuad] in
1614 def FABSQ : F3_3u<2, 0b110100, 0b000001011,
1615 (outs QFPRegs:$rd), (ins QFPRegs:$rs2),
1617 [(set f128:$rd, (fabs f128:$rs2))]>;
1620 // Floating-point compare instruction with %fcc0-%fcc3.
1621 def V9FCMPS : F3_3c<2, 0b110101, 0b001010001,
1622 (outs FCCRegs:$rd), (ins FPRegs:$rs1, FPRegs:$rs2),
1623 "fcmps $rd, $rs1, $rs2", []>;
1624 def V9FCMPD : F3_3c<2, 0b110101, 0b001010010,
1625 (outs FCCRegs:$rd), (ins DFPRegs:$rs1, DFPRegs:$rs2),
1626 "fcmpd $rd, $rs1, $rs2", []>;
1627 def V9FCMPQ : F3_3c<2, 0b110101, 0b001010011,
1628 (outs FCCRegs:$rd), (ins QFPRegs:$rs1, QFPRegs:$rs2),
1629 "fcmpq $rd, $rs1, $rs2", []>,
1630 Requires<[HasHardQuad]>;
1632 let hasSideEffects = 1 in {
1633 def V9FCMPES : F3_3c<2, 0b110101, 0b001010101,
1634 (outs FCCRegs:$rd), (ins FPRegs:$rs1, FPRegs:$rs2),
1635 "fcmpes $rd, $rs1, $rs2", []>;
1636 def V9FCMPED : F3_3c<2, 0b110101, 0b001010110,
1637 (outs FCCRegs:$rd), (ins DFPRegs:$rs1, DFPRegs:$rs2),
1638 "fcmped $rd, $rs1, $rs2", []>;
1639 def V9FCMPEQ : F3_3c<2, 0b110101, 0b001010111,
1640 (outs FCCRegs:$rd), (ins QFPRegs:$rs1, QFPRegs:$rs2),
1641 "fcmpeq $rd, $rs1, $rs2", []>,
1642 Requires<[HasHardQuad]>;
1645 // Floating point conditional move instrucitons with %fcc0-%fcc3.
1646 let Predicates = [HasV9] in {
1647 let Constraints = "$f = $rd", intcc = 0 in {
1649 : F4_1<0b101100, (outs IntRegs:$rd),
1650 (ins FCCRegs:$cc, IntRegs:$rs2, IntRegs:$f, CCOp:$cond),
1651 "mov$cond $cc, $rs2, $rd", []>;
1653 : F4_2<0b101100, (outs IntRegs:$rd),
1654 (ins FCCRegs:$cc, i32imm:$simm11, IntRegs:$f, CCOp:$cond),
1655 "mov$cond $cc, $simm11, $rd", []>;
1657 : F4_3<0b110101, 0b000001, (outs FPRegs:$rd),
1658 (ins FCCRegs:$opf_cc, FPRegs:$rs2, FPRegs:$f, CCOp:$cond),
1659 "fmovs$cond $opf_cc, $rs2, $rd", []>;
1661 : F4_3<0b110101, 0b000010, (outs DFPRegs:$rd),
1662 (ins FCCRegs:$opf_cc, DFPRegs:$rs2, DFPRegs:$f, CCOp:$cond),
1663 "fmovd$cond $opf_cc, $rs2, $rd", []>;
1664 let Predicates = [HasV9, HasHardQuad] in
1666 : F4_3<0b110101, 0b000011, (outs QFPRegs:$rd),
1667 (ins FCCRegs:$opf_cc, QFPRegs:$rs2, QFPRegs:$f, CCOp:$cond),
1668 "fmovq$cond $opf_cc, $rs2, $rd", []>;
1669 } // Constraints = "$f = $rd", ...
1670 } // let Predicates = [hasV9]
1673 // POPCrr - This does a ctpop of a 64-bit register. As such, we have to clear
1674 // the top 32-bits before using it. To do this clearing, we use a SRLri X,0.
1676 def POPCrr : F3_1<2, 0b101110,
1677 (outs IntRegs:$rd), (ins IntRegs:$rs2),
1678 "popc $rs2, $rd", []>, Requires<[HasV9]>;
1679 def : Pat<(i32 (ctpop i32:$src)),
1680 (POPCrr (SRLri $src, 0))>;
1682 let Predicates = [HasV9], hasSideEffects = 1, rd = 0, rs1 = 0b01111 in
1683 def MEMBARi : F3_2<2, 0b101000, (outs), (ins MembarTag:$simm13),
1684 "membar $simm13", []>;
1686 let Predicates = [HasV9], rd = 15, rs1 = 0b00000 in
1687 def SIR: F3_2<2, 0b110000, (outs),
1688 (ins simm13Op:$simm13),
1691 // CASA supported on all V9, some LEON3 and all LEON4 processors.
1692 let Predicates = [HasCASA], Constraints = "$swap = $rd" in
1693 def CASArr: F3_1_asi<3, 0b111100,
1694 (outs IntRegs:$rd), (ins IntRegs:$rs1, IntRegs:$rs2,
1695 IntRegs:$swap, ASITag:$asi),
1696 "casa [$rs1] $asi, $rs2, $rd", []>;
1698 // On the other hand, CASA that takes its ASI from a register
1699 // is only supported on V9 processors.
1700 let Predicates = [HasV9], Uses = [ASR3], Constraints = "$swap = $rd" in
1701 def CASAri: F3_1_cas_asi<3, 0b111100,
1702 (outs IntRegs:$rd), (ins IntRegs:$rs1, IntRegs:$rs2,
1704 "casa [$rs1] %asi, $rs2, $rd", []>;
1706 // TODO: Add DAG sequence to lower these instructions. Currently, only provided
1707 // as inline assembler-supported instructions.
1708 let Predicates = [HasUMAC_SMAC], Defs = [Y, ASR18], Uses = [Y, ASR18] in {
1709 def SMACrr : F3_1<2, 0b111111,
1710 (outs IntRegs:$rd), (ins IntRegs:$rs1, IntRegs:$rs2, ASRRegs:$asr18),
1711 "smac $rs1, $rs2, $rd",
1714 def SMACri : F3_2<2, 0b111111,
1715 (outs IntRegs:$rd), (ins IntRegs:$rs1, simm13Op:$simm13, ASRRegs:$asr18),
1716 "smac $rs1, $simm13, $rd",
1719 def UMACrr : F3_1<2, 0b111110,
1720 (outs IntRegs:$rd), (ins IntRegs:$rs1, IntRegs:$rs2, ASRRegs:$asr18),
1721 "umac $rs1, $rs2, $rd",
1724 def UMACri : F3_2<2, 0b111110,
1725 (outs IntRegs:$rd), (ins IntRegs:$rs1, simm13Op:$simm13, ASRRegs:$asr18),
1726 "umac $rs1, $simm13, $rd",
1730 // The partial write WRPSR instruction has a non-zero destination
1731 // register value to separate it from the standard instruction.
1732 let Predicates = [HasPWRPSR], Defs = [PSR], rd=1 in {
1733 def PWRPSRrr : F3_1<2, 0b110001,
1734 (outs), (ins IntRegs:$rs1, IntRegs:$rs2),
1735 "pwr $rs1, $rs2, %psr", []>;
1736 def PWRPSRri : F3_2<2, 0b110001,
1737 (outs), (ins IntRegs:$rs1, simm13Op:$simm13),
1738 "pwr $rs1, $simm13, %psr", []>;
1741 let Defs = [ICC] in {
1742 defm TADDCC : F3_12np<"taddcc", 0b100000>;
1743 defm TSUBCC : F3_12np<"tsubcc", 0b100001>;
1745 let hasSideEffects = 1 in {
1746 defm TADDCCTV : F3_12np<"taddcctv", 0b100010>;
1747 defm TSUBCCTV : F3_12np<"tsubcctv", 0b100011>;
1751 // Section A.11 - DONE and RETRY
1752 // Section A.47 - SAVED and RESTORED
1753 let Predicates = [HasV9], rs1 = 0, rs2 = 0 in {
1755 def DONE : F3_1<2, 0b111110, (outs), (ins), "done", []>;
1758 def RETRY : F3_1<2, 0b111110, (outs), (ins), "retry", []>;
1761 def SAVED : F3_1<2, 0b110001, (outs), (ins), "saved", []>;
1764 def RESTORED : F3_1<2, 0b110001, (outs), (ins), "restored", []>;
1767 // Section A.42 - Prefetch Data
1768 let Predicates = [HasV9] in {
1769 def PREFETCHr : F3_1<3, 0b101101,
1770 (outs), (ins (MEMrr $rs1, $rs2):$addr, shift_imm5:$rd),
1771 "prefetch [$addr], $rd", []>;
1772 def PREFETCHi : F3_2<3, 0b101101,
1773 (outs), (ins (MEMri $rs1, $simm13):$addr, shift_imm5:$rd),
1774 "prefetch [$addr], $rd", []>;
1779 // Section A.43 - Read Privileged Register Instructions
1780 let Predicates = [HasV9] in {
1782 def RDPR : F3_1<2, 0b101010,
1783 (outs IntRegs:$rd), (ins PRRegs:$rs1),
1784 "rdpr $rs1, $rd", []>;
1786 // Special case %fq as the register is also used in V8
1787 // (albeit with different instructions and encoding).
1788 // This allows us to reuse the register definition and
1789 // the "%fq" designation while giving it a different encoding.
1790 let Uses = [FQ], rs1 = 15, rs2 = 0 in
1791 def RDFQ : F3_1<2, 0b101010,
1792 (outs IntRegs:$rd), (ins),
1793 "rdpr %fq, $rd", []>;
1796 // Section A.62 - Write Privileged Register Instructions
1797 let Predicates = [HasV9] in {
1798 def WRPRrr : F3_1<2, 0b110010,
1799 (outs PRRegs:$rd), (ins IntRegs:$rs1, IntRegs:$rs2),
1800 "wrpr $rs1, $rs2, $rd", []>;
1801 def WRPRri : F3_2<2, 0b110010,
1802 (outs PRRegs:$rd), (ins IntRegs:$rs1, simm13Op:$simm13),
1803 "wrpr $rs1, $simm13, $rd", []>;
1806 //===----------------------------------------------------------------------===//
1807 // Non-Instruction Patterns
1808 //===----------------------------------------------------------------------===//
1811 def : Pat<(i32 0), (COPY (i32 G0))>;
1812 // Small immediates.
1813 def : Pat<(i32 simm13:$val),
1814 (ORri (i32 G0), imm:$val)>;
1815 // Arbitrary immediates.
1816 def : Pat<(i32 imm:$val),
1817 (ORri (SETHIi (HI22 imm:$val)), (LO10 imm:$val))>;
1820 def to_tframeindex : SDNodeXForm<frameindex, [{
1821 return CurDAG->getTargetFrameIndex(N->getIndex(), N->getValueType(0));
1823 def : Pat<(i32 (frameindex:$ptr)), (ADDri (i32 (to_tframeindex $ptr)), (i32 0))>;
1824 def : Pat<(i64 (frameindex:$ptr)), (ADDri (i64 (to_tframeindex $ptr)), (i64 0))>;
1826 // Global addresses, constant pool entries
1827 let Predicates = [Is32Bit] in {
1829 def : Pat<(SPhi tglobaladdr:$in), (SETHIi tglobaladdr:$in)>;
1830 def : Pat<(SPlo tglobaladdr:$in), (ORri (i32 G0), tglobaladdr:$in)>;
1831 def : Pat<(SPhi tconstpool:$in), (SETHIi tconstpool:$in)>;
1832 def : Pat<(SPlo tconstpool:$in), (ORri (i32 G0), tconstpool:$in)>;
1834 // GlobalTLS addresses
1835 def : Pat<(SPhi tglobaltlsaddr:$in), (SETHIi tglobaltlsaddr:$in)>;
1836 def : Pat<(SPlo tglobaltlsaddr:$in), (ORri (i32 G0), tglobaltlsaddr:$in)>;
1837 def : Pat<(add (SPhi tglobaltlsaddr:$in1), (SPlo tglobaltlsaddr:$in2)),
1838 (ADDri (SETHIi tglobaltlsaddr:$in1), (tglobaltlsaddr:$in2))>;
1839 def : Pat<(xor (SPhi tglobaltlsaddr:$in1), (SPlo tglobaltlsaddr:$in2)),
1840 (XORri (SETHIi tglobaltlsaddr:$in1), (tglobaltlsaddr:$in2))>;
1843 def : Pat<(SPhi tblockaddress:$in), (SETHIi tblockaddress:$in)>;
1844 def : Pat<(SPlo tblockaddress:$in), (ORri (i32 G0), tblockaddress:$in)>;
1846 // Add reg, lo. This is used when taking the addr of a global/constpool entry.
1847 def : Pat<(add iPTR:$r, (SPlo tglobaladdr:$in)), (ADDri $r, tglobaladdr:$in)>;
1848 def : Pat<(add iPTR:$r, (SPlo tconstpool:$in)), (ADDri $r, tconstpool:$in)>;
1849 def : Pat<(add iPTR:$r, (SPlo tblockaddress:$in)),
1850 (ADDri $r, tblockaddress:$in)>;
1854 def : Pat<(call tglobaladdr:$dst),
1855 (CALL tglobaladdr:$dst)>;
1856 def : Pat<(call texternalsym:$dst),
1857 (CALL texternalsym:$dst)>;
1859 // Map integer extload's to zextloads.
1860 def : Pat<(i32 (extloadi1 ADDRrr:$src)), (LDUBrr ADDRrr:$src)>;
1861 def : Pat<(i32 (extloadi1 ADDRri:$src)), (LDUBri ADDRri:$src)>;
1862 def : Pat<(i32 (extloadi8 ADDRrr:$src)), (LDUBrr ADDRrr:$src)>;
1863 def : Pat<(i32 (extloadi8 ADDRri:$src)), (LDUBri ADDRri:$src)>;
1864 def : Pat<(i32 (extloadi16 ADDRrr:$src)), (LDUHrr ADDRrr:$src)>;
1865 def : Pat<(i32 (extloadi16 ADDRri:$src)), (LDUHri ADDRri:$src)>;
1867 // zextload bool -> zextload byte
1868 def : Pat<(i32 (zextloadi1 ADDRrr:$src)), (LDUBrr ADDRrr:$src)>;
1869 def : Pat<(i32 (zextloadi1 ADDRri:$src)), (LDUBri ADDRri:$src)>;
1871 // store 0, addr -> store %g0, addr
1872 def : Pat<(store (i32 0), ADDRrr:$dst), (STrr ADDRrr:$dst, (i32 G0))>;
1873 def : Pat<(store (i32 0), ADDRri:$dst), (STri ADDRri:$dst, (i32 G0))>;
1875 // store bar for all atomic_fence in V8.
1876 let Predicates = [HasNoV9] in
1877 def : Pat<(atomic_fence timm, timm), (STBAR)>;
1879 let Predicates = [HasV9] in
1880 def : Pat<(atomic_fence timm, timm), (MEMBARi 0xf)>;
1882 // atomic_load addr -> load addr
1883 def : Pat<(i32 (atomic_load_8 ADDRrr:$src)), (LDUBrr ADDRrr:$src)>;
1884 def : Pat<(i32 (atomic_load_8 ADDRri:$src)), (LDUBri ADDRri:$src)>;
1885 def : Pat<(i32 (atomic_load_16 ADDRrr:$src)), (LDUHrr ADDRrr:$src)>;
1886 def : Pat<(i32 (atomic_load_16 ADDRri:$src)), (LDUHri ADDRri:$src)>;
1887 def : Pat<(i32 (atomic_load_32 ADDRrr:$src)), (LDrr ADDRrr:$src)>;
1888 def : Pat<(i32 (atomic_load_32 ADDRri:$src)), (LDri ADDRri:$src)>;
1890 // atomic_store val, addr -> store val, addr
1891 def : Pat<(atomic_store_8 i32:$val, ADDRrr:$dst), (STBrr ADDRrr:$dst, $val)>;
1892 def : Pat<(atomic_store_8 i32:$val, ADDRri:$dst), (STBri ADDRri:$dst, $val)>;
1893 def : Pat<(atomic_store_16 i32:$val, ADDRrr:$dst), (STHrr ADDRrr:$dst, $val)>;
1894 def : Pat<(atomic_store_16 i32:$val, ADDRri:$dst), (STHri ADDRri:$dst, $val)>;
1895 def : Pat<(atomic_store_32 i32:$val, ADDRrr:$dst), (STrr ADDRrr:$dst, $val)>;
1896 def : Pat<(atomic_store_32 i32:$val, ADDRri:$dst), (STri ADDRri:$dst, $val)>;
1898 let Predicates = [HasV9] in
1899 def : Pat<(atomic_cmp_swap_32 iPTR:$rs1, i32:$rs2, i32:$swap),
1900 (CASArr $rs1, $rs2, $swap, 0x80)>;
1902 // Same pattern as CASArr above, but with a different ASI.
1903 let Predicates = [HasLeonCASA] in
1904 def : Pat<(atomic_cmp_swap_32 iPTR:$rs1, i32:$rs2, i32:$swap),
1905 (CASArr $rs1, $rs2, $swap, 0x0A)>;
1907 // A register pair with zero upper half.
1908 // The upper part is done with ORrr instead of `COPY G0`
1909 // or a normal register copy, since `COPY G0`s in that place
1910 // will be converted into `COPY G0_G1` later on, which is not
1911 // what we want in this case.
1912 def : Pat<(build_vector (i32 0), (i32 IntRegs:$a2)),
1913 (INSERT_SUBREG (INSERT_SUBREG (v2i32 (IMPLICIT_DEF)),
1914 (ORrr (i32 G0), (i32 G0)), sub_even),
1915 (i32 IntRegs:$a2), sub_odd)>;
1918 def : Pat<(extractelt (v2i32 IntPair:$Rn), 0),
1919 (i32 (EXTRACT_SUBREG IntPair:$Rn, sub_even))>;
1920 def : Pat<(extractelt (v2i32 IntPair:$Rn), 1),
1921 (i32 (EXTRACT_SUBREG IntPair:$Rn, sub_odd))>;
1924 def : Pat<(build_vector (i32 IntRegs:$a1), (i32 IntRegs:$a2)),
1926 (INSERT_SUBREG (v2i32 (IMPLICIT_DEF)), (i32 IntRegs:$a1), sub_even),
1927 (i32 IntRegs:$a2), sub_odd)>;
1930 include "SparcInstr64Bit.td"
1931 include "SparcInstrVIS.td"
1932 include "SparcInstrAliases.td"