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<"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<"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<"FeatureVIS">;
45 def HasVIS2 : Predicate<"Subtarget->isVIS2()">,
46 AssemblerPredicate<"FeatureVIS2">;
47 def HasVIS3 : Predicate<"Subtarget->isVIS3()">,
48 AssemblerPredicate<"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 CASA
56 def HasLeonCASA : Predicate<"Subtarget->hasLeonCasa()">;
58 // HasPWRPSR - This is true when the target processor supports partial
59 // writes to the PSR register that only affects the ET field.
60 def HasPWRPSR : Predicate<"Subtarget->hasPWRPSR()">,
61 AssemblerPredicate<"FeaturePWRPSR">;
63 // HasUMAC_SMAC - This is true when the target processor supports the
64 // UMAC and SMAC instructions
65 def HasUMAC_SMAC : Predicate<"Subtarget->hasUmacSmac()">;
67 def HasNoFdivSqrtFix : Predicate<"!Subtarget->fixAllFDIVSQRT()">;
68 def HasFMULS : Predicate<"!Subtarget->hasNoFMULS()">;
69 def HasFSMULD : Predicate<"!Subtarget->hasNoFSMULD()">;
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.
75 def UseDeprecatedInsts : Predicate<"Subtarget->useDeprecatedV8Instructions()">;
77 //===----------------------------------------------------------------------===//
78 // Instruction Pattern Stuff
79 //===----------------------------------------------------------------------===//
81 def simm11 : PatLeaf<(imm), [{ return isInt<11>(N->getSExtValue()); }]>;
83 def simm13 : PatLeaf<(imm), [{ return isInt<13>(N->getSExtValue()); }]>;
85 def LO10 : SDNodeXForm<imm, [{
86 return CurDAG->getTargetConstant((unsigned)N->getZExtValue() & 1023, SDLoc(N),
90 def HI22 : SDNodeXForm<imm, [{
91 // Transformation function: shift the immediate value down into the low bits.
92 return CurDAG->getTargetConstant((unsigned)N->getZExtValue() >> 10, SDLoc(N),
96 // Return the complement of a HI22 immediate value.
97 def HI22_not : SDNodeXForm<imm, [{
98 return CurDAG->getTargetConstant(~(unsigned)N->getZExtValue() >> 10, SDLoc(N),
102 def SETHIimm : PatLeaf<(imm), [{
103 return isShiftedUInt<22, 10>(N->getZExtValue());
106 // The N->hasOneUse() prevents the immediate from being instantiated in both
107 // normal and complement form.
108 def SETHIimm_not : PatLeaf<(i32 imm), [{
109 return N->hasOneUse() && isShiftedUInt<22, 10>(~(unsigned)N->getZExtValue());
113 def ADDRrr : ComplexPattern<iPTR, 2, "SelectADDRrr", [], []>;
114 def ADDRri : ComplexPattern<iPTR, 2, "SelectADDRri", [frameindex], []>;
117 def SparcMEMrrAsmOperand : AsmOperandClass {
119 let ParserMethod = "parseMEMOperand";
122 def SparcMEMriAsmOperand : AsmOperandClass {
124 let ParserMethod = "parseMEMOperand";
127 def MEMrr : Operand<iPTR> {
128 let PrintMethod = "printMemOperand";
129 let MIOperandInfo = (ops ptr_rc, ptr_rc);
130 let ParserMatchClass = SparcMEMrrAsmOperand;
132 def MEMri : Operand<iPTR> {
133 let PrintMethod = "printMemOperand";
134 let MIOperandInfo = (ops ptr_rc, i32imm);
135 let ParserMatchClass = SparcMEMriAsmOperand;
138 def TLSSym : Operand<iPTR>;
140 def SparcMembarTagAsmOperand : AsmOperandClass {
141 let Name = "MembarTag";
142 let ParserMethod = "parseMembarTag";
145 def MembarTag : Operand<i32> {
146 let PrintMethod = "printMembarTag";
147 let ParserMatchClass = SparcMembarTagAsmOperand;
150 // Branch targets have OtherVT type.
151 def brtarget : Operand<OtherVT> {
152 let EncoderMethod = "getBranchTargetOpValue";
155 def bprtarget : Operand<OtherVT> {
156 let EncoderMethod = "getBranchPredTargetOpValue";
159 def bprtarget16 : Operand<OtherVT> {
160 let EncoderMethod = "getBranchOnRegTargetOpValue";
163 def calltarget : Operand<i32> {
164 let EncoderMethod = "getCallTargetOpValue";
165 let DecoderMethod = "DecodeCall";
168 def simm13Op : Operand<i32> {
169 let DecoderMethod = "DecodeSIMM13";
172 // Operand for printing out a condition code.
173 let PrintMethod = "printCCOperand" in
174 def CCOp : Operand<i32>;
177 SDTypeProfile<0, 2, [SDTCisInt<0>, SDTCisSameAs<0, 1>]>;
179 SDTypeProfile<0, 2, [SDTCisFP<0>, SDTCisSameAs<0, 1>]>;
181 SDTypeProfile<0, 2, [SDTCisVT<0, OtherVT>, SDTCisVT<1, i32>]>;
183 SDTypeProfile<1, 3, [SDTCisSameAs<0, 1>, SDTCisSameAs<1, 2>, SDTCisVT<3, i32>]>;
185 SDTypeProfile<1, 1, [SDTCisVT<0, f32>, SDTCisFP<1>]>;
187 SDTypeProfile<1, 1, [SDTCisFP<0>, SDTCisVT<1, f32>]>;
189 SDTypeProfile<1, 1, [SDTCisVT<0, f64>, SDTCisFP<1>]>;
191 SDTypeProfile<1, 1, [SDTCisFP<0>, SDTCisVT<1, f64>]>;
194 SDTypeProfile<1, 3, [SDTCisInt<0>, SDTCisSameAs<0, 1>, SDTCisPtrTy<2>]>;
196 SDTypeProfile<1, 2, [SDTCisPtrTy<0>, SDTCisPtrTy<1>]>;
198 def SPcmpicc : SDNode<"SPISD::CMPICC", SDTSPcmpicc, [SDNPOutGlue]>;
199 def SPcmpfcc : SDNode<"SPISD::CMPFCC", SDTSPcmpfcc, [SDNPOutGlue]>;
200 def SPbricc : SDNode<"SPISD::BRICC", SDTSPbrcc, [SDNPHasChain, SDNPInGlue]>;
201 def SPbrxcc : SDNode<"SPISD::BRXCC", SDTSPbrcc, [SDNPHasChain, SDNPInGlue]>;
202 def SPbrfcc : SDNode<"SPISD::BRFCC", SDTSPbrcc, [SDNPHasChain, SDNPInGlue]>;
204 def SPhi : SDNode<"SPISD::Hi", SDTIntUnaryOp>;
205 def SPlo : SDNode<"SPISD::Lo", SDTIntUnaryOp>;
207 def SPftoi : SDNode<"SPISD::FTOI", SDTSPFTOI>;
208 def SPitof : SDNode<"SPISD::ITOF", SDTSPITOF>;
209 def SPftox : SDNode<"SPISD::FTOX", SDTSPFTOX>;
210 def SPxtof : SDNode<"SPISD::XTOF", SDTSPXTOF>;
212 def SPselecticc : SDNode<"SPISD::SELECT_ICC", SDTSPselectcc, [SDNPInGlue]>;
213 def SPselectxcc : SDNode<"SPISD::SELECT_XCC", SDTSPselectcc, [SDNPInGlue]>;
214 def SPselectfcc : SDNode<"SPISD::SELECT_FCC", SDTSPselectcc, [SDNPInGlue]>;
216 // These are target-independent nodes, but have target-specific formats.
217 def SDT_SPCallSeqStart : SDCallSeqStart<[ SDTCisVT<0, i32>,
219 def SDT_SPCallSeqEnd : SDCallSeqEnd<[ SDTCisVT<0, i32>,
222 def callseq_start : SDNode<"ISD::CALLSEQ_START", SDT_SPCallSeqStart,
223 [SDNPHasChain, SDNPOutGlue]>;
224 def callseq_end : SDNode<"ISD::CALLSEQ_END", SDT_SPCallSeqEnd,
225 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue]>;
227 def SDT_SPCall : SDTypeProfile<0, -1, [SDTCisVT<0, i32>]>;
228 def call : SDNode<"SPISD::CALL", SDT_SPCall,
229 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
232 def SDT_SPRet : SDTypeProfile<0, 1, [SDTCisVT<0, i32>]>;
233 def retflag : SDNode<"SPISD::RET_FLAG", SDT_SPRet,
234 [SDNPHasChain, SDNPOptInGlue, SDNPVariadic]>;
236 def flushw : SDNode<"SPISD::FLUSHW", SDTNone,
237 [SDNPHasChain, SDNPSideEffect, SDNPMayStore]>;
239 def tlsadd : SDNode<"SPISD::TLS_ADD", SDTSPtlsadd>;
240 def tlsld : SDNode<"SPISD::TLS_LD", SDTSPtlsld>;
241 def tlscall : SDNode<"SPISD::TLS_CALL", SDT_SPCall,
242 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
245 def getPCX : Operand<iPTR> {
246 let PrintMethod = "printGetPCX";
249 //===----------------------------------------------------------------------===//
250 // SPARC Flag Conditions
251 //===----------------------------------------------------------------------===//
253 // Note that these values must be kept in sync with the CCOp::CondCode enum
255 class ICC_VAL<int N> : PatLeaf<(i32 N)>;
256 def ICC_NE : ICC_VAL< 9>; // Not Equal
257 def ICC_E : ICC_VAL< 1>; // Equal
258 def ICC_G : ICC_VAL<10>; // Greater
259 def ICC_LE : ICC_VAL< 2>; // Less or Equal
260 def ICC_GE : ICC_VAL<11>; // Greater or Equal
261 def ICC_L : ICC_VAL< 3>; // Less
262 def ICC_GU : ICC_VAL<12>; // Greater Unsigned
263 def ICC_LEU : ICC_VAL< 4>; // Less or Equal Unsigned
264 def ICC_CC : ICC_VAL<13>; // Carry Clear/Great or Equal Unsigned
265 def ICC_CS : ICC_VAL< 5>; // Carry Set/Less Unsigned
266 def ICC_POS : ICC_VAL<14>; // Positive
267 def ICC_NEG : ICC_VAL< 6>; // Negative
268 def ICC_VC : ICC_VAL<15>; // Overflow Clear
269 def ICC_VS : ICC_VAL< 7>; // Overflow Set
271 class FCC_VAL<int N> : PatLeaf<(i32 N)>;
272 def FCC_U : FCC_VAL<23>; // Unordered
273 def FCC_G : FCC_VAL<22>; // Greater
274 def FCC_UG : FCC_VAL<21>; // Unordered or Greater
275 def FCC_L : FCC_VAL<20>; // Less
276 def FCC_UL : FCC_VAL<19>; // Unordered or Less
277 def FCC_LG : FCC_VAL<18>; // Less or Greater
278 def FCC_NE : FCC_VAL<17>; // Not Equal
279 def FCC_E : FCC_VAL<25>; // Equal
280 def FCC_UE : FCC_VAL<26>; // Unordered or Equal
281 def FCC_GE : FCC_VAL<27>; // Greater or Equal
282 def FCC_UGE : FCC_VAL<28>; // Unordered or Greater or Equal
283 def FCC_LE : FCC_VAL<29>; // Less or Equal
284 def FCC_ULE : FCC_VAL<30>; // Unordered or Less or Equal
285 def FCC_O : FCC_VAL<31>; // Ordered
287 class CPCC_VAL<int N> : PatLeaf<(i32 N)>;
288 def CPCC_3 : CPCC_VAL<39>; // 3
289 def CPCC_2 : CPCC_VAL<38>; // 2
290 def CPCC_23 : CPCC_VAL<37>; // 2 or 3
291 def CPCC_1 : CPCC_VAL<36>; // 1
292 def CPCC_13 : CPCC_VAL<35>; // 1 or 3
293 def CPCC_12 : CPCC_VAL<34>; // 1 or 2
294 def CPCC_123 : CPCC_VAL<33>; // 1 or 2 or 3
295 def CPCC_0 : CPCC_VAL<41>; // 0
296 def CPCC_03 : CPCC_VAL<42>; // 0 or 3
297 def CPCC_02 : CPCC_VAL<43>; // 0 or 2
298 def CPCC_023 : CPCC_VAL<44>; // 0 or 2 or 3
299 def CPCC_01 : CPCC_VAL<45>; // 0 or 1
300 def CPCC_013 : CPCC_VAL<46>; // 0 or 1 or 3
301 def CPCC_012 : CPCC_VAL<47>; // 0 or 1 or 2
303 //===----------------------------------------------------------------------===//
304 // Instruction Class Templates
305 //===----------------------------------------------------------------------===//
307 /// F3_12 multiclass - Define a normal F3_1/F3_2 pattern in one shot.
308 multiclass F3_12<string OpcStr, bits<6> Op3Val, SDNode OpNode,
309 RegisterClass RC, ValueType Ty, Operand immOp,
310 InstrItinClass itin = IIC_iu_instr> {
311 def rr : F3_1<2, Op3Val,
312 (outs RC:$rd), (ins RC:$rs1, RC:$rs2),
313 !strconcat(OpcStr, " $rs1, $rs2, $rd"),
314 [(set Ty:$rd, (OpNode Ty:$rs1, Ty:$rs2))],
316 def ri : F3_2<2, Op3Val,
317 (outs RC:$rd), (ins RC:$rs1, immOp:$simm13),
318 !strconcat(OpcStr, " $rs1, $simm13, $rd"),
319 [(set Ty:$rd, (OpNode Ty:$rs1, (Ty simm13:$simm13)))],
323 /// F3_12np multiclass - Define a normal F3_1/F3_2 pattern in one shot, with no
325 multiclass F3_12np<string OpcStr, bits<6> Op3Val, InstrItinClass itin = IIC_iu_instr> {
326 def rr : F3_1<2, Op3Val,
327 (outs IntRegs:$rd), (ins IntRegs:$rs1, IntRegs:$rs2),
328 !strconcat(OpcStr, " $rs1, $rs2, $rd"), [],
330 def ri : F3_2<2, Op3Val,
331 (outs IntRegs:$rd), (ins IntRegs:$rs1, simm13Op:$simm13),
332 !strconcat(OpcStr, " $rs1, $simm13, $rd"), [],
336 // Load multiclass - Define both Reg+Reg/Reg+Imm patterns in one shot.
337 multiclass Load<string OpcStr, bits<6> Op3Val, SDPatternOperator OpNode,
338 RegisterClass RC, ValueType Ty, InstrItinClass itin = IIC_iu_instr> {
339 def rr : F3_1<3, Op3Val,
340 (outs RC:$dst), (ins MEMrr:$addr),
341 !strconcat(OpcStr, " [$addr], $dst"),
342 [(set Ty:$dst, (OpNode ADDRrr:$addr))],
344 def ri : F3_2<3, Op3Val,
345 (outs RC:$dst), (ins MEMri:$addr),
346 !strconcat(OpcStr, " [$addr], $dst"),
347 [(set Ty:$dst, (OpNode ADDRri:$addr))],
351 // TODO: Instructions of the LoadASI class are currently asm only; hooking up
352 // CodeGen's address spaces to use these is a future task.
353 class LoadASI<string OpcStr, bits<6> Op3Val, SDPatternOperator OpNode,
354 RegisterClass RC, ValueType Ty, InstrItinClass itin = NoItinerary> :
355 F3_1_asi<3, Op3Val, (outs RC:$dst), (ins MEMrr:$addr, i8imm:$asi),
356 !strconcat(OpcStr, "a [$addr] $asi, $dst"),
359 // LoadA multiclass - As above, but also define alternate address space variant
360 multiclass LoadA<string OpcStr, bits<6> Op3Val, bits<6> LoadAOp3Val,
361 SDPatternOperator OpNode, RegisterClass RC, ValueType Ty,
362 InstrItinClass itin = NoItinerary> :
363 Load<OpcStr, Op3Val, OpNode, RC, Ty, itin> {
364 def Arr : LoadASI<OpcStr, LoadAOp3Val, OpNode, RC, Ty>;
367 // The LDSTUB instruction is supported for asm only.
368 // It is unlikely that general-purpose code could make use of it.
369 // CAS is preferred for sparc v9.
370 def LDSTUBrr : F3_1<3, 0b001101, (outs IntRegs:$dst), (ins MEMrr:$addr),
371 "ldstub [$addr], $dst", []>;
372 def LDSTUBri : F3_2<3, 0b001101, (outs IntRegs:$dst), (ins MEMri:$addr),
373 "ldstub [$addr], $dst", []>;
374 def LDSTUBArr : F3_1_asi<3, 0b011101, (outs IntRegs:$dst),
375 (ins MEMrr:$addr, i8imm:$asi),
376 "ldstuba [$addr] $asi, $dst", []>;
378 // Store multiclass - Define both Reg+Reg/Reg+Imm patterns in one shot.
379 multiclass Store<string OpcStr, bits<6> Op3Val, SDPatternOperator OpNode,
380 RegisterClass RC, ValueType Ty, InstrItinClass itin = IIC_st> {
381 def rr : F3_1<3, Op3Val,
382 (outs), (ins MEMrr:$addr, RC:$rd),
383 !strconcat(OpcStr, " $rd, [$addr]"),
384 [(OpNode Ty:$rd, ADDRrr:$addr)],
386 def ri : F3_2<3, Op3Val,
387 (outs), (ins MEMri:$addr, RC:$rd),
388 !strconcat(OpcStr, " $rd, [$addr]"),
389 [(OpNode Ty:$rd, ADDRri:$addr)],
393 // TODO: Instructions of the StoreASI class are currently asm only; hooking up
394 // CodeGen's address spaces to use these is a future task.
395 class StoreASI<string OpcStr, bits<6> Op3Val,
396 SDPatternOperator OpNode, RegisterClass RC, ValueType Ty,
397 InstrItinClass itin = IIC_st> :
398 F3_1_asi<3, Op3Val, (outs), (ins MEMrr:$addr, RC:$rd, i8imm:$asi),
399 !strconcat(OpcStr, "a $rd, [$addr] $asi"),
403 multiclass StoreA<string OpcStr, bits<6> Op3Val, bits<6> StoreAOp3Val,
404 SDPatternOperator OpNode, RegisterClass RC, ValueType Ty,
405 InstrItinClass itin = IIC_st> :
406 Store<OpcStr, Op3Val, OpNode, RC, Ty> {
407 def Arr : StoreASI<OpcStr, StoreAOp3Val, OpNode, RC, Ty, itin>;
410 //===----------------------------------------------------------------------===//
412 //===----------------------------------------------------------------------===//
414 // Pseudo instructions.
415 class Pseudo<dag outs, dag ins, string asmstr, list<dag> pattern>
416 : InstSP<outs, ins, asmstr, pattern> {
417 let isCodeGenOnly = 1;
423 def GETPCX : Pseudo<(outs getPCX:$getpcseq), (ins), "$getpcseq", [] >;
426 let Defs = [O6], Uses = [O6] in {
427 def ADJCALLSTACKDOWN : Pseudo<(outs), (ins i32imm:$amt1, i32imm:$amt2),
428 "!ADJCALLSTACKDOWN $amt1, $amt2",
429 [(callseq_start timm:$amt1, timm:$amt2)]>;
430 def ADJCALLSTACKUP : Pseudo<(outs), (ins i32imm:$amt1, i32imm:$amt2),
431 "!ADJCALLSTACKUP $amt1",
432 [(callseq_end timm:$amt1, timm:$amt2)]>;
435 let hasSideEffects = 1, mayStore = 1 in {
436 let rd = 0, rs1 = 0, rs2 = 0 in
437 def FLUSHW : F3_1<0b10, 0b101011, (outs), (ins),
439 [(flushw)]>, Requires<[HasV9]>;
440 let rd = 8, rs1 = 0, simm13 = 3 in
441 def TA3 : F3_2<0b10, 0b111010, (outs), (ins),
446 // SELECT_CC_* - Used to implement the SELECT_CC DAG operation. Expanded after
447 // instruction selection into a branch sequence. This has to handle all
448 // permutations of selection between i32/f32/f64 on ICC and FCC.
449 // Expanded after instruction selection.
450 let Uses = [ICC], usesCustomInserter = 1 in {
451 def SELECT_CC_Int_ICC
452 : Pseudo<(outs IntRegs:$dst), (ins IntRegs:$T, IntRegs:$F, i32imm:$Cond),
453 "; SELECT_CC_Int_ICC PSEUDO!",
454 [(set i32:$dst, (SPselecticc i32:$T, i32:$F, imm:$Cond))]>;
456 : Pseudo<(outs FPRegs:$dst), (ins FPRegs:$T, FPRegs:$F, i32imm:$Cond),
457 "; SELECT_CC_FP_ICC PSEUDO!",
458 [(set f32:$dst, (SPselecticc f32:$T, f32:$F, imm:$Cond))]>;
460 def SELECT_CC_DFP_ICC
461 : Pseudo<(outs DFPRegs:$dst), (ins DFPRegs:$T, DFPRegs:$F, i32imm:$Cond),
462 "; SELECT_CC_DFP_ICC PSEUDO!",
463 [(set f64:$dst, (SPselecticc f64:$T, f64:$F, imm:$Cond))]>;
465 def SELECT_CC_QFP_ICC
466 : Pseudo<(outs QFPRegs:$dst), (ins QFPRegs:$T, QFPRegs:$F, i32imm:$Cond),
467 "; SELECT_CC_QFP_ICC PSEUDO!",
468 [(set f128:$dst, (SPselecticc f128:$T, f128:$F, imm:$Cond))]>;
471 let usesCustomInserter = 1, Uses = [FCC0] in {
473 def SELECT_CC_Int_FCC
474 : Pseudo<(outs IntRegs:$dst), (ins IntRegs:$T, IntRegs:$F, i32imm:$Cond),
475 "; SELECT_CC_Int_FCC PSEUDO!",
476 [(set i32:$dst, (SPselectfcc i32:$T, i32:$F, imm:$Cond))]>;
479 : Pseudo<(outs FPRegs:$dst), (ins FPRegs:$T, FPRegs:$F, i32imm:$Cond),
480 "; SELECT_CC_FP_FCC PSEUDO!",
481 [(set f32:$dst, (SPselectfcc f32:$T, f32:$F, imm:$Cond))]>;
482 def SELECT_CC_DFP_FCC
483 : Pseudo<(outs DFPRegs:$dst), (ins DFPRegs:$T, DFPRegs:$F, i32imm:$Cond),
484 "; SELECT_CC_DFP_FCC PSEUDO!",
485 [(set f64:$dst, (SPselectfcc f64:$T, f64:$F, imm:$Cond))]>;
486 def SELECT_CC_QFP_FCC
487 : Pseudo<(outs QFPRegs:$dst), (ins QFPRegs:$T, QFPRegs:$F, i32imm:$Cond),
488 "; SELECT_CC_QFP_FCC PSEUDO!",
489 [(set f128:$dst, (SPselectfcc f128:$T, f128:$F, imm:$Cond))]>;
492 // Section B.1 - Load Integer Instructions, p. 90
493 let DecoderMethod = "DecodeLoadInt" in {
494 defm LDSB : LoadA<"ldsb", 0b001001, 0b011001, sextloadi8, IntRegs, i32>;
495 defm LDSH : LoadA<"ldsh", 0b001010, 0b011010, sextloadi16, IntRegs, i32>;
496 defm LDUB : LoadA<"ldub", 0b000001, 0b010001, zextloadi8, IntRegs, i32>;
497 defm LDUH : LoadA<"lduh", 0b000010, 0b010010, zextloadi16, IntRegs, i32>;
498 defm LD : LoadA<"ld", 0b000000, 0b010000, load, IntRegs, i32>;
501 let DecoderMethod = "DecodeLoadIntPair" in
502 defm LDD : LoadA<"ldd", 0b000011, 0b010011, load, IntPair, v2i32, IIC_ldd>;
504 // Section B.2 - Load Floating-point Instructions, p. 92
505 let DecoderMethod = "DecodeLoadFP" in {
506 defm LDF : Load<"ld", 0b100000, load, FPRegs, f32, IIC_iu_or_fpu_instr>;
507 def LDFArr : LoadASI<"ld", 0b110000, load, FPRegs, f32, IIC_iu_or_fpu_instr>,
510 let DecoderMethod = "DecodeLoadDFP" in {
511 defm LDDF : Load<"ldd", 0b100011, load, DFPRegs, f64, IIC_ldd>;
512 def LDDFArr : LoadASI<"ldd", 0b110011, load, DFPRegs, f64>,
515 let DecoderMethod = "DecodeLoadQFP" in
516 defm LDQF : LoadA<"ldq", 0b100010, 0b110010, load, QFPRegs, f128>,
517 Requires<[HasV9, HasHardQuad]>;
519 let DecoderMethod = "DecodeLoadCP" in
520 defm LDC : Load<"ld", 0b110000, load, CoprocRegs, i32>;
521 let DecoderMethod = "DecodeLoadCPPair" in
522 defm LDDC : Load<"ldd", 0b110011, load, CoprocPair, v2i32, IIC_ldd>;
524 let DecoderMethod = "DecodeLoadCP", Defs = [CPSR] in {
526 def LDCSRrr : F3_1<3, 0b110001, (outs), (ins MEMrr:$addr),
527 "ld [$addr], %csr", []>;
528 def LDCSRri : F3_2<3, 0b110001, (outs), (ins MEMri:$addr),
529 "ld [$addr], %csr", []>;
533 let DecoderMethod = "DecodeLoadFP" in
534 let Defs = [FSR] in {
536 def LDFSRrr : F3_1<3, 0b100001, (outs), (ins MEMrr:$addr),
537 "ld [$addr], %fsr", [], IIC_iu_or_fpu_instr>;
538 def LDFSRri : F3_2<3, 0b100001, (outs), (ins MEMri:$addr),
539 "ld [$addr], %fsr", [], IIC_iu_or_fpu_instr>;
542 def LDXFSRrr : F3_1<3, 0b100001, (outs), (ins MEMrr:$addr),
543 "ldx [$addr], %fsr", []>, Requires<[HasV9]>;
544 def LDXFSRri : F3_2<3, 0b100001, (outs), (ins MEMri:$addr),
545 "ldx [$addr], %fsr", []>, Requires<[HasV9]>;
549 // Section B.4 - Store Integer Instructions, p. 95
550 let DecoderMethod = "DecodeStoreInt" in {
551 defm STB : StoreA<"stb", 0b000101, 0b010101, truncstorei8, IntRegs, i32>;
552 defm STH : StoreA<"sth", 0b000110, 0b010110, truncstorei16, IntRegs, i32>;
553 defm ST : StoreA<"st", 0b000100, 0b010100, store, IntRegs, i32>;
556 let DecoderMethod = "DecodeStoreIntPair" in
557 defm STD : StoreA<"std", 0b000111, 0b010111, store, IntPair, v2i32, IIC_std>;
559 // Section B.5 - Store Floating-point Instructions, p. 97
560 let DecoderMethod = "DecodeStoreFP" in {
561 defm STF : Store<"st", 0b100100, store, FPRegs, f32>;
562 def STFArr : StoreASI<"st", 0b110100, store, FPRegs, f32>,
565 let DecoderMethod = "DecodeStoreDFP" in {
566 defm STDF : Store<"std", 0b100111, store, DFPRegs, f64, IIC_std>;
567 def STDFArr : StoreASI<"std", 0b110111, store, DFPRegs, f64>,
570 let DecoderMethod = "DecodeStoreQFP" in
571 defm STQF : StoreA<"stq", 0b100110, 0b110110, store, QFPRegs, f128>,
572 Requires<[HasV9, HasHardQuad]>;
574 let DecoderMethod = "DecodeStoreCP" in
575 defm STC : Store<"st", 0b110100, store, CoprocRegs, i32>;
577 let DecoderMethod = "DecodeStoreCPPair" in
578 defm STDC : Store<"std", 0b110111, store, CoprocPair, v2i32, IIC_std>;
580 let DecoderMethod = "DecodeStoreCP", rd = 0 in {
581 let Defs = [CPSR] in {
582 def STCSRrr : F3_1<3, 0b110101, (outs MEMrr:$addr), (ins),
583 "st %csr, [$addr]", [], IIC_st>;
584 def STCSRri : F3_2<3, 0b110101, (outs MEMri:$addr), (ins),
585 "st %csr, [$addr]", [], IIC_st>;
587 let Defs = [CPQ] in {
588 def STDCQrr : F3_1<3, 0b110110, (outs MEMrr:$addr), (ins),
589 "std %cq, [$addr]", [], IIC_std>;
590 def STDCQri : F3_2<3, 0b110110, (outs MEMri:$addr), (ins),
591 "std %cq, [$addr]", [], IIC_std>;
595 let DecoderMethod = "DecodeStoreFP" in {
597 let Defs = [FSR] in {
598 def STFSRrr : F3_1<3, 0b100101, (outs MEMrr:$addr), (ins),
599 "st %fsr, [$addr]", [], IIC_st>;
600 def STFSRri : F3_2<3, 0b100101, (outs MEMri:$addr), (ins),
601 "st %fsr, [$addr]", [], IIC_st>;
604 def STDFQrr : F3_1<3, 0b100110, (outs MEMrr:$addr), (ins),
605 "std %fq, [$addr]", [], IIC_std>;
606 def STDFQri : F3_2<3, 0b100110, (outs MEMri:$addr), (ins),
607 "std %fq, [$addr]", [], IIC_std>;
610 let rd = 1, Defs = [FSR] in {
611 def STXFSRrr : F3_1<3, 0b100101, (outs MEMrr:$addr), (ins),
612 "stx %fsr, [$addr]", []>, Requires<[HasV9]>;
613 def STXFSRri : F3_2<3, 0b100101, (outs MEMri:$addr), (ins),
614 "stx %fsr, [$addr]", []>, Requires<[HasV9]>;
618 // Section B.8 - SWAP Register with Memory Instruction
620 let Constraints = "$val = $dst", DecoderMethod = "DecodeSWAP" in {
621 def SWAPrr : F3_1<3, 0b001111,
622 (outs IntRegs:$dst), (ins MEMrr:$addr, IntRegs:$val),
623 "swap [$addr], $dst",
624 [(set i32:$dst, (atomic_swap_32 ADDRrr:$addr, i32:$val))]>;
625 def SWAPri : F3_2<3, 0b001111,
626 (outs IntRegs:$dst), (ins MEMri:$addr, IntRegs:$val),
627 "swap [$addr], $dst",
628 [(set i32:$dst, (atomic_swap_32 ADDRri:$addr, i32:$val))]>;
629 def SWAPArr : F3_1_asi<3, 0b011111,
630 (outs IntRegs:$dst), (ins MEMrr:$addr, i8imm:$asi, IntRegs:$val),
631 "swapa [$addr] $asi, $dst",
632 [/*FIXME: pattern?*/]>;
636 // Section B.9 - SETHI Instruction, p. 104
637 def SETHIi: F2_1<0b100,
638 (outs IntRegs:$rd), (ins i32imm:$imm22),
640 [(set i32:$rd, SETHIimm:$imm22)],
643 // Section B.10 - NOP Instruction, p. 105
644 // (It's a special case of SETHI)
645 let rd = 0, imm22 = 0 in
646 def NOP : F2_1<0b100, (outs), (ins), "nop", []>;
648 // Section B.11 - Logical Instructions, p. 106
649 defm AND : F3_12<"and", 0b000001, and, IntRegs, i32, simm13Op>;
651 def ANDNrr : F3_1<2, 0b000101,
652 (outs IntRegs:$rd), (ins IntRegs:$rs1, IntRegs:$rs2),
653 "andn $rs1, $rs2, $rd",
654 [(set i32:$rd, (and i32:$rs1, (not i32:$rs2)))]>;
655 def ANDNri : F3_2<2, 0b000101,
656 (outs IntRegs:$rd), (ins IntRegs:$rs1, simm13Op:$simm13),
657 "andn $rs1, $simm13, $rd", []>;
659 defm OR : F3_12<"or", 0b000010, or, IntRegs, i32, simm13Op>;
661 def ORNrr : F3_1<2, 0b000110,
662 (outs IntRegs:$rd), (ins IntRegs:$rs1, IntRegs:$rs2),
663 "orn $rs1, $rs2, $rd",
664 [(set i32:$rd, (or i32:$rs1, (not i32:$rs2)))]>;
665 def ORNri : F3_2<2, 0b000110,
666 (outs IntRegs:$rd), (ins IntRegs:$rs1, simm13Op:$simm13),
667 "orn $rs1, $simm13, $rd", []>;
668 defm XOR : F3_12<"xor", 0b000011, xor, IntRegs, i32, simm13Op>;
670 def XNORrr : F3_1<2, 0b000111,
671 (outs IntRegs:$rd), (ins IntRegs:$rs1, IntRegs:$rs2),
672 "xnor $rs1, $rs2, $rd",
673 [(set i32:$rd, (not (xor i32:$rs1, i32:$rs2)))]>;
674 def XNORri : F3_2<2, 0b000111,
675 (outs IntRegs:$rd), (ins IntRegs:$rs1, simm13Op:$simm13),
676 "xnor $rs1, $simm13, $rd", []>;
678 def : Pat<(and IntRegs:$rs1, SETHIimm_not:$rs2),
679 (ANDNrr i32:$rs1, (SETHIi SETHIimm_not:$rs2))>;
681 def : Pat<(or IntRegs:$rs1, SETHIimm_not:$rs2),
682 (ORNrr i32:$rs1, (SETHIi SETHIimm_not:$rs2))>;
684 let Defs = [ICC] in {
685 defm ANDCC : F3_12np<"andcc", 0b010001>;
686 defm ANDNCC : F3_12np<"andncc", 0b010101>;
687 defm ORCC : F3_12np<"orcc", 0b010010>;
688 defm ORNCC : F3_12np<"orncc", 0b010110>;
689 defm XORCC : F3_12np<"xorcc", 0b010011>;
690 defm XNORCC : F3_12np<"xnorcc", 0b010111>;
693 // Section B.12 - Shift Instructions, p. 107
694 defm SLL : F3_12<"sll", 0b100101, shl, IntRegs, i32, simm13Op>;
695 defm SRL : F3_12<"srl", 0b100110, srl, IntRegs, i32, simm13Op>;
696 defm SRA : F3_12<"sra", 0b100111, sra, IntRegs, i32, simm13Op>;
698 // Section B.13 - Add Instructions, p. 108
699 defm ADD : F3_12<"add", 0b000000, add, IntRegs, i32, simm13Op>;
701 // "LEA" forms of add (patterns to make tblgen happy)
702 let Predicates = [Is32Bit], isCodeGenOnly = 1 in
703 def LEA_ADDri : F3_2<2, 0b000000,
704 (outs IntRegs:$dst), (ins MEMri:$addr),
705 "add ${addr:arith}, $dst",
706 [(set iPTR:$dst, ADDRri:$addr)]>;
709 defm ADDCC : F3_12<"addcc", 0b010000, addc, IntRegs, i32, simm13Op>;
712 defm ADDC : F3_12np<"addx", 0b001000>;
714 let Uses = [ICC], Defs = [ICC] in
715 defm ADDE : F3_12<"addxcc", 0b011000, adde, IntRegs, i32, simm13Op>;
717 // Section B.15 - Subtract Instructions, p. 110
718 defm SUB : F3_12 <"sub" , 0b000100, sub, IntRegs, i32, simm13Op>;
719 let Uses = [ICC], Defs = [ICC] in
720 defm SUBE : F3_12 <"subxcc" , 0b011100, sube, IntRegs, i32, simm13Op>;
723 defm SUBCC : F3_12 <"subcc", 0b010100, subc, IntRegs, i32, simm13Op>;
726 defm SUBC : F3_12np <"subx", 0b001100>;
728 // cmp (from Section A.3) is a specialized alias for subcc
729 let Defs = [ICC], rd = 0 in {
730 def CMPrr : F3_1<2, 0b010100,
731 (outs), (ins IntRegs:$rs1, IntRegs:$rs2),
733 [(SPcmpicc i32:$rs1, i32:$rs2)]>;
734 def CMPri : F3_2<2, 0b010100,
735 (outs), (ins IntRegs:$rs1, simm13Op:$simm13),
737 [(SPcmpicc i32:$rs1, (i32 simm13:$simm13))]>;
740 // Section B.18 - Multiply Instructions, p. 113
742 defm UMUL : F3_12<"umul", 0b001010, umullohi, IntRegs, i32, simm13Op, IIC_iu_umul>;
743 defm SMUL : F3_12<"smul", 0b001011, smullohi, IntRegs, i32, simm13Op, IIC_iu_smul>;
746 let Defs = [Y, ICC] in {
747 defm UMULCC : F3_12np<"umulcc", 0b011010, IIC_iu_umul>;
748 defm SMULCC : F3_12np<"smulcc", 0b011011, IIC_iu_smul>;
751 let Defs = [Y, ICC], Uses = [Y, ICC] in {
752 defm MULSCC : F3_12np<"mulscc", 0b100100>;
755 // Section B.19 - Divide Instructions, p. 115
756 let Uses = [Y], Defs = [Y] in {
757 defm UDIV : F3_12np<"udiv", 0b001110, IIC_iu_div>;
758 defm SDIV : F3_12np<"sdiv", 0b001111, IIC_iu_div>;
761 let Uses = [Y], Defs = [Y, ICC] in {
762 defm UDIVCC : F3_12np<"udivcc", 0b011110, IIC_iu_div>;
763 defm SDIVCC : F3_12np<"sdivcc", 0b011111, IIC_iu_div>;
766 // Section B.20 - SAVE and RESTORE, p. 117
767 defm SAVE : F3_12np<"save" , 0b111100>;
768 defm RESTORE : F3_12np<"restore", 0b111101>;
770 // Section B.21 - Branch on Integer Condition Codes Instructions, p. 119
772 // unconditional branch class.
773 class BranchAlways<dag ins, string asmstr, list<dag> pattern>
774 : F2_2<0b010, 0, (outs), ins, asmstr, pattern> {
776 let isTerminator = 1;
777 let hasDelaySlot = 1;
782 def BA : BranchAlways<(ins brtarget:$imm22), "ba $imm22", [(br bb:$imm22)]>;
785 let isBranch = 1, isTerminator = 1, hasDelaySlot = 1 in {
787 // conditional branch class:
788 class BranchSP<dag ins, string asmstr, list<dag> pattern>
789 : F2_2<0b010, 0, (outs), ins, asmstr, pattern, IIC_iu_instr>;
791 // conditional branch with annul class:
792 class BranchSPA<dag ins, string asmstr, list<dag> pattern>
793 : F2_2<0b010, 1, (outs), ins, asmstr, pattern, IIC_iu_instr>;
795 // Conditional branch class on %icc|%xcc with predication:
796 multiclass IPredBranch<string regstr, list<dag> CCPattern> {
797 def CC : F2_3<0b001, 0, 1, (outs), (ins bprtarget:$imm19, CCOp:$cond),
798 !strconcat("b$cond ", !strconcat(regstr, ", $imm19")),
801 def CCA : F2_3<0b001, 1, 1, (outs), (ins bprtarget:$imm19, CCOp:$cond),
802 !strconcat("b$cond,a ", !strconcat(regstr, ", $imm19")),
805 def CCNT : F2_3<0b001, 0, 0, (outs), (ins bprtarget:$imm19, CCOp:$cond),
806 !strconcat("b$cond,pn ", !strconcat(regstr, ", $imm19")),
809 def CCANT : F2_3<0b001, 1, 0, (outs), (ins bprtarget:$imm19, CCOp:$cond),
810 !strconcat("b$cond,a,pn ", !strconcat(regstr, ", $imm19")),
815 } // let isBranch = 1, isTerminator = 1, hasDelaySlot = 1
818 // Indirect branch instructions.
819 let isTerminator = 1, isBarrier = 1, hasDelaySlot = 1, isBranch =1,
820 isIndirectBranch = 1, rd = 0, isCodeGenOnly = 1 in {
821 def BINDrr : F3_1<2, 0b111000,
822 (outs), (ins MEMrr:$ptr),
824 [(brind ADDRrr:$ptr)]>;
825 def BINDri : F3_2<2, 0b111000,
826 (outs), (ins MEMri:$ptr),
828 [(brind ADDRri:$ptr)]>;
831 let Uses = [ICC] in {
832 def BCOND : BranchSP<(ins brtarget:$imm22, CCOp:$cond),
834 [(SPbricc bb:$imm22, imm:$cond)]>;
835 def BCONDA : BranchSPA<(ins brtarget:$imm22, CCOp:$cond),
836 "b$cond,a $imm22", []>;
838 let Predicates = [HasV9], cc = 0b00 in
839 defm BPI : IPredBranch<"%icc", []>;
842 // Section B.22 - Branch on Floating-point Condition Codes Instructions, p. 121
844 let isBranch = 1, isTerminator = 1, hasDelaySlot = 1 in {
846 // floating-point conditional branch class:
847 class FPBranchSP<dag ins, string asmstr, list<dag> pattern>
848 : F2_2<0b110, 0, (outs), ins, asmstr, pattern, IIC_fpu_normal_instr>;
850 // floating-point conditional branch with annul class:
851 class FPBranchSPA<dag ins, string asmstr, list<dag> pattern>
852 : F2_2<0b110, 1, (outs), ins, asmstr, pattern, IIC_fpu_normal_instr>;
854 // Conditional branch class on %fcc0-%fcc3 with predication:
855 multiclass FPredBranch {
856 def CC : F2_3<0b101, 0, 1, (outs), (ins bprtarget:$imm19, CCOp:$cond,
858 "fb$cond $cc, $imm19", [], IIC_fpu_normal_instr>;
859 def CCA : F2_3<0b101, 1, 1, (outs), (ins bprtarget:$imm19, CCOp:$cond,
861 "fb$cond,a $cc, $imm19", [], IIC_fpu_normal_instr>;
862 def CCNT : F2_3<0b101, 0, 0, (outs), (ins bprtarget:$imm19, CCOp:$cond,
864 "fb$cond,pn $cc, $imm19", [], IIC_fpu_normal_instr>;
865 def CCANT : F2_3<0b101, 1, 0, (outs), (ins bprtarget:$imm19, CCOp:$cond,
867 "fb$cond,a,pn $cc, $imm19", [], IIC_fpu_normal_instr>;
869 } // let isBranch = 1, isTerminator = 1, hasDelaySlot = 1
871 let Uses = [FCC0] in {
872 def FBCOND : FPBranchSP<(ins brtarget:$imm22, CCOp:$cond),
874 [(SPbrfcc bb:$imm22, imm:$cond)]>;
875 def FBCONDA : FPBranchSPA<(ins brtarget:$imm22, CCOp:$cond),
876 "fb$cond,a $imm22", []>;
879 let Predicates = [HasV9] in
880 defm BPF : FPredBranch;
882 // Section B.22 - Branch on Co-processor Condition Codes Instructions, p. 123
883 let isBranch = 1, isTerminator = 1, hasDelaySlot = 1 in {
885 // co-processor conditional branch class:
886 class CPBranchSP<dag ins, string asmstr, list<dag> pattern>
887 : F2_2<0b111, 0, (outs), ins, asmstr, pattern>;
889 // co-processor conditional branch with annul class:
890 class CPBranchSPA<dag ins, string asmstr, list<dag> pattern>
891 : F2_2<0b111, 1, (outs), ins, asmstr, pattern>;
893 } // let isBranch = 1, isTerminator = 1, hasDelaySlot = 1
895 def CBCOND : CPBranchSP<(ins brtarget:$imm22, CCOp:$cond),
897 [(SPbrfcc bb:$imm22, imm:$cond)]>;
898 def CBCONDA : CPBranchSPA<(ins brtarget:$imm22, CCOp:$cond),
899 "cb$cond,a $imm22", []>;
901 // Section B.24 - Call and Link Instruction, p. 125
902 // This is the only Format 1 instruction
904 hasDelaySlot = 1, isCall = 1 in {
905 def CALL : InstSP<(outs), (ins calltarget:$disp, variable_ops),
911 let Inst{29-0} = disp;
914 // indirect calls: special cases of JMPL.
915 let isCodeGenOnly = 1, rd = 15 in {
916 def CALLrr : F3_1<2, 0b111000,
917 (outs), (ins MEMrr:$ptr, variable_ops),
919 [(call ADDRrr:$ptr)],
921 def CALLri : F3_2<2, 0b111000,
922 (outs), (ins MEMri:$ptr, variable_ops),
924 [(call ADDRri:$ptr)],
929 // Section B.25 - Jump and Link Instruction
932 let isTerminator = 1, hasDelaySlot = 1, isBarrier = 1,
933 DecoderMethod = "DecodeJMPL" in {
934 def JMPLrr: F3_1<2, 0b111000,
935 (outs IntRegs:$dst), (ins MEMrr:$addr),
939 def JMPLri: F3_2<2, 0b111000,
940 (outs IntRegs:$dst), (ins MEMri:$addr),
946 // Section A.3 - Synthetic Instructions, p. 85
947 // special cases of JMPL:
948 let isReturn = 1, isTerminator = 1, hasDelaySlot = 1, isBarrier = 1,
949 isCodeGenOnly = 1 in {
950 let rd = 0, rs1 = 15 in
951 def RETL: F3_2<2, 0b111000,
952 (outs), (ins i32imm:$val),
954 [(retflag simm13:$val)],
957 let rd = 0, rs1 = 31 in
958 def RET: F3_2<2, 0b111000,
959 (outs), (ins i32imm:$val),
965 // Section B.26 - Return from Trap Instruction
966 let isReturn = 1, isTerminator = 1, hasDelaySlot = 1,
967 isBarrier = 1, rd = 0, DecoderMethod = "DecodeReturn" in {
968 def RETTrr : F3_1<2, 0b111001,
969 (outs), (ins MEMrr:$addr),
973 def RETTri : F3_2<2, 0b111001,
974 (outs), (ins MEMri:$addr),
981 // Section B.27 - Trap on Integer Condition Codes Instruction
982 // conditional branch class:
983 let DecoderNamespace = "SparcV8", DecoderMethod = "DecodeTRAP", hasSideEffects = 1, Uses = [ICC], cc = 0b00 in
985 def TRAPrr : TRAPSPrr<0b111010,
986 (outs), (ins IntRegs:$rs1, IntRegs:$rs2, CCOp:$cond),
987 "t$cond $rs1 + $rs2",
989 def TRAPri : TRAPSPri<0b111010,
990 (outs), (ins IntRegs:$rs1, i32imm:$imm, CCOp:$cond),
991 "t$cond $rs1 + $imm",
995 multiclass TRAP<string regStr> {
996 def rr : TRAPSPrr<0b111010,
997 (outs), (ins IntRegs:$rs1, IntRegs:$rs2, CCOp:$cond),
998 !strconcat(!strconcat("t$cond ", regStr), ", $rs1 + $rs2"),
1000 def ri : TRAPSPri<0b111010,
1001 (outs), (ins IntRegs:$rs1, i32imm:$imm, CCOp:$cond),
1002 !strconcat(!strconcat("t$cond ", regStr), ", $rs1 + $imm"),
1006 let DecoderNamespace = "SparcV9", DecoderMethod = "DecodeTRAP", Predicates = [HasV9], hasSideEffects = 1, Uses = [ICC], cc = 0b00 in
1007 defm TICC : TRAP<"%icc">;
1010 let isBarrier = 1, isTerminator = 1, rd = 0b01000, rs1 = 0, simm13 = 5 in
1011 def TA5 : F3_2<0b10, 0b111010, (outs), (ins), "ta 5", [(trap)]>;
1013 let hasSideEffects = 1, rd = 0b01000, rs1 = 0, simm13 = 1 in
1014 def TA1 : F3_2<0b10, 0b111010, (outs), (ins), "ta 1", [(debugtrap)]>;
1016 // Section B.28 - Read State Register Instructions
1018 def RDASR : F3_1<2, 0b101000,
1019 (outs IntRegs:$rd), (ins ASRRegs:$rs1),
1020 "rd $rs1, $rd", []>;
1022 // PSR, WIM, and TBR don't exist on the SparcV9, only the V8.
1023 let Predicates = [HasNoV9] in {
1024 let rs2 = 0, rs1 = 0, Uses=[PSR] in
1025 def RDPSR : F3_1<2, 0b101001,
1026 (outs IntRegs:$rd), (ins),
1027 "rd %psr, $rd", []>;
1029 let rs2 = 0, rs1 = 0, Uses=[WIM] in
1030 def RDWIM : F3_1<2, 0b101010,
1031 (outs IntRegs:$rd), (ins),
1032 "rd %wim, $rd", []>;
1034 let rs2 = 0, rs1 = 0, Uses=[TBR] in
1035 def RDTBR : F3_1<2, 0b101011,
1036 (outs IntRegs:$rd), (ins),
1037 "rd %tbr, $rd", []>;
1040 // Section B.29 - Write State Register Instructions
1041 def WRASRrr : F3_1<2, 0b110000,
1042 (outs ASRRegs:$rd), (ins IntRegs:$rs1, IntRegs:$rs2),
1043 "wr $rs1, $rs2, $rd", []>;
1044 def WRASRri : F3_2<2, 0b110000,
1045 (outs ASRRegs:$rd), (ins IntRegs:$rs1, simm13Op:$simm13),
1046 "wr $rs1, $simm13, $rd", []>;
1048 // PSR, WIM, and TBR don't exist on the SparcV9, only the V8.
1049 let Predicates = [HasNoV9] in {
1050 let Defs = [PSR], rd=0 in {
1051 def WRPSRrr : F3_1<2, 0b110001,
1052 (outs), (ins IntRegs:$rs1, IntRegs:$rs2),
1053 "wr $rs1, $rs2, %psr", []>;
1054 def WRPSRri : F3_2<2, 0b110001,
1055 (outs), (ins IntRegs:$rs1, simm13Op:$simm13),
1056 "wr $rs1, $simm13, %psr", []>;
1059 let Defs = [WIM], rd=0 in {
1060 def WRWIMrr : F3_1<2, 0b110010,
1061 (outs), (ins IntRegs:$rs1, IntRegs:$rs2),
1062 "wr $rs1, $rs2, %wim", []>;
1063 def WRWIMri : F3_2<2, 0b110010,
1064 (outs), (ins IntRegs:$rs1, simm13Op:$simm13),
1065 "wr $rs1, $simm13, %wim", []>;
1068 let Defs = [TBR], rd=0 in {
1069 def WRTBRrr : F3_1<2, 0b110011,
1070 (outs), (ins IntRegs:$rs1, IntRegs:$rs2),
1071 "wr $rs1, $rs2, %tbr", []>;
1072 def WRTBRri : F3_2<2, 0b110011,
1073 (outs), (ins IntRegs:$rs1, simm13Op:$simm13),
1074 "wr $rs1, $simm13, %tbr", []>;
1078 // Section B.30 - STBAR Instruction
1079 let hasSideEffects = 1, rd = 0, rs1 = 0b01111, rs2 = 0 in
1080 def STBAR : F3_1<2, 0b101000, (outs), (ins), "stbar", []>;
1083 // Section B.31 - Unimplmented Instruction
1085 def UNIMP : F2_1<0b000, (outs), (ins i32imm:$imm22),
1086 "unimp $imm22", []>;
1088 // Section B.32 - Flush Instruction Memory
1090 def FLUSHrr : F3_1<2, 0b111011, (outs), (ins MEMrr:$addr),
1092 def FLUSHri : F3_2<2, 0b111011, (outs), (ins MEMri:$addr),
1095 // The no-arg FLUSH is only here for the benefit of the InstAlias
1096 // "flush", which cannot seem to use FLUSHrr, due to the inability
1097 // to construct a MEMrr with fixed G0 registers.
1098 let rs1 = 0, rs2 = 0 in
1099 def FLUSH : F3_1<2, 0b111011, (outs), (ins), "flush %g0", []>;
1102 // Section B.33 - Floating-point Operate (FPop) Instructions
1104 // Convert Integer to Floating-point Instructions, p. 141
1105 def FITOS : F3_3u<2, 0b110100, 0b011000100,
1106 (outs FPRegs:$rd), (ins FPRegs:$rs2),
1108 [(set FPRegs:$rd, (SPitof FPRegs:$rs2))],
1109 IIC_fpu_fast_instr>;
1110 def FITOD : F3_3u<2, 0b110100, 0b011001000,
1111 (outs DFPRegs:$rd), (ins FPRegs:$rs2),
1113 [(set DFPRegs:$rd, (SPitof FPRegs:$rs2))],
1114 IIC_fpu_fast_instr>;
1115 def FITOQ : F3_3u<2, 0b110100, 0b011001100,
1116 (outs QFPRegs:$rd), (ins FPRegs:$rs2),
1118 [(set QFPRegs:$rd, (SPitof FPRegs:$rs2))]>,
1119 Requires<[HasHardQuad]>;
1121 // Convert Floating-point to Integer Instructions, p. 142
1122 def FSTOI : F3_3u<2, 0b110100, 0b011010001,
1123 (outs FPRegs:$rd), (ins FPRegs:$rs2),
1125 [(set FPRegs:$rd, (SPftoi FPRegs:$rs2))],
1126 IIC_fpu_fast_instr>;
1127 def FDTOI : F3_3u<2, 0b110100, 0b011010010,
1128 (outs FPRegs:$rd), (ins DFPRegs:$rs2),
1130 [(set FPRegs:$rd, (SPftoi DFPRegs:$rs2))],
1131 IIC_fpu_fast_instr>;
1132 def FQTOI : F3_3u<2, 0b110100, 0b011010011,
1133 (outs FPRegs:$rd), (ins QFPRegs:$rs2),
1135 [(set FPRegs:$rd, (SPftoi QFPRegs:$rs2))]>,
1136 Requires<[HasHardQuad]>;
1138 // Convert between Floating-point Formats Instructions, p. 143
1139 def FSTOD : F3_3u<2, 0b110100, 0b011001001,
1140 (outs DFPRegs:$rd), (ins FPRegs:$rs2),
1142 [(set f64:$rd, (fpextend f32:$rs2))],
1144 def FSTOQ : F3_3u<2, 0b110100, 0b011001101,
1145 (outs QFPRegs:$rd), (ins FPRegs:$rs2),
1147 [(set f128:$rd, (fpextend f32:$rs2))]>,
1148 Requires<[HasHardQuad]>;
1149 def FDTOS : F3_3u<2, 0b110100, 0b011000110,
1150 (outs FPRegs:$rd), (ins DFPRegs:$rs2),
1152 [(set f32:$rd, (fpround f64:$rs2))],
1153 IIC_fpu_fast_instr>;
1154 def FDTOQ : F3_3u<2, 0b110100, 0b011001110,
1155 (outs QFPRegs:$rd), (ins DFPRegs:$rs2),
1157 [(set f128:$rd, (fpextend f64:$rs2))]>,
1158 Requires<[HasHardQuad]>;
1159 def FQTOS : F3_3u<2, 0b110100, 0b011000111,
1160 (outs FPRegs:$rd), (ins QFPRegs:$rs2),
1162 [(set f32:$rd, (fpround f128:$rs2))]>,
1163 Requires<[HasHardQuad]>;
1164 def FQTOD : F3_3u<2, 0b110100, 0b011001011,
1165 (outs DFPRegs:$rd), (ins QFPRegs:$rs2),
1167 [(set f64:$rd, (fpround f128:$rs2))]>,
1168 Requires<[HasHardQuad]>;
1170 // Floating-point Move Instructions, p. 144
1171 def FMOVS : F3_3u<2, 0b110100, 0b000000001,
1172 (outs FPRegs:$rd), (ins FPRegs:$rs2),
1173 "fmovs $rs2, $rd", []>;
1174 def FNEGS : F3_3u<2, 0b110100, 0b000000101,
1175 (outs FPRegs:$rd), (ins FPRegs:$rs2),
1177 [(set f32:$rd, (fneg f32:$rs2))],
1179 def FABSS : F3_3u<2, 0b110100, 0b000001001,
1180 (outs FPRegs:$rd), (ins FPRegs:$rs2),
1182 [(set f32:$rd, (fabs f32:$rs2))],
1186 // Floating-point Square Root Instructions, p.145
1187 // FSQRTS generates an erratum on LEON processors, so by disabling this instruction
1188 // this will be promoted to use FSQRTD with doubles instead.
1189 let Predicates = [HasNoFdivSqrtFix] in
1190 def FSQRTS : F3_3u<2, 0b110100, 0b000101001,
1191 (outs FPRegs:$rd), (ins FPRegs:$rs2),
1193 [(set f32:$rd, (fsqrt f32:$rs2))],
1195 def FSQRTD : F3_3u<2, 0b110100, 0b000101010,
1196 (outs DFPRegs:$rd), (ins DFPRegs:$rs2),
1198 [(set f64:$rd, (fsqrt f64:$rs2))],
1200 def FSQRTQ : F3_3u<2, 0b110100, 0b000101011,
1201 (outs QFPRegs:$rd), (ins QFPRegs:$rs2),
1203 [(set f128:$rd, (fsqrt f128:$rs2))]>,
1204 Requires<[HasHardQuad]>;
1208 // Floating-point Add and Subtract Instructions, p. 146
1209 def FADDS : F3_3<2, 0b110100, 0b001000001,
1210 (outs FPRegs:$rd), (ins FPRegs:$rs1, FPRegs:$rs2),
1211 "fadds $rs1, $rs2, $rd",
1212 [(set f32:$rd, (fadd f32:$rs1, f32:$rs2))],
1213 IIC_fpu_fast_instr>;
1214 def FADDD : F3_3<2, 0b110100, 0b001000010,
1215 (outs DFPRegs:$rd), (ins DFPRegs:$rs1, DFPRegs:$rs2),
1216 "faddd $rs1, $rs2, $rd",
1217 [(set f64:$rd, (fadd f64:$rs1, f64:$rs2))],
1218 IIC_fpu_fast_instr>;
1219 def FADDQ : F3_3<2, 0b110100, 0b001000011,
1220 (outs QFPRegs:$rd), (ins QFPRegs:$rs1, QFPRegs:$rs2),
1221 "faddq $rs1, $rs2, $rd",
1222 [(set f128:$rd, (fadd f128:$rs1, f128:$rs2))]>,
1223 Requires<[HasHardQuad]>;
1225 def FSUBS : F3_3<2, 0b110100, 0b001000101,
1226 (outs FPRegs:$rd), (ins FPRegs:$rs1, FPRegs:$rs2),
1227 "fsubs $rs1, $rs2, $rd",
1228 [(set f32:$rd, (fsub f32:$rs1, f32:$rs2))],
1229 IIC_fpu_fast_instr>;
1230 def FSUBD : F3_3<2, 0b110100, 0b001000110,
1231 (outs DFPRegs:$rd), (ins DFPRegs:$rs1, DFPRegs:$rs2),
1232 "fsubd $rs1, $rs2, $rd",
1233 [(set f64:$rd, (fsub f64:$rs1, f64:$rs2))],
1234 IIC_fpu_fast_instr>;
1235 def FSUBQ : F3_3<2, 0b110100, 0b001000111,
1236 (outs QFPRegs:$rd), (ins QFPRegs:$rs1, QFPRegs:$rs2),
1237 "fsubq $rs1, $rs2, $rd",
1238 [(set f128:$rd, (fsub f128:$rs1, f128:$rs2))]>,
1239 Requires<[HasHardQuad]>;
1242 // Floating-point Multiply and Divide Instructions, p. 147
1243 def FMULS : F3_3<2, 0b110100, 0b001001001,
1244 (outs FPRegs:$rd), (ins FPRegs:$rs1, FPRegs:$rs2),
1245 "fmuls $rs1, $rs2, $rd",
1246 [(set f32:$rd, (fmul f32:$rs1, f32:$rs2))],
1248 Requires<[HasFMULS]>;
1249 def FMULD : F3_3<2, 0b110100, 0b001001010,
1250 (outs DFPRegs:$rd), (ins DFPRegs:$rs1, DFPRegs:$rs2),
1251 "fmuld $rs1, $rs2, $rd",
1252 [(set f64:$rd, (fmul f64:$rs1, f64:$rs2))],
1254 def FMULQ : F3_3<2, 0b110100, 0b001001011,
1255 (outs QFPRegs:$rd), (ins QFPRegs:$rs1, QFPRegs:$rs2),
1256 "fmulq $rs1, $rs2, $rd",
1257 [(set f128:$rd, (fmul f128:$rs1, f128:$rs2))]>,
1258 Requires<[HasHardQuad]>;
1260 def FSMULD : F3_3<2, 0b110100, 0b001101001,
1261 (outs DFPRegs:$rd), (ins FPRegs:$rs1, FPRegs:$rs2),
1262 "fsmuld $rs1, $rs2, $rd",
1263 [(set f64:$rd, (fmul (fpextend f32:$rs1),
1264 (fpextend f32:$rs2)))],
1266 Requires<[HasFSMULD]>;
1267 def FDMULQ : F3_3<2, 0b110100, 0b001101110,
1268 (outs QFPRegs:$rd), (ins DFPRegs:$rs1, DFPRegs:$rs2),
1269 "fdmulq $rs1, $rs2, $rd",
1270 [(set f128:$rd, (fmul (fpextend f64:$rs1),
1271 (fpextend f64:$rs2)))]>,
1272 Requires<[HasHardQuad]>;
1274 // FDIVS generates an erratum on LEON processors, so by disabling this instruction
1275 // this will be promoted to use FDIVD with doubles instead.
1276 def FDIVS : F3_3<2, 0b110100, 0b001001101,
1277 (outs FPRegs:$rd), (ins FPRegs:$rs1, FPRegs:$rs2),
1278 "fdivs $rs1, $rs2, $rd",
1279 [(set f32:$rd, (fdiv f32:$rs1, f32:$rs2))],
1281 def FDIVD : F3_3<2, 0b110100, 0b001001110,
1282 (outs DFPRegs:$rd), (ins DFPRegs:$rs1, DFPRegs:$rs2),
1283 "fdivd $rs1, $rs2, $rd",
1284 [(set f64:$rd, (fdiv f64:$rs1, f64:$rs2))],
1286 def FDIVQ : F3_3<2, 0b110100, 0b001001111,
1287 (outs QFPRegs:$rd), (ins QFPRegs:$rs1, QFPRegs:$rs2),
1288 "fdivq $rs1, $rs2, $rd",
1289 [(set f128:$rd, (fdiv f128:$rs1, f128:$rs2))]>,
1290 Requires<[HasHardQuad]>;
1292 // Floating-point Compare Instructions, p. 148
1293 // Note: the 2nd template arg is different for these guys.
1294 // Note 2: the result of a FCMP is not available until the 2nd cycle
1295 // after the instr is retired, but there is no interlock in Sparc V8.
1296 // This behavior is modeled with a forced noop after the instruction in
1299 let Defs = [FCC0], rd = 0, isCodeGenOnly = 1 in {
1300 def FCMPS : F3_3c<2, 0b110101, 0b001010001,
1301 (outs), (ins FPRegs:$rs1, FPRegs:$rs2),
1303 [(SPcmpfcc f32:$rs1, f32:$rs2)],
1304 IIC_fpu_fast_instr>;
1305 def FCMPD : F3_3c<2, 0b110101, 0b001010010,
1306 (outs), (ins DFPRegs:$rs1, DFPRegs:$rs2),
1308 [(SPcmpfcc f64:$rs1, f64:$rs2)],
1309 IIC_fpu_fast_instr>;
1310 def FCMPQ : F3_3c<2, 0b110101, 0b001010011,
1311 (outs), (ins QFPRegs:$rs1, QFPRegs:$rs2),
1313 [(SPcmpfcc f128:$rs1, f128:$rs2)]>,
1314 Requires<[HasHardQuad]>;
1317 //===----------------------------------------------------------------------===//
1318 // Instructions for Thread Local Storage(TLS).
1319 //===----------------------------------------------------------------------===//
1320 let isAsmParserOnly = 1 in {
1321 def TLS_ADDrr : F3_1<2, 0b000000,
1323 (ins IntRegs:$rs1, IntRegs:$rs2, TLSSym:$sym),
1324 "add $rs1, $rs2, $rd, $sym",
1326 (tlsadd i32:$rs1, i32:$rs2, tglobaltlsaddr:$sym))]>;
1329 def TLS_LDrr : F3_1<3, 0b000000,
1330 (outs IntRegs:$dst), (ins MEMrr:$addr, TLSSym:$sym),
1331 "ld [$addr], $dst, $sym",
1333 (tlsld ADDRrr:$addr, tglobaltlsaddr:$sym))]>;
1335 let Uses = [O6], isCall = 1, hasDelaySlot = 1 in
1336 def TLS_CALL : InstSP<(outs),
1337 (ins calltarget:$disp, TLSSym:$sym, variable_ops),
1339 [(tlscall texternalsym:$disp, tglobaltlsaddr:$sym)],
1343 let Inst{29-0} = disp;
1347 //===----------------------------------------------------------------------===//
1349 //===----------------------------------------------------------------------===//
1351 // V9 Conditional Moves.
1352 let Predicates = [HasV9], Constraints = "$f = $rd" in {
1353 // Move Integer Register on Condition (MOVcc) p. 194 of the V9 manual.
1354 let Uses = [ICC], intcc = 1, cc = 0b00 in {
1356 : F4_1<0b101100, (outs IntRegs:$rd),
1357 (ins IntRegs:$rs2, IntRegs:$f, CCOp:$cond),
1358 "mov$cond %icc, $rs2, $rd",
1359 [(set i32:$rd, (SPselecticc i32:$rs2, i32:$f, imm:$cond))]>;
1362 : F4_2<0b101100, (outs IntRegs:$rd),
1363 (ins i32imm:$simm11, IntRegs:$f, CCOp:$cond),
1364 "mov$cond %icc, $simm11, $rd",
1366 (SPselecticc simm11:$simm11, i32:$f, imm:$cond))]>;
1369 let Uses = [FCC0], intcc = 0, cc = 0b00 in {
1371 : F4_1<0b101100, (outs IntRegs:$rd),
1372 (ins IntRegs:$rs2, IntRegs:$f, CCOp:$cond),
1373 "mov$cond %fcc0, $rs2, $rd",
1374 [(set i32:$rd, (SPselectfcc i32:$rs2, i32:$f, imm:$cond))]>;
1376 : F4_2<0b101100, (outs IntRegs:$rd),
1377 (ins i32imm:$simm11, IntRegs:$f, CCOp:$cond),
1378 "mov$cond %fcc0, $simm11, $rd",
1380 (SPselectfcc simm11:$simm11, i32:$f, imm:$cond))]>;
1383 let Uses = [ICC], intcc = 1, opf_cc = 0b00 in {
1385 : F4_3<0b110101, 0b000001, (outs FPRegs:$rd),
1386 (ins FPRegs:$rs2, FPRegs:$f, CCOp:$cond),
1387 "fmovs$cond %icc, $rs2, $rd",
1388 [(set f32:$rd, (SPselecticc f32:$rs2, f32:$f, imm:$cond))]>;
1390 : F4_3<0b110101, 0b000010, (outs DFPRegs:$rd),
1391 (ins DFPRegs:$rs2, DFPRegs:$f, CCOp:$cond),
1392 "fmovd$cond %icc, $rs2, $rd",
1393 [(set f64:$rd, (SPselecticc f64:$rs2, f64:$f, imm:$cond))]>;
1395 : F4_3<0b110101, 0b000011, (outs QFPRegs:$rd),
1396 (ins QFPRegs:$rs2, QFPRegs:$f, CCOp:$cond),
1397 "fmovq$cond %icc, $rs2, $rd",
1398 [(set f128:$rd, (SPselecticc f128:$rs2, f128:$f, imm:$cond))]>,
1399 Requires<[HasHardQuad]>;
1402 let Uses = [FCC0], intcc = 0, opf_cc = 0b00 in {
1404 : F4_3<0b110101, 0b000001, (outs FPRegs:$rd),
1405 (ins FPRegs:$rs2, FPRegs:$f, CCOp:$cond),
1406 "fmovs$cond %fcc0, $rs2, $rd",
1407 [(set f32:$rd, (SPselectfcc f32:$rs2, f32:$f, imm:$cond))]>;
1409 : F4_3<0b110101, 0b000010, (outs DFPRegs:$rd),
1410 (ins DFPRegs:$rs2, DFPRegs:$f, CCOp:$cond),
1411 "fmovd$cond %fcc0, $rs2, $rd",
1412 [(set f64:$rd, (SPselectfcc f64:$rs2, f64:$f, imm:$cond))]>;
1414 : F4_3<0b110101, 0b000011, (outs QFPRegs:$rd),
1415 (ins QFPRegs:$rs2, QFPRegs:$f, CCOp:$cond),
1416 "fmovq$cond %fcc0, $rs2, $rd",
1417 [(set f128:$rd, (SPselectfcc f128:$rs2, f128:$f, imm:$cond))]>,
1418 Requires<[HasHardQuad]>;
1423 // Floating-Point Move Instructions, p. 164 of the V9 manual.
1424 let Predicates = [HasV9] in {
1425 def FMOVD : F3_3u<2, 0b110100, 0b000000010,
1426 (outs DFPRegs:$rd), (ins DFPRegs:$rs2),
1427 "fmovd $rs2, $rd", []>;
1428 def FMOVQ : F3_3u<2, 0b110100, 0b000000011,
1429 (outs QFPRegs:$rd), (ins QFPRegs:$rs2),
1430 "fmovq $rs2, $rd", []>,
1431 Requires<[HasHardQuad]>;
1432 def FNEGD : F3_3u<2, 0b110100, 0b000000110,
1433 (outs DFPRegs:$rd), (ins DFPRegs:$rs2),
1435 [(set f64:$rd, (fneg f64:$rs2))]>;
1436 def FNEGQ : F3_3u<2, 0b110100, 0b000000111,
1437 (outs QFPRegs:$rd), (ins QFPRegs:$rs2),
1439 [(set f128:$rd, (fneg f128:$rs2))]>,
1440 Requires<[HasHardQuad]>;
1441 def FABSD : F3_3u<2, 0b110100, 0b000001010,
1442 (outs DFPRegs:$rd), (ins DFPRegs:$rs2),
1444 [(set f64:$rd, (fabs f64:$rs2))]>;
1445 def FABSQ : F3_3u<2, 0b110100, 0b000001011,
1446 (outs QFPRegs:$rd), (ins QFPRegs:$rs2),
1448 [(set f128:$rd, (fabs f128:$rs2))]>,
1449 Requires<[HasHardQuad]>;
1452 // Floating-point compare instruction with %fcc0-%fcc3.
1453 def V9FCMPS : F3_3c<2, 0b110101, 0b001010001,
1454 (outs FCCRegs:$rd), (ins FPRegs:$rs1, FPRegs:$rs2),
1455 "fcmps $rd, $rs1, $rs2", []>;
1456 def V9FCMPD : F3_3c<2, 0b110101, 0b001010010,
1457 (outs FCCRegs:$rd), (ins DFPRegs:$rs1, DFPRegs:$rs2),
1458 "fcmpd $rd, $rs1, $rs2", []>;
1459 def V9FCMPQ : F3_3c<2, 0b110101, 0b001010011,
1460 (outs FCCRegs:$rd), (ins QFPRegs:$rs1, QFPRegs:$rs2),
1461 "fcmpq $rd, $rs1, $rs2", []>,
1462 Requires<[HasHardQuad]>;
1464 let hasSideEffects = 1 in {
1465 def V9FCMPES : F3_3c<2, 0b110101, 0b001010101,
1466 (outs FCCRegs:$rd), (ins FPRegs:$rs1, FPRegs:$rs2),
1467 "fcmpes $rd, $rs1, $rs2", []>;
1468 def V9FCMPED : F3_3c<2, 0b110101, 0b001010110,
1469 (outs FCCRegs:$rd), (ins DFPRegs:$rs1, DFPRegs:$rs2),
1470 "fcmped $rd, $rs1, $rs2", []>;
1471 def V9FCMPEQ : F3_3c<2, 0b110101, 0b001010111,
1472 (outs FCCRegs:$rd), (ins QFPRegs:$rs1, QFPRegs:$rs2),
1473 "fcmpeq $rd, $rs1, $rs2", []>,
1474 Requires<[HasHardQuad]>;
1477 // Floating point conditional move instrucitons with %fcc0-%fcc3.
1478 let Predicates = [HasV9] in {
1479 let Constraints = "$f = $rd", intcc = 0 in {
1481 : F4_1<0b101100, (outs IntRegs:$rd),
1482 (ins FCCRegs:$cc, IntRegs:$rs2, IntRegs:$f, CCOp:$cond),
1483 "mov$cond $cc, $rs2, $rd", []>;
1485 : F4_2<0b101100, (outs IntRegs:$rd),
1486 (ins FCCRegs:$cc, i32imm:$simm11, IntRegs:$f, CCOp:$cond),
1487 "mov$cond $cc, $simm11, $rd", []>;
1489 : F4_3<0b110101, 0b000001, (outs FPRegs:$rd),
1490 (ins FCCRegs:$opf_cc, FPRegs:$rs2, FPRegs:$f, CCOp:$cond),
1491 "fmovs$cond $opf_cc, $rs2, $rd", []>;
1493 : F4_3<0b110101, 0b000010, (outs DFPRegs:$rd),
1494 (ins FCCRegs:$opf_cc, DFPRegs:$rs2, DFPRegs:$f, CCOp:$cond),
1495 "fmovd$cond $opf_cc, $rs2, $rd", []>;
1497 : F4_3<0b110101, 0b000011, (outs QFPRegs:$rd),
1498 (ins FCCRegs:$opf_cc, QFPRegs:$rs2, QFPRegs:$f, CCOp:$cond),
1499 "fmovq$cond $opf_cc, $rs2, $rd", []>,
1500 Requires<[HasHardQuad]>;
1501 } // Constraints = "$f = $rd", ...
1502 } // let Predicates = [hasV9]
1505 // POPCrr - This does a ctpop of a 64-bit register. As such, we have to clear
1506 // the top 32-bits before using it. To do this clearing, we use a SRLri X,0.
1508 def POPCrr : F3_1<2, 0b101110,
1509 (outs IntRegs:$rd), (ins IntRegs:$rs2),
1510 "popc $rs2, $rd", []>, Requires<[HasV9]>;
1511 def : Pat<(i32 (ctpop i32:$src)),
1512 (POPCrr (SRLri $src, 0))>;
1514 let Predicates = [HasV9], hasSideEffects = 1, rd = 0, rs1 = 0b01111 in
1515 def MEMBARi : F3_2<2, 0b101000, (outs), (ins MembarTag:$simm13),
1516 "membar $simm13", []>;
1518 // The CAS instruction, unlike other instructions, only comes in a
1519 // form which requires an ASI be provided. The ASI value hardcoded
1520 // here is ASI_PRIMARY, the default unprivileged ASI for SparcV9.
1521 let Predicates = [HasV9], Constraints = "$swap = $rd", asi = 0b10000000 in
1522 def CASrr: F3_1_asi<3, 0b111100,
1523 (outs IntRegs:$rd), (ins IntRegs:$rs1, IntRegs:$rs2,
1525 "cas [$rs1], $rs2, $rd",
1527 (atomic_cmp_swap_32 iPTR:$rs1, i32:$rs2, i32:$swap))]>;
1530 // CASA is supported as an instruction on some LEON3 and all LEON4 processors.
1531 // This version can be automatically lowered from C code, selecting ASI 10
1532 let Predicates = [HasLeonCASA], Constraints = "$swap = $rd", asi = 0b00001010 in
1533 def CASAasi10: F3_1_asi<3, 0b111100,
1534 (outs IntRegs:$rd), (ins IntRegs:$rs1, IntRegs:$rs2,
1536 "casa [$rs1] 10, $rs2, $rd",
1538 (atomic_cmp_swap_32 iPTR:$rs1, i32:$rs2, i32:$swap))]>;
1540 // CASA supported on some LEON3 and all LEON4 processors. Same pattern as
1541 // CASrr, above, but with a different ASI. This version is supported for
1542 // inline assembly lowering only.
1543 let Predicates = [HasLeonCASA], Constraints = "$swap = $rd" in
1544 def CASArr: F3_1_asi<3, 0b111100,
1545 (outs IntRegs:$rd), (ins IntRegs:$rs1, IntRegs:$rs2,
1546 IntRegs:$swap, i8imm:$asi),
1547 "casa [$rs1] $asi, $rs2, $rd", []>;
1549 // TODO: Add DAG sequence to lower these instructions. Currently, only provided
1550 // as inline assembler-supported instructions.
1551 let Predicates = [HasUMAC_SMAC], Defs = [Y, ASR18], Uses = [Y, ASR18] in {
1552 def SMACrr : F3_1<2, 0b111111,
1553 (outs IntRegs:$rd), (ins IntRegs:$rs1, IntRegs:$rs2, ASRRegs:$asr18),
1554 "smac $rs1, $rs2, $rd",
1557 def SMACri : F3_2<2, 0b111111,
1558 (outs IntRegs:$rd), (ins IntRegs:$rs1, simm13Op:$simm13, ASRRegs:$asr18),
1559 "smac $rs1, $simm13, $rd",
1562 def UMACrr : F3_1<2, 0b111110,
1563 (outs IntRegs:$rd), (ins IntRegs:$rs1, IntRegs:$rs2, ASRRegs:$asr18),
1564 "umac $rs1, $rs2, $rd",
1567 def UMACri : F3_2<2, 0b111110,
1568 (outs IntRegs:$rd), (ins IntRegs:$rs1, simm13Op:$simm13, ASRRegs:$asr18),
1569 "umac $rs1, $simm13, $rd",
1573 // The partial write WRPSR instruction has a non-zero destination
1574 // register value to separate it from the standard instruction.
1575 let Predicates = [HasPWRPSR], Defs = [PSR], rd=1 in {
1576 def PWRPSRrr : F3_1<2, 0b110001,
1577 (outs), (ins IntRegs:$rs1, IntRegs:$rs2),
1578 "pwr $rs1, $rs2, %psr", []>;
1579 def PWRPSRri : F3_2<2, 0b110001,
1580 (outs), (ins IntRegs:$rs1, simm13Op:$simm13),
1581 "pwr $rs1, $simm13, %psr", []>;
1584 let Defs = [ICC] in {
1585 defm TADDCC : F3_12np<"taddcc", 0b100000>;
1586 defm TSUBCC : F3_12np<"tsubcc", 0b100001>;
1588 let hasSideEffects = 1 in {
1589 defm TADDCCTV : F3_12np<"taddcctv", 0b100010>;
1590 defm TSUBCCTV : F3_12np<"tsubcctv", 0b100011>;
1595 // Section A.43 - Read Privileged Register Instructions
1596 let Predicates = [HasV9] in {
1598 def RDPR : F3_1<2, 0b101010,
1599 (outs IntRegs:$rd), (ins PRRegs:$rs1),
1600 "rdpr $rs1, $rd", []>;
1603 // Section A.62 - Write Privileged Register Instructions
1604 let Predicates = [HasV9] in {
1605 def WRPRrr : F3_1<2, 0b110010,
1606 (outs PRRegs:$rd), (ins IntRegs:$rs1, IntRegs:$rs2),
1607 "wrpr $rs1, $rs2, $rd", []>;
1608 def WRPRri : F3_2<2, 0b110010,
1609 (outs PRRegs:$rd), (ins IntRegs:$rs1, simm13Op:$simm13),
1610 "wrpr $rs1, $simm13, $rd", []>;
1613 //===----------------------------------------------------------------------===//
1614 // Non-Instruction Patterns
1615 //===----------------------------------------------------------------------===//
1619 (ORrr (i32 G0), (i32 G0))>;
1620 // Small immediates.
1621 def : Pat<(i32 simm13:$val),
1622 (ORri (i32 G0), imm:$val)>;
1623 // Arbitrary immediates.
1624 def : Pat<(i32 imm:$val),
1625 (ORri (SETHIi (HI22 imm:$val)), (LO10 imm:$val))>;
1628 // Global addresses, constant pool entries
1629 let Predicates = [Is32Bit] in {
1631 def : Pat<(SPhi tglobaladdr:$in), (SETHIi tglobaladdr:$in)>;
1632 def : Pat<(SPlo tglobaladdr:$in), (ORri (i32 G0), tglobaladdr:$in)>;
1633 def : Pat<(SPhi tconstpool:$in), (SETHIi tconstpool:$in)>;
1634 def : Pat<(SPlo tconstpool:$in), (ORri (i32 G0), tconstpool:$in)>;
1636 // GlobalTLS addresses
1637 def : Pat<(SPhi tglobaltlsaddr:$in), (SETHIi tglobaltlsaddr:$in)>;
1638 def : Pat<(SPlo tglobaltlsaddr:$in), (ORri (i32 G0), tglobaltlsaddr:$in)>;
1639 def : Pat<(add (SPhi tglobaltlsaddr:$in1), (SPlo tglobaltlsaddr:$in2)),
1640 (ADDri (SETHIi tglobaltlsaddr:$in1), (tglobaltlsaddr:$in2))>;
1641 def : Pat<(xor (SPhi tglobaltlsaddr:$in1), (SPlo tglobaltlsaddr:$in2)),
1642 (XORri (SETHIi tglobaltlsaddr:$in1), (tglobaltlsaddr:$in2))>;
1645 def : Pat<(SPhi tblockaddress:$in), (SETHIi tblockaddress:$in)>;
1646 def : Pat<(SPlo tblockaddress:$in), (ORri (i32 G0), tblockaddress:$in)>;
1648 // Add reg, lo. This is used when taking the addr of a global/constpool entry.
1649 def : Pat<(add iPTR:$r, (SPlo tglobaladdr:$in)), (ADDri $r, tglobaladdr:$in)>;
1650 def : Pat<(add iPTR:$r, (SPlo tconstpool:$in)), (ADDri $r, tconstpool:$in)>;
1651 def : Pat<(add iPTR:$r, (SPlo tblockaddress:$in)),
1652 (ADDri $r, tblockaddress:$in)>;
1656 def : Pat<(call tglobaladdr:$dst),
1657 (CALL tglobaladdr:$dst)>;
1658 def : Pat<(call texternalsym:$dst),
1659 (CALL texternalsym:$dst)>;
1661 // Map integer extload's to zextloads.
1662 def : Pat<(i32 (extloadi1 ADDRrr:$src)), (LDUBrr ADDRrr:$src)>;
1663 def : Pat<(i32 (extloadi1 ADDRri:$src)), (LDUBri ADDRri:$src)>;
1664 def : Pat<(i32 (extloadi8 ADDRrr:$src)), (LDUBrr ADDRrr:$src)>;
1665 def : Pat<(i32 (extloadi8 ADDRri:$src)), (LDUBri ADDRri:$src)>;
1666 def : Pat<(i32 (extloadi16 ADDRrr:$src)), (LDUHrr ADDRrr:$src)>;
1667 def : Pat<(i32 (extloadi16 ADDRri:$src)), (LDUHri ADDRri:$src)>;
1669 // zextload bool -> zextload byte
1670 def : Pat<(i32 (zextloadi1 ADDRrr:$src)), (LDUBrr ADDRrr:$src)>;
1671 def : Pat<(i32 (zextloadi1 ADDRri:$src)), (LDUBri ADDRri:$src)>;
1673 // store 0, addr -> store %g0, addr
1674 def : Pat<(store (i32 0), ADDRrr:$dst), (STrr ADDRrr:$dst, (i32 G0))>;
1675 def : Pat<(store (i32 0), ADDRri:$dst), (STri ADDRri:$dst, (i32 G0))>;
1677 // store bar for all atomic_fence in V8.
1678 let Predicates = [HasNoV9] in
1679 def : Pat<(atomic_fence imm, imm), (STBAR)>;
1681 // atomic_load addr -> load addr
1682 def : Pat<(i32 (atomic_load_8 ADDRrr:$src)), (LDUBrr ADDRrr:$src)>;
1683 def : Pat<(i32 (atomic_load_8 ADDRri:$src)), (LDUBri ADDRri:$src)>;
1684 def : Pat<(i32 (atomic_load_16 ADDRrr:$src)), (LDUHrr ADDRrr:$src)>;
1685 def : Pat<(i32 (atomic_load_16 ADDRri:$src)), (LDUHri ADDRri:$src)>;
1686 def : Pat<(i32 (atomic_load_32 ADDRrr:$src)), (LDrr ADDRrr:$src)>;
1687 def : Pat<(i32 (atomic_load_32 ADDRri:$src)), (LDri ADDRri:$src)>;
1689 // atomic_store val, addr -> store val, addr
1690 def : Pat<(atomic_store_8 ADDRrr:$dst, i32:$val), (STBrr ADDRrr:$dst, $val)>;
1691 def : Pat<(atomic_store_8 ADDRri:$dst, i32:$val), (STBri ADDRri:$dst, $val)>;
1692 def : Pat<(atomic_store_16 ADDRrr:$dst, i32:$val), (STHrr ADDRrr:$dst, $val)>;
1693 def : Pat<(atomic_store_16 ADDRri:$dst, i32:$val), (STHri ADDRri:$dst, $val)>;
1694 def : Pat<(atomic_store_32 ADDRrr:$dst, i32:$val), (STrr ADDRrr:$dst, $val)>;
1695 def : Pat<(atomic_store_32 ADDRri:$dst, i32:$val), (STri ADDRri:$dst, $val)>;
1698 def : Pat<(extractelt (v2i32 IntPair:$Rn), 0),
1699 (i32 (EXTRACT_SUBREG IntPair:$Rn, sub_even))>;
1700 def : Pat<(extractelt (v2i32 IntPair:$Rn), 1),
1701 (i32 (EXTRACT_SUBREG IntPair:$Rn, sub_odd))>;
1704 def : Pat<(build_vector (i32 IntRegs:$a1), (i32 IntRegs:$a2)),
1706 (INSERT_SUBREG (v2i32 (IMPLICIT_DEF)), (i32 IntRegs:$a1), sub_even),
1707 (i32 IntRegs:$a2), sub_odd)>;
1710 include "SparcInstr64Bit.td"
1711 include "SparcInstrVIS.td"
1712 include "SparcInstrAliases.td"