1//===-- AMDGPUInstructions.td - Common instruction defs ---*- tablegen -*-===//
2//
3//                     The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file contains instruction defs that are common to all hw codegen
11// targets.
12//
13//===----------------------------------------------------------------------===//
14
15class AMDGPUInst <dag outs, dag ins, string asm = "",
16  list<dag> pattern = []> : Instruction {
17  field bit isRegisterLoad = 0;
18  field bit isRegisterStore = 0;
19
20  let Namespace = "AMDGPU";
21  let OutOperandList = outs;
22  let InOperandList = ins;
23  let AsmString = asm;
24  let Pattern = pattern;
25  let Itinerary = NullALU;
26
27  // SoftFail is a field the disassembler can use to provide a way for
28  // instructions to not match without killing the whole decode process. It is
29  // mainly used for ARM, but Tablegen expects this field to exist or it fails
30  // to build the decode table.
31  field bits<64> SoftFail = 0;
32
33  let DecoderNamespace = Namespace;
34
35  let TSFlags{63} = isRegisterLoad;
36  let TSFlags{62} = isRegisterStore;
37}
38
39class AMDGPUShaderInst <dag outs, dag ins, string asm = "",
40  list<dag> pattern = []> : AMDGPUInst<outs, ins, asm, pattern> {
41
42  field bits<32> Inst = 0xffffffff;
43}
44
45def FP16Denormals : Predicate<"Subtarget.hasFP16Denormals()">;
46def FP32Denormals : Predicate<"Subtarget.hasFP32Denormals()">;
47def FP64Denormals : Predicate<"Subtarget.hasFP64Denormals()">;
48def UnsafeFPMath : Predicate<"TM.Options.UnsafeFPMath">;
49
50def InstFlag : OperandWithDefaultOps <i32, (ops (i32 0))>;
51def ADDRIndirect : ComplexPattern<iPTR, 2, "SelectADDRIndirect", [], []>;
52
53let OperandType = "OPERAND_IMMEDIATE" in {
54
55def u32imm : Operand<i32> {
56  let PrintMethod = "printU32ImmOperand";
57}
58
59def u16imm : Operand<i16> {
60  let PrintMethod = "printU16ImmOperand";
61}
62
63def u8imm : Operand<i8> {
64  let PrintMethod = "printU8ImmOperand";
65}
66
67} // End OperandType = "OPERAND_IMMEDIATE"
68
69//===--------------------------------------------------------------------===//
70// Custom Operands
71//===--------------------------------------------------------------------===//
72def brtarget   : Operand<OtherVT>;
73
74//===----------------------------------------------------------------------===//
75// PatLeafs for floating-point comparisons
76//===----------------------------------------------------------------------===//
77
78def COND_OEQ : PatLeaf <
79  (cond),
80  [{return N->get() == ISD::SETOEQ || N->get() == ISD::SETEQ;}]
81>;
82
83def COND_ONE : PatLeaf <
84  (cond),
85  [{return N->get() == ISD::SETONE || N->get() == ISD::SETNE;}]
86>;
87
88def COND_OGT : PatLeaf <
89  (cond),
90  [{return N->get() == ISD::SETOGT || N->get() == ISD::SETGT;}]
91>;
92
93def COND_OGE : PatLeaf <
94  (cond),
95  [{return N->get() == ISD::SETOGE || N->get() == ISD::SETGE;}]
96>;
97
98def COND_OLT : PatLeaf <
99  (cond),
100  [{return N->get() == ISD::SETOLT || N->get() == ISD::SETLT;}]
101>;
102
103def COND_OLE : PatLeaf <
104  (cond),
105  [{return N->get() == ISD::SETOLE || N->get() == ISD::SETLE;}]
106>;
107
108
109def COND_O : PatLeaf <(cond), [{return N->get() == ISD::SETO;}]>;
110def COND_UO : PatLeaf <(cond), [{return N->get() == ISD::SETUO;}]>;
111
112//===----------------------------------------------------------------------===//
113// PatLeafs for unsigned / unordered comparisons
114//===----------------------------------------------------------------------===//
115
116def COND_UEQ : PatLeaf <(cond), [{return N->get() == ISD::SETUEQ;}]>;
117def COND_UNE : PatLeaf <(cond), [{return N->get() == ISD::SETUNE;}]>;
118def COND_UGT : PatLeaf <(cond), [{return N->get() == ISD::SETUGT;}]>;
119def COND_UGE : PatLeaf <(cond), [{return N->get() == ISD::SETUGE;}]>;
120def COND_ULT : PatLeaf <(cond), [{return N->get() == ISD::SETULT;}]>;
121def COND_ULE : PatLeaf <(cond), [{return N->get() == ISD::SETULE;}]>;
122
123// XXX - For some reason R600 version is preferring to use unordered
124// for setne?
125def COND_UNE_NE : PatLeaf <
126  (cond),
127  [{return N->get() == ISD::SETUNE || N->get() == ISD::SETNE;}]
128>;
129
130//===----------------------------------------------------------------------===//
131// PatLeafs for signed comparisons
132//===----------------------------------------------------------------------===//
133
134def COND_SGT : PatLeaf <(cond), [{return N->get() == ISD::SETGT;}]>;
135def COND_SGE : PatLeaf <(cond), [{return N->get() == ISD::SETGE;}]>;
136def COND_SLT : PatLeaf <(cond), [{return N->get() == ISD::SETLT;}]>;
137def COND_SLE : PatLeaf <(cond), [{return N->get() == ISD::SETLE;}]>;
138
139//===----------------------------------------------------------------------===//
140// PatLeafs for integer equality
141//===----------------------------------------------------------------------===//
142
143def COND_EQ : PatLeaf <
144  (cond),
145  [{return N->get() == ISD::SETEQ || N->get() == ISD::SETUEQ;}]
146>;
147
148def COND_NE : PatLeaf <
149  (cond),
150  [{return N->get() == ISD::SETNE || N->get() == ISD::SETUNE;}]
151>;
152
153def COND_NULL : PatLeaf <
154  (cond),
155  [{(void)N; return false;}]
156>;
157
158
159//===----------------------------------------------------------------------===//
160// Misc. PatFrags
161//===----------------------------------------------------------------------===//
162
163class HasOneUseBinOp<SDPatternOperator op> : PatFrag<
164  (ops node:$src0, node:$src1),
165  (op $src0, $src1),
166  [{ return N->hasOneUse(); }]
167>;
168
169class HasOneUseTernaryOp<SDPatternOperator op> : PatFrag<
170  (ops node:$src0, node:$src1, node:$src2),
171  (op $src0, $src1, $src2),
172  [{ return N->hasOneUse(); }]
173>;
174
175//===----------------------------------------------------------------------===//
176// Load/Store Pattern Fragments
177//===----------------------------------------------------------------------===//
178
179class PrivateMemOp <dag ops, dag frag> : PatFrag <ops, frag, [{
180  return cast<MemSDNode>(N)->getAddressSpace() == AMDGPUAS::PRIVATE_ADDRESS;
181}]>;
182
183class PrivateLoad <SDPatternOperator op> : PrivateMemOp <
184  (ops node:$ptr), (op node:$ptr)
185>;
186
187class PrivateStore <SDPatternOperator op> : PrivateMemOp <
188  (ops node:$value, node:$ptr), (op node:$value, node:$ptr)
189>;
190
191def load_private : PrivateLoad <load>;
192
193def truncstorei8_private : PrivateStore <truncstorei8>;
194def truncstorei16_private : PrivateStore <truncstorei16>;
195def store_private : PrivateStore <store>;
196
197class GlobalMemOp <dag ops, dag frag> : PatFrag <ops, frag, [{
198  return cast<MemSDNode>(N)->getAddressSpace() == AMDGPUAS::GLOBAL_ADDRESS;
199}]>;
200
201// Global address space loads
202class GlobalLoad <SDPatternOperator op> : GlobalMemOp <
203  (ops node:$ptr), (op node:$ptr)
204>;
205
206def global_load : GlobalLoad <load>;
207
208// Global address space stores
209class GlobalStore <SDPatternOperator op> : GlobalMemOp <
210  (ops node:$value, node:$ptr), (op node:$value, node:$ptr)
211>;
212
213def global_store : GlobalStore <store>;
214def global_store_atomic : GlobalStore<atomic_store>;
215
216
217class ConstantMemOp <dag ops, dag frag> : PatFrag <ops, frag, [{
218  return cast<MemSDNode>(N)->getAddressSpace() == AMDGPUAS::CONSTANT_ADDRESS;
219}]>;
220
221// Constant address space loads
222class ConstantLoad <SDPatternOperator op> : ConstantMemOp <
223  (ops node:$ptr), (op node:$ptr)
224>;
225
226def constant_load : ConstantLoad<load>;
227
228class LocalMemOp <dag ops, dag frag> : PatFrag <ops, frag, [{
229  return cast<MemSDNode>(N)->getAddressSpace() == AMDGPUAS::LOCAL_ADDRESS;
230}]>;
231
232// Local address space loads
233class LocalLoad <SDPatternOperator op> : LocalMemOp <
234  (ops node:$ptr), (op node:$ptr)
235>;
236
237class LocalStore <SDPatternOperator op> : LocalMemOp <
238  (ops node:$value, node:$ptr), (op node:$value, node:$ptr)
239>;
240
241class FlatMemOp <dag ops, dag frag> : PatFrag <ops, frag, [{
242  return cast<MemSDNode>(N)->getAddressSPace() == AMDGPUAS::FLAT_ADDRESS;
243}]>;
244
245class FlatLoad <SDPatternOperator op> : FlatMemOp <
246  (ops node:$ptr), (op node:$ptr)
247>;
248
249class AZExtLoadBase <SDPatternOperator ld_node>: PatFrag<(ops node:$ptr),
250                                              (ld_node node:$ptr), [{
251  LoadSDNode *L = cast<LoadSDNode>(N);
252  return L->getExtensionType() == ISD::ZEXTLOAD ||
253         L->getExtensionType() == ISD::EXTLOAD;
254}]>;
255
256def az_extload : AZExtLoadBase <unindexedload>;
257
258def az_extloadi8 : PatFrag<(ops node:$ptr), (az_extload node:$ptr), [{
259  return cast<LoadSDNode>(N)->getMemoryVT() == MVT::i8;
260}]>;
261
262def az_extloadi8_global : GlobalLoad <az_extloadi8>;
263def sextloadi8_global : GlobalLoad <sextloadi8>;
264
265def az_extloadi8_constant : ConstantLoad <az_extloadi8>;
266def sextloadi8_constant : ConstantLoad <sextloadi8>;
267
268def az_extloadi8_local : LocalLoad <az_extloadi8>;
269def sextloadi8_local : LocalLoad <sextloadi8>;
270
271def extloadi8_private : PrivateLoad <az_extloadi8>;
272def sextloadi8_private : PrivateLoad <sextloadi8>;
273
274def az_extloadi16 : PatFrag<(ops node:$ptr), (az_extload node:$ptr), [{
275  return cast<LoadSDNode>(N)->getMemoryVT() == MVT::i16;
276}]>;
277
278def az_extloadi16_global : GlobalLoad <az_extloadi16>;
279def sextloadi16_global : GlobalLoad <sextloadi16>;
280
281def az_extloadi16_constant : ConstantLoad <az_extloadi16>;
282def sextloadi16_constant : ConstantLoad <sextloadi16>;
283
284def az_extloadi16_local : LocalLoad <az_extloadi16>;
285def sextloadi16_local : LocalLoad <sextloadi16>;
286
287def extloadi16_private : PrivateLoad <az_extloadi16>;
288def sextloadi16_private : PrivateLoad <sextloadi16>;
289
290def az_extloadi32 : PatFrag<(ops node:$ptr), (az_extload node:$ptr), [{
291  return cast<LoadSDNode>(N)->getMemoryVT() == MVT::i32;
292}]>;
293
294def az_extloadi32_global : GlobalLoad <az_extloadi32>;
295
296def az_extloadi32_flat : FlatLoad <az_extloadi32>;
297
298def az_extloadi32_constant : ConstantLoad <az_extloadi32>;
299
300def truncstorei8_global : GlobalStore <truncstorei8>;
301def truncstorei16_global : GlobalStore <truncstorei16>;
302
303def local_store : LocalStore <store>;
304def truncstorei8_local : LocalStore <truncstorei8>;
305def truncstorei16_local : LocalStore <truncstorei16>;
306
307def local_load : LocalLoad <load>;
308
309class Aligned8Bytes <dag ops, dag frag> : PatFrag <ops, frag, [{
310    return cast<MemSDNode>(N)->getAlignment() % 8 == 0;
311}]>;
312
313def local_load_aligned8bytes : Aligned8Bytes <
314  (ops node:$ptr), (local_load node:$ptr)
315>;
316
317def local_store_aligned8bytes : Aligned8Bytes <
318  (ops node:$val, node:$ptr), (local_store node:$val, node:$ptr)
319>;
320
321class local_binary_atomic_op<SDNode atomic_op> :
322  PatFrag<(ops node:$ptr, node:$value),
323    (atomic_op node:$ptr, node:$value), [{
324  return cast<MemSDNode>(N)->getAddressSpace() == AMDGPUAS::LOCAL_ADDRESS;
325}]>;
326
327
328def atomic_swap_local : local_binary_atomic_op<atomic_swap>;
329def atomic_load_add_local : local_binary_atomic_op<atomic_load_add>;
330def atomic_load_sub_local : local_binary_atomic_op<atomic_load_sub>;
331def atomic_load_and_local : local_binary_atomic_op<atomic_load_and>;
332def atomic_load_or_local : local_binary_atomic_op<atomic_load_or>;
333def atomic_load_xor_local : local_binary_atomic_op<atomic_load_xor>;
334def atomic_load_nand_local : local_binary_atomic_op<atomic_load_nand>;
335def atomic_load_min_local : local_binary_atomic_op<atomic_load_min>;
336def atomic_load_max_local : local_binary_atomic_op<atomic_load_max>;
337def atomic_load_umin_local : local_binary_atomic_op<atomic_load_umin>;
338def atomic_load_umax_local : local_binary_atomic_op<atomic_load_umax>;
339
340def mskor_global : PatFrag<(ops node:$val, node:$ptr),
341                            (AMDGPUstore_mskor node:$val, node:$ptr), [{
342  return cast<MemSDNode>(N)->getAddressSpace() == AMDGPUAS::GLOBAL_ADDRESS;
343}]>;
344
345multiclass AtomicCmpSwapLocal <SDNode cmp_swap_node> {
346
347  def _32_local : PatFrag <
348    (ops node:$ptr, node:$cmp, node:$swap),
349    (cmp_swap_node node:$ptr, node:$cmp, node:$swap), [{
350      AtomicSDNode *AN = cast<AtomicSDNode>(N);
351      return AN->getMemoryVT() == MVT::i32 &&
352             AN->getAddressSpace() == AMDGPUAS::LOCAL_ADDRESS;
353  }]>;
354
355  def _64_local : PatFrag<
356    (ops node:$ptr, node:$cmp, node:$swap),
357    (cmp_swap_node node:$ptr, node:$cmp, node:$swap), [{
358      AtomicSDNode *AN = cast<AtomicSDNode>(N);
359      return AN->getMemoryVT() == MVT::i64 &&
360             AN->getAddressSpace() == AMDGPUAS::LOCAL_ADDRESS;
361  }]>;
362}
363
364defm atomic_cmp_swap : AtomicCmpSwapLocal <atomic_cmp_swap>;
365
366class global_binary_atomic_op<SDNode atomic_op> : PatFrag<
367  (ops node:$ptr, node:$value),
368  (atomic_op node:$ptr, node:$value),
369  [{return cast<MemSDNode>(N)->getAddressSpace() == AMDGPUAS::GLOBAL_ADDRESS;}]
370>;
371
372def atomic_swap_global : global_binary_atomic_op<atomic_swap>;
373def atomic_add_global : global_binary_atomic_op<atomic_load_add>;
374def atomic_and_global : global_binary_atomic_op<atomic_load_and>;
375def atomic_max_global : global_binary_atomic_op<atomic_load_max>;
376def atomic_min_global : global_binary_atomic_op<atomic_load_min>;
377def atomic_or_global : global_binary_atomic_op<atomic_load_or>;
378def atomic_sub_global : global_binary_atomic_op<atomic_load_sub>;
379def atomic_umax_global : global_binary_atomic_op<atomic_load_umax>;
380def atomic_umin_global : global_binary_atomic_op<atomic_load_umin>;
381def atomic_xor_global : global_binary_atomic_op<atomic_load_xor>;
382
383def atomic_cmp_swap_global : global_binary_atomic_op<AMDGPUatomic_cmp_swap>;
384
385//===----------------------------------------------------------------------===//
386// Misc Pattern Fragments
387//===----------------------------------------------------------------------===//
388
389class Constants {
390int TWO_PI = 0x40c90fdb;
391int PI = 0x40490fdb;
392int TWO_PI_INV = 0x3e22f983;
393int FP_UINT_MAX_PLUS_1 = 0x4f800000;    // 1 << 32 in floating point encoding
394int FP32_ONE = 0x3f800000;
395int FP32_NEG_ONE = 0xbf800000;
396int FP64_ONE = 0x3ff0000000000000;
397int FP64_NEG_ONE = 0xbff0000000000000;
398}
399def CONST : Constants;
400
401def FP_ZERO : PatLeaf <
402  (fpimm),
403  [{return N->getValueAPF().isZero();}]
404>;
405
406def FP_ONE : PatLeaf <
407  (fpimm),
408  [{return N->isExactlyValue(1.0);}]
409>;
410
411def FP_HALF : PatLeaf <
412  (fpimm),
413  [{return N->isExactlyValue(0.5);}]
414>;
415
416let isCodeGenOnly = 1, isPseudo = 1 in {
417
418let usesCustomInserter = 1  in {
419
420class CLAMP <RegisterClass rc> : AMDGPUShaderInst <
421  (outs rc:$dst),
422  (ins rc:$src0),
423  "CLAMP $dst, $src0",
424  [(set f32:$dst, (AMDGPUclamp f32:$src0, (f32 FP_ZERO), (f32 FP_ONE)))]
425>;
426
427class FABS <RegisterClass rc> : AMDGPUShaderInst <
428  (outs rc:$dst),
429  (ins rc:$src0),
430  "FABS $dst, $src0",
431  [(set f32:$dst, (fabs f32:$src0))]
432>;
433
434class FNEG <RegisterClass rc> : AMDGPUShaderInst <
435  (outs rc:$dst),
436  (ins rc:$src0),
437  "FNEG $dst, $src0",
438  [(set f32:$dst, (fneg f32:$src0))]
439>;
440
441} // usesCustomInserter = 1
442
443multiclass RegisterLoadStore <RegisterClass dstClass, Operand addrClass,
444                    ComplexPattern addrPat> {
445let UseNamedOperandTable = 1 in {
446
447  def RegisterLoad : AMDGPUShaderInst <
448    (outs dstClass:$dst),
449    (ins addrClass:$addr, i32imm:$chan),
450    "RegisterLoad $dst, $addr",
451    [(set i32:$dst, (AMDGPUregister_load addrPat:$addr, (i32 timm:$chan)))]
452  > {
453    let isRegisterLoad = 1;
454  }
455
456  def RegisterStore : AMDGPUShaderInst <
457    (outs),
458    (ins dstClass:$val, addrClass:$addr, i32imm:$chan),
459    "RegisterStore $val, $addr",
460    [(AMDGPUregister_store i32:$val, addrPat:$addr, (i32 timm:$chan))]
461  > {
462    let isRegisterStore = 1;
463  }
464}
465}
466
467} // End isCodeGenOnly = 1, isPseudo = 1
468
469/* Generic helper patterns for intrinsics */
470/* -------------------------------------- */
471
472class POW_Common <AMDGPUInst log_ieee, AMDGPUInst exp_ieee, AMDGPUInst mul>
473  : Pat <
474  (fpow f32:$src0, f32:$src1),
475  (exp_ieee (mul f32:$src1, (log_ieee f32:$src0)))
476>;
477
478/* Other helper patterns */
479/* --------------------- */
480
481/* Extract element pattern */
482class Extract_Element <ValueType sub_type, ValueType vec_type, int sub_idx,
483                       SubRegIndex sub_reg>
484  : Pat<
485  (sub_type (extractelt vec_type:$src, sub_idx)),
486  (EXTRACT_SUBREG $src, sub_reg)
487>;
488
489/* Insert element pattern */
490class Insert_Element <ValueType elem_type, ValueType vec_type,
491                      int sub_idx, SubRegIndex sub_reg>
492  : Pat <
493  (insertelt vec_type:$vec, elem_type:$elem, sub_idx),
494  (INSERT_SUBREG $vec, $elem, sub_reg)
495>;
496
497// XXX: Convert to new syntax and use COPY_TO_REG, once the DFAPacketizer
498// can handle COPY instructions.
499// bitconvert pattern
500class BitConvert <ValueType dt, ValueType st, RegisterClass rc> : Pat <
501  (dt (bitconvert (st rc:$src0))),
502  (dt rc:$src0)
503>;
504
505// XXX: Convert to new syntax and use COPY_TO_REG, once the DFAPacketizer
506// can handle COPY instructions.
507class DwordAddrPat<ValueType vt, RegisterClass rc> : Pat <
508  (vt (AMDGPUdwordaddr (vt rc:$addr))),
509  (vt rc:$addr)
510>;
511
512// BFI_INT patterns
513
514multiclass BFIPatterns <Instruction BFI_INT,
515                        Instruction LoadImm32,
516                        RegisterClass RC64> {
517  // Definition from ISA doc:
518  // (y & x) | (z & ~x)
519  def : Pat <
520    (or (and i32:$y, i32:$x), (and i32:$z, (not i32:$x))),
521    (BFI_INT $x, $y, $z)
522  >;
523
524  // SHA-256 Ch function
525  // z ^ (x & (y ^ z))
526  def : Pat <
527    (xor i32:$z, (and i32:$x, (xor i32:$y, i32:$z))),
528    (BFI_INT $x, $y, $z)
529  >;
530
531  def : Pat <
532    (fcopysign f32:$src0, f32:$src1),
533    (BFI_INT (LoadImm32 (i32 0x7fffffff)), $src0, $src1)
534  >;
535
536  def : Pat <
537    (f64 (fcopysign f64:$src0, f64:$src1)),
538    (REG_SEQUENCE RC64,
539      (i32 (EXTRACT_SUBREG $src0, sub0)), sub0,
540      (BFI_INT (LoadImm32 (i32 0x7fffffff)),
541               (i32 (EXTRACT_SUBREG $src0, sub1)),
542               (i32 (EXTRACT_SUBREG $src1, sub1))), sub1)
543  >;
544
545  def : Pat <
546    (f64 (fcopysign f64:$src0, f32:$src1)),
547    (REG_SEQUENCE RC64,
548      (i32 (EXTRACT_SUBREG $src0, sub0)), sub0,
549      (BFI_INT (LoadImm32 (i32 0x7fffffff)),
550               (i32 (EXTRACT_SUBREG $src0, sub1)),
551               $src1), sub1)
552  >;
553}
554
555// SHA-256 Ma patterns
556
557// ((x & z) | (y & (x | z))) -> BFI_INT (XOR x, y), z, y
558class SHA256MaPattern <Instruction BFI_INT, Instruction XOR> : Pat <
559  (or (and i32:$x, i32:$z), (and i32:$y, (or i32:$x, i32:$z))),
560  (BFI_INT (XOR i32:$x, i32:$y), i32:$z, i32:$y)
561>;
562
563// Bitfield extract patterns
564
565def IMMZeroBasedBitfieldMask : PatLeaf <(imm), [{
566  return isMask_32(N->getZExtValue());
567}]>;
568
569def IMMPopCount : SDNodeXForm<imm, [{
570  return CurDAG->getTargetConstant(countPopulation(N->getZExtValue()), SDLoc(N),
571                                   MVT::i32);
572}]>;
573
574class BFEPattern <Instruction BFE, Instruction MOV> : Pat <
575  (i32 (and (i32 (srl i32:$src, i32:$rshift)), IMMZeroBasedBitfieldMask:$mask)),
576  (BFE $src, $rshift, (MOV (i32 (IMMPopCount $mask))))
577>;
578
579// rotr pattern
580class ROTRPattern <Instruction BIT_ALIGN> : Pat <
581  (rotr i32:$src0, i32:$src1),
582  (BIT_ALIGN $src0, $src0, $src1)
583>;
584
585// This matches 16 permutations of
586// max(min(x, y), min(max(x, y), z))
587class IntMed3Pat<Instruction med3Inst,
588                 SDPatternOperator max,
589                 SDPatternOperator max_oneuse,
590                 SDPatternOperator min_oneuse> : Pat<
591  (max (min_oneuse i32:$src0, i32:$src1),
592       (min_oneuse (max_oneuse i32:$src0, i32:$src1), i32:$src2)),
593  (med3Inst $src0, $src1, $src2)
594>;
595
596let Properties = [SDNPCommutative, SDNPAssociative] in {
597def smax_oneuse : HasOneUseBinOp<smax>;
598def smin_oneuse : HasOneUseBinOp<smin>;
599def umax_oneuse : HasOneUseBinOp<umax>;
600def umin_oneuse : HasOneUseBinOp<umin>;
601def sub_oneuse : HasOneUseBinOp<sub>;
602} // Properties = [SDNPCommutative, SDNPAssociative]
603
604def select_oneuse : HasOneUseTernaryOp<select>;
605
606// Special conversion patterns
607
608def cvt_rpi_i32_f32 : PatFrag <
609  (ops node:$src),
610  (fp_to_sint (ffloor (fadd $src, FP_HALF))),
611  [{ (void) N; return TM.Options.NoNaNsFPMath; }]
612>;
613
614def cvt_flr_i32_f32 : PatFrag <
615  (ops node:$src),
616  (fp_to_sint (ffloor $src)),
617  [{ (void)N; return TM.Options.NoNaNsFPMath; }]
618>;
619
620class IMad24Pat<Instruction Inst> : Pat <
621  (add (AMDGPUmul_i24 i32:$src0, i32:$src1), i32:$src2),
622  (Inst $src0, $src1, $src2)
623>;
624
625class UMad24Pat<Instruction Inst> : Pat <
626  (add (AMDGPUmul_u24 i32:$src0, i32:$src1), i32:$src2),
627  (Inst $src0, $src1, $src2)
628>;
629
630class RcpPat<Instruction RcpInst, ValueType vt> : Pat <
631  (fdiv FP_ONE, vt:$src),
632  (RcpInst $src)
633>;
634
635class RsqPat<Instruction RsqInst, ValueType vt> : Pat <
636  (AMDGPUrcp (fsqrt vt:$src)),
637  (RsqInst $src)
638>;
639
640include "R600Instructions.td"
641include "R700Instructions.td"
642include "EvergreenInstructions.td"
643include "CaymanInstructions.td"
644
645include "SIInstrInfo.td"
646
647