blob: 0a103e8ab780042ce2ccd45d38f713acd63734af [file] [log] [blame]
Tom Stellard75aadc22012-12-11 21:25:42 +00001//===-- 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, list<dag> pattern> : Instruction {
Tom Stellardf3b2a1e2013-02-06 17:32:29 +000016 field bit isRegisterLoad = 0;
17 field bit isRegisterStore = 0;
Tom Stellard75aadc22012-12-11 21:25:42 +000018
19 let Namespace = "AMDGPU";
20 let OutOperandList = outs;
21 let InOperandList = ins;
22 let AsmString = asm;
23 let Pattern = pattern;
24 let Itinerary = NullALU;
Tom Stellardf3b2a1e2013-02-06 17:32:29 +000025
26 let TSFlags{63} = isRegisterLoad;
27 let TSFlags{62} = isRegisterStore;
Tom Stellard75aadc22012-12-11 21:25:42 +000028}
29
30class AMDGPUShaderInst <dag outs, dag ins, string asm, list<dag> pattern>
31 : AMDGPUInst<outs, ins, asm, pattern> {
32
33 field bits<32> Inst = 0xffffffff;
34
35}
36
37def InstFlag : OperandWithDefaultOps <i32, (ops (i32 0))>;
Tom Stellard81d871d2013-11-13 23:36:50 +000038def ADDRIndirect : ComplexPattern<iPTR, 2, "SelectADDRIndirect", [], []>;
Tom Stellard75aadc22012-12-11 21:25:42 +000039
Matt Arsenault4d7d3832014-04-15 22:32:49 +000040def u32imm : Operand<i32> {
41 let PrintMethod = "printU32ImmOperand";
42}
43
44def u16imm : Operand<i16> {
45 let PrintMethod = "printU16ImmOperand";
46}
47
48def u8imm : Operand<i8> {
49 let PrintMethod = "printU8ImmOperand";
50}
51
Tom Stellardc0845332013-11-22 23:07:58 +000052//===----------------------------------------------------------------------===//
53// PatLeafs for floating-point comparisons
54//===----------------------------------------------------------------------===//
Tom Stellard75aadc22012-12-11 21:25:42 +000055
Tom Stellard0351ea22013-09-28 02:50:50 +000056def COND_OEQ : PatLeaf <
57 (cond),
58 [{return N->get() == ISD::SETOEQ || N->get() == ISD::SETEQ;}]
59>;
60
Tom Stellard0351ea22013-09-28 02:50:50 +000061def COND_OGT : PatLeaf <
62 (cond),
63 [{return N->get() == ISD::SETOGT || N->get() == ISD::SETGT;}]
64>;
65
Tom Stellard0351ea22013-09-28 02:50:50 +000066def COND_OGE : PatLeaf <
67 (cond),
68 [{return N->get() == ISD::SETOGE || N->get() == ISD::SETGE;}]
69>;
70
Tom Stellardc0845332013-11-22 23:07:58 +000071def COND_OLT : PatLeaf <
Tom Stellard75aadc22012-12-11 21:25:42 +000072 (cond),
Tom Stellardc0845332013-11-22 23:07:58 +000073 [{return N->get() == ISD::SETOLT || N->get() == ISD::SETLT;}]
Tom Stellard75aadc22012-12-11 21:25:42 +000074>;
75
Tom Stellardc0845332013-11-22 23:07:58 +000076def COND_OLE : PatLeaf <
Tom Stellard75aadc22012-12-11 21:25:42 +000077 (cond),
Tom Stellardc0845332013-11-22 23:07:58 +000078 [{return N->get() == ISD::SETOLE || N->get() == ISD::SETLE;}]
79>;
80
81def COND_UNE : PatLeaf <
82 (cond),
83 [{return N->get() == ISD::SETUNE || N->get() == ISD::SETNE;}]
84>;
85
86def COND_O : PatLeaf <(cond), [{return N->get() == ISD::SETO;}]>;
87def COND_UO : PatLeaf <(cond), [{return N->get() == ISD::SETUO;}]>;
88
89//===----------------------------------------------------------------------===//
90// PatLeafs for unsigned comparisons
91//===----------------------------------------------------------------------===//
92
93def COND_UGT : PatLeaf <(cond), [{return N->get() == ISD::SETUGT;}]>;
94def COND_UGE : PatLeaf <(cond), [{return N->get() == ISD::SETUGE;}]>;
95def COND_ULT : PatLeaf <(cond), [{return N->get() == ISD::SETULT;}]>;
96def COND_ULE : PatLeaf <(cond), [{return N->get() == ISD::SETULE;}]>;
97
98//===----------------------------------------------------------------------===//
99// PatLeafs for signed comparisons
100//===----------------------------------------------------------------------===//
101
102def COND_SGT : PatLeaf <(cond), [{return N->get() == ISD::SETGT;}]>;
103def COND_SGE : PatLeaf <(cond), [{return N->get() == ISD::SETGE;}]>;
104def COND_SLT : PatLeaf <(cond), [{return N->get() == ISD::SETLT;}]>;
105def COND_SLE : PatLeaf <(cond), [{return N->get() == ISD::SETLE;}]>;
106
107//===----------------------------------------------------------------------===//
108// PatLeafs for integer equality
109//===----------------------------------------------------------------------===//
110
111def COND_EQ : PatLeaf <
112 (cond),
113 [{return N->get() == ISD::SETEQ || N->get() == ISD::SETUEQ;}]
114>;
115
116def COND_NE : PatLeaf <
117 (cond),
118 [{return N->get() == ISD::SETNE || N->get() == ISD::SETUNE;}]
Tom Stellard75aadc22012-12-11 21:25:42 +0000119>;
120
Christian Konigb19849a2013-02-21 15:17:04 +0000121def COND_NULL : PatLeaf <
122 (cond),
123 [{return false;}]
124>;
125
Tom Stellard75aadc22012-12-11 21:25:42 +0000126//===----------------------------------------------------------------------===//
127// Load/Store Pattern Fragments
128//===----------------------------------------------------------------------===//
129
Tom Stellard31209cc2013-07-15 19:00:09 +0000130def az_extload : PatFrag<(ops node:$ptr), (unindexedload node:$ptr), [{
131 LoadSDNode *L = cast<LoadSDNode>(N);
132 return L->getExtensionType() == ISD::ZEXTLOAD ||
133 L->getExtensionType() == ISD::EXTLOAD;
134}]>;
135
Tom Stellard33dd04b2013-07-23 01:47:52 +0000136def az_extloadi8 : PatFrag<(ops node:$ptr), (az_extload node:$ptr), [{
137 return cast<LoadSDNode>(N)->getMemoryVT() == MVT::i8;
138}]>;
139
Tom Stellardc6f4a292013-08-26 15:05:59 +0000140def az_extloadi8_global : PatFrag<(ops node:$ptr), (az_extloadi8 node:$ptr), [{
141 return isGlobalLoad(dyn_cast<LoadSDNode>(N));
142}]>;
143
Tom Stellard9f950332013-07-23 01:48:35 +0000144def sextloadi8_global : PatFrag<(ops node:$ptr), (sextloadi8 node:$ptr), [{
Tom Stellard75aadc22012-12-11 21:25:42 +0000145 return isGlobalLoad(dyn_cast<LoadSDNode>(N));
146}]>;
147
Tom Stellard33dd04b2013-07-23 01:47:52 +0000148def az_extloadi8_constant : PatFrag<(ops node:$ptr), (az_extloadi8 node:$ptr), [{
Tom Stellard9f950332013-07-23 01:48:35 +0000149 return isConstantLoad(dyn_cast<LoadSDNode>(N), -1);
150}]>;
151
152def sextloadi8_constant : PatFrag<(ops node:$ptr), (sextloadi8 node:$ptr), [{
153 return isConstantLoad(dyn_cast<LoadSDNode>(N), -1);
154}]>;
155
Tom Stellardc6f4a292013-08-26 15:05:59 +0000156def az_extloadi8_local : PatFrag<(ops node:$ptr), (az_extloadi8 node:$ptr), [{
157 return isLocalLoad(dyn_cast<LoadSDNode>(N));
158}]>;
159
160def sextloadi8_local : PatFrag<(ops node:$ptr), (sextloadi8 node:$ptr), [{
161 return isLocalLoad(dyn_cast<LoadSDNode>(N));
Tom Stellard33dd04b2013-07-23 01:47:52 +0000162}]>;
163
164def az_extloadi16 : PatFrag<(ops node:$ptr), (az_extload node:$ptr), [{
165 return cast<LoadSDNode>(N)->getMemoryVT() == MVT::i16;
166}]>;
167
168def az_extloadi16_global : PatFrag<(ops node:$ptr), (az_extloadi16 node:$ptr), [{
169 return isGlobalLoad(dyn_cast<LoadSDNode>(N));
170}]>;
171
Tom Stellard9f950332013-07-23 01:48:35 +0000172def sextloadi16_global : PatFrag<(ops node:$ptr), (sextloadi16 node:$ptr), [{
Tom Stellard07a10a32013-06-03 17:39:43 +0000173 return isGlobalLoad(dyn_cast<LoadSDNode>(N));
174}]>;
175
Tom Stellard9f950332013-07-23 01:48:35 +0000176def az_extloadi16_constant : PatFrag<(ops node:$ptr), (az_extloadi16 node:$ptr), [{
177 return isConstantLoad(dyn_cast<LoadSDNode>(N), -1);
178}]>;
179
180def sextloadi16_constant : PatFrag<(ops node:$ptr), (sextloadi16 node:$ptr), [{
181 return isConstantLoad(dyn_cast<LoadSDNode>(N), -1);
182}]>;
183
Tom Stellardc6f4a292013-08-26 15:05:59 +0000184def az_extloadi16_local : PatFrag<(ops node:$ptr), (az_extloadi16 node:$ptr), [{
185 return isLocalLoad(dyn_cast<LoadSDNode>(N));
186}]>;
187
188def sextloadi16_local : PatFrag<(ops node:$ptr), (sextloadi16 node:$ptr), [{
189 return isLocalLoad(dyn_cast<LoadSDNode>(N));
190}]>;
191
Tom Stellard31209cc2013-07-15 19:00:09 +0000192def az_extloadi32 : PatFrag<(ops node:$ptr), (az_extload node:$ptr), [{
193 return cast<LoadSDNode>(N)->getMemoryVT() == MVT::i32;
194}]>;
195
196def az_extloadi32_global : PatFrag<(ops node:$ptr),
197 (az_extloadi32 node:$ptr), [{
198 return isGlobalLoad(dyn_cast<LoadSDNode>(N));
199}]>;
200
201def az_extloadi32_constant : PatFrag<(ops node:$ptr),
202 (az_extloadi32 node:$ptr), [{
203 return isConstantLoad(dyn_cast<LoadSDNode>(N), -1);
204}]>;
205
Tom Stellardd3ee8c12013-08-16 01:12:06 +0000206def truncstorei8_global : PatFrag<(ops node:$val, node:$ptr),
207 (truncstorei8 node:$val, node:$ptr), [{
208 return isGlobalStore(dyn_cast<StoreSDNode>(N));
209}]>;
210
211def truncstorei16_global : PatFrag<(ops node:$val, node:$ptr),
212 (truncstorei16 node:$val, node:$ptr), [{
213 return isGlobalStore(dyn_cast<StoreSDNode>(N));
214}]>;
215
Tom Stellardc026e8b2013-06-28 15:47:08 +0000216def local_store : PatFrag<(ops node:$val, node:$ptr),
217 (store node:$val, node:$ptr), [{
Tom Stellardf3d166a2013-08-26 15:05:49 +0000218 return isLocalStore(dyn_cast<StoreSDNode>(N));
219}]>;
220
221def truncstorei8_local : PatFrag<(ops node:$val, node:$ptr),
222 (truncstorei8 node:$val, node:$ptr), [{
223 return isLocalStore(dyn_cast<StoreSDNode>(N));
224}]>;
225
226def truncstorei16_local : PatFrag<(ops node:$val, node:$ptr),
227 (truncstorei16 node:$val, node:$ptr), [{
228 return isLocalStore(dyn_cast<StoreSDNode>(N));
229}]>;
230
231def local_load : PatFrag<(ops node:$ptr), (load node:$ptr), [{
232 return isLocalLoad(dyn_cast<LoadSDNode>(N));
Tom Stellardc026e8b2013-06-28 15:47:08 +0000233}]>;
234
Matt Arsenault72574102014-06-11 18:08:34 +0000235
236class local_binary_atomic_op<SDNode atomic_op> :
237 PatFrag<(ops node:$ptr, node:$value),
238 (atomic_op node:$ptr, node:$value), [{
239 return cast<MemSDNode>(N)->getAddressSpace() == AMDGPUAS::LOCAL_ADDRESS;
Tom Stellard13c68ef2013-09-05 18:38:09 +0000240}]>;
241
Matt Arsenault72574102014-06-11 18:08:34 +0000242
243def atomic_swap_local : local_binary_atomic_op<atomic_swap>;
244def atomic_load_add_local : local_binary_atomic_op<atomic_load_add>;
245def atomic_load_sub_local : local_binary_atomic_op<atomic_load_sub>;
246def atomic_load_and_local : local_binary_atomic_op<atomic_load_and>;
247def atomic_load_or_local : local_binary_atomic_op<atomic_load_or>;
248def atomic_load_xor_local : local_binary_atomic_op<atomic_load_xor>;
249def atomic_load_nand_local : local_binary_atomic_op<atomic_load_nand>;
250def atomic_load_min_local : local_binary_atomic_op<atomic_load_min>;
251def atomic_load_max_local : local_binary_atomic_op<atomic_load_max>;
252def atomic_load_umin_local : local_binary_atomic_op<atomic_load_umin>;
253def atomic_load_umax_local : local_binary_atomic_op<atomic_load_umax>;
Aaron Watry372cecf2013-09-06 20:17:42 +0000254
Tom Stellardd3ee8c12013-08-16 01:12:06 +0000255def mskor_global : PatFrag<(ops node:$val, node:$ptr),
256 (AMDGPUstore_mskor node:$val, node:$ptr), [{
257 return dyn_cast<MemSDNode>(N)->getAddressSpace() == AMDGPUAS::GLOBAL_ADDRESS;
258}]>;
259
Matt Arsenaultc793e1d2014-06-11 18:08:48 +0000260def atomic_cmp_swap_32_local :
261 PatFrag<(ops node:$ptr, node:$cmp, node:$swap),
262 (atomic_cmp_swap node:$ptr, node:$cmp, node:$swap), [{
263 AtomicSDNode *AN = cast<AtomicSDNode>(N);
264 return AN->getMemoryVT() == MVT::i32 &&
265 AN->getAddressSpace() == AMDGPUAS::LOCAL_ADDRESS;
266}]>;
267
268
Tom Stellard75aadc22012-12-11 21:25:42 +0000269class Constants {
270int TWO_PI = 0x40c90fdb;
271int PI = 0x40490fdb;
272int TWO_PI_INV = 0x3e22f983;
NAKAMURA Takumi4bb85f92013-10-28 04:07:23 +0000273int FP_UINT_MAX_PLUS_1 = 0x4f800000; // 1 << 32 in floating point encoding
Matt Arsenaultaeca2fa2014-05-31 06:47:42 +0000274int FP32_NEG_ONE = 0xbf800000;
275int FP32_ONE = 0x3f800000;
Tom Stellard75aadc22012-12-11 21:25:42 +0000276}
277def CONST : Constants;
278
279def FP_ZERO : PatLeaf <
280 (fpimm),
281 [{return N->getValueAPF().isZero();}]
282>;
283
284def FP_ONE : PatLeaf <
285 (fpimm),
286 [{return N->isExactlyValue(1.0);}]
287>;
288
Tom Stellardf3b2a1e2013-02-06 17:32:29 +0000289let isCodeGenOnly = 1, isPseudo = 1 in {
290
291let usesCustomInserter = 1 in {
Tom Stellard75aadc22012-12-11 21:25:42 +0000292
293class CLAMP <RegisterClass rc> : AMDGPUShaderInst <
294 (outs rc:$dst),
295 (ins rc:$src0),
296 "CLAMP $dst, $src0",
Tom Stellard40b7f1f2013-05-02 15:30:12 +0000297 [(set f32:$dst, (int_AMDIL_clamp f32:$src0, (f32 FP_ZERO), (f32 FP_ONE)))]
Tom Stellard75aadc22012-12-11 21:25:42 +0000298>;
299
300class FABS <RegisterClass rc> : AMDGPUShaderInst <
301 (outs rc:$dst),
302 (ins rc:$src0),
303 "FABS $dst, $src0",
Tom Stellard40b7f1f2013-05-02 15:30:12 +0000304 [(set f32:$dst, (fabs f32:$src0))]
Tom Stellard75aadc22012-12-11 21:25:42 +0000305>;
306
307class FNEG <RegisterClass rc> : AMDGPUShaderInst <
308 (outs rc:$dst),
309 (ins rc:$src0),
310 "FNEG $dst, $src0",
Tom Stellard40b7f1f2013-05-02 15:30:12 +0000311 [(set f32:$dst, (fneg f32:$src0))]
Tom Stellard75aadc22012-12-11 21:25:42 +0000312>;
313
Tom Stellardf3b2a1e2013-02-06 17:32:29 +0000314} // usesCustomInserter = 1
315
316multiclass RegisterLoadStore <RegisterClass dstClass, Operand addrClass,
317 ComplexPattern addrPat> {
Tom Stellard81d871d2013-11-13 23:36:50 +0000318let UseNamedOperandTable = 1 in {
319
Tom Stellardf3b2a1e2013-02-06 17:32:29 +0000320 def RegisterLoad : AMDGPUShaderInst <
321 (outs dstClass:$dst),
322 (ins addrClass:$addr, i32imm:$chan),
323 "RegisterLoad $dst, $addr",
Tom Stellard40b7f1f2013-05-02 15:30:12 +0000324 [(set i32:$dst, (AMDGPUregister_load addrPat:$addr, (i32 timm:$chan)))]
Tom Stellardf3b2a1e2013-02-06 17:32:29 +0000325 > {
326 let isRegisterLoad = 1;
327 }
328
329 def RegisterStore : AMDGPUShaderInst <
330 (outs),
331 (ins dstClass:$val, addrClass:$addr, i32imm:$chan),
332 "RegisterStore $val, $addr",
Tom Stellard40b7f1f2013-05-02 15:30:12 +0000333 [(AMDGPUregister_store i32:$val, addrPat:$addr, (i32 timm:$chan))]
Tom Stellardf3b2a1e2013-02-06 17:32:29 +0000334 > {
335 let isRegisterStore = 1;
336 }
337}
Tom Stellard81d871d2013-11-13 23:36:50 +0000338}
Tom Stellardf3b2a1e2013-02-06 17:32:29 +0000339
340} // End isCodeGenOnly = 1, isPseudo = 1
Tom Stellard75aadc22012-12-11 21:25:42 +0000341
342/* Generic helper patterns for intrinsics */
343/* -------------------------------------- */
344
Tom Stellard40b7f1f2013-05-02 15:30:12 +0000345class POW_Common <AMDGPUInst log_ieee, AMDGPUInst exp_ieee, AMDGPUInst mul>
346 : Pat <
347 (fpow f32:$src0, f32:$src1),
348 (exp_ieee (mul f32:$src1, (log_ieee f32:$src0)))
Tom Stellard75aadc22012-12-11 21:25:42 +0000349>;
350
351/* Other helper patterns */
352/* --------------------- */
353
354/* Extract element pattern */
Matt Arsenault530dde42014-02-26 23:00:58 +0000355class Extract_Element <ValueType sub_type, ValueType vec_type, int sub_idx,
Tom Stellard40b7f1f2013-05-02 15:30:12 +0000356 SubRegIndex sub_reg>
357 : Pat<
358 (sub_type (vector_extract vec_type:$src, sub_idx)),
359 (EXTRACT_SUBREG $src, sub_reg)
Tom Stellard75aadc22012-12-11 21:25:42 +0000360>;
361
362/* Insert element pattern */
363class Insert_Element <ValueType elem_type, ValueType vec_type,
Tom Stellard40b7f1f2013-05-02 15:30:12 +0000364 int sub_idx, SubRegIndex sub_reg>
365 : Pat <
366 (vector_insert vec_type:$vec, elem_type:$elem, sub_idx),
367 (INSERT_SUBREG $vec, $elem, sub_reg)
Tom Stellard75aadc22012-12-11 21:25:42 +0000368>;
369
Tom Stellard40b7f1f2013-05-02 15:30:12 +0000370// XXX: Convert to new syntax and use COPY_TO_REG, once the DFAPacketizer
371// can handle COPY instructions.
Tom Stellard75aadc22012-12-11 21:25:42 +0000372// bitconvert pattern
373class BitConvert <ValueType dt, ValueType st, RegisterClass rc> : Pat <
374 (dt (bitconvert (st rc:$src0))),
375 (dt rc:$src0)
376>;
377
Tom Stellard40b7f1f2013-05-02 15:30:12 +0000378// XXX: Convert to new syntax and use COPY_TO_REG, once the DFAPacketizer
379// can handle COPY instructions.
Tom Stellard75aadc22012-12-11 21:25:42 +0000380class DwordAddrPat<ValueType vt, RegisterClass rc> : Pat <
381 (vt (AMDGPUdwordaddr (vt rc:$addr))),
382 (vt rc:$addr)
383>;
384
Tom Stellard9d10c4c2013-04-19 02:11:06 +0000385// BFI_INT patterns
386
Matt Arsenault6e439652014-06-10 19:00:20 +0000387multiclass BFIPatterns <Instruction BFI_INT, Instruction LoadImm32> {
Tom Stellard9d10c4c2013-04-19 02:11:06 +0000388
389 // Definition from ISA doc:
390 // (y & x) | (z & ~x)
391 def : Pat <
392 (or (and i32:$y, i32:$x), (and i32:$z, (not i32:$x))),
393 (BFI_INT $x, $y, $z)
394 >;
395
396 // SHA-256 Ch function
397 // z ^ (x & (y ^ z))
398 def : Pat <
399 (xor i32:$z, (and i32:$x, (xor i32:$y, i32:$z))),
400 (BFI_INT $x, $y, $z)
401 >;
402
Matt Arsenault6e439652014-06-10 19:00:20 +0000403 def : Pat <
404 (fcopysign f32:$src0, f32:$src1),
405 (BFI_INT (LoadImm32 0x7fffffff), $src0, $src1)
406 >;
407
408 def : Pat <
409 (f64 (fcopysign f64:$src0, f64:$src1)),
410 (INSERT_SUBREG (INSERT_SUBREG (f64 (IMPLICIT_DEF)),
411 (i32 (EXTRACT_SUBREG $src0, sub0)), sub0),
412 (BFI_INT (LoadImm32 0x7fffffff),
413 (i32 (EXTRACT_SUBREG $src0, sub1)),
414 (i32 (EXTRACT_SUBREG $src1, sub1))), sub1)
415 >;
Tom Stellard9d10c4c2013-04-19 02:11:06 +0000416}
417
Tom Stellardeac65dd2013-05-03 17:21:20 +0000418// SHA-256 Ma patterns
419
420// ((x & z) | (y & (x | z))) -> BFI_INT (XOR x, y), z, y
421class SHA256MaPattern <Instruction BFI_INT, Instruction XOR> : Pat <
422 (or (and i32:$x, i32:$z), (and i32:$y, (or i32:$x, i32:$z))),
423 (BFI_INT (XOR i32:$x, i32:$y), i32:$z, i32:$y)
424>;
425
Tom Stellard2b971eb2013-05-10 02:09:45 +0000426// Bitfield extract patterns
427
Tom Stellarda2a4b8e2014-01-23 18:49:33 +0000428/*
429
430XXX: The BFE pattern is not working correctly because the XForm is not being
431applied.
432
Tom Stellard2b971eb2013-05-10 02:09:45 +0000433def legalshift32 : ImmLeaf <i32, [{return Imm >=0 && Imm < 32;}]>;
434def bfemask : PatLeaf <(imm), [{return isMask_32(N->getZExtValue());}],
435 SDNodeXForm<imm, [{ return CurDAG->getTargetConstant(CountTrailingOnes_32(N->getZExtValue()), MVT::i32);}]>>;
436
437class BFEPattern <Instruction BFE> : Pat <
438 (and (srl i32:$x, legalshift32:$y), bfemask:$z),
439 (BFE $x, $y, $z)
440>;
441
Tom Stellarda2a4b8e2014-01-23 18:49:33 +0000442*/
443
Tom Stellard5643c4a2013-05-20 15:02:19 +0000444// rotr pattern
445class ROTRPattern <Instruction BIT_ALIGN> : Pat <
446 (rotr i32:$src0, i32:$src1),
447 (BIT_ALIGN $src0, $src0, $src1)
448>;
449
Tom Stellard41fc7852013-07-23 01:48:42 +0000450// 24-bit arithmetic patterns
451def umul24 : PatFrag <(ops node:$x, node:$y), (mul node:$x, node:$y)>;
452
453/*
454class UMUL24Pattern <Instruction UMUL24> : Pat <
455 (mul U24:$x, U24:$y),
456 (UMUL24 $x, $y)
457>;
458*/
459
Matt Arsenaulteb260202014-05-22 18:00:15 +0000460class IMad24Pat<Instruction Inst> : Pat <
461 (add (AMDGPUmul_i24 i32:$src0, i32:$src1), i32:$src2),
462 (Inst $src0, $src1, $src2)
463>;
464
465class UMad24Pat<Instruction Inst> : Pat <
466 (add (AMDGPUmul_u24 i32:$src0, i32:$src1), i32:$src2),
467 (Inst $src0, $src1, $src2)
468>;
469
Matt Arsenault493c5f12014-05-22 18:00:24 +0000470multiclass Expand24IBitOps<Instruction MulInst, Instruction AddInst> {
471 def _expand_imad24 : Pat <
472 (AMDGPUmad_i24 i32:$src0, i32:$src1, i32:$src2),
473 (AddInst (MulInst $src0, $src1), $src2)
474 >;
Matt Arsenaultf15a0562014-05-22 18:00:20 +0000475
Matt Arsenault493c5f12014-05-22 18:00:24 +0000476 def _expand_imul24 : Pat <
477 (AMDGPUmul_i24 i32:$src0, i32:$src1),
478 (MulInst $src0, $src1)
479 >;
480}
Matt Arsenaultf15a0562014-05-22 18:00:20 +0000481
Matt Arsenault493c5f12014-05-22 18:00:24 +0000482multiclass Expand24UBitOps<Instruction MulInst, Instruction AddInst> {
483 def _expand_umad24 : Pat <
484 (AMDGPUmad_u24 i32:$src0, i32:$src1, i32:$src2),
485 (AddInst (MulInst $src0, $src1), $src2)
486 >;
487
488 def _expand_umul24 : Pat <
489 (AMDGPUmul_u24 i32:$src0, i32:$src1),
490 (MulInst $src0, $src1)
491 >;
492}
Matt Arsenaulteb260202014-05-22 18:00:15 +0000493
Tom Stellard75aadc22012-12-11 21:25:42 +0000494include "R600Instructions.td"
Tom Stellard2c1c9de2014-03-24 16:07:25 +0000495include "R700Instructions.td"
496include "EvergreenInstructions.td"
497include "CaymanInstructions.td"
Tom Stellard75aadc22012-12-11 21:25:42 +0000498
499include "SIInstrInfo.td"
500