1 //===-- SparcInstrInfo.td - Target Description for Sparc Target -----------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file describes the Sparc instructions in TableGen format.
12 //===----------------------------------------------------------------------===//
14 //===----------------------------------------------------------------------===//
15 // Instruction format superclass
16 //===----------------------------------------------------------------------===//
18 include "SparcInstrFormats.td"
20 //===----------------------------------------------------------------------===//
21 // Feature predicates.
22 //===----------------------------------------------------------------------===//
24 // True when generating 32-bit code.
25 def Is32Bit : Predicate<"!Subtarget.is64Bit()">;
27 // True when generating 64-bit code. This also implies HasV9.
28 def Is64Bit : Predicate<"Subtarget.is64Bit()">;
30 // HasV9 - This predicate is true when the target processor supports V9
31 // instructions. Note that the machine may be running in 32-bit mode.
32 def HasV9 : Predicate<"Subtarget.isV9()">,
33 AssemblerPredicate<"FeatureV9">;
35 // HasNoV9 - This predicate is true when the target doesn't have V9
36 // instructions. Use of this is just a hack for the isel not having proper
37 // costs for V8 instructions that are more expensive than their V9 ones.
38 def HasNoV9 : Predicate<"!Subtarget.isV9()">;
40 // HasVIS - This is true when the target processor has VIS extensions.
41 def HasVIS : Predicate<"Subtarget.isVIS()">;
43 // HasHardQuad - This is true when the target processor supports quad floating
44 // point instructions.
45 def HasHardQuad : Predicate<"Subtarget.hasHardQuad()">;
47 // UseDeprecatedInsts - This predicate is true when the target processor is a
48 // V8, or when it is V9 but the V8 deprecated instructions are efficient enough
49 // to use when appropriate. In either of these cases, the instruction selector
50 // will pick deprecated instructions.
51 def UseDeprecatedInsts : Predicate<"Subtarget.useDeprecatedV8Instructions()">;
53 //===----------------------------------------------------------------------===//
54 // Instruction Pattern Stuff
55 //===----------------------------------------------------------------------===//
57 def simm11 : PatLeaf<(imm), [{ return isInt<11>(N->getSExtValue()); }]>;
59 def simm13 : PatLeaf<(imm), [{ return isInt<13>(N->getSExtValue()); }]>;
61 def LO10 : SDNodeXForm<imm, [{
62 return CurDAG->getTargetConstant((unsigned)N->getZExtValue() & 1023,
66 def HI22 : SDNodeXForm<imm, [{
67 // Transformation function: shift the immediate value down into the low bits.
68 return CurDAG->getTargetConstant((unsigned)N->getZExtValue() >> 10, MVT::i32);
71 def SETHIimm : PatLeaf<(imm), [{
72 return isShiftedUInt<22, 10>(N->getZExtValue());
76 def ADDRrr : ComplexPattern<iPTR, 2, "SelectADDRrr", [], []>;
77 def ADDRri : ComplexPattern<iPTR, 2, "SelectADDRri", [frameindex], []>;
80 def SparcMEMrrAsmOperand : AsmOperandClass {
82 let ParserMethod = "parseMEMOperand";
85 def SparcMEMriAsmOperand : AsmOperandClass {
87 let ParserMethod = "parseMEMOperand";
90 def MEMrr : Operand<iPTR> {
91 let PrintMethod = "printMemOperand";
92 let MIOperandInfo = (ops ptr_rc, ptr_rc);
93 let ParserMatchClass = SparcMEMrrAsmOperand;
95 def MEMri : Operand<iPTR> {
96 let PrintMethod = "printMemOperand";
97 let MIOperandInfo = (ops ptr_rc, i32imm);
98 let ParserMatchClass = SparcMEMriAsmOperand;
101 def TLSSym : Operand<iPTR>;
103 // Branch targets have OtherVT type.
104 def brtarget : Operand<OtherVT> {
105 let EncoderMethod = "getBranchTargetOpValue";
108 def bprtarget : Operand<OtherVT> {
109 let EncoderMethod = "getBranchPredTargetOpValue";
112 def calltarget : Operand<i32> {
113 let EncoderMethod = "getCallTargetOpValue";
114 let DecoderMethod = "DecodeCall";
117 def simm13Op : Operand<i32> {
118 let DecoderMethod = "DecodeSIMM13";
121 // Operand for printing out a condition code.
122 let PrintMethod = "printCCOperand" in
123 def CCOp : Operand<i32>;
126 SDTypeProfile<0, 2, [SDTCisInt<0>, SDTCisSameAs<0, 1>]>;
128 SDTypeProfile<0, 2, [SDTCisFP<0>, SDTCisSameAs<0, 1>]>;
130 SDTypeProfile<0, 2, [SDTCisVT<0, OtherVT>, SDTCisVT<1, i32>]>;
132 SDTypeProfile<1, 3, [SDTCisSameAs<0, 1>, SDTCisSameAs<1, 2>, SDTCisVT<3, i32>]>;
134 SDTypeProfile<1, 1, [SDTCisVT<0, f32>, SDTCisFP<1>]>;
136 SDTypeProfile<1, 1, [SDTCisFP<0>, SDTCisVT<1, f32>]>;
138 SDTypeProfile<1, 1, [SDTCisVT<0, f64>, SDTCisFP<1>]>;
140 SDTypeProfile<1, 1, [SDTCisFP<0>, SDTCisVT<1, f64>]>;
143 SDTypeProfile<1, 3, [SDTCisInt<0>, SDTCisSameAs<0, 1>, SDTCisPtrTy<2>]>;
145 SDTypeProfile<1, 2, [SDTCisPtrTy<0>, SDTCisPtrTy<1>]>;
147 def SPcmpicc : SDNode<"SPISD::CMPICC", SDTSPcmpicc, [SDNPOutGlue]>;
148 def SPcmpfcc : SDNode<"SPISD::CMPFCC", SDTSPcmpfcc, [SDNPOutGlue]>;
149 def SPbricc : SDNode<"SPISD::BRICC", SDTSPbrcc, [SDNPHasChain, SDNPInGlue]>;
150 def SPbrxcc : SDNode<"SPISD::BRXCC", SDTSPbrcc, [SDNPHasChain, SDNPInGlue]>;
151 def SPbrfcc : SDNode<"SPISD::BRFCC", SDTSPbrcc, [SDNPHasChain, SDNPInGlue]>;
153 def SPhi : SDNode<"SPISD::Hi", SDTIntUnaryOp>;
154 def SPlo : SDNode<"SPISD::Lo", SDTIntUnaryOp>;
156 def SPftoi : SDNode<"SPISD::FTOI", SDTSPFTOI>;
157 def SPitof : SDNode<"SPISD::ITOF", SDTSPITOF>;
158 def SPftox : SDNode<"SPISD::FTOX", SDTSPFTOX>;
159 def SPxtof : SDNode<"SPISD::XTOF", SDTSPXTOF>;
161 def SPselecticc : SDNode<"SPISD::SELECT_ICC", SDTSPselectcc, [SDNPInGlue]>;
162 def SPselectxcc : SDNode<"SPISD::SELECT_XCC", SDTSPselectcc, [SDNPInGlue]>;
163 def SPselectfcc : SDNode<"SPISD::SELECT_FCC", SDTSPselectcc, [SDNPInGlue]>;
165 // These are target-independent nodes, but have target-specific formats.
166 def SDT_SPCallSeqStart : SDCallSeqStart<[ SDTCisVT<0, i32> ]>;
167 def SDT_SPCallSeqEnd : SDCallSeqEnd<[ SDTCisVT<0, i32>,
170 def callseq_start : SDNode<"ISD::CALLSEQ_START", SDT_SPCallSeqStart,
171 [SDNPHasChain, SDNPOutGlue]>;
172 def callseq_end : SDNode<"ISD::CALLSEQ_END", SDT_SPCallSeqEnd,
173 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue]>;
175 def SDT_SPCall : SDTypeProfile<0, -1, [SDTCisVT<0, i32>]>;
176 def call : SDNode<"SPISD::CALL", SDT_SPCall,
177 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
180 def SDT_SPRet : SDTypeProfile<0, 1, [SDTCisVT<0, i32>]>;
181 def retflag : SDNode<"SPISD::RET_FLAG", SDT_SPRet,
182 [SDNPHasChain, SDNPOptInGlue, SDNPVariadic]>;
184 def flushw : SDNode<"SPISD::FLUSHW", SDTNone,
185 [SDNPHasChain, SDNPSideEffect, SDNPMayStore]>;
187 def tlsadd : SDNode<"SPISD::TLS_ADD", SDTSPtlsadd>;
188 def tlsld : SDNode<"SPISD::TLS_LD", SDTSPtlsld>;
189 def tlscall : SDNode<"SPISD::TLS_CALL", SDT_SPCall,
190 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
193 def getPCX : Operand<iPTR> {
194 let PrintMethod = "printGetPCX";
197 //===----------------------------------------------------------------------===//
198 // SPARC Flag Conditions
199 //===----------------------------------------------------------------------===//
201 // Note that these values must be kept in sync with the CCOp::CondCode enum
203 class ICC_VAL<int N> : PatLeaf<(i32 N)>;
204 def ICC_NE : ICC_VAL< 9>; // Not Equal
205 def ICC_E : ICC_VAL< 1>; // Equal
206 def ICC_G : ICC_VAL<10>; // Greater
207 def ICC_LE : ICC_VAL< 2>; // Less or Equal
208 def ICC_GE : ICC_VAL<11>; // Greater or Equal
209 def ICC_L : ICC_VAL< 3>; // Less
210 def ICC_GU : ICC_VAL<12>; // Greater Unsigned
211 def ICC_LEU : ICC_VAL< 4>; // Less or Equal Unsigned
212 def ICC_CC : ICC_VAL<13>; // Carry Clear/Great or Equal Unsigned
213 def ICC_CS : ICC_VAL< 5>; // Carry Set/Less Unsigned
214 def ICC_POS : ICC_VAL<14>; // Positive
215 def ICC_NEG : ICC_VAL< 6>; // Negative
216 def ICC_VC : ICC_VAL<15>; // Overflow Clear
217 def ICC_VS : ICC_VAL< 7>; // Overflow Set
219 class FCC_VAL<int N> : PatLeaf<(i32 N)>;
220 def FCC_U : FCC_VAL<23>; // Unordered
221 def FCC_G : FCC_VAL<22>; // Greater
222 def FCC_UG : FCC_VAL<21>; // Unordered or Greater
223 def FCC_L : FCC_VAL<20>; // Less
224 def FCC_UL : FCC_VAL<19>; // Unordered or Less
225 def FCC_LG : FCC_VAL<18>; // Less or Greater
226 def FCC_NE : FCC_VAL<17>; // Not Equal
227 def FCC_E : FCC_VAL<25>; // Equal
228 def FCC_UE : FCC_VAL<24>; // Unordered or Equal
229 def FCC_GE : FCC_VAL<25>; // Greater or Equal
230 def FCC_UGE : FCC_VAL<26>; // Unordered or Greater or Equal
231 def FCC_LE : FCC_VAL<27>; // Less or Equal
232 def FCC_ULE : FCC_VAL<28>; // Unordered or Less or Equal
233 def FCC_O : FCC_VAL<29>; // Ordered
235 //===----------------------------------------------------------------------===//
236 // Instruction Class Templates
237 //===----------------------------------------------------------------------===//
239 /// F3_12 multiclass - Define a normal F3_1/F3_2 pattern in one shot.
240 multiclass F3_12<string OpcStr, bits<6> Op3Val, SDNode OpNode,
241 RegisterClass RC, ValueType Ty, Operand immOp> {
242 def rr : F3_1<2, Op3Val,
243 (outs RC:$rd), (ins RC:$rs1, RC:$rs2),
244 !strconcat(OpcStr, " $rs1, $rs2, $rd"),
245 [(set Ty:$rd, (OpNode Ty:$rs1, Ty:$rs2))]>;
246 def ri : F3_2<2, Op3Val,
247 (outs RC:$rd), (ins RC:$rs1, immOp:$simm13),
248 !strconcat(OpcStr, " $rs1, $simm13, $rd"),
249 [(set Ty:$rd, (OpNode Ty:$rs1, (Ty simm13:$simm13)))]>;
252 /// F3_12np multiclass - Define a normal F3_1/F3_2 pattern in one shot, with no
254 multiclass F3_12np<string OpcStr, bits<6> Op3Val> {
255 def rr : F3_1<2, Op3Val,
256 (outs IntRegs:$rd), (ins IntRegs:$rs1, IntRegs:$rs2),
257 !strconcat(OpcStr, " $rs1, $rs2, $rd"), []>;
258 def ri : F3_2<2, Op3Val,
259 (outs IntRegs:$rd), (ins IntRegs:$rs1, simm13Op:$simm13),
260 !strconcat(OpcStr, " $rs1, $simm13, $rd"), []>;
263 // Load multiclass - Define both Reg+Reg/Reg+Imm patterns in one shot.
264 multiclass Load<string OpcStr, bits<6> Op3Val, SDPatternOperator OpNode,
265 RegisterClass RC, ValueType Ty> {
266 def rr : F3_1<3, Op3Val,
267 (outs RC:$dst), (ins MEMrr:$addr),
268 !strconcat(OpcStr, " [$addr], $dst"),
269 [(set Ty:$dst, (OpNode ADDRrr:$addr))]>;
270 def ri : F3_2<3, Op3Val,
271 (outs RC:$dst), (ins MEMri:$addr),
272 !strconcat(OpcStr, " [$addr], $dst"),
273 [(set Ty:$dst, (OpNode ADDRri:$addr))]>;
276 // Store multiclass - Define both Reg+Reg/Reg+Imm patterns in one shot.
277 multiclass Store<string OpcStr, bits<6> Op3Val, SDPatternOperator OpNode,
278 RegisterClass RC, ValueType Ty> {
279 def rr : F3_1<3, Op3Val,
280 (outs), (ins MEMrr:$addr, RC:$rd),
281 !strconcat(OpcStr, " $rd, [$addr]"),
282 [(OpNode Ty:$rd, ADDRrr:$addr)]>;
283 def ri : F3_2<3, Op3Val,
284 (outs), (ins MEMri:$addr, RC:$rd),
285 !strconcat(OpcStr, " $rd, [$addr]"),
286 [(OpNode Ty:$rd, ADDRri:$addr)]>;
289 //===----------------------------------------------------------------------===//
291 //===----------------------------------------------------------------------===//
293 // Pseudo instructions.
294 class Pseudo<dag outs, dag ins, string asmstr, list<dag> pattern>
295 : InstSP<outs, ins, asmstr, pattern> {
296 let isCodeGenOnly = 1;
302 def GETPCX : Pseudo<(outs getPCX:$getpcseq), (ins), "$getpcseq", [] >;
305 let Defs = [O6], Uses = [O6] in {
306 def ADJCALLSTACKDOWN : Pseudo<(outs), (ins i32imm:$amt),
307 "!ADJCALLSTACKDOWN $amt",
308 [(callseq_start timm:$amt)]>;
309 def ADJCALLSTACKUP : Pseudo<(outs), (ins i32imm:$amt1, i32imm:$amt2),
310 "!ADJCALLSTACKUP $amt1",
311 [(callseq_end timm:$amt1, timm:$amt2)]>;
314 let hasSideEffects = 1, mayStore = 1 in {
315 let rd = 0, rs1 = 0, rs2 = 0 in
316 def FLUSHW : F3_1<0b10, 0b101011, (outs), (ins),
318 [(flushw)]>, Requires<[HasV9]>;
319 let rd = 0, rs1 = 1, simm13 = 3 in
320 def TA3 : F3_2<0b10, 0b111010, (outs), (ins),
325 let isBarrier = 1, isTerminator = 1, rd = 0b1000, rs1 = 0, simm13 = 5 in
326 def TA5 : F3_2<0b10, 0b111010, (outs), (ins), "ta 5", [(trap)]>;
329 def UNIMP : F2_1<0b000, (outs), (ins i32imm:$imm22),
332 // SELECT_CC_* - Used to implement the SELECT_CC DAG operation. Expanded after
333 // instruction selection into a branch sequence. This has to handle all
334 // permutations of selection between i32/f32/f64 on ICC and FCC.
335 // Expanded after instruction selection.
336 let Uses = [ICC], usesCustomInserter = 1 in {
337 def SELECT_CC_Int_ICC
338 : Pseudo<(outs IntRegs:$dst), (ins IntRegs:$T, IntRegs:$F, i32imm:$Cond),
339 "; SELECT_CC_Int_ICC PSEUDO!",
340 [(set i32:$dst, (SPselecticc i32:$T, i32:$F, imm:$Cond))]>;
342 : Pseudo<(outs FPRegs:$dst), (ins FPRegs:$T, FPRegs:$F, i32imm:$Cond),
343 "; SELECT_CC_FP_ICC PSEUDO!",
344 [(set f32:$dst, (SPselecticc f32:$T, f32:$F, imm:$Cond))]>;
346 def SELECT_CC_DFP_ICC
347 : Pseudo<(outs DFPRegs:$dst), (ins DFPRegs:$T, DFPRegs:$F, i32imm:$Cond),
348 "; SELECT_CC_DFP_ICC PSEUDO!",
349 [(set f64:$dst, (SPselecticc f64:$T, f64:$F, imm:$Cond))]>;
351 def SELECT_CC_QFP_ICC
352 : Pseudo<(outs QFPRegs:$dst), (ins QFPRegs:$T, QFPRegs:$F, i32imm:$Cond),
353 "; SELECT_CC_QFP_ICC PSEUDO!",
354 [(set f128:$dst, (SPselecticc f128:$T, f128:$F, imm:$Cond))]>;
357 let usesCustomInserter = 1, Uses = [FCC0] in {
359 def SELECT_CC_Int_FCC
360 : Pseudo<(outs IntRegs:$dst), (ins IntRegs:$T, IntRegs:$F, i32imm:$Cond),
361 "; SELECT_CC_Int_FCC PSEUDO!",
362 [(set i32:$dst, (SPselectfcc i32:$T, i32:$F, imm:$Cond))]>;
365 : Pseudo<(outs FPRegs:$dst), (ins FPRegs:$T, FPRegs:$F, i32imm:$Cond),
366 "; SELECT_CC_FP_FCC PSEUDO!",
367 [(set f32:$dst, (SPselectfcc f32:$T, f32:$F, imm:$Cond))]>;
368 def SELECT_CC_DFP_FCC
369 : Pseudo<(outs DFPRegs:$dst), (ins DFPRegs:$T, DFPRegs:$F, i32imm:$Cond),
370 "; SELECT_CC_DFP_FCC PSEUDO!",
371 [(set f64:$dst, (SPselectfcc f64:$T, f64:$F, imm:$Cond))]>;
372 def SELECT_CC_QFP_FCC
373 : Pseudo<(outs QFPRegs:$dst), (ins QFPRegs:$T, QFPRegs:$F, i32imm:$Cond),
374 "; SELECT_CC_QFP_FCC PSEUDO!",
375 [(set f128:$dst, (SPselectfcc f128:$T, f128:$F, imm:$Cond))]>;
379 let isTerminator = 1, hasDelaySlot = 1, isBarrier = 1 in {
380 def JMPLrr: F3_1<2, 0b111000, (outs IntRegs:$dst), (ins MEMrr:$addr),
381 "jmpl $addr, $dst", []>;
382 def JMPLri: F3_2<2, 0b111000, (outs IntRegs:$dst), (ins MEMri:$addr),
383 "jmpl $addr, $dst", []>;
386 // Section A.3 - Synthetic Instructions, p. 85
387 // special cases of JMPL:
388 let isReturn = 1, isTerminator = 1, hasDelaySlot = 1, isBarrier = 1,
389 isCodeGenOnly = 1 in {
390 let rd = 0, rs1 = 15 in
391 def RETL: F3_2<2, 0b111000, (outs), (ins i32imm:$val),
392 "jmp %o7+$val", [(retflag simm13:$val)]>;
394 let rd = 0, rs1 = 31 in
395 def RET: F3_2<2, 0b111000, (outs), (ins i32imm:$val),
399 // Section B.1 - Load Integer Instructions, p. 90
400 let DecoderMethod = "DecodeLoadInt" in {
401 defm LDSB : Load<"ldsb", 0b001001, sextloadi8, IntRegs, i32>;
402 defm LDSH : Load<"ldsh", 0b001010, sextloadi16, IntRegs, i32>;
403 defm LDUB : Load<"ldub", 0b000001, zextloadi8, IntRegs, i32>;
404 defm LDUH : Load<"lduh", 0b000010, zextloadi16, IntRegs, i32>;
405 defm LD : Load<"ld", 0b000000, load, IntRegs, i32>;
408 // Section B.2 - Load Floating-point Instructions, p. 92
409 let DecoderMethod = "DecodeLoadFP" in
410 defm LDF : Load<"ld", 0b100000, load, FPRegs, f32>;
411 let DecoderMethod = "DecodeLoadDFP" in
412 defm LDDF : Load<"ldd", 0b100011, load, DFPRegs, f64>;
413 let DecoderMethod = "DecodeLoadQFP" in
414 defm LDQF : Load<"ldq", 0b100010, load, QFPRegs, f128>,
415 Requires<[HasV9, HasHardQuad]>;
417 // Section B.4 - Store Integer Instructions, p. 95
418 let DecoderMethod = "DecodeStoreInt" in {
419 defm STB : Store<"stb", 0b000101, truncstorei8, IntRegs, i32>;
420 defm STH : Store<"sth", 0b000110, truncstorei16, IntRegs, i32>;
421 defm ST : Store<"st", 0b000100, store, IntRegs, i32>;
424 // Section B.5 - Store Floating-point Instructions, p. 97
425 let DecoderMethod = "DecodeStoreFP" in
426 defm STF : Store<"st", 0b100100, store, FPRegs, f32>;
427 let DecoderMethod = "DecodeStoreDFP" in
428 defm STDF : Store<"std", 0b100111, store, DFPRegs, f64>;
429 let DecoderMethod = "DecodeStoreQFP" in
430 defm STQF : Store<"stq", 0b100110, store, QFPRegs, f128>,
431 Requires<[HasV9, HasHardQuad]>;
433 // Section B.9 - SETHI Instruction, p. 104
434 def SETHIi: F2_1<0b100,
435 (outs IntRegs:$rd), (ins i32imm:$imm22),
437 [(set i32:$rd, SETHIimm:$imm22)]>;
439 // Section B.10 - NOP Instruction, p. 105
440 // (It's a special case of SETHI)
441 let rd = 0, imm22 = 0 in
442 def NOP : F2_1<0b100, (outs), (ins), "nop", []>;
444 // Section B.11 - Logical Instructions, p. 106
445 defm AND : F3_12<"and", 0b000001, and, IntRegs, i32, simm13Op>;
447 def ANDNrr : F3_1<2, 0b000101,
448 (outs IntRegs:$rd), (ins IntRegs:$rs1, IntRegs:$rs2),
449 "andn $rs1, $rs2, $rd",
450 [(set i32:$rd, (and i32:$rs1, (not i32:$rs2)))]>;
451 def ANDNri : F3_2<2, 0b000101,
452 (outs IntRegs:$rd), (ins IntRegs:$rs1, simm13Op:$simm13),
453 "andn $rs1, $simm13, $rd", []>;
455 defm OR : F3_12<"or", 0b000010, or, IntRegs, i32, simm13Op>;
457 def ORNrr : F3_1<2, 0b000110,
458 (outs IntRegs:$rd), (ins IntRegs:$rs1, IntRegs:$rs2),
459 "orn $rs1, $rs2, $rd",
460 [(set i32:$rd, (or i32:$rs1, (not i32:$rs2)))]>;
461 def ORNri : F3_2<2, 0b000110,
462 (outs IntRegs:$rd), (ins IntRegs:$rs1, simm13Op:$simm13),
463 "orn $rs1, $simm13, $rd", []>;
464 defm XOR : F3_12<"xor", 0b000011, xor, IntRegs, i32, simm13Op>;
466 def XNORrr : F3_1<2, 0b000111,
467 (outs IntRegs:$rd), (ins IntRegs:$rs1, IntRegs:$rs2),
468 "xnor $rs1, $rs2, $rd",
469 [(set i32:$rd, (not (xor i32:$rs1, i32:$rs2)))]>;
470 def XNORri : F3_2<2, 0b000111,
471 (outs IntRegs:$rd), (ins IntRegs:$rs1, simm13Op:$simm13),
472 "xnor $rs1, $simm13, $rd", []>;
474 let Defs = [ICC] in {
475 defm ANDCC : F3_12np<"andcc", 0b010001>;
476 defm ANDNCC : F3_12np<"andncc", 0b010101>;
477 defm ORCC : F3_12np<"orcc", 0b010010>;
478 defm ORNCC : F3_12np<"orncc", 0b010110>;
479 defm XORCC : F3_12np<"xorcc", 0b010011>;
480 defm XNORCC : F3_12np<"xnorcc", 0b010111>;
483 // Section B.12 - Shift Instructions, p. 107
484 defm SLL : F3_12<"sll", 0b100101, shl, IntRegs, i32, simm13Op>;
485 defm SRL : F3_12<"srl", 0b100110, srl, IntRegs, i32, simm13Op>;
486 defm SRA : F3_12<"sra", 0b100111, sra, IntRegs, i32, simm13Op>;
488 // Section B.13 - Add Instructions, p. 108
489 defm ADD : F3_12<"add", 0b000000, add, IntRegs, i32, simm13Op>;
491 // "LEA" forms of add (patterns to make tblgen happy)
492 let Predicates = [Is32Bit], isCodeGenOnly = 1 in
493 def LEA_ADDri : F3_2<2, 0b000000,
494 (outs IntRegs:$dst), (ins MEMri:$addr),
495 "add ${addr:arith}, $dst",
496 [(set iPTR:$dst, ADDRri:$addr)]>;
499 defm ADDCC : F3_12<"addcc", 0b010000, addc, IntRegs, i32, simm13Op>;
502 defm ADDC : F3_12np<"addx", 0b001000>;
504 let Uses = [ICC], Defs = [ICC] in
505 defm ADDE : F3_12<"addxcc", 0b011000, adde, IntRegs, i32, simm13Op>;
507 // Section B.15 - Subtract Instructions, p. 110
508 defm SUB : F3_12 <"sub" , 0b000100, sub, IntRegs, i32, simm13Op>;
509 let Uses = [ICC], Defs = [ICC] in
510 defm SUBE : F3_12 <"subxcc" , 0b011100, sube, IntRegs, i32, simm13Op>;
513 defm SUBCC : F3_12 <"subcc", 0b010100, subc, IntRegs, i32, simm13Op>;
516 defm SUBC : F3_12np <"subx", 0b001100>;
518 let Defs = [ICC], rd = 0 in {
519 def CMPrr : F3_1<2, 0b010100,
520 (outs), (ins IntRegs:$rs1, IntRegs:$rs2),
522 [(SPcmpicc i32:$rs1, i32:$rs2)]>;
523 def CMPri : F3_2<2, 0b010100,
524 (outs), (ins IntRegs:$rs1, simm13Op:$simm13),
526 [(SPcmpicc i32:$rs1, (i32 simm13:$simm13))]>;
529 // Section B.18 - Multiply Instructions, p. 113
531 defm UMUL : F3_12np<"umul", 0b001010>;
532 defm SMUL : F3_12 <"smul", 0b001011, mul, IntRegs, i32, simm13Op>;
535 let Defs = [Y, ICC] in {
536 defm UMULCC : F3_12np<"umulcc", 0b011010>;
537 defm SMULCC : F3_12np<"smulcc", 0b011011>;
540 // Section B.19 - Divide Instructions, p. 115
542 defm UDIV : F3_12np<"udiv", 0b001110>;
543 defm SDIV : F3_12np<"sdiv", 0b001111>;
546 let Defs = [Y, ICC] in {
547 defm UDIVCC : F3_12np<"udivcc", 0b011110>;
548 defm SDIVCC : F3_12np<"sdivcc", 0b011111>;
551 // Section B.20 - SAVE and RESTORE, p. 117
552 defm SAVE : F3_12np<"save" , 0b111100>;
553 defm RESTORE : F3_12np<"restore", 0b111101>;
555 // Section B.21 - Branch on Integer Condition Codes Instructions, p. 119
557 // unconditional branch class.
558 class BranchAlways<dag ins, string asmstr, list<dag> pattern>
559 : F2_2<0b010, 0, (outs), ins, asmstr, pattern> {
561 let isTerminator = 1;
562 let hasDelaySlot = 1;
567 def BA : BranchAlways<(ins brtarget:$imm22), "ba $imm22", [(br bb:$imm22)]>;
570 let isBranch = 1, isTerminator = 1, hasDelaySlot = 1 in {
572 // conditional branch class:
573 class BranchSP<dag ins, string asmstr, list<dag> pattern>
574 : F2_2<0b010, 0, (outs), ins, asmstr, pattern>;
576 // conditional branch with annul class:
577 class BranchSPA<dag ins, string asmstr, list<dag> pattern>
578 : F2_2<0b010, 1, (outs), ins, asmstr, pattern>;
580 // Conditional branch class on %icc|%xcc with predication:
581 multiclass IPredBranch<string regstr, list<dag> CCPattern> {
582 def CC : F2_3<0b001, 0, 1, (outs), (ins bprtarget:$imm19, CCOp:$cond),
583 !strconcat("b$cond ", !strconcat(regstr, ", $imm19")),
585 def CCA : F2_3<0b001, 1, 1, (outs), (ins bprtarget:$imm19, CCOp:$cond),
586 !strconcat("b$cond,a ", !strconcat(regstr, ", $imm19")),
588 def CCNT : F2_3<0b001, 0, 0, (outs), (ins bprtarget:$imm19, CCOp:$cond),
589 !strconcat("b$cond,pn ", !strconcat(regstr, ", $imm19")),
591 def CCANT : F2_3<0b001, 1, 0, (outs), (ins bprtarget:$imm19, CCOp:$cond),
592 !strconcat("b$cond,a,pn ", !strconcat(regstr, ", $imm19")),
596 } // let isBranch = 1, isTerminator = 1, hasDelaySlot = 1
599 // Indirect branch instructions.
600 let isTerminator = 1, isBarrier = 1, hasDelaySlot = 1, isBranch =1,
601 isIndirectBranch = 1, rd = 0, isCodeGenOnly = 1 in {
602 def BINDrr : F3_1<2, 0b111000,
603 (outs), (ins MEMrr:$ptr),
605 [(brind ADDRrr:$ptr)]>;
606 def BINDri : F3_2<2, 0b111000,
607 (outs), (ins MEMri:$ptr),
609 [(brind ADDRri:$ptr)]>;
612 let Uses = [ICC] in {
613 def BCOND : BranchSP<(ins brtarget:$imm22, CCOp:$cond),
615 [(SPbricc bb:$imm22, imm:$cond)]>;
616 def BCONDA : BranchSPA<(ins brtarget:$imm22, CCOp:$cond),
617 "b$cond,a $imm22", []>;
619 let Predicates = [HasV9], cc = 0b00 in
620 defm BPI : IPredBranch<"%icc", []>;
623 // Section B.22 - Branch on Floating-point Condition Codes Instructions, p. 121
625 let isBranch = 1, isTerminator = 1, hasDelaySlot = 1 in {
627 // floating-point conditional branch class:
628 class FPBranchSP<dag ins, string asmstr, list<dag> pattern>
629 : F2_2<0b110, 0, (outs), ins, asmstr, pattern>;
631 // floating-point conditional branch with annul class:
632 class FPBranchSPA<dag ins, string asmstr, list<dag> pattern>
633 : F2_2<0b110, 1, (outs), ins, asmstr, pattern>;
635 // Conditional branch class on %fcc0-%fcc3 with predication:
636 multiclass FPredBranch {
637 def CC : F2_3<0b101, 0, 1, (outs), (ins bprtarget:$imm19, CCOp:$cond),
638 "fb$cond %fcc0, $imm19", []>;
639 def CCA : F2_3<0b101, 1, 1, (outs), (ins bprtarget:$imm19, CCOp:$cond),
640 "fb$cond,a %fcc0, $imm19", []>;
641 def CCNT : F2_3<0b101, 0, 0, (outs), (ins bprtarget:$imm19, CCOp:$cond),
642 "fb$cond,pn %fcc0, $imm19", []>;
643 def CCANT : F2_3<0b101, 1, 0, (outs), (ins bprtarget:$imm19, CCOp:$cond),
644 "fb$cond,a,pn %fcc0, $imm19", []>;
646 } // let isBranch = 1, isTerminator = 1, hasDelaySlot = 1
648 let Uses = [FCC0] in {
649 def FBCOND : FPBranchSP<(ins brtarget:$imm22, CCOp:$cond),
651 [(SPbrfcc bb:$imm22, imm:$cond)]>;
652 def FBCONDA : FPBranchSPA<(ins brtarget:$imm22, CCOp:$cond),
653 "fb$cond,a $imm22", []>;
655 let Predicates = [HasV9], cc = 0b00 in
656 defm BPF : FPredBranch;
659 // Section B.24 - Call and Link Instruction, p. 125
660 // This is the only Format 1 instruction
662 hasDelaySlot = 1, isCall = 1 in {
663 def CALL : InstSP<(outs), (ins calltarget:$disp, variable_ops),
667 let Inst{29-0} = disp;
670 // indirect calls: special cases of JMPL.
671 let isCodeGenOnly = 1, rd = 15 in {
672 def CALLrr : F3_1<2, 0b111000,
673 (outs), (ins MEMrr:$ptr, variable_ops),
675 [(call ADDRrr:$ptr)]>;
676 def CALLri : F3_2<2, 0b111000,
677 (outs), (ins MEMri:$ptr, variable_ops),
679 [(call ADDRri:$ptr)]>;
683 // Section B.28 - Read State Register Instructions
684 let Uses = [Y], rs1 = 0, rs2 = 0 in
685 def RDY : F3_1<2, 0b101000,
686 (outs IntRegs:$dst), (ins),
689 // Section B.29 - Write State Register Instructions
690 let Defs = [Y], rd = 0 in {
691 def WRYrr : F3_1<2, 0b110000,
692 (outs), (ins IntRegs:$rs1, IntRegs:$rs2),
693 "wr $rs1, $rs2, %y", []>;
694 def WRYri : F3_2<2, 0b110000,
695 (outs), (ins IntRegs:$rs1, simm13Op:$simm13),
696 "wr $rs1, $simm13, %y", []>;
698 // Convert Integer to Floating-point Instructions, p. 141
699 def FITOS : F3_3u<2, 0b110100, 0b011000100,
700 (outs FPRegs:$rd), (ins FPRegs:$rs2),
702 [(set FPRegs:$rd, (SPitof FPRegs:$rs2))]>;
703 def FITOD : F3_3u<2, 0b110100, 0b011001000,
704 (outs DFPRegs:$rd), (ins FPRegs:$rs2),
706 [(set DFPRegs:$rd, (SPitof FPRegs:$rs2))]>;
707 def FITOQ : F3_3u<2, 0b110100, 0b011001100,
708 (outs QFPRegs:$rd), (ins FPRegs:$rs2),
710 [(set QFPRegs:$rd, (SPitof FPRegs:$rs2))]>,
711 Requires<[HasHardQuad]>;
713 // Convert Floating-point to Integer Instructions, p. 142
714 def FSTOI : F3_3u<2, 0b110100, 0b011010001,
715 (outs FPRegs:$rd), (ins FPRegs:$rs2),
717 [(set FPRegs:$rd, (SPftoi FPRegs:$rs2))]>;
718 def FDTOI : F3_3u<2, 0b110100, 0b011010010,
719 (outs FPRegs:$rd), (ins DFPRegs:$rs2),
721 [(set FPRegs:$rd, (SPftoi DFPRegs:$rs2))]>;
722 def FQTOI : F3_3u<2, 0b110100, 0b011010011,
723 (outs FPRegs:$rd), (ins QFPRegs:$rs2),
725 [(set FPRegs:$rd, (SPftoi QFPRegs:$rs2))]>,
726 Requires<[HasHardQuad]>;
728 // Convert between Floating-point Formats Instructions, p. 143
729 def FSTOD : F3_3u<2, 0b110100, 0b011001001,
730 (outs DFPRegs:$rd), (ins FPRegs:$rs2),
732 [(set f64:$rd, (fextend f32:$rs2))]>;
733 def FSTOQ : F3_3u<2, 0b110100, 0b011001101,
734 (outs QFPRegs:$rd), (ins FPRegs:$rs2),
736 [(set f128:$rd, (fextend f32:$rs2))]>,
737 Requires<[HasHardQuad]>;
738 def FDTOS : F3_3u<2, 0b110100, 0b011000110,
739 (outs FPRegs:$rd), (ins DFPRegs:$rs2),
741 [(set f32:$rd, (fround f64:$rs2))]>;
742 def FDTOQ : F3_3u<2, 0b110100, 0b011001110,
743 (outs QFPRegs:$rd), (ins DFPRegs:$rs2),
745 [(set f128:$rd, (fextend f64:$rs2))]>,
746 Requires<[HasHardQuad]>;
747 def FQTOS : F3_3u<2, 0b110100, 0b011000111,
748 (outs FPRegs:$rd), (ins QFPRegs:$rs2),
750 [(set f32:$rd, (fround f128:$rs2))]>,
751 Requires<[HasHardQuad]>;
752 def FQTOD : F3_3u<2, 0b110100, 0b011001011,
753 (outs DFPRegs:$rd), (ins QFPRegs:$rs2),
755 [(set f64:$rd, (fround f128:$rs2))]>,
756 Requires<[HasHardQuad]>;
758 // Floating-point Move Instructions, p. 144
759 def FMOVS : F3_3u<2, 0b110100, 0b000000001,
760 (outs FPRegs:$rd), (ins FPRegs:$rs2),
761 "fmovs $rs2, $rd", []>;
762 def FNEGS : F3_3u<2, 0b110100, 0b000000101,
763 (outs FPRegs:$rd), (ins FPRegs:$rs2),
765 [(set f32:$rd, (fneg f32:$rs2))]>;
766 def FABSS : F3_3u<2, 0b110100, 0b000001001,
767 (outs FPRegs:$rd), (ins FPRegs:$rs2),
769 [(set f32:$rd, (fabs f32:$rs2))]>;
772 // Floating-point Square Root Instructions, p.145
773 def FSQRTS : F3_3u<2, 0b110100, 0b000101001,
774 (outs FPRegs:$rd), (ins FPRegs:$rs2),
776 [(set f32:$rd, (fsqrt f32:$rs2))]>;
777 def FSQRTD : F3_3u<2, 0b110100, 0b000101010,
778 (outs DFPRegs:$rd), (ins DFPRegs:$rs2),
780 [(set f64:$rd, (fsqrt f64:$rs2))]>;
781 def FSQRTQ : F3_3u<2, 0b110100, 0b000101011,
782 (outs QFPRegs:$rd), (ins QFPRegs:$rs2),
784 [(set f128:$rd, (fsqrt f128:$rs2))]>,
785 Requires<[HasHardQuad]>;
789 // Floating-point Add and Subtract Instructions, p. 146
790 def FADDS : F3_3<2, 0b110100, 0b001000001,
791 (outs FPRegs:$rd), (ins FPRegs:$rs1, FPRegs:$rs2),
792 "fadds $rs1, $rs2, $rd",
793 [(set f32:$rd, (fadd f32:$rs1, f32:$rs2))]>;
794 def FADDD : F3_3<2, 0b110100, 0b001000010,
795 (outs DFPRegs:$rd), (ins DFPRegs:$rs1, DFPRegs:$rs2),
796 "faddd $rs1, $rs2, $rd",
797 [(set f64:$rd, (fadd f64:$rs1, f64:$rs2))]>;
798 def FADDQ : F3_3<2, 0b110100, 0b001000011,
799 (outs QFPRegs:$rd), (ins QFPRegs:$rs1, QFPRegs:$rs2),
800 "faddq $rs1, $rs2, $rd",
801 [(set f128:$rd, (fadd f128:$rs1, f128:$rs2))]>,
802 Requires<[HasHardQuad]>;
804 def FSUBS : F3_3<2, 0b110100, 0b001000101,
805 (outs FPRegs:$rd), (ins FPRegs:$rs1, FPRegs:$rs2),
806 "fsubs $rs1, $rs2, $rd",
807 [(set f32:$rd, (fsub f32:$rs1, f32:$rs2))]>;
808 def FSUBD : F3_3<2, 0b110100, 0b001000110,
809 (outs DFPRegs:$rd), (ins DFPRegs:$rs1, DFPRegs:$rs2),
810 "fsubd $rs1, $rs2, $rd",
811 [(set f64:$rd, (fsub f64:$rs1, f64:$rs2))]>;
812 def FSUBQ : F3_3<2, 0b110100, 0b001000111,
813 (outs QFPRegs:$rd), (ins QFPRegs:$rs1, QFPRegs:$rs2),
814 "fsubq $rs1, $rs2, $rd",
815 [(set f128:$rd, (fsub f128:$rs1, f128:$rs2))]>,
816 Requires<[HasHardQuad]>;
819 // Floating-point Multiply and Divide Instructions, p. 147
820 def FMULS : F3_3<2, 0b110100, 0b001001001,
821 (outs FPRegs:$rd), (ins FPRegs:$rs1, FPRegs:$rs2),
822 "fmuls $rs1, $rs2, $rd",
823 [(set f32:$rd, (fmul f32:$rs1, f32:$rs2))]>;
824 def FMULD : F3_3<2, 0b110100, 0b001001010,
825 (outs DFPRegs:$rd), (ins DFPRegs:$rs1, DFPRegs:$rs2),
826 "fmuld $rs1, $rs2, $rd",
827 [(set f64:$rd, (fmul f64:$rs1, f64:$rs2))]>;
828 def FMULQ : F3_3<2, 0b110100, 0b001001011,
829 (outs QFPRegs:$rd), (ins QFPRegs:$rs1, QFPRegs:$rs2),
830 "fmulq $rs1, $rs2, $rd",
831 [(set f128:$rd, (fmul f128:$rs1, f128:$rs2))]>,
832 Requires<[HasHardQuad]>;
834 def FSMULD : F3_3<2, 0b110100, 0b001101001,
835 (outs DFPRegs:$rd), (ins FPRegs:$rs1, FPRegs:$rs2),
836 "fsmuld $rs1, $rs2, $rd",
837 [(set f64:$rd, (fmul (fextend f32:$rs1),
838 (fextend f32:$rs2)))]>;
839 def FDMULQ : F3_3<2, 0b110100, 0b001101110,
840 (outs QFPRegs:$rd), (ins DFPRegs:$rs1, DFPRegs:$rs2),
841 "fdmulq $rs1, $rs2, $rd",
842 [(set f128:$rd, (fmul (fextend f64:$rs1),
843 (fextend f64:$rs2)))]>,
844 Requires<[HasHardQuad]>;
846 def FDIVS : F3_3<2, 0b110100, 0b001001101,
847 (outs FPRegs:$rd), (ins FPRegs:$rs1, FPRegs:$rs2),
848 "fdivs $rs1, $rs2, $rd",
849 [(set f32:$rd, (fdiv f32:$rs1, f32:$rs2))]>;
850 def FDIVD : F3_3<2, 0b110100, 0b001001110,
851 (outs DFPRegs:$rd), (ins DFPRegs:$rs1, DFPRegs:$rs2),
852 "fdivd $rs1, $rs2, $rd",
853 [(set f64:$rd, (fdiv f64:$rs1, f64:$rs2))]>;
854 def FDIVQ : F3_3<2, 0b110100, 0b001001111,
855 (outs QFPRegs:$rd), (ins QFPRegs:$rs1, QFPRegs:$rs2),
856 "fdivq $rs1, $rs2, $rd",
857 [(set f128:$rd, (fdiv f128:$rs1, f128:$rs2))]>,
858 Requires<[HasHardQuad]>;
860 // Floating-point Compare Instructions, p. 148
861 // Note: the 2nd template arg is different for these guys.
862 // Note 2: the result of a FCMP is not available until the 2nd cycle
863 // after the instr is retired, but there is no interlock in Sparc V8.
864 // This behavior is modeled with a forced noop after the instruction in
867 let Defs = [FCC0] in {
868 def FCMPS : F3_3c<2, 0b110101, 0b001010001,
869 (outs), (ins FPRegs:$rs1, FPRegs:$rs2),
871 [(SPcmpfcc f32:$rs1, f32:$rs2)]>;
872 def FCMPD : F3_3c<2, 0b110101, 0b001010010,
873 (outs), (ins DFPRegs:$rs1, DFPRegs:$rs2),
875 [(SPcmpfcc f64:$rs1, f64:$rs2)]>;
876 def FCMPQ : F3_3c<2, 0b110101, 0b001010011,
877 (outs), (ins QFPRegs:$rs1, QFPRegs:$rs2),
879 [(SPcmpfcc f128:$rs1, f128:$rs2)]>,
880 Requires<[HasHardQuad]>;
883 //===----------------------------------------------------------------------===//
884 // Instructions for Thread Local Storage(TLS).
885 //===----------------------------------------------------------------------===//
886 let isCodeGenOnly = 1, isAsmParserOnly = 1 in {
887 def TLS_ADDrr : F3_1<2, 0b000000,
889 (ins IntRegs:$rs1, IntRegs:$rs2, TLSSym:$sym),
890 "add $rs1, $rs2, $rd, $sym",
892 (tlsadd i32:$rs1, i32:$rs2, tglobaltlsaddr:$sym))]>;
895 def TLS_LDrr : F3_1<3, 0b000000,
896 (outs IntRegs:$dst), (ins MEMrr:$addr, TLSSym:$sym),
897 "ld [$addr], $dst, $sym",
899 (tlsld ADDRrr:$addr, tglobaltlsaddr:$sym))]>;
901 let Uses = [O6], isCall = 1, hasDelaySlot = 1 in
902 def TLS_CALL : InstSP<(outs),
903 (ins calltarget:$disp, TLSSym:$sym, variable_ops),
905 [(tlscall texternalsym:$disp, tglobaltlsaddr:$sym)]> {
908 let Inst{29-0} = disp;
912 //===----------------------------------------------------------------------===//
914 //===----------------------------------------------------------------------===//
916 // V9 Conditional Moves.
917 let Predicates = [HasV9], Constraints = "$f = $rd" in {
918 // Move Integer Register on Condition (MOVcc) p. 194 of the V9 manual.
919 let Uses = [ICC], cc = 0b100 in {
921 : F4_1<0b101100, (outs IntRegs:$rd),
922 (ins IntRegs:$rs2, IntRegs:$f, CCOp:$cond),
923 "mov$cond %icc, $rs2, $rd",
924 [(set i32:$rd, (SPselecticc i32:$rs2, i32:$f, imm:$cond))]>;
927 : F4_2<0b101100, (outs IntRegs:$rd),
928 (ins i32imm:$simm11, IntRegs:$f, CCOp:$cond),
929 "mov$cond %icc, $simm11, $rd",
931 (SPselecticc simm11:$simm11, i32:$f, imm:$cond))]>;
934 let Uses = [FCC0], cc = 0b000 in {
936 : F4_1<0b101100, (outs IntRegs:$rd),
937 (ins IntRegs:$rs2, IntRegs:$f, CCOp:$cond),
938 "mov$cond %fcc0, $rs2, $rd",
939 [(set i32:$rd, (SPselectfcc i32:$rs2, i32:$f, imm:$cond))]>;
941 : F4_2<0b101100, (outs IntRegs:$rd),
942 (ins i32imm:$simm11, IntRegs:$f, CCOp:$cond),
943 "mov$cond %fcc0, $simm11, $rd",
945 (SPselectfcc simm11:$simm11, i32:$f, imm:$cond))]>;
948 let Uses = [ICC], opf_cc = 0b100 in {
950 : F4_3<0b110101, 0b000001, (outs FPRegs:$rd),
951 (ins FPRegs:$rs2, FPRegs:$f, CCOp:$cond),
952 "fmovs$cond %icc, $rs2, $rd",
953 [(set f32:$rd, (SPselecticc f32:$rs2, f32:$f, imm:$cond))]>;
955 : F4_3<0b110101, 0b000010, (outs DFPRegs:$rd),
956 (ins DFPRegs:$rs2, DFPRegs:$f, CCOp:$cond),
957 "fmovd$cond %icc, $rs2, $rd",
958 [(set f64:$rd, (SPselecticc f64:$rs2, f64:$f, imm:$cond))]>;
960 : F4_3<0b110101, 0b000011, (outs QFPRegs:$rd),
961 (ins QFPRegs:$rs2, QFPRegs:$f, CCOp:$cond),
962 "fmovq$cond %icc, $rs2, $rd",
963 [(set f128:$rd, (SPselecticc f128:$rs2, f128:$f, imm:$cond))]>,
964 Requires<[HasHardQuad]>;
967 let Uses = [FCC0], opf_cc = 0b000 in {
969 : F4_3<0b110101, 0b000001, (outs FPRegs:$rd),
970 (ins FPRegs:$rs2, FPRegs:$f, CCOp:$cond),
971 "fmovs$cond %fcc0, $rs2, $rd",
972 [(set f32:$rd, (SPselectfcc f32:$rs2, f32:$f, imm:$cond))]>;
974 : F4_3<0b110101, 0b000010, (outs DFPRegs:$rd),
975 (ins DFPRegs:$rs2, DFPRegs:$f, CCOp:$cond),
976 "fmovd$cond %fcc0, $rs2, $rd",
977 [(set f64:$rd, (SPselectfcc f64:$rs2, f64:$f, imm:$cond))]>;
979 : F4_3<0b110101, 0b000011, (outs QFPRegs:$rd),
980 (ins QFPRegs:$rs2, QFPRegs:$f, CCOp:$cond),
981 "fmovq$cond %fcc0, $rs2, $rd",
982 [(set f128:$rd, (SPselectfcc f128:$rs2, f128:$f, imm:$cond))]>,
983 Requires<[HasHardQuad]>;
988 // Floating-Point Move Instructions, p. 164 of the V9 manual.
989 let Predicates = [HasV9] in {
990 def FMOVD : F3_3u<2, 0b110100, 0b000000010,
991 (outs DFPRegs:$rd), (ins DFPRegs:$rs2),
992 "fmovd $rs2, $rd", []>;
993 def FMOVQ : F3_3u<2, 0b110100, 0b000000011,
994 (outs QFPRegs:$rd), (ins QFPRegs:$rs2),
995 "fmovq $rs2, $rd", []>,
996 Requires<[HasHardQuad]>;
997 def FNEGD : F3_3u<2, 0b110100, 0b000000110,
998 (outs DFPRegs:$rd), (ins DFPRegs:$rs2),
1000 [(set f64:$rd, (fneg f64:$rs2))]>;
1001 def FNEGQ : F3_3u<2, 0b110100, 0b000000111,
1002 (outs QFPRegs:$rd), (ins QFPRegs:$rs2),
1004 [(set f128:$rd, (fneg f128:$rs2))]>,
1005 Requires<[HasHardQuad]>;
1006 def FABSD : F3_3u<2, 0b110100, 0b000001010,
1007 (outs DFPRegs:$rd), (ins DFPRegs:$rs2),
1009 [(set f64:$rd, (fabs f64:$rs2))]>;
1010 def FABSQ : F3_3u<2, 0b110100, 0b000001011,
1011 (outs QFPRegs:$rd), (ins QFPRegs:$rs2),
1013 [(set f128:$rd, (fabs f128:$rs2))]>,
1014 Requires<[HasHardQuad]>;
1017 // POPCrr - This does a ctpop of a 64-bit register. As such, we have to clear
1018 // the top 32-bits before using it. To do this clearing, we use a SRLri X,0.
1020 def POPCrr : F3_1<2, 0b101110,
1021 (outs IntRegs:$dst), (ins IntRegs:$src),
1022 "popc $src, $dst", []>, Requires<[HasV9]>;
1023 def : Pat<(ctpop i32:$src),
1024 (POPCrr (SRLri $src, 0))>;
1027 let hasSideEffects =1, rd = 0, rs1 = 0b01111, rs2 = 0 in
1028 def STBAR : F3_1<2, 0b101000, (outs), (ins), "stbar", []>;
1030 let Predicates = [HasV9], hasSideEffects = 1, rd = 0, rs1 = 0b01111 in
1031 def MEMBARi : F3_2<2, 0b101000, (outs), (ins simm13Op:$simm13),
1032 "membar $simm13", []>;
1034 let Constraints = "$val = $dst" in {
1035 def SWAPrr : F3_1<3, 0b001111,
1036 (outs IntRegs:$dst), (ins MEMrr:$addr, IntRegs:$val),
1037 "swap [$addr], $dst",
1038 [(set i32:$dst, (atomic_swap_32 ADDRrr:$addr, i32:$val))]>;
1039 def SWAPri : F3_2<3, 0b001111,
1040 (outs IntRegs:$dst), (ins MEMri:$addr, IntRegs:$val),
1041 "swap [$addr], $dst",
1042 [(set i32:$dst, (atomic_swap_32 ADDRri:$addr, i32:$val))]>;
1045 let Predicates = [HasV9], Constraints = "$swap = $rd" in
1046 def CASrr: F3_1_asi<3, 0b111100, 0b10000000,
1047 (outs IntRegs:$rd), (ins IntRegs:$rs1, IntRegs:$rs2,
1049 "cas [$rs1], $rs2, $rd",
1051 (atomic_cmp_swap iPTR:$rs1, i32:$rs2, i32:$swap))]>;
1053 let Defs = [ICC] in {
1054 defm TADDCC : F3_12np<"taddcc", 0b100000>;
1055 defm TSUBCC : F3_12np<"tsubcc", 0b100001>;
1057 let hasSideEffects = 1 in {
1058 defm TADDCCTV : F3_12np<"taddcctv", 0b100010>;
1059 defm TSUBCCTV : F3_12np<"tsubcctv", 0b100011>;
1063 //===----------------------------------------------------------------------===//
1064 // Non-Instruction Patterns
1065 //===----------------------------------------------------------------------===//
1067 // Small immediates.
1068 def : Pat<(i32 simm13:$val),
1069 (ORri (i32 G0), imm:$val)>;
1070 // Arbitrary immediates.
1071 def : Pat<(i32 imm:$val),
1072 (ORri (SETHIi (HI22 imm:$val)), (LO10 imm:$val))>;
1075 // Global addresses, constant pool entries
1076 let Predicates = [Is32Bit] in {
1078 def : Pat<(SPhi tglobaladdr:$in), (SETHIi tglobaladdr:$in)>;
1079 def : Pat<(SPlo tglobaladdr:$in), (ORri (i32 G0), tglobaladdr:$in)>;
1080 def : Pat<(SPhi tconstpool:$in), (SETHIi tconstpool:$in)>;
1081 def : Pat<(SPlo tconstpool:$in), (ORri (i32 G0), tconstpool:$in)>;
1083 // GlobalTLS addresses
1084 def : Pat<(SPhi tglobaltlsaddr:$in), (SETHIi tglobaltlsaddr:$in)>;
1085 def : Pat<(SPlo tglobaltlsaddr:$in), (ORri (i32 G0), tglobaltlsaddr:$in)>;
1086 def : Pat<(add (SPhi tglobaltlsaddr:$in1), (SPlo tglobaltlsaddr:$in2)),
1087 (ADDri (SETHIi tglobaltlsaddr:$in1), (tglobaltlsaddr:$in2))>;
1088 def : Pat<(xor (SPhi tglobaltlsaddr:$in1), (SPlo tglobaltlsaddr:$in2)),
1089 (XORri (SETHIi tglobaltlsaddr:$in1), (tglobaltlsaddr:$in2))>;
1092 def : Pat<(SPhi tblockaddress:$in), (SETHIi tblockaddress:$in)>;
1093 def : Pat<(SPlo tblockaddress:$in), (ORri (i32 G0), tblockaddress:$in)>;
1095 // Add reg, lo. This is used when taking the addr of a global/constpool entry.
1096 def : Pat<(add iPTR:$r, (SPlo tglobaladdr:$in)), (ADDri $r, tglobaladdr:$in)>;
1097 def : Pat<(add iPTR:$r, (SPlo tconstpool:$in)), (ADDri $r, tconstpool:$in)>;
1098 def : Pat<(add iPTR:$r, (SPlo tblockaddress:$in)),
1099 (ADDri $r, tblockaddress:$in)>;
1103 def : Pat<(call tglobaladdr:$dst),
1104 (CALL tglobaladdr:$dst)>;
1105 def : Pat<(call texternalsym:$dst),
1106 (CALL texternalsym:$dst)>;
1108 // Map integer extload's to zextloads.
1109 def : Pat<(i32 (extloadi1 ADDRrr:$src)), (LDUBrr ADDRrr:$src)>;
1110 def : Pat<(i32 (extloadi1 ADDRri:$src)), (LDUBri ADDRri:$src)>;
1111 def : Pat<(i32 (extloadi8 ADDRrr:$src)), (LDUBrr ADDRrr:$src)>;
1112 def : Pat<(i32 (extloadi8 ADDRri:$src)), (LDUBri ADDRri:$src)>;
1113 def : Pat<(i32 (extloadi16 ADDRrr:$src)), (LDUHrr ADDRrr:$src)>;
1114 def : Pat<(i32 (extloadi16 ADDRri:$src)), (LDUHri ADDRri:$src)>;
1116 // zextload bool -> zextload byte
1117 def : Pat<(i32 (zextloadi1 ADDRrr:$src)), (LDUBrr ADDRrr:$src)>;
1118 def : Pat<(i32 (zextloadi1 ADDRri:$src)), (LDUBri ADDRri:$src)>;
1120 // store 0, addr -> store %g0, addr
1121 def : Pat<(store (i32 0), ADDRrr:$dst), (STrr ADDRrr:$dst, (i32 G0))>;
1122 def : Pat<(store (i32 0), ADDRri:$dst), (STri ADDRri:$dst, (i32 G0))>;
1124 // store bar for all atomic_fence in V8.
1125 let Predicates = [HasNoV9] in
1126 def : Pat<(atomic_fence imm, imm), (STBAR)>;
1128 // atomic_load_32 addr -> load addr
1129 def : Pat<(i32 (atomic_load ADDRrr:$src)), (LDrr ADDRrr:$src)>;
1130 def : Pat<(i32 (atomic_load ADDRri:$src)), (LDri ADDRri:$src)>;
1132 // atomic_store_32 val, addr -> store val, addr
1133 def : Pat<(atomic_store ADDRrr:$dst, i32:$val), (STrr ADDRrr:$dst, $val)>;
1134 def : Pat<(atomic_store ADDRri:$dst, i32:$val), (STri ADDRri:$dst, $val)>;
1137 include "SparcInstr64Bit.td"
1138 include "SparcInstrAliases.td"