1 //===-- SparcInstr64Bit.td - 64-bit instructions 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 contains instruction definitions and patterns needed for 64-bit
10 // code generation on SPARC v9.
12 // Some SPARC v9 instructions are defined in SparcInstrInfo.td because they can
13 // also be used in 32-bit code running on a SPARC v9 CPU.
15 //===----------------------------------------------------------------------===//
17 let Predicates = [Is64Bit] in {
18 // The same integer registers are used for i32 and i64 values.
19 // When registers hold i32 values, the high bits are don't care.
20 // This give us free trunc and anyext.
21 def : Pat<(i64 (anyext i32:$val)), (COPY_TO_REGCLASS $val, I64Regs)>;
22 def : Pat<(i32 (trunc i64:$val)), (COPY_TO_REGCLASS $val, IntRegs)>;
24 } // Predicates = [Is64Bit]
27 //===----------------------------------------------------------------------===//
28 // 64-bit Shift Instructions.
29 //===----------------------------------------------------------------------===//
31 // The 32-bit shift instructions are still available. The left shift srl
32 // instructions shift all 64 bits, but it only accepts a 5-bit shift amount.
34 // The srl instructions only shift the low 32 bits and clear the high 32 bits.
35 // Finally, sra shifts the low 32 bits and sign-extends to 64 bits.
37 let Predicates = [Is64Bit] in {
39 def : Pat<(i64 (zext i32:$val)), (SRLri $val, 0)>;
40 def : Pat<(i64 (sext i32:$val)), (SRAri $val, 0)>;
42 def : Pat<(i64 (and i64:$val, 0xffffffff)), (SRLri $val, 0)>;
43 def : Pat<(i64 (sext_inreg i64:$val, i32)), (SRAri $val, 0)>;
45 defm SLLX : F3_S<"sllx", 0b100101, 1, shl, i64, shift_imm6, I64Regs>;
46 defm SRLX : F3_S<"srlx", 0b100110, 1, srl, i64, shift_imm6, I64Regs>;
47 defm SRAX : F3_S<"srax", 0b100111, 1, sra, i64, shift_imm6, I64Regs>;
49 } // Predicates = [Is64Bit]
52 //===----------------------------------------------------------------------===//
54 //===----------------------------------------------------------------------===//
56 // All 32-bit immediates can be materialized with sethi+or, but 64-bit
57 // immediates may require more code. There may be a point where it is
58 // preferable to use a constant pool load instead, depending on the
61 // Single-instruction patterns.
64 def : Pat<(i64 0), (COPY (i64 G0))>,
67 // The ALU instructions want their simm13 operands as i32 immediates.
68 // FIXME: This is no longer true, they are now pointer-sized.
69 def as_i32imm : SDNodeXForm<imm, [{
70 return CurDAG->getSignedTargetConstant(N->getSExtValue(), SDLoc(N), MVT::i32);
72 def : Pat<(i64 simm13:$val), (ORri (i64 G0), (as_i32imm $val))>;
73 def : Pat<(i64 SETHIimm:$val), (SETHIi (HI22 $val))>;
75 // Double-instruction patterns.
77 // All unsigned i32 immediates can be handled by sethi+or.
78 def uimm32 : PatLeaf<(imm), [{ return isUInt<32>(N->getZExtValue()); }]>;
79 def : Pat<(i64 uimm32:$val), (ORri (SETHIi (HI22 $val)), (LO10 $val))>,
82 // All negative i33 immediates can be handled by sethi+xor.
83 def nimm33 : PatLeaf<(imm), [{
84 int64_t Imm = N->getSExtValue();
85 return Imm < 0 && isInt<33>(Imm);
87 // Bits 10-31 inverted. Same as assembler's %hix.
88 def HIX22 : SDNodeXForm<imm, [{
89 uint64_t Val = (~N->getZExtValue() >> 10) & ((1u << 22) - 1);
90 return CurDAG->getTargetConstant(Val, SDLoc(N), MVT::i32);
92 // Bits 0-9 with ones in bits 10-31. Same as assembler's %lox.
93 def LOX10 : SDNodeXForm<imm, [{
94 return CurDAG->getSignedTargetConstant(~(~N->getZExtValue() & 0x3ff),
97 def : Pat<(i64 nimm33:$val), (XORri (SETHIi (HIX22 $val)), (LOX10 $val))>,
100 // More possible patterns:
107 // (xor (sllx sethi), simm13)
108 // (sllx (xor sethi, simm13))
112 // (or sethi, (sllx sethi))
113 // (xnor sethi, (sllx sethi))
117 // (or (sllx sethi), (or sethi, simm13))
118 // (xnor (sllx sethi), (or sethi, simm13))
119 // (or (sllx sethi), (sllx sethi))
120 // (xnor (sllx sethi), (sllx sethi))
122 // Worst case is 6 instrs:
124 // (or (sllx (or sethi, simmm13)), (or sethi, simm13))
126 // Bits 42-63, same as assembler's %hh.
127 def HH22 : SDNodeXForm<imm, [{
128 uint64_t Val = (N->getZExtValue() >> 42) & ((1u << 22) - 1);
129 return CurDAG->getTargetConstant(Val, SDLoc(N), MVT::i32);
131 // Bits 32-41, same as assembler's %hm.
132 def HM10 : SDNodeXForm<imm, [{
133 uint64_t Val = (N->getZExtValue() >> 32) & ((1u << 10) - 1);
134 return CurDAG->getTargetConstant(Val, SDLoc(N), MVT::i32);
136 def : Pat<(i64 imm:$val),
137 (ORrr (SLLXri (ORri (SETHIi (HH22 $val)), (HM10 $val)), (i32 32)),
138 (ORri (SETHIi (HI22 $val)), (LO10 $val)))>,
142 //===----------------------------------------------------------------------===//
143 // 64-bit Integer Arithmetic and Logic.
144 //===----------------------------------------------------------------------===//
146 let Predicates = [Is64Bit] in {
148 def : Pat<(and i64:$lhs, i64:$rhs), (ANDrr $lhs, $rhs)>;
149 def : Pat<(or i64:$lhs, i64:$rhs), (ORrr $lhs, $rhs)>;
150 def : Pat<(xor i64:$lhs, i64:$rhs), (XORrr $lhs, $rhs)>;
152 def : Pat<(and i64:$lhs, (i64 simm13:$rhs)), (ANDri $lhs, imm:$rhs)>;
153 def : Pat<(or i64:$lhs, (i64 simm13:$rhs)), (ORri $lhs, imm:$rhs)>;
154 def : Pat<(xor i64:$lhs, (i64 simm13:$rhs)), (XORri $lhs, imm:$rhs)>;
156 def : Pat<(and i64:$lhs, (not i64:$rhs)), (ANDNrr $lhs, $rhs)>;
157 def : Pat<(or i64:$lhs, (not i64:$rhs)), (ORNrr $lhs, $rhs)>;
158 def : Pat<(not (xor i64:$lhs, i64:$rhs)), (XNORrr $lhs, $rhs)>;
160 def : Pat<(add i64:$lhs, i64:$rhs), (ADDrr $lhs, $rhs)>;
161 def : Pat<(sub i64:$lhs, i64:$rhs), (SUBrr $lhs, $rhs)>;
163 def : Pat<(add i64:$lhs, (i64 simm13:$rhs)), (ADDri $lhs, imm:$rhs)>;
164 def : Pat<(sub i64:$lhs, (i64 simm13:$rhs)), (SUBri $lhs, imm:$rhs)>;
166 def : Pat<(tlsadd i64:$rs1, i64:$rs2, tglobaltlsaddr:$sym),
167 (TLS_ADDrr $rs1, $rs2, $sym)>;
169 def : Pat<(SPcmpicc i64:$lhs, i64:$rhs), (SUBCCrr $lhs, $rhs)>;
170 def : Pat<(SPcmpicc i64:$lhs, (i64 simm13:$rhs)), (SUBCCri $lhs, imm:$rhs)>;
171 def : Pat<(i64 (ctpop i64:$src)), (POPCrr $src)>;
173 } // Predicates = [Is64Bit]
176 //===----------------------------------------------------------------------===//
177 // 64-bit Integer Multiply and Divide.
178 //===----------------------------------------------------------------------===//
180 let Predicates = [Is64Bit] in {
182 def MULXrr : F3_1<2, 0b001001,
183 (outs I64Regs:$rd), (ins I64Regs:$rs1, I64Regs:$rs2),
184 "mulx $rs1, $rs2, $rd",
185 [(set i64:$rd, (mul i64:$rs1, i64:$rs2))]>;
186 def MULXri : F3_2<2, 0b001001,
187 (outs IntRegs:$rd), (ins IntRegs:$rs1, i64imm:$simm13),
188 "mulx $rs1, $simm13, $rd",
189 [(set i64:$rd, (mul i64:$rs1, (i64 simm13:$simm13)))]>;
191 // Division can trap.
192 let hasSideEffects = 1 in {
193 def SDIVXrr : F3_1<2, 0b101101,
194 (outs I64Regs:$rd), (ins I64Regs:$rs1, I64Regs:$rs2),
195 "sdivx $rs1, $rs2, $rd",
196 [(set i64:$rd, (sdiv i64:$rs1, i64:$rs2))]>;
197 def SDIVXri : F3_2<2, 0b101101,
198 (outs IntRegs:$rd), (ins IntRegs:$rs1, i64imm:$simm13),
199 "sdivx $rs1, $simm13, $rd",
200 [(set i64:$rd, (sdiv i64:$rs1, (i64 simm13:$simm13)))]>;
202 def UDIVXrr : F3_1<2, 0b001101,
203 (outs I64Regs:$rd), (ins I64Regs:$rs1, I64Regs:$rs2),
204 "udivx $rs1, $rs2, $rd",
205 [(set i64:$rd, (udiv i64:$rs1, i64:$rs2))]>;
206 def UDIVXri : F3_2<2, 0b001101,
207 (outs IntRegs:$rd), (ins IntRegs:$rs1, i64imm:$simm13),
208 "udivx $rs1, $simm13, $rd",
209 [(set i64:$rd, (udiv i64:$rs1, (i64 simm13:$simm13)))]>;
210 } // hasSideEffects = 1
212 } // Predicates = [Is64Bit]
215 //===----------------------------------------------------------------------===//
216 // 64-bit Loads and Stores.
217 //===----------------------------------------------------------------------===//
219 // All the 32-bit loads and stores are available. The extending loads are sign
220 // or zero-extending to 64 bits. The LDrr and LDri instructions load 32 bits
221 // zero-extended to i64. Their mnemonic is lduw in SPARC v9 (Load Unsigned
224 // SPARC v9 adds 64-bit loads as well as a sign-extending ldsw i32 loads.
226 let Predicates = [Is64Bit] in {
229 defm LDX : LoadA<"ldx", 0b001011, 0b011011, load, I64Regs, i64>;
231 let mayLoad = 1, isAsmParserOnly = 1 in {
232 def TLS_LDXrr : F3_1<3, 0b001011,
234 (ins (MEMrr $rs1, $rs2):$addr, TailRelocSymTLSLoad:$sym),
235 "ldx [$addr], $rd, $sym",
237 (tlsld ADDRrr:$addr, tglobaltlsaddr:$sym))]>;
238 def GDOP_LDXrr : F3_1<3, 0b001011,
240 (ins (MEMrr $rs1, $rs2):$addr, TailRelocSymGOTLoad:$sym),
241 "ldx [$addr], $rd, $sym",
243 (load_gdop ADDRrr:$addr, tglobaladdr:$sym))]>;
246 // Extending loads to i64.
247 def : Pat<(i64 (zextloadi1 ADDRrr:$addr)), (LDUBrr ADDRrr:$addr)>;
248 def : Pat<(i64 (zextloadi1 ADDRri:$addr)), (LDUBri ADDRri:$addr)>;
249 def : Pat<(i64 (extloadi1 ADDRrr:$addr)), (LDUBrr ADDRrr:$addr)>;
250 def : Pat<(i64 (extloadi1 ADDRri:$addr)), (LDUBri ADDRri:$addr)>;
252 def : Pat<(i64 (zextloadi8 ADDRrr:$addr)), (LDUBrr ADDRrr:$addr)>;
253 def : Pat<(i64 (zextloadi8 ADDRri:$addr)), (LDUBri ADDRri:$addr)>;
254 def : Pat<(i64 (extloadi8 ADDRrr:$addr)), (LDUBrr ADDRrr:$addr)>;
255 def : Pat<(i64 (extloadi8 ADDRri:$addr)), (LDUBri ADDRri:$addr)>;
256 def : Pat<(i64 (sextloadi8 ADDRrr:$addr)), (LDSBrr ADDRrr:$addr)>;
257 def : Pat<(i64 (sextloadi8 ADDRri:$addr)), (LDSBri ADDRri:$addr)>;
259 def : Pat<(i64 (zextloadi16 ADDRrr:$addr)), (LDUHrr ADDRrr:$addr)>;
260 def : Pat<(i64 (zextloadi16 ADDRri:$addr)), (LDUHri ADDRri:$addr)>;
261 def : Pat<(i64 (extloadi16 ADDRrr:$addr)), (LDUHrr ADDRrr:$addr)>;
262 def : Pat<(i64 (extloadi16 ADDRri:$addr)), (LDUHri ADDRri:$addr)>;
263 def : Pat<(i64 (sextloadi16 ADDRrr:$addr)), (LDSHrr ADDRrr:$addr)>;
264 def : Pat<(i64 (sextloadi16 ADDRri:$addr)), (LDSHri ADDRri:$addr)>;
266 def : Pat<(i64 (zextloadi32 ADDRrr:$addr)), (LDrr ADDRrr:$addr)>;
267 def : Pat<(i64 (zextloadi32 ADDRri:$addr)), (LDri ADDRri:$addr)>;
268 def : Pat<(i64 (extloadi32 ADDRrr:$addr)), (LDrr ADDRrr:$addr)>;
269 def : Pat<(i64 (extloadi32 ADDRri:$addr)), (LDri ADDRri:$addr)>;
271 // Sign-extending load of i32 into i64 is a new SPARC v9 instruction.
272 defm LDSW : LoadA<"ldsw", 0b001000, 0b011000, sextloadi32, I64Regs, i64>;
275 defm STX : StoreA<"stx", 0b001110, 0b011110, store, I64Regs, i64>;
277 // Truncating stores from i64 are identical to the i32 stores.
278 def : Pat<(truncstorei8 i64:$src, ADDRrr:$addr), (STBrr ADDRrr:$addr, $src)>;
279 def : Pat<(truncstorei8 i64:$src, ADDRri:$addr), (STBri ADDRri:$addr, $src)>;
280 def : Pat<(truncstorei16 i64:$src, ADDRrr:$addr), (STHrr ADDRrr:$addr, $src)>;
281 def : Pat<(truncstorei16 i64:$src, ADDRri:$addr), (STHri ADDRri:$addr, $src)>;
282 def : Pat<(truncstorei32 i64:$src, ADDRrr:$addr), (STrr ADDRrr:$addr, $src)>;
283 def : Pat<(truncstorei32 i64:$src, ADDRri:$addr), (STri ADDRri:$addr, $src)>;
285 // store 0, addr -> store %g0, addr
286 def : Pat<(store (i64 0), ADDRrr:$dst), (STXrr ADDRrr:$dst, (i64 G0))>;
287 def : Pat<(store (i64 0), ADDRri:$dst), (STXri ADDRri:$dst, (i64 G0))>;
289 } // Predicates = [Is64Bit]
292 //===----------------------------------------------------------------------===//
293 // 64-bit Conditionals.
294 //===----------------------------------------------------------------------===//
297 // Flag-setting instructions like subcc and addcc set both icc and xcc flags.
298 // The icc flags correspond to the 32-bit result, and the xcc are for the
299 // full 64-bit result.
301 // We reuse CMPICC SDNodes for compares, but use new BPXCC branch nodes for
302 // 64-bit compares. See LowerBR_CC.
304 let Predicates = [Is64Bit] in {
306 let Uses = [ICC], cc = 0b10 in
307 defm BPX : IPredBranch<"%xcc", [(SPbpxcc bb:$imm19, imm:$cond)]>;
309 // Conditional moves on %xcc.
310 let Uses = [ICC], Constraints = "$f = $rd" in {
311 let intcc = 1, cc = 0b10 in {
312 def MOVXCCrr : F4_1<0b101100, (outs IntRegs:$rd),
313 (ins IntRegs:$rs2, IntRegs:$f, CCOp:$cond),
314 "mov$cond %xcc, $rs2, $rd",
316 (SPselectxcc i32:$rs2, i32:$f, imm:$cond))]>;
317 def MOVXCCri : F4_2<0b101100, (outs IntRegs:$rd),
318 (ins i32imm:$simm11, IntRegs:$f, CCOp:$cond),
319 "mov$cond %xcc, $simm11, $rd",
321 (SPselectxcc simm11:$simm11, i32:$f, imm:$cond))]>;
324 let intcc = 1, opf_cc = 0b10 in {
325 def FMOVS_XCC : F4_3<0b110101, 0b000001, (outs FPRegs:$rd),
326 (ins FPRegs:$rs2, FPRegs:$f, CCOp:$cond),
327 "fmovs$cond %xcc, $rs2, $rd",
329 (SPselectxcc f32:$rs2, f32:$f, imm:$cond))]>;
330 def FMOVD_XCC : F4_3<0b110101, 0b000010, (outs DFPRegs:$rd),
331 (ins DFPRegs:$rs2, DFPRegs:$f, CCOp:$cond),
332 "fmovd$cond %xcc, $rs2, $rd",
334 (SPselectxcc f64:$rs2, f64:$f, imm:$cond))]>;
335 let Predicates = [Is64Bit, HasHardQuad] in
336 def FMOVQ_XCC : F4_3<0b110101, 0b000011, (outs QFPRegs:$rd),
337 (ins QFPRegs:$rs2, QFPRegs:$f, CCOp:$cond),
338 "fmovq$cond %xcc, $rs2, $rd",
340 (SPselectxcc f128:$rs2, f128:$f, imm:$cond))]>;
342 } // Uses, Constraints
344 // Branch On integer register with Prediction (BPr).
345 let isBranch = 1, isTerminator = 1, hasDelaySlot = 1 in
346 multiclass BranchOnReg<list<dag> CCPattern> {
347 def R : F2_4<0, 1, (outs), (ins bprtarget16:$imm16, RegCCOp:$rcond, I64Regs:$rs1),
348 "br$rcond $rs1, $imm16", CCPattern>;
349 def RA : F2_4<1, 1, (outs), (ins bprtarget16:$imm16, RegCCOp:$rcond, I64Regs:$rs1),
350 "br$rcond,a $rs1, $imm16", []>;
351 def RNT : F2_4<0, 0, (outs), (ins bprtarget16:$imm16, RegCCOp:$rcond, I64Regs:$rs1),
352 "br$rcond,pn $rs1, $imm16", []>;
353 def RANT : F2_4<1, 0, (outs), (ins bprtarget16:$imm16, RegCCOp:$rcond, I64Regs:$rs1),
354 "br$rcond,a,pn $rs1, $imm16", []>;
357 multiclass bpr_alias<string OpcStr, Instruction NAPT, Instruction APT> {
358 def : InstAlias<!strconcat(OpcStr, ",pt $rs1, $imm16"),
359 (NAPT I64Regs:$rs1, bprtarget16:$imm16), 0>;
360 def : InstAlias<!strconcat(OpcStr, ",a,pt $rs1, $imm16"),
361 (APT I64Regs:$rs1, bprtarget16:$imm16), 0>;
364 let Predicates = [Is64Bit] in
365 defm BP : BranchOnReg<[(SPbrreg bb:$imm16, imm:$rcond, i64:$rs1)]>;
367 // Move integer register on register condition (MOVr).
368 let Predicates = [Is64Bit], Constraints = "$f = $rd" in {
369 def MOVRrr : F4_4r<0b101111, 0b00000, (outs IntRegs:$rd),
370 (ins I64Regs:$rs1, IntRegs:$rs2, IntRegs:$f, RegCCOp:$rcond),
371 "movr$rcond $rs1, $rs2, $rd",
372 [(set i32:$rd, (SPselectreg i32:$rs2, i32:$f, imm:$rcond, i64:$rs1))]>;
374 def MOVRri : F4_4i<0b101111, (outs IntRegs:$rd),
375 (ins I64Regs:$rs1, i32imm:$simm10, IntRegs:$f, RegCCOp:$rcond),
376 "movr$rcond $rs1, $simm10, $rd",
377 [(set i32:$rd, (SPselectreg simm10:$simm10, i32:$f, imm:$rcond, i64:$rs1))]>;
380 // Move FP register on integer register condition (FMOVr).
381 let Predicates = [Is64Bit], Constraints = "$f = $rd" in {
382 def FMOVRS : F4_4r<0b110101, 0b00101,
383 (outs FPRegs:$rd), (ins I64Regs:$rs1, FPRegs:$rs2, FPRegs:$f, RegCCOp:$rcond),
384 "fmovrs$rcond $rs1, $rs2, $rd",
385 [(set f32:$rd, (SPselectreg f32:$rs2, f32:$f, imm:$rcond, i64:$rs1))]>;
386 def FMOVRD : F4_4r<0b110101, 0b00110,
387 (outs DFPRegs:$rd), (ins I64Regs:$rs1, DFPRegs:$rs2, DFPRegs:$f, RegCCOp:$rcond),
388 "fmovrd$rcond $rs1, $rs2, $rd",
389 [(set f64:$rd, (SPselectreg f64:$rs2, f64:$f, imm:$rcond, i64:$rs1))]>;
390 let Predicates = [HasHardQuad] in
391 def FMOVRQ : F4_4r<0b110101, 0b00111,
392 (outs QFPRegs:$rd), (ins I64Regs:$rs1, QFPRegs:$rs2, QFPRegs:$f, RegCCOp:$rcond),
393 "fmovrq$rcond $rs1, $rs2, $rd",
394 [(set f128:$rd, (SPselectreg f128:$rs2, f128:$f, imm:$rcond, i64:$rs1))]>;
397 //===----------------------------------------------------------------------===//
398 // 64-bit Floating Point Conversions.
399 //===----------------------------------------------------------------------===//
401 let Predicates = [Is64Bit] in {
403 def FXTOS : F3_3u<2, 0b110100, 0b010000100,
404 (outs FPRegs:$rd), (ins DFPRegs:$rs2),
406 [(set FPRegs:$rd, (SPxtof DFPRegs:$rs2))]>;
407 def FXTOD : F3_3u<2, 0b110100, 0b010001000,
408 (outs DFPRegs:$rd), (ins DFPRegs:$rs2),
410 [(set DFPRegs:$rd, (SPxtof DFPRegs:$rs2))]>;
411 let Predicates = [Is64Bit, HasHardQuad] in
412 def FXTOQ : F3_3u<2, 0b110100, 0b010001100,
413 (outs QFPRegs:$rd), (ins DFPRegs:$rs2),
415 [(set QFPRegs:$rd, (SPxtof DFPRegs:$rs2))]>;
417 def FSTOX : F3_3u<2, 0b110100, 0b010000001,
418 (outs DFPRegs:$rd), (ins FPRegs:$rs2),
420 [(set DFPRegs:$rd, (SPftox FPRegs:$rs2))]>;
421 def FDTOX : F3_3u<2, 0b110100, 0b010000010,
422 (outs DFPRegs:$rd), (ins DFPRegs:$rs2),
424 [(set DFPRegs:$rd, (SPftox DFPRegs:$rs2))]>;
425 let Predicates = [Is64Bit, HasHardQuad] in
426 def FQTOX : F3_3u<2, 0b110100, 0b010000011,
427 (outs DFPRegs:$rd), (ins QFPRegs:$rs2),
429 [(set DFPRegs:$rd, (SPftox QFPRegs:$rs2))]>;
431 } // Predicates = [Is64Bit]
433 def : Pat<(SPselectxcc i64:$t, i64:$f, imm:$cond),
434 (MOVXCCrr $t, $f, imm:$cond)>;
435 def : Pat<(SPselectxcc (i64 simm11:$t), i64:$f, imm:$cond),
436 (MOVXCCri (as_i32imm $t), $f, imm:$cond)>;
438 def : Pat<(SPselecticc i64:$t, i64:$f, imm:$cond),
439 (MOVICCrr $t, $f, imm:$cond)>;
440 def : Pat<(SPselecticc (i64 simm11:$t), i64:$f, imm:$cond),
441 (MOVICCri (as_i32imm $t), $f, imm:$cond)>;
443 def : Pat<(SPselectfcc i64:$t, i64:$f, imm:$cond),
444 (MOVFCCrr $t, $f, imm:$cond)>;
445 def : Pat<(SPselectfcc (i64 simm11:$t), i64:$f, imm:$cond),
446 (MOVFCCri (as_i32imm $t), $f, imm:$cond)>;
448 def : Pat<(SPselectreg i64:$t, i64:$f, imm:$rcond, i64:$rs1),
449 (MOVRrr $rs1, $t, $f, imm:$rcond)>;
450 def : Pat<(SPselectreg (i64 simm10:$t), i64:$f, imm:$rcond, i64:$rs1),
451 (MOVRri $rs1, (as_i32imm $t), $f, imm:$rcond)>;
453 } // Predicates = [Is64Bit]
456 let Predicates = [Is64Bit, HasV9], Constraints = "$swap = $rd" in {
457 def CASXArr: F3_1_asi<3, 0b111110,
458 (outs I64Regs:$rd), (ins I64Regs:$rs1, I64Regs:$rs2,
459 I64Regs:$swap, ASITag:$asi),
460 "casxa [$rs1] $asi, $rs2, $rd",
464 def CASXAri: F3_1_cas_asi<3, 0b111110,
465 (outs I64Regs:$rd), (ins I64Regs:$rs1, I64Regs:$rs2,
467 "casxa [$rs1] %asi, $rs2, $rd",
469 } // Predicates = [Is64Bit], Constraints = ...
471 let Predicates = [Is64Bit] in {
473 // atomic_load_64 addr -> load addr
474 def : Pat<(i64 (atomic_load_64 ADDRrr:$src)), (LDXrr ADDRrr:$src)>;
475 def : Pat<(i64 (atomic_load_64 ADDRri:$src)), (LDXri ADDRri:$src)>;
477 // atomic_store_64 val, addr -> store val, addr
478 def : Pat<(atomic_store_64 i64:$val, ADDRrr:$dst), (STXrr ADDRrr:$dst, $val)>;
479 def : Pat<(atomic_store_64 i64:$val, ADDRri:$dst), (STXri ADDRri:$dst, $val)>;
481 def : Pat<(atomic_cmp_swap_i64 i64:$rs1, i64:$rs2, i64:$swap),
482 (CASXArr $rs1, $rs2, $swap, 0x80)>;
484 } // Predicates = [Is64Bit]
486 let Predicates = [Is64Bit], hasSideEffects = 1, Uses = [ICC], cc = 0b10 in
487 defm TXCC : TRAP<"%xcc">;
489 // Global addresses, constant pool entries
490 let Predicates = [Is64Bit] in {
492 def : Pat<(SPhi tglobaladdr:$in), (SETHIi tglobaladdr:$in)>;
493 def : Pat<(SPlo tglobaladdr:$in), (ORri (i64 G0), tglobaladdr:$in)>;
494 def : Pat<(SPhi tconstpool:$in), (SETHIi tconstpool:$in)>;
495 def : Pat<(SPlo tconstpool:$in), (ORri (i64 G0), tconstpool:$in)>;
497 // GlobalTLS addresses
498 def : Pat<(SPhi tglobaltlsaddr:$in), (SETHIi tglobaltlsaddr:$in)>;
499 def : Pat<(SPlo tglobaltlsaddr:$in), (ORri (i64 G0), tglobaltlsaddr:$in)>;
500 def : Pat<(add (SPhi tglobaltlsaddr:$in1), (SPlo tglobaltlsaddr:$in2)),
501 (ADDri (SETHIi tglobaltlsaddr:$in1), (tglobaltlsaddr:$in2))>;
502 def : Pat<(xor (SPhi tglobaltlsaddr:$in1), (SPlo tglobaltlsaddr:$in2)),
503 (XORri (SETHIi tglobaltlsaddr:$in1), (tglobaltlsaddr:$in2))>;
506 def : Pat<(SPhi tblockaddress:$in), (SETHIi tblockaddress:$in)>;
507 def : Pat<(SPlo tblockaddress:$in), (ORri (i64 G0), tblockaddress:$in)>;
509 // Add reg, lo. This is used when taking the addr of a global/constpool entry.
510 def : Pat<(add iPTR:$r, (SPlo tglobaladdr:$in)), (ADDri $r, tglobaladdr:$in)>;
511 def : Pat<(add iPTR:$r, (SPlo tconstpool:$in)), (ADDri $r, tconstpool:$in)>;
512 def : Pat<(add iPTR:$r, (SPlo tblockaddress:$in)),
513 (ADDri $r, tblockaddress:$in)>;