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 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<(all_of 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], []>;
116 // Constrained operands for the shift operations.
117 class ShiftAmtImmAsmOperand<int Bits> : AsmOperandClass {
118 let Name = "ShiftAmtImm" # Bits;
119 let ParserMethod = "parseShiftAmtImm<" # Bits # ">";
121 def shift_imm5 : Operand<i32> {
122 let ParserMatchClass = ShiftAmtImmAsmOperand<5>;
124 def shift_imm6 : Operand<i32> {
125 let ParserMatchClass = ShiftAmtImmAsmOperand<6>;
129 def SparcMEMrrAsmOperand : AsmOperandClass {
131 let ParserMethod = "parseMEMOperand";
134 def SparcMEMriAsmOperand : AsmOperandClass {
136 let ParserMethod = "parseMEMOperand";
139 def MEMrr : Operand<iPTR> {
140 let PrintMethod = "printMemOperand";
141 let MIOperandInfo = (ops ptr_rc, ptr_rc);
142 let ParserMatchClass = SparcMEMrrAsmOperand;
144 def MEMri : Operand<iPTR> {
145 let PrintMethod = "printMemOperand";
146 let MIOperandInfo = (ops ptr_rc, i32imm);
147 let ParserMatchClass = SparcMEMriAsmOperand;
150 def TLSSym : Operand<iPTR>;
152 def SparcMembarTagAsmOperand : AsmOperandClass {
153 let Name = "MembarTag";
154 let ParserMethod = "parseMembarTag";
157 def MembarTag : Operand<i32> {
158 let PrintMethod = "printMembarTag";
159 let ParserMatchClass = SparcMembarTagAsmOperand;
162 // Branch targets have OtherVT type.
163 def brtarget : Operand<OtherVT> {
164 let EncoderMethod = "getBranchTargetOpValue";
167 def bprtarget : Operand<OtherVT> {
168 let EncoderMethod = "getBranchPredTargetOpValue";
171 def bprtarget16 : Operand<OtherVT> {
172 let EncoderMethod = "getBranchOnRegTargetOpValue";
175 def SparcCallTargetAsmOperand : AsmOperandClass {
176 let Name = "CallTarget";
177 let ParserMethod = "parseCallTarget";
180 def calltarget : Operand<i32> {
181 let EncoderMethod = "getCallTargetOpValue";
182 let DecoderMethod = "DecodeCall";
183 let ParserMatchClass = SparcCallTargetAsmOperand;
186 def simm13Op : Operand<i32> {
187 let DecoderMethod = "DecodeSIMM13";
188 let EncoderMethod = "getSImm13OpValue";
191 // Operand for printing out a condition code.
192 let PrintMethod = "printCCOperand" in
193 def CCOp : Operand<i32>;
196 SDTypeProfile<0, 2, [SDTCisInt<0>, SDTCisSameAs<0, 1>]>;
198 SDTypeProfile<0, 2, [SDTCisFP<0>, SDTCisSameAs<0, 1>]>;
200 SDTypeProfile<0, 2, [SDTCisVT<0, OtherVT>, SDTCisVT<1, i32>]>;
202 SDTypeProfile<1, 3, [SDTCisSameAs<0, 1>, SDTCisSameAs<1, 2>, SDTCisVT<3, i32>]>;
204 SDTypeProfile<1, 1, [SDTCisVT<0, f32>, SDTCisFP<1>]>;
206 SDTypeProfile<1, 1, [SDTCisFP<0>, SDTCisVT<1, f32>]>;
208 SDTypeProfile<1, 1, [SDTCisVT<0, f64>, SDTCisFP<1>]>;
210 SDTypeProfile<1, 1, [SDTCisFP<0>, SDTCisVT<1, f64>]>;
213 SDTypeProfile<1, 3, [SDTCisInt<0>, SDTCisSameAs<0, 1>, SDTCisPtrTy<2>]>;
215 SDTypeProfile<1, 2, [SDTCisPtrTy<0>, SDTCisPtrTy<1>]>;
217 def SPcmpicc : SDNode<"SPISD::CMPICC", SDTSPcmpicc, [SDNPOutGlue]>;
218 def SPcmpfcc : SDNode<"SPISD::CMPFCC", SDTSPcmpfcc, [SDNPOutGlue]>;
219 def SPbricc : SDNode<"SPISD::BRICC", SDTSPbrcc, [SDNPHasChain, SDNPInGlue]>;
220 def SPbrxcc : SDNode<"SPISD::BRXCC", SDTSPbrcc, [SDNPHasChain, SDNPInGlue]>;
221 def SPbrfcc : SDNode<"SPISD::BRFCC", SDTSPbrcc, [SDNPHasChain, SDNPInGlue]>;
223 def SPhi : SDNode<"SPISD::Hi", SDTIntUnaryOp>;
224 def SPlo : SDNode<"SPISD::Lo", SDTIntUnaryOp>;
226 def SPftoi : SDNode<"SPISD::FTOI", SDTSPFTOI>;
227 def SPitof : SDNode<"SPISD::ITOF", SDTSPITOF>;
228 def SPftox : SDNode<"SPISD::FTOX", SDTSPFTOX>;
229 def SPxtof : SDNode<"SPISD::XTOF", SDTSPXTOF>;
231 def SPselecticc : SDNode<"SPISD::SELECT_ICC", SDTSPselectcc, [SDNPInGlue]>;
232 def SPselectxcc : SDNode<"SPISD::SELECT_XCC", SDTSPselectcc, [SDNPInGlue]>;
233 def SPselectfcc : SDNode<"SPISD::SELECT_FCC", SDTSPselectcc, [SDNPInGlue]>;
235 // These are target-independent nodes, but have target-specific formats.
236 def SDT_SPCallSeqStart : SDCallSeqStart<[ SDTCisVT<0, i32>,
238 def SDT_SPCallSeqEnd : SDCallSeqEnd<[ SDTCisVT<0, i32>,
241 def callseq_start : SDNode<"ISD::CALLSEQ_START", SDT_SPCallSeqStart,
242 [SDNPHasChain, SDNPOutGlue]>;
243 def callseq_end : SDNode<"ISD::CALLSEQ_END", SDT_SPCallSeqEnd,
244 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue]>;
246 def SDT_SPCall : SDTypeProfile<0, -1, [SDTCisVT<0, i32>]>;
247 def call : SDNode<"SPISD::CALL", SDT_SPCall,
248 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
251 def SDT_SPRet : SDTypeProfile<0, 1, [SDTCisVT<0, i32>]>;
252 def retflag : SDNode<"SPISD::RET_FLAG", SDT_SPRet,
253 [SDNPHasChain, SDNPOptInGlue, SDNPVariadic]>;
255 def flushw : SDNode<"SPISD::FLUSHW", SDTNone,
256 [SDNPHasChain, SDNPSideEffect, SDNPMayStore]>;
258 def tlsadd : SDNode<"SPISD::TLS_ADD", SDTSPtlsadd>;
259 def tlsld : SDNode<"SPISD::TLS_LD", SDTSPtlsld>;
260 def tlscall : SDNode<"SPISD::TLS_CALL", SDT_SPCall,
261 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
264 def getPCX : Operand<iPTR> {
265 let PrintMethod = "printGetPCX";
268 //===----------------------------------------------------------------------===//
269 // SPARC Flag Conditions
270 //===----------------------------------------------------------------------===//
272 // Note that these values must be kept in sync with the CCOp::CondCode enum
274 class ICC_VAL<int N> : PatLeaf<(i32 N)>;
275 def ICC_NE : ICC_VAL< 9>; // Not Equal
276 def ICC_E : ICC_VAL< 1>; // Equal
277 def ICC_G : ICC_VAL<10>; // Greater
278 def ICC_LE : ICC_VAL< 2>; // Less or Equal
279 def ICC_GE : ICC_VAL<11>; // Greater or Equal
280 def ICC_L : ICC_VAL< 3>; // Less
281 def ICC_GU : ICC_VAL<12>; // Greater Unsigned
282 def ICC_LEU : ICC_VAL< 4>; // Less or Equal Unsigned
283 def ICC_CC : ICC_VAL<13>; // Carry Clear/Great or Equal Unsigned
284 def ICC_CS : ICC_VAL< 5>; // Carry Set/Less Unsigned
285 def ICC_POS : ICC_VAL<14>; // Positive
286 def ICC_NEG : ICC_VAL< 6>; // Negative
287 def ICC_VC : ICC_VAL<15>; // Overflow Clear
288 def ICC_VS : ICC_VAL< 7>; // Overflow Set
290 class FCC_VAL<int N> : PatLeaf<(i32 N)>;
291 def FCC_U : FCC_VAL<23>; // Unordered
292 def FCC_G : FCC_VAL<22>; // Greater
293 def FCC_UG : FCC_VAL<21>; // Unordered or Greater
294 def FCC_L : FCC_VAL<20>; // Less
295 def FCC_UL : FCC_VAL<19>; // Unordered or Less
296 def FCC_LG : FCC_VAL<18>; // Less or Greater
297 def FCC_NE : FCC_VAL<17>; // Not Equal
298 def FCC_E : FCC_VAL<25>; // Equal
299 def FCC_UE : FCC_VAL<26>; // Unordered or Equal
300 def FCC_GE : FCC_VAL<27>; // Greater or Equal
301 def FCC_UGE : FCC_VAL<28>; // Unordered or Greater or Equal
302 def FCC_LE : FCC_VAL<29>; // Less or Equal
303 def FCC_ULE : FCC_VAL<30>; // Unordered or Less or Equal
304 def FCC_O : FCC_VAL<31>; // Ordered
306 class CPCC_VAL<int N> : PatLeaf<(i32 N)>;
307 def CPCC_3 : CPCC_VAL<39>; // 3
308 def CPCC_2 : CPCC_VAL<38>; // 2
309 def CPCC_23 : CPCC_VAL<37>; // 2 or 3
310 def CPCC_1 : CPCC_VAL<36>; // 1
311 def CPCC_13 : CPCC_VAL<35>; // 1 or 3
312 def CPCC_12 : CPCC_VAL<34>; // 1 or 2
313 def CPCC_123 : CPCC_VAL<33>; // 1 or 2 or 3
314 def CPCC_0 : CPCC_VAL<41>; // 0
315 def CPCC_03 : CPCC_VAL<42>; // 0 or 3
316 def CPCC_02 : CPCC_VAL<43>; // 0 or 2
317 def CPCC_023 : CPCC_VAL<44>; // 0 or 2 or 3
318 def CPCC_01 : CPCC_VAL<45>; // 0 or 1
319 def CPCC_013 : CPCC_VAL<46>; // 0 or 1 or 3
320 def CPCC_012 : CPCC_VAL<47>; // 0 or 1 or 2
322 //===----------------------------------------------------------------------===//
323 // Instruction Class Templates
324 //===----------------------------------------------------------------------===//
326 /// F3_12 multiclass - Define a normal F3_1/F3_2 pattern in one shot.
327 multiclass F3_12<string OpcStr, bits<6> Op3Val, SDNode OpNode,
328 RegisterClass RC, ValueType Ty, Operand immOp,
329 InstrItinClass itin = IIC_iu_instr> {
330 def rr : F3_1<2, Op3Val,
331 (outs RC:$rd), (ins RC:$rs1, RC:$rs2),
332 !strconcat(OpcStr, " $rs1, $rs2, $rd"),
333 [(set Ty:$rd, (OpNode Ty:$rs1, Ty:$rs2))],
335 def ri : F3_2<2, Op3Val,
336 (outs RC:$rd), (ins RC:$rs1, immOp:$simm13),
337 !strconcat(OpcStr, " $rs1, $simm13, $rd"),
338 [(set Ty:$rd, (OpNode Ty:$rs1, (Ty simm13:$simm13)))],
342 /// F3_12np multiclass - Define a normal F3_1/F3_2 pattern in one shot, with no
344 multiclass F3_12np<string OpcStr, bits<6> Op3Val, InstrItinClass itin = IIC_iu_instr> {
345 def rr : F3_1<2, Op3Val,
346 (outs IntRegs:$rd), (ins IntRegs:$rs1, IntRegs:$rs2),
347 !strconcat(OpcStr, " $rs1, $rs2, $rd"), [],
349 def ri : F3_2<2, Op3Val,
350 (outs IntRegs:$rd), (ins IntRegs:$rs1, simm13Op:$simm13),
351 !strconcat(OpcStr, " $rs1, $simm13, $rd"), [],
355 // Load multiclass - Define both Reg+Reg/Reg+Imm patterns in one shot.
356 multiclass Load<string OpcStr, bits<6> Op3Val, SDPatternOperator OpNode,
357 RegisterClass RC, ValueType Ty, InstrItinClass itin = IIC_iu_instr> {
358 def rr : F3_1<3, Op3Val,
359 (outs RC:$dst), (ins MEMrr:$addr),
360 !strconcat(OpcStr, " [$addr], $dst"),
361 [(set Ty:$dst, (OpNode ADDRrr:$addr))],
363 def ri : F3_2<3, Op3Val,
364 (outs RC:$dst), (ins MEMri:$addr),
365 !strconcat(OpcStr, " [$addr], $dst"),
366 [(set Ty:$dst, (OpNode ADDRri:$addr))],
370 // TODO: Instructions of the LoadASI class are currently asm only; hooking up
371 // CodeGen's address spaces to use these is a future task.
372 class LoadASI<string OpcStr, bits<6> Op3Val, SDPatternOperator OpNode,
373 RegisterClass RC, ValueType Ty, InstrItinClass itin = NoItinerary> :
374 F3_1_asi<3, Op3Val, (outs RC:$dst), (ins MEMrr:$addr, i8imm:$asi),
375 !strconcat(OpcStr, "a [$addr] $asi, $dst"),
378 // LoadA multiclass - As above, but also define alternate address space variant
379 multiclass LoadA<string OpcStr, bits<6> Op3Val, bits<6> LoadAOp3Val,
380 SDPatternOperator OpNode, RegisterClass RC, ValueType Ty,
381 InstrItinClass itin = NoItinerary> :
382 Load<OpcStr, Op3Val, OpNode, RC, Ty, itin> {
383 def Arr : LoadASI<OpcStr, LoadAOp3Val, OpNode, RC, Ty>;
386 // The LDSTUB instruction is supported for asm only.
387 // It is unlikely that general-purpose code could make use of it.
388 // CAS is preferred for sparc v9.
389 def LDSTUBrr : F3_1<3, 0b001101, (outs IntRegs:$dst), (ins MEMrr:$addr),
390 "ldstub [$addr], $dst", []>;
391 def LDSTUBri : F3_2<3, 0b001101, (outs IntRegs:$dst), (ins MEMri:$addr),
392 "ldstub [$addr], $dst", []>;
393 def LDSTUBArr : F3_1_asi<3, 0b011101, (outs IntRegs:$dst),
394 (ins MEMrr:$addr, i8imm:$asi),
395 "ldstuba [$addr] $asi, $dst", []>;
397 // Store multiclass - Define both Reg+Reg/Reg+Imm patterns in one shot.
398 multiclass Store<string OpcStr, bits<6> Op3Val, SDPatternOperator OpNode,
399 RegisterClass RC, ValueType Ty, InstrItinClass itin = IIC_st> {
400 def rr : F3_1<3, Op3Val,
401 (outs), (ins MEMrr:$addr, RC:$rd),
402 !strconcat(OpcStr, " $rd, [$addr]"),
403 [(OpNode Ty:$rd, ADDRrr:$addr)],
405 def ri : F3_2<3, Op3Val,
406 (outs), (ins MEMri:$addr, RC:$rd),
407 !strconcat(OpcStr, " $rd, [$addr]"),
408 [(OpNode Ty:$rd, ADDRri:$addr)],
412 // TODO: Instructions of the StoreASI class are currently asm only; hooking up
413 // CodeGen's address spaces to use these is a future task.
414 class StoreASI<string OpcStr, bits<6> Op3Val,
415 SDPatternOperator OpNode, RegisterClass RC, ValueType Ty,
416 InstrItinClass itin = IIC_st> :
417 F3_1_asi<3, Op3Val, (outs), (ins MEMrr:$addr, RC:$rd, i8imm:$asi),
418 !strconcat(OpcStr, "a $rd, [$addr] $asi"),
422 multiclass StoreA<string OpcStr, bits<6> Op3Val, bits<6> StoreAOp3Val,
423 SDPatternOperator OpNode, RegisterClass RC, ValueType Ty,
424 InstrItinClass itin = IIC_st> :
425 Store<OpcStr, Op3Val, OpNode, RC, Ty> {
426 def Arr : StoreASI<OpcStr, StoreAOp3Val, OpNode, RC, Ty, itin>;
429 //===----------------------------------------------------------------------===//
431 //===----------------------------------------------------------------------===//
433 // Pseudo instructions.
434 class Pseudo<dag outs, dag ins, string asmstr, list<dag> pattern>
435 : InstSP<outs, ins, asmstr, pattern> {
436 let isCodeGenOnly = 1;
442 def GETPCX : Pseudo<(outs getPCX:$getpcseq), (ins), "$getpcseq", [] >;
445 let Defs = [O6], Uses = [O6] in {
446 def ADJCALLSTACKDOWN : Pseudo<(outs), (ins i32imm:$amt1, i32imm:$amt2),
447 "!ADJCALLSTACKDOWN $amt1, $amt2",
448 [(callseq_start timm:$amt1, timm:$amt2)]>;
449 def ADJCALLSTACKUP : Pseudo<(outs), (ins i32imm:$amt1, i32imm:$amt2),
450 "!ADJCALLSTACKUP $amt1",
451 [(callseq_end timm:$amt1, timm:$amt2)]>;
454 let hasSideEffects = 1, mayStore = 1 in {
455 let rd = 0, rs1 = 0, rs2 = 0 in
456 def FLUSHW : F3_1<0b10, 0b101011, (outs), (ins),
458 [(flushw)]>, Requires<[HasV9]>;
459 let rd = 8, rs1 = 0, simm13 = 3 in
460 def TA3 : F3_2<0b10, 0b111010, (outs), (ins),
465 // SELECT_CC_* - Used to implement the SELECT_CC DAG operation. Expanded after
466 // instruction selection into a branch sequence. This has to handle all
467 // permutations of selection between i32/f32/f64 on ICC and FCC.
468 // Expanded after instruction selection.
469 let Uses = [ICC], usesCustomInserter = 1 in {
470 def SELECT_CC_Int_ICC
471 : Pseudo<(outs IntRegs:$dst), (ins IntRegs:$T, IntRegs:$F, i32imm:$Cond),
472 "; SELECT_CC_Int_ICC PSEUDO!",
473 [(set i32:$dst, (SPselecticc i32:$T, i32:$F, imm:$Cond))]>;
475 : Pseudo<(outs FPRegs:$dst), (ins FPRegs:$T, FPRegs:$F, i32imm:$Cond),
476 "; SELECT_CC_FP_ICC PSEUDO!",
477 [(set f32:$dst, (SPselecticc f32:$T, f32:$F, imm:$Cond))]>;
479 def SELECT_CC_DFP_ICC
480 : Pseudo<(outs DFPRegs:$dst), (ins DFPRegs:$T, DFPRegs:$F, i32imm:$Cond),
481 "; SELECT_CC_DFP_ICC PSEUDO!",
482 [(set f64:$dst, (SPselecticc f64:$T, f64:$F, imm:$Cond))]>;
484 def SELECT_CC_QFP_ICC
485 : Pseudo<(outs QFPRegs:$dst), (ins QFPRegs:$T, QFPRegs:$F, i32imm:$Cond),
486 "; SELECT_CC_QFP_ICC PSEUDO!",
487 [(set f128:$dst, (SPselecticc f128:$T, f128:$F, imm:$Cond))]>;
490 let usesCustomInserter = 1, Uses = [FCC0] in {
492 def SELECT_CC_Int_FCC
493 : Pseudo<(outs IntRegs:$dst), (ins IntRegs:$T, IntRegs:$F, i32imm:$Cond),
494 "; SELECT_CC_Int_FCC PSEUDO!",
495 [(set i32:$dst, (SPselectfcc i32:$T, i32:$F, imm:$Cond))]>;
498 : Pseudo<(outs FPRegs:$dst), (ins FPRegs:$T, FPRegs:$F, i32imm:$Cond),
499 "; SELECT_CC_FP_FCC PSEUDO!",
500 [(set f32:$dst, (SPselectfcc f32:$T, f32:$F, imm:$Cond))]>;
501 def SELECT_CC_DFP_FCC
502 : Pseudo<(outs DFPRegs:$dst), (ins DFPRegs:$T, DFPRegs:$F, i32imm:$Cond),
503 "; SELECT_CC_DFP_FCC PSEUDO!",
504 [(set f64:$dst, (SPselectfcc f64:$T, f64:$F, imm:$Cond))]>;
505 def SELECT_CC_QFP_FCC
506 : Pseudo<(outs QFPRegs:$dst), (ins QFPRegs:$T, QFPRegs:$F, i32imm:$Cond),
507 "; SELECT_CC_QFP_FCC PSEUDO!",
508 [(set f128:$dst, (SPselectfcc f128:$T, f128:$F, imm:$Cond))]>;
511 // Section B.1 - Load Integer Instructions, p. 90
512 let DecoderMethod = "DecodeLoadInt" in {
513 defm LDSB : LoadA<"ldsb", 0b001001, 0b011001, sextloadi8, IntRegs, i32>;
514 defm LDSH : LoadA<"ldsh", 0b001010, 0b011010, sextloadi16, IntRegs, i32>;
515 defm LDUB : LoadA<"ldub", 0b000001, 0b010001, zextloadi8, IntRegs, i32>;
516 defm LDUH : LoadA<"lduh", 0b000010, 0b010010, zextloadi16, IntRegs, i32>;
517 defm LD : LoadA<"ld", 0b000000, 0b010000, load, IntRegs, i32>;
520 let DecoderMethod = "DecodeLoadIntPair" in
521 defm LDD : LoadA<"ldd", 0b000011, 0b010011, load, IntPair, v2i32, IIC_ldd>;
523 // Section B.2 - Load Floating-point Instructions, p. 92
524 let DecoderMethod = "DecodeLoadFP" in {
525 defm LDF : Load<"ld", 0b100000, load, FPRegs, f32, IIC_iu_or_fpu_instr>;
526 def LDFArr : LoadASI<"ld", 0b110000, load, FPRegs, f32, IIC_iu_or_fpu_instr>,
529 let DecoderMethod = "DecodeLoadDFP" in {
530 defm LDDF : Load<"ldd", 0b100011, load, DFPRegs, f64, IIC_ldd>;
531 def LDDFArr : LoadASI<"ldd", 0b110011, load, DFPRegs, f64>,
534 let DecoderMethod = "DecodeLoadQFP" in
535 defm LDQF : LoadA<"ldq", 0b100010, 0b110010, load, QFPRegs, f128>,
536 Requires<[HasV9, HasHardQuad]>;
538 let DecoderMethod = "DecodeLoadCP" in
539 defm LDC : Load<"ld", 0b110000, load, CoprocRegs, i32>;
540 let DecoderMethod = "DecodeLoadCPPair" in
541 defm LDDC : Load<"ldd", 0b110011, load, CoprocPair, v2i32, IIC_ldd>;
543 let DecoderMethod = "DecodeLoadCP", Defs = [CPSR] in {
545 def LDCSRrr : F3_1<3, 0b110001, (outs), (ins MEMrr:$addr),
546 "ld [$addr], %csr", []>;
547 def LDCSRri : F3_2<3, 0b110001, (outs), (ins MEMri:$addr),
548 "ld [$addr], %csr", []>;
552 let DecoderMethod = "DecodeLoadFP" in
553 let Defs = [FSR] in {
555 def LDFSRrr : F3_1<3, 0b100001, (outs), (ins MEMrr:$addr),
556 "ld [$addr], %fsr", [], IIC_iu_or_fpu_instr>;
557 def LDFSRri : F3_2<3, 0b100001, (outs), (ins MEMri:$addr),
558 "ld [$addr], %fsr", [], IIC_iu_or_fpu_instr>;
561 def LDXFSRrr : F3_1<3, 0b100001, (outs), (ins MEMrr:$addr),
562 "ldx [$addr], %fsr", []>, Requires<[HasV9]>;
563 def LDXFSRri : F3_2<3, 0b100001, (outs), (ins MEMri:$addr),
564 "ldx [$addr], %fsr", []>, Requires<[HasV9]>;
568 // Section B.4 - Store Integer Instructions, p. 95
569 let DecoderMethod = "DecodeStoreInt" in {
570 defm STB : StoreA<"stb", 0b000101, 0b010101, truncstorei8, IntRegs, i32>;
571 defm STH : StoreA<"sth", 0b000110, 0b010110, truncstorei16, IntRegs, i32>;
572 defm ST : StoreA<"st", 0b000100, 0b010100, store, IntRegs, i32>;
575 let DecoderMethod = "DecodeStoreIntPair" in
576 defm STD : StoreA<"std", 0b000111, 0b010111, store, IntPair, v2i32, IIC_std>;
578 // Section B.5 - Store Floating-point Instructions, p. 97
579 let DecoderMethod = "DecodeStoreFP" in {
580 defm STF : Store<"st", 0b100100, store, FPRegs, f32>;
581 def STFArr : StoreASI<"st", 0b110100, store, FPRegs, f32>,
584 let DecoderMethod = "DecodeStoreDFP" in {
585 defm STDF : Store<"std", 0b100111, store, DFPRegs, f64, IIC_std>;
586 def STDFArr : StoreASI<"std", 0b110111, store, DFPRegs, f64>,
589 let DecoderMethod = "DecodeStoreQFP" in
590 defm STQF : StoreA<"stq", 0b100110, 0b110110, store, QFPRegs, f128>,
591 Requires<[HasV9, HasHardQuad]>;
593 let DecoderMethod = "DecodeStoreCP" in
594 defm STC : Store<"st", 0b110100, store, CoprocRegs, i32>;
596 let DecoderMethod = "DecodeStoreCPPair" in
597 defm STDC : Store<"std", 0b110111, store, CoprocPair, v2i32, IIC_std>;
599 let DecoderMethod = "DecodeStoreCP", rd = 0 in {
600 let Defs = [CPSR] in {
601 def STCSRrr : F3_1<3, 0b110101, (outs MEMrr:$addr), (ins),
602 "st %csr, [$addr]", [], IIC_st>;
603 def STCSRri : F3_2<3, 0b110101, (outs MEMri:$addr), (ins),
604 "st %csr, [$addr]", [], IIC_st>;
606 let Defs = [CPQ] in {
607 def STDCQrr : F3_1<3, 0b110110, (outs MEMrr:$addr), (ins),
608 "std %cq, [$addr]", [], IIC_std>;
609 def STDCQri : F3_2<3, 0b110110, (outs MEMri:$addr), (ins),
610 "std %cq, [$addr]", [], IIC_std>;
614 let DecoderMethod = "DecodeStoreFP" in {
616 let Defs = [FSR] in {
617 def STFSRrr : F3_1<3, 0b100101, (outs MEMrr:$addr), (ins),
618 "st %fsr, [$addr]", [], IIC_st>;
619 def STFSRri : F3_2<3, 0b100101, (outs MEMri:$addr), (ins),
620 "st %fsr, [$addr]", [], IIC_st>;
623 def STDFQrr : F3_1<3, 0b100110, (outs MEMrr:$addr), (ins),
624 "std %fq, [$addr]", [], IIC_std>;
625 def STDFQri : F3_2<3, 0b100110, (outs MEMri:$addr), (ins),
626 "std %fq, [$addr]", [], IIC_std>;
629 let rd = 1, Defs = [FSR] in {
630 def STXFSRrr : F3_1<3, 0b100101, (outs MEMrr:$addr), (ins),
631 "stx %fsr, [$addr]", []>, Requires<[HasV9]>;
632 def STXFSRri : F3_2<3, 0b100101, (outs MEMri:$addr), (ins),
633 "stx %fsr, [$addr]", []>, Requires<[HasV9]>;
637 // Section B.8 - SWAP Register with Memory Instruction
639 let Constraints = "$val = $dst", DecoderMethod = "DecodeSWAP" in {
640 def SWAPrr : F3_1<3, 0b001111,
641 (outs IntRegs:$dst), (ins MEMrr:$addr, IntRegs:$val),
642 "swap [$addr], $dst",
643 [(set i32:$dst, (atomic_swap_32 ADDRrr:$addr, i32:$val))]>;
644 def SWAPri : F3_2<3, 0b001111,
645 (outs IntRegs:$dst), (ins MEMri:$addr, IntRegs:$val),
646 "swap [$addr], $dst",
647 [(set i32:$dst, (atomic_swap_32 ADDRri:$addr, i32:$val))]>;
648 def SWAPArr : F3_1_asi<3, 0b011111,
649 (outs IntRegs:$dst), (ins MEMrr:$addr, i8imm:$asi, IntRegs:$val),
650 "swapa [$addr] $asi, $dst",
651 [/*FIXME: pattern?*/]>;
655 // Section B.9 - SETHI Instruction, p. 104
656 def SETHIi: F2_1<0b100,
657 (outs IntRegs:$rd), (ins i32imm:$imm22),
659 [(set i32:$rd, SETHIimm:$imm22)],
662 // Section B.10 - NOP Instruction, p. 105
663 // (It's a special case of SETHI)
664 let rd = 0, imm22 = 0 in
665 def NOP : F2_1<0b100, (outs), (ins), "nop", []>;
667 // Section B.11 - Logical Instructions, p. 106
668 defm AND : F3_12<"and", 0b000001, and, IntRegs, i32, simm13Op>;
670 def ANDNrr : F3_1<2, 0b000101,
671 (outs IntRegs:$rd), (ins IntRegs:$rs1, IntRegs:$rs2),
672 "andn $rs1, $rs2, $rd",
673 [(set i32:$rd, (and i32:$rs1, (not i32:$rs2)))]>;
674 def ANDNri : F3_2<2, 0b000101,
675 (outs IntRegs:$rd), (ins IntRegs:$rs1, simm13Op:$simm13),
676 "andn $rs1, $simm13, $rd", []>;
678 defm OR : F3_12<"or", 0b000010, or, IntRegs, i32, simm13Op>;
680 def ORNrr : F3_1<2, 0b000110,
681 (outs IntRegs:$rd), (ins IntRegs:$rs1, IntRegs:$rs2),
682 "orn $rs1, $rs2, $rd",
683 [(set i32:$rd, (or i32:$rs1, (not i32:$rs2)))]>;
684 def ORNri : F3_2<2, 0b000110,
685 (outs IntRegs:$rd), (ins IntRegs:$rs1, simm13Op:$simm13),
686 "orn $rs1, $simm13, $rd", []>;
687 defm XOR : F3_12<"xor", 0b000011, xor, IntRegs, i32, simm13Op>;
689 def XNORrr : F3_1<2, 0b000111,
690 (outs IntRegs:$rd), (ins IntRegs:$rs1, IntRegs:$rs2),
691 "xnor $rs1, $rs2, $rd",
692 [(set i32:$rd, (not (xor i32:$rs1, i32:$rs2)))]>;
693 def XNORri : F3_2<2, 0b000111,
694 (outs IntRegs:$rd), (ins IntRegs:$rs1, simm13Op:$simm13),
695 "xnor $rs1, $simm13, $rd", []>;
697 def : Pat<(and IntRegs:$rs1, SETHIimm_not:$rs2),
698 (ANDNrr i32:$rs1, (SETHIi SETHIimm_not:$rs2))>;
700 def : Pat<(or IntRegs:$rs1, SETHIimm_not:$rs2),
701 (ORNrr i32:$rs1, (SETHIi SETHIimm_not:$rs2))>;
703 let Defs = [ICC] in {
704 defm ANDCC : F3_12np<"andcc", 0b010001>;
705 defm ANDNCC : F3_12np<"andncc", 0b010101>;
706 defm ORCC : F3_12np<"orcc", 0b010010>;
707 defm ORNCC : F3_12np<"orncc", 0b010110>;
708 defm XORCC : F3_12np<"xorcc", 0b010011>;
709 defm XNORCC : F3_12np<"xnorcc", 0b010111>;
712 // Section B.12 - Shift Instructions, p. 107
713 defm SLL : F3_S<"sll", 0b100101, 0, shl, i32, shift_imm5, IntRegs>;
714 defm SRL : F3_S<"srl", 0b100110, 0, srl, i32, shift_imm5, IntRegs>;
715 defm SRA : F3_S<"sra", 0b100111, 0, sra, i32, shift_imm5, IntRegs>;
717 // Section B.13 - Add Instructions, p. 108
718 defm ADD : F3_12<"add", 0b000000, add, IntRegs, i32, simm13Op>;
720 // "LEA" forms of add (patterns to make tblgen happy)
721 let Predicates = [Is32Bit], isCodeGenOnly = 1 in
722 def LEA_ADDri : F3_2<2, 0b000000,
723 (outs IntRegs:$dst), (ins MEMri:$addr),
724 "add ${addr:arith}, $dst",
725 [(set iPTR:$dst, ADDRri:$addr)]>;
728 defm ADDCC : F3_12<"addcc", 0b010000, addc, IntRegs, i32, simm13Op>;
731 defm ADDC : F3_12np<"addx", 0b001000>;
733 let Uses = [ICC], Defs = [ICC] in
734 defm ADDE : F3_12<"addxcc", 0b011000, adde, IntRegs, i32, simm13Op>;
736 // Section B.15 - Subtract Instructions, p. 110
737 defm SUB : F3_12 <"sub" , 0b000100, sub, IntRegs, i32, simm13Op>;
738 let Uses = [ICC], Defs = [ICC] in
739 defm SUBE : F3_12 <"subxcc" , 0b011100, sube, IntRegs, i32, simm13Op>;
742 defm SUBCC : F3_12 <"subcc", 0b010100, subc, IntRegs, i32, simm13Op>;
745 defm SUBC : F3_12np <"subx", 0b001100>;
747 // cmp (from Section A.3) is a specialized alias for subcc
748 let Defs = [ICC], rd = 0 in {
749 def CMPrr : F3_1<2, 0b010100,
750 (outs), (ins IntRegs:$rs1, IntRegs:$rs2),
752 [(SPcmpicc i32:$rs1, i32:$rs2)]>;
753 def CMPri : F3_2<2, 0b010100,
754 (outs), (ins IntRegs:$rs1, simm13Op:$simm13),
756 [(SPcmpicc i32:$rs1, (i32 simm13:$simm13))]>;
759 // Section B.18 - Multiply Instructions, p. 113
761 defm UMUL : F3_12<"umul", 0b001010, umullohi, IntRegs, i32, simm13Op, IIC_iu_umul>;
762 defm SMUL : F3_12<"smul", 0b001011, smullohi, IntRegs, i32, simm13Op, IIC_iu_smul>;
765 let Defs = [Y, ICC] in {
766 defm UMULCC : F3_12np<"umulcc", 0b011010, IIC_iu_umul>;
767 defm SMULCC : F3_12np<"smulcc", 0b011011, IIC_iu_smul>;
770 let Defs = [Y, ICC], Uses = [Y, ICC] in {
771 defm MULSCC : F3_12np<"mulscc", 0b100100>;
774 // Section B.19 - Divide Instructions, p. 115
775 let Uses = [Y], Defs = [Y] in {
776 defm UDIV : F3_12np<"udiv", 0b001110, IIC_iu_div>;
777 defm SDIV : F3_12np<"sdiv", 0b001111, IIC_iu_div>;
780 let Uses = [Y], Defs = [Y, ICC] in {
781 defm UDIVCC : F3_12np<"udivcc", 0b011110, IIC_iu_div>;
782 defm SDIVCC : F3_12np<"sdivcc", 0b011111, IIC_iu_div>;
785 // Section B.20 - SAVE and RESTORE, p. 117
786 defm SAVE : F3_12np<"save" , 0b111100>;
787 defm RESTORE : F3_12np<"restore", 0b111101>;
789 // Section B.21 - Branch on Integer Condition Codes Instructions, p. 119
791 // unconditional branch class.
792 class BranchAlways<dag ins, string asmstr, list<dag> pattern>
793 : F2_2<0b010, 0, (outs), ins, asmstr, pattern> {
795 let isTerminator = 1;
796 let hasDelaySlot = 1;
801 def BA : BranchAlways<(ins brtarget:$imm22), "ba $imm22", [(br bb:$imm22)]>;
804 let isBranch = 1, isTerminator = 1, hasDelaySlot = 1 in {
806 // conditional branch class:
807 class BranchSP<dag ins, string asmstr, list<dag> pattern>
808 : F2_2<0b010, 0, (outs), ins, asmstr, pattern, IIC_iu_instr>;
810 // conditional branch with annul class:
811 class BranchSPA<dag ins, string asmstr, list<dag> pattern>
812 : F2_2<0b010, 1, (outs), ins, asmstr, pattern, IIC_iu_instr>;
814 // Conditional branch class on %icc|%xcc with predication:
815 multiclass IPredBranch<string regstr, list<dag> CCPattern> {
816 def CC : F2_3<0b001, 0, 1, (outs), (ins bprtarget:$imm19, CCOp:$cond),
817 !strconcat("b$cond ", !strconcat(regstr, ", $imm19")),
820 def CCA : F2_3<0b001, 1, 1, (outs), (ins bprtarget:$imm19, CCOp:$cond),
821 !strconcat("b$cond,a ", !strconcat(regstr, ", $imm19")),
824 def CCNT : F2_3<0b001, 0, 0, (outs), (ins bprtarget:$imm19, CCOp:$cond),
825 !strconcat("b$cond,pn ", !strconcat(regstr, ", $imm19")),
828 def CCANT : F2_3<0b001, 1, 0, (outs), (ins bprtarget:$imm19, CCOp:$cond),
829 !strconcat("b$cond,a,pn ", !strconcat(regstr, ", $imm19")),
834 } // let isBranch = 1, isTerminator = 1, hasDelaySlot = 1
837 // Indirect branch instructions.
838 let isTerminator = 1, isBarrier = 1, hasDelaySlot = 1, isBranch =1,
839 isIndirectBranch = 1, rd = 0, isCodeGenOnly = 1 in {
840 def BINDrr : F3_1<2, 0b111000,
841 (outs), (ins MEMrr:$ptr),
843 [(brind ADDRrr:$ptr)]>;
844 def BINDri : F3_2<2, 0b111000,
845 (outs), (ins MEMri:$ptr),
847 [(brind ADDRri:$ptr)]>;
850 let Uses = [ICC] in {
851 def BCOND : BranchSP<(ins brtarget:$imm22, CCOp:$cond),
853 [(SPbricc bb:$imm22, imm:$cond)]>;
854 def BCONDA : BranchSPA<(ins brtarget:$imm22, CCOp:$cond),
855 "b$cond,a $imm22", []>;
857 let Predicates = [HasV9], cc = 0b00 in
858 defm BPI : IPredBranch<"%icc", []>;
861 // Section B.22 - Branch on Floating-point Condition Codes Instructions, p. 121
863 let isBranch = 1, isTerminator = 1, hasDelaySlot = 1 in {
865 // floating-point conditional branch class:
866 class FPBranchSP<dag ins, string asmstr, list<dag> pattern>
867 : F2_2<0b110, 0, (outs), ins, asmstr, pattern, IIC_fpu_normal_instr>;
869 // floating-point conditional branch with annul class:
870 class FPBranchSPA<dag ins, string asmstr, list<dag> pattern>
871 : F2_2<0b110, 1, (outs), ins, asmstr, pattern, IIC_fpu_normal_instr>;
873 // Conditional branch class on %fcc0-%fcc3 with predication:
874 multiclass FPredBranch {
875 def CC : F2_3<0b101, 0, 1, (outs), (ins bprtarget:$imm19, CCOp:$cond,
877 "fb$cond $cc, $imm19", [], IIC_fpu_normal_instr>;
878 def CCA : F2_3<0b101, 1, 1, (outs), (ins bprtarget:$imm19, CCOp:$cond,
880 "fb$cond,a $cc, $imm19", [], IIC_fpu_normal_instr>;
881 def CCNT : F2_3<0b101, 0, 0, (outs), (ins bprtarget:$imm19, CCOp:$cond,
883 "fb$cond,pn $cc, $imm19", [], IIC_fpu_normal_instr>;
884 def CCANT : F2_3<0b101, 1, 0, (outs), (ins bprtarget:$imm19, CCOp:$cond,
886 "fb$cond,a,pn $cc, $imm19", [], IIC_fpu_normal_instr>;
888 } // let isBranch = 1, isTerminator = 1, hasDelaySlot = 1
890 let Uses = [FCC0] in {
891 def FBCOND : FPBranchSP<(ins brtarget:$imm22, CCOp:$cond),
893 [(SPbrfcc bb:$imm22, imm:$cond)]>;
894 def FBCONDA : FPBranchSPA<(ins brtarget:$imm22, CCOp:$cond),
895 "fb$cond,a $imm22", []>;
898 let Predicates = [HasV9] in
899 defm BPF : FPredBranch;
901 // Section B.22 - Branch on Co-processor Condition Codes Instructions, p. 123
902 let isBranch = 1, isTerminator = 1, hasDelaySlot = 1 in {
904 // co-processor conditional branch class:
905 class CPBranchSP<dag ins, string asmstr, list<dag> pattern>
906 : F2_2<0b111, 0, (outs), ins, asmstr, pattern>;
908 // co-processor conditional branch with annul class:
909 class CPBranchSPA<dag ins, string asmstr, list<dag> pattern>
910 : F2_2<0b111, 1, (outs), ins, asmstr, pattern>;
912 } // let isBranch = 1, isTerminator = 1, hasDelaySlot = 1
914 def CBCOND : CPBranchSP<(ins brtarget:$imm22, CCOp:$cond),
916 [(SPbrfcc bb:$imm22, imm:$cond)]>;
917 def CBCONDA : CPBranchSPA<(ins brtarget:$imm22, CCOp:$cond),
918 "cb$cond,a $imm22", []>;
920 // Section B.24 - Call and Link Instruction, p. 125
921 // This is the only Format 1 instruction
923 hasDelaySlot = 1, isCall = 1 in {
924 def CALL : InstSP<(outs), (ins calltarget:$disp, variable_ops),
930 let Inst{29-0} = disp;
933 // indirect calls: special cases of JMPL.
934 let isCodeGenOnly = 1, rd = 15 in {
935 def CALLrr : F3_1<2, 0b111000,
936 (outs), (ins MEMrr:$ptr, variable_ops),
938 [(call ADDRrr:$ptr)],
940 def CALLri : F3_2<2, 0b111000,
941 (outs), (ins MEMri:$ptr, variable_ops),
943 [(call ADDRri:$ptr)],
948 // Section B.25 - Jump and Link Instruction
951 let isTerminator = 1, hasDelaySlot = 1, isBarrier = 1,
952 DecoderMethod = "DecodeJMPL" in {
953 def JMPLrr: F3_1<2, 0b111000,
954 (outs IntRegs:$dst), (ins MEMrr:$addr),
958 def JMPLri: F3_2<2, 0b111000,
959 (outs IntRegs:$dst), (ins MEMri:$addr),
965 // Section A.3 - Synthetic Instructions, p. 85
966 // special cases of JMPL:
967 let isReturn = 1, isTerminator = 1, hasDelaySlot = 1, isBarrier = 1,
968 isCodeGenOnly = 1 in {
969 let rd = 0, rs1 = 15 in
970 def RETL: F3_2<2, 0b111000,
971 (outs), (ins i32imm:$val),
973 [(retflag simm13:$val)],
976 let rd = 0, rs1 = 31 in
977 def RET: F3_2<2, 0b111000,
978 (outs), (ins i32imm:$val),
984 // Section B.26 - Return from Trap Instruction
985 let isReturn = 1, isTerminator = 1, hasDelaySlot = 1,
986 isBarrier = 1, rd = 0, DecoderMethod = "DecodeReturn" in {
987 def RETTrr : F3_1<2, 0b111001,
988 (outs), (ins MEMrr:$addr),
992 def RETTri : F3_2<2, 0b111001,
993 (outs), (ins MEMri:$addr),
1000 // Section B.27 - Trap on Integer Condition Codes Instruction
1001 // conditional branch class:
1002 let DecoderNamespace = "SparcV8", DecoderMethod = "DecodeTRAP", hasSideEffects = 1, Uses = [ICC], cc = 0b00 in
1004 def TRAPrr : TRAPSPrr<0b111010,
1005 (outs), (ins IntRegs:$rs1, IntRegs:$rs2, CCOp:$cond),
1006 "t$cond $rs1 + $rs2",
1008 def TRAPri : TRAPSPri<0b111010,
1009 (outs), (ins IntRegs:$rs1, i32imm:$imm, CCOp:$cond),
1010 "t$cond $rs1 + $imm",
1014 multiclass TRAP<string regStr> {
1015 def rr : TRAPSPrr<0b111010,
1016 (outs), (ins IntRegs:$rs1, IntRegs:$rs2, CCOp:$cond),
1017 !strconcat(!strconcat("t$cond ", regStr), ", $rs1 + $rs2"),
1019 def ri : TRAPSPri<0b111010,
1020 (outs), (ins IntRegs:$rs1, i32imm:$imm, CCOp:$cond),
1021 !strconcat(!strconcat("t$cond ", regStr), ", $rs1 + $imm"),
1025 let DecoderNamespace = "SparcV9", DecoderMethod = "DecodeTRAP", Predicates = [HasV9], hasSideEffects = 1, Uses = [ICC], cc = 0b00 in
1026 defm TICC : TRAP<"%icc">;
1029 let isBarrier = 1, isTerminator = 1, rd = 0b01000, rs1 = 0, simm13 = 5 in
1030 def TA5 : F3_2<0b10, 0b111010, (outs), (ins), "ta 5", [(trap)]>;
1032 let hasSideEffects = 1, rd = 0b01000, rs1 = 0, simm13 = 1 in
1033 def TA1 : F3_2<0b10, 0b111010, (outs), (ins), "ta 1", [(debugtrap)]>;
1035 // Section B.28 - Read State Register Instructions
1037 def RDASR : F3_1<2, 0b101000,
1038 (outs IntRegs:$rd), (ins ASRRegs:$rs1),
1039 "rd $rs1, $rd", []>;
1041 // PSR, WIM, and TBR don't exist on the SparcV9, only the V8.
1042 let Predicates = [HasNoV9] in {
1043 let rs2 = 0, rs1 = 0, Uses=[PSR] in
1044 def RDPSR : F3_1<2, 0b101001,
1045 (outs IntRegs:$rd), (ins),
1046 "rd %psr, $rd", []>;
1048 let rs2 = 0, rs1 = 0, Uses=[WIM] in
1049 def RDWIM : F3_1<2, 0b101010,
1050 (outs IntRegs:$rd), (ins),
1051 "rd %wim, $rd", []>;
1053 let rs2 = 0, rs1 = 0, Uses=[TBR] in
1054 def RDTBR : F3_1<2, 0b101011,
1055 (outs IntRegs:$rd), (ins),
1056 "rd %tbr, $rd", []>;
1059 // PC don't exist on the SparcV8, only the V9.
1060 let Predicates = [HasV9] in {
1061 let rs2 = 0, rs1 = 5 in
1062 def RDPC : F3_1<2, 0b101000,
1063 (outs IntRegs:$rd), (ins),
1067 // Section B.29 - Write State Register Instructions
1068 def WRASRrr : F3_1<2, 0b110000,
1069 (outs ASRRegs:$rd), (ins IntRegs:$rs1, IntRegs:$rs2),
1070 "wr $rs1, $rs2, $rd", []>;
1071 def WRASRri : F3_2<2, 0b110000,
1072 (outs ASRRegs:$rd), (ins IntRegs:$rs1, simm13Op:$simm13),
1073 "wr $rs1, $simm13, $rd", []>;
1075 // PSR, WIM, and TBR don't exist on the SparcV9, only the V8.
1076 let Predicates = [HasNoV9] in {
1077 let Defs = [PSR], rd=0 in {
1078 def WRPSRrr : F3_1<2, 0b110001,
1079 (outs), (ins IntRegs:$rs1, IntRegs:$rs2),
1080 "wr $rs1, $rs2, %psr", []>;
1081 def WRPSRri : F3_2<2, 0b110001,
1082 (outs), (ins IntRegs:$rs1, simm13Op:$simm13),
1083 "wr $rs1, $simm13, %psr", []>;
1086 let Defs = [WIM], rd=0 in {
1087 def WRWIMrr : F3_1<2, 0b110010,
1088 (outs), (ins IntRegs:$rs1, IntRegs:$rs2),
1089 "wr $rs1, $rs2, %wim", []>;
1090 def WRWIMri : F3_2<2, 0b110010,
1091 (outs), (ins IntRegs:$rs1, simm13Op:$simm13),
1092 "wr $rs1, $simm13, %wim", []>;
1095 let Defs = [TBR], rd=0 in {
1096 def WRTBRrr : F3_1<2, 0b110011,
1097 (outs), (ins IntRegs:$rs1, IntRegs:$rs2),
1098 "wr $rs1, $rs2, %tbr", []>;
1099 def WRTBRri : F3_2<2, 0b110011,
1100 (outs), (ins IntRegs:$rs1, simm13Op:$simm13),
1101 "wr $rs1, $simm13, %tbr", []>;
1105 // Section B.30 - STBAR Instruction
1106 let hasSideEffects = 1, rd = 0, rs1 = 0b01111, rs2 = 0 in
1107 def STBAR : F3_1<2, 0b101000, (outs), (ins), "stbar", []>;
1110 // Section B.31 - Unimplemented Instruction
1112 def UNIMP : F2_1<0b000, (outs), (ins i32imm:$imm22),
1113 "unimp $imm22", []>;
1115 // Section B.32 - Flush Instruction Memory
1117 def FLUSHrr : F3_1<2, 0b111011, (outs), (ins MEMrr:$addr),
1119 def FLUSHri : F3_2<2, 0b111011, (outs), (ins MEMri:$addr),
1122 // The no-arg FLUSH is only here for the benefit of the InstAlias
1123 // "flush", which cannot seem to use FLUSHrr, due to the inability
1124 // to construct a MEMrr with fixed G0 registers.
1125 let rs1 = 0, rs2 = 0 in
1126 def FLUSH : F3_1<2, 0b111011, (outs), (ins), "flush %g0", []>;
1129 // Section B.33 - Floating-point Operate (FPop) Instructions
1131 // Convert Integer to Floating-point Instructions, p. 141
1132 def FITOS : F3_3u<2, 0b110100, 0b011000100,
1133 (outs FPRegs:$rd), (ins FPRegs:$rs2),
1135 [(set FPRegs:$rd, (SPitof FPRegs:$rs2))],
1136 IIC_fpu_fast_instr>;
1137 def FITOD : F3_3u<2, 0b110100, 0b011001000,
1138 (outs DFPRegs:$rd), (ins FPRegs:$rs2),
1140 [(set DFPRegs:$rd, (SPitof FPRegs:$rs2))],
1141 IIC_fpu_fast_instr>;
1142 def FITOQ : F3_3u<2, 0b110100, 0b011001100,
1143 (outs QFPRegs:$rd), (ins FPRegs:$rs2),
1145 [(set QFPRegs:$rd, (SPitof FPRegs:$rs2))]>,
1146 Requires<[HasHardQuad]>;
1148 // Convert Floating-point to Integer Instructions, p. 142
1149 def FSTOI : F3_3u<2, 0b110100, 0b011010001,
1150 (outs FPRegs:$rd), (ins FPRegs:$rs2),
1152 [(set FPRegs:$rd, (SPftoi FPRegs:$rs2))],
1153 IIC_fpu_fast_instr>;
1154 def FDTOI : F3_3u<2, 0b110100, 0b011010010,
1155 (outs FPRegs:$rd), (ins DFPRegs:$rs2),
1157 [(set FPRegs:$rd, (SPftoi DFPRegs:$rs2))],
1158 IIC_fpu_fast_instr>;
1159 def FQTOI : F3_3u<2, 0b110100, 0b011010011,
1160 (outs FPRegs:$rd), (ins QFPRegs:$rs2),
1162 [(set FPRegs:$rd, (SPftoi QFPRegs:$rs2))]>,
1163 Requires<[HasHardQuad]>;
1165 // Convert between Floating-point Formats Instructions, p. 143
1166 def FSTOD : F3_3u<2, 0b110100, 0b011001001,
1167 (outs DFPRegs:$rd), (ins FPRegs:$rs2),
1169 [(set f64:$rd, (fpextend f32:$rs2))],
1171 def FSTOQ : F3_3u<2, 0b110100, 0b011001101,
1172 (outs QFPRegs:$rd), (ins FPRegs:$rs2),
1174 [(set f128:$rd, (fpextend f32:$rs2))]>,
1175 Requires<[HasHardQuad]>;
1176 def FDTOS : F3_3u<2, 0b110100, 0b011000110,
1177 (outs FPRegs:$rd), (ins DFPRegs:$rs2),
1179 [(set f32:$rd, (fpround f64:$rs2))],
1180 IIC_fpu_fast_instr>;
1181 def FDTOQ : F3_3u<2, 0b110100, 0b011001110,
1182 (outs QFPRegs:$rd), (ins DFPRegs:$rs2),
1184 [(set f128:$rd, (fpextend f64:$rs2))]>,
1185 Requires<[HasHardQuad]>;
1186 def FQTOS : F3_3u<2, 0b110100, 0b011000111,
1187 (outs FPRegs:$rd), (ins QFPRegs:$rs2),
1189 [(set f32:$rd, (fpround f128:$rs2))]>,
1190 Requires<[HasHardQuad]>;
1191 def FQTOD : F3_3u<2, 0b110100, 0b011001011,
1192 (outs DFPRegs:$rd), (ins QFPRegs:$rs2),
1194 [(set f64:$rd, (fpround f128:$rs2))]>,
1195 Requires<[HasHardQuad]>;
1197 // Floating-point Move Instructions, p. 144
1198 def FMOVS : F3_3u<2, 0b110100, 0b000000001,
1199 (outs FPRegs:$rd), (ins FPRegs:$rs2),
1200 "fmovs $rs2, $rd", []>;
1201 def FNEGS : F3_3u<2, 0b110100, 0b000000101,
1202 (outs FPRegs:$rd), (ins FPRegs:$rs2),
1204 [(set f32:$rd, (fneg f32:$rs2))],
1206 def FABSS : F3_3u<2, 0b110100, 0b000001001,
1207 (outs FPRegs:$rd), (ins FPRegs:$rs2),
1209 [(set f32:$rd, (fabs f32:$rs2))],
1213 // Floating-point Square Root Instructions, p.145
1214 // FSQRTS generates an erratum on LEON processors, so by disabling this instruction
1215 // this will be promoted to use FSQRTD with doubles instead.
1216 let Predicates = [HasNoFdivSqrtFix] in
1217 def FSQRTS : F3_3u<2, 0b110100, 0b000101001,
1218 (outs FPRegs:$rd), (ins FPRegs:$rs2),
1220 [(set f32:$rd, (fsqrt f32:$rs2))],
1222 def FSQRTD : F3_3u<2, 0b110100, 0b000101010,
1223 (outs DFPRegs:$rd), (ins DFPRegs:$rs2),
1225 [(set f64:$rd, (fsqrt f64:$rs2))],
1227 def FSQRTQ : F3_3u<2, 0b110100, 0b000101011,
1228 (outs QFPRegs:$rd), (ins QFPRegs:$rs2),
1230 [(set f128:$rd, (fsqrt f128:$rs2))]>,
1231 Requires<[HasHardQuad]>;
1235 // Floating-point Add and Subtract Instructions, p. 146
1236 def FADDS : F3_3<2, 0b110100, 0b001000001,
1237 (outs FPRegs:$rd), (ins FPRegs:$rs1, FPRegs:$rs2),
1238 "fadds $rs1, $rs2, $rd",
1239 [(set f32:$rd, (fadd f32:$rs1, f32:$rs2))],
1240 IIC_fpu_fast_instr>;
1241 def FADDD : F3_3<2, 0b110100, 0b001000010,
1242 (outs DFPRegs:$rd), (ins DFPRegs:$rs1, DFPRegs:$rs2),
1243 "faddd $rs1, $rs2, $rd",
1244 [(set f64:$rd, (fadd f64:$rs1, f64:$rs2))],
1245 IIC_fpu_fast_instr>;
1246 def FADDQ : F3_3<2, 0b110100, 0b001000011,
1247 (outs QFPRegs:$rd), (ins QFPRegs:$rs1, QFPRegs:$rs2),
1248 "faddq $rs1, $rs2, $rd",
1249 [(set f128:$rd, (fadd f128:$rs1, f128:$rs2))]>,
1250 Requires<[HasHardQuad]>;
1252 def FSUBS : F3_3<2, 0b110100, 0b001000101,
1253 (outs FPRegs:$rd), (ins FPRegs:$rs1, FPRegs:$rs2),
1254 "fsubs $rs1, $rs2, $rd",
1255 [(set f32:$rd, (fsub f32:$rs1, f32:$rs2))],
1256 IIC_fpu_fast_instr>;
1257 def FSUBD : F3_3<2, 0b110100, 0b001000110,
1258 (outs DFPRegs:$rd), (ins DFPRegs:$rs1, DFPRegs:$rs2),
1259 "fsubd $rs1, $rs2, $rd",
1260 [(set f64:$rd, (fsub f64:$rs1, f64:$rs2))],
1261 IIC_fpu_fast_instr>;
1262 def FSUBQ : F3_3<2, 0b110100, 0b001000111,
1263 (outs QFPRegs:$rd), (ins QFPRegs:$rs1, QFPRegs:$rs2),
1264 "fsubq $rs1, $rs2, $rd",
1265 [(set f128:$rd, (fsub f128:$rs1, f128:$rs2))]>,
1266 Requires<[HasHardQuad]>;
1269 // Floating-point Multiply and Divide Instructions, p. 147
1270 def FMULS : F3_3<2, 0b110100, 0b001001001,
1271 (outs FPRegs:$rd), (ins FPRegs:$rs1, FPRegs:$rs2),
1272 "fmuls $rs1, $rs2, $rd",
1273 [(set f32:$rd, (fmul f32:$rs1, f32:$rs2))],
1275 Requires<[HasFMULS]>;
1276 def FMULD : F3_3<2, 0b110100, 0b001001010,
1277 (outs DFPRegs:$rd), (ins DFPRegs:$rs1, DFPRegs:$rs2),
1278 "fmuld $rs1, $rs2, $rd",
1279 [(set f64:$rd, (fmul f64:$rs1, f64:$rs2))],
1281 def FMULQ : F3_3<2, 0b110100, 0b001001011,
1282 (outs QFPRegs:$rd), (ins QFPRegs:$rs1, QFPRegs:$rs2),
1283 "fmulq $rs1, $rs2, $rd",
1284 [(set f128:$rd, (fmul f128:$rs1, f128:$rs2))]>,
1285 Requires<[HasHardQuad]>;
1287 def FSMULD : F3_3<2, 0b110100, 0b001101001,
1288 (outs DFPRegs:$rd), (ins FPRegs:$rs1, FPRegs:$rs2),
1289 "fsmuld $rs1, $rs2, $rd",
1290 [(set f64:$rd, (fmul (fpextend f32:$rs1),
1291 (fpextend f32:$rs2)))],
1293 Requires<[HasFSMULD]>;
1294 def FDMULQ : F3_3<2, 0b110100, 0b001101110,
1295 (outs QFPRegs:$rd), (ins DFPRegs:$rs1, DFPRegs:$rs2),
1296 "fdmulq $rs1, $rs2, $rd",
1297 [(set f128:$rd, (fmul (fpextend f64:$rs1),
1298 (fpextend f64:$rs2)))]>,
1299 Requires<[HasHardQuad]>;
1301 // FDIVS generates an erratum on LEON processors, so by disabling this instruction
1302 // this will be promoted to use FDIVD with doubles instead.
1303 def FDIVS : F3_3<2, 0b110100, 0b001001101,
1304 (outs FPRegs:$rd), (ins FPRegs:$rs1, FPRegs:$rs2),
1305 "fdivs $rs1, $rs2, $rd",
1306 [(set f32:$rd, (fdiv f32:$rs1, f32:$rs2))],
1308 def FDIVD : F3_3<2, 0b110100, 0b001001110,
1309 (outs DFPRegs:$rd), (ins DFPRegs:$rs1, DFPRegs:$rs2),
1310 "fdivd $rs1, $rs2, $rd",
1311 [(set f64:$rd, (fdiv f64:$rs1, f64:$rs2))],
1313 def FDIVQ : F3_3<2, 0b110100, 0b001001111,
1314 (outs QFPRegs:$rd), (ins QFPRegs:$rs1, QFPRegs:$rs2),
1315 "fdivq $rs1, $rs2, $rd",
1316 [(set f128:$rd, (fdiv f128:$rs1, f128:$rs2))]>,
1317 Requires<[HasHardQuad]>;
1319 // Floating-point Compare Instructions, p. 148
1320 // Note: the 2nd template arg is different for these guys.
1321 // Note 2: the result of a FCMP is not available until the 2nd cycle
1322 // after the instr is retired, but there is no interlock in Sparc V8.
1323 // This behavior is modeled with a forced noop after the instruction in
1326 let Defs = [FCC0], rd = 0, isCodeGenOnly = 1 in {
1327 def FCMPS : F3_3c<2, 0b110101, 0b001010001,
1328 (outs), (ins FPRegs:$rs1, FPRegs:$rs2),
1330 [(SPcmpfcc f32:$rs1, f32:$rs2)],
1331 IIC_fpu_fast_instr>;
1332 def FCMPD : F3_3c<2, 0b110101, 0b001010010,
1333 (outs), (ins DFPRegs:$rs1, DFPRegs:$rs2),
1335 [(SPcmpfcc f64:$rs1, f64:$rs2)],
1336 IIC_fpu_fast_instr>;
1337 def FCMPQ : F3_3c<2, 0b110101, 0b001010011,
1338 (outs), (ins QFPRegs:$rs1, QFPRegs:$rs2),
1340 [(SPcmpfcc f128:$rs1, f128:$rs2)]>,
1341 Requires<[HasHardQuad]>;
1344 //===----------------------------------------------------------------------===//
1345 // Instructions for Thread Local Storage(TLS).
1346 //===----------------------------------------------------------------------===//
1347 let isAsmParserOnly = 1 in {
1348 def TLS_ADDrr : F3_1<2, 0b000000,
1350 (ins IntRegs:$rs1, IntRegs:$rs2, TLSSym:$sym),
1351 "add $rs1, $rs2, $rd, $sym",
1353 (tlsadd i32:$rs1, i32:$rs2, tglobaltlsaddr:$sym))]>;
1356 def TLS_LDrr : F3_1<3, 0b000000,
1357 (outs IntRegs:$dst), (ins MEMrr:$addr, TLSSym:$sym),
1358 "ld [$addr], $dst, $sym",
1360 (tlsld ADDRrr:$addr, tglobaltlsaddr:$sym))]>;
1362 let Uses = [O6], isCall = 1, hasDelaySlot = 1 in
1363 def TLS_CALL : InstSP<(outs),
1364 (ins calltarget:$disp, TLSSym:$sym, variable_ops),
1366 [(tlscall texternalsym:$disp, tglobaltlsaddr:$sym)],
1370 let Inst{29-0} = disp;
1374 //===----------------------------------------------------------------------===//
1376 //===----------------------------------------------------------------------===//
1378 // V9 Conditional Moves.
1379 let Predicates = [HasV9], Constraints = "$f = $rd" in {
1380 // Move Integer Register on Condition (MOVcc) p. 194 of the V9 manual.
1381 let Uses = [ICC], intcc = 1, cc = 0b00 in {
1383 : F4_1<0b101100, (outs IntRegs:$rd),
1384 (ins IntRegs:$rs2, IntRegs:$f, CCOp:$cond),
1385 "mov$cond %icc, $rs2, $rd",
1386 [(set i32:$rd, (SPselecticc i32:$rs2, i32:$f, imm:$cond))]>;
1389 : F4_2<0b101100, (outs IntRegs:$rd),
1390 (ins i32imm:$simm11, IntRegs:$f, CCOp:$cond),
1391 "mov$cond %icc, $simm11, $rd",
1393 (SPselecticc simm11:$simm11, i32:$f, imm:$cond))]>;
1396 let Uses = [FCC0], intcc = 0, cc = 0b00 in {
1398 : F4_1<0b101100, (outs IntRegs:$rd),
1399 (ins IntRegs:$rs2, IntRegs:$f, CCOp:$cond),
1400 "mov$cond %fcc0, $rs2, $rd",
1401 [(set i32:$rd, (SPselectfcc i32:$rs2, i32:$f, imm:$cond))]>;
1403 : F4_2<0b101100, (outs IntRegs:$rd),
1404 (ins i32imm:$simm11, IntRegs:$f, CCOp:$cond),
1405 "mov$cond %fcc0, $simm11, $rd",
1407 (SPselectfcc simm11:$simm11, i32:$f, imm:$cond))]>;
1410 let Uses = [ICC], intcc = 1, opf_cc = 0b00 in {
1412 : F4_3<0b110101, 0b000001, (outs FPRegs:$rd),
1413 (ins FPRegs:$rs2, FPRegs:$f, CCOp:$cond),
1414 "fmovs$cond %icc, $rs2, $rd",
1415 [(set f32:$rd, (SPselecticc f32:$rs2, f32:$f, imm:$cond))]>;
1417 : F4_3<0b110101, 0b000010, (outs DFPRegs:$rd),
1418 (ins DFPRegs:$rs2, DFPRegs:$f, CCOp:$cond),
1419 "fmovd$cond %icc, $rs2, $rd",
1420 [(set f64:$rd, (SPselecticc f64:$rs2, f64:$f, imm:$cond))]>;
1422 : F4_3<0b110101, 0b000011, (outs QFPRegs:$rd),
1423 (ins QFPRegs:$rs2, QFPRegs:$f, CCOp:$cond),
1424 "fmovq$cond %icc, $rs2, $rd",
1425 [(set f128:$rd, (SPselecticc f128:$rs2, f128:$f, imm:$cond))]>,
1426 Requires<[HasHardQuad]>;
1429 let Uses = [FCC0], intcc = 0, opf_cc = 0b00 in {
1431 : F4_3<0b110101, 0b000001, (outs FPRegs:$rd),
1432 (ins FPRegs:$rs2, FPRegs:$f, CCOp:$cond),
1433 "fmovs$cond %fcc0, $rs2, $rd",
1434 [(set f32:$rd, (SPselectfcc f32:$rs2, f32:$f, imm:$cond))]>;
1436 : F4_3<0b110101, 0b000010, (outs DFPRegs:$rd),
1437 (ins DFPRegs:$rs2, DFPRegs:$f, CCOp:$cond),
1438 "fmovd$cond %fcc0, $rs2, $rd",
1439 [(set f64:$rd, (SPselectfcc f64:$rs2, f64:$f, imm:$cond))]>;
1441 : F4_3<0b110101, 0b000011, (outs QFPRegs:$rd),
1442 (ins QFPRegs:$rs2, QFPRegs:$f, CCOp:$cond),
1443 "fmovq$cond %fcc0, $rs2, $rd",
1444 [(set f128:$rd, (SPselectfcc f128:$rs2, f128:$f, imm:$cond))]>,
1445 Requires<[HasHardQuad]>;
1450 // Floating-Point Move Instructions, p. 164 of the V9 manual.
1451 let Predicates = [HasV9] in {
1452 def FMOVD : F3_3u<2, 0b110100, 0b000000010,
1453 (outs DFPRegs:$rd), (ins DFPRegs:$rs2),
1454 "fmovd $rs2, $rd", []>;
1455 def FMOVQ : F3_3u<2, 0b110100, 0b000000011,
1456 (outs QFPRegs:$rd), (ins QFPRegs:$rs2),
1457 "fmovq $rs2, $rd", []>,
1458 Requires<[HasHardQuad]>;
1459 def FNEGD : F3_3u<2, 0b110100, 0b000000110,
1460 (outs DFPRegs:$rd), (ins DFPRegs:$rs2),
1462 [(set f64:$rd, (fneg f64:$rs2))]>;
1463 def FNEGQ : F3_3u<2, 0b110100, 0b000000111,
1464 (outs QFPRegs:$rd), (ins QFPRegs:$rs2),
1466 [(set f128:$rd, (fneg f128:$rs2))]>,
1467 Requires<[HasHardQuad]>;
1468 def FABSD : F3_3u<2, 0b110100, 0b000001010,
1469 (outs DFPRegs:$rd), (ins DFPRegs:$rs2),
1471 [(set f64:$rd, (fabs f64:$rs2))]>;
1472 def FABSQ : F3_3u<2, 0b110100, 0b000001011,
1473 (outs QFPRegs:$rd), (ins QFPRegs:$rs2),
1475 [(set f128:$rd, (fabs f128:$rs2))]>,
1476 Requires<[HasHardQuad]>;
1479 // Floating-point compare instruction with %fcc0-%fcc3.
1480 def V9FCMPS : F3_3c<2, 0b110101, 0b001010001,
1481 (outs FCCRegs:$rd), (ins FPRegs:$rs1, FPRegs:$rs2),
1482 "fcmps $rd, $rs1, $rs2", []>;
1483 def V9FCMPD : F3_3c<2, 0b110101, 0b001010010,
1484 (outs FCCRegs:$rd), (ins DFPRegs:$rs1, DFPRegs:$rs2),
1485 "fcmpd $rd, $rs1, $rs2", []>;
1486 def V9FCMPQ : F3_3c<2, 0b110101, 0b001010011,
1487 (outs FCCRegs:$rd), (ins QFPRegs:$rs1, QFPRegs:$rs2),
1488 "fcmpq $rd, $rs1, $rs2", []>,
1489 Requires<[HasHardQuad]>;
1491 let hasSideEffects = 1 in {
1492 def V9FCMPES : F3_3c<2, 0b110101, 0b001010101,
1493 (outs FCCRegs:$rd), (ins FPRegs:$rs1, FPRegs:$rs2),
1494 "fcmpes $rd, $rs1, $rs2", []>;
1495 def V9FCMPED : F3_3c<2, 0b110101, 0b001010110,
1496 (outs FCCRegs:$rd), (ins DFPRegs:$rs1, DFPRegs:$rs2),
1497 "fcmped $rd, $rs1, $rs2", []>;
1498 def V9FCMPEQ : F3_3c<2, 0b110101, 0b001010111,
1499 (outs FCCRegs:$rd), (ins QFPRegs:$rs1, QFPRegs:$rs2),
1500 "fcmpeq $rd, $rs1, $rs2", []>,
1501 Requires<[HasHardQuad]>;
1504 // Floating point conditional move instrucitons with %fcc0-%fcc3.
1505 let Predicates = [HasV9] in {
1506 let Constraints = "$f = $rd", intcc = 0 in {
1508 : F4_1<0b101100, (outs IntRegs:$rd),
1509 (ins FCCRegs:$cc, IntRegs:$rs2, IntRegs:$f, CCOp:$cond),
1510 "mov$cond $cc, $rs2, $rd", []>;
1512 : F4_2<0b101100, (outs IntRegs:$rd),
1513 (ins FCCRegs:$cc, i32imm:$simm11, IntRegs:$f, CCOp:$cond),
1514 "mov$cond $cc, $simm11, $rd", []>;
1516 : F4_3<0b110101, 0b000001, (outs FPRegs:$rd),
1517 (ins FCCRegs:$opf_cc, FPRegs:$rs2, FPRegs:$f, CCOp:$cond),
1518 "fmovs$cond $opf_cc, $rs2, $rd", []>;
1520 : F4_3<0b110101, 0b000010, (outs DFPRegs:$rd),
1521 (ins FCCRegs:$opf_cc, DFPRegs:$rs2, DFPRegs:$f, CCOp:$cond),
1522 "fmovd$cond $opf_cc, $rs2, $rd", []>;
1524 : F4_3<0b110101, 0b000011, (outs QFPRegs:$rd),
1525 (ins FCCRegs:$opf_cc, QFPRegs:$rs2, QFPRegs:$f, CCOp:$cond),
1526 "fmovq$cond $opf_cc, $rs2, $rd", []>,
1527 Requires<[HasHardQuad]>;
1528 } // Constraints = "$f = $rd", ...
1529 } // let Predicates = [hasV9]
1532 // POPCrr - This does a ctpop of a 64-bit register. As such, we have to clear
1533 // the top 32-bits before using it. To do this clearing, we use a SRLri X,0.
1535 def POPCrr : F3_1<2, 0b101110,
1536 (outs IntRegs:$rd), (ins IntRegs:$rs2),
1537 "popc $rs2, $rd", []>, Requires<[HasV9]>;
1538 def : Pat<(i32 (ctpop i32:$src)),
1539 (POPCrr (SRLri $src, 0))>;
1541 let Predicates = [HasV9], hasSideEffects = 1, rd = 0, rs1 = 0b01111 in
1542 def MEMBARi : F3_2<2, 0b101000, (outs), (ins MembarTag:$simm13),
1543 "membar $simm13", []>;
1545 let Predicates = [HasV9], rd = 15, rs1 = 0b00000 in
1546 def SIR: F3_2<2, 0b110000, (outs),
1547 (ins simm13Op:$simm13),
1550 // The CAS instruction, unlike other instructions, only comes in a
1551 // form which requires an ASI be provided. The ASI value hardcoded
1552 // here is ASI_PRIMARY, the default unprivileged ASI for SparcV9.
1553 let Predicates = [HasV9], Constraints = "$swap = $rd", asi = 0b10000000 in
1554 def CASrr: F3_1_asi<3, 0b111100,
1555 (outs IntRegs:$rd), (ins IntRegs:$rs1, IntRegs:$rs2,
1557 "cas [$rs1], $rs2, $rd",
1559 (atomic_cmp_swap_32 iPTR:$rs1, i32:$rs2, i32:$swap))]>;
1562 // CASA is supported as an instruction on some LEON3 and all LEON4 processors.
1563 // This version can be automatically lowered from C code, selecting ASI 10
1564 let Predicates = [HasLeonCASA], Constraints = "$swap = $rd", asi = 0b00001010 in
1565 def CASAasi10: F3_1_asi<3, 0b111100,
1566 (outs IntRegs:$rd), (ins IntRegs:$rs1, IntRegs:$rs2,
1568 "casa [$rs1] 10, $rs2, $rd",
1570 (atomic_cmp_swap_32 iPTR:$rs1, i32:$rs2, i32:$swap))]>;
1572 // CASA supported on some LEON3 and all LEON4 processors. Same pattern as
1573 // CASrr, above, but with a different ASI. This version is supported for
1574 // inline assembly lowering only.
1575 let Predicates = [HasLeonCASA], Constraints = "$swap = $rd" in
1576 def CASArr: F3_1_asi<3, 0b111100,
1577 (outs IntRegs:$rd), (ins IntRegs:$rs1, IntRegs:$rs2,
1578 IntRegs:$swap, i8imm:$asi),
1579 "casa [$rs1] $asi, $rs2, $rd", []>;
1581 // TODO: Add DAG sequence to lower these instructions. Currently, only provided
1582 // as inline assembler-supported instructions.
1583 let Predicates = [HasUMAC_SMAC], Defs = [Y, ASR18], Uses = [Y, ASR18] in {
1584 def SMACrr : F3_1<2, 0b111111,
1585 (outs IntRegs:$rd), (ins IntRegs:$rs1, IntRegs:$rs2, ASRRegs:$asr18),
1586 "smac $rs1, $rs2, $rd",
1589 def SMACri : F3_2<2, 0b111111,
1590 (outs IntRegs:$rd), (ins IntRegs:$rs1, simm13Op:$simm13, ASRRegs:$asr18),
1591 "smac $rs1, $simm13, $rd",
1594 def UMACrr : F3_1<2, 0b111110,
1595 (outs IntRegs:$rd), (ins IntRegs:$rs1, IntRegs:$rs2, ASRRegs:$asr18),
1596 "umac $rs1, $rs2, $rd",
1599 def UMACri : F3_2<2, 0b111110,
1600 (outs IntRegs:$rd), (ins IntRegs:$rs1, simm13Op:$simm13, ASRRegs:$asr18),
1601 "umac $rs1, $simm13, $rd",
1605 // The partial write WRPSR instruction has a non-zero destination
1606 // register value to separate it from the standard instruction.
1607 let Predicates = [HasPWRPSR], Defs = [PSR], rd=1 in {
1608 def PWRPSRrr : F3_1<2, 0b110001,
1609 (outs), (ins IntRegs:$rs1, IntRegs:$rs2),
1610 "pwr $rs1, $rs2, %psr", []>;
1611 def PWRPSRri : F3_2<2, 0b110001,
1612 (outs), (ins IntRegs:$rs1, simm13Op:$simm13),
1613 "pwr $rs1, $simm13, %psr", []>;
1616 let Defs = [ICC] in {
1617 defm TADDCC : F3_12np<"taddcc", 0b100000>;
1618 defm TSUBCC : F3_12np<"tsubcc", 0b100001>;
1620 let hasSideEffects = 1 in {
1621 defm TADDCCTV : F3_12np<"taddcctv", 0b100010>;
1622 defm TSUBCCTV : F3_12np<"tsubcctv", 0b100011>;
1627 // Section A.43 - Read Privileged Register Instructions
1628 let Predicates = [HasV9] in {
1630 def RDPR : F3_1<2, 0b101010,
1631 (outs IntRegs:$rd), (ins PRRegs:$rs1),
1632 "rdpr $rs1, $rd", []>;
1635 // Section A.62 - Write Privileged Register Instructions
1636 let Predicates = [HasV9] in {
1637 def WRPRrr : F3_1<2, 0b110010,
1638 (outs PRRegs:$rd), (ins IntRegs:$rs1, IntRegs:$rs2),
1639 "wrpr $rs1, $rs2, $rd", []>;
1640 def WRPRri : F3_2<2, 0b110010,
1641 (outs PRRegs:$rd), (ins IntRegs:$rs1, simm13Op:$simm13),
1642 "wrpr $rs1, $simm13, $rd", []>;
1645 //===----------------------------------------------------------------------===//
1646 // Non-Instruction Patterns
1647 //===----------------------------------------------------------------------===//
1651 (ORrr (i32 G0), (i32 G0))>;
1652 // Small immediates.
1653 def : Pat<(i32 simm13:$val),
1654 (ORri (i32 G0), imm:$val)>;
1655 // Arbitrary immediates.
1656 def : Pat<(i32 imm:$val),
1657 (ORri (SETHIi (HI22 imm:$val)), (LO10 imm:$val))>;
1660 // Global addresses, constant pool entries
1661 let Predicates = [Is32Bit] in {
1663 def : Pat<(SPhi tglobaladdr:$in), (SETHIi tglobaladdr:$in)>;
1664 def : Pat<(SPlo tglobaladdr:$in), (ORri (i32 G0), tglobaladdr:$in)>;
1665 def : Pat<(SPhi tconstpool:$in), (SETHIi tconstpool:$in)>;
1666 def : Pat<(SPlo tconstpool:$in), (ORri (i32 G0), tconstpool:$in)>;
1668 // GlobalTLS addresses
1669 def : Pat<(SPhi tglobaltlsaddr:$in), (SETHIi tglobaltlsaddr:$in)>;
1670 def : Pat<(SPlo tglobaltlsaddr:$in), (ORri (i32 G0), tglobaltlsaddr:$in)>;
1671 def : Pat<(add (SPhi tglobaltlsaddr:$in1), (SPlo tglobaltlsaddr:$in2)),
1672 (ADDri (SETHIi tglobaltlsaddr:$in1), (tglobaltlsaddr:$in2))>;
1673 def : Pat<(xor (SPhi tglobaltlsaddr:$in1), (SPlo tglobaltlsaddr:$in2)),
1674 (XORri (SETHIi tglobaltlsaddr:$in1), (tglobaltlsaddr:$in2))>;
1677 def : Pat<(SPhi tblockaddress:$in), (SETHIi tblockaddress:$in)>;
1678 def : Pat<(SPlo tblockaddress:$in), (ORri (i32 G0), tblockaddress:$in)>;
1680 // Add reg, lo. This is used when taking the addr of a global/constpool entry.
1681 def : Pat<(add iPTR:$r, (SPlo tglobaladdr:$in)), (ADDri $r, tglobaladdr:$in)>;
1682 def : Pat<(add iPTR:$r, (SPlo tconstpool:$in)), (ADDri $r, tconstpool:$in)>;
1683 def : Pat<(add iPTR:$r, (SPlo tblockaddress:$in)),
1684 (ADDri $r, tblockaddress:$in)>;
1688 def : Pat<(call tglobaladdr:$dst),
1689 (CALL tglobaladdr:$dst)>;
1690 def : Pat<(call texternalsym:$dst),
1691 (CALL texternalsym:$dst)>;
1693 // Map integer extload's to zextloads.
1694 def : Pat<(i32 (extloadi1 ADDRrr:$src)), (LDUBrr ADDRrr:$src)>;
1695 def : Pat<(i32 (extloadi1 ADDRri:$src)), (LDUBri ADDRri:$src)>;
1696 def : Pat<(i32 (extloadi8 ADDRrr:$src)), (LDUBrr ADDRrr:$src)>;
1697 def : Pat<(i32 (extloadi8 ADDRri:$src)), (LDUBri ADDRri:$src)>;
1698 def : Pat<(i32 (extloadi16 ADDRrr:$src)), (LDUHrr ADDRrr:$src)>;
1699 def : Pat<(i32 (extloadi16 ADDRri:$src)), (LDUHri ADDRri:$src)>;
1701 // zextload bool -> zextload byte
1702 def : Pat<(i32 (zextloadi1 ADDRrr:$src)), (LDUBrr ADDRrr:$src)>;
1703 def : Pat<(i32 (zextloadi1 ADDRri:$src)), (LDUBri ADDRri:$src)>;
1705 // store 0, addr -> store %g0, addr
1706 def : Pat<(store (i32 0), ADDRrr:$dst), (STrr ADDRrr:$dst, (i32 G0))>;
1707 def : Pat<(store (i32 0), ADDRri:$dst), (STri ADDRri:$dst, (i32 G0))>;
1709 // store bar for all atomic_fence in V8.
1710 let Predicates = [HasNoV9] in
1711 def : Pat<(atomic_fence timm, timm), (STBAR)>;
1713 let Predicates = [HasV9] in
1714 def : Pat<(atomic_fence timm, timm), (MEMBARi 0xf)>;
1716 // atomic_load addr -> load addr
1717 def : Pat<(i32 (atomic_load_8 ADDRrr:$src)), (LDUBrr ADDRrr:$src)>;
1718 def : Pat<(i32 (atomic_load_8 ADDRri:$src)), (LDUBri ADDRri:$src)>;
1719 def : Pat<(i32 (atomic_load_16 ADDRrr:$src)), (LDUHrr ADDRrr:$src)>;
1720 def : Pat<(i32 (atomic_load_16 ADDRri:$src)), (LDUHri ADDRri:$src)>;
1721 def : Pat<(i32 (atomic_load_32 ADDRrr:$src)), (LDrr ADDRrr:$src)>;
1722 def : Pat<(i32 (atomic_load_32 ADDRri:$src)), (LDri ADDRri:$src)>;
1724 // atomic_store val, addr -> store val, addr
1725 def : Pat<(atomic_store_8 ADDRrr:$dst, i32:$val), (STBrr ADDRrr:$dst, $val)>;
1726 def : Pat<(atomic_store_8 ADDRri:$dst, i32:$val), (STBri ADDRri:$dst, $val)>;
1727 def : Pat<(atomic_store_16 ADDRrr:$dst, i32:$val), (STHrr ADDRrr:$dst, $val)>;
1728 def : Pat<(atomic_store_16 ADDRri:$dst, i32:$val), (STHri ADDRri:$dst, $val)>;
1729 def : Pat<(atomic_store_32 ADDRrr:$dst, i32:$val), (STrr ADDRrr:$dst, $val)>;
1730 def : Pat<(atomic_store_32 ADDRri:$dst, i32:$val), (STri ADDRri:$dst, $val)>;
1733 def : Pat<(extractelt (v2i32 IntPair:$Rn), 0),
1734 (i32 (EXTRACT_SUBREG IntPair:$Rn, sub_even))>;
1735 def : Pat<(extractelt (v2i32 IntPair:$Rn), 1),
1736 (i32 (EXTRACT_SUBREG IntPair:$Rn, sub_odd))>;
1739 def : Pat<(build_vector (i32 IntRegs:$a1), (i32 IntRegs:$a2)),
1741 (INSERT_SUBREG (v2i32 (IMPLICIT_DEF)), (i32 IntRegs:$a1), sub_even),
1742 (i32 IntRegs:$a2), sub_odd)>;
1745 include "SparcInstr64Bit.td"
1746 include "SparcInstrVIS.td"
1747 include "SparcInstrAliases.td"