blob: a7fb14c26a76c262df98407fb01362fe056973ee [file] [log] [blame]
Scott Michel66377522007-12-04 22:35:58 +00001//==- SPUInstrInfo.td - Describe the Cell SPU Instructions -*- tablegen -*-==//
Scott Michelf0569be2008-12-27 04:51:36 +00002//
Scott Michel66377522007-12-04 22:35:58 +00003// The LLVM Compiler Infrastructure
4//
Chris Lattner4ee451d2007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Scott Michelf0569be2008-12-27 04:51:36 +00007//
Scott Michel66377522007-12-04 22:35:58 +00008//===----------------------------------------------------------------------===//
9// Cell SPU Instructions:
10//===----------------------------------------------------------------------===//
11
12//===----------------------------------------------------------------------===//
13// TODO Items (not urgent today, but would be nice, low priority)
14//
15// ANDBI, ORBI: SPU constructs a 4-byte constant for these instructions by
16// concatenating the byte argument b as "bbbb". Could recognize this bit pattern
17// in 16-bit and 32-bit constants and reduce instruction count.
18//===----------------------------------------------------------------------===//
19
20//===----------------------------------------------------------------------===//
21// Pseudo instructions:
22//===----------------------------------------------------------------------===//
23
24let hasCtrlDep = 1, Defs = [R1], Uses = [R1] in {
Scott Michel203b2d62008-04-30 00:30:08 +000025 def ADJCALLSTACKDOWN : Pseudo<(outs), (ins u16imm_i32:$amt),
Scott Michel66377522007-12-04 22:35:58 +000026 "${:comment} ADJCALLSTACKDOWN",
Chris Lattnere563bbc2008-10-11 22:08:30 +000027 [(callseq_start timm:$amt)]>;
Scott Michel203b2d62008-04-30 00:30:08 +000028 def ADJCALLSTACKUP : Pseudo<(outs), (ins u16imm_i32:$amt),
Scott Michel66377522007-12-04 22:35:58 +000029 "${:comment} ADJCALLSTACKUP",
Chris Lattnere563bbc2008-10-11 22:08:30 +000030 [(callseq_end timm:$amt)]>;
Scott Michel66377522007-12-04 22:35:58 +000031}
32
33//===----------------------------------------------------------------------===//
Scott Michel66377522007-12-04 22:35:58 +000034// Loads:
35// NB: The ordering is actually important, since the instruction selection
36// will try each of the instructions in sequence, i.e., the D-form first with
37// the 10-bit displacement, then the A-form with the 16 bit displacement, and
38// finally the X-form with the register-register.
39//===----------------------------------------------------------------------===//
40
Dan Gohman15511cf2008-12-03 18:15:48 +000041let canFoldAsLoad = 1 in {
Scott Michel053c1da2008-01-29 02:16:57 +000042 class LoadDFormVec<ValueType vectype>
Scott Michelf0569be2008-12-27 04:51:36 +000043 : RI10Form<0b00101100, (outs VECREG:$rT), (ins dformaddr:$src),
Scott Michel053c1da2008-01-29 02:16:57 +000044 "lqd\t$rT, $src",
45 LoadStore,
46 [(set (vectype VECREG:$rT), (load dform_addr:$src))]>
47 { }
Scott Michel66377522007-12-04 22:35:58 +000048
Scott Michel053c1da2008-01-29 02:16:57 +000049 class LoadDForm<RegisterClass rclass>
Scott Michelf0569be2008-12-27 04:51:36 +000050 : RI10Form<0b00101100, (outs rclass:$rT), (ins dformaddr:$src),
Scott Michel053c1da2008-01-29 02:16:57 +000051 "lqd\t$rT, $src",
52 LoadStore,
53 [(set rclass:$rT, (load dform_addr:$src))]>
54 { }
Scott Michel66377522007-12-04 22:35:58 +000055
Scott Michel053c1da2008-01-29 02:16:57 +000056 multiclass LoadDForms
57 {
58 def v16i8: LoadDFormVec<v16i8>;
59 def v8i16: LoadDFormVec<v8i16>;
60 def v4i32: LoadDFormVec<v4i32>;
61 def v2i64: LoadDFormVec<v2i64>;
62 def v4f32: LoadDFormVec<v4f32>;
63 def v2f64: LoadDFormVec<v2f64>;
Scott Michel66377522007-12-04 22:35:58 +000064
Scott Michel21213e72009-01-06 23:10:38 +000065 def v2i32: LoadDFormVec<v2i32>;
66
Scott Michel053c1da2008-01-29 02:16:57 +000067 def r128: LoadDForm<GPRC>;
68 def r64: LoadDForm<R64C>;
69 def r32: LoadDForm<R32C>;
70 def f32: LoadDForm<R32FP>;
71 def f64: LoadDForm<R64FP>;
72 def r16: LoadDForm<R16C>;
73 def r8: LoadDForm<R8C>;
74 }
Scott Michel66377522007-12-04 22:35:58 +000075
Scott Michel053c1da2008-01-29 02:16:57 +000076 class LoadAFormVec<ValueType vectype>
77 : RI16Form<0b100001100, (outs VECREG:$rT), (ins addr256k:$src),
78 "lqa\t$rT, $src",
79 LoadStore,
80 [(set (vectype VECREG:$rT), (load aform_addr:$src))]>
81 { }
Scott Michel66377522007-12-04 22:35:58 +000082
Scott Michel053c1da2008-01-29 02:16:57 +000083 class LoadAForm<RegisterClass rclass>
84 : RI16Form<0b100001100, (outs rclass:$rT), (ins addr256k:$src),
85 "lqa\t$rT, $src",
86 LoadStore,
87 [(set rclass:$rT, (load aform_addr:$src))]>
88 { }
Scott Michel66377522007-12-04 22:35:58 +000089
Scott Michel053c1da2008-01-29 02:16:57 +000090 multiclass LoadAForms
91 {
92 def v16i8: LoadAFormVec<v16i8>;
93 def v8i16: LoadAFormVec<v8i16>;
94 def v4i32: LoadAFormVec<v4i32>;
95 def v2i64: LoadAFormVec<v2i64>;
96 def v4f32: LoadAFormVec<v4f32>;
97 def v2f64: LoadAFormVec<v2f64>;
Scott Michel66377522007-12-04 22:35:58 +000098
Scott Michel21213e72009-01-06 23:10:38 +000099 def v2i32: LoadAFormVec<v2i32>;
100
Scott Michel053c1da2008-01-29 02:16:57 +0000101 def r128: LoadAForm<GPRC>;
102 def r64: LoadAForm<R64C>;
103 def r32: LoadAForm<R32C>;
104 def f32: LoadAForm<R32FP>;
105 def f64: LoadAForm<R64FP>;
106 def r16: LoadAForm<R16C>;
107 def r8: LoadAForm<R8C>;
108 }
Scott Michel66377522007-12-04 22:35:58 +0000109
Scott Michel053c1da2008-01-29 02:16:57 +0000110 class LoadXFormVec<ValueType vectype>
111 : RRForm<0b00100011100, (outs VECREG:$rT), (ins memrr:$src),
112 "lqx\t$rT, $src",
113 LoadStore,
114 [(set (vectype VECREG:$rT), (load xform_addr:$src))]>
115 { }
Scott Michel66377522007-12-04 22:35:58 +0000116
Scott Michel053c1da2008-01-29 02:16:57 +0000117 class LoadXForm<RegisterClass rclass>
118 : RRForm<0b00100011100, (outs rclass:$rT), (ins memrr:$src),
119 "lqx\t$rT, $src",
120 LoadStore,
121 [(set rclass:$rT, (load xform_addr:$src))]>
122 { }
Scott Michel66377522007-12-04 22:35:58 +0000123
Scott Michel053c1da2008-01-29 02:16:57 +0000124 multiclass LoadXForms
125 {
126 def v16i8: LoadXFormVec<v16i8>;
127 def v8i16: LoadXFormVec<v8i16>;
128 def v4i32: LoadXFormVec<v4i32>;
129 def v2i64: LoadXFormVec<v2i64>;
130 def v4f32: LoadXFormVec<v4f32>;
131 def v2f64: LoadXFormVec<v2f64>;
Scott Michel66377522007-12-04 22:35:58 +0000132
Scott Michel21213e72009-01-06 23:10:38 +0000133 def v2i32: LoadXFormVec<v2i32>;
134
Scott Michel053c1da2008-01-29 02:16:57 +0000135 def r128: LoadXForm<GPRC>;
136 def r64: LoadXForm<R64C>;
137 def r32: LoadXForm<R32C>;
138 def f32: LoadXForm<R32FP>;
139 def f64: LoadXForm<R64FP>;
140 def r16: LoadXForm<R16C>;
141 def r8: LoadXForm<R8C>;
142 }
Scott Michel66377522007-12-04 22:35:58 +0000143
Scott Michel053c1da2008-01-29 02:16:57 +0000144 defm LQA : LoadAForms;
145 defm LQD : LoadDForms;
146 defm LQX : LoadXForms;
Scott Michel504c3692007-12-17 22:32:34 +0000147
Scott Michel66377522007-12-04 22:35:58 +0000148/* Load quadword, PC relative: Not much use at this point in time.
Scott Michel053c1da2008-01-29 02:16:57 +0000149 Might be of use later for relocatable code. It's effectively the
150 same as LQA, but uses PC-relative addressing.
Scott Michel66377522007-12-04 22:35:58 +0000151 def LQR : RI16Form<0b111001100, (outs VECREG:$rT), (ins s16imm:$disp),
152 "lqr\t$rT, $disp", LoadStore,
153 [(set VECREG:$rT, (load iaddr:$disp))]>;
154 */
Scott Michel66377522007-12-04 22:35:58 +0000155}
156
157//===----------------------------------------------------------------------===//
158// Stores:
159//===----------------------------------------------------------------------===//
Scott Michel053c1da2008-01-29 02:16:57 +0000160class StoreDFormVec<ValueType vectype>
Scott Michelf0569be2008-12-27 04:51:36 +0000161 : RI10Form<0b00100100, (outs), (ins VECREG:$rT, dformaddr:$src),
Scott Michel053c1da2008-01-29 02:16:57 +0000162 "stqd\t$rT, $src",
163 LoadStore,
164 [(store (vectype VECREG:$rT), dform_addr:$src)]>
165{ }
Scott Michel66377522007-12-04 22:35:58 +0000166
Scott Michel053c1da2008-01-29 02:16:57 +0000167class StoreDForm<RegisterClass rclass>
Scott Michelf0569be2008-12-27 04:51:36 +0000168 : RI10Form<0b00100100, (outs), (ins rclass:$rT, dformaddr:$src),
Scott Michel053c1da2008-01-29 02:16:57 +0000169 "stqd\t$rT, $src",
170 LoadStore,
171 [(store rclass:$rT, dform_addr:$src)]>
172{ }
Scott Michel66377522007-12-04 22:35:58 +0000173
Scott Michel053c1da2008-01-29 02:16:57 +0000174multiclass StoreDForms
175{
176 def v16i8: StoreDFormVec<v16i8>;
177 def v8i16: StoreDFormVec<v8i16>;
178 def v4i32: StoreDFormVec<v4i32>;
179 def v2i64: StoreDFormVec<v2i64>;
180 def v4f32: StoreDFormVec<v4f32>;
181 def v2f64: StoreDFormVec<v2f64>;
Scott Michel66377522007-12-04 22:35:58 +0000182
Scott Michel21213e72009-01-06 23:10:38 +0000183 def v2i32: StoreDFormVec<v2i32>;
184
Scott Michel053c1da2008-01-29 02:16:57 +0000185 def r128: StoreDForm<GPRC>;
186 def r64: StoreDForm<R64C>;
187 def r32: StoreDForm<R32C>;
188 def f32: StoreDForm<R32FP>;
189 def f64: StoreDForm<R64FP>;
190 def r16: StoreDForm<R16C>;
191 def r8: StoreDForm<R8C>;
192}
Scott Michel66377522007-12-04 22:35:58 +0000193
Scott Michel053c1da2008-01-29 02:16:57 +0000194class StoreAFormVec<ValueType vectype>
195 : RI16Form<0b0010010, (outs), (ins VECREG:$rT, addr256k:$src),
Scott Michel7f9ba9b2008-01-30 02:55:46 +0000196 "stqa\t$rT, $src",
197 LoadStore,
Scott Michelad2715e2008-03-05 23:02:02 +0000198 [(store (vectype VECREG:$rT), aform_addr:$src)]>;
Scott Michel66377522007-12-04 22:35:58 +0000199
Scott Michel053c1da2008-01-29 02:16:57 +0000200class StoreAForm<RegisterClass rclass>
201 : RI16Form<0b001001, (outs), (ins rclass:$rT, addr256k:$src),
Scott Michel7f9ba9b2008-01-30 02:55:46 +0000202 "stqa\t$rT, $src",
203 LoadStore,
Scott Michelad2715e2008-03-05 23:02:02 +0000204 [(store rclass:$rT, aform_addr:$src)]>;
Scott Michel66377522007-12-04 22:35:58 +0000205
Scott Michel053c1da2008-01-29 02:16:57 +0000206multiclass StoreAForms
207{
208 def v16i8: StoreAFormVec<v16i8>;
209 def v8i16: StoreAFormVec<v8i16>;
210 def v4i32: StoreAFormVec<v4i32>;
211 def v2i64: StoreAFormVec<v2i64>;
212 def v4f32: StoreAFormVec<v4f32>;
213 def v2f64: StoreAFormVec<v2f64>;
Scott Michel66377522007-12-04 22:35:58 +0000214
Scott Michel21213e72009-01-06 23:10:38 +0000215 def v2i32: StoreAFormVec<v2i32>;
216
Scott Michel053c1da2008-01-29 02:16:57 +0000217 def r128: StoreAForm<GPRC>;
218 def r64: StoreAForm<R64C>;
219 def r32: StoreAForm<R32C>;
220 def f32: StoreAForm<R32FP>;
221 def f64: StoreAForm<R64FP>;
222 def r16: StoreAForm<R16C>;
223 def r8: StoreAForm<R8C>;
224}
Scott Michel66377522007-12-04 22:35:58 +0000225
Scott Michel053c1da2008-01-29 02:16:57 +0000226class StoreXFormVec<ValueType vectype>
227 : RRForm<0b00100100, (outs), (ins VECREG:$rT, memrr:$src),
Scott Michel7f9ba9b2008-01-30 02:55:46 +0000228 "stqx\t$rT, $src",
229 LoadStore,
230 [(store (vectype VECREG:$rT), xform_addr:$src)]>
Scott Michel053c1da2008-01-29 02:16:57 +0000231{ }
Scott Michel66377522007-12-04 22:35:58 +0000232
Scott Michel053c1da2008-01-29 02:16:57 +0000233class StoreXForm<RegisterClass rclass>
234 : RRForm<0b00100100, (outs), (ins rclass:$rT, memrr:$src),
Scott Michel7f9ba9b2008-01-30 02:55:46 +0000235 "stqx\t$rT, $src",
236 LoadStore,
237 [(store rclass:$rT, xform_addr:$src)]>
Scott Michel053c1da2008-01-29 02:16:57 +0000238{ }
Scott Michel66377522007-12-04 22:35:58 +0000239
Scott Michel053c1da2008-01-29 02:16:57 +0000240multiclass StoreXForms
241{
242 def v16i8: StoreXFormVec<v16i8>;
243 def v8i16: StoreXFormVec<v8i16>;
244 def v4i32: StoreXFormVec<v4i32>;
245 def v2i64: StoreXFormVec<v2i64>;
246 def v4f32: StoreXFormVec<v4f32>;
247 def v2f64: StoreXFormVec<v2f64>;
Scott Michel66377522007-12-04 22:35:58 +0000248
Scott Michel21213e72009-01-06 23:10:38 +0000249 def v2i32: StoreXFormVec<v2i32>;
250
Scott Michel053c1da2008-01-29 02:16:57 +0000251 def r128: StoreXForm<GPRC>;
252 def r64: StoreXForm<R64C>;
253 def r32: StoreXForm<R32C>;
254 def f32: StoreXForm<R32FP>;
255 def f64: StoreXForm<R64FP>;
256 def r16: StoreXForm<R16C>;
257 def r8: StoreXForm<R8C>;
258}
Scott Michel66377522007-12-04 22:35:58 +0000259
Scott Michel053c1da2008-01-29 02:16:57 +0000260defm STQD : StoreDForms;
261defm STQA : StoreAForms;
262defm STQX : StoreXForms;
Scott Michel66377522007-12-04 22:35:58 +0000263
264/* Store quadword, PC relative: Not much use at this point in time. Might
Scott Michel053c1da2008-01-29 02:16:57 +0000265 be useful for relocatable code.
Chris Lattnerc8478d82008-01-06 06:44:58 +0000266def STQR : RI16Form<0b111000100, (outs), (ins VECREG:$rT, s16imm:$disp),
267 "stqr\t$rT, $disp", LoadStore,
268 [(store VECREG:$rT, iaddr:$disp)]>;
269*/
Scott Michel66377522007-12-04 22:35:58 +0000270
271//===----------------------------------------------------------------------===//
272// Generate Controls for Insertion:
273//===----------------------------------------------------------------------===//
274
Scott Michelf0569be2008-12-27 04:51:36 +0000275def CBD: RI7Form<0b10101111100, (outs VECREG:$rT), (ins shufaddr:$src),
Scott Michel1a6cdb62008-12-01 17:56:02 +0000276 "cbd\t$rT, $src", ShuffleOp,
277 [(set (v16i8 VECREG:$rT), (SPUshufmask dform2_addr:$src))]>;
Scott Michel66377522007-12-04 22:35:58 +0000278
Scott Michel1a6cdb62008-12-01 17:56:02 +0000279def CBX: RRForm<0b00101011100, (outs VECREG:$rT), (ins memrr:$src),
Scott Michel66377522007-12-04 22:35:58 +0000280 "cbx\t$rT, $src", ShuffleOp,
Scott Michel7a1c9e92008-11-22 23:50:42 +0000281 [(set (v16i8 VECREG:$rT), (SPUshufmask xform_addr:$src))]>;
Scott Michel66377522007-12-04 22:35:58 +0000282
Scott Michelf0569be2008-12-27 04:51:36 +0000283def CHD: RI7Form<0b10101111100, (outs VECREG:$rT), (ins shufaddr:$src),
Scott Michel66377522007-12-04 22:35:58 +0000284 "chd\t$rT, $src", ShuffleOp,
Scott Michel7a1c9e92008-11-22 23:50:42 +0000285 [(set (v8i16 VECREG:$rT), (SPUshufmask dform2_addr:$src))]>;
Scott Michel66377522007-12-04 22:35:58 +0000286
Scott Michel1a6cdb62008-12-01 17:56:02 +0000287def CHX: RRForm<0b10101011100, (outs VECREG:$rT), (ins memrr:$src),
Scott Michel66377522007-12-04 22:35:58 +0000288 "chx\t$rT, $src", ShuffleOp,
Scott Michel7a1c9e92008-11-22 23:50:42 +0000289 [(set (v8i16 VECREG:$rT), (SPUshufmask xform_addr:$src))]>;
Scott Michel66377522007-12-04 22:35:58 +0000290
Scott Michelf0569be2008-12-27 04:51:36 +0000291def CWD: RI7Form<0b01101111100, (outs VECREG:$rT), (ins shufaddr:$src),
Scott Michel66377522007-12-04 22:35:58 +0000292 "cwd\t$rT, $src", ShuffleOp,
Scott Michel7a1c9e92008-11-22 23:50:42 +0000293 [(set (v4i32 VECREG:$rT), (SPUshufmask dform2_addr:$src))]>;
Scott Michel66377522007-12-04 22:35:58 +0000294
Scott Michel1a6cdb62008-12-01 17:56:02 +0000295def CWX: RRForm<0b01101011100, (outs VECREG:$rT), (ins memrr:$src),
Scott Michel66377522007-12-04 22:35:58 +0000296 "cwx\t$rT, $src", ShuffleOp,
Scott Michel7a1c9e92008-11-22 23:50:42 +0000297 [(set (v4i32 VECREG:$rT), (SPUshufmask xform_addr:$src))]>;
Scott Michel66377522007-12-04 22:35:58 +0000298
Scott Michelf0569be2008-12-27 04:51:36 +0000299def CWDf32: RI7Form<0b01101111100, (outs VECREG:$rT), (ins shufaddr:$src),
Scott Michel1a6cdb62008-12-01 17:56:02 +0000300 "cwd\t$rT, $src", ShuffleOp,
301 [(set (v4f32 VECREG:$rT), (SPUshufmask dform2_addr:$src))]>;
302
303def CWXf32: RRForm<0b01101011100, (outs VECREG:$rT), (ins memrr:$src),
Scott Michel203b2d62008-04-30 00:30:08 +0000304 "cwx\t$rT, $src", ShuffleOp,
Scott Michel7a1c9e92008-11-22 23:50:42 +0000305 [(set (v4f32 VECREG:$rT), (SPUshufmask xform_addr:$src))]>;
Scott Michel203b2d62008-04-30 00:30:08 +0000306
Scott Michelf0569be2008-12-27 04:51:36 +0000307def CDD: RI7Form<0b11101111100, (outs VECREG:$rT), (ins shufaddr:$src),
Scott Michel66377522007-12-04 22:35:58 +0000308 "cdd\t$rT, $src", ShuffleOp,
Scott Michel7a1c9e92008-11-22 23:50:42 +0000309 [(set (v2i64 VECREG:$rT), (SPUshufmask dform2_addr:$src))]>;
Scott Michel66377522007-12-04 22:35:58 +0000310
Scott Michel1a6cdb62008-12-01 17:56:02 +0000311def CDX: RRForm<0b11101011100, (outs VECREG:$rT), (ins memrr:$src),
Scott Michel66377522007-12-04 22:35:58 +0000312 "cdx\t$rT, $src", ShuffleOp,
Scott Michel7a1c9e92008-11-22 23:50:42 +0000313 [(set (v2i64 VECREG:$rT), (SPUshufmask xform_addr:$src))]>;
Scott Michel66377522007-12-04 22:35:58 +0000314
Scott Michelf0569be2008-12-27 04:51:36 +0000315def CDDf64: RI7Form<0b11101111100, (outs VECREG:$rT), (ins shufaddr:$src),
Scott Michel1a6cdb62008-12-01 17:56:02 +0000316 "cdd\t$rT, $src", ShuffleOp,
317 [(set (v2f64 VECREG:$rT), (SPUshufmask dform2_addr:$src))]>;
318
319def CDXf64: RRForm<0b11101011100, (outs VECREG:$rT), (ins memrr:$src),
Scott Michel203b2d62008-04-30 00:30:08 +0000320 "cdx\t$rT, $src", ShuffleOp,
Scott Michel7a1c9e92008-11-22 23:50:42 +0000321 [(set (v2f64 VECREG:$rT), (SPUshufmask xform_addr:$src))]>;
Scott Michel203b2d62008-04-30 00:30:08 +0000322
Scott Michel66377522007-12-04 22:35:58 +0000323//===----------------------------------------------------------------------===//
324// Constant formation:
325//===----------------------------------------------------------------------===//
326
327def ILHv8i16:
328 RI16Form<0b110000010, (outs VECREG:$rT), (ins s16imm:$val),
329 "ilh\t$rT, $val", ImmLoad,
330 [(set (v8i16 VECREG:$rT), (v8i16 v8i16SExt16Imm:$val))]>;
331
332def ILHr16:
333 RI16Form<0b110000010, (outs R16C:$rT), (ins s16imm:$val),
334 "ilh\t$rT, $val", ImmLoad,
335 [(set R16C:$rT, immSExt16:$val)]>;
336
Scott Michel504c3692007-12-17 22:32:34 +0000337// Cell SPU doesn't have a native 8-bit immediate load, but ILH works ("with
338// the right constant")
339def ILHr8:
340 RI16Form<0b110000010, (outs R8C:$rT), (ins s16imm_i8:$val),
341 "ilh\t$rT, $val", ImmLoad,
342 [(set R8C:$rT, immSExt8:$val)]>;
343
Scott Michel66377522007-12-04 22:35:58 +0000344// IL does sign extension!
Scott Michel66377522007-12-04 22:35:58 +0000345
Scott Michelad2715e2008-03-05 23:02:02 +0000346class ILInst<dag OOL, dag IOL, list<dag> pattern>:
347 RI16Form<0b100000010, OOL, IOL, "il\t$rT, $val",
348 ImmLoad, pattern>;
Scott Michel66377522007-12-04 22:35:58 +0000349
Scott Michelad2715e2008-03-05 23:02:02 +0000350class ILVecInst<ValueType vectype, Operand immtype, PatLeaf xform>:
351 ILInst<(outs VECREG:$rT), (ins immtype:$val),
352 [(set (vectype VECREG:$rT), (vectype xform:$val))]>;
Scott Michel66377522007-12-04 22:35:58 +0000353
Scott Michelad2715e2008-03-05 23:02:02 +0000354class ILRegInst<RegisterClass rclass, Operand immtype, PatLeaf xform>:
355 ILInst<(outs rclass:$rT), (ins immtype:$val),
356 [(set rclass:$rT, xform:$val)]>;
Scott Michel66377522007-12-04 22:35:58 +0000357
Scott Michelad2715e2008-03-05 23:02:02 +0000358multiclass ImmediateLoad
359{
360 def v2i64: ILVecInst<v2i64, s16imm_i64, v2i64SExt16Imm>;
361 def v4i32: ILVecInst<v4i32, s16imm_i32, v4i32SExt16Imm>;
Scott Michel66377522007-12-04 22:35:58 +0000362
Scott Michelad2715e2008-03-05 23:02:02 +0000363 // TODO: Need v2f64, v4f32
Scott Michel66377522007-12-04 22:35:58 +0000364
Scott Michelad2715e2008-03-05 23:02:02 +0000365 def r64: ILRegInst<R64C, s16imm_i64, immSExt16>;
366 def r32: ILRegInst<R32C, s16imm_i32, immSExt16>;
367 def f32: ILRegInst<R32FP, s16imm_f32, fpimmSExt16>;
368 def f64: ILRegInst<R64FP, s16imm_f64, fpimmSExt16>;
369}
Scott Michel66377522007-12-04 22:35:58 +0000370
Scott Michelad2715e2008-03-05 23:02:02 +0000371defm IL : ImmediateLoad;
Scott Michel66377522007-12-04 22:35:58 +0000372
Scott Michelad2715e2008-03-05 23:02:02 +0000373class ILHUInst<dag OOL, dag IOL, list<dag> pattern>:
374 RI16Form<0b010000010, OOL, IOL, "ilhu\t$rT, $val",
375 ImmLoad, pattern>;
Scott Michel66377522007-12-04 22:35:58 +0000376
Scott Michelad2715e2008-03-05 23:02:02 +0000377class ILHUVecInst<ValueType vectype, Operand immtype, PatLeaf xform>:
378 ILHUInst<(outs VECREG:$rT), (ins immtype:$val),
379 [(set (vectype VECREG:$rT), (vectype xform:$val))]>;
380
381class ILHURegInst<RegisterClass rclass, Operand immtype, PatLeaf xform>:
382 ILHUInst<(outs rclass:$rT), (ins immtype:$val),
383 [(set rclass:$rT, xform:$val)]>;
384
385multiclass ImmLoadHalfwordUpper
386{
387 def v2i64: ILHUVecInst<v2i64, u16imm_i64, immILHUvec_i64>;
Scott Michel203b2d62008-04-30 00:30:08 +0000388 def v4i32: ILHUVecInst<v4i32, u16imm_i32, immILHUvec>;
Scott Michelad2715e2008-03-05 23:02:02 +0000389
390 def r64: ILHURegInst<R64C, u16imm_i64, hi16>;
Scott Michel203b2d62008-04-30 00:30:08 +0000391 def r32: ILHURegInst<R32C, u16imm_i32, hi16>;
Scott Michelad2715e2008-03-05 23:02:02 +0000392
393 // Loads the high portion of an address
394 def hi: ILHURegInst<R32C, symbolHi, hi16>;
395
396 // Used in custom lowering constant SFP loads:
397 def f32: ILHURegInst<R32FP, f16imm, hi16_f32>;
398}
399
400defm ILHU : ImmLoadHalfwordUpper;
Scott Michel66377522007-12-04 22:35:58 +0000401
402// Immediate load address (can also be used to load 18-bit unsigned constants,
403// see the zext 16->32 pattern)
Scott Michelad2715e2008-03-05 23:02:02 +0000404
Scott Michela59d4692008-02-23 18:41:37 +0000405class ILAInst<dag OOL, dag IOL, list<dag> pattern>:
406 RI18Form<0b1000010, OOL, IOL, "ila\t$rT, $val",
407 LoadNOP, pattern>;
Scott Michel66377522007-12-04 22:35:58 +0000408
Scott Michelad2715e2008-03-05 23:02:02 +0000409class ILAVecInst<ValueType vectype, Operand immtype, PatLeaf xform>:
410 ILAInst<(outs VECREG:$rT), (ins immtype:$val),
411 [(set (vectype VECREG:$rT), (vectype xform:$val))]>;
412
413class ILARegInst<RegisterClass rclass, Operand immtype, PatLeaf xform>:
414 ILAInst<(outs rclass:$rT), (ins immtype:$val),
415 [(set rclass:$rT, xform:$val)]>;
416
Scott Michela59d4692008-02-23 18:41:37 +0000417multiclass ImmLoadAddress
418{
Scott Michelad2715e2008-03-05 23:02:02 +0000419 def v2i64: ILAVecInst<v2i64, u18imm, v2i64Uns18Imm>;
420 def v4i32: ILAVecInst<v4i32, u18imm, v4i32Uns18Imm>;
Scott Michel66377522007-12-04 22:35:58 +0000421
Scott Michelad2715e2008-03-05 23:02:02 +0000422 def r64: ILARegInst<R64C, u18imm_i64, imm18>;
423 def r32: ILARegInst<R32C, u18imm, imm18>;
424 def f32: ILARegInst<R32FP, f18imm, fpimm18>;
425 def f64: ILARegInst<R64FP, f18imm_f64, fpimm18>;
Scott Michel66377522007-12-04 22:35:58 +0000426
Scott Michelf0569be2008-12-27 04:51:36 +0000427 def hi: ILARegInst<R32C, symbolHi, imm18>;
Scott Michelad2715e2008-03-05 23:02:02 +0000428 def lo: ILARegInst<R32C, symbolLo, imm18>;
Scott Michel66377522007-12-04 22:35:58 +0000429
Scott Michela59d4692008-02-23 18:41:37 +0000430 def lsa: ILAInst<(outs R32C:$rT), (ins symbolLSA:$val),
431 [/* no pattern */]>;
432}
433
434defm ILA : ImmLoadAddress;
Scott Michel66377522007-12-04 22:35:58 +0000435
436// Immediate OR, Halfword Lower: The "other" part of loading large constants
437// into 32-bit registers. See the anonymous pattern Pat<(i32 imm:$imm), ...>
438// Note that these are really two operand instructions, but they're encoded
439// as three operands with the first two arguments tied-to each other.
440
Scott Michelad2715e2008-03-05 23:02:02 +0000441class IOHLInst<dag OOL, dag IOL, list<dag> pattern>:
442 RI16Form<0b100000110, OOL, IOL, "iohl\t$rT, $val",
443 ImmLoad, pattern>,
444 RegConstraint<"$rS = $rT">,
445 NoEncode<"$rS">;
Scott Michel66377522007-12-04 22:35:58 +0000446
Scott Michelad2715e2008-03-05 23:02:02 +0000447class IOHLVecInst<ValueType vectype, Operand immtype /* , PatLeaf xform */>:
448 IOHLInst<(outs VECREG:$rT), (ins VECREG:$rS, immtype:$val),
449 [/* no pattern */]>;
Scott Michel66377522007-12-04 22:35:58 +0000450
Scott Michelad2715e2008-03-05 23:02:02 +0000451class IOHLRegInst<RegisterClass rclass, Operand immtype /* , PatLeaf xform */>:
452 IOHLInst<(outs rclass:$rT), (ins rclass:$rS, immtype:$val),
453 [/* no pattern */]>;
Scott Michel66377522007-12-04 22:35:58 +0000454
Scott Michelad2715e2008-03-05 23:02:02 +0000455multiclass ImmOrHalfwordLower
456{
457 def v2i64: IOHLVecInst<v2i64, u16imm_i64>;
Scott Michel203b2d62008-04-30 00:30:08 +0000458 def v4i32: IOHLVecInst<v4i32, u16imm_i32>;
Scott Michelad2715e2008-03-05 23:02:02 +0000459
460 def r32: IOHLRegInst<R32C, i32imm>;
461 def f32: IOHLRegInst<R32FP, f32imm>;
462
463 def lo: IOHLRegInst<R32C, symbolLo>;
464}
465
466defm IOHL: ImmOrHalfwordLower;
Scott Michel9de5d0d2008-01-11 02:53:15 +0000467
Scott Michel66377522007-12-04 22:35:58 +0000468// Form select mask for bytes using immediate, used in conjunction with the
469// SELB instruction:
470
Scott Michelad2715e2008-03-05 23:02:02 +0000471class FSMBIVec<ValueType vectype>:
472 RI16Form<0b101001100, (outs VECREG:$rT), (ins u16imm:$val),
473 "fsmbi\t$rT, $val",
474 SelectOp,
Scott Michel8bf61e82008-06-02 22:18:03 +0000475 [(set (vectype VECREG:$rT), (SPUselmask (i16 immU16:$val)))]>;
Scott Michel66377522007-12-04 22:35:58 +0000476
Scott Michela59d4692008-02-23 18:41:37 +0000477multiclass FormSelectMaskBytesImm
Scott Michel053c1da2008-01-29 02:16:57 +0000478{
479 def v16i8: FSMBIVec<v16i8>;
480 def v8i16: FSMBIVec<v8i16>;
481 def v4i32: FSMBIVec<v4i32>;
482 def v2i64: FSMBIVec<v2i64>;
483}
Scott Michel66377522007-12-04 22:35:58 +0000484
Scott Michela59d4692008-02-23 18:41:37 +0000485defm FSMBI : FormSelectMaskBytesImm;
486
487// fsmb: Form select mask for bytes. N.B. Input operand, $rA, is 16-bits
Scott Michelf0569be2008-12-27 04:51:36 +0000488class FSMBInst<dag OOL, dag IOL, list<dag> pattern>:
489 RRForm_1<0b01101101100, OOL, IOL, "fsmb\t$rT, $rA", SelectOp,
490 pattern>;
491
492class FSMBRegInst<RegisterClass rclass, ValueType vectype>:
493 FSMBInst<(outs VECREG:$rT), (ins rclass:$rA),
494 [(set (vectype VECREG:$rT), (SPUselmask rclass:$rA))]>;
495
496class FSMBVecInst<ValueType vectype>:
497 FSMBInst<(outs VECREG:$rT), (ins VECREG:$rA),
498 [(set (vectype VECREG:$rT),
499 (SPUselmask (vectype VECREG:$rA)))]>;
500
501multiclass FormSelectMaskBits {
502 def v16i8_r16: FSMBRegInst<R16C, v16i8>;
503 def v16i8: FSMBVecInst<v16i8>;
504}
505
506defm FSMB: FormSelectMaskBits;
Scott Michela59d4692008-02-23 18:41:37 +0000507
508// fsmh: Form select mask for halfwords. N.B., Input operand, $rA, is
509// only 8-bits wide (even though it's input as 16-bits here)
Scott Michelf0569be2008-12-27 04:51:36 +0000510
511class FSMHInst<dag OOL, dag IOL, list<dag> pattern>:
512 RRForm_1<0b10101101100, OOL, IOL, "fsmh\t$rT, $rA", SelectOp,
513 pattern>;
514
515class FSMHRegInst<RegisterClass rclass, ValueType vectype>:
516 FSMHInst<(outs VECREG:$rT), (ins rclass:$rA),
517 [(set (vectype VECREG:$rT), (SPUselmask rclass:$rA))]>;
518
519class FSMHVecInst<ValueType vectype>:
520 FSMHInst<(outs VECREG:$rT), (ins VECREG:$rA),
521 [(set (vectype VECREG:$rT),
522 (SPUselmask (vectype VECREG:$rA)))]>;
523
524multiclass FormSelectMaskHalfword {
525 def v8i16_r16: FSMHRegInst<R16C, v8i16>;
526 def v8i16: FSMHVecInst<v8i16>;
527}
528
529defm FSMH: FormSelectMaskHalfword;
Scott Michela59d4692008-02-23 18:41:37 +0000530
531// fsm: Form select mask for words. Like the other fsm* instructions,
532// only the lower 4 bits of $rA are significant.
Scott Michelf0569be2008-12-27 04:51:36 +0000533
534class FSMInst<dag OOL, dag IOL, list<dag> pattern>:
535 RRForm_1<0b00101101100, OOL, IOL, "fsm\t$rT, $rA", SelectOp,
536 pattern>;
537
538class FSMRegInst<ValueType vectype, RegisterClass rclass>:
539 FSMInst<(outs VECREG:$rT), (ins rclass:$rA),
540 [(set (vectype VECREG:$rT), (SPUselmask rclass:$rA))]>;
541
542class FSMVecInst<ValueType vectype>:
543 FSMInst<(outs VECREG:$rT), (ins VECREG:$rA),
544 [(set (vectype VECREG:$rT), (SPUselmask (vectype VECREG:$rA)))]>;
Scott Michel8bf61e82008-06-02 22:18:03 +0000545
546multiclass FormSelectMaskWord {
Scott Michelf0569be2008-12-27 04:51:36 +0000547 def v4i32: FSMVecInst<v4i32>;
548
549 def r32 : FSMRegInst<v4i32, R32C>;
550 def r16 : FSMRegInst<v4i32, R16C>;
Scott Michel8bf61e82008-06-02 22:18:03 +0000551}
552
553defm FSM : FormSelectMaskWord;
554
555// Special case when used for i64 math operations
556multiclass FormSelectMaskWord64 {
Scott Michelf0569be2008-12-27 04:51:36 +0000557 def r32 : FSMRegInst<v2i64, R32C>;
558 def r16 : FSMRegInst<v2i64, R16C>;
Scott Michel8bf61e82008-06-02 22:18:03 +0000559}
560
561defm FSM64 : FormSelectMaskWord64;
Scott Michel66377522007-12-04 22:35:58 +0000562
563//===----------------------------------------------------------------------===//
564// Integer and Logical Operations:
565//===----------------------------------------------------------------------===//
566
567def AHv8i16:
568 RRForm<0b00010011000, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
569 "ah\t$rT, $rA, $rB", IntegerOp,
570 [(set (v8i16 VECREG:$rT), (int_spu_si_ah VECREG:$rA, VECREG:$rB))]>;
571
572def : Pat<(add (v8i16 VECREG:$rA), (v8i16 VECREG:$rB)),
573 (AHv8i16 VECREG:$rA, VECREG:$rB)>;
574
Scott Michel66377522007-12-04 22:35:58 +0000575def AHr16:
576 RRForm<0b00010011000, (outs R16C:$rT), (ins R16C:$rA, R16C:$rB),
577 "ah\t$rT, $rA, $rB", IntegerOp,
578 [(set R16C:$rT, (add R16C:$rA, R16C:$rB))]>;
579
580def AHIvec:
581 RI10Form<0b10111000, (outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
582 "ahi\t$rT, $rA, $val", IntegerOp,
583 [(set (v8i16 VECREG:$rT), (add (v8i16 VECREG:$rA),
584 v8i16SExt10Imm:$val))]>;
585
Scott Michela59d4692008-02-23 18:41:37 +0000586def AHIr16:
587 RI10Form<0b10111000, (outs R16C:$rT), (ins R16C:$rA, s10imm:$val),
588 "ahi\t$rT, $rA, $val", IntegerOp,
Scott Michel02d711b2008-12-30 23:28:25 +0000589 [(set R16C:$rT, (add R16C:$rA, i16ImmSExt10:$val))]>;
590
591// v4i32, i32 add instruction:
Scott Michel66377522007-12-04 22:35:58 +0000592
Scott Michel1df30c42008-12-29 03:23:36 +0000593class AInst<dag OOL, dag IOL, list<dag> pattern>:
594 RRForm<0b00000011000, OOL, IOL,
595 "a\t$rT, $rA, $rB", IntegerOp,
596 pattern>;
Scott Michel66377522007-12-04 22:35:58 +0000597
Scott Michel1df30c42008-12-29 03:23:36 +0000598class AVecInst<ValueType vectype>:
599 AInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
600 [(set (vectype VECREG:$rT), (add (vectype VECREG:$rA),
601 (vectype VECREG:$rB)))]>;
Scott Michel66377522007-12-04 22:35:58 +0000602
Scott Michel1df30c42008-12-29 03:23:36 +0000603class ARegInst<RegisterClass rclass>:
604 AInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB),
605 [(set rclass:$rT, (add rclass:$rA, rclass:$rB))]>;
606
607multiclass AddInstruction {
608 def v4i32: AVecInst<v4i32>;
609 def v16i8: AVecInst<v16i8>;
610
611 def r32: ARegInst<R32C>;
Scott Michel1df30c42008-12-29 03:23:36 +0000612}
Scott Michel66377522007-12-04 22:35:58 +0000613
Scott Michel1df30c42008-12-29 03:23:36 +0000614defm A : AddInstruction;
Scott Michel504c3692007-12-17 22:32:34 +0000615
Scott Michel02d711b2008-12-30 23:28:25 +0000616class AIInst<dag OOL, dag IOL, list<dag> pattern>:
617 RI10Form<0b00111000, OOL, IOL,
Scott Michel19c10e62009-01-26 03:37:41 +0000618 "ai\t$rT, $rA, $val", IntegerOp,
619 pattern>;
Scott Michel66377522007-12-04 22:35:58 +0000620
Scott Michel02d711b2008-12-30 23:28:25 +0000621class AIVecInst<ValueType vectype, PatLeaf immpred>:
622 AIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
Scott Michel19c10e62009-01-26 03:37:41 +0000623 [(set (vectype VECREG:$rT), (add (vectype VECREG:$rA), immpred:$val))]>;
Scott Michel02d711b2008-12-30 23:28:25 +0000624
625class AIFPVecInst<ValueType vectype, PatLeaf immpred>:
626 AIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
Scott Michel19c10e62009-01-26 03:37:41 +0000627 [/* no pattern */]>;
Scott Michel02d711b2008-12-30 23:28:25 +0000628
629class AIRegInst<RegisterClass rclass, PatLeaf immpred>:
630 AIInst<(outs rclass:$rT), (ins rclass:$rA, s10imm_i32:$val),
Scott Michel19c10e62009-01-26 03:37:41 +0000631 [(set rclass:$rT, (add rclass:$rA, immpred:$val))]>;
Scott Michel02d711b2008-12-30 23:28:25 +0000632
633// This is used to add epsilons to floating point numbers in the f32 fdiv code:
634class AIFPInst<RegisterClass rclass, PatLeaf immpred>:
635 AIInst<(outs rclass:$rT), (ins rclass:$rA, s10imm_i32:$val),
Scott Michel19c10e62009-01-26 03:37:41 +0000636 [/* no pattern */]>;
Scott Michel02d711b2008-12-30 23:28:25 +0000637
638multiclass AddImmediate {
639 def v4i32: AIVecInst<v4i32, v4i32SExt10Imm>;
640
641 def r32: AIRegInst<R32C, i32ImmSExt10>;
642
643 def v4f32: AIFPVecInst<v4f32, v4i32SExt10Imm>;
644 def f32: AIFPInst<R32FP, i32ImmSExt10>;
645}
646
647defm AI : AddImmediate;
Scott Michel66377522007-12-04 22:35:58 +0000648
Scott Michel504c3692007-12-17 22:32:34 +0000649def SFHvec:
650 RRForm<0b00010010000, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
651 "sfh\t$rT, $rA, $rB", IntegerOp,
652 [(set (v8i16 VECREG:$rT), (sub (v8i16 VECREG:$rA),
653 (v8i16 VECREG:$rB)))]>;
Scott Michel66377522007-12-04 22:35:58 +0000654
Scott Michel504c3692007-12-17 22:32:34 +0000655def SFHr16:
656 RRForm<0b00010010000, (outs R16C:$rT), (ins R16C:$rA, R16C:$rB),
657 "sfh\t$rT, $rA, $rB", IntegerOp,
Kalle Raiskila26c4cf4c2010-05-10 08:13:49 +0000658 [(set R16C:$rT, (sub R16C:$rB, R16C:$rA))]>;
Scott Michel66377522007-12-04 22:35:58 +0000659
660def SFHIvec:
661 RI10Form<0b10110000, (outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
662 "sfhi\t$rT, $rA, $val", IntegerOp,
663 [(set (v8i16 VECREG:$rT), (sub v8i16SExt10Imm:$val,
664 (v8i16 VECREG:$rA)))]>;
665
666def SFHIr16 : RI10Form<0b10110000, (outs R16C:$rT), (ins R16C:$rA, s10imm:$val),
667 "sfhi\t$rT, $rA, $val", IntegerOp,
668 [(set R16C:$rT, (sub i16ImmSExt10:$val, R16C:$rA))]>;
669
670def SFvec : RRForm<0b00000010000, (outs VECREG:$rT),
671 (ins VECREG:$rA, VECREG:$rB),
672 "sf\t$rT, $rA, $rB", IntegerOp,
Kalle Raiskila26c4cf4c2010-05-10 08:13:49 +0000673 [(set (v4i32 VECREG:$rT), (sub (v4i32 VECREG:$rB), (v4i32 VECREG:$rA)))]>;
Scott Michel66377522007-12-04 22:35:58 +0000674
675def SFr32 : RRForm<0b00000010000, (outs R32C:$rT), (ins R32C:$rA, R32C:$rB),
676 "sf\t$rT, $rA, $rB", IntegerOp,
Kalle Raiskila26c4cf4c2010-05-10 08:13:49 +0000677 [(set R32C:$rT, (sub R32C:$rB, R32C:$rA))]>;
Scott Michel66377522007-12-04 22:35:58 +0000678
679def SFIvec:
680 RI10Form<0b00110000, (outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
681 "sfi\t$rT, $rA, $val", IntegerOp,
682 [(set (v4i32 VECREG:$rT), (sub v4i32SExt10Imm:$val,
683 (v4i32 VECREG:$rA)))]>;
684
685def SFIr32 : RI10Form<0b00110000, (outs R32C:$rT),
686 (ins R32C:$rA, s10imm_i32:$val),
687 "sfi\t$rT, $rA, $val", IntegerOp,
688 [(set R32C:$rT, (sub i32ImmSExt10:$val, R32C:$rA))]>;
689
690// ADDX: only available in vector form, doesn't match a pattern.
Scott Michel8bf61e82008-06-02 22:18:03 +0000691class ADDXInst<dag OOL, dag IOL, list<dag> pattern>:
692 RRForm<0b00000010110, OOL, IOL,
693 "addx\t$rT, $rA, $rB",
694 IntegerOp, pattern>;
695
696class ADDXVecInst<ValueType vectype>:
697 ADDXInst<(outs VECREG:$rT),
698 (ins VECREG:$rA, VECREG:$rB, VECREG:$rCarry),
Scott Michel94bd57e2009-01-15 04:41:47 +0000699 [/* no pattern */]>,
Scott Michel66377522007-12-04 22:35:58 +0000700 RegConstraint<"$rCarry = $rT">,
701 NoEncode<"$rCarry">;
702
Scott Michel8bf61e82008-06-02 22:18:03 +0000703class ADDXRegInst<RegisterClass rclass>:
704 ADDXInst<(outs rclass:$rT),
705 (ins rclass:$rA, rclass:$rB, rclass:$rCarry),
Scott Michel94bd57e2009-01-15 04:41:47 +0000706 [/* no pattern */]>,
Scott Michel66377522007-12-04 22:35:58 +0000707 RegConstraint<"$rCarry = $rT">,
708 NoEncode<"$rCarry">;
709
Scott Michel8bf61e82008-06-02 22:18:03 +0000710multiclass AddExtended {
711 def v2i64 : ADDXVecInst<v2i64>;
712 def v4i32 : ADDXVecInst<v4i32>;
713 def r64 : ADDXRegInst<R64C>;
714 def r32 : ADDXRegInst<R32C>;
715}
716
717defm ADDX : AddExtended;
718
719// CG: Generate carry for add
720class CGInst<dag OOL, dag IOL, list<dag> pattern>:
721 RRForm<0b01000011000, OOL, IOL,
722 "cg\t$rT, $rA, $rB",
723 IntegerOp, pattern>;
724
725class CGVecInst<ValueType vectype>:
726 CGInst<(outs VECREG:$rT),
727 (ins VECREG:$rA, VECREG:$rB),
Scott Michel94bd57e2009-01-15 04:41:47 +0000728 [/* no pattern */]>;
Scott Michel8bf61e82008-06-02 22:18:03 +0000729
730class CGRegInst<RegisterClass rclass>:
731 CGInst<(outs rclass:$rT),
732 (ins rclass:$rA, rclass:$rB),
Scott Michel94bd57e2009-01-15 04:41:47 +0000733 [/* no pattern */]>;
Scott Michel8bf61e82008-06-02 22:18:03 +0000734
735multiclass CarryGenerate {
736 def v2i64 : CGVecInst<v2i64>;
737 def v4i32 : CGVecInst<v4i32>;
738 def r64 : CGRegInst<R64C>;
739 def r32 : CGRegInst<R32C>;
740}
741
742defm CG : CarryGenerate;
743
744// SFX: Subract from, extended. This is used in conjunction with BG to subtract
745// with carry (borrow, in this case)
746class SFXInst<dag OOL, dag IOL, list<dag> pattern>:
747 RRForm<0b10000010110, OOL, IOL,
748 "sfx\t$rT, $rA, $rB",
749 IntegerOp, pattern>;
750
751class SFXVecInst<ValueType vectype>:
752 SFXInst<(outs VECREG:$rT),
753 (ins VECREG:$rA, VECREG:$rB, VECREG:$rCarry),
Scott Michel94bd57e2009-01-15 04:41:47 +0000754 [/* no pattern */]>,
Scott Michel66377522007-12-04 22:35:58 +0000755 RegConstraint<"$rCarry = $rT">,
756 NoEncode<"$rCarry">;
757
Scott Michel8bf61e82008-06-02 22:18:03 +0000758class SFXRegInst<RegisterClass rclass>:
759 SFXInst<(outs rclass:$rT),
760 (ins rclass:$rA, rclass:$rB, rclass:$rCarry),
Scott Michel94bd57e2009-01-15 04:41:47 +0000761 [/* no pattern */]>,
Scott Michel8bf61e82008-06-02 22:18:03 +0000762 RegConstraint<"$rCarry = $rT">,
763 NoEncode<"$rCarry">;
764
765multiclass SubtractExtended {
766 def v2i64 : SFXVecInst<v2i64>;
767 def v4i32 : SFXVecInst<v4i32>;
768 def r64 : SFXRegInst<R64C>;
769 def r32 : SFXRegInst<R32C>;
770}
771
772defm SFX : SubtractExtended;
773
Scott Michel66377522007-12-04 22:35:58 +0000774// BG: only available in vector form, doesn't match a pattern.
Scott Michel8bf61e82008-06-02 22:18:03 +0000775class BGInst<dag OOL, dag IOL, list<dag> pattern>:
776 RRForm<0b01000010000, OOL, IOL,
777 "bg\t$rT, $rA, $rB",
778 IntegerOp, pattern>;
Scott Michel66377522007-12-04 22:35:58 +0000779
Scott Michel8bf61e82008-06-02 22:18:03 +0000780class BGVecInst<ValueType vectype>:
781 BGInst<(outs VECREG:$rT),
782 (ins VECREG:$rA, VECREG:$rB),
Scott Michel94bd57e2009-01-15 04:41:47 +0000783 [/* no pattern */]>;
Scott Michel8bf61e82008-06-02 22:18:03 +0000784
785class BGRegInst<RegisterClass rclass>:
786 BGInst<(outs rclass:$rT),
787 (ins rclass:$rA, rclass:$rB),
Scott Michel94bd57e2009-01-15 04:41:47 +0000788 [/* no pattern */]>;
Scott Michel8bf61e82008-06-02 22:18:03 +0000789
790multiclass BorrowGenerate {
791 def v4i32 : BGVecInst<v4i32>;
792 def v2i64 : BGVecInst<v2i64>;
793 def r64 : BGRegInst<R64C>;
794 def r32 : BGRegInst<R32C>;
795}
796
797defm BG : BorrowGenerate;
798
799// BGX: Borrow generate, extended.
Scott Michel66377522007-12-04 22:35:58 +0000800def BGXvec:
801 RRForm<0b11000010110, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB,
Scott Michelf0569be2008-12-27 04:51:36 +0000802 VECREG:$rCarry),
Scott Michel66377522007-12-04 22:35:58 +0000803 "bgx\t$rT, $rA, $rB", IntegerOp,
804 []>,
805 RegConstraint<"$rCarry = $rT">,
806 NoEncode<"$rCarry">;
807
808// Halfword multiply variants:
809// N.B: These can be used to build up larger quantities (16x16 -> 32)
810
811def MPYv8i16:
812 RRForm<0b00100011110, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
813 "mpy\t$rT, $rA, $rB", IntegerMulDiv,
Scott Michel02d711b2008-12-30 23:28:25 +0000814 [/* no pattern */]>;
Scott Michel66377522007-12-04 22:35:58 +0000815
816def MPYr16:
817 RRForm<0b00100011110, (outs R16C:$rT), (ins R16C:$rA, R16C:$rB),
818 "mpy\t$rT, $rA, $rB", IntegerMulDiv,
819 [(set R16C:$rT, (mul R16C:$rA, R16C:$rB))]>;
820
Scott Michel1df30c42008-12-29 03:23:36 +0000821// Unsigned 16-bit multiply:
822
823class MPYUInst<dag OOL, dag IOL, list<dag> pattern>:
824 RRForm<0b00110011110, OOL, IOL,
825 "mpyu\t$rT, $rA, $rB", IntegerMulDiv,
826 pattern>;
827
Scott Michel66377522007-12-04 22:35:58 +0000828def MPYUv4i32:
Scott Michel1df30c42008-12-29 03:23:36 +0000829 MPYUInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
Scott Michel02d711b2008-12-30 23:28:25 +0000830 [/* no pattern */]>;
Scott Michel66377522007-12-04 22:35:58 +0000831
832def MPYUr16:
Scott Michel1df30c42008-12-29 03:23:36 +0000833 MPYUInst<(outs R32C:$rT), (ins R16C:$rA, R16C:$rB),
834 [(set R32C:$rT, (mul (zext R16C:$rA), (zext R16C:$rB)))]>;
Scott Michel66377522007-12-04 22:35:58 +0000835
836def MPYUr32:
Scott Michel1df30c42008-12-29 03:23:36 +0000837 MPYUInst<(outs R32C:$rT), (ins R32C:$rA, R32C:$rB),
Scott Michel02d711b2008-12-30 23:28:25 +0000838 [/* no pattern */]>;
Scott Michel66377522007-12-04 22:35:58 +0000839
Scott Michel1df30c42008-12-29 03:23:36 +0000840// mpyi: multiply 16 x s10imm -> 32 result.
841
842class MPYIInst<dag OOL, dag IOL, list<dag> pattern>:
843 RI10Form<0b00101110, OOL, IOL,
Scott Michel66377522007-12-04 22:35:58 +0000844 "mpyi\t$rT, $rA, $val", IntegerMulDiv,
Scott Michel1df30c42008-12-29 03:23:36 +0000845 pattern>;
846
847def MPYIvec:
848 MPYIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
849 [(set (v8i16 VECREG:$rT),
850 (mul (v8i16 VECREG:$rA), v8i16SExt10Imm:$val))]>;
Scott Michel66377522007-12-04 22:35:58 +0000851
852def MPYIr16:
Scott Michel1df30c42008-12-29 03:23:36 +0000853 MPYIInst<(outs R16C:$rT), (ins R16C:$rA, s10imm:$val),
854 [(set R16C:$rT, (mul R16C:$rA, i16ImmSExt10:$val))]>;
Scott Michel66377522007-12-04 22:35:58 +0000855
856// mpyui: same issues as other multiplies, plus, this doesn't match a
857// pattern... but may be used during target DAG selection or lowering
Scott Michel1df30c42008-12-29 03:23:36 +0000858
859class MPYUIInst<dag OOL, dag IOL, list<dag> pattern>:
860 RI10Form<0b10101110, OOL, IOL,
861 "mpyui\t$rT, $rA, $val", IntegerMulDiv,
862 pattern>;
863
Scott Michel66377522007-12-04 22:35:58 +0000864def MPYUIvec:
Scott Michel1df30c42008-12-29 03:23:36 +0000865 MPYUIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
866 []>;
Scott Michel66377522007-12-04 22:35:58 +0000867
868def MPYUIr16:
Scott Michel1df30c42008-12-29 03:23:36 +0000869 MPYUIInst<(outs R16C:$rT), (ins R16C:$rA, s10imm:$val),
870 []>;
Scott Michel66377522007-12-04 22:35:58 +0000871
872// mpya: 16 x 16 + 16 -> 32 bit result
Scott Michel1df30c42008-12-29 03:23:36 +0000873class MPYAInst<dag OOL, dag IOL, list<dag> pattern>:
874 RRRForm<0b0011, OOL, IOL,
875 "mpya\t$rT, $rA, $rB, $rC", IntegerMulDiv,
876 pattern>;
877
Scott Michel94bd57e2009-01-15 04:41:47 +0000878def MPYAv4i32:
Scott Michel1df30c42008-12-29 03:23:36 +0000879 MPYAInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB, VECREG:$rC),
880 [(set (v4i32 VECREG:$rT),
881 (add (v4i32 (bitconvert (mul (v8i16 VECREG:$rA),
882 (v8i16 VECREG:$rB)))),
883 (v4i32 VECREG:$rC)))]>;
Scott Michel66377522007-12-04 22:35:58 +0000884
885def MPYAr32:
Scott Michel1df30c42008-12-29 03:23:36 +0000886 MPYAInst<(outs R32C:$rT), (ins R16C:$rA, R16C:$rB, R32C:$rC),
887 [(set R32C:$rT, (add (sext (mul R16C:$rA, R16C:$rB)),
888 R32C:$rC))]>;
889
890def MPYAr32_sext:
891 MPYAInst<(outs R32C:$rT), (ins R16C:$rA, R16C:$rB, R32C:$rC),
892 [(set R32C:$rT, (add (mul (sext R16C:$rA), (sext R16C:$rB)),
893 R32C:$rC))]>;
Scott Michel66377522007-12-04 22:35:58 +0000894
895def MPYAr32_sextinreg:
Scott Michel1df30c42008-12-29 03:23:36 +0000896 MPYAInst<(outs R32C:$rT), (ins R32C:$rA, R32C:$rB, R32C:$rC),
897 [(set R32C:$rT, (add (mul (sext_inreg R32C:$rA, i16),
898 (sext_inreg R32C:$rB, i16)),
899 R32C:$rC))]>;
Scott Michel66377522007-12-04 22:35:58 +0000900
901// mpyh: multiply high, used to synthesize 32-bit multiplies
Scott Michel1df30c42008-12-29 03:23:36 +0000902class MPYHInst<dag OOL, dag IOL, list<dag> pattern>:
903 RRForm<0b10100011110, OOL, IOL,
904 "mpyh\t$rT, $rA, $rB", IntegerMulDiv,
905 pattern>;
906
Scott Michel66377522007-12-04 22:35:58 +0000907def MPYHv4i32:
Scott Michel1df30c42008-12-29 03:23:36 +0000908 MPYHInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
Scott Michel02d711b2008-12-30 23:28:25 +0000909 [/* no pattern */]>;
Scott Michel66377522007-12-04 22:35:58 +0000910
911def MPYHr32:
Scott Michel1df30c42008-12-29 03:23:36 +0000912 MPYHInst<(outs R32C:$rT), (ins R32C:$rA, R32C:$rB),
Scott Michel02d711b2008-12-30 23:28:25 +0000913 [/* no pattern */]>;
Scott Michel66377522007-12-04 22:35:58 +0000914
915// mpys: multiply high and shift right (returns the top half of
916// a 16-bit multiply, sign extended to 32 bits.)
Scott Michel66377522007-12-04 22:35:58 +0000917
Scott Michel02d711b2008-12-30 23:28:25 +0000918class MPYSInst<dag OOL, dag IOL>:
919 RRForm<0b11100011110, OOL, IOL,
Scott Michel66377522007-12-04 22:35:58 +0000920 "mpys\t$rT, $rA, $rB", IntegerMulDiv,
Scott Michel02d711b2008-12-30 23:28:25 +0000921 [/* no pattern */]>;
922
Scott Michel94bd57e2009-01-15 04:41:47 +0000923def MPYSv4i32:
Scott Michel02d711b2008-12-30 23:28:25 +0000924 MPYSInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB)>;
925
926def MPYSr16:
927 MPYSInst<(outs R32C:$rT), (ins R16C:$rA, R16C:$rB)>;
Scott Michel66377522007-12-04 22:35:58 +0000928
929// mpyhh: multiply high-high (returns the 32-bit result from multiplying
930// the top 16 bits of the $rA, $rB)
Scott Michel02d711b2008-12-30 23:28:25 +0000931
932class MPYHHInst<dag OOL, dag IOL>:
933 RRForm<0b01100011110, OOL, IOL,
934 "mpyhh\t$rT, $rA, $rB", IntegerMulDiv,
935 [/* no pattern */]>;
936
Scott Michel66377522007-12-04 22:35:58 +0000937def MPYHHv8i16:
Scott Michel02d711b2008-12-30 23:28:25 +0000938 MPYHHInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB)>;
Scott Michel66377522007-12-04 22:35:58 +0000939
940def MPYHHr32:
Scott Michel02d711b2008-12-30 23:28:25 +0000941 MPYHHInst<(outs R32C:$rT), (ins R32C:$rA, R32C:$rB)>;
Scott Michel66377522007-12-04 22:35:58 +0000942
943// mpyhha: Multiply high-high, add to $rT:
Scott Michel66377522007-12-04 22:35:58 +0000944
Scott Michel02d711b2008-12-30 23:28:25 +0000945class MPYHHAInst<dag OOL, dag IOL>:
946 RRForm<0b01100010110, OOL, IOL,
Scott Michel66377522007-12-04 22:35:58 +0000947 "mpyhha\t$rT, $rA, $rB", IntegerMulDiv,
Scott Michel02d711b2008-12-30 23:28:25 +0000948 [/* no pattern */]>;
949
950def MPYHHAvec:
951 MPYHHAInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB)>;
952
953def MPYHHAr32:
954 MPYHHAInst<(outs R32C:$rT), (ins R32C:$rA, R32C:$rB)>;
Scott Michel66377522007-12-04 22:35:58 +0000955
Scott Michel94bd57e2009-01-15 04:41:47 +0000956// mpyhhu: Multiply high-high, unsigned, e.g.:
957//
958// +-------+-------+ +-------+-------+ +---------+
959// | a0 . a1 | x | b0 . b1 | = | a0 x b0 |
960// +-------+-------+ +-------+-------+ +---------+
961//
962// where a0, b0 are the upper 16 bits of the 32-bit word
Scott Michel66377522007-12-04 22:35:58 +0000963
Scott Michel02d711b2008-12-30 23:28:25 +0000964class MPYHHUInst<dag OOL, dag IOL>:
965 RRForm<0b01110011110, OOL, IOL,
Scott Michel66377522007-12-04 22:35:58 +0000966 "mpyhhu\t$rT, $rA, $rB", IntegerMulDiv,
Scott Michel02d711b2008-12-30 23:28:25 +0000967 [/* no pattern */]>;
968
Scott Michel94bd57e2009-01-15 04:41:47 +0000969def MPYHHUv4i32:
Scott Michel02d711b2008-12-30 23:28:25 +0000970 MPYHHUInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB)>;
971
972def MPYHHUr32:
973 MPYHHUInst<(outs R32C:$rT), (ins R32C:$rA, R32C:$rB)>;
Scott Michel66377522007-12-04 22:35:58 +0000974
975// mpyhhau: Multiply high-high, unsigned
Scott Michel02d711b2008-12-30 23:28:25 +0000976
977class MPYHHAUInst<dag OOL, dag IOL>:
978 RRForm<0b01110010110, OOL, IOL,
979 "mpyhhau\t$rT, $rA, $rB", IntegerMulDiv,
980 [/* no pattern */]>;
981
Scott Michel66377522007-12-04 22:35:58 +0000982def MPYHHAUvec:
Scott Michel02d711b2008-12-30 23:28:25 +0000983 MPYHHAUInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB)>;
984
Scott Michel66377522007-12-04 22:35:58 +0000985def MPYHHAUr32:
Scott Michel02d711b2008-12-30 23:28:25 +0000986 MPYHHAUInst<(outs R32C:$rT), (ins R32C:$rA, R32C:$rB)>;
Scott Michel1df30c42008-12-29 03:23:36 +0000987
988//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
Scott Michel66377522007-12-04 22:35:58 +0000989// clz: Count leading zeroes
Scott Michel1df30c42008-12-29 03:23:36 +0000990//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
Scott Michelf0569be2008-12-27 04:51:36 +0000991class CLZInst<dag OOL, dag IOL, list<dag> pattern>:
992 RRForm_1<0b10100101010, OOL, IOL, "clz\t$rT, $rA",
993 IntegerOp, pattern>;
Scott Michel66377522007-12-04 22:35:58 +0000994
Scott Michelf0569be2008-12-27 04:51:36 +0000995class CLZRegInst<RegisterClass rclass>:
996 CLZInst<(outs rclass:$rT), (ins rclass:$rA),
Scott Michel02d711b2008-12-30 23:28:25 +0000997 [(set rclass:$rT, (ctlz rclass:$rA))]>;
Scott Michelf0569be2008-12-27 04:51:36 +0000998
999class CLZVecInst<ValueType vectype>:
1000 CLZInst<(outs VECREG:$rT), (ins VECREG:$rA),
1001 [(set (vectype VECREG:$rT), (ctlz (vectype VECREG:$rA)))]>;
1002
1003multiclass CountLeadingZeroes {
1004 def v4i32 : CLZVecInst<v4i32>;
1005 def r32 : CLZRegInst<R32C>;
1006}
1007
1008defm CLZ : CountLeadingZeroes;
Scott Michel66377522007-12-04 22:35:58 +00001009
1010// cntb: Count ones in bytes (aka "population count")
Scott Michelf0569be2008-12-27 04:51:36 +00001011//
Scott Michel66377522007-12-04 22:35:58 +00001012// NOTE: This instruction is really a vector instruction, but the custom
1013// lowering code uses it in unorthodox ways to support CTPOP for other
1014// data types!
Scott Michelf0569be2008-12-27 04:51:36 +00001015
Scott Michel66377522007-12-04 22:35:58 +00001016def CNTBv16i8:
1017 RRForm_1<0b00101101010, (outs VECREG:$rT), (ins VECREG:$rA),
1018 "cntb\t$rT, $rA", IntegerOp,
Scott Michel8bf61e82008-06-02 22:18:03 +00001019 [(set (v16i8 VECREG:$rT), (SPUcntb (v16i8 VECREG:$rA)))]>;
Scott Michel66377522007-12-04 22:35:58 +00001020
1021def CNTBv8i16 :
1022 RRForm_1<0b00101101010, (outs VECREG:$rT), (ins VECREG:$rA),
1023 "cntb\t$rT, $rA", IntegerOp,
Scott Michel8bf61e82008-06-02 22:18:03 +00001024 [(set (v8i16 VECREG:$rT), (SPUcntb (v8i16 VECREG:$rA)))]>;
Scott Michel66377522007-12-04 22:35:58 +00001025
1026def CNTBv4i32 :
1027 RRForm_1<0b00101101010, (outs VECREG:$rT), (ins VECREG:$rA),
1028 "cntb\t$rT, $rA", IntegerOp,
Scott Michel8bf61e82008-06-02 22:18:03 +00001029 [(set (v4i32 VECREG:$rT), (SPUcntb (v4i32 VECREG:$rA)))]>;
Scott Michel66377522007-12-04 22:35:58 +00001030
Scott Michelf0569be2008-12-27 04:51:36 +00001031// gbb: Gather the low order bits from each byte in $rA into a single 16-bit
1032// quantity stored into $rT's slot 0, upper 16 bits are zeroed, as are
1033// slots 1-3.
1034//
1035// Note: This instruction "pairs" with the fsmb instruction for all of the
1036// various types defined here.
1037//
1038// Note 2: The "VecInst" and "RegInst" forms refer to the result being either
1039// a vector or register.
1040
1041class GBBInst<dag OOL, dag IOL, list<dag> pattern>:
1042 RRForm_1<0b01001101100, OOL, IOL, "gbb\t$rT, $rA", GatherOp, pattern>;
1043
1044class GBBRegInst<RegisterClass rclass, ValueType vectype>:
1045 GBBInst<(outs rclass:$rT), (ins VECREG:$rA),
Scott Michel21213e72009-01-06 23:10:38 +00001046 [/* no pattern */]>;
Scott Michelf0569be2008-12-27 04:51:36 +00001047
1048class GBBVecInst<ValueType vectype>:
1049 GBBInst<(outs VECREG:$rT), (ins VECREG:$rA),
Scott Michel21213e72009-01-06 23:10:38 +00001050 [/* no pattern */]>;
Scott Michelf0569be2008-12-27 04:51:36 +00001051
1052multiclass GatherBitsFromBytes {
1053 def v16i8_r32: GBBRegInst<R32C, v16i8>;
1054 def v16i8_r16: GBBRegInst<R16C, v16i8>;
1055 def v16i8: GBBVecInst<v16i8>;
1056}
1057
1058defm GBB: GatherBitsFromBytes;
Scott Michel66377522007-12-04 22:35:58 +00001059
1060// gbh: Gather all low order bits from each halfword in $rA into a single
Scott Michelf0569be2008-12-27 04:51:36 +00001061// 8-bit quantity stored in $rT's slot 0, with the upper bits of $rT set to 0
1062// and slots 1-3 also set to 0.
1063//
1064// See notes for GBBInst, above.
1065
1066class GBHInst<dag OOL, dag IOL, list<dag> pattern>:
1067 RRForm_1<0b10001101100, OOL, IOL, "gbh\t$rT, $rA", GatherOp,
1068 pattern>;
1069
1070class GBHRegInst<RegisterClass rclass, ValueType vectype>:
1071 GBHInst<(outs rclass:$rT), (ins VECREG:$rA),
Scott Michel21213e72009-01-06 23:10:38 +00001072 [/* no pattern */]>;
Scott Michelf0569be2008-12-27 04:51:36 +00001073
1074class GBHVecInst<ValueType vectype>:
1075 GBHInst<(outs VECREG:$rT), (ins VECREG:$rA),
Scott Michel21213e72009-01-06 23:10:38 +00001076 [/* no pattern */]>;
Scott Michelf0569be2008-12-27 04:51:36 +00001077
1078multiclass GatherBitsHalfword {
1079 def v8i16_r32: GBHRegInst<R32C, v8i16>;
1080 def v8i16_r16: GBHRegInst<R16C, v8i16>;
1081 def v8i16: GBHVecInst<v8i16>;
1082}
1083
1084defm GBH: GatherBitsHalfword;
Scott Michel66377522007-12-04 22:35:58 +00001085
1086// gb: Gather all low order bits from each word in $rA into a single
Scott Michelf0569be2008-12-27 04:51:36 +00001087// 4-bit quantity stored in $rT's slot 0, upper bits in $rT set to 0,
1088// as well as slots 1-3.
1089//
1090// See notes for gbb, above.
1091
1092class GBInst<dag OOL, dag IOL, list<dag> pattern>:
1093 RRForm_1<0b00001101100, OOL, IOL, "gb\t$rT, $rA", GatherOp,
1094 pattern>;
1095
1096class GBRegInst<RegisterClass rclass, ValueType vectype>:
1097 GBInst<(outs rclass:$rT), (ins VECREG:$rA),
Scott Michel21213e72009-01-06 23:10:38 +00001098 [/* no pattern */]>;
Scott Michelf0569be2008-12-27 04:51:36 +00001099
1100class GBVecInst<ValueType vectype>:
1101 GBInst<(outs VECREG:$rT), (ins VECREG:$rA),
Scott Michel21213e72009-01-06 23:10:38 +00001102 [/* no pattern */]>;
Scott Michelf0569be2008-12-27 04:51:36 +00001103
1104multiclass GatherBitsWord {
1105 def v4i32_r32: GBRegInst<R32C, v4i32>;
1106 def v4i32_r16: GBRegInst<R16C, v4i32>;
1107 def v4i32: GBVecInst<v4i32>;
1108}
1109
1110defm GB: GatherBitsWord;
Scott Michel66377522007-12-04 22:35:58 +00001111
1112// avgb: average bytes
1113def AVGB:
1114 RRForm<0b11001011000, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1115 "avgb\t$rT, $rA, $rB", ByteOp,
1116 []>;
1117
1118// absdb: absolute difference of bytes
1119def ABSDB:
1120 RRForm<0b11001010000, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1121 "absdb\t$rT, $rA, $rB", ByteOp,
1122 []>;
1123
1124// sumb: sum bytes into halfwords
1125def SUMB:
1126 RRForm<0b11001010010, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1127 "sumb\t$rT, $rA, $rB", ByteOp,
1128 []>;
1129
1130// Sign extension operations:
Scott Michel8bf61e82008-06-02 22:18:03 +00001131class XSBHInst<dag OOL, dag IOL, list<dag> pattern>:
1132 RRForm_1<0b01101101010, OOL, IOL,
1133 "xsbh\t$rDst, $rSrc",
1134 IntegerOp, pattern>;
Scott Michel66377522007-12-04 22:35:58 +00001135
Scott Micheldd950092009-01-06 03:36:14 +00001136class XSBHInRegInst<RegisterClass rclass, list<dag> pattern>:
Scott Michel8bf61e82008-06-02 22:18:03 +00001137 XSBHInst<(outs rclass:$rDst), (ins rclass:$rSrc),
Scott Micheldd950092009-01-06 03:36:14 +00001138 pattern>;
Scott Michel8bf61e82008-06-02 22:18:03 +00001139
1140multiclass ExtendByteHalfword {
Chris Lattnere9eda0f2010-03-19 04:53:47 +00001141 def v16i8: XSBHInst<(outs VECREG:$rDst), (ins VECREG:$rSrc),
1142 [
1143 /*(set (v8i16 VECREG:$rDst), (sext (v8i16 VECREG:$rSrc)))*/]>;
Scott Micheldd950092009-01-06 03:36:14 +00001144 def r8: XSBHInst<(outs R16C:$rDst), (ins R8C:$rSrc),
1145 [(set R16C:$rDst, (sext R8C:$rSrc))]>;
1146 def r16: XSBHInRegInst<R16C,
1147 [(set R16C:$rDst, (sext_inreg R16C:$rSrc, i8))]>;
Scott Michel8bf61e82008-06-02 22:18:03 +00001148
1149 // 32-bit form for XSBH: used to sign extend 8-bit quantities to 16-bit
1150 // quantities to 32-bit quantities via a 32-bit register (see the sext 8->32
1151 // pattern below). Intentionally doesn't match a pattern because we want the
1152 // sext 8->32 pattern to do the work for us, namely because we need the extra
1153 // XSHWr32.
Scott Micheldd950092009-01-06 03:36:14 +00001154 def r32: XSBHInRegInst<R32C, [/* no pattern */]>;
1155
1156 // Same as the 32-bit version, but for i64
1157 def r64: XSBHInRegInst<R64C, [/* no pattern */]>;
Scott Michel8bf61e82008-06-02 22:18:03 +00001158}
1159
1160defm XSBH : ExtendByteHalfword;
1161
Scott Michel66377522007-12-04 22:35:58 +00001162// Sign extend halfwords to words:
Scott Michel66377522007-12-04 22:35:58 +00001163
Scott Micheldd950092009-01-06 03:36:14 +00001164class XSHWInst<dag OOL, dag IOL, list<dag> pattern>:
1165 RRForm_1<0b01101101010, OOL, IOL, "xshw\t$rDest, $rSrc",
1166 IntegerOp, pattern>;
Scott Michel66377522007-12-04 22:35:58 +00001167
Scott Micheldd950092009-01-06 03:36:14 +00001168class XSHWVecInst<ValueType in_vectype, ValueType out_vectype>:
1169 XSHWInst<(outs VECREG:$rDest), (ins VECREG:$rSrc),
1170 [(set (out_vectype VECREG:$rDest),
1171 (sext (in_vectype VECREG:$rSrc)))]>;
1172
1173class XSHWInRegInst<RegisterClass rclass, list<dag> pattern>:
1174 XSHWInst<(outs rclass:$rDest), (ins rclass:$rSrc),
1175 pattern>;
1176
1177class XSHWRegInst<RegisterClass rclass>:
1178 XSHWInst<(outs rclass:$rDest), (ins R16C:$rSrc),
1179 [(set rclass:$rDest, (sext R16C:$rSrc))]>;
1180
1181multiclass ExtendHalfwordWord {
1182 def v4i32: XSHWVecInst<v4i32, v8i16>;
1183
1184 def r16: XSHWRegInst<R32C>;
1185
1186 def r32: XSHWInRegInst<R32C,
1187 [(set R32C:$rDest, (sext_inreg R32C:$rSrc, i16))]>;
1188 def r64: XSHWInRegInst<R64C, [/* no pattern */]>;
1189}
1190
1191defm XSHW : ExtendHalfwordWord;
Scott Michel66377522007-12-04 22:35:58 +00001192
Scott Micheled741dd2009-01-05 01:34:35 +00001193// Sign-extend words to doublewords (32->64 bits)
Scott Michel66377522007-12-04 22:35:58 +00001194
Scott Micheled741dd2009-01-05 01:34:35 +00001195class XSWDInst<dag OOL, dag IOL, list<dag> pattern>:
Scott Micheldd950092009-01-06 03:36:14 +00001196 RRForm_1<0b01100101010, OOL, IOL, "xswd\t$rDst, $rSrc",
1197 IntegerOp, pattern>;
Scott Micheled741dd2009-01-05 01:34:35 +00001198
1199class XSWDVecInst<ValueType in_vectype, ValueType out_vectype>:
1200 XSWDInst<(outs VECREG:$rDst), (ins VECREG:$rSrc),
Chris Lattnere9eda0f2010-03-19 04:53:47 +00001201 [/*(set (out_vectype VECREG:$rDst),
1202 (sext (out_vectype VECREG:$rSrc)))*/]>;
Scott Micheled741dd2009-01-05 01:34:35 +00001203
1204class XSWDRegInst<RegisterClass in_rclass, RegisterClass out_rclass>:
1205 XSWDInst<(outs out_rclass:$rDst), (ins in_rclass:$rSrc),
1206 [(set out_rclass:$rDst, (sext in_rclass:$rSrc))]>;
1207
1208multiclass ExtendWordToDoubleWord {
1209 def v2i64: XSWDVecInst<v4i32, v2i64>;
1210 def r64: XSWDRegInst<R32C, R64C>;
1211
1212 def r64_inreg: XSWDInst<(outs R64C:$rDst), (ins R64C:$rSrc),
1213 [(set R64C:$rDst, (sext_inreg R64C:$rSrc, i32))]>;
1214}
Scott Michel66377522007-12-04 22:35:58 +00001215
Scott Micheled741dd2009-01-05 01:34:35 +00001216defm XSWD : ExtendWordToDoubleWord;
Scott Michel66377522007-12-04 22:35:58 +00001217
1218// AND operations
Scott Michel66377522007-12-04 22:35:58 +00001219
Scott Michela59d4692008-02-23 18:41:37 +00001220class ANDInst<dag OOL, dag IOL, list<dag> pattern> :
1221 RRForm<0b10000011000, OOL, IOL, "and\t$rT, $rA, $rB",
1222 IntegerOp, pattern>;
Scott Michel66377522007-12-04 22:35:58 +00001223
Scott Michela59d4692008-02-23 18:41:37 +00001224class ANDVecInst<ValueType vectype>:
1225 ANDInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1226 [(set (vectype VECREG:$rT), (and (vectype VECREG:$rA),
1227 (vectype VECREG:$rB)))]>;
Scott Michel66377522007-12-04 22:35:58 +00001228
Scott Michelad2715e2008-03-05 23:02:02 +00001229class ANDRegInst<RegisterClass rclass>:
1230 ANDInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB),
1231 [(set rclass:$rT, (and rclass:$rA, rclass:$rB))]>;
1232
Scott Michela59d4692008-02-23 18:41:37 +00001233multiclass BitwiseAnd
1234{
1235 def v16i8: ANDVecInst<v16i8>;
1236 def v8i16: ANDVecInst<v8i16>;
1237 def v4i32: ANDVecInst<v4i32>;
1238 def v2i64: ANDVecInst<v2i64>;
Scott Michel66377522007-12-04 22:35:58 +00001239
Scott Michelad2715e2008-03-05 23:02:02 +00001240 def r128: ANDRegInst<GPRC>;
1241 def r64: ANDRegInst<R64C>;
1242 def r32: ANDRegInst<R32C>;
1243 def r16: ANDRegInst<R16C>;
1244 def r8: ANDRegInst<R8C>;
Scott Michel66377522007-12-04 22:35:58 +00001245
Scott Michela59d4692008-02-23 18:41:37 +00001246 //===---------------------------------------------
1247 // Special instructions to perform the fabs instruction
1248 def fabs32: ANDInst<(outs R32FP:$rT), (ins R32FP:$rA, R32C:$rB),
1249 [/* Intentionally does not match a pattern */]>;
Scott Michel66377522007-12-04 22:35:58 +00001250
Scott Michel7ea02ff2009-03-17 01:15:45 +00001251 def fabs64: ANDInst<(outs R64FP:$rT), (ins R64FP:$rA, R64C:$rB),
Scott Michelc9c8b2a2009-01-26 03:31:40 +00001252 [/* Intentionally does not match a pattern */]>;
1253
Scott Michela59d4692008-02-23 18:41:37 +00001254 def fabsvec: ANDInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1255 [/* Intentionally does not match a pattern */]>;
1256
1257 //===---------------------------------------------
1258
1259 // Hacked form of AND to zero-extend 16-bit quantities to 32-bit
1260 // quantities -- see 16->32 zext pattern.
1261 //
1262 // This pattern is somewhat artificial, since it might match some
1263 // compiler generated pattern but it is unlikely to do so.
1264
1265 def i16i32: ANDInst<(outs R32C:$rT), (ins R16C:$rA, R32C:$rB),
1266 [(set R32C:$rT, (and (zext R16C:$rA), R32C:$rB))]>;
1267}
1268
1269defm AND : BitwiseAnd;
Scott Michel66377522007-12-04 22:35:58 +00001270
Chris Lattner918472a2010-03-28 07:48:17 +00001271
1272def vnot_cell_conv : PatFrag<(ops node:$in),
1273 (xor node:$in, (bitconvert (v4i32 immAllOnesV)))>;
1274
1275// N.B.: vnot_cell_conv is one of those special target selection pattern
1276// fragments,
Scott Michel66377522007-12-04 22:35:58 +00001277// in which we expect there to be a bit_convert on the constant. Bear in mind
1278// that llvm translates "not <reg>" to "xor <reg>, -1" (or in this case, a
1279// constant -1 vector.)
Scott Michel66377522007-12-04 22:35:58 +00001280
Scott Michela59d4692008-02-23 18:41:37 +00001281class ANDCInst<dag OOL, dag IOL, list<dag> pattern>:
1282 RRForm<0b10000011010, OOL, IOL, "andc\t$rT, $rA, $rB",
1283 IntegerOp, pattern>;
Scott Michel66377522007-12-04 22:35:58 +00001284
Scott Michel7ea02ff2009-03-17 01:15:45 +00001285class ANDCVecInst<ValueType vectype, PatFrag vnot_frag = vnot>:
Scott Michela59d4692008-02-23 18:41:37 +00001286 ANDCInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
Scott Michel7ea02ff2009-03-17 01:15:45 +00001287 [(set (vectype VECREG:$rT),
1288 (and (vectype VECREG:$rA),
1289 (vnot_frag (vectype VECREG:$rB))))]>;
Scott Michel66377522007-12-04 22:35:58 +00001290
Scott Michela59d4692008-02-23 18:41:37 +00001291class ANDCRegInst<RegisterClass rclass>:
1292 ANDCInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB),
1293 [(set rclass:$rT, (and rclass:$rA, (not rclass:$rB)))]>;
Scott Michel66377522007-12-04 22:35:58 +00001294
Scott Michela59d4692008-02-23 18:41:37 +00001295multiclass AndComplement
1296{
1297 def v16i8: ANDCVecInst<v16i8>;
1298 def v8i16: ANDCVecInst<v8i16>;
1299 def v4i32: ANDCVecInst<v4i32>;
1300 def v2i64: ANDCVecInst<v2i64>;
Scott Michel66377522007-12-04 22:35:58 +00001301
Scott Michela59d4692008-02-23 18:41:37 +00001302 def r128: ANDCRegInst<GPRC>;
1303 def r64: ANDCRegInst<R64C>;
1304 def r32: ANDCRegInst<R32C>;
1305 def r16: ANDCRegInst<R16C>;
1306 def r8: ANDCRegInst<R8C>;
Scott Michel7ea02ff2009-03-17 01:15:45 +00001307
1308 // Sometimes, the xor pattern has a bitcast constant:
Chris Lattner918472a2010-03-28 07:48:17 +00001309 def v16i8_conv: ANDCVecInst<v16i8, vnot_cell_conv>;
Scott Michela59d4692008-02-23 18:41:37 +00001310}
Scott Michel504c3692007-12-17 22:32:34 +00001311
Scott Michela59d4692008-02-23 18:41:37 +00001312defm ANDC : AndComplement;
Scott Michel66377522007-12-04 22:35:58 +00001313
Scott Michela59d4692008-02-23 18:41:37 +00001314class ANDBIInst<dag OOL, dag IOL, list<dag> pattern>:
1315 RI10Form<0b01101000, OOL, IOL, "andbi\t$rT, $rA, $val",
Scott Michelaedc6372008-12-10 00:15:19 +00001316 ByteOp, pattern>;
Scott Michel504c3692007-12-17 22:32:34 +00001317
Scott Michela59d4692008-02-23 18:41:37 +00001318multiclass AndByteImm
1319{
1320 def v16i8: ANDBIInst<(outs VECREG:$rT), (ins VECREG:$rA, u10imm:$val),
1321 [(set (v16i8 VECREG:$rT),
1322 (and (v16i8 VECREG:$rA),
1323 (v16i8 v16i8U8Imm:$val)))]>;
Scott Michel66377522007-12-04 22:35:58 +00001324
Scott Michela59d4692008-02-23 18:41:37 +00001325 def r8: ANDBIInst<(outs R8C:$rT), (ins R8C:$rA, u10imm_i8:$val),
1326 [(set R8C:$rT, (and R8C:$rA, immU8:$val))]>;
1327}
Scott Michel504c3692007-12-17 22:32:34 +00001328
Scott Michela59d4692008-02-23 18:41:37 +00001329defm ANDBI : AndByteImm;
Scott Michel66377522007-12-04 22:35:58 +00001330
Scott Michela59d4692008-02-23 18:41:37 +00001331class ANDHIInst<dag OOL, dag IOL, list<dag> pattern> :
1332 RI10Form<0b10101000, OOL, IOL, "andhi\t$rT, $rA, $val",
Scott Michelaedc6372008-12-10 00:15:19 +00001333 ByteOp, pattern>;
Scott Michel66377522007-12-04 22:35:58 +00001334
Scott Michela59d4692008-02-23 18:41:37 +00001335multiclass AndHalfwordImm
1336{
1337 def v8i16: ANDHIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
1338 [(set (v8i16 VECREG:$rT),
1339 (and (v8i16 VECREG:$rA), v8i16SExt10Imm:$val))]>;
Scott Michel66377522007-12-04 22:35:58 +00001340
Scott Michela59d4692008-02-23 18:41:37 +00001341 def r16: ANDHIInst<(outs R16C:$rT), (ins R16C:$rA, u10imm:$val),
1342 [(set R16C:$rT, (and R16C:$rA, i16ImmUns10:$val))]>;
Scott Michel504c3692007-12-17 22:32:34 +00001343
Scott Michela59d4692008-02-23 18:41:37 +00001344 // Zero-extend i8 to i16:
1345 def i8i16: ANDHIInst<(outs R16C:$rT), (ins R8C:$rA, u10imm:$val),
1346 [(set R16C:$rT, (and (zext R8C:$rA), i16ImmUns10:$val))]>;
1347}
Scott Michel66377522007-12-04 22:35:58 +00001348
Scott Michela59d4692008-02-23 18:41:37 +00001349defm ANDHI : AndHalfwordImm;
1350
1351class ANDIInst<dag OOL, dag IOL, list<dag> pattern> :
1352 RI10Form<0b00101000, OOL, IOL, "andi\t$rT, $rA, $val",
1353 IntegerOp, pattern>;
1354
1355multiclass AndWordImm
1356{
1357 def v4i32: ANDIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
1358 [(set (v4i32 VECREG:$rT),
1359 (and (v4i32 VECREG:$rA), v4i32SExt10Imm:$val))]>;
1360
1361 def r32: ANDIInst<(outs R32C:$rT), (ins R32C:$rA, s10imm_i32:$val),
1362 [(set R32C:$rT, (and R32C:$rA, i32ImmSExt10:$val))]>;
1363
1364 // Hacked form of ANDI to zero-extend i8 quantities to i32. See the zext 8->32
1365 // pattern below.
1366 def i8i32: ANDIInst<(outs R32C:$rT), (ins R8C:$rA, s10imm_i32:$val),
1367 [(set R32C:$rT,
1368 (and (zext R8C:$rA), i32ImmSExt10:$val))]>;
1369
1370 // Hacked form of ANDI to zero-extend i16 quantities to i32. See the
1371 // zext 16->32 pattern below.
1372 //
1373 // Note that this pattern is somewhat artificial, since it might match
1374 // something the compiler generates but is unlikely to occur in practice.
1375 def i16i32: ANDIInst<(outs R32C:$rT), (ins R16C:$rA, s10imm_i32:$val),
1376 [(set R32C:$rT,
1377 (and (zext R16C:$rA), i32ImmSExt10:$val))]>;
1378}
1379
1380defm ANDI : AndWordImm;
1381
1382//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
Scott Michel66377522007-12-04 22:35:58 +00001383// Bitwise OR group:
Scott Michela59d4692008-02-23 18:41:37 +00001384//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
1385
Scott Michel66377522007-12-04 22:35:58 +00001386// Bitwise "or" (N.B.: These are also register-register copy instructions...)
Scott Michela59d4692008-02-23 18:41:37 +00001387class ORInst<dag OOL, dag IOL, list<dag> pattern>:
1388 RRForm<0b10000010000, OOL, IOL, "or\t$rT, $rA, $rB",
1389 IntegerOp, pattern>;
Scott Michel66377522007-12-04 22:35:58 +00001390
Scott Michela59d4692008-02-23 18:41:37 +00001391class ORVecInst<ValueType vectype>:
1392 ORInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1393 [(set (vectype VECREG:$rT), (or (vectype VECREG:$rA),
1394 (vectype VECREG:$rB)))]>;
Scott Michel66377522007-12-04 22:35:58 +00001395
Scott Michela59d4692008-02-23 18:41:37 +00001396class ORRegInst<RegisterClass rclass>:
1397 ORInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB),
1398 [(set rclass:$rT, (or rclass:$rA, rclass:$rB))]>;
Scott Michel66377522007-12-04 22:35:58 +00001399
Scott Michelf0569be2008-12-27 04:51:36 +00001400// ORCvtForm: OR conversion form
1401//
1402// This is used to "convert" the preferred slot to its vector equivalent, as
1403// well as convert a vector back to its preferred slot.
1404//
1405// These are effectively no-ops, but need to exist for proper type conversion
1406// and type coercion.
1407
Scott Micheld1e8d9c2009-01-21 04:58:48 +00001408class ORCvtForm<dag OOL, dag IOL, list<dag> pattern = [/* no pattern */]>
Scott Michelf0569be2008-12-27 04:51:36 +00001409 : SPUInstr<OOL, IOL, "or\t$rT, $rA, $rA", IntegerOp> {
1410 bits<7> RA;
1411 bits<7> RT;
1412
Scott Micheld1e8d9c2009-01-21 04:58:48 +00001413 let Pattern = pattern;
Scott Michelf0569be2008-12-27 04:51:36 +00001414
1415 let Inst{0-10} = 0b10000010000;
1416 let Inst{11-17} = RA;
1417 let Inst{18-24} = RA;
1418 let Inst{25-31} = RT;
1419}
1420
Scott Michela59d4692008-02-23 18:41:37 +00001421class ORPromoteScalar<RegisterClass rclass>:
Scott Michelf0569be2008-12-27 04:51:36 +00001422 ORCvtForm<(outs VECREG:$rT), (ins rclass:$rA)>;
Scott Michel66377522007-12-04 22:35:58 +00001423
Scott Michela59d4692008-02-23 18:41:37 +00001424class ORExtractElt<RegisterClass rclass>:
Scott Michelf0569be2008-12-27 04:51:36 +00001425 ORCvtForm<(outs rclass:$rT), (ins VECREG:$rA)>;
1426
Scott Micheld1e8d9c2009-01-21 04:58:48 +00001427/* class ORCvtRegGPRC<RegisterClass rclass>:
1428 ORCvtForm<(outs GPRC:$rT), (ins rclass:$rA)>; */
Scott Michelf0569be2008-12-27 04:51:36 +00001429
Scott Micheld1e8d9c2009-01-21 04:58:48 +00001430/* class ORCvtGPRCReg<RegisterClass rclass>:
1431 ORCvtForm<(outs rclass:$rT), (ins GPRC:$rA)>; */
Scott Micheldd950092009-01-06 03:36:14 +00001432
Scott Micheld1e8d9c2009-01-21 04:58:48 +00001433class ORCvtFormR32Reg<RegisterClass rclass, list<dag> pattern = [ ]>:
1434 ORCvtForm<(outs rclass:$rT), (ins R32C:$rA), pattern>;
Scott Micheldd950092009-01-06 03:36:14 +00001435
Scott Micheld1e8d9c2009-01-21 04:58:48 +00001436class ORCvtFormRegR32<RegisterClass rclass, list<dag> pattern = [ ]>:
1437 ORCvtForm<(outs R32C:$rT), (ins rclass:$rA), pattern>;
Scott Micheldd950092009-01-06 03:36:14 +00001438
Scott Micheld1e8d9c2009-01-21 04:58:48 +00001439class ORCvtFormR64Reg<RegisterClass rclass, list<dag> pattern = [ ]>:
1440 ORCvtForm<(outs rclass:$rT), (ins R64C:$rA), pattern>;
Scott Micheldd950092009-01-06 03:36:14 +00001441
Scott Micheld1e8d9c2009-01-21 04:58:48 +00001442class ORCvtFormRegR64<RegisterClass rclass, list<dag> pattern = [ ]>:
1443 ORCvtForm<(outs R64C:$rT), (ins rclass:$rA), pattern>;
Scott Michelf0569be2008-12-27 04:51:36 +00001444
Scott Michel6e1d1472009-03-16 18:47:25 +00001445class ORCvtGPRCVec:
1446 ORCvtForm<(outs VECREG:$rT), (ins GPRC:$rA)>;
1447
1448class ORCvtVecGPRC:
1449 ORCvtForm<(outs GPRC:$rT), (ins VECREG:$rA)>;
Scott Michel66377522007-12-04 22:35:58 +00001450
Scott Michela59d4692008-02-23 18:41:37 +00001451multiclass BitwiseOr
1452{
1453 def v16i8: ORVecInst<v16i8>;
1454 def v8i16: ORVecInst<v8i16>;
1455 def v4i32: ORVecInst<v4i32>;
1456 def v2i64: ORVecInst<v2i64>;
Scott Michel66377522007-12-04 22:35:58 +00001457
Scott Michela59d4692008-02-23 18:41:37 +00001458 def v4f32: ORInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1459 [(set (v4f32 VECREG:$rT),
1460 (v4f32 (bitconvert (or (v4i32 VECREG:$rA),
1461 (v4i32 VECREG:$rB)))))]>;
Scott Michel66377522007-12-04 22:35:58 +00001462
Scott Michela59d4692008-02-23 18:41:37 +00001463 def v2f64: ORInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
Scott Michelf0569be2008-12-27 04:51:36 +00001464 [(set (v2f64 VECREG:$rT),
Scott Michela59d4692008-02-23 18:41:37 +00001465 (v2f64 (bitconvert (or (v2i64 VECREG:$rA),
1466 (v2i64 VECREG:$rB)))))]>;
Scott Michel66377522007-12-04 22:35:58 +00001467
Scott Micheld1e8d9c2009-01-21 04:58:48 +00001468 def r128: ORRegInst<GPRC>;
1469 def r64: ORRegInst<R64C>;
1470 def r32: ORRegInst<R32C>;
1471 def r16: ORRegInst<R16C>;
1472 def r8: ORRegInst<R8C>;
Scott Michel66377522007-12-04 22:35:58 +00001473
Scott Michela59d4692008-02-23 18:41:37 +00001474 // OR instructions used to copy f32 and f64 registers.
1475 def f32: ORInst<(outs R32FP:$rT), (ins R32FP:$rA, R32FP:$rB),
1476 [/* no pattern */]>;
Scott Michel504c3692007-12-17 22:32:34 +00001477
Scott Michela59d4692008-02-23 18:41:37 +00001478 def f64: ORInst<(outs R64FP:$rT), (ins R64FP:$rA, R64FP:$rB),
1479 [/* no pattern */]>;
Scott Michel86c041f2007-12-20 00:44:13 +00001480
Scott Michel02d711b2008-12-30 23:28:25 +00001481 // scalar->vector promotion, prefslot2vec:
Scott Michela59d4692008-02-23 18:41:37 +00001482 def v16i8_i8: ORPromoteScalar<R8C>;
1483 def v8i16_i16: ORPromoteScalar<R16C>;
1484 def v4i32_i32: ORPromoteScalar<R32C>;
1485 def v2i64_i64: ORPromoteScalar<R64C>;
1486 def v4f32_f32: ORPromoteScalar<R32FP>;
1487 def v2f64_f64: ORPromoteScalar<R64FP>;
Scott Michel86c041f2007-12-20 00:44:13 +00001488
Scott Michel02d711b2008-12-30 23:28:25 +00001489 // vector->scalar demotion, vec2prefslot:
Scott Michela59d4692008-02-23 18:41:37 +00001490 def i8_v16i8: ORExtractElt<R8C>;
1491 def i16_v8i16: ORExtractElt<R16C>;
1492 def i32_v4i32: ORExtractElt<R32C>;
1493 def i64_v2i64: ORExtractElt<R64C>;
1494 def f32_v4f32: ORExtractElt<R32FP>;
1495 def f64_v2f64: ORExtractElt<R64FP>;
Scott Michelf0569be2008-12-27 04:51:36 +00001496
Scott Michel6e1d1472009-03-16 18:47:25 +00001497 // Conversion from vector to GPRC
1498 def i128_vec: ORCvtVecGPRC;
1499
1500 // Conversion from GPRC to vector
1501 def vec_i128: ORCvtGPRCVec;
1502
Scott Micheld1e8d9c2009-01-21 04:58:48 +00001503/*
Scott Michel6e1d1472009-03-16 18:47:25 +00001504 // Conversion from register to GPRC
Scott Michelf0569be2008-12-27 04:51:36 +00001505 def i128_r64: ORCvtRegGPRC<R64C>;
1506 def i128_f64: ORCvtRegGPRC<R64FP>;
1507 def i128_r32: ORCvtRegGPRC<R32C>;
1508 def i128_f32: ORCvtRegGPRC<R32FP>;
1509 def i128_r16: ORCvtRegGPRC<R16C>;
1510 def i128_r8: ORCvtRegGPRC<R8C>;
1511
Scott Michel6e1d1472009-03-16 18:47:25 +00001512 // Conversion from GPRC to register
Scott Michelf0569be2008-12-27 04:51:36 +00001513 def r64_i128: ORCvtGPRCReg<R64C>;
1514 def f64_i128: ORCvtGPRCReg<R64FP>;
1515 def r32_i128: ORCvtGPRCReg<R32C>;
1516 def f32_i128: ORCvtGPRCReg<R32FP>;
1517 def r16_i128: ORCvtGPRCReg<R16C>;
1518 def r8_i128: ORCvtGPRCReg<R8C>;
Scott Micheld1e8d9c2009-01-21 04:58:48 +00001519*/
1520/*
Scott Micheldd950092009-01-06 03:36:14 +00001521 // Conversion from register to R32C:
Scott Michel6e1d1472009-03-16 18:47:25 +00001522 def r32_r16: ORCvtFormRegR32<R16C>;
1523 def r32_r8: ORCvtFormRegR32<R8C>;
Scott Micheldd950092009-01-06 03:36:14 +00001524
1525 // Conversion from R32C to register
1526 def r32_r16: ORCvtFormR32Reg<R16C>;
1527 def r32_r8: ORCvtFormR32Reg<R8C>;
Scott Micheld1e8d9c2009-01-21 04:58:48 +00001528*/
Scott Michelc9c8b2a2009-01-26 03:31:40 +00001529
Scott Michel6e1d1472009-03-16 18:47:25 +00001530 // Conversion from R64C to register:
Scott Michelc9c8b2a2009-01-26 03:31:40 +00001531 def r32_r64: ORCvtFormR64Reg<R32C>;
1532 // def r16_r64: ORCvtFormR64Reg<R16C>;
1533 // def r8_r64: ORCvtFormR64Reg<R8C>;
1534
Scott Michel6e1d1472009-03-16 18:47:25 +00001535 // Conversion to R64C from register:
Scott Michelc9c8b2a2009-01-26 03:31:40 +00001536 def r64_r32: ORCvtFormRegR64<R32C>;
1537 // def r64_r16: ORCvtFormRegR64<R16C>;
1538 // def r64_r8: ORCvtFormRegR64<R8C>;
Scott Micheld1e8d9c2009-01-21 04:58:48 +00001539
1540 // bitconvert patterns:
1541 def r32_f32: ORCvtFormR32Reg<R32FP,
1542 [(set R32FP:$rT, (bitconvert R32C:$rA))]>;
1543 def f32_r32: ORCvtFormRegR32<R32FP,
1544 [(set R32C:$rT, (bitconvert R32FP:$rA))]>;
1545
1546 def r64_f64: ORCvtFormR64Reg<R64FP,
1547 [(set R64FP:$rT, (bitconvert R64C:$rA))]>;
1548 def f64_r64: ORCvtFormRegR64<R64FP,
1549 [(set R64C:$rT, (bitconvert R64FP:$rA))]>;
Scott Michela59d4692008-02-23 18:41:37 +00001550}
Scott Michel504c3692007-12-17 22:32:34 +00001551
Scott Michela59d4692008-02-23 18:41:37 +00001552defm OR : BitwiseOr;
1553
Scott Michelf0569be2008-12-27 04:51:36 +00001554// scalar->vector promotion patterns (preferred slot to vector):
1555def : Pat<(v16i8 (SPUprefslot2vec R8C:$rA)),
1556 (ORv16i8_i8 R8C:$rA)>;
Scott Michel504c3692007-12-17 22:32:34 +00001557
Scott Michelf0569be2008-12-27 04:51:36 +00001558def : Pat<(v8i16 (SPUprefslot2vec R16C:$rA)),
1559 (ORv8i16_i16 R16C:$rA)>;
Scott Michel66377522007-12-04 22:35:58 +00001560
Scott Michelf0569be2008-12-27 04:51:36 +00001561def : Pat<(v4i32 (SPUprefslot2vec R32C:$rA)),
1562 (ORv4i32_i32 R32C:$rA)>;
Scott Michel66377522007-12-04 22:35:58 +00001563
Scott Michelf0569be2008-12-27 04:51:36 +00001564def : Pat<(v2i64 (SPUprefslot2vec R64C:$rA)),
1565 (ORv2i64_i64 R64C:$rA)>;
Scott Michel66377522007-12-04 22:35:58 +00001566
Scott Michelf0569be2008-12-27 04:51:36 +00001567def : Pat<(v4f32 (SPUprefslot2vec R32FP:$rA)),
1568 (ORv4f32_f32 R32FP:$rA)>;
Scott Michel66377522007-12-04 22:35:58 +00001569
Scott Michelf0569be2008-12-27 04:51:36 +00001570def : Pat<(v2f64 (SPUprefslot2vec R64FP:$rA)),
1571 (ORv2f64_f64 R64FP:$rA)>;
Scott Michel66377522007-12-04 22:35:58 +00001572
Scott Michelf0569be2008-12-27 04:51:36 +00001573// ORi*_v*: Used to extract vector element 0 (the preferred slot), otherwise
1574// known as converting the vector back to its preferred slot
Scott Michel504c3692007-12-17 22:32:34 +00001575
Scott Michel104de432008-11-24 17:11:17 +00001576def : Pat<(SPUvec2prefslot (v16i8 VECREG:$rA)),
Scott Michelf0569be2008-12-27 04:51:36 +00001577 (ORi8_v16i8 VECREG:$rA)>;
Scott Michel504c3692007-12-17 22:32:34 +00001578
Scott Michel104de432008-11-24 17:11:17 +00001579def : Pat<(SPUvec2prefslot (v8i16 VECREG:$rA)),
Scott Michelf0569be2008-12-27 04:51:36 +00001580 (ORi16_v8i16 VECREG:$rA)>;
Scott Michel66377522007-12-04 22:35:58 +00001581
Scott Michel104de432008-11-24 17:11:17 +00001582def : Pat<(SPUvec2prefslot (v4i32 VECREG:$rA)),
Scott Michelf0569be2008-12-27 04:51:36 +00001583 (ORi32_v4i32 VECREG:$rA)>;
Scott Michel66377522007-12-04 22:35:58 +00001584
Scott Michel104de432008-11-24 17:11:17 +00001585def : Pat<(SPUvec2prefslot (v2i64 VECREG:$rA)),
Scott Michelf0569be2008-12-27 04:51:36 +00001586 (ORi64_v2i64 VECREG:$rA)>;
Scott Michel66377522007-12-04 22:35:58 +00001587
Scott Michel104de432008-11-24 17:11:17 +00001588def : Pat<(SPUvec2prefslot (v4f32 VECREG:$rA)),
Scott Michelf0569be2008-12-27 04:51:36 +00001589 (ORf32_v4f32 VECREG:$rA)>;
Scott Michel66377522007-12-04 22:35:58 +00001590
Scott Michel104de432008-11-24 17:11:17 +00001591def : Pat<(SPUvec2prefslot (v2f64 VECREG:$rA)),
Scott Michelf0569be2008-12-27 04:51:36 +00001592 (ORf64_v2f64 VECREG:$rA)>;
1593
1594// Load Register: This is an assembler alias for a bitwise OR of a register
1595// against itself. It's here because it brings some clarity to assembly
1596// language output.
1597
1598let hasCtrlDep = 1 in {
1599 class LRInst<dag OOL, dag IOL>
1600 : SPUInstr<OOL, IOL, "lr\t$rT, $rA", IntegerOp> {
1601 bits<7> RA;
1602 bits<7> RT;
1603
1604 let Pattern = [/*no pattern*/];
1605
1606 let Inst{0-10} = 0b10000010000; /* It's an OR operation */
1607 let Inst{11-17} = RA;
1608 let Inst{18-24} = RA;
1609 let Inst{25-31} = RT;
1610 }
1611
1612 class LRVecInst<ValueType vectype>:
1613 LRInst<(outs VECREG:$rT), (ins VECREG:$rA)>;
1614
1615 class LRRegInst<RegisterClass rclass>:
1616 LRInst<(outs rclass:$rT), (ins rclass:$rA)>;
1617
1618 multiclass LoadRegister {
1619 def v2i64: LRVecInst<v2i64>;
1620 def v2f64: LRVecInst<v2f64>;
1621 def v4i32: LRVecInst<v4i32>;
1622 def v4f32: LRVecInst<v4f32>;
1623 def v8i16: LRVecInst<v8i16>;
1624 def v16i8: LRVecInst<v16i8>;
1625
1626 def r128: LRRegInst<GPRC>;
1627 def r64: LRRegInst<R64C>;
1628 def f64: LRRegInst<R64FP>;
1629 def r32: LRRegInst<R32C>;
1630 def f32: LRRegInst<R32FP>;
1631 def r16: LRRegInst<R16C>;
1632 def r8: LRRegInst<R8C>;
1633 }
1634
1635 defm LR: LoadRegister;
1636}
Scott Michel66377522007-12-04 22:35:58 +00001637
Scott Michela59d4692008-02-23 18:41:37 +00001638// ORC: Bitwise "or" with complement (c = a | ~b)
Scott Michel66377522007-12-04 22:35:58 +00001639
Scott Michela59d4692008-02-23 18:41:37 +00001640class ORCInst<dag OOL, dag IOL, list<dag> pattern>:
1641 RRForm<0b10010010000, OOL, IOL, "orc\t$rT, $rA, $rB",
1642 IntegerOp, pattern>;
Scott Michel66377522007-12-04 22:35:58 +00001643
Scott Michela59d4692008-02-23 18:41:37 +00001644class ORCVecInst<ValueType vectype>:
1645 ORCInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1646 [(set (vectype VECREG:$rT), (or (vectype VECREG:$rA),
1647 (vnot (vectype VECREG:$rB))))]>;
Scott Michel66377522007-12-04 22:35:58 +00001648
Scott Michela59d4692008-02-23 18:41:37 +00001649class ORCRegInst<RegisterClass rclass>:
1650 ORCInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB),
1651 [(set rclass:$rT, (or rclass:$rA, (not rclass:$rB)))]>;
Scott Michel66377522007-12-04 22:35:58 +00001652
Scott Michela59d4692008-02-23 18:41:37 +00001653multiclass BitwiseOrComplement
1654{
1655 def v16i8: ORCVecInst<v16i8>;
1656 def v8i16: ORCVecInst<v8i16>;
1657 def v4i32: ORCVecInst<v4i32>;
1658 def v2i64: ORCVecInst<v2i64>;
Scott Michel66377522007-12-04 22:35:58 +00001659
Scott Michel6e1d1472009-03-16 18:47:25 +00001660 def r128: ORCRegInst<GPRC>;
Scott Michela59d4692008-02-23 18:41:37 +00001661 def r64: ORCRegInst<R64C>;
1662 def r32: ORCRegInst<R32C>;
1663 def r16: ORCRegInst<R16C>;
1664 def r8: ORCRegInst<R8C>;
1665}
1666
1667defm ORC : BitwiseOrComplement;
Scott Michel504c3692007-12-17 22:32:34 +00001668
Scott Michel66377522007-12-04 22:35:58 +00001669// OR byte immediate
Scott Michela59d4692008-02-23 18:41:37 +00001670class ORBIInst<dag OOL, dag IOL, list<dag> pattern>:
1671 RI10Form<0b01100000, OOL, IOL, "orbi\t$rT, $rA, $val",
1672 IntegerOp, pattern>;
Scott Michel66377522007-12-04 22:35:58 +00001673
Scott Michela59d4692008-02-23 18:41:37 +00001674class ORBIVecInst<ValueType vectype, PatLeaf immpred>:
1675 ORBIInst<(outs VECREG:$rT), (ins VECREG:$rA, u10imm:$val),
1676 [(set (v16i8 VECREG:$rT), (or (vectype VECREG:$rA),
1677 (vectype immpred:$val)))]>;
1678
1679multiclass BitwiseOrByteImm
1680{
1681 def v16i8: ORBIVecInst<v16i8, v16i8U8Imm>;
1682
1683 def r8: ORBIInst<(outs R8C:$rT), (ins R8C:$rA, u10imm_i8:$val),
1684 [(set R8C:$rT, (or R8C:$rA, immU8:$val))]>;
1685}
1686
1687defm ORBI : BitwiseOrByteImm;
Scott Michel504c3692007-12-17 22:32:34 +00001688
Scott Michel66377522007-12-04 22:35:58 +00001689// OR halfword immediate
Scott Michela59d4692008-02-23 18:41:37 +00001690class ORHIInst<dag OOL, dag IOL, list<dag> pattern>:
1691 RI10Form<0b10100000, OOL, IOL, "orhi\t$rT, $rA, $val",
1692 IntegerOp, pattern>;
Scott Michel66377522007-12-04 22:35:58 +00001693
Scott Michela59d4692008-02-23 18:41:37 +00001694class ORHIVecInst<ValueType vectype, PatLeaf immpred>:
1695 ORHIInst<(outs VECREG:$rT), (ins VECREG:$rA, u10imm:$val),
1696 [(set (vectype VECREG:$rT), (or (vectype VECREG:$rA),
1697 immpred:$val))]>;
Scott Michel504c3692007-12-17 22:32:34 +00001698
Scott Michela59d4692008-02-23 18:41:37 +00001699multiclass BitwiseOrHalfwordImm
1700{
1701 def v8i16: ORHIVecInst<v8i16, v8i16Uns10Imm>;
1702
1703 def r16: ORHIInst<(outs R16C:$rT), (ins R16C:$rA, u10imm:$val),
1704 [(set R16C:$rT, (or R16C:$rA, i16ImmUns10:$val))]>;
1705
1706 // Specialized ORHI form used to promote 8-bit registers to 16-bit
1707 def i8i16: ORHIInst<(outs R16C:$rT), (ins R8C:$rA, s10imm:$val),
1708 [(set R16C:$rT, (or (anyext R8C:$rA),
1709 i16ImmSExt10:$val))]>;
1710}
1711
1712defm ORHI : BitwiseOrHalfwordImm;
1713
1714class ORIInst<dag OOL, dag IOL, list<dag> pattern>:
1715 RI10Form<0b00100000, OOL, IOL, "ori\t$rT, $rA, $val",
1716 IntegerOp, pattern>;
1717
1718class ORIVecInst<ValueType vectype, PatLeaf immpred>:
1719 ORIInst<(outs VECREG:$rT), (ins VECREG:$rA, u10imm:$val),
1720 [(set (vectype VECREG:$rT), (or (vectype VECREG:$rA),
1721 immpred:$val))]>;
Scott Michel66377522007-12-04 22:35:58 +00001722
1723// Bitwise "or" with immediate
Scott Michela59d4692008-02-23 18:41:37 +00001724multiclass BitwiseOrImm
1725{
1726 def v4i32: ORIVecInst<v4i32, v4i32Uns10Imm>;
Scott Michel66377522007-12-04 22:35:58 +00001727
Scott Michela59d4692008-02-23 18:41:37 +00001728 def r32: ORIInst<(outs R32C:$rT), (ins R32C:$rA, u10imm_i32:$val),
1729 [(set R32C:$rT, (or R32C:$rA, i32ImmUns10:$val))]>;
Scott Michel66377522007-12-04 22:35:58 +00001730
Scott Michela59d4692008-02-23 18:41:37 +00001731 // i16i32: hacked version of the ori instruction to extend 16-bit quantities
1732 // to 32-bit quantities. used exclusively to match "anyext" conversions (vide
1733 // infra "anyext 16->32" pattern.)
1734 def i16i32: ORIInst<(outs R32C:$rT), (ins R16C:$rA, s10imm_i32:$val),
1735 [(set R32C:$rT, (or (anyext R16C:$rA),
1736 i32ImmSExt10:$val))]>;
Scott Michel66377522007-12-04 22:35:58 +00001737
Scott Michela59d4692008-02-23 18:41:37 +00001738 // i8i32: Hacked version of the ORI instruction to extend 16-bit quantities
1739 // to 32-bit quantities. Used exclusively to match "anyext" conversions (vide
1740 // infra "anyext 16->32" pattern.)
1741 def i8i32: ORIInst<(outs R32C:$rT), (ins R8C:$rA, s10imm_i32:$val),
1742 [(set R32C:$rT, (or (anyext R8C:$rA),
1743 i32ImmSExt10:$val))]>;
1744}
Scott Michel66377522007-12-04 22:35:58 +00001745
Scott Michela59d4692008-02-23 18:41:37 +00001746defm ORI : BitwiseOrImm;
Scott Michel504c3692007-12-17 22:32:34 +00001747
Scott Michel66377522007-12-04 22:35:58 +00001748// ORX: "or" across the vector: or's $rA's word slots leaving the result in
1749// $rT[0], slots 1-3 are zeroed.
1750//
Scott Michel504c3692007-12-17 22:32:34 +00001751// FIXME: Needs to match an intrinsic pattern.
Scott Michel66377522007-12-04 22:35:58 +00001752def ORXv4i32:
1753 RRForm<0b10010010000, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1754 "orx\t$rT, $rA, $rB", IntegerOp,
1755 []>;
1756
Scott Michel504c3692007-12-17 22:32:34 +00001757// XOR:
Scott Michel66377522007-12-04 22:35:58 +00001758
Scott Michelad2715e2008-03-05 23:02:02 +00001759class XORInst<dag OOL, dag IOL, list<dag> pattern> :
1760 RRForm<0b10010010000, OOL, IOL, "xor\t$rT, $rA, $rB",
1761 IntegerOp, pattern>;
Scott Michel66377522007-12-04 22:35:58 +00001762
Scott Michelad2715e2008-03-05 23:02:02 +00001763class XORVecInst<ValueType vectype>:
1764 XORInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1765 [(set (vectype VECREG:$rT), (xor (vectype VECREG:$rA),
1766 (vectype VECREG:$rB)))]>;
Scott Michel66377522007-12-04 22:35:58 +00001767
Scott Michelad2715e2008-03-05 23:02:02 +00001768class XORRegInst<RegisterClass rclass>:
1769 XORInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB),
1770 [(set rclass:$rT, (xor rclass:$rA, rclass:$rB))]>;
1771
1772multiclass BitwiseExclusiveOr
1773{
1774 def v16i8: XORVecInst<v16i8>;
1775 def v8i16: XORVecInst<v8i16>;
1776 def v4i32: XORVecInst<v4i32>;
1777 def v2i64: XORVecInst<v2i64>;
1778
1779 def r128: XORRegInst<GPRC>;
1780 def r64: XORRegInst<R64C>;
1781 def r32: XORRegInst<R32C>;
1782 def r16: XORRegInst<R16C>;
1783 def r8: XORRegInst<R8C>;
Scott Michela82d3f72009-03-17 16:45:16 +00001784
1785 // XOR instructions used to negate f32 and f64 quantities.
1786
1787 def fneg32: XORInst<(outs R32FP:$rT), (ins R32FP:$rA, R32C:$rB),
1788 [/* no pattern */]>;
1789
1790 def fneg64: XORInst<(outs R64FP:$rT), (ins R64FP:$rA, R64C:$rB),
1791 [/* no pattern */]>;
1792
1793 def fnegvec: XORInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1794 [/* no pattern, see fneg{32,64} */]>;
Scott Michelad2715e2008-03-05 23:02:02 +00001795}
1796
1797defm XOR : BitwiseExclusiveOr;
Scott Michel66377522007-12-04 22:35:58 +00001798
1799//==----------------------------------------------------------
Scott Michel504c3692007-12-17 22:32:34 +00001800
Scott Michela59d4692008-02-23 18:41:37 +00001801class XORBIInst<dag OOL, dag IOL, list<dag> pattern>:
1802 RI10Form<0b01100000, OOL, IOL, "xorbi\t$rT, $rA, $val",
1803 IntegerOp, pattern>;
Scott Michel66377522007-12-04 22:35:58 +00001804
Scott Michela59d4692008-02-23 18:41:37 +00001805multiclass XorByteImm
1806{
1807 def v16i8:
1808 XORBIInst<(outs VECREG:$rT), (ins VECREG:$rA, u10imm:$val),
1809 [(set (v16i8 VECREG:$rT), (xor (v16i8 VECREG:$rA), v16i8U8Imm:$val))]>;
1810
1811 def r8:
1812 XORBIInst<(outs R8C:$rT), (ins R8C:$rA, u10imm_i8:$val),
1813 [(set R8C:$rT, (xor R8C:$rA, immU8:$val))]>;
1814}
1815
1816defm XORBI : XorByteImm;
Scott Michel504c3692007-12-17 22:32:34 +00001817
Scott Michel66377522007-12-04 22:35:58 +00001818def XORHIv8i16:
Scott Michela59d4692008-02-23 18:41:37 +00001819 RI10Form<0b10100000, (outs VECREG:$rT), (ins VECREG:$rA, u10imm:$val),
Scott Michel66377522007-12-04 22:35:58 +00001820 "xorhi\t$rT, $rA, $val", IntegerOp,
1821 [(set (v8i16 VECREG:$rT), (xor (v8i16 VECREG:$rA),
1822 v8i16SExt10Imm:$val))]>;
1823
1824def XORHIr16:
1825 RI10Form<0b10100000, (outs R16C:$rT), (ins R16C:$rA, s10imm:$val),
1826 "xorhi\t$rT, $rA, $val", IntegerOp,
1827 [(set R16C:$rT, (xor R16C:$rA, i16ImmSExt10:$val))]>;
1828
1829def XORIv4i32:
Scott Michel78c47fa2008-03-10 16:58:52 +00001830 RI10Form<0b00100000, (outs VECREG:$rT), (ins VECREG:$rA, s10imm_i32:$val),
Scott Michel66377522007-12-04 22:35:58 +00001831 "xori\t$rT, $rA, $val", IntegerOp,
1832 [(set (v4i32 VECREG:$rT), (xor (v4i32 VECREG:$rA),
1833 v4i32SExt10Imm:$val))]>;
1834
1835def XORIr32:
1836 RI10Form<0b00100000, (outs R32C:$rT), (ins R32C:$rA, s10imm_i32:$val),
1837 "xori\t$rT, $rA, $val", IntegerOp,
1838 [(set R32C:$rT, (xor R32C:$rA, i32ImmSExt10:$val))]>;
1839
1840// NAND:
Scott Michel66377522007-12-04 22:35:58 +00001841
Scott Michel6e1d1472009-03-16 18:47:25 +00001842class NANDInst<dag OOL, dag IOL, list<dag> pattern>:
1843 RRForm<0b10010011000, OOL, IOL, "nand\t$rT, $rA, $rB",
1844 IntegerOp, pattern>;
Scott Michel66377522007-12-04 22:35:58 +00001845
Scott Michel6e1d1472009-03-16 18:47:25 +00001846class NANDVecInst<ValueType vectype>:
1847 NANDInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1848 [(set (vectype VECREG:$rT), (vnot (and (vectype VECREG:$rA),
1849 (vectype VECREG:$rB))))]>;
1850class NANDRegInst<RegisterClass rclass>:
1851 NANDInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB),
1852 [(set rclass:$rT, (not (and rclass:$rA, rclass:$rB)))]>;
Scott Michel66377522007-12-04 22:35:58 +00001853
Scott Michel6e1d1472009-03-16 18:47:25 +00001854multiclass BitwiseNand
1855{
1856 def v16i8: NANDVecInst<v16i8>;
1857 def v8i16: NANDVecInst<v8i16>;
1858 def v4i32: NANDVecInst<v4i32>;
1859 def v2i64: NANDVecInst<v2i64>;
Scott Michel66377522007-12-04 22:35:58 +00001860
Scott Michel6e1d1472009-03-16 18:47:25 +00001861 def r128: NANDRegInst<GPRC>;
1862 def r64: NANDRegInst<R64C>;
1863 def r32: NANDRegInst<R32C>;
1864 def r16: NANDRegInst<R16C>;
1865 def r8: NANDRegInst<R8C>;
1866}
Scott Michel66377522007-12-04 22:35:58 +00001867
Scott Michel6e1d1472009-03-16 18:47:25 +00001868defm NAND : BitwiseNand;
Scott Michel504c3692007-12-17 22:32:34 +00001869
Scott Michel66377522007-12-04 22:35:58 +00001870// NOR:
Scott Michel66377522007-12-04 22:35:58 +00001871
Scott Michel6e1d1472009-03-16 18:47:25 +00001872class NORInst<dag OOL, dag IOL, list<dag> pattern>:
1873 RRForm<0b10010010000, OOL, IOL, "nor\t$rT, $rA, $rB",
1874 IntegerOp, pattern>;
Scott Michel66377522007-12-04 22:35:58 +00001875
Scott Michel6e1d1472009-03-16 18:47:25 +00001876class NORVecInst<ValueType vectype>:
1877 NORInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1878 [(set (vectype VECREG:$rT), (vnot (or (vectype VECREG:$rA),
1879 (vectype VECREG:$rB))))]>;
1880class NORRegInst<RegisterClass rclass>:
1881 NORInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB),
1882 [(set rclass:$rT, (not (or rclass:$rA, rclass:$rB)))]>;
Scott Michel66377522007-12-04 22:35:58 +00001883
Scott Michel6e1d1472009-03-16 18:47:25 +00001884multiclass BitwiseNor
1885{
1886 def v16i8: NORVecInst<v16i8>;
1887 def v8i16: NORVecInst<v8i16>;
1888 def v4i32: NORVecInst<v4i32>;
1889 def v2i64: NORVecInst<v2i64>;
Scott Michel66377522007-12-04 22:35:58 +00001890
Scott Michel6e1d1472009-03-16 18:47:25 +00001891 def r128: NORRegInst<GPRC>;
1892 def r64: NORRegInst<R64C>;
1893 def r32: NORRegInst<R32C>;
1894 def r16: NORRegInst<R16C>;
1895 def r8: NORRegInst<R8C>;
1896}
Scott Michel66377522007-12-04 22:35:58 +00001897
Scott Michel6e1d1472009-03-16 18:47:25 +00001898defm NOR : BitwiseNor;
Scott Michel504c3692007-12-17 22:32:34 +00001899
Scott Michel66377522007-12-04 22:35:58 +00001900// Select bits:
Scott Michelad2715e2008-03-05 23:02:02 +00001901class SELBInst<dag OOL, dag IOL, list<dag> pattern>:
1902 RRRForm<0b1000, OOL, IOL, "selb\t$rT, $rA, $rB, $rC",
1903 IntegerOp, pattern>;
Scott Michel66377522007-12-04 22:35:58 +00001904
Scott Michelc9c8b2a2009-01-26 03:31:40 +00001905class SELBVecInst<ValueType vectype, PatFrag vnot_frag = vnot>:
Scott Michelad2715e2008-03-05 23:02:02 +00001906 SELBInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB, VECREG:$rC),
1907 [(set (vectype VECREG:$rT),
1908 (or (and (vectype VECREG:$rC), (vectype VECREG:$rB)),
Scott Michelc9c8b2a2009-01-26 03:31:40 +00001909 (and (vnot_frag (vectype VECREG:$rC)),
Scott Michelad2715e2008-03-05 23:02:02 +00001910 (vectype VECREG:$rA))))]>;
Scott Michel66377522007-12-04 22:35:58 +00001911
Scott Michel02d711b2008-12-30 23:28:25 +00001912class SELBVecVCondInst<ValueType vectype>:
1913 SELBInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB, VECREG:$rC),
1914 [(set (vectype VECREG:$rT),
1915 (select (vectype VECREG:$rC),
1916 (vectype VECREG:$rB),
1917 (vectype VECREG:$rA)))]>;
1918
Scott Michelf0569be2008-12-27 04:51:36 +00001919class SELBVecCondInst<ValueType vectype>:
1920 SELBInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB, R32C:$rC),
1921 [(set (vectype VECREG:$rT),
1922 (select R32C:$rC,
1923 (vectype VECREG:$rB),
1924 (vectype VECREG:$rA)))]>;
1925
Scott Michelad2715e2008-03-05 23:02:02 +00001926class SELBRegInst<RegisterClass rclass>:
1927 SELBInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB, rclass:$rC),
1928 [(set rclass:$rT,
Scott Michel1df30c42008-12-29 03:23:36 +00001929 (or (and rclass:$rB, rclass:$rC),
1930 (and rclass:$rA, (not rclass:$rC))))]>;
Scott Michel66377522007-12-04 22:35:58 +00001931
Scott Michelf0569be2008-12-27 04:51:36 +00001932class SELBRegCondInst<RegisterClass rcond, RegisterClass rclass>:
1933 SELBInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB, rcond:$rC),
1934 [(set rclass:$rT,
1935 (select rcond:$rC, rclass:$rB, rclass:$rA))]>;
1936
Scott Michelad2715e2008-03-05 23:02:02 +00001937multiclass SelectBits
1938{
1939 def v16i8: SELBVecInst<v16i8>;
1940 def v8i16: SELBVecInst<v8i16>;
1941 def v4i32: SELBVecInst<v4i32>;
Chris Lattner918472a2010-03-28 07:48:17 +00001942 def v2i64: SELBVecInst<v2i64, vnot_cell_conv>;
Scott Michel66377522007-12-04 22:35:58 +00001943
Scott Michelad2715e2008-03-05 23:02:02 +00001944 def r128: SELBRegInst<GPRC>;
1945 def r64: SELBRegInst<R64C>;
1946 def r32: SELBRegInst<R32C>;
1947 def r16: SELBRegInst<R16C>;
1948 def r8: SELBRegInst<R8C>;
Scott Michelf0569be2008-12-27 04:51:36 +00001949
1950 def v16i8_cond: SELBVecCondInst<v16i8>;
1951 def v8i16_cond: SELBVecCondInst<v8i16>;
1952 def v4i32_cond: SELBVecCondInst<v4i32>;
1953 def v2i64_cond: SELBVecCondInst<v2i64>;
1954
Scott Michel02d711b2008-12-30 23:28:25 +00001955 def v16i8_vcond: SELBVecCondInst<v16i8>;
1956 def v8i16_vcond: SELBVecCondInst<v8i16>;
1957 def v4i32_vcond: SELBVecCondInst<v4i32>;
1958 def v2i64_vcond: SELBVecCondInst<v2i64>;
1959
1960 def v4f32_cond:
Scott Michel19c10e62009-01-26 03:37:41 +00001961 SELBInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB, VECREG:$rC),
1962 [(set (v4f32 VECREG:$rT),
1963 (select (v4i32 VECREG:$rC),
1964 (v4f32 VECREG:$rB),
1965 (v4f32 VECREG:$rA)))]>;
Scott Michel02d711b2008-12-30 23:28:25 +00001966
Scott Micheld1e8d9c2009-01-21 04:58:48 +00001967 // SELBr64_cond is defined in SPU64InstrInfo.td
Scott Michelf0569be2008-12-27 04:51:36 +00001968 def r32_cond: SELBRegCondInst<R32C, R32C>;
Scott Michel02d711b2008-12-30 23:28:25 +00001969 def f32_cond: SELBRegCondInst<R32C, R32FP>;
Scott Michelf0569be2008-12-27 04:51:36 +00001970 def r16_cond: SELBRegCondInst<R16C, R16C>;
1971 def r8_cond: SELBRegCondInst<R8C, R8C>;
Scott Michelad2715e2008-03-05 23:02:02 +00001972}
Scott Michel66377522007-12-04 22:35:58 +00001973
Scott Michelad2715e2008-03-05 23:02:02 +00001974defm SELB : SelectBits;
Scott Michel66377522007-12-04 22:35:58 +00001975
Scott Michel7a1c9e92008-11-22 23:50:42 +00001976class SPUselbPatVec<ValueType vectype, SPUInstr inst>:
Scott Michelad2715e2008-03-05 23:02:02 +00001977 Pat<(SPUselb (vectype VECREG:$rA), (vectype VECREG:$rB), (vectype VECREG:$rC)),
1978 (inst VECREG:$rA, VECREG:$rB, VECREG:$rC)>;
Scott Michel66377522007-12-04 22:35:58 +00001979
Scott Michel7a1c9e92008-11-22 23:50:42 +00001980def : SPUselbPatVec<v16i8, SELBv16i8>;
1981def : SPUselbPatVec<v8i16, SELBv8i16>;
1982def : SPUselbPatVec<v4i32, SELBv4i32>;
1983def : SPUselbPatVec<v2i64, SELBv2i64>;
1984
1985class SPUselbPatReg<RegisterClass rclass, SPUInstr inst>:
1986 Pat<(SPUselb rclass:$rA, rclass:$rB, rclass:$rC),
1987 (inst rclass:$rA, rclass:$rB, rclass:$rC)>;
1988
1989def : SPUselbPatReg<R8C, SELBr8>;
1990def : SPUselbPatReg<R16C, SELBr16>;
1991def : SPUselbPatReg<R32C, SELBr32>;
1992def : SPUselbPatReg<R64C, SELBr64>;
Scott Michel66377522007-12-04 22:35:58 +00001993
Scott Michelad2715e2008-03-05 23:02:02 +00001994// EQV: Equivalence (1 for each same bit, otherwise 0)
1995//
1996// Note: There are a lot of ways to match this bit operator and these patterns
1997// attempt to be as exhaustive as possible.
Scott Michel66377522007-12-04 22:35:58 +00001998
Scott Michelad2715e2008-03-05 23:02:02 +00001999class EQVInst<dag OOL, dag IOL, list<dag> pattern>:
2000 RRForm<0b10010010000, OOL, IOL, "eqv\t$rT, $rA, $rB",
2001 IntegerOp, pattern>;
Scott Michel66377522007-12-04 22:35:58 +00002002
Scott Michelad2715e2008-03-05 23:02:02 +00002003class EQVVecInst<ValueType vectype>:
2004 EQVInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
2005 [(set (vectype VECREG:$rT),
2006 (or (and (vectype VECREG:$rA), (vectype VECREG:$rB)),
2007 (and (vnot (vectype VECREG:$rA)),
2008 (vnot (vectype VECREG:$rB)))))]>;
Scott Michel66377522007-12-04 22:35:58 +00002009
Scott Michelad2715e2008-03-05 23:02:02 +00002010class EQVRegInst<RegisterClass rclass>:
2011 EQVInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB),
2012 [(set rclass:$rT, (or (and rclass:$rA, rclass:$rB),
2013 (and (not rclass:$rA), (not rclass:$rB))))]>;
Scott Michel66377522007-12-04 22:35:58 +00002014
Scott Michelad2715e2008-03-05 23:02:02 +00002015class EQVVecPattern1<ValueType vectype>:
2016 EQVInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
2017 [(set (vectype VECREG:$rT),
2018 (xor (vectype VECREG:$rA), (vnot (vectype VECREG:$rB))))]>;
Scott Michel66377522007-12-04 22:35:58 +00002019
Scott Michelad2715e2008-03-05 23:02:02 +00002020class EQVRegPattern1<RegisterClass rclass>:
2021 EQVInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB),
2022 [(set rclass:$rT, (xor rclass:$rA, (not rclass:$rB)))]>;
Scott Michel66377522007-12-04 22:35:58 +00002023
Scott Michelad2715e2008-03-05 23:02:02 +00002024class EQVVecPattern2<ValueType vectype>:
2025 EQVInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
2026 [(set (vectype VECREG:$rT),
2027 (or (and (vectype VECREG:$rA), (vectype VECREG:$rB)),
2028 (vnot (or (vectype VECREG:$rA), (vectype VECREG:$rB)))))]>;
Scott Michel66377522007-12-04 22:35:58 +00002029
Scott Michelad2715e2008-03-05 23:02:02 +00002030class EQVRegPattern2<RegisterClass rclass>:
2031 EQVInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB),
2032 [(set rclass:$rT,
2033 (or (and rclass:$rA, rclass:$rB),
2034 (not (or rclass:$rA, rclass:$rB))))]>;
Scott Michel66377522007-12-04 22:35:58 +00002035
Scott Michelad2715e2008-03-05 23:02:02 +00002036class EQVVecPattern3<ValueType vectype>:
2037 EQVInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
2038 [(set (vectype VECREG:$rT),
2039 (not (xor (vectype VECREG:$rA), (vectype VECREG:$rB))))]>;
Scott Michel66377522007-12-04 22:35:58 +00002040
Scott Michelad2715e2008-03-05 23:02:02 +00002041class EQVRegPattern3<RegisterClass rclass>:
2042 EQVInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB),
2043 [(set rclass:$rT, (not (xor rclass:$rA, rclass:$rB)))]>;
Scott Michel66377522007-12-04 22:35:58 +00002044
Scott Michelad2715e2008-03-05 23:02:02 +00002045multiclass BitEquivalence
2046{
2047 def v16i8: EQVVecInst<v16i8>;
2048 def v8i16: EQVVecInst<v8i16>;
2049 def v4i32: EQVVecInst<v4i32>;
2050 def v2i64: EQVVecInst<v2i64>;
Scott Michel66377522007-12-04 22:35:58 +00002051
Scott Michelad2715e2008-03-05 23:02:02 +00002052 def v16i8_1: EQVVecPattern1<v16i8>;
2053 def v8i16_1: EQVVecPattern1<v8i16>;
2054 def v4i32_1: EQVVecPattern1<v4i32>;
2055 def v2i64_1: EQVVecPattern1<v2i64>;
Scott Michel66377522007-12-04 22:35:58 +00002056
Scott Michelad2715e2008-03-05 23:02:02 +00002057 def v16i8_2: EQVVecPattern2<v16i8>;
2058 def v8i16_2: EQVVecPattern2<v8i16>;
2059 def v4i32_2: EQVVecPattern2<v4i32>;
2060 def v2i64_2: EQVVecPattern2<v2i64>;
Scott Michel66377522007-12-04 22:35:58 +00002061
Scott Michelad2715e2008-03-05 23:02:02 +00002062 def v16i8_3: EQVVecPattern3<v16i8>;
2063 def v8i16_3: EQVVecPattern3<v8i16>;
2064 def v4i32_3: EQVVecPattern3<v4i32>;
2065 def v2i64_3: EQVVecPattern3<v2i64>;
Scott Michel66377522007-12-04 22:35:58 +00002066
Scott Michelad2715e2008-03-05 23:02:02 +00002067 def r128: EQVRegInst<GPRC>;
2068 def r64: EQVRegInst<R64C>;
2069 def r32: EQVRegInst<R32C>;
2070 def r16: EQVRegInst<R16C>;
2071 def r8: EQVRegInst<R8C>;
Scott Michel66377522007-12-04 22:35:58 +00002072
Scott Michelad2715e2008-03-05 23:02:02 +00002073 def r128_1: EQVRegPattern1<GPRC>;
2074 def r64_1: EQVRegPattern1<R64C>;
2075 def r32_1: EQVRegPattern1<R32C>;
2076 def r16_1: EQVRegPattern1<R16C>;
2077 def r8_1: EQVRegPattern1<R8C>;
Scott Michel66377522007-12-04 22:35:58 +00002078
Scott Michelad2715e2008-03-05 23:02:02 +00002079 def r128_2: EQVRegPattern2<GPRC>;
2080 def r64_2: EQVRegPattern2<R64C>;
2081 def r32_2: EQVRegPattern2<R32C>;
2082 def r16_2: EQVRegPattern2<R16C>;
2083 def r8_2: EQVRegPattern2<R8C>;
Scott Michel66377522007-12-04 22:35:58 +00002084
Scott Michelad2715e2008-03-05 23:02:02 +00002085 def r128_3: EQVRegPattern3<GPRC>;
2086 def r64_3: EQVRegPattern3<R64C>;
2087 def r32_3: EQVRegPattern3<R32C>;
2088 def r16_3: EQVRegPattern3<R16C>;
2089 def r8_3: EQVRegPattern3<R8C>;
2090}
Scott Michel504c3692007-12-17 22:32:34 +00002091
Scott Michelad2715e2008-03-05 23:02:02 +00002092defm EQV: BitEquivalence;
Scott Michel66377522007-12-04 22:35:58 +00002093
2094//===----------------------------------------------------------------------===//
2095// Vector shuffle...
2096//===----------------------------------------------------------------------===//
Scott Michel66377522007-12-04 22:35:58 +00002097// SPUshuffle is generated in LowerVECTOR_SHUFFLE and gets replaced with SHUFB.
2098// See the SPUshuffle SDNode operand above, which sets up the DAG pattern
2099// matcher to emit something when the LowerVECTOR_SHUFFLE generates a node with
2100// the SPUISD::SHUFB opcode.
Scott Michela59d4692008-02-23 18:41:37 +00002101//===----------------------------------------------------------------------===//
Scott Michel66377522007-12-04 22:35:58 +00002102
Scott Michela59d4692008-02-23 18:41:37 +00002103class SHUFBInst<dag OOL, dag IOL, list<dag> pattern>:
2104 RRRForm<0b1000, OOL, IOL, "shufb\t$rT, $rA, $rB, $rC",
2105 IntegerOp, pattern>;
Scott Michel66377522007-12-04 22:35:58 +00002106
Scott Michel1a6cdb62008-12-01 17:56:02 +00002107class SHUFBVecInst<ValueType resultvec, ValueType maskvec>:
Scott Michela59d4692008-02-23 18:41:37 +00002108 SHUFBInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB, VECREG:$rC),
Scott Michel1a6cdb62008-12-01 17:56:02 +00002109 [(set (resultvec VECREG:$rT),
2110 (SPUshuffle (resultvec VECREG:$rA),
2111 (resultvec VECREG:$rB),
2112 (maskvec VECREG:$rC)))]>;
Scott Michel86c041f2007-12-20 00:44:13 +00002113
Scott Michelf0569be2008-12-27 04:51:36 +00002114class SHUFBGPRCInst:
2115 SHUFBInst<(outs VECREG:$rT), (ins GPRC:$rA, GPRC:$rB, VECREG:$rC),
2116 [/* no pattern */]>;
2117
Scott Michela59d4692008-02-23 18:41:37 +00002118multiclass ShuffleBytes
2119{
Scott Michel1a6cdb62008-12-01 17:56:02 +00002120 def v16i8 : SHUFBVecInst<v16i8, v16i8>;
2121 def v16i8_m32 : SHUFBVecInst<v16i8, v4i32>;
2122 def v8i16 : SHUFBVecInst<v8i16, v16i8>;
2123 def v8i16_m32 : SHUFBVecInst<v8i16, v4i32>;
2124 def v4i32 : SHUFBVecInst<v4i32, v16i8>;
2125 def v4i32_m32 : SHUFBVecInst<v4i32, v4i32>;
2126 def v2i64 : SHUFBVecInst<v2i64, v16i8>;
2127 def v2i64_m32 : SHUFBVecInst<v2i64, v4i32>;
Scott Michel66377522007-12-04 22:35:58 +00002128
Scott Michel1a6cdb62008-12-01 17:56:02 +00002129 def v4f32 : SHUFBVecInst<v4f32, v16i8>;
2130 def v4f32_m32 : SHUFBVecInst<v4f32, v4i32>;
2131
2132 def v2f64 : SHUFBVecInst<v2f64, v16i8>;
2133 def v2f64_m32 : SHUFBVecInst<v2f64, v4i32>;
Scott Michelf0569be2008-12-27 04:51:36 +00002134
2135 def gprc : SHUFBGPRCInst;
Scott Michela59d4692008-02-23 18:41:37 +00002136}
2137
2138defm SHUFB : ShuffleBytes;
2139
Scott Michel66377522007-12-04 22:35:58 +00002140//===----------------------------------------------------------------------===//
2141// Shift and rotate group:
2142//===----------------------------------------------------------------------===//
2143
Scott Michela59d4692008-02-23 18:41:37 +00002144class SHLHInst<dag OOL, dag IOL, list<dag> pattern>:
2145 RRForm<0b11111010000, OOL, IOL, "shlh\t$rT, $rA, $rB",
2146 RotateShift, pattern>;
2147
2148class SHLHVecInst<ValueType vectype>:
2149 SHLHInst<(outs VECREG:$rT), (ins VECREG:$rA, R16C:$rB),
2150 [(set (vectype VECREG:$rT),
2151 (SPUvec_shl (vectype VECREG:$rA), R16C:$rB))]>;
Scott Michel66377522007-12-04 22:35:58 +00002152
Scott Michela59d4692008-02-23 18:41:37 +00002153multiclass ShiftLeftHalfword
2154{
2155 def v8i16: SHLHVecInst<v8i16>;
2156 def r16: SHLHInst<(outs R16C:$rT), (ins R16C:$rA, R16C:$rB),
2157 [(set R16C:$rT, (shl R16C:$rA, R16C:$rB))]>;
2158 def r16_r32: SHLHInst<(outs R16C:$rT), (ins R16C:$rA, R32C:$rB),
2159 [(set R16C:$rT, (shl R16C:$rA, R32C:$rB))]>;
2160}
Scott Michel66377522007-12-04 22:35:58 +00002161
Scott Michela59d4692008-02-23 18:41:37 +00002162defm SHLH : ShiftLeftHalfword;
Scott Michel66377522007-12-04 22:35:58 +00002163
Scott Michela59d4692008-02-23 18:41:37 +00002164//===----------------------------------------------------------------------===//
Scott Michel504c3692007-12-17 22:32:34 +00002165
Scott Michela59d4692008-02-23 18:41:37 +00002166class SHLHIInst<dag OOL, dag IOL, list<dag> pattern>:
2167 RI7Form<0b11111010000, OOL, IOL, "shlhi\t$rT, $rA, $val",
2168 RotateShift, pattern>;
Scott Michel66377522007-12-04 22:35:58 +00002169
Scott Michela59d4692008-02-23 18:41:37 +00002170class SHLHIVecInst<ValueType vectype>:
2171 SHLHIInst<(outs VECREG:$rT), (ins VECREG:$rA, u7imm:$val),
2172 [(set (vectype VECREG:$rT),
2173 (SPUvec_shl (vectype VECREG:$rA), (i16 uimm7:$val)))]>;
Scott Michel66377522007-12-04 22:35:58 +00002174
Scott Michela59d4692008-02-23 18:41:37 +00002175multiclass ShiftLeftHalfwordImm
2176{
2177 def v8i16: SHLHIVecInst<v8i16>;
2178 def r16: SHLHIInst<(outs R16C:$rT), (ins R16C:$rA, u7imm:$val),
2179 [(set R16C:$rT, (shl R16C:$rA, (i16 uimm7:$val)))]>;
2180}
2181
2182defm SHLHI : ShiftLeftHalfwordImm;
2183
2184def : Pat<(SPUvec_shl (v8i16 VECREG:$rA), (i32 uimm7:$val)),
Chris Lattner420c69d2010-03-15 05:53:47 +00002185 (SHLHIv8i16 VECREG:$rA, (TO_IMM16 uimm7:$val))>;
Scott Michela59d4692008-02-23 18:41:37 +00002186
2187def : Pat<(shl R16C:$rA, (i32 uimm7:$val)),
Chris Lattner420c69d2010-03-15 05:53:47 +00002188 (SHLHIr16 R16C:$rA, (TO_IMM16 uimm7:$val))>;
Scott Michel66377522007-12-04 22:35:58 +00002189
Scott Michela59d4692008-02-23 18:41:37 +00002190//===----------------------------------------------------------------------===//
Scott Michel66377522007-12-04 22:35:58 +00002191
Scott Michela59d4692008-02-23 18:41:37 +00002192class SHLInst<dag OOL, dag IOL, list<dag> pattern>:
2193 RRForm<0b11111010000, OOL, IOL, "shl\t$rT, $rA, $rB",
2194 RotateShift, pattern>;
Scott Michel66377522007-12-04 22:35:58 +00002195
Scott Michela59d4692008-02-23 18:41:37 +00002196multiclass ShiftLeftWord
2197{
2198 def v4i32:
2199 SHLInst<(outs VECREG:$rT), (ins VECREG:$rA, R16C:$rB),
2200 [(set (v4i32 VECREG:$rT),
2201 (SPUvec_shl (v4i32 VECREG:$rA), R16C:$rB))]>;
2202 def r32:
2203 SHLInst<(outs R32C:$rT), (ins R32C:$rA, R32C:$rB),
2204 [(set R32C:$rT, (shl R32C:$rA, R32C:$rB))]>;
2205}
Scott Michel66377522007-12-04 22:35:58 +00002206
Scott Michela59d4692008-02-23 18:41:37 +00002207defm SHL: ShiftLeftWord;
Scott Michel504c3692007-12-17 22:32:34 +00002208
Scott Michela59d4692008-02-23 18:41:37 +00002209//===----------------------------------------------------------------------===//
Scott Michel66377522007-12-04 22:35:58 +00002210
Scott Michela59d4692008-02-23 18:41:37 +00002211class SHLIInst<dag OOL, dag IOL, list<dag> pattern>:
2212 RI7Form<0b11111010000, OOL, IOL, "shli\t$rT, $rA, $val",
2213 RotateShift, pattern>;
Scott Michel66377522007-12-04 22:35:58 +00002214
Scott Michela59d4692008-02-23 18:41:37 +00002215multiclass ShiftLeftWordImm
2216{
2217 def v4i32:
2218 SHLIInst<(outs VECREG:$rT), (ins VECREG:$rA, u7imm_i32:$val),
2219 [(set (v4i32 VECREG:$rT),
2220 (SPUvec_shl (v4i32 VECREG:$rA), (i32 uimm7:$val)))]>;
Scott Michel66377522007-12-04 22:35:58 +00002221
Scott Michela59d4692008-02-23 18:41:37 +00002222 def r32:
2223 SHLIInst<(outs R32C:$rT), (ins R32C:$rA, u7imm_i32:$val),
2224 [(set R32C:$rT, (shl R32C:$rA, (i32 uimm7:$val)))]>;
2225}
Scott Michel66377522007-12-04 22:35:58 +00002226
Scott Michela59d4692008-02-23 18:41:37 +00002227defm SHLI : ShiftLeftWordImm;
Scott Michel504c3692007-12-17 22:32:34 +00002228
Scott Michela59d4692008-02-23 18:41:37 +00002229//===----------------------------------------------------------------------===//
Scott Michel66377522007-12-04 22:35:58 +00002230// SHLQBI vec form: Note that this will shift the entire vector (the 128-bit
2231// register) to the left. Vector form is here to ensure type correctness.
Scott Michela59d4692008-02-23 18:41:37 +00002232//
2233// The shift count is in the lowest 3 bits (29-31) of $rB, so only a bit shift
2234// of 7 bits is actually possible.
2235//
2236// Note also that SHLQBI/SHLQBII are used in conjunction with SHLQBY/SHLQBYI
2237// to shift i64 and i128. SHLQBI is the residual left over after shifting by
2238// bytes with SHLQBY.
Scott Michel66377522007-12-04 22:35:58 +00002239
Scott Michela59d4692008-02-23 18:41:37 +00002240class SHLQBIInst<dag OOL, dag IOL, list<dag> pattern>:
2241 RRForm<0b11011011100, OOL, IOL, "shlqbi\t$rT, $rA, $rB",
2242 RotateShift, pattern>;
2243
2244class SHLQBIVecInst<ValueType vectype>:
2245 SHLQBIInst<(outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB),
2246 [(set (vectype VECREG:$rT),
2247 (SPUshlquad_l_bits (vectype VECREG:$rA), R32C:$rB))]>;
2248
Scott Micheld1e8d9c2009-01-21 04:58:48 +00002249class SHLQBIRegInst<RegisterClass rclass>:
2250 SHLQBIInst<(outs rclass:$rT), (ins rclass:$rA, R32C:$rB),
2251 [/* no pattern */]>;
2252
Scott Michela59d4692008-02-23 18:41:37 +00002253multiclass ShiftLeftQuadByBits
2254{
2255 def v16i8: SHLQBIVecInst<v16i8>;
2256 def v8i16: SHLQBIVecInst<v8i16>;
2257 def v4i32: SHLQBIVecInst<v4i32>;
Scott Michel7a1c9e92008-11-22 23:50:42 +00002258 def v4f32: SHLQBIVecInst<v4f32>;
Scott Michela59d4692008-02-23 18:41:37 +00002259 def v2i64: SHLQBIVecInst<v2i64>;
Scott Michel7a1c9e92008-11-22 23:50:42 +00002260 def v2f64: SHLQBIVecInst<v2f64>;
Scott Micheld1e8d9c2009-01-21 04:58:48 +00002261
2262 def r128: SHLQBIRegInst<GPRC>;
Scott Michela59d4692008-02-23 18:41:37 +00002263}
2264
2265defm SHLQBI : ShiftLeftQuadByBits;
2266
2267// See note above on SHLQBI. In this case, the predicate actually does then
2268// enforcement, whereas with SHLQBI, we have to "take it on faith."
2269class SHLQBIIInst<dag OOL, dag IOL, list<dag> pattern>:
2270 RI7Form<0b11011111100, OOL, IOL, "shlqbii\t$rT, $rA, $val",
2271 RotateShift, pattern>;
2272
2273class SHLQBIIVecInst<ValueType vectype>:
2274 SHLQBIIInst<(outs VECREG:$rT), (ins VECREG:$rA, u7imm_i32:$val),
2275 [(set (vectype VECREG:$rT),
2276 (SPUshlquad_l_bits (vectype VECREG:$rA), (i32 bitshift:$val)))]>;
2277
2278multiclass ShiftLeftQuadByBitsImm
2279{
2280 def v16i8 : SHLQBIIVecInst<v16i8>;
2281 def v8i16 : SHLQBIIVecInst<v8i16>;
2282 def v4i32 : SHLQBIIVecInst<v4i32>;
Scott Michel7a1c9e92008-11-22 23:50:42 +00002283 def v4f32 : SHLQBIIVecInst<v4f32>;
Scott Michela59d4692008-02-23 18:41:37 +00002284 def v2i64 : SHLQBIIVecInst<v2i64>;
Scott Michel7a1c9e92008-11-22 23:50:42 +00002285 def v2f64 : SHLQBIIVecInst<v2f64>;
Scott Michela59d4692008-02-23 18:41:37 +00002286}
2287
2288defm SHLQBII : ShiftLeftQuadByBitsImm;
Scott Michel66377522007-12-04 22:35:58 +00002289
2290// SHLQBY, SHLQBYI vector forms: Shift the entire vector to the left by bytes,
Scott Michela59d4692008-02-23 18:41:37 +00002291// not by bits. See notes above on SHLQBI.
Scott Michel66377522007-12-04 22:35:58 +00002292
Scott Michela59d4692008-02-23 18:41:37 +00002293class SHLQBYInst<dag OOL, dag IOL, list<dag> pattern>:
Scott Michel662165d2008-11-25 00:23:16 +00002294 RI7Form<0b11111011100, OOL, IOL, "shlqby\t$rT, $rA, $rB",
Scott Michela59d4692008-02-23 18:41:37 +00002295 RotateShift, pattern>;
Scott Michel66377522007-12-04 22:35:58 +00002296
Scott Michela59d4692008-02-23 18:41:37 +00002297class SHLQBYVecInst<ValueType vectype>:
2298 SHLQBYInst<(outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB),
2299 [(set (vectype VECREG:$rT),
2300 (SPUshlquad_l_bytes (vectype VECREG:$rA), R32C:$rB))]>;
Scott Michel66377522007-12-04 22:35:58 +00002301
Scott Michela59d4692008-02-23 18:41:37 +00002302multiclass ShiftLeftQuadBytes
2303{
2304 def v16i8: SHLQBYVecInst<v16i8>;
2305 def v8i16: SHLQBYVecInst<v8i16>;
2306 def v4i32: SHLQBYVecInst<v4i32>;
Scott Michel7a1c9e92008-11-22 23:50:42 +00002307 def v4f32: SHLQBYVecInst<v4f32>;
Scott Michela59d4692008-02-23 18:41:37 +00002308 def v2i64: SHLQBYVecInst<v2i64>;
Scott Michel7a1c9e92008-11-22 23:50:42 +00002309 def v2f64: SHLQBYVecInst<v2f64>;
Scott Michela59d4692008-02-23 18:41:37 +00002310 def r128: SHLQBYInst<(outs GPRC:$rT), (ins GPRC:$rA, R32C:$rB),
2311 [(set GPRC:$rT, (SPUshlquad_l_bytes GPRC:$rA, R32C:$rB))]>;
2312}
Scott Michel66377522007-12-04 22:35:58 +00002313
Scott Michela59d4692008-02-23 18:41:37 +00002314defm SHLQBY: ShiftLeftQuadBytes;
Scott Michel66377522007-12-04 22:35:58 +00002315
Scott Michela59d4692008-02-23 18:41:37 +00002316class SHLQBYIInst<dag OOL, dag IOL, list<dag> pattern>:
2317 RI7Form<0b11111111100, OOL, IOL, "shlqbyi\t$rT, $rA, $val",
2318 RotateShift, pattern>;
Scott Michel504c3692007-12-17 22:32:34 +00002319
Scott Michela59d4692008-02-23 18:41:37 +00002320class SHLQBYIVecInst<ValueType vectype>:
2321 SHLQBYIInst<(outs VECREG:$rT), (ins VECREG:$rA, u7imm_i32:$val),
2322 [(set (vectype VECREG:$rT),
2323 (SPUshlquad_l_bytes (vectype VECREG:$rA), (i32 uimm7:$val)))]>;
Scott Michel504c3692007-12-17 22:32:34 +00002324
Scott Michela59d4692008-02-23 18:41:37 +00002325multiclass ShiftLeftQuadBytesImm
2326{
2327 def v16i8: SHLQBYIVecInst<v16i8>;
2328 def v8i16: SHLQBYIVecInst<v8i16>;
2329 def v4i32: SHLQBYIVecInst<v4i32>;
Scott Michel7a1c9e92008-11-22 23:50:42 +00002330 def v4f32: SHLQBYIVecInst<v4f32>;
Scott Michela59d4692008-02-23 18:41:37 +00002331 def v2i64: SHLQBYIVecInst<v2i64>;
Scott Michel7a1c9e92008-11-22 23:50:42 +00002332 def v2f64: SHLQBYIVecInst<v2f64>;
Scott Michela59d4692008-02-23 18:41:37 +00002333 def r128: SHLQBYIInst<(outs GPRC:$rT), (ins GPRC:$rA, u7imm_i32:$val),
2334 [(set GPRC:$rT,
2335 (SPUshlquad_l_bytes GPRC:$rA, (i32 uimm7:$val)))]>;
2336}
Scott Michel504c3692007-12-17 22:32:34 +00002337
Scott Michela59d4692008-02-23 18:41:37 +00002338defm SHLQBYI : ShiftLeftQuadBytesImm;
Scott Michel504c3692007-12-17 22:32:34 +00002339
Scott Micheld1e8d9c2009-01-21 04:58:48 +00002340class SHLQBYBIInst<dag OOL, dag IOL, list<dag> pattern>:
2341 RRForm<0b00111001111, OOL, IOL, "shlqbybi\t$rT, $rA, $rB",
2342 RotateShift, pattern>;
2343
2344class SHLQBYBIVecInst<ValueType vectype>:
2345 SHLQBYBIInst<(outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB),
2346 [/* no pattern */]>;
2347
2348class SHLQBYBIRegInst<RegisterClass rclass>:
2349 SHLQBYBIInst<(outs rclass:$rT), (ins rclass:$rA, R32C:$rB),
2350 [/* no pattern */]>;
2351
2352multiclass ShiftLeftQuadBytesBitCount
2353{
2354 def v16i8: SHLQBYBIVecInst<v16i8>;
2355 def v8i16: SHLQBYBIVecInst<v8i16>;
2356 def v4i32: SHLQBYBIVecInst<v4i32>;
2357 def v4f32: SHLQBYBIVecInst<v4f32>;
2358 def v2i64: SHLQBYBIVecInst<v2i64>;
2359 def v2f64: SHLQBYBIVecInst<v2f64>;
2360
2361 def r128: SHLQBYBIRegInst<GPRC>;
2362}
2363
2364defm SHLQBYBI : ShiftLeftQuadBytesBitCount;
2365
Scott Michela59d4692008-02-23 18:41:37 +00002366//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2367// Rotate halfword:
2368//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2369class ROTHInst<dag OOL, dag IOL, list<dag> pattern>:
2370 RRForm<0b00111010000, OOL, IOL, "roth\t$rT, $rA, $rB",
2371 RotateShift, pattern>;
2372
2373class ROTHVecInst<ValueType vectype>:
2374 ROTHInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
2375 [(set (vectype VECREG:$rT),
Chris Lattnerdd6fbd12010-03-08 18:59:49 +00002376 (SPUvec_rotl VECREG:$rA, (v8i16 VECREG:$rB)))]>;
Scott Michela59d4692008-02-23 18:41:37 +00002377
2378class ROTHRegInst<RegisterClass rclass>:
2379 ROTHInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB),
2380 [(set rclass:$rT, (rotl rclass:$rA, rclass:$rB))]>;
2381
2382multiclass RotateLeftHalfword
2383{
2384 def v8i16: ROTHVecInst<v8i16>;
2385 def r16: ROTHRegInst<R16C>;
2386}
2387
2388defm ROTH: RotateLeftHalfword;
2389
2390def ROTHr16_r32: ROTHInst<(outs R16C:$rT), (ins R16C:$rA, R32C:$rB),
2391 [(set R16C:$rT, (rotl R16C:$rA, R32C:$rB))]>;
2392
2393//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2394// Rotate halfword, immediate:
2395//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2396class ROTHIInst<dag OOL, dag IOL, list<dag> pattern>:
2397 RI7Form<0b00111110000, OOL, IOL, "rothi\t$rT, $rA, $val",
2398 RotateShift, pattern>;
2399
2400class ROTHIVecInst<ValueType vectype>:
2401 ROTHIInst<(outs VECREG:$rT), (ins VECREG:$rA, u7imm:$val),
2402 [(set (vectype VECREG:$rT),
2403 (SPUvec_rotl VECREG:$rA, (i16 uimm7:$val)))]>;
2404
2405multiclass RotateLeftHalfwordImm
2406{
2407 def v8i16: ROTHIVecInst<v8i16>;
2408 def r16: ROTHIInst<(outs R16C:$rT), (ins R16C:$rA, u7imm:$val),
2409 [(set R16C:$rT, (rotl R16C:$rA, (i16 uimm7:$val)))]>;
2410 def r16_r32: ROTHIInst<(outs R16C:$rT), (ins R16C:$rA, u7imm_i32:$val),
2411 [(set R16C:$rT, (rotl R16C:$rA, (i32 uimm7:$val)))]>;
2412}
2413
2414defm ROTHI: RotateLeftHalfwordImm;
2415
Chris Lattner420c69d2010-03-15 05:53:47 +00002416def : Pat<(SPUvec_rotl (v8i16 VECREG:$rA), (i32 uimm7:$val)),
2417 (ROTHIv8i16 VECREG:$rA, (TO_IMM16 imm:$val))>;
Scott Michelf0569be2008-12-27 04:51:36 +00002418
Scott Michela59d4692008-02-23 18:41:37 +00002419//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2420// Rotate word:
2421//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
Scott Michel66377522007-12-04 22:35:58 +00002422
Scott Michela59d4692008-02-23 18:41:37 +00002423class ROTInst<dag OOL, dag IOL, list<dag> pattern>:
2424 RRForm<0b00011010000, OOL, IOL, "rot\t$rT, $rA, $rB",
2425 RotateShift, pattern>;
Scott Michel66377522007-12-04 22:35:58 +00002426
Scott Michela59d4692008-02-23 18:41:37 +00002427class ROTVecInst<ValueType vectype>:
2428 ROTInst<(outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB),
2429 [(set (vectype VECREG:$rT),
2430 (SPUvec_rotl (vectype VECREG:$rA), R32C:$rB))]>;
Scott Michel504c3692007-12-17 22:32:34 +00002431
Scott Michela59d4692008-02-23 18:41:37 +00002432class ROTRegInst<RegisterClass rclass>:
2433 ROTInst<(outs rclass:$rT), (ins rclass:$rA, R32C:$rB),
2434 [(set rclass:$rT,
2435 (rotl rclass:$rA, R32C:$rB))]>;
Scott Michel66377522007-12-04 22:35:58 +00002436
Scott Michela59d4692008-02-23 18:41:37 +00002437multiclass RotateLeftWord
2438{
2439 def v4i32: ROTVecInst<v4i32>;
2440 def r32: ROTRegInst<R32C>;
2441}
2442
2443defm ROT: RotateLeftWord;
Scott Michel66377522007-12-04 22:35:58 +00002444
Scott Michel504c3692007-12-17 22:32:34 +00002445// The rotate amount is in the same bits whether we've got an 8-bit, 16-bit or
2446// 32-bit register
2447def ROTr32_r16_anyext:
Scott Michela59d4692008-02-23 18:41:37 +00002448 ROTInst<(outs R32C:$rT), (ins R32C:$rA, R16C:$rB),
2449 [(set R32C:$rT, (rotl R32C:$rA, (i32 (anyext R16C:$rB))))]>;
Scott Michel504c3692007-12-17 22:32:34 +00002450
2451def : Pat<(rotl R32C:$rA, (i32 (zext R16C:$rB))),
2452 (ROTr32_r16_anyext R32C:$rA, R16C:$rB)>;
2453
2454def : Pat<(rotl R32C:$rA, (i32 (sext R16C:$rB))),
2455 (ROTr32_r16_anyext R32C:$rA, R16C:$rB)>;
2456
2457def ROTr32_r8_anyext:
Scott Michela59d4692008-02-23 18:41:37 +00002458 ROTInst<(outs R32C:$rT), (ins R32C:$rA, R8C:$rB),
2459 [(set R32C:$rT, (rotl R32C:$rA, (i32 (anyext R8C:$rB))))]>;
Scott Michel504c3692007-12-17 22:32:34 +00002460
2461def : Pat<(rotl R32C:$rA, (i32 (zext R8C:$rB))),
2462 (ROTr32_r8_anyext R32C:$rA, R8C:$rB)>;
2463
2464def : Pat<(rotl R32C:$rA, (i32 (sext R8C:$rB))),
2465 (ROTr32_r8_anyext R32C:$rA, R8C:$rB)>;
2466
Scott Michela59d4692008-02-23 18:41:37 +00002467//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2468// Rotate word, immediate
2469//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
Scott Michel66377522007-12-04 22:35:58 +00002470
Scott Michela59d4692008-02-23 18:41:37 +00002471class ROTIInst<dag OOL, dag IOL, list<dag> pattern>:
2472 RI7Form<0b00011110000, OOL, IOL, "roti\t$rT, $rA, $val",
2473 RotateShift, pattern>;
Scott Michel66377522007-12-04 22:35:58 +00002474
Scott Michela59d4692008-02-23 18:41:37 +00002475class ROTIVecInst<ValueType vectype, Operand optype, ValueType inttype, PatLeaf pred>:
2476 ROTIInst<(outs VECREG:$rT), (ins VECREG:$rA, optype:$val),
2477 [(set (vectype VECREG:$rT),
2478 (SPUvec_rotl (vectype VECREG:$rA), (inttype pred:$val)))]>;
Scott Michel504c3692007-12-17 22:32:34 +00002479
Scott Michela59d4692008-02-23 18:41:37 +00002480class ROTIRegInst<RegisterClass rclass, Operand optype, ValueType inttype, PatLeaf pred>:
2481 ROTIInst<(outs rclass:$rT), (ins rclass:$rA, optype:$val),
2482 [(set rclass:$rT, (rotl rclass:$rA, (inttype pred:$val)))]>;
Scott Michel66377522007-12-04 22:35:58 +00002483
Scott Michela59d4692008-02-23 18:41:37 +00002484multiclass RotateLeftWordImm
2485{
2486 def v4i32: ROTIVecInst<v4i32, u7imm_i32, i32, uimm7>;
2487 def v4i32_i16: ROTIVecInst<v4i32, u7imm, i16, uimm7>;
2488 def v4i32_i8: ROTIVecInst<v4i32, u7imm_i8, i8, uimm7>;
Scott Michel66377522007-12-04 22:35:58 +00002489
Scott Michela59d4692008-02-23 18:41:37 +00002490 def r32: ROTIRegInst<R32C, u7imm_i32, i32, uimm7>;
2491 def r32_i16: ROTIRegInst<R32C, u7imm, i16, uimm7>;
2492 def r32_i8: ROTIRegInst<R32C, u7imm_i8, i8, uimm7>;
2493}
Scott Michel504c3692007-12-17 22:32:34 +00002494
Scott Michela59d4692008-02-23 18:41:37 +00002495defm ROTI : RotateLeftWordImm;
2496
2497//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2498// Rotate quad by byte (count)
2499//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2500
2501class ROTQBYInst<dag OOL, dag IOL, list<dag> pattern>:
2502 RRForm<0b00111011100, OOL, IOL, "rotqby\t$rT, $rA, $rB",
2503 RotateShift, pattern>;
2504
2505class ROTQBYVecInst<ValueType vectype>:
2506 ROTQBYInst<(outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB),
2507 [(set (vectype VECREG:$rT),
2508 (SPUrotbytes_left (vectype VECREG:$rA), R32C:$rB))]>;
2509
2510multiclass RotateQuadLeftByBytes
2511{
2512 def v16i8: ROTQBYVecInst<v16i8>;
2513 def v8i16: ROTQBYVecInst<v8i16>;
2514 def v4i32: ROTQBYVecInst<v4i32>;
Scott Michelcc188272008-12-04 21:01:44 +00002515 def v4f32: ROTQBYVecInst<v4f32>;
Scott Michela59d4692008-02-23 18:41:37 +00002516 def v2i64: ROTQBYVecInst<v2i64>;
Scott Michelcc188272008-12-04 21:01:44 +00002517 def v2f64: ROTQBYVecInst<v2f64>;
Scott Michela59d4692008-02-23 18:41:37 +00002518}
2519
2520defm ROTQBY: RotateQuadLeftByBytes;
Scott Michel66377522007-12-04 22:35:58 +00002521
Scott Michela59d4692008-02-23 18:41:37 +00002522//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2523// Rotate quad by byte (count), immediate
2524//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2525
2526class ROTQBYIInst<dag OOL, dag IOL, list<dag> pattern>:
2527 RI7Form<0b00111111100, OOL, IOL, "rotqbyi\t$rT, $rA, $val",
2528 RotateShift, pattern>;
2529
2530class ROTQBYIVecInst<ValueType vectype>:
2531 ROTQBYIInst<(outs VECREG:$rT), (ins VECREG:$rA, u7imm:$val),
2532 [(set (vectype VECREG:$rT),
2533 (SPUrotbytes_left (vectype VECREG:$rA), (i16 uimm7:$val)))]>;
2534
2535multiclass RotateQuadByBytesImm
2536{
2537 def v16i8: ROTQBYIVecInst<v16i8>;
2538 def v8i16: ROTQBYIVecInst<v8i16>;
2539 def v4i32: ROTQBYIVecInst<v4i32>;
Scott Michelcc188272008-12-04 21:01:44 +00002540 def v4f32: ROTQBYIVecInst<v4f32>;
Scott Michela59d4692008-02-23 18:41:37 +00002541 def v2i64: ROTQBYIVecInst<v2i64>;
Scott Michelcc188272008-12-04 21:01:44 +00002542 def vfi64: ROTQBYIVecInst<v2f64>;
Scott Michela59d4692008-02-23 18:41:37 +00002543}
2544
2545defm ROTQBYI: RotateQuadByBytesImm;
Scott Michel66377522007-12-04 22:35:58 +00002546
Scott Michel66377522007-12-04 22:35:58 +00002547// See ROTQBY note above.
Scott Michel8bf61e82008-06-02 22:18:03 +00002548class ROTQBYBIInst<dag OOL, dag IOL, list<dag> pattern>:
2549 RI7Form<0b00110011100, OOL, IOL,
2550 "rotqbybi\t$rT, $rA, $shift",
2551 RotateShift, pattern>;
2552
2553class ROTQBYBIVecInst<ValueType vectype, RegisterClass rclass>:
2554 ROTQBYBIInst<(outs VECREG:$rT), (ins VECREG:$rA, rclass:$shift),
2555 [(set (vectype VECREG:$rT),
2556 (SPUrotbytes_left_bits (vectype VECREG:$rA), rclass:$shift))]>;
2557
2558multiclass RotateQuadByBytesByBitshift {
2559 def v16i8_r32: ROTQBYBIVecInst<v16i8, R32C>;
2560 def v8i16_r32: ROTQBYBIVecInst<v8i16, R32C>;
2561 def v4i32_r32: ROTQBYBIVecInst<v4i32, R32C>;
2562 def v2i64_r32: ROTQBYBIVecInst<v2i64, R32C>;
2563}
2564
2565defm ROTQBYBI : RotateQuadByBytesByBitshift;
Scott Michel66377522007-12-04 22:35:58 +00002566
Scott Michela59d4692008-02-23 18:41:37 +00002567//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
Scott Michel66377522007-12-04 22:35:58 +00002568// See ROTQBY note above.
2569//
2570// Assume that the user of this instruction knows to shift the rotate count
2571// into bit 29
Scott Michela59d4692008-02-23 18:41:37 +00002572//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
Scott Michel66377522007-12-04 22:35:58 +00002573
Scott Michela59d4692008-02-23 18:41:37 +00002574class ROTQBIInst<dag OOL, dag IOL, list<dag> pattern>:
2575 RRForm<0b00011011100, OOL, IOL, "rotqbi\t$rT, $rA, $rB",
2576 RotateShift, pattern>;
Scott Michel66377522007-12-04 22:35:58 +00002577
Scott Michela59d4692008-02-23 18:41:37 +00002578class ROTQBIVecInst<ValueType vectype>:
Scott Michel02d711b2008-12-30 23:28:25 +00002579 ROTQBIInst<(outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB),
Scott Michela59d4692008-02-23 18:41:37 +00002580 [/* no pattern yet */]>;
2581
2582class ROTQBIRegInst<RegisterClass rclass>:
Scott Michel02d711b2008-12-30 23:28:25 +00002583 ROTQBIInst<(outs rclass:$rT), (ins rclass:$rA, R32C:$rB),
Scott Michela59d4692008-02-23 18:41:37 +00002584 [/* no pattern yet */]>;
2585
2586multiclass RotateQuadByBitCount
2587{
2588 def v16i8: ROTQBIVecInst<v16i8>;
2589 def v8i16: ROTQBIVecInst<v8i16>;
2590 def v4i32: ROTQBIVecInst<v4i32>;
2591 def v2i64: ROTQBIVecInst<v2i64>;
2592
2593 def r128: ROTQBIRegInst<GPRC>;
2594 def r64: ROTQBIRegInst<R64C>;
2595}
2596
2597defm ROTQBI: RotateQuadByBitCount;
Scott Michelf0569be2008-12-27 04:51:36 +00002598
Scott Michela59d4692008-02-23 18:41:37 +00002599class ROTQBIIInst<dag OOL, dag IOL, list<dag> pattern>:
2600 RI7Form<0b00011111100, OOL, IOL, "rotqbii\t$rT, $rA, $val",
2601 RotateShift, pattern>;
2602
2603class ROTQBIIVecInst<ValueType vectype, Operand optype, ValueType inttype,
2604 PatLeaf pred>:
2605 ROTQBIIInst<(outs VECREG:$rT), (ins VECREG:$rA, optype:$val),
2606 [/* no pattern yet */]>;
2607
2608class ROTQBIIRegInst<RegisterClass rclass, Operand optype, ValueType inttype,
2609 PatLeaf pred>:
2610 ROTQBIIInst<(outs rclass:$rT), (ins rclass:$rA, optype:$val),
2611 [/* no pattern yet */]>;
2612
2613multiclass RotateQuadByBitCountImm
2614{
2615 def v16i8: ROTQBIIVecInst<v16i8, u7imm_i32, i32, uimm7>;
2616 def v8i16: ROTQBIIVecInst<v8i16, u7imm_i32, i32, uimm7>;
2617 def v4i32: ROTQBIIVecInst<v4i32, u7imm_i32, i32, uimm7>;
2618 def v2i64: ROTQBIIVecInst<v2i64, u7imm_i32, i32, uimm7>;
2619
2620 def r128: ROTQBIIRegInst<GPRC, u7imm_i32, i32, uimm7>;
2621 def r64: ROTQBIIRegInst<R64C, u7imm_i32, i32, uimm7>;
2622}
2623
2624defm ROTQBII : RotateQuadByBitCountImm;
2625
2626//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
Scott Michel66377522007-12-04 22:35:58 +00002627// ROTHM v8i16 form:
2628// NOTE(1): No vector rotate is generated by the C/C++ frontend (today),
2629// so this only matches a synthetically generated/lowered code
2630// fragment.
2631// NOTE(2): $rB must be negated before the right rotate!
Scott Michela59d4692008-02-23 18:41:37 +00002632//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
Scott Michel66377522007-12-04 22:35:58 +00002633
Scott Michela59d4692008-02-23 18:41:37 +00002634class ROTHMInst<dag OOL, dag IOL, list<dag> pattern>:
2635 RRForm<0b10111010000, OOL, IOL, "rothm\t$rT, $rA, $rB",
2636 RotateShift, pattern>;
2637
2638def ROTHMv8i16:
2639 ROTHMInst<(outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB),
2640 [/* see patterns below - $rB must be negated */]>;
2641
2642def : Pat<(SPUvec_srl (v8i16 VECREG:$rA), R32C:$rB),
Scott Michel66377522007-12-04 22:35:58 +00002643 (ROTHMv8i16 VECREG:$rA, (SFIr32 R32C:$rB, 0))>;
2644
Scott Michela59d4692008-02-23 18:41:37 +00002645def : Pat<(SPUvec_srl (v8i16 VECREG:$rA), R16C:$rB),
Scott Michel66377522007-12-04 22:35:58 +00002646 (ROTHMv8i16 VECREG:$rA,
2647 (SFIr32 (XSHWr16 R16C:$rB), 0))>;
2648
Scott Michela59d4692008-02-23 18:41:37 +00002649def : Pat<(SPUvec_srl (v8i16 VECREG:$rA), R8C:$rB),
Scott Michel66377522007-12-04 22:35:58 +00002650 (ROTHMv8i16 VECREG:$rA,
Scott Michel504c3692007-12-17 22:32:34 +00002651 (SFIr32 (XSHWr16 (XSBHr8 R8C:$rB) ), 0))>;
Scott Michel66377522007-12-04 22:35:58 +00002652
2653// ROTHM r16 form: Rotate 16-bit quantity to right, zero fill at the left
2654// Note: This instruction doesn't match a pattern because rB must be negated
2655// for the instruction to work. Thus, the pattern below the instruction!
Scott Michela59d4692008-02-23 18:41:37 +00002656
Scott Michel66377522007-12-04 22:35:58 +00002657def ROTHMr16:
Scott Michela59d4692008-02-23 18:41:37 +00002658 ROTHMInst<(outs R16C:$rT), (ins R16C:$rA, R32C:$rB),
2659 [/* see patterns below - $rB must be negated! */]>;
Scott Michel66377522007-12-04 22:35:58 +00002660
2661def : Pat<(srl R16C:$rA, R32C:$rB),
2662 (ROTHMr16 R16C:$rA, (SFIr32 R32C:$rB, 0))>;
2663
2664def : Pat<(srl R16C:$rA, R16C:$rB),
2665 (ROTHMr16 R16C:$rA,
2666 (SFIr32 (XSHWr16 R16C:$rB), 0))>;
2667
Scott Michel504c3692007-12-17 22:32:34 +00002668def : Pat<(srl R16C:$rA, R8C:$rB),
Scott Michel66377522007-12-04 22:35:58 +00002669 (ROTHMr16 R16C:$rA,
Scott Michel504c3692007-12-17 22:32:34 +00002670 (SFIr32 (XSHWr16 (XSBHr8 R8C:$rB) ), 0))>;
Scott Michel66377522007-12-04 22:35:58 +00002671
2672// ROTHMI v8i16 form: See the comment for ROTHM v8i16. The difference here is
2673// that the immediate can be complemented, so that the user doesn't have to
2674// worry about it.
Scott Michel66377522007-12-04 22:35:58 +00002675
Scott Michela59d4692008-02-23 18:41:37 +00002676class ROTHMIInst<dag OOL, dag IOL, list<dag> pattern>:
2677 RI7Form<0b10111110000, OOL, IOL, "rothmi\t$rT, $rA, $val",
2678 RotateShift, pattern>;
2679
2680def ROTHMIv8i16:
2681 ROTHMIInst<(outs VECREG:$rT), (ins VECREG:$rA, rothNeg7imm:$val),
2682 [/* no pattern */]>;
2683
2684def : Pat<(SPUvec_srl (v8i16 VECREG:$rA), (i32 imm:$val)),
2685 (ROTHMIv8i16 VECREG:$rA, imm:$val)>;
2686
2687def: Pat<(SPUvec_srl (v8i16 VECREG:$rA), (i16 imm:$val)),
Chris Lattner420c69d2010-03-15 05:53:47 +00002688 (ROTHMIv8i16 VECREG:$rA, (TO_IMM32 imm:$val))>;
Scott Michelf0569be2008-12-27 04:51:36 +00002689
Scott Michela59d4692008-02-23 18:41:37 +00002690def: Pat<(SPUvec_srl (v8i16 VECREG:$rA), (i8 imm:$val)),
Chris Lattner420c69d2010-03-15 05:53:47 +00002691 (ROTHMIv8i16 VECREG:$rA, (TO_IMM32 imm:$val))>;
Scott Michel66377522007-12-04 22:35:58 +00002692
2693def ROTHMIr16:
Scott Michela59d4692008-02-23 18:41:37 +00002694 ROTHMIInst<(outs R16C:$rT), (ins R16C:$rA, rothNeg7imm:$val),
2695 [/* no pattern */]>;
2696
2697def: Pat<(srl R16C:$rA, (i32 uimm7:$val)),
2698 (ROTHMIr16 R16C:$rA, uimm7:$val)>;
Scott Michel66377522007-12-04 22:35:58 +00002699
2700def: Pat<(srl R16C:$rA, (i16 uimm7:$val)),
Chris Lattner420c69d2010-03-15 05:53:47 +00002701 (ROTHMIr16 R16C:$rA, (TO_IMM32 uimm7:$val))>;
Scott Michel66377522007-12-04 22:35:58 +00002702
Scott Michel504c3692007-12-17 22:32:34 +00002703def: Pat<(srl R16C:$rA, (i8 uimm7:$val)),
Chris Lattner420c69d2010-03-15 05:53:47 +00002704 (ROTHMIr16 R16C:$rA, (TO_IMM32 uimm7:$val))>;
Scott Michel504c3692007-12-17 22:32:34 +00002705
Scott Michel66377522007-12-04 22:35:58 +00002706// ROTM v4i32 form: See the ROTHM v8i16 comments.
Scott Michela59d4692008-02-23 18:41:37 +00002707class ROTMInst<dag OOL, dag IOL, list<dag> pattern>:
2708 RRForm<0b10011010000, OOL, IOL, "rotm\t$rT, $rA, $rB",
2709 RotateShift, pattern>;
Scott Michel66377522007-12-04 22:35:58 +00002710
Scott Michela59d4692008-02-23 18:41:37 +00002711def ROTMv4i32:
2712 ROTMInst<(outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB),
2713 [/* see patterns below - $rB must be negated */]>;
2714
Chris Lattner420c69d2010-03-15 05:53:47 +00002715def : Pat<(SPUvec_srl (v4i32 VECREG:$rA), R32C:$rB),
Scott Michel66377522007-12-04 22:35:58 +00002716 (ROTMv4i32 VECREG:$rA, (SFIr32 R32C:$rB, 0))>;
2717
Chris Lattner420c69d2010-03-15 05:53:47 +00002718def : Pat<(SPUvec_srl (v4i32 VECREG:$rA), R16C:$rB),
Scott Michel66377522007-12-04 22:35:58 +00002719 (ROTMv4i32 VECREG:$rA,
2720 (SFIr32 (XSHWr16 R16C:$rB), 0))>;
2721
Chris Lattner420c69d2010-03-15 05:53:47 +00002722def : Pat<(SPUvec_srl (v4i32 VECREG:$rA), R8C:$rB),
Scott Michel66377522007-12-04 22:35:58 +00002723 (ROTMv4i32 VECREG:$rA,
Scott Michela59d4692008-02-23 18:41:37 +00002724 (SFIr32 (XSHWr16 (XSBHr8 R8C:$rB)), 0))>;
Scott Michel66377522007-12-04 22:35:58 +00002725
2726def ROTMr32:
Scott Michela59d4692008-02-23 18:41:37 +00002727 ROTMInst<(outs R32C:$rT), (ins R32C:$rA, R32C:$rB),
2728 [/* see patterns below - $rB must be negated */]>;
Scott Michel66377522007-12-04 22:35:58 +00002729
2730def : Pat<(srl R32C:$rA, R32C:$rB),
2731 (ROTMr32 R32C:$rA, (SFIr32 R32C:$rB, 0))>;
2732
2733def : Pat<(srl R32C:$rA, R16C:$rB),
2734 (ROTMr32 R32C:$rA,
2735 (SFIr32 (XSHWr16 R16C:$rB), 0))>;
2736
Scott Michel504c3692007-12-17 22:32:34 +00002737def : Pat<(srl R32C:$rA, R8C:$rB),
2738 (ROTMr32 R32C:$rA,
2739 (SFIr32 (XSHWr16 (XSBHr8 R8C:$rB)), 0))>;
2740
Scott Michel66377522007-12-04 22:35:58 +00002741// ROTMI v4i32 form: See the comment for ROTHM v8i16.
2742def ROTMIv4i32:
2743 RI7Form<0b10011110000, (outs VECREG:$rT), (ins VECREG:$rA, rotNeg7imm:$val),
2744 "rotmi\t$rT, $rA, $val", RotateShift,
2745 [(set (v4i32 VECREG:$rT),
Scott Michela59d4692008-02-23 18:41:37 +00002746 (SPUvec_srl VECREG:$rA, (i32 uimm7:$val)))]>;
Scott Michel66377522007-12-04 22:35:58 +00002747
Chris Lattner420c69d2010-03-15 05:53:47 +00002748def : Pat<(SPUvec_srl (v4i32 VECREG:$rA), (i16 uimm7:$val)),
2749 (ROTMIv4i32 VECREG:$rA, (TO_IMM32 uimm7:$val))>;
Scott Michelf0569be2008-12-27 04:51:36 +00002750
Chris Lattner420c69d2010-03-15 05:53:47 +00002751def : Pat<(SPUvec_srl (v4i32 VECREG:$rA), (i8 uimm7:$val)),
2752 (ROTMIv4i32 VECREG:$rA, (TO_IMM32 uimm7:$val))>;
Scott Michel66377522007-12-04 22:35:58 +00002753
2754// ROTMI r32 form: know how to complement the immediate value.
2755def ROTMIr32:
2756 RI7Form<0b10011110000, (outs R32C:$rT), (ins R32C:$rA, rotNeg7imm:$val),
2757 "rotmi\t$rT, $rA, $val", RotateShift,
2758 [(set R32C:$rT, (srl R32C:$rA, (i32 uimm7:$val)))]>;
2759
2760def : Pat<(srl R32C:$rA, (i16 imm:$val)),
Chris Lattner420c69d2010-03-15 05:53:47 +00002761 (ROTMIr32 R32C:$rA, (TO_IMM32 uimm7:$val))>;
Scott Michel66377522007-12-04 22:35:58 +00002762
Scott Michel504c3692007-12-17 22:32:34 +00002763def : Pat<(srl R32C:$rA, (i8 imm:$val)),
Chris Lattner420c69d2010-03-15 05:53:47 +00002764 (ROTMIr32 R32C:$rA, (TO_IMM32 uimm7:$val))>;
Scott Michel504c3692007-12-17 22:32:34 +00002765
Scott Michela59d4692008-02-23 18:41:37 +00002766//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
Scott Micheldd950092009-01-06 03:36:14 +00002767// ROTQMBY: This is a vector form merely so that when used in an
Scott Michel66377522007-12-04 22:35:58 +00002768// instruction pattern, type checking will succeed. This instruction assumes
Scott Michela59d4692008-02-23 18:41:37 +00002769// that the user knew to negate $rB.
Scott Michela59d4692008-02-23 18:41:37 +00002770//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
Scott Michel66377522007-12-04 22:35:58 +00002771
Scott Michela59d4692008-02-23 18:41:37 +00002772class ROTQMBYInst<dag OOL, dag IOL, list<dag> pattern>:
2773 RRForm<0b10111011100, OOL, IOL, "rotqmby\t$rT, $rA, $rB",
2774 RotateShift, pattern>;
Scott Michel66377522007-12-04 22:35:58 +00002775
Scott Michela59d4692008-02-23 18:41:37 +00002776class ROTQMBYVecInst<ValueType vectype>:
2777 ROTQMBYInst<(outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB),
2778 [/* no pattern, $rB must be negated */]>;
Scott Michel66377522007-12-04 22:35:58 +00002779
Scott Michela59d4692008-02-23 18:41:37 +00002780class ROTQMBYRegInst<RegisterClass rclass>:
2781 ROTQMBYInst<(outs rclass:$rT), (ins rclass:$rA, R32C:$rB),
Scott Michel02d711b2008-12-30 23:28:25 +00002782 [/* no pattern */]>;
Scott Michel66377522007-12-04 22:35:58 +00002783
Scott Michela59d4692008-02-23 18:41:37 +00002784multiclass RotateQuadBytes
2785{
2786 def v16i8: ROTQMBYVecInst<v16i8>;
2787 def v8i16: ROTQMBYVecInst<v8i16>;
2788 def v4i32: ROTQMBYVecInst<v4i32>;
2789 def v2i64: ROTQMBYVecInst<v2i64>;
Scott Michel66377522007-12-04 22:35:58 +00002790
Scott Michela59d4692008-02-23 18:41:37 +00002791 def r128: ROTQMBYRegInst<GPRC>;
2792 def r64: ROTQMBYRegInst<R64C>;
2793}
2794
2795defm ROTQMBY : RotateQuadBytes;
2796
Scott Michela59d4692008-02-23 18:41:37 +00002797class ROTQMBYIInst<dag OOL, dag IOL, list<dag> pattern>:
2798 RI7Form<0b10111111100, OOL, IOL, "rotqmbyi\t$rT, $rA, $val",
2799 RotateShift, pattern>;
2800
2801class ROTQMBYIVecInst<ValueType vectype>:
2802 ROTQMBYIInst<(outs VECREG:$rT), (ins VECREG:$rA, rotNeg7imm:$val),
Scott Michel02d711b2008-12-30 23:28:25 +00002803 [/* no pattern */]>;
Scott Michela59d4692008-02-23 18:41:37 +00002804
Scott Micheldd950092009-01-06 03:36:14 +00002805class ROTQMBYIRegInst<RegisterClass rclass, Operand optype, ValueType inttype,
2806 PatLeaf pred>:
Scott Michela59d4692008-02-23 18:41:37 +00002807 ROTQMBYIInst<(outs rclass:$rT), (ins rclass:$rA, optype:$val),
Scott Michel02d711b2008-12-30 23:28:25 +00002808 [/* no pattern */]>;
Scott Michela59d4692008-02-23 18:41:37 +00002809
Scott Micheldd950092009-01-06 03:36:14 +00002810// 128-bit zero extension form:
2811class ROTQMBYIZExtInst<RegisterClass rclass, Operand optype, PatLeaf pred>:
2812 ROTQMBYIInst<(outs GPRC:$rT), (ins rclass:$rA, optype:$val),
2813 [/* no pattern */]>;
2814
Scott Michela59d4692008-02-23 18:41:37 +00002815multiclass RotateQuadBytesImm
2816{
2817 def v16i8: ROTQMBYIVecInst<v16i8>;
2818 def v8i16: ROTQMBYIVecInst<v8i16>;
2819 def v4i32: ROTQMBYIVecInst<v4i32>;
2820 def v2i64: ROTQMBYIVecInst<v2i64>;
2821
2822 def r128: ROTQMBYIRegInst<GPRC, rotNeg7imm, i32, uimm7>;
2823 def r64: ROTQMBYIRegInst<R64C, rotNeg7imm, i32, uimm7>;
Scott Micheldd950092009-01-06 03:36:14 +00002824
2825 def r128_zext_r8: ROTQMBYIZExtInst<R8C, rotNeg7imm, uimm7>;
2826 def r128_zext_r16: ROTQMBYIZExtInst<R16C, rotNeg7imm, uimm7>;
2827 def r128_zext_r32: ROTQMBYIZExtInst<R32C, rotNeg7imm, uimm7>;
2828 def r128_zext_r64: ROTQMBYIZExtInst<R64C, rotNeg7imm, uimm7>;
Scott Michela59d4692008-02-23 18:41:37 +00002829}
2830
2831defm ROTQMBYI : RotateQuadBytesImm;
2832
Scott Michela59d4692008-02-23 18:41:37 +00002833//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2834// Rotate right and mask by bit count
2835//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2836
2837class ROTQMBYBIInst<dag OOL, dag IOL, list<dag> pattern>:
2838 RRForm<0b10110011100, OOL, IOL, "rotqmbybi\t$rT, $rA, $rB",
2839 RotateShift, pattern>;
2840
2841class ROTQMBYBIVecInst<ValueType vectype>:
Scott Michel02d711b2008-12-30 23:28:25 +00002842 ROTQMBYBIInst<(outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB),
2843 [/* no pattern, */]>;
Scott Michela59d4692008-02-23 18:41:37 +00002844
2845multiclass RotateMaskQuadByBitCount
2846{
2847 def v16i8: ROTQMBYBIVecInst<v16i8>;
2848 def v8i16: ROTQMBYBIVecInst<v8i16>;
2849 def v4i32: ROTQMBYBIVecInst<v4i32>;
2850 def v2i64: ROTQMBYBIVecInst<v2i64>;
2851}
2852
2853defm ROTQMBYBI: RotateMaskQuadByBitCount;
2854
2855//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2856// Rotate quad and mask by bits
2857// Note that the rotate amount has to be negated
2858//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2859
2860class ROTQMBIInst<dag OOL, dag IOL, list<dag> pattern>:
2861 RRForm<0b10011011100, OOL, IOL, "rotqmbi\t$rT, $rA, $rB",
2862 RotateShift, pattern>;
2863
2864class ROTQMBIVecInst<ValueType vectype>:
2865 ROTQMBIInst<(outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB),
2866 [/* no pattern */]>;
2867
2868class ROTQMBIRegInst<RegisterClass rclass>:
2869 ROTQMBIInst<(outs rclass:$rT), (ins rclass:$rA, R32C:$rB),
2870 [/* no pattern */]>;
2871
2872multiclass RotateMaskQuadByBits
2873{
2874 def v16i8: ROTQMBIVecInst<v16i8>;
2875 def v8i16: ROTQMBIVecInst<v8i16>;
2876 def v4i32: ROTQMBIVecInst<v4i32>;
2877 def v2i64: ROTQMBIVecInst<v2i64>;
2878
2879 def r128: ROTQMBIRegInst<GPRC>;
2880 def r64: ROTQMBIRegInst<R64C>;
2881}
2882
2883defm ROTQMBI: RotateMaskQuadByBits;
2884
Scott Michela59d4692008-02-23 18:41:37 +00002885//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2886// Rotate quad and mask by bits, immediate
2887//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2888
2889class ROTQMBIIInst<dag OOL, dag IOL, list<dag> pattern>:
2890 RI7Form<0b10011111100, OOL, IOL, "rotqmbii\t$rT, $rA, $val",
2891 RotateShift, pattern>;
2892
2893class ROTQMBIIVecInst<ValueType vectype>:
2894 ROTQMBIIInst<(outs VECREG:$rT), (ins VECREG:$rA, rotNeg7imm:$val),
Scott Michel02d711b2008-12-30 23:28:25 +00002895 [/* no pattern */]>;
Scott Michela59d4692008-02-23 18:41:37 +00002896
2897class ROTQMBIIRegInst<RegisterClass rclass>:
2898 ROTQMBIIInst<(outs rclass:$rT), (ins rclass:$rA, rotNeg7imm:$val),
Scott Michel02d711b2008-12-30 23:28:25 +00002899 [/* no pattern */]>;
Scott Michela59d4692008-02-23 18:41:37 +00002900
2901multiclass RotateMaskQuadByBitsImm
2902{
2903 def v16i8: ROTQMBIIVecInst<v16i8>;
2904 def v8i16: ROTQMBIIVecInst<v8i16>;
2905 def v4i32: ROTQMBIIVecInst<v4i32>;
2906 def v2i64: ROTQMBIIVecInst<v2i64>;
2907
2908 def r128: ROTQMBIIRegInst<GPRC>;
2909 def r64: ROTQMBIIRegInst<R64C>;
2910}
2911
2912defm ROTQMBII: RotateMaskQuadByBitsImm;
2913
2914//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2915//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
Scott Michel66377522007-12-04 22:35:58 +00002916
2917def ROTMAHv8i16:
2918 RRForm<0b01111010000, (outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB),
2919 "rotmah\t$rT, $rA, $rB", RotateShift,
2920 [/* see patterns below - $rB must be negated */]>;
2921
Chris Lattner420c69d2010-03-15 05:53:47 +00002922def : Pat<(SPUvec_sra (v8i16 VECREG:$rA), R32C:$rB),
Scott Michel66377522007-12-04 22:35:58 +00002923 (ROTMAHv8i16 VECREG:$rA, (SFIr32 R32C:$rB, 0))>;
2924
Chris Lattner420c69d2010-03-15 05:53:47 +00002925def : Pat<(SPUvec_sra (v8i16 VECREG:$rA), R16C:$rB),
Scott Michel66377522007-12-04 22:35:58 +00002926 (ROTMAHv8i16 VECREG:$rA,
2927 (SFIr32 (XSHWr16 R16C:$rB), 0))>;
2928
Chris Lattner420c69d2010-03-15 05:53:47 +00002929def : Pat<(SPUvec_sra (v8i16 VECREG:$rA), R8C:$rB),
Scott Michel504c3692007-12-17 22:32:34 +00002930 (ROTMAHv8i16 VECREG:$rA,
2931 (SFIr32 (XSHWr16 (XSBHr8 R8C:$rB)), 0))>;
2932
Scott Michel66377522007-12-04 22:35:58 +00002933def ROTMAHr16:
2934 RRForm<0b01111010000, (outs R16C:$rT), (ins R16C:$rA, R32C:$rB),
2935 "rotmah\t$rT, $rA, $rB", RotateShift,
2936 [/* see patterns below - $rB must be negated */]>;
2937
2938def : Pat<(sra R16C:$rA, R32C:$rB),
2939 (ROTMAHr16 R16C:$rA, (SFIr32 R32C:$rB, 0))>;
2940
2941def : Pat<(sra R16C:$rA, R16C:$rB),
2942 (ROTMAHr16 R16C:$rA,
2943 (SFIr32 (XSHWr16 R16C:$rB), 0))>;
2944
Scott Michel504c3692007-12-17 22:32:34 +00002945def : Pat<(sra R16C:$rA, R8C:$rB),
2946 (ROTMAHr16 R16C:$rA,
2947 (SFIr32 (XSHWr16 (XSBHr8 R8C:$rB)), 0))>;
2948
Scott Michel66377522007-12-04 22:35:58 +00002949def ROTMAHIv8i16:
2950 RRForm<0b01111110000, (outs VECREG:$rT), (ins VECREG:$rA, rothNeg7imm:$val),
2951 "rotmahi\t$rT, $rA, $val", RotateShift,
2952 [(set (v8i16 VECREG:$rT),
Scott Michela59d4692008-02-23 18:41:37 +00002953 (SPUvec_sra (v8i16 VECREG:$rA), (i32 uimm7:$val)))]>;
Scott Michel66377522007-12-04 22:35:58 +00002954
Scott Michela59d4692008-02-23 18:41:37 +00002955def : Pat<(SPUvec_sra (v8i16 VECREG:$rA), (i16 uimm7:$val)),
Chris Lattner420c69d2010-03-15 05:53:47 +00002956 (ROTMAHIv8i16 (v8i16 VECREG:$rA), (TO_IMM32 uimm7:$val))>;
Scott Michel66377522007-12-04 22:35:58 +00002957
Scott Michela59d4692008-02-23 18:41:37 +00002958def : Pat<(SPUvec_sra (v8i16 VECREG:$rA), (i8 uimm7:$val)),
Chris Lattner420c69d2010-03-15 05:53:47 +00002959 (ROTMAHIv8i16 (v8i16 VECREG:$rA), (TO_IMM32 uimm7:$val))>;
Scott Michel504c3692007-12-17 22:32:34 +00002960
Scott Michel66377522007-12-04 22:35:58 +00002961def ROTMAHIr16:
2962 RRForm<0b01111110000, (outs R16C:$rT), (ins R16C:$rA, rothNeg7imm_i16:$val),
2963 "rotmahi\t$rT, $rA, $val", RotateShift,
2964 [(set R16C:$rT, (sra R16C:$rA, (i16 uimm7:$val)))]>;
2965
2966def : Pat<(sra R16C:$rA, (i32 imm:$val)),
Chris Lattner420c69d2010-03-15 05:53:47 +00002967 (ROTMAHIr16 R16C:$rA, (TO_IMM32 uimm7:$val))>;
Scott Michel66377522007-12-04 22:35:58 +00002968
Scott Michel504c3692007-12-17 22:32:34 +00002969def : Pat<(sra R16C:$rA, (i8 imm:$val)),
Chris Lattner420c69d2010-03-15 05:53:47 +00002970 (ROTMAHIr16 R16C:$rA, (TO_IMM32 uimm7:$val))>;
Scott Michel504c3692007-12-17 22:32:34 +00002971
Scott Michel66377522007-12-04 22:35:58 +00002972def ROTMAv4i32:
2973 RRForm<0b01011010000, (outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB),
2974 "rotma\t$rT, $rA, $rB", RotateShift,
2975 [/* see patterns below - $rB must be negated */]>;
2976
Chris Lattner420c69d2010-03-15 05:53:47 +00002977def : Pat<(SPUvec_sra (v4i32 VECREG:$rA), R32C:$rB),
2978 (ROTMAv4i32 VECREG:$rA, (SFIr32 R32C:$rB, 0))>;
Scott Michel66377522007-12-04 22:35:58 +00002979
Chris Lattner420c69d2010-03-15 05:53:47 +00002980def : Pat<(SPUvec_sra (v4i32 VECREG:$rA), R16C:$rB),
2981 (ROTMAv4i32 VECREG:$rA,
Scott Michel66377522007-12-04 22:35:58 +00002982 (SFIr32 (XSHWr16 R16C:$rB), 0))>;
2983
Chris Lattner420c69d2010-03-15 05:53:47 +00002984def : Pat<(SPUvec_sra (v4i32 VECREG:$rA), R8C:$rB),
2985 (ROTMAv4i32 VECREG:$rA,
Scott Michel504c3692007-12-17 22:32:34 +00002986 (SFIr32 (XSHWr16 (XSBHr8 R8C:$rB)), 0))>;
2987
Scott Michel66377522007-12-04 22:35:58 +00002988def ROTMAr32:
2989 RRForm<0b01011010000, (outs R32C:$rT), (ins R32C:$rA, R32C:$rB),
2990 "rotma\t$rT, $rA, $rB", RotateShift,
2991 [/* see patterns below - $rB must be negated */]>;
2992
2993def : Pat<(sra R32C:$rA, R32C:$rB),
2994 (ROTMAr32 R32C:$rA, (SFIr32 R32C:$rB, 0))>;
2995
2996def : Pat<(sra R32C:$rA, R16C:$rB),
2997 (ROTMAr32 R32C:$rA,
2998 (SFIr32 (XSHWr16 R16C:$rB), 0))>;
2999
Scott Michel504c3692007-12-17 22:32:34 +00003000def : Pat<(sra R32C:$rA, R8C:$rB),
3001 (ROTMAr32 R32C:$rA,
3002 (SFIr32 (XSHWr16 (XSBHr8 R8C:$rB)), 0))>;
3003
Scott Michel8bf61e82008-06-02 22:18:03 +00003004class ROTMAIInst<dag OOL, dag IOL, list<dag> pattern>:
3005 RRForm<0b01011110000, OOL, IOL,
3006 "rotmai\t$rT, $rA, $val",
3007 RotateShift, pattern>;
Scott Michel66377522007-12-04 22:35:58 +00003008
Scott Michel8bf61e82008-06-02 22:18:03 +00003009class ROTMAIVecInst<ValueType vectype, Operand intop, ValueType inttype>:
3010 ROTMAIInst<(outs VECREG:$rT), (ins VECREG:$rA, intop:$val),
3011 [(set (vectype VECREG:$rT),
3012 (SPUvec_sra VECREG:$rA, (inttype uimm7:$val)))]>;
Scott Michel66377522007-12-04 22:35:58 +00003013
Scott Michel8bf61e82008-06-02 22:18:03 +00003014class ROTMAIRegInst<RegisterClass rclass, Operand intop, ValueType inttype>:
3015 ROTMAIInst<(outs rclass:$rT), (ins rclass:$rA, intop:$val),
3016 [(set rclass:$rT, (sra rclass:$rA, (inttype uimm7:$val)))]>;
Scott Michel66377522007-12-04 22:35:58 +00003017
Scott Michel8bf61e82008-06-02 22:18:03 +00003018multiclass RotateMaskAlgebraicImm {
3019 def v2i64_i32 : ROTMAIVecInst<v2i64, rotNeg7imm, i32>;
3020 def v4i32_i32 : ROTMAIVecInst<v4i32, rotNeg7imm, i32>;
3021 def r64_i32 : ROTMAIRegInst<R64C, rotNeg7imm, i32>;
3022 def r32_i32 : ROTMAIRegInst<R32C, rotNeg7imm, i32>;
3023}
Scott Michel66377522007-12-04 22:35:58 +00003024
Scott Michel8bf61e82008-06-02 22:18:03 +00003025defm ROTMAI : RotateMaskAlgebraicImm;
Scott Michel504c3692007-12-17 22:32:34 +00003026
Scott Michel66377522007-12-04 22:35:58 +00003027//===----------------------------------------------------------------------===//
3028// Branch and conditionals:
3029//===----------------------------------------------------------------------===//
3030
3031let isTerminator = 1, isBarrier = 1 in {
3032 // Halt If Equal (r32 preferred slot only, no vector form)
3033 def HEQr32:
3034 RRForm_3<0b00011011110, (outs), (ins R32C:$rA, R32C:$rB),
3035 "heq\t$rA, $rB", BranchResolv,
3036 [/* no pattern to match */]>;
3037
3038 def HEQIr32 :
3039 RI10Form_2<0b11111110, (outs), (ins R32C:$rA, s10imm:$val),
3040 "heqi\t$rA, $val", BranchResolv,
3041 [/* no pattern to match */]>;
3042
3043 // HGT/HGTI: These instructions use signed arithmetic for the comparison,
3044 // contrasting with HLGT/HLGTI, which use unsigned comparison:
3045 def HGTr32:
3046 RRForm_3<0b00011010010, (outs), (ins R32C:$rA, R32C:$rB),
3047 "hgt\t$rA, $rB", BranchResolv,
3048 [/* no pattern to match */]>;
3049
Scott Michelf0569be2008-12-27 04:51:36 +00003050 def HGTIr32:
Scott Michel66377522007-12-04 22:35:58 +00003051 RI10Form_2<0b11110010, (outs), (ins R32C:$rA, s10imm:$val),
3052 "hgti\t$rA, $val", BranchResolv,
3053 [/* no pattern to match */]>;
3054
3055 def HLGTr32:
3056 RRForm_3<0b00011011010, (outs), (ins R32C:$rA, R32C:$rB),
3057 "hlgt\t$rA, $rB", BranchResolv,
3058 [/* no pattern to match */]>;
3059
3060 def HLGTIr32:
3061 RI10Form_2<0b11111010, (outs), (ins R32C:$rA, s10imm:$val),
3062 "hlgti\t$rA, $val", BranchResolv,
3063 [/* no pattern to match */]>;
3064}
3065
Scott Michelf0569be2008-12-27 04:51:36 +00003066//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
3067// Comparison operators for i8, i16 and i32:
3068//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
Scott Michel66377522007-12-04 22:35:58 +00003069
Scott Michela59d4692008-02-23 18:41:37 +00003070class CEQBInst<dag OOL, dag IOL, list<dag> pattern> :
3071 RRForm<0b00001011110, OOL, IOL, "ceqb\t$rT, $rA, $rB",
3072 ByteOp, pattern>;
Scott Michel66377522007-12-04 22:35:58 +00003073
Scott Michela59d4692008-02-23 18:41:37 +00003074multiclass CmpEqualByte
3075{
3076 def v16i8 :
3077 CEQBInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
3078 [(set (v16i8 VECREG:$rT), (seteq (v8i16 VECREG:$rA),
3079 (v8i16 VECREG:$rB)))]>;
Scott Michel504c3692007-12-17 22:32:34 +00003080
Scott Michela59d4692008-02-23 18:41:37 +00003081 def r8 :
3082 CEQBInst<(outs R8C:$rT), (ins R8C:$rA, R8C:$rB),
3083 [(set R8C:$rT, (seteq R8C:$rA, R8C:$rB))]>;
3084}
Scott Michel66377522007-12-04 22:35:58 +00003085
Scott Michela59d4692008-02-23 18:41:37 +00003086class CEQBIInst<dag OOL, dag IOL, list<dag> pattern> :
3087 RI10Form<0b01111110, OOL, IOL, "ceqbi\t$rT, $rA, $val",
3088 ByteOp, pattern>;
Scott Michel66377522007-12-04 22:35:58 +00003089
Scott Michela59d4692008-02-23 18:41:37 +00003090multiclass CmpEqualByteImm
3091{
3092 def v16i8 :
3093 CEQBIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm_i8:$val),
3094 [(set (v16i8 VECREG:$rT), (seteq (v16i8 VECREG:$rA),
3095 v16i8SExt8Imm:$val))]>;
3096 def r8:
3097 CEQBIInst<(outs R8C:$rT), (ins R8C:$rA, s10imm_i8:$val),
3098 [(set R8C:$rT, (seteq R8C:$rA, immSExt8:$val))]>;
3099}
Scott Michel66377522007-12-04 22:35:58 +00003100
Scott Michela59d4692008-02-23 18:41:37 +00003101class CEQHInst<dag OOL, dag IOL, list<dag> pattern> :
3102 RRForm<0b00010011110, OOL, IOL, "ceqh\t$rT, $rA, $rB",
3103 ByteOp, pattern>;
Scott Michel66377522007-12-04 22:35:58 +00003104
Scott Michela59d4692008-02-23 18:41:37 +00003105multiclass CmpEqualHalfword
3106{
3107 def v8i16 : CEQHInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
3108 [(set (v8i16 VECREG:$rT), (seteq (v8i16 VECREG:$rA),
3109 (v8i16 VECREG:$rB)))]>;
Scott Michel66377522007-12-04 22:35:58 +00003110
Scott Michela59d4692008-02-23 18:41:37 +00003111 def r16 : CEQHInst<(outs R16C:$rT), (ins R16C:$rA, R16C:$rB),
3112 [(set R16C:$rT, (seteq R16C:$rA, R16C:$rB))]>;
3113}
Scott Michel66377522007-12-04 22:35:58 +00003114
Scott Michela59d4692008-02-23 18:41:37 +00003115class CEQHIInst<dag OOL, dag IOL, list<dag> pattern> :
3116 RI10Form<0b10111110, OOL, IOL, "ceqhi\t$rT, $rA, $val",
3117 ByteOp, pattern>;
Scott Michel66377522007-12-04 22:35:58 +00003118
Scott Michela59d4692008-02-23 18:41:37 +00003119multiclass CmpEqualHalfwordImm
3120{
3121 def v8i16 : CEQHIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
3122 [(set (v8i16 VECREG:$rT),
3123 (seteq (v8i16 VECREG:$rA),
3124 (v8i16 v8i16SExt10Imm:$val)))]>;
3125 def r16 : CEQHIInst<(outs R16C:$rT), (ins R16C:$rA, s10imm:$val),
3126 [(set R16C:$rT, (seteq R16C:$rA, i16ImmSExt10:$val))]>;
3127}
Scott Michel66377522007-12-04 22:35:58 +00003128
Scott Michela59d4692008-02-23 18:41:37 +00003129class CEQInst<dag OOL, dag IOL, list<dag> pattern> :
3130 RRForm<0b00000011110, OOL, IOL, "ceq\t$rT, $rA, $rB",
3131 ByteOp, pattern>;
3132
3133multiclass CmpEqualWord
3134{
3135 def v4i32 : CEQInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
3136 [(set (v4i32 VECREG:$rT),
3137 (seteq (v4i32 VECREG:$rA), (v4i32 VECREG:$rB)))]>;
3138
3139 def r32 : CEQInst<(outs R32C:$rT), (ins R32C:$rA, R32C:$rB),
3140 [(set R32C:$rT, (seteq R32C:$rA, R32C:$rB))]>;
3141}
3142
3143class CEQIInst<dag OOL, dag IOL, list<dag> pattern> :
3144 RI10Form<0b00111110, OOL, IOL, "ceqi\t$rT, $rA, $val",
3145 ByteOp, pattern>;
3146
3147multiclass CmpEqualWordImm
3148{
3149 def v4i32 : CEQIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
3150 [(set (v4i32 VECREG:$rT),
3151 (seteq (v4i32 VECREG:$rA),
3152 (v4i32 v4i32SExt16Imm:$val)))]>;
3153
3154 def r32: CEQIInst<(outs R32C:$rT), (ins R32C:$rA, s10imm_i32:$val),
3155 [(set R32C:$rT, (seteq R32C:$rA, i32ImmSExt10:$val))]>;
3156}
3157
3158class CGTBInst<dag OOL, dag IOL, list<dag> pattern> :
3159 RRForm<0b00001010010, OOL, IOL, "cgtb\t$rT, $rA, $rB",
3160 ByteOp, pattern>;
3161
3162multiclass CmpGtrByte
3163{
3164 def v16i8 :
3165 CGTBInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
3166 [(set (v16i8 VECREG:$rT), (setgt (v8i16 VECREG:$rA),
3167 (v8i16 VECREG:$rB)))]>;
3168
3169 def r8 :
3170 CGTBInst<(outs R8C:$rT), (ins R8C:$rA, R8C:$rB),
3171 [(set R8C:$rT, (setgt R8C:$rA, R8C:$rB))]>;
3172}
3173
3174class CGTBIInst<dag OOL, dag IOL, list<dag> pattern> :
3175 RI10Form<0b01110010, OOL, IOL, "cgtbi\t$rT, $rA, $val",
3176 ByteOp, pattern>;
3177
3178multiclass CmpGtrByteImm
3179{
3180 def v16i8 :
3181 CGTBIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm_i8:$val),
3182 [(set (v16i8 VECREG:$rT), (setgt (v16i8 VECREG:$rA),
3183 v16i8SExt8Imm:$val))]>;
3184 def r8:
3185 CGTBIInst<(outs R8C:$rT), (ins R8C:$rA, s10imm_i8:$val),
Scott Michel79698f62008-03-20 00:51:36 +00003186 [(set R8C:$rT, (setgt R8C:$rA, immSExt8:$val))]>;
Scott Michela59d4692008-02-23 18:41:37 +00003187}
3188
3189class CGTHInst<dag OOL, dag IOL, list<dag> pattern> :
3190 RRForm<0b00010010010, OOL, IOL, "cgth\t$rT, $rA, $rB",
3191 ByteOp, pattern>;
3192
3193multiclass CmpGtrHalfword
3194{
3195 def v8i16 : CGTHInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
3196 [(set (v8i16 VECREG:$rT), (setgt (v8i16 VECREG:$rA),
3197 (v8i16 VECREG:$rB)))]>;
3198
3199 def r16 : CGTHInst<(outs R16C:$rT), (ins R16C:$rA, R16C:$rB),
3200 [(set R16C:$rT, (setgt R16C:$rA, R16C:$rB))]>;
3201}
3202
3203class CGTHIInst<dag OOL, dag IOL, list<dag> pattern> :
3204 RI10Form<0b10110010, OOL, IOL, "cgthi\t$rT, $rA, $val",
3205 ByteOp, pattern>;
3206
3207multiclass CmpGtrHalfwordImm
3208{
3209 def v8i16 : CGTHIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
3210 [(set (v8i16 VECREG:$rT),
3211 (setgt (v8i16 VECREG:$rA),
3212 (v8i16 v8i16SExt10Imm:$val)))]>;
3213 def r16 : CGTHIInst<(outs R16C:$rT), (ins R16C:$rA, s10imm:$val),
3214 [(set R16C:$rT, (setgt R16C:$rA, i16ImmSExt10:$val))]>;
3215}
3216
3217class CGTInst<dag OOL, dag IOL, list<dag> pattern> :
3218 RRForm<0b00000010010, OOL, IOL, "cgt\t$rT, $rA, $rB",
3219 ByteOp, pattern>;
3220
3221multiclass CmpGtrWord
3222{
3223 def v4i32 : CGTInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
3224 [(set (v4i32 VECREG:$rT),
3225 (setgt (v4i32 VECREG:$rA), (v4i32 VECREG:$rB)))]>;
3226
3227 def r32 : CGTInst<(outs R32C:$rT), (ins R32C:$rA, R32C:$rB),
3228 [(set R32C:$rT, (setgt R32C:$rA, R32C:$rB))]>;
3229}
3230
3231class CGTIInst<dag OOL, dag IOL, list<dag> pattern> :
3232 RI10Form<0b00110010, OOL, IOL, "cgti\t$rT, $rA, $val",
3233 ByteOp, pattern>;
3234
3235multiclass CmpGtrWordImm
3236{
3237 def v4i32 : CGTIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
3238 [(set (v4i32 VECREG:$rT),
3239 (setgt (v4i32 VECREG:$rA),
3240 (v4i32 v4i32SExt16Imm:$val)))]>;
3241
3242 def r32: CGTIInst<(outs R32C:$rT), (ins R32C:$rA, s10imm_i32:$val),
3243 [(set R32C:$rT, (setgt R32C:$rA, i32ImmSExt10:$val))]>;
Scott Michel02d711b2008-12-30 23:28:25 +00003244
3245 // CGTIv4f32, CGTIf32: These are used in the f32 fdiv instruction sequence:
3246 def v4f32: CGTIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
3247 [(set (v4i32 VECREG:$rT),
3248 (setgt (v4i32 (bitconvert (v4f32 VECREG:$rA))),
3249 (v4i32 v4i32SExt16Imm:$val)))]>;
3250
3251 def f32: CGTIInst<(outs R32C:$rT), (ins R32FP:$rA, s10imm_i32:$val),
Scott Michel19c10e62009-01-26 03:37:41 +00003252 [/* no pattern */]>;
Scott Michela59d4692008-02-23 18:41:37 +00003253}
3254
3255class CLGTBInst<dag OOL, dag IOL, list<dag> pattern> :
Scott Michelad2715e2008-03-05 23:02:02 +00003256 RRForm<0b00001011010, OOL, IOL, "clgtb\t$rT, $rA, $rB",
Scott Michela59d4692008-02-23 18:41:37 +00003257 ByteOp, pattern>;
3258
3259multiclass CmpLGtrByte
3260{
3261 def v16i8 :
3262 CLGTBInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
3263 [(set (v16i8 VECREG:$rT), (setugt (v8i16 VECREG:$rA),
3264 (v8i16 VECREG:$rB)))]>;
3265
3266 def r8 :
3267 CLGTBInst<(outs R8C:$rT), (ins R8C:$rA, R8C:$rB),
3268 [(set R8C:$rT, (setugt R8C:$rA, R8C:$rB))]>;
3269}
3270
3271class CLGTBIInst<dag OOL, dag IOL, list<dag> pattern> :
Scott Michelad2715e2008-03-05 23:02:02 +00003272 RI10Form<0b01111010, OOL, IOL, "clgtbi\t$rT, $rA, $val",
Scott Michela59d4692008-02-23 18:41:37 +00003273 ByteOp, pattern>;
3274
3275multiclass CmpLGtrByteImm
3276{
3277 def v16i8 :
3278 CLGTBIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm_i8:$val),
3279 [(set (v16i8 VECREG:$rT), (setugt (v16i8 VECREG:$rA),
3280 v16i8SExt8Imm:$val))]>;
3281 def r8:
3282 CLGTBIInst<(outs R8C:$rT), (ins R8C:$rA, s10imm_i8:$val),
3283 [(set R8C:$rT, (setugt R8C:$rA, immSExt8:$val))]>;
3284}
3285
3286class CLGTHInst<dag OOL, dag IOL, list<dag> pattern> :
Scott Michelad2715e2008-03-05 23:02:02 +00003287 RRForm<0b00010011010, OOL, IOL, "clgth\t$rT, $rA, $rB",
Scott Michela59d4692008-02-23 18:41:37 +00003288 ByteOp, pattern>;
3289
3290multiclass CmpLGtrHalfword
3291{
3292 def v8i16 : CLGTHInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
3293 [(set (v8i16 VECREG:$rT), (setugt (v8i16 VECREG:$rA),
3294 (v8i16 VECREG:$rB)))]>;
3295
3296 def r16 : CLGTHInst<(outs R16C:$rT), (ins R16C:$rA, R16C:$rB),
3297 [(set R16C:$rT, (setugt R16C:$rA, R16C:$rB))]>;
3298}
3299
3300class CLGTHIInst<dag OOL, dag IOL, list<dag> pattern> :
Scott Michelad2715e2008-03-05 23:02:02 +00003301 RI10Form<0b10111010, OOL, IOL, "clgthi\t$rT, $rA, $val",
Scott Michela59d4692008-02-23 18:41:37 +00003302 ByteOp, pattern>;
3303
3304multiclass CmpLGtrHalfwordImm
3305{
3306 def v8i16 : CLGTHIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
3307 [(set (v8i16 VECREG:$rT),
3308 (setugt (v8i16 VECREG:$rA),
3309 (v8i16 v8i16SExt10Imm:$val)))]>;
3310 def r16 : CLGTHIInst<(outs R16C:$rT), (ins R16C:$rA, s10imm:$val),
3311 [(set R16C:$rT, (setugt R16C:$rA, i16ImmSExt10:$val))]>;
3312}
3313
3314class CLGTInst<dag OOL, dag IOL, list<dag> pattern> :
Scott Michelad2715e2008-03-05 23:02:02 +00003315 RRForm<0b00000011010, OOL, IOL, "clgt\t$rT, $rA, $rB",
Scott Michela59d4692008-02-23 18:41:37 +00003316 ByteOp, pattern>;
3317
3318multiclass CmpLGtrWord
3319{
3320 def v4i32 : CLGTInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
3321 [(set (v4i32 VECREG:$rT),
3322 (setugt (v4i32 VECREG:$rA), (v4i32 VECREG:$rB)))]>;
3323
3324 def r32 : CLGTInst<(outs R32C:$rT), (ins R32C:$rA, R32C:$rB),
3325 [(set R32C:$rT, (setugt R32C:$rA, R32C:$rB))]>;
3326}
3327
3328class CLGTIInst<dag OOL, dag IOL, list<dag> pattern> :
Scott Michelad2715e2008-03-05 23:02:02 +00003329 RI10Form<0b00111010, OOL, IOL, "clgti\t$rT, $rA, $val",
Scott Michela59d4692008-02-23 18:41:37 +00003330 ByteOp, pattern>;
3331
3332multiclass CmpLGtrWordImm
3333{
3334 def v4i32 : CLGTIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
3335 [(set (v4i32 VECREG:$rT),
3336 (setugt (v4i32 VECREG:$rA),
3337 (v4i32 v4i32SExt16Imm:$val)))]>;
3338
3339 def r32: CLGTIInst<(outs R32C:$rT), (ins R32C:$rA, s10imm_i32:$val),
Scott Michelad2715e2008-03-05 23:02:02 +00003340 [(set R32C:$rT, (setugt R32C:$rA, i32ImmSExt10:$val))]>;
Scott Michela59d4692008-02-23 18:41:37 +00003341}
3342
3343defm CEQB : CmpEqualByte;
3344defm CEQBI : CmpEqualByteImm;
3345defm CEQH : CmpEqualHalfword;
3346defm CEQHI : CmpEqualHalfwordImm;
3347defm CEQ : CmpEqualWord;
3348defm CEQI : CmpEqualWordImm;
3349defm CGTB : CmpGtrByte;
3350defm CGTBI : CmpGtrByteImm;
3351defm CGTH : CmpGtrHalfword;
3352defm CGTHI : CmpGtrHalfwordImm;
3353defm CGT : CmpGtrWord;
3354defm CGTI : CmpGtrWordImm;
3355defm CLGTB : CmpLGtrByte;
3356defm CLGTBI : CmpLGtrByteImm;
3357defm CLGTH : CmpLGtrHalfword;
3358defm CLGTHI : CmpLGtrHalfwordImm;
3359defm CLGT : CmpLGtrWord;
3360defm CLGTI : CmpLGtrWordImm;
3361
Scott Michel78c47fa2008-03-10 16:58:52 +00003362//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
Scott Michela59d4692008-02-23 18:41:37 +00003363// For SETCC primitives not supported above (setlt, setle, setge, etc.)
3364// define a pattern to generate the right code, as a binary operator
3365// (in a manner of speaking.)
Scott Michel78c47fa2008-03-10 16:58:52 +00003366//
Scott Michelf0569be2008-12-27 04:51:36 +00003367// Notes:
3368// 1. This only matches the setcc set of conditionals. Special pattern
3369// matching is used for select conditionals.
3370//
3371// 2. The "DAG" versions of these classes is almost exclusively used for
3372// i64 comparisons. See the tblgen fundamentals documentation for what
3373// ".ResultInstrs[0]" means; see TargetSelectionDAG.td and the Pattern
3374// class for where ResultInstrs originates.
Scott Michel78c47fa2008-03-10 16:58:52 +00003375//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
Scott Michela59d4692008-02-23 18:41:37 +00003376
Scott Michel78c47fa2008-03-10 16:58:52 +00003377class SETCCNegCondReg<PatFrag cond, RegisterClass rclass, ValueType inttype,
3378 SPUInstr xorinst, SPUInstr cmpare>:
3379 Pat<(cond rclass:$rA, rclass:$rB),
3380 (xorinst (cmpare rclass:$rA, rclass:$rB), (inttype -1))>;
3381
3382class SETCCNegCondImm<PatFrag cond, RegisterClass rclass, ValueType inttype,
3383 PatLeaf immpred, SPUInstr xorinst, SPUInstr cmpare>:
3384 Pat<(cond rclass:$rA, (inttype immpred:$imm)),
3385 (xorinst (cmpare rclass:$rA, (inttype immpred:$imm)), (inttype -1))>;
3386
Scott Michelf0569be2008-12-27 04:51:36 +00003387def : SETCCNegCondReg<setne, R8C, i8, XORBIr8, CEQBr8>;
Scott Michel78c47fa2008-03-10 16:58:52 +00003388def : SETCCNegCondImm<setne, R8C, i8, immSExt8, XORBIr8, CEQBIr8>;
3389
Scott Michelf0569be2008-12-27 04:51:36 +00003390def : SETCCNegCondReg<setne, R16C, i16, XORHIr16, CEQHr16>;
Scott Michel78c47fa2008-03-10 16:58:52 +00003391def : SETCCNegCondImm<setne, R16C, i16, i16ImmSExt10, XORHIr16, CEQHIr16>;
3392
3393def : SETCCNegCondReg<setne, R32C, i32, XORIr32, CEQr32>;
3394def : SETCCNegCondImm<setne, R32C, i32, i32ImmSExt10, XORIr32, CEQIr32>;
Scott Michela59d4692008-02-23 18:41:37 +00003395
3396class SETCCBinOpReg<PatFrag cond, RegisterClass rclass,
3397 SPUInstr binop, SPUInstr cmpOp1, SPUInstr cmpOp2>:
3398 Pat<(cond rclass:$rA, rclass:$rB),
3399 (binop (cmpOp1 rclass:$rA, rclass:$rB),
3400 (cmpOp2 rclass:$rA, rclass:$rB))>;
3401
3402class SETCCBinOpImm<PatFrag cond, RegisterClass rclass, PatLeaf immpred,
3403 ValueType immtype,
3404 SPUInstr binop, SPUInstr cmpOp1, SPUInstr cmpOp2>:
3405 Pat<(cond rclass:$rA, (immtype immpred:$imm)),
3406 (binop (cmpOp1 rclass:$rA, (immtype immpred:$imm)),
3407 (cmpOp2 rclass:$rA, (immtype immpred:$imm)))>;
3408
Scott Michel78c47fa2008-03-10 16:58:52 +00003409def : SETCCBinOpReg<setge, R8C, ORr8, CGTBr8, CEQBr8>;
3410def : SETCCBinOpImm<setge, R8C, immSExt8, i8, ORr8, CGTBIr8, CEQBIr8>;
3411def : SETCCBinOpReg<setlt, R8C, NORr8, CGTBr8, CEQBr8>;
3412def : SETCCBinOpImm<setlt, R8C, immSExt8, i8, NORr8, CGTBIr8, CEQBIr8>;
3413def : Pat<(setle R8C:$rA, R8C:$rB),
3414 (XORBIr8 (CGTBr8 R8C:$rA, R8C:$rB), 0xff)>;
3415def : Pat<(setle R8C:$rA, immU8:$imm),
3416 (XORBIr8 (CGTBIr8 R8C:$rA, immU8:$imm), 0xff)>;
Scott Michela59d4692008-02-23 18:41:37 +00003417
Scott Michel78c47fa2008-03-10 16:58:52 +00003418def : SETCCBinOpReg<setge, R16C, ORr16, CGTHr16, CEQHr16>;
3419def : SETCCBinOpImm<setge, R16C, i16ImmSExt10, i16,
3420 ORr16, CGTHIr16, CEQHIr16>;
3421def : SETCCBinOpReg<setlt, R16C, NORr16, CGTHr16, CEQHr16>;
3422def : SETCCBinOpImm<setlt, R16C, i16ImmSExt10, i16, NORr16, CGTHIr16, CEQHIr16>;
3423def : Pat<(setle R16C:$rA, R16C:$rB),
3424 (XORHIr16 (CGTHr16 R16C:$rA, R16C:$rB), 0xffff)>;
3425def : Pat<(setle R16C:$rA, i16ImmSExt10:$imm),
3426 (XORHIr16 (CGTHIr16 R16C:$rA, i16ImmSExt10:$imm), 0xffff)>;
Scott Michela59d4692008-02-23 18:41:37 +00003427
Scott Michel78c47fa2008-03-10 16:58:52 +00003428def : SETCCBinOpReg<setge, R32C, ORr32, CGTr32, CEQr32>;
3429def : SETCCBinOpImm<setge, R32C, i32ImmSExt10, i32,
3430 ORr32, CGTIr32, CEQIr32>;
3431def : SETCCBinOpReg<setlt, R32C, NORr32, CGTr32, CEQr32>;
3432def : SETCCBinOpImm<setlt, R32C, i32ImmSExt10, i32, NORr32, CGTIr32, CEQIr32>;
3433def : Pat<(setle R32C:$rA, R32C:$rB),
3434 (XORIr32 (CGTr32 R32C:$rA, R32C:$rB), 0xffffffff)>;
3435def : Pat<(setle R32C:$rA, i32ImmSExt10:$imm),
3436 (XORIr32 (CGTIr32 R32C:$rA, i32ImmSExt10:$imm), 0xffffffff)>;
Scott Michela59d4692008-02-23 18:41:37 +00003437
Scott Michel78c47fa2008-03-10 16:58:52 +00003438def : SETCCBinOpReg<setuge, R8C, ORr8, CLGTBr8, CEQBr8>;
3439def : SETCCBinOpImm<setuge, R8C, immSExt8, i8, ORr8, CLGTBIr8, CEQBIr8>;
3440def : SETCCBinOpReg<setult, R8C, NORr8, CLGTBr8, CEQBr8>;
3441def : SETCCBinOpImm<setult, R8C, immSExt8, i8, NORr8, CLGTBIr8, CEQBIr8>;
3442def : Pat<(setule R8C:$rA, R8C:$rB),
3443 (XORBIr8 (CLGTBr8 R8C:$rA, R8C:$rB), 0xff)>;
3444def : Pat<(setule R8C:$rA, immU8:$imm),
3445 (XORBIr8 (CLGTBIr8 R8C:$rA, immU8:$imm), 0xff)>;
Scott Michela59d4692008-02-23 18:41:37 +00003446
Scott Michel78c47fa2008-03-10 16:58:52 +00003447def : SETCCBinOpReg<setuge, R16C, ORr16, CLGTHr16, CEQHr16>;
3448def : SETCCBinOpImm<setuge, R16C, i16ImmSExt10, i16,
3449 ORr16, CLGTHIr16, CEQHIr16>;
3450def : SETCCBinOpReg<setult, R16C, NORr16, CLGTHr16, CEQHr16>;
3451def : SETCCBinOpImm<setult, R16C, i16ImmSExt10, i16, NORr16,
3452 CLGTHIr16, CEQHIr16>;
3453def : Pat<(setule R16C:$rA, R16C:$rB),
3454 (XORHIr16 (CLGTHr16 R16C:$rA, R16C:$rB), 0xffff)>;
Scott Michel79698f62008-03-20 00:51:36 +00003455def : Pat<(setule R16C:$rA, i16ImmSExt10:$imm),
Scott Michel78c47fa2008-03-10 16:58:52 +00003456 (XORHIr16 (CLGTHIr16 R16C:$rA, i16ImmSExt10:$imm), 0xffff)>;
Scott Michela59d4692008-02-23 18:41:37 +00003457
Scott Michel78c47fa2008-03-10 16:58:52 +00003458def : SETCCBinOpReg<setuge, R32C, ORr32, CLGTr32, CEQr32>;
Scott Michel79698f62008-03-20 00:51:36 +00003459def : SETCCBinOpImm<setuge, R32C, i32ImmSExt10, i32,
Scott Michel78c47fa2008-03-10 16:58:52 +00003460 ORr32, CLGTIr32, CEQIr32>;
3461def : SETCCBinOpReg<setult, R32C, NORr32, CLGTr32, CEQr32>;
Scott Michel79698f62008-03-20 00:51:36 +00003462def : SETCCBinOpImm<setult, R32C, i32ImmSExt10, i32, NORr32, CLGTIr32, CEQIr32>;
Scott Michel78c47fa2008-03-10 16:58:52 +00003463def : Pat<(setule R32C:$rA, R32C:$rB),
3464 (XORIr32 (CLGTr32 R32C:$rA, R32C:$rB), 0xffffffff)>;
3465def : Pat<(setule R32C:$rA, i32ImmSExt10:$imm),
3466 (XORIr32 (CLGTIr32 R32C:$rA, i32ImmSExt10:$imm), 0xffffffff)>;
Scott Michela59d4692008-02-23 18:41:37 +00003467
Scott Michel78c47fa2008-03-10 16:58:52 +00003468//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
3469// select conditional patterns:
3470//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
3471
3472class SELECTNegCondReg<PatFrag cond, RegisterClass rclass, ValueType inttype,
3473 SPUInstr selinstr, SPUInstr cmpare>:
3474 Pat<(select (inttype (cond rclass:$rA, rclass:$rB)),
3475 rclass:$rTrue, rclass:$rFalse),
3476 (selinstr rclass:$rTrue, rclass:$rFalse,
Bill Wendlingbbf2e062008-07-22 08:50:44 +00003477 (cmpare rclass:$rA, rclass:$rB))>;
Scott Michel78c47fa2008-03-10 16:58:52 +00003478
3479class SELECTNegCondImm<PatFrag cond, RegisterClass rclass, ValueType inttype,
3480 PatLeaf immpred, SPUInstr selinstr, SPUInstr cmpare>:
3481 Pat<(select (inttype (cond rclass:$rA, immpred:$imm)),
Bill Wendlingbbf2e062008-07-22 08:50:44 +00003482 rclass:$rTrue, rclass:$rFalse),
Scott Michel78c47fa2008-03-10 16:58:52 +00003483 (selinstr rclass:$rTrue, rclass:$rFalse,
3484 (cmpare rclass:$rA, immpred:$imm))>;
3485
3486def : SELECTNegCondReg<setne, R8C, i8, SELBr8, CEQBr8>;
3487def : SELECTNegCondImm<setne, R8C, i8, immSExt8, SELBr8, CEQBIr8>;
3488def : SELECTNegCondReg<setle, R8C, i8, SELBr8, CGTBr8>;
3489def : SELECTNegCondImm<setle, R8C, i8, immSExt8, SELBr8, CGTBr8>;
3490def : SELECTNegCondReg<setule, R8C, i8, SELBr8, CLGTBr8>;
3491def : SELECTNegCondImm<setule, R8C, i8, immU8, SELBr8, CLGTBIr8>;
3492
3493def : SELECTNegCondReg<setne, R16C, i16, SELBr16, CEQHr16>;
3494def : SELECTNegCondImm<setne, R16C, i16, i16ImmSExt10, SELBr16, CEQHIr16>;
3495def : SELECTNegCondReg<setle, R16C, i16, SELBr16, CGTHr16>;
3496def : SELECTNegCondImm<setle, R16C, i16, i16ImmSExt10, SELBr16, CGTHIr16>;
3497def : SELECTNegCondReg<setule, R16C, i16, SELBr16, CLGTHr16>;
3498def : SELECTNegCondImm<setule, R16C, i16, i16ImmSExt10, SELBr16, CLGTHIr16>;
3499
3500def : SELECTNegCondReg<setne, R32C, i32, SELBr32, CEQr32>;
3501def : SELECTNegCondImm<setne, R32C, i32, i32ImmSExt10, SELBr32, CEQIr32>;
3502def : SELECTNegCondReg<setle, R32C, i32, SELBr32, CGTr32>;
3503def : SELECTNegCondImm<setle, R32C, i32, i32ImmSExt10, SELBr32, CGTIr32>;
3504def : SELECTNegCondReg<setule, R32C, i32, SELBr32, CLGTr32>;
3505def : SELECTNegCondImm<setule, R32C, i32, i32ImmSExt10, SELBr32, CLGTIr32>;
3506
3507class SELECTBinOpReg<PatFrag cond, RegisterClass rclass, ValueType inttype,
3508 SPUInstr selinstr, SPUInstr binop, SPUInstr cmpOp1,
3509 SPUInstr cmpOp2>:
3510 Pat<(select (inttype (cond rclass:$rA, rclass:$rB)),
Scott Michelf0569be2008-12-27 04:51:36 +00003511 rclass:$rTrue, rclass:$rFalse),
3512 (selinstr rclass:$rFalse, rclass:$rTrue,
Scott Michel78c47fa2008-03-10 16:58:52 +00003513 (binop (cmpOp1 rclass:$rA, rclass:$rB),
3514 (cmpOp2 rclass:$rA, rclass:$rB)))>;
3515
3516class SELECTBinOpImm<PatFrag cond, RegisterClass rclass, PatLeaf immpred,
3517 ValueType inttype,
3518 SPUInstr selinstr, SPUInstr binop, SPUInstr cmpOp1,
3519 SPUInstr cmpOp2>:
3520 Pat<(select (inttype (cond rclass:$rA, (inttype immpred:$imm))),
Bill Wendlingbbf2e062008-07-22 08:50:44 +00003521 rclass:$rTrue, rclass:$rFalse),
Scott Michel78c47fa2008-03-10 16:58:52 +00003522 (selinstr rclass:$rFalse, rclass:$rTrue,
3523 (binop (cmpOp1 rclass:$rA, (inttype immpred:$imm)),
3524 (cmpOp2 rclass:$rA, (inttype immpred:$imm))))>;
3525
3526def : SELECTBinOpReg<setge, R8C, i8, SELBr8, ORr8, CGTBr8, CEQBr8>;
3527def : SELECTBinOpImm<setge, R8C, immSExt8, i8,
3528 SELBr8, ORr8, CGTBIr8, CEQBIr8>;
3529
3530def : SELECTBinOpReg<setge, R16C, i16, SELBr16, ORr16, CGTHr16, CEQHr16>;
3531def : SELECTBinOpImm<setge, R16C, i16ImmSExt10, i16,
3532 SELBr16, ORr16, CGTHIr16, CEQHIr16>;
3533
3534def : SELECTBinOpReg<setge, R32C, i32, SELBr32, ORr32, CGTr32, CEQr32>;
3535def : SELECTBinOpImm<setge, R32C, i32ImmSExt10, i32,
3536 SELBr32, ORr32, CGTIr32, CEQIr32>;
3537
3538def : SELECTBinOpReg<setuge, R8C, i8, SELBr8, ORr8, CLGTBr8, CEQBr8>;
3539def : SELECTBinOpImm<setuge, R8C, immSExt8, i8,
3540 SELBr8, ORr8, CLGTBIr8, CEQBIr8>;
3541
3542def : SELECTBinOpReg<setuge, R16C, i16, SELBr16, ORr16, CLGTHr16, CEQHr16>;
3543def : SELECTBinOpImm<setuge, R16C, i16ImmUns10, i16,
3544 SELBr16, ORr16, CLGTHIr16, CEQHIr16>;
3545
3546def : SELECTBinOpReg<setuge, R32C, i32, SELBr32, ORr32, CLGTr32, CEQr32>;
3547def : SELECTBinOpImm<setuge, R32C, i32ImmUns10, i32,
3548 SELBr32, ORr32, CLGTIr32, CEQIr32>;
Scott Michela59d4692008-02-23 18:41:37 +00003549
3550//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
Scott Michel66377522007-12-04 22:35:58 +00003551
3552let isCall = 1,
3553 // All calls clobber the non-callee-saved registers:
3554 Defs = [R0, R1, R2, R3, R4, R5, R6, R7, R8, R9,
3555 R10,R11,R12,R13,R14,R15,R16,R17,R18,R19,
3556 R20,R21,R22,R23,R24,R25,R26,R27,R28,R29,
3557 R30,R31,R32,R33,R34,R35,R36,R37,R38,R39,
3558 R40,R41,R42,R43,R44,R45,R46,R47,R48,R49,
3559 R50,R51,R52,R53,R54,R55,R56,R57,R58,R59,
3560 R60,R61,R62,R63,R64,R65,R66,R67,R68,R69,
3561 R70,R71,R72,R73,R74,R75,R76,R77,R78,R79],
3562 // All of these instructions use $lr (aka $0)
3563 Uses = [R0] in {
3564 // Branch relative and set link: Used if we actually know that the target
3565 // is within [-32768, 32767] bytes of the target
3566 def BRSL:
3567 BranchSetLink<0b011001100, (outs), (ins relcalltarget:$func, variable_ops),
3568 "brsl\t$$lr, $func",
3569 [(SPUcall (SPUpcrel tglobaladdr:$func, 0))]>;
3570
3571 // Branch absolute and set link: Used if we actually know that the target
3572 // is an absolute address
3573 def BRASL:
3574 BranchSetLink<0b011001100, (outs), (ins calltarget:$func, variable_ops),
3575 "brasl\t$$lr, $func",
Scott Michel9de5d0d2008-01-11 02:53:15 +00003576 [(SPUcall (SPUaform tglobaladdr:$func, 0))]>;
Scott Michel66377522007-12-04 22:35:58 +00003577
3578 // Branch indirect and set link if external data. These instructions are not
3579 // actually generated, matched by an intrinsic:
3580 def BISLED_00: BISLEDForm<0b11, "bisled\t$$lr, $func", [/* empty pattern */]>;
3581 def BISLED_E0: BISLEDForm<0b10, "bisled\t$$lr, $func", [/* empty pattern */]>;
3582 def BISLED_0D: BISLEDForm<0b01, "bisled\t$$lr, $func", [/* empty pattern */]>;
3583 def BISLED_ED: BISLEDForm<0b00, "bisled\t$$lr, $func", [/* empty pattern */]>;
3584
3585 // Branch indirect and set link. This is the "X-form" address version of a
3586 // function call
3587 def BISL:
3588 BIForm<0b10010101100, "bisl\t$$lr, $func", [(SPUcall R32C:$func)]>;
3589}
3590
Scott Michel1df30c42008-12-29 03:23:36 +00003591// Support calls to external symbols:
3592def : Pat<(SPUcall (SPUpcrel texternalsym:$func, 0)),
3593 (BRSL texternalsym:$func)>;
3594
3595def : Pat<(SPUcall (SPUaform texternalsym:$func, 0)),
3596 (BRASL texternalsym:$func)>;
3597
Scott Michel66377522007-12-04 22:35:58 +00003598// Unconditional branches:
Dan Gohman5b37fba2009-11-10 22:16:57 +00003599let isBranch = 1, isTerminator = 1, hasCtrlDep = 1 in {
3600 let isBarrier = 1 in {
3601 def BR :
3602 UncondBranch<0b001001100, (outs), (ins brtarget:$dest),
3603 "br\t$dest",
3604 [(br bb:$dest)]>;
Scott Michel66377522007-12-04 22:35:58 +00003605
Dan Gohman5b37fba2009-11-10 22:16:57 +00003606 // Unconditional, absolute address branch
3607 def BRA:
3608 UncondBranch<0b001100000, (outs), (ins brtarget:$dest),
3609 "bra\t$dest",
3610 [/* no pattern */]>;
Scott Michel66377522007-12-04 22:35:58 +00003611
Dan Gohman5b37fba2009-11-10 22:16:57 +00003612 // Indirect branch
3613 def BI:
3614 BIForm<0b00010101100, "bi\t$func", [(brind R32C:$func)]>;
3615 }
Scott Michel66377522007-12-04 22:35:58 +00003616
Scott Micheled741dd2009-01-05 01:34:35 +00003617 // Conditional branches:
Scott Michelf0569be2008-12-27 04:51:36 +00003618 class BRNZInst<dag IOL, list<dag> pattern>:
3619 RI16Form<0b010000100, (outs), IOL, "brnz\t$rCond,$dest",
3620 BranchResolv, pattern>;
Scott Michel66377522007-12-04 22:35:58 +00003621
Scott Michelf0569be2008-12-27 04:51:36 +00003622 class BRNZRegInst<RegisterClass rclass>:
3623 BRNZInst<(ins rclass:$rCond, brtarget:$dest),
3624 [(brcond rclass:$rCond, bb:$dest)]>;
Scott Michel66377522007-12-04 22:35:58 +00003625
Scott Michelf0569be2008-12-27 04:51:36 +00003626 class BRNZVecInst<ValueType vectype>:
3627 BRNZInst<(ins VECREG:$rCond, brtarget:$dest),
3628 [(brcond (vectype VECREG:$rCond), bb:$dest)]>;
Scott Michel66377522007-12-04 22:35:58 +00003629
Scott Michelf0569be2008-12-27 04:51:36 +00003630 multiclass BranchNotZero {
3631 def v4i32 : BRNZVecInst<v4i32>;
3632 def r32 : BRNZRegInst<R32C>;
3633 }
Scott Michel66377522007-12-04 22:35:58 +00003634
Scott Michelf0569be2008-12-27 04:51:36 +00003635 defm BRNZ : BranchNotZero;
3636
3637 class BRZInst<dag IOL, list<dag> pattern>:
3638 RI16Form<0b000000100, (outs), IOL, "brz\t$rT,$dest",
3639 BranchResolv, pattern>;
3640
3641 class BRZRegInst<RegisterClass rclass>:
3642 BRZInst<(ins rclass:$rT, brtarget:$dest), [/* no pattern */]>;
3643
3644 class BRZVecInst<ValueType vectype>:
3645 BRZInst<(ins VECREG:$rT, brtarget:$dest), [/* no pattern */]>;
3646
3647 multiclass BranchZero {
3648 def v4i32: BRZVecInst<v4i32>;
3649 def r32: BRZRegInst<R32C>;
3650 }
3651
3652 defm BRZ: BranchZero;
3653
3654 // Note: LLVM doesn't do branch conditional, indirect. Otherwise these would
3655 // be useful:
3656 /*
3657 class BINZInst<dag IOL, list<dag> pattern>:
3658 BICondForm<0b10010100100, (outs), IOL, "binz\t$rA, $dest", pattern>;
3659
3660 class BINZRegInst<RegisterClass rclass>:
3661 BINZInst<(ins rclass:$rA, brtarget:$dest),
3662 [(brcond rclass:$rA, R32C:$dest)]>;
3663
3664 class BINZVecInst<ValueType vectype>:
3665 BINZInst<(ins VECREG:$rA, R32C:$dest),
3666 [(brcond (vectype VECREG:$rA), R32C:$dest)]>;
3667
3668 multiclass BranchNotZeroIndirect {
3669 def v4i32: BINZVecInst<v4i32>;
3670 def r32: BINZRegInst<R32C>;
3671 }
3672
3673 defm BINZ: BranchNotZeroIndirect;
3674
3675 class BIZInst<dag IOL, list<dag> pattern>:
3676 BICondForm<0b00010100100, (outs), IOL, "biz\t$rA, $func", pattern>;
3677
3678 class BIZRegInst<RegisterClass rclass>:
3679 BIZInst<(ins rclass:$rA, R32C:$func), [/* no pattern */]>;
3680
3681 class BIZVecInst<ValueType vectype>:
3682 BIZInst<(ins VECREG:$rA, R32C:$func), [/* no pattern */]>;
3683
3684 multiclass BranchZeroIndirect {
3685 def v4i32: BIZVecInst<v4i32>;
3686 def r32: BIZRegInst<R32C>;
3687 }
3688
3689 defm BIZ: BranchZeroIndirect;
3690 */
3691
3692 class BRHNZInst<dag IOL, list<dag> pattern>:
3693 RI16Form<0b011000100, (outs), IOL, "brhnz\t$rCond,$dest", BranchResolv,
3694 pattern>;
3695
3696 class BRHNZRegInst<RegisterClass rclass>:
3697 BRHNZInst<(ins rclass:$rCond, brtarget:$dest),
3698 [(brcond rclass:$rCond, bb:$dest)]>;
3699
3700 class BRHNZVecInst<ValueType vectype>:
3701 BRHNZInst<(ins VECREG:$rCond, brtarget:$dest), [/* no pattern */]>;
3702
3703 multiclass BranchNotZeroHalfword {
3704 def v8i16: BRHNZVecInst<v8i16>;
3705 def r16: BRHNZRegInst<R16C>;
3706 }
3707
3708 defm BRHNZ: BranchNotZeroHalfword;
3709
3710 class BRHZInst<dag IOL, list<dag> pattern>:
3711 RI16Form<0b001000100, (outs), IOL, "brhz\t$rT,$dest", BranchResolv,
3712 pattern>;
3713
3714 class BRHZRegInst<RegisterClass rclass>:
3715 BRHZInst<(ins rclass:$rT, brtarget:$dest), [/* no pattern */]>;
3716
3717 class BRHZVecInst<ValueType vectype>:
3718 BRHZInst<(ins VECREG:$rT, brtarget:$dest), [/* no pattern */]>;
3719
3720 multiclass BranchZeroHalfword {
3721 def v8i16: BRHZVecInst<v8i16>;
3722 def r16: BRHZRegInst<R16C>;
3723 }
3724
3725 defm BRHZ: BranchZeroHalfword;
Scott Michel66377522007-12-04 22:35:58 +00003726}
3727
Scott Michel58c58182008-01-17 20:38:41 +00003728//===----------------------------------------------------------------------===//
Scott Michel053c1da2008-01-29 02:16:57 +00003729// setcc and brcond patterns:
Scott Michel58c58182008-01-17 20:38:41 +00003730//===----------------------------------------------------------------------===//
Scott Michel053c1da2008-01-29 02:16:57 +00003731
Scott Michelf0569be2008-12-27 04:51:36 +00003732def : Pat<(brcond (i16 (seteq R16C:$rA, 0)), bb:$dest),
3733 (BRHZr16 R16C:$rA, bb:$dest)>;
3734def : Pat<(brcond (i16 (setne R16C:$rA, 0)), bb:$dest),
3735 (BRHNZr16 R16C:$rA, bb:$dest)>;
Scott Michela59d4692008-02-23 18:41:37 +00003736
Scott Michelf0569be2008-12-27 04:51:36 +00003737def : Pat<(brcond (i32 (seteq R32C:$rA, 0)), bb:$dest),
3738 (BRZr32 R32C:$rA, bb:$dest)>;
3739def : Pat<(brcond (i32 (setne R32C:$rA, 0)), bb:$dest),
3740 (BRNZr32 R32C:$rA, bb:$dest)>;
Scott Michel66377522007-12-04 22:35:58 +00003741
Scott Michela59d4692008-02-23 18:41:37 +00003742multiclass BranchCondEQ<PatFrag cond, SPUInstr brinst16, SPUInstr brinst32>
3743{
3744 def r16imm: Pat<(brcond (i16 (cond R16C:$rA, i16ImmSExt10:$val)), bb:$dest),
3745 (brinst16 (CEQHIr16 R16C:$rA, i16ImmSExt10:$val), bb:$dest)>;
Scott Michel053c1da2008-01-29 02:16:57 +00003746
Scott Michela59d4692008-02-23 18:41:37 +00003747 def r16 : Pat<(brcond (i16 (cond R16C:$rA, R16C:$rB)), bb:$dest),
3748 (brinst16 (CEQHr16 R16C:$rA, R16:$rB), bb:$dest)>;
3749
3750 def r32imm : Pat<(brcond (i32 (cond R32C:$rA, i32ImmSExt10:$val)), bb:$dest),
3751 (brinst32 (CEQIr32 R32C:$rA, i32ImmSExt10:$val), bb:$dest)>;
3752
3753 def r32 : Pat<(brcond (i32 (cond R32C:$rA, R32C:$rB)), bb:$dest),
3754 (brinst32 (CEQr32 R32C:$rA, R32C:$rB), bb:$dest)>;
3755}
3756
Scott Micheled741dd2009-01-05 01:34:35 +00003757defm BRCONDeq : BranchCondEQ<seteq, BRHNZr16, BRNZr32>;
3758defm BRCONDne : BranchCondEQ<setne, BRHZr16, BRZr32>;
Scott Michela59d4692008-02-23 18:41:37 +00003759
3760multiclass BranchCondLGT<PatFrag cond, SPUInstr brinst16, SPUInstr brinst32>
3761{
3762 def r16imm : Pat<(brcond (i16 (cond R16C:$rA, i16ImmSExt10:$val)), bb:$dest),
3763 (brinst16 (CLGTHIr16 R16C:$rA, i16ImmSExt10:$val), bb:$dest)>;
3764
3765 def r16 : Pat<(brcond (i16 (cond R16C:$rA, R16C:$rB)), bb:$dest),
3766 (brinst16 (CLGTHr16 R16C:$rA, R16:$rB), bb:$dest)>;
3767
3768 def r32imm : Pat<(brcond (i32 (cond R32C:$rA, i32ImmSExt10:$val)), bb:$dest),
3769 (brinst32 (CLGTIr32 R32C:$rA, i32ImmSExt10:$val), bb:$dest)>;
3770
3771 def r32 : Pat<(brcond (i32 (cond R32C:$rA, R32C:$rB)), bb:$dest),
3772 (brinst32 (CLGTr32 R32C:$rA, R32C:$rB), bb:$dest)>;
3773}
3774
Scott Michelf0569be2008-12-27 04:51:36 +00003775defm BRCONDugt : BranchCondLGT<setugt, BRHNZr16, BRNZr32>;
3776defm BRCONDule : BranchCondLGT<setule, BRHZr16, BRZr32>;
Scott Michela59d4692008-02-23 18:41:37 +00003777
3778multiclass BranchCondLGTEQ<PatFrag cond, SPUInstr orinst16, SPUInstr brinst16,
3779 SPUInstr orinst32, SPUInstr brinst32>
3780{
3781 def r16imm: Pat<(brcond (i16 (cond R16C:$rA, i16ImmSExt10:$val)), bb:$dest),
3782 (brinst16 (orinst16 (CLGTHIr16 R16C:$rA, i16ImmSExt10:$val),
3783 (CEQHIr16 R16C:$rA, i16ImmSExt10:$val)),
3784 bb:$dest)>;
3785
3786 def r16: Pat<(brcond (i16 (cond R16C:$rA, R16C:$rB)), bb:$dest),
3787 (brinst16 (orinst16 (CLGTHr16 R16C:$rA, R16:$rB),
3788 (CEQHr16 R16C:$rA, R16:$rB)),
3789 bb:$dest)>;
3790
3791 def r32imm : Pat<(brcond (i32 (cond R32C:$rA, i32ImmSExt10:$val)), bb:$dest),
3792 (brinst32 (orinst32 (CLGTIr32 R32C:$rA, i32ImmSExt10:$val),
3793 (CEQIr32 R32C:$rA, i32ImmSExt10:$val)),
3794 bb:$dest)>;
3795
3796 def r32 : Pat<(brcond (i32 (cond R32C:$rA, R32C:$rB)), bb:$dest),
3797 (brinst32 (orinst32 (CLGTr32 R32C:$rA, R32C:$rB),
3798 (CEQr32 R32C:$rA, R32C:$rB)),
3799 bb:$dest)>;
3800}
3801
Scott Michelf0569be2008-12-27 04:51:36 +00003802defm BRCONDuge : BranchCondLGTEQ<setuge, ORr16, BRHNZr16, ORr32, BRNZr32>;
3803defm BRCONDult : BranchCondLGTEQ<setult, ORr16, BRHZr16, ORr32, BRZr32>;
Scott Michela59d4692008-02-23 18:41:37 +00003804
3805multiclass BranchCondGT<PatFrag cond, SPUInstr brinst16, SPUInstr brinst32>
3806{
3807 def r16imm : Pat<(brcond (i16 (cond R16C:$rA, i16ImmSExt10:$val)), bb:$dest),
3808 (brinst16 (CGTHIr16 R16C:$rA, i16ImmSExt10:$val), bb:$dest)>;
3809
3810 def r16 : Pat<(brcond (i16 (cond R16C:$rA, R16C:$rB)), bb:$dest),
3811 (brinst16 (CGTHr16 R16C:$rA, R16:$rB), bb:$dest)>;
3812
3813 def r32imm : Pat<(brcond (i32 (cond R32C:$rA, i32ImmSExt10:$val)), bb:$dest),
3814 (brinst32 (CGTIr32 R32C:$rA, i32ImmSExt10:$val), bb:$dest)>;
3815
3816 def r32 : Pat<(brcond (i32 (cond R32C:$rA, R32C:$rB)), bb:$dest),
3817 (brinst32 (CGTr32 R32C:$rA, R32C:$rB), bb:$dest)>;
3818}
3819
Scott Michelf0569be2008-12-27 04:51:36 +00003820defm BRCONDgt : BranchCondGT<setgt, BRHNZr16, BRNZr32>;
3821defm BRCONDle : BranchCondGT<setle, BRHZr16, BRZr32>;
Scott Michela59d4692008-02-23 18:41:37 +00003822
3823multiclass BranchCondGTEQ<PatFrag cond, SPUInstr orinst16, SPUInstr brinst16,
3824 SPUInstr orinst32, SPUInstr brinst32>
3825{
3826 def r16imm: Pat<(brcond (i16 (cond R16C:$rA, i16ImmSExt10:$val)), bb:$dest),
3827 (brinst16 (orinst16 (CGTHIr16 R16C:$rA, i16ImmSExt10:$val),
3828 (CEQHIr16 R16C:$rA, i16ImmSExt10:$val)),
3829 bb:$dest)>;
3830
3831 def r16: Pat<(brcond (i16 (cond R16C:$rA, R16C:$rB)), bb:$dest),
3832 (brinst16 (orinst16 (CGTHr16 R16C:$rA, R16:$rB),
3833 (CEQHr16 R16C:$rA, R16:$rB)),
3834 bb:$dest)>;
3835
3836 def r32imm : Pat<(brcond (i32 (cond R32C:$rA, i32ImmSExt10:$val)), bb:$dest),
3837 (brinst32 (orinst32 (CGTIr32 R32C:$rA, i32ImmSExt10:$val),
3838 (CEQIr32 R32C:$rA, i32ImmSExt10:$val)),
3839 bb:$dest)>;
3840
3841 def r32 : Pat<(brcond (i32 (cond R32C:$rA, R32C:$rB)), bb:$dest),
3842 (brinst32 (orinst32 (CGTr32 R32C:$rA, R32C:$rB),
3843 (CEQr32 R32C:$rA, R32C:$rB)),
3844 bb:$dest)>;
3845}
3846
Scott Michelf0569be2008-12-27 04:51:36 +00003847defm BRCONDge : BranchCondGTEQ<setge, ORr16, BRHNZr16, ORr32, BRNZr32>;
3848defm BRCONDlt : BranchCondGTEQ<setlt, ORr16, BRHZr16, ORr32, BRZr32>;
Scott Michel053c1da2008-01-29 02:16:57 +00003849
Scott Michel66377522007-12-04 22:35:58 +00003850let isTerminator = 1, isBarrier = 1 in {
3851 let isReturn = 1 in {
3852 def RET:
3853 RETForm<"bi\t$$lr", [(retflag)]>;
3854 }
3855}
3856
3857//===----------------------------------------------------------------------===//
Scott Michel66377522007-12-04 22:35:58 +00003858// Single precision floating point instructions
3859//===----------------------------------------------------------------------===//
3860
Scott Michelaedc6372008-12-10 00:15:19 +00003861class FAInst<dag OOL, dag IOL, list<dag> pattern>:
3862 RRForm<0b01011000100, OOL, IOL, "fa\t$rT, $rA, $rB",
Scott Michel02d711b2008-12-30 23:28:25 +00003863 SPrecFP, pattern>;
Scott Michelf0569be2008-12-27 04:51:36 +00003864
Scott Michelaedc6372008-12-10 00:15:19 +00003865class FAVecInst<ValueType vectype>:
3866 FAInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
3867 [(set (vectype VECREG:$rT),
Scott Michel02d711b2008-12-30 23:28:25 +00003868 (fadd (vectype VECREG:$rA), (vectype VECREG:$rB)))]>;
Scott Michelf0569be2008-12-27 04:51:36 +00003869
Scott Michelaedc6372008-12-10 00:15:19 +00003870multiclass SFPAdd
3871{
3872 def v4f32: FAVecInst<v4f32>;
Scott Michel02d711b2008-12-30 23:28:25 +00003873 def f32: FAInst<(outs R32FP:$rT), (ins R32FP:$rA, R32FP:$rB),
3874 [(set R32FP:$rT, (fadd R32FP:$rA, R32FP:$rB))]>;
Scott Michelaedc6372008-12-10 00:15:19 +00003875}
Scott Michel66377522007-12-04 22:35:58 +00003876
Scott Michelaedc6372008-12-10 00:15:19 +00003877defm FA : SFPAdd;
Scott Michel66377522007-12-04 22:35:58 +00003878
Scott Michelaedc6372008-12-10 00:15:19 +00003879class FSInst<dag OOL, dag IOL, list<dag> pattern>:
3880 RRForm<0b01011000100, OOL, IOL, "fs\t$rT, $rA, $rB",
Scott Michel02d711b2008-12-30 23:28:25 +00003881 SPrecFP, pattern>;
Scott Michel66377522007-12-04 22:35:58 +00003882
Scott Michelaedc6372008-12-10 00:15:19 +00003883class FSVecInst<ValueType vectype>:
3884 FSInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
Scott Michel02d711b2008-12-30 23:28:25 +00003885 [(set (vectype VECREG:$rT),
3886 (fsub (vectype VECREG:$rA), (vectype VECREG:$rB)))]>;
Scott Michelaedc6372008-12-10 00:15:19 +00003887
3888multiclass SFPSub
3889{
3890 def v4f32: FSVecInst<v4f32>;
Scott Michel02d711b2008-12-30 23:28:25 +00003891 def f32: FSInst<(outs R32FP:$rT), (ins R32FP:$rA, R32FP:$rB),
3892 [(set R32FP:$rT, (fsub R32FP:$rA, R32FP:$rB))]>;
Scott Michelaedc6372008-12-10 00:15:19 +00003893}
3894
3895defm FS : SFPSub;
Scott Michel66377522007-12-04 22:35:58 +00003896
3897// Floating point reciprocal estimate
Scott Michel66377522007-12-04 22:35:58 +00003898
Scott Michel02d711b2008-12-30 23:28:25 +00003899class FRESTInst<dag OOL, dag IOL>:
3900 RRForm_1<0b00110111000, OOL, IOL,
3901 "frest\t$rT, $rA", SPrecFP,
3902 [/* no pattern */]>;
3903
3904def FRESTv4f32 :
3905 FRESTInst<(outs VECREG:$rT), (ins VECREG:$rA)>;
3906
3907def FRESTf32 :
3908 FRESTInst<(outs R32FP:$rT), (ins R32FP:$rA)>;
Scott Michel66377522007-12-04 22:35:58 +00003909
3910// Floating point interpolate (used in conjunction with reciprocal estimate)
3911def FIv4f32 :
3912 RRForm<0b00101011110, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
3913 "fi\t$rT, $rA, $rB", SPrecFP,
Scott Michel02d711b2008-12-30 23:28:25 +00003914 [/* no pattern */]>;
Scott Michel66377522007-12-04 22:35:58 +00003915
3916def FIf32 :
3917 RRForm<0b00101011110, (outs R32FP:$rT), (ins R32FP:$rA, R32FP:$rB),
3918 "fi\t$rT, $rA, $rB", SPrecFP,
Scott Michel02d711b2008-12-30 23:28:25 +00003919 [/* no pattern */]>;
Scott Michel66377522007-12-04 22:35:58 +00003920
Scott Michel9c0c6b22008-11-21 02:56:16 +00003921//--------------------------------------------------------------------------
3922// Basic single precision floating point comparisons:
3923//
3924// Note: There is no support on SPU for single precision NaN. Consequently,
3925// ordered and unordered comparisons are the same.
3926//--------------------------------------------------------------------------
3927
Scott Michel66377522007-12-04 22:35:58 +00003928def FCEQf32 :
3929 RRForm<0b01000011110, (outs R32C:$rT), (ins R32FP:$rA, R32FP:$rB),
3930 "fceq\t$rT, $rA, $rB", SPrecFP,
Scott Michel9c0c6b22008-11-21 02:56:16 +00003931 [(set R32C:$rT, (setueq R32FP:$rA, R32FP:$rB))]>;
3932
3933def : Pat<(setoeq R32FP:$rA, R32FP:$rB),
3934 (FCEQf32 R32FP:$rA, R32FP:$rB)>;
Scott Michel66377522007-12-04 22:35:58 +00003935
3936def FCMEQf32 :
3937 RRForm<0b01010011110, (outs R32C:$rT), (ins R32FP:$rA, R32FP:$rB),
3938 "fcmeq\t$rT, $rA, $rB", SPrecFP,
Scott Michel9c0c6b22008-11-21 02:56:16 +00003939 [(set R32C:$rT, (setueq (fabs R32FP:$rA), (fabs R32FP:$rB)))]>;
3940
3941def : Pat<(setoeq (fabs R32FP:$rA), (fabs R32FP:$rB)),
3942 (FCMEQf32 R32FP:$rA, R32FP:$rB)>;
Scott Michel66377522007-12-04 22:35:58 +00003943
3944def FCGTf32 :
3945 RRForm<0b01000011010, (outs R32C:$rT), (ins R32FP:$rA, R32FP:$rB),
3946 "fcgt\t$rT, $rA, $rB", SPrecFP,
Scott Michel9c0c6b22008-11-21 02:56:16 +00003947 [(set R32C:$rT, (setugt R32FP:$rA, R32FP:$rB))]>;
3948
3949def : Pat<(setugt R32FP:$rA, R32FP:$rB),
3950 (FCGTf32 R32FP:$rA, R32FP:$rB)>;
Scott Michel66377522007-12-04 22:35:58 +00003951
3952def FCMGTf32 :
3953 RRForm<0b01010011010, (outs R32C:$rT), (ins R32FP:$rA, R32FP:$rB),
3954 "fcmgt\t$rT, $rA, $rB", SPrecFP,
Scott Michel9c0c6b22008-11-21 02:56:16 +00003955 [(set R32C:$rT, (setugt (fabs R32FP:$rA), (fabs R32FP:$rB)))]>;
3956
3957def : Pat<(setugt (fabs R32FP:$rA), (fabs R32FP:$rB)),
3958 (FCMGTf32 R32FP:$rA, R32FP:$rB)>;
3959
3960//--------------------------------------------------------------------------
3961// Single precision floating point comparisons and SETCC equivalents:
3962//--------------------------------------------------------------------------
3963
3964def : SETCCNegCondReg<setune, R32FP, i32, XORIr32, FCEQf32>;
3965def : SETCCNegCondReg<setone, R32FP, i32, XORIr32, FCEQf32>;
3966
3967def : SETCCBinOpReg<setuge, R32FP, ORr32, FCGTf32, FCEQf32>;
3968def : SETCCBinOpReg<setoge, R32FP, ORr32, FCGTf32, FCEQf32>;
3969
3970def : SETCCBinOpReg<setult, R32FP, NORr32, FCGTf32, FCEQf32>;
3971def : SETCCBinOpReg<setolt, R32FP, NORr32, FCGTf32, FCEQf32>;
3972
3973def : Pat<(setule R32FP:$rA, R32FP:$rB),
3974 (XORIr32 (FCGTf32 R32FP:$rA, R32FP:$rB), 0xffffffff)>;
3975def : Pat<(setole R32FP:$rA, R32FP:$rB),
3976 (XORIr32 (FCGTf32 R32FP:$rA, R32FP:$rB), 0xffffffff)>;
Scott Michel66377522007-12-04 22:35:58 +00003977
3978// FP Status and Control Register Write
3979// Why isn't rT a don't care in the ISA?
3980// Should we create a special RRForm_3 for this guy and zero out the rT?
3981def FSCRWf32 :
3982 RRForm_1<0b01011101110, (outs R32FP:$rT), (ins R32FP:$rA),
3983 "fscrwr\t$rA", SPrecFP,
3984 [/* This instruction requires an intrinsic. Note: rT is unused. */]>;
3985
3986// FP Status and Control Register Read
3987def FSCRRf32 :
3988 RRForm_2<0b01011101110, (outs R32FP:$rT), (ins),
3989 "fscrrd\t$rT", SPrecFP,
3990 [/* This instruction requires an intrinsic */]>;
3991
3992// llvm instruction space
3993// How do these map onto cell instructions?
3994// fdiv rA rB
3995// frest rC rB # c = 1/b (both lines)
3996// fi rC rB rC
3997// fm rD rA rC # d = a * 1/b
3998// fnms rB rD rB rA # b = - (d * b - a) --should == 0 in a perfect world
3999// fma rB rB rC rD # b = b * c + d
4000// = -(d *b -a) * c + d
4001// = a * c - c ( a *b *c - a)
4002
4003// fcopysign (???)
4004
4005// Library calls:
4006// These llvm instructions will actually map to library calls.
4007// All that's needed, then, is to check that the appropriate library is
4008// imported and do a brsl to the proper function name.
4009// frem # fmod(x, y): x - (x/y) * y
4010// (Note: fmod(double, double), fmodf(float,float)
4011// fsqrt?
4012// fsin?
4013// fcos?
4014// Unimplemented SPU instruction space
4015// floating reciprocal absolute square root estimate (frsqest)
4016
4017// The following are probably just intrinsics
Scott Michelf0569be2008-12-27 04:51:36 +00004018// status and control register write
Scott Michel66377522007-12-04 22:35:58 +00004019// status and control register read
4020
4021//--------------------------------------
4022// Floating point multiply instructions
4023//--------------------------------------
4024
4025def FMv4f32:
4026 RRForm<0b00100011010, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
4027 "fm\t$rT, $rA, $rB", SPrecFP,
4028 [(set (v4f32 VECREG:$rT), (fmul (v4f32 VECREG:$rA),
4029 (v4f32 VECREG:$rB)))]>;
4030
4031def FMf32 :
4032 RRForm<0b01100011010, (outs R32FP:$rT), (ins R32FP:$rA, R32FP:$rB),
4033 "fm\t$rT, $rA, $rB", SPrecFP,
4034 [(set R32FP:$rT, (fmul R32FP:$rA, R32FP:$rB))]>;
4035
4036// Floating point multiply and add
4037// e.g. d = c + (a * b)
4038def FMAv4f32:
4039 RRRForm<0b0111, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB, VECREG:$rC),
4040 "fma\t$rT, $rA, $rB, $rC", SPrecFP,
4041 [(set (v4f32 VECREG:$rT),
4042 (fadd (v4f32 VECREG:$rC),
4043 (fmul (v4f32 VECREG:$rA), (v4f32 VECREG:$rB))))]>;
4044
4045def FMAf32:
4046 RRRForm<0b0111, (outs R32FP:$rT), (ins R32FP:$rA, R32FP:$rB, R32FP:$rC),
4047 "fma\t$rT, $rA, $rB, $rC", SPrecFP,
4048 [(set R32FP:$rT, (fadd R32FP:$rC, (fmul R32FP:$rA, R32FP:$rB)))]>;
4049
4050// FP multiply and subtract
4051// Subtracts value in rC from product
4052// res = a * b - c
4053def FMSv4f32 :
4054 RRRForm<0b0111, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB, VECREG:$rC),
4055 "fms\t$rT, $rA, $rB, $rC", SPrecFP,
4056 [(set (v4f32 VECREG:$rT),
4057 (fsub (fmul (v4f32 VECREG:$rA), (v4f32 VECREG:$rB)),
4058 (v4f32 VECREG:$rC)))]>;
4059
4060def FMSf32 :
4061 RRRForm<0b0111, (outs R32FP:$rT), (ins R32FP:$rA, R32FP:$rB, R32FP:$rC),
4062 "fms\t$rT, $rA, $rB, $rC", SPrecFP,
4063 [(set R32FP:$rT,
4064 (fsub (fmul R32FP:$rA, R32FP:$rB), R32FP:$rC))]>;
4065
4066// Floating Negative Mulitply and Subtract
4067// Subtracts product from value in rC
4068// res = fneg(fms a b c)
4069// = - (a * b - c)
4070// = c - a * b
4071// NOTE: subtraction order
4072// fsub a b = a - b
Scott Michelf0569be2008-12-27 04:51:36 +00004073// fs a b = b - a?
Scott Michel66377522007-12-04 22:35:58 +00004074def FNMSf32 :
4075 RRRForm<0b1101, (outs R32FP:$rT), (ins R32FP:$rA, R32FP:$rB, R32FP:$rC),
4076 "fnms\t$rT, $rA, $rB, $rC", SPrecFP,
4077 [(set R32FP:$rT, (fsub R32FP:$rC, (fmul R32FP:$rA, R32FP:$rB)))]>;
4078
4079def FNMSv4f32 :
4080 RRRForm<0b1101, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB, VECREG:$rC),
4081 "fnms\t$rT, $rA, $rB, $rC", SPrecFP,
Scott Michelf0569be2008-12-27 04:51:36 +00004082 [(set (v4f32 VECREG:$rT),
4083 (fsub (v4f32 VECREG:$rC),
4084 (fmul (v4f32 VECREG:$rA),
Scott Michel66377522007-12-04 22:35:58 +00004085 (v4f32 VECREG:$rB))))]>;
4086
4087//--------------------------------------
4088// Floating Point Conversions
4089// Signed conversions:
4090def CSiFv4f32:
4091 CVTIntFPForm<0b0101101110, (outs VECREG:$rT), (ins VECREG:$rA),
4092 "csflt\t$rT, $rA, 0", SPrecFP,
4093 [(set (v4f32 VECREG:$rT), (sint_to_fp (v4i32 VECREG:$rA)))]>;
4094
Scott Michelf0569be2008-12-27 04:51:36 +00004095// Convert signed integer to floating point
Scott Michel66377522007-12-04 22:35:58 +00004096def CSiFf32 :
4097 CVTIntFPForm<0b0101101110, (outs R32FP:$rT), (ins R32C:$rA),
4098 "csflt\t$rT, $rA, 0", SPrecFP,
4099 [(set R32FP:$rT, (sint_to_fp R32C:$rA))]>;
4100
4101// Convert unsigned into to float
4102def CUiFv4f32 :
4103 CVTIntFPForm<0b1101101110, (outs VECREG:$rT), (ins VECREG:$rA),
4104 "cuflt\t$rT, $rA, 0", SPrecFP,
4105 [(set (v4f32 VECREG:$rT), (uint_to_fp (v4i32 VECREG:$rA)))]>;
4106
4107def CUiFf32 :
4108 CVTIntFPForm<0b1101101110, (outs R32FP:$rT), (ins R32C:$rA),
4109 "cuflt\t$rT, $rA, 0", SPrecFP,
4110 [(set R32FP:$rT, (uint_to_fp R32C:$rA))]>;
4111
Scott Michelf0569be2008-12-27 04:51:36 +00004112// Convert float to unsigned int
Scott Michel66377522007-12-04 22:35:58 +00004113// Assume that scale = 0
4114
4115def CFUiv4f32 :
4116 CVTIntFPForm<0b1101101110, (outs VECREG:$rT), (ins VECREG:$rA),
4117 "cfltu\t$rT, $rA, 0", SPrecFP,
4118 [(set (v4i32 VECREG:$rT), (fp_to_uint (v4f32 VECREG:$rA)))]>;
4119
4120def CFUif32 :
4121 CVTIntFPForm<0b1101101110, (outs R32C:$rT), (ins R32FP:$rA),
4122 "cfltu\t$rT, $rA, 0", SPrecFP,
4123 [(set R32C:$rT, (fp_to_uint R32FP:$rA))]>;
4124
Scott Michelf0569be2008-12-27 04:51:36 +00004125// Convert float to signed int
Scott Michel66377522007-12-04 22:35:58 +00004126// Assume that scale = 0
4127
4128def CFSiv4f32 :
4129 CVTIntFPForm<0b1101101110, (outs VECREG:$rT), (ins VECREG:$rA),
4130 "cflts\t$rT, $rA, 0", SPrecFP,
4131 [(set (v4i32 VECREG:$rT), (fp_to_sint (v4f32 VECREG:$rA)))]>;
4132
4133def CFSif32 :
4134 CVTIntFPForm<0b1101101110, (outs R32C:$rT), (ins R32FP:$rA),
4135 "cflts\t$rT, $rA, 0", SPrecFP,
4136 [(set R32C:$rT, (fp_to_sint R32FP:$rA))]>;
4137
4138//===----------------------------------------------------------------------==//
4139// Single<->Double precision conversions
4140//===----------------------------------------------------------------------==//
4141
4142// NOTE: We use "vec" name suffix here to avoid confusion (e.g. input is a
4143// v4f32, output is v2f64--which goes in the name?)
4144
4145// Floating point extend single to double
4146// NOTE: Not sure if passing in v4f32 to FESDvec is correct since it
4147// operates on two double-word slots (i.e. 1st and 3rd fp numbers
4148// are ignored).
4149def FESDvec :
4150 RRForm_1<0b00011101110, (outs VECREG:$rT), (ins VECREG:$rA),
4151 "fesd\t$rT, $rA", SPrecFP,
Chris Lattnere9eda0f2010-03-19 04:53:47 +00004152 [/*(set (v2f64 VECREG:$rT), (fextend (v4f32 VECREG:$rA)))*/]>;
Scott Michel66377522007-12-04 22:35:58 +00004153
4154def FESDf32 :
4155 RRForm_1<0b00011101110, (outs R64FP:$rT), (ins R32FP:$rA),
4156 "fesd\t$rT, $rA", SPrecFP,
4157 [(set R64FP:$rT, (fextend R32FP:$rA))]>;
4158
4159// Floating point round double to single
4160//def FRDSvec :
4161// RRForm_1<0b10011101110, (outs VECREG:$rT), (ins VECREG:$rA),
4162// "frds\t$rT, $rA,", SPrecFP,
4163// [(set (v4f32 R32FP:$rT), (fround (v2f64 R64FP:$rA)))]>;
4164
4165def FRDSf64 :
4166 RRForm_1<0b10011101110, (outs R32FP:$rT), (ins R64FP:$rA),
4167 "frds\t$rT, $rA", SPrecFP,
4168 [(set R32FP:$rT, (fround R64FP:$rA))]>;
4169
4170//ToDo include anyextend?
4171
4172//===----------------------------------------------------------------------==//
4173// Double precision floating point instructions
4174//===----------------------------------------------------------------------==//
4175def FAf64 :
4176 RRForm<0b00110011010, (outs R64FP:$rT), (ins R64FP:$rA, R64FP:$rB),
4177 "dfa\t$rT, $rA, $rB", DPrecFP,
4178 [(set R64FP:$rT, (fadd R64FP:$rA, R64FP:$rB))]>;
4179
4180def FAv2f64 :
4181 RRForm<0b00110011010, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
4182 "dfa\t$rT, $rA, $rB", DPrecFP,
4183 [(set (v2f64 VECREG:$rT), (fadd (v2f64 VECREG:$rA), (v2f64 VECREG:$rB)))]>;
4184
4185def FSf64 :
4186 RRForm<0b10100011010, (outs R64FP:$rT), (ins R64FP:$rA, R64FP:$rB),
4187 "dfs\t$rT, $rA, $rB", DPrecFP,
4188 [(set R64FP:$rT, (fsub R64FP:$rA, R64FP:$rB))]>;
4189
4190def FSv2f64 :
4191 RRForm<0b10100011010, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
4192 "dfs\t$rT, $rA, $rB", DPrecFP,
4193 [(set (v2f64 VECREG:$rT),
4194 (fsub (v2f64 VECREG:$rA), (v2f64 VECREG:$rB)))]>;
4195
4196def FMf64 :
4197 RRForm<0b01100011010, (outs R64FP:$rT), (ins R64FP:$rA, R64FP:$rB),
4198 "dfm\t$rT, $rA, $rB", DPrecFP,
4199 [(set R64FP:$rT, (fmul R64FP:$rA, R64FP:$rB))]>;
4200
4201def FMv2f64:
4202 RRForm<0b00100011010, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
4203 "dfm\t$rT, $rA, $rB", DPrecFP,
4204 [(set (v2f64 VECREG:$rT),
4205 (fmul (v2f64 VECREG:$rA), (v2f64 VECREG:$rB)))]>;
4206
4207def FMAf64:
4208 RRForm<0b00111010110, (outs R64FP:$rT),
4209 (ins R64FP:$rA, R64FP:$rB, R64FP:$rC),
4210 "dfma\t$rT, $rA, $rB", DPrecFP,
4211 [(set R64FP:$rT, (fadd R64FP:$rC, (fmul R64FP:$rA, R64FP:$rB)))]>,
4212 RegConstraint<"$rC = $rT">,
4213 NoEncode<"$rC">;
4214
4215def FMAv2f64:
4216 RRForm<0b00111010110, (outs VECREG:$rT),
4217 (ins VECREG:$rA, VECREG:$rB, VECREG:$rC),
4218 "dfma\t$rT, $rA, $rB", DPrecFP,
4219 [(set (v2f64 VECREG:$rT),
4220 (fadd (v2f64 VECREG:$rC),
4221 (fmul (v2f64 VECREG:$rA), (v2f64 VECREG:$rB))))]>,
4222 RegConstraint<"$rC = $rT">,
4223 NoEncode<"$rC">;
4224
4225def FMSf64 :
4226 RRForm<0b10111010110, (outs R64FP:$rT),
4227 (ins R64FP:$rA, R64FP:$rB, R64FP:$rC),
4228 "dfms\t$rT, $rA, $rB", DPrecFP,
4229 [(set R64FP:$rT, (fsub (fmul R64FP:$rA, R64FP:$rB), R64FP:$rC))]>,
4230 RegConstraint<"$rC = $rT">,
4231 NoEncode<"$rC">;
4232
4233def FMSv2f64 :
4234 RRForm<0b10111010110, (outs VECREG:$rT),
4235 (ins VECREG:$rA, VECREG:$rB, VECREG:$rC),
4236 "dfms\t$rT, $rA, $rB", DPrecFP,
4237 [(set (v2f64 VECREG:$rT),
4238 (fsub (fmul (v2f64 VECREG:$rA), (v2f64 VECREG:$rB)),
4239 (v2f64 VECREG:$rC)))]>;
4240
Scott Michel7ea02ff2009-03-17 01:15:45 +00004241// DFNMS: - (a * b - c)
Scott Michel66377522007-12-04 22:35:58 +00004242// - (a * b) + c => c - (a * b)
Scott Michel7ea02ff2009-03-17 01:15:45 +00004243
4244class DFNMSInst<dag OOL, dag IOL, list<dag> pattern>:
4245 RRForm<0b01111010110, OOL, IOL, "dfnms\t$rT, $rA, $rB",
4246 DPrecFP, pattern>,
Scott Michel66377522007-12-04 22:35:58 +00004247 RegConstraint<"$rC = $rT">,
4248 NoEncode<"$rC">;
4249
Scott Michel7ea02ff2009-03-17 01:15:45 +00004250class DFNMSVecInst<list<dag> pattern>:
4251 DFNMSInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB, VECREG:$rC),
4252 pattern>;
Scott Michel66377522007-12-04 22:35:58 +00004253
Scott Michel7ea02ff2009-03-17 01:15:45 +00004254class DFNMSRegInst<list<dag> pattern>:
4255 DFNMSInst<(outs R64FP:$rT), (ins R64FP:$rA, R64FP:$rB, R64FP:$rC),
4256 pattern>;
Scott Michel66377522007-12-04 22:35:58 +00004257
Scott Michel7ea02ff2009-03-17 01:15:45 +00004258multiclass DFMultiplySubtract
4259{
4260 def v2f64 : DFNMSVecInst<[(set (v2f64 VECREG:$rT),
4261 (fsub (v2f64 VECREG:$rC),
4262 (fmul (v2f64 VECREG:$rA),
4263 (v2f64 VECREG:$rB))))]>;
4264
4265 def f64 : DFNMSRegInst<[(set R64FP:$rT,
4266 (fsub R64FP:$rC,
4267 (fmul R64FP:$rA, R64FP:$rB)))]>;
4268}
4269
4270defm DFNMS : DFMultiplySubtract;
Scott Michel66377522007-12-04 22:35:58 +00004271
4272// - (a * b + c)
4273// - (a * b) - c
4274def FNMAf64 :
4275 RRForm<0b11111010110, (outs R64FP:$rT),
4276 (ins R64FP:$rA, R64FP:$rB, R64FP:$rC),
4277 "dfnma\t$rT, $rA, $rB", DPrecFP,
4278 [(set R64FP:$rT, (fneg (fadd R64FP:$rC, (fmul R64FP:$rA, R64FP:$rB))))]>,
4279 RegConstraint<"$rC = $rT">,
4280 NoEncode<"$rC">;
4281
4282def FNMAv2f64 :
4283 RRForm<0b11111010110, (outs VECREG:$rT),
4284 (ins VECREG:$rA, VECREG:$rB, VECREG:$rC),
4285 "dfnma\t$rT, $rA, $rB", DPrecFP,
Scott Michelf0569be2008-12-27 04:51:36 +00004286 [(set (v2f64 VECREG:$rT),
4287 (fneg (fadd (v2f64 VECREG:$rC),
4288 (fmul (v2f64 VECREG:$rA),
Scott Michel66377522007-12-04 22:35:58 +00004289 (v2f64 VECREG:$rB)))))]>,
4290 RegConstraint<"$rC = $rT">,
4291 NoEncode<"$rC">;
4292
4293//===----------------------------------------------------------------------==//
4294// Floating point negation and absolute value
4295//===----------------------------------------------------------------------==//
4296
4297def : Pat<(fneg (v4f32 VECREG:$rA)),
Scott Michela82d3f72009-03-17 16:45:16 +00004298 (XORfnegvec (v4f32 VECREG:$rA),
4299 (v4f32 (ILHUv4i32 0x8000)))>;
Scott Michel66377522007-12-04 22:35:58 +00004300
4301def : Pat<(fneg R32FP:$rA),
Scott Michela82d3f72009-03-17 16:45:16 +00004302 (XORfneg32 R32FP:$rA, (ILHUr32 0x8000))>;
Scott Michel66377522007-12-04 22:35:58 +00004303
4304// Floating point absolute value
Scott Michel7ea02ff2009-03-17 01:15:45 +00004305// Note: f64 fabs is custom-selected.
Scott Michel66377522007-12-04 22:35:58 +00004306
4307def : Pat<(fabs R32FP:$rA),
4308 (ANDfabs32 R32FP:$rA, (IOHLr32 (ILHUr32 0x7fff), 0xffff))>;
4309
4310def : Pat<(fabs (v4f32 VECREG:$rA)),
4311 (ANDfabsvec (v4f32 VECREG:$rA),
Scott Michel7ea02ff2009-03-17 01:15:45 +00004312 (IOHLv4i32 (ILHUv4i32 0x7fff), 0xffff))>;
Scott Michelc9c8b2a2009-01-26 03:31:40 +00004313
Scott Michel66377522007-12-04 22:35:58 +00004314//===----------------------------------------------------------------------===//
Scott Michelaedc6372008-12-10 00:15:19 +00004315// Hint for branch instructions:
4316//===----------------------------------------------------------------------===//
4317
4318/* def HBR : SPUInstr<(outs), (ins), "hbr\t" */
4319
4320//===----------------------------------------------------------------------===//
Scott Michel66377522007-12-04 22:35:58 +00004321// Execution, Load NOP (execute NOPs belong in even pipeline, load NOPs belong
4322// in the odd pipeline)
4323//===----------------------------------------------------------------------===//
4324
Scott Michela59d4692008-02-23 18:41:37 +00004325def ENOP : SPUInstr<(outs), (ins), "enop", ExecNOP> {
Scott Michel66377522007-12-04 22:35:58 +00004326 let Pattern = [];
4327
4328 let Inst{0-10} = 0b10000000010;
4329 let Inst{11-17} = 0;
4330 let Inst{18-24} = 0;
4331 let Inst{25-31} = 0;
4332}
4333
Scott Michela59d4692008-02-23 18:41:37 +00004334def LNOP : SPUInstr<(outs), (ins), "lnop", LoadNOP> {
Scott Michel66377522007-12-04 22:35:58 +00004335 let Pattern = [];
4336
4337 let Inst{0-10} = 0b10000000000;
4338 let Inst{11-17} = 0;
4339 let Inst{18-24} = 0;
4340 let Inst{25-31} = 0;
4341}
4342
4343//===----------------------------------------------------------------------===//
4344// Bit conversions (type conversions between vector/packed types)
Scott Michel6e1d1472009-03-16 18:47:25 +00004345// NOTE: Promotions are handled using the XS* instructions.
Scott Michel66377522007-12-04 22:35:58 +00004346//===----------------------------------------------------------------------===//
4347def : Pat<(v16i8 (bitconvert (v8i16 VECREG:$src))), (v16i8 VECREG:$src)>;
4348def : Pat<(v16i8 (bitconvert (v4i32 VECREG:$src))), (v16i8 VECREG:$src)>;
4349def : Pat<(v16i8 (bitconvert (v2i64 VECREG:$src))), (v16i8 VECREG:$src)>;
4350def : Pat<(v16i8 (bitconvert (v4f32 VECREG:$src))), (v16i8 VECREG:$src)>;
4351def : Pat<(v16i8 (bitconvert (v2f64 VECREG:$src))), (v16i8 VECREG:$src)>;
4352
4353def : Pat<(v8i16 (bitconvert (v16i8 VECREG:$src))), (v8i16 VECREG:$src)>;
4354def : Pat<(v8i16 (bitconvert (v4i32 VECREG:$src))), (v8i16 VECREG:$src)>;
4355def : Pat<(v8i16 (bitconvert (v2i64 VECREG:$src))), (v8i16 VECREG:$src)>;
4356def : Pat<(v8i16 (bitconvert (v4f32 VECREG:$src))), (v8i16 VECREG:$src)>;
4357def : Pat<(v8i16 (bitconvert (v2f64 VECREG:$src))), (v8i16 VECREG:$src)>;
4358
4359def : Pat<(v4i32 (bitconvert (v16i8 VECREG:$src))), (v4i32 VECREG:$src)>;
4360def : Pat<(v4i32 (bitconvert (v8i16 VECREG:$src))), (v4i32 VECREG:$src)>;
4361def : Pat<(v4i32 (bitconvert (v2i64 VECREG:$src))), (v4i32 VECREG:$src)>;
4362def : Pat<(v4i32 (bitconvert (v4f32 VECREG:$src))), (v4i32 VECREG:$src)>;
4363def : Pat<(v4i32 (bitconvert (v2f64 VECREG:$src))), (v4i32 VECREG:$src)>;
4364
4365def : Pat<(v2i64 (bitconvert (v16i8 VECREG:$src))), (v2i64 VECREG:$src)>;
4366def : Pat<(v2i64 (bitconvert (v8i16 VECREG:$src))), (v2i64 VECREG:$src)>;
4367def : Pat<(v2i64 (bitconvert (v4i32 VECREG:$src))), (v2i64 VECREG:$src)>;
4368def : Pat<(v2i64 (bitconvert (v4f32 VECREG:$src))), (v2i64 VECREG:$src)>;
4369def : Pat<(v2i64 (bitconvert (v2f64 VECREG:$src))), (v2i64 VECREG:$src)>;
4370
4371def : Pat<(v4f32 (bitconvert (v16i8 VECREG:$src))), (v4f32 VECREG:$src)>;
4372def : Pat<(v4f32 (bitconvert (v8i16 VECREG:$src))), (v4f32 VECREG:$src)>;
4373def : Pat<(v4f32 (bitconvert (v2i64 VECREG:$src))), (v4f32 VECREG:$src)>;
4374def : Pat<(v4f32 (bitconvert (v4i32 VECREG:$src))), (v4f32 VECREG:$src)>;
4375def : Pat<(v4f32 (bitconvert (v2f64 VECREG:$src))), (v4f32 VECREG:$src)>;
4376
4377def : Pat<(v2f64 (bitconvert (v16i8 VECREG:$src))), (v2f64 VECREG:$src)>;
4378def : Pat<(v2f64 (bitconvert (v8i16 VECREG:$src))), (v2f64 VECREG:$src)>;
4379def : Pat<(v2f64 (bitconvert (v4i32 VECREG:$src))), (v2f64 VECREG:$src)>;
4380def : Pat<(v2f64 (bitconvert (v2i64 VECREG:$src))), (v2f64 VECREG:$src)>;
Chris Lattnere82f3362010-03-28 08:36:45 +00004381def : Pat<(v2f64 (bitconvert (v4f32 VECREG:$src))), (v2f64 VECREG:$src)>;
Scott Michel66377522007-12-04 22:35:58 +00004382
Scott Michel6e1d1472009-03-16 18:47:25 +00004383def : Pat<(i128 (bitconvert (v16i8 VECREG:$src))),
4384 (ORi128_vec VECREG:$src)>;
4385def : Pat<(i128 (bitconvert (v8i16 VECREG:$src))),
4386 (ORi128_vec VECREG:$src)>;
4387def : Pat<(i128 (bitconvert (v4i32 VECREG:$src))),
4388 (ORi128_vec VECREG:$src)>;
4389def : Pat<(i128 (bitconvert (v2i64 VECREG:$src))),
4390 (ORi128_vec VECREG:$src)>;
4391def : Pat<(i128 (bitconvert (v4f32 VECREG:$src))),
4392 (ORi128_vec VECREG:$src)>;
4393def : Pat<(i128 (bitconvert (v2f64 VECREG:$src))),
4394 (ORi128_vec VECREG:$src)>;
4395
4396def : Pat<(v16i8 (bitconvert (i128 GPRC:$src))),
4397 (v16i8 (ORvec_i128 GPRC:$src))>;
4398def : Pat<(v8i16 (bitconvert (i128 GPRC:$src))),
4399 (v8i16 (ORvec_i128 GPRC:$src))>;
4400def : Pat<(v4i32 (bitconvert (i128 GPRC:$src))),
4401 (v4i32 (ORvec_i128 GPRC:$src))>;
4402def : Pat<(v2i64 (bitconvert (i128 GPRC:$src))),
4403 (v2i64 (ORvec_i128 GPRC:$src))>;
4404def : Pat<(v4f32 (bitconvert (i128 GPRC:$src))),
4405 (v4f32 (ORvec_i128 GPRC:$src))>;
4406def : Pat<(v2f64 (bitconvert (i128 GPRC:$src))),
4407 (v2f64 (ORvec_i128 GPRC:$src))>;
Scott Michel66377522007-12-04 22:35:58 +00004408
4409//===----------------------------------------------------------------------===//
4410// Instruction patterns:
4411//===----------------------------------------------------------------------===//
4412
4413// General 32-bit constants:
4414def : Pat<(i32 imm:$imm),
4415 (IOHLr32 (ILHUr32 (HI16 imm:$imm)), (LO16 imm:$imm))>;
4416
4417// Single precision float constants:
Nate Begemanccef5802008-02-14 18:43:04 +00004418def : Pat<(f32 fpimm:$imm),
Scott Michel66377522007-12-04 22:35:58 +00004419 (IOHLf32 (ILHUf32 (HI16_f32 fpimm:$imm)), (LO16_f32 fpimm:$imm))>;
4420
4421// General constant 32-bit vectors
4422def : Pat<(v4i32 v4i32Imm:$imm),
Scott Michelad2715e2008-03-05 23:02:02 +00004423 (IOHLv4i32 (v4i32 (ILHUv4i32 (HI16_vec v4i32Imm:$imm))),
4424 (LO16_vec v4i32Imm:$imm))>;
Scott Michelf0569be2008-12-27 04:51:36 +00004425
Scott Michel504c3692007-12-17 22:32:34 +00004426// 8-bit constants
4427def : Pat<(i8 imm:$imm),
4428 (ILHr8 imm:$imm)>;
Scott Michel66377522007-12-04 22:35:58 +00004429
4430//===----------------------------------------------------------------------===//
Scott Michel66377522007-12-04 22:35:58 +00004431// Zero/Any/Sign extensions
4432//===----------------------------------------------------------------------===//
4433
Scott Michel66377522007-12-04 22:35:58 +00004434// sext 8->32: Sign extend bytes to words
4435def : Pat<(sext_inreg R32C:$rSrc, i8),
4436 (XSHWr32 (XSBHr32 R32C:$rSrc))>;
4437
Scott Michel504c3692007-12-17 22:32:34 +00004438def : Pat<(i32 (sext R8C:$rSrc)),
4439 (XSHWr16 (XSBHr8 R8C:$rSrc))>;
4440
Scott Micheldd950092009-01-06 03:36:14 +00004441// sext 8->64: Sign extend bytes to double word
4442def : Pat<(sext_inreg R64C:$rSrc, i8),
4443 (XSWDr64_inreg (XSHWr64 (XSBHr64 R64C:$rSrc)))>;
4444
4445def : Pat<(i64 (sext R8C:$rSrc)),
4446 (XSWDr64 (XSHWr16 (XSBHr8 R8C:$rSrc)))>;
4447
Scott Michel504c3692007-12-17 22:32:34 +00004448// zext 8->16: Zero extend bytes to halfwords
4449def : Pat<(i16 (zext R8C:$rSrc)),
Scott Michela59d4692008-02-23 18:41:37 +00004450 (ANDHIi8i16 R8C:$rSrc, 0xff)>;
Scott Michel504c3692007-12-17 22:32:34 +00004451
Scott Michel504c3692007-12-17 22:32:34 +00004452// zext 8->32: Zero extend bytes to words
4453def : Pat<(i32 (zext R8C:$rSrc)),
Scott Michela59d4692008-02-23 18:41:37 +00004454 (ANDIi8i32 R8C:$rSrc, 0xff)>;
Scott Michel504c3692007-12-17 22:32:34 +00004455
Scott Micheldd950092009-01-06 03:36:14 +00004456// zext 8->64: Zero extend bytes to double words
4457def : Pat<(i64 (zext R8C:$rSrc)),
4458 (ORi64_v2i64 (SELBv4i32 (ROTQMBYv4i32
4459 (ORv4i32_i32 (ANDIi8i32 R8C:$rSrc, 0xff)),
4460 0x4),
4461 (ILv4i32 0x0),
4462 (FSMBIv4i32 0x0f0f)))>;
4463
4464// anyext 8->16: Extend 8->16 bits, irrespective of sign, preserves high bits
Scott Michel504c3692007-12-17 22:32:34 +00004465def : Pat<(i16 (anyext R8C:$rSrc)),
Scott Michela59d4692008-02-23 18:41:37 +00004466 (ORHIi8i16 R8C:$rSrc, 0)>;
Scott Michel504c3692007-12-17 22:32:34 +00004467
Scott Micheldd950092009-01-06 03:36:14 +00004468// anyext 8->32: Extend 8->32 bits, irrespective of sign, preserves high bits
Scott Michel504c3692007-12-17 22:32:34 +00004469def : Pat<(i32 (anyext R8C:$rSrc)),
Scott Michela59d4692008-02-23 18:41:37 +00004470 (ORIi8i32 R8C:$rSrc, 0)>;
Scott Michel504c3692007-12-17 22:32:34 +00004471
Scott Micheldd950092009-01-06 03:36:14 +00004472// sext 16->64: Sign extend halfword to double word
4473def : Pat<(sext_inreg R64C:$rSrc, i16),
4474 (XSWDr64_inreg (XSHWr64 R64C:$rSrc))>;
4475
4476def : Pat<(sext R16C:$rSrc),
4477 (XSWDr64 (XSHWr16 R16C:$rSrc))>;
4478
Scott Michela59d4692008-02-23 18:41:37 +00004479// zext 16->32: Zero extend halfwords to words
Scott Michel66377522007-12-04 22:35:58 +00004480def : Pat<(i32 (zext R16C:$rSrc)),
Scott Michela59d4692008-02-23 18:41:37 +00004481 (ANDi16i32 R16C:$rSrc, (ILAr32 0xffff))>;
Scott Michel66377522007-12-04 22:35:58 +00004482
4483def : Pat<(i32 (zext (and R16C:$rSrc, 0xf))),
Scott Michela59d4692008-02-23 18:41:37 +00004484 (ANDIi16i32 R16C:$rSrc, 0xf)>;
Scott Michel66377522007-12-04 22:35:58 +00004485
4486def : Pat<(i32 (zext (and R16C:$rSrc, 0xff))),
Scott Michela59d4692008-02-23 18:41:37 +00004487 (ANDIi16i32 R16C:$rSrc, 0xff)>;
Scott Michel66377522007-12-04 22:35:58 +00004488
4489def : Pat<(i32 (zext (and R16C:$rSrc, 0xfff))),
Scott Michela59d4692008-02-23 18:41:37 +00004490 (ANDIi16i32 R16C:$rSrc, 0xfff)>;
Scott Michel66377522007-12-04 22:35:58 +00004491
4492// anyext 16->32: Extend 16->32 bits, irrespective of sign
4493def : Pat<(i32 (anyext R16C:$rSrc)),
Scott Michela59d4692008-02-23 18:41:37 +00004494 (ORIi16i32 R16C:$rSrc, 0)>;
Scott Michel66377522007-12-04 22:35:58 +00004495
4496//===----------------------------------------------------------------------===//
Scott Michelf0569be2008-12-27 04:51:36 +00004497// Truncates:
4498// These truncates are for the SPU's supported types (i8, i16, i32). i64 and
4499// above are custom lowered.
4500//===----------------------------------------------------------------------===//
4501
4502def : Pat<(i8 (trunc GPRC:$src)),
4503 (ORi8_v16i8
4504 (SHUFBgprc GPRC:$src, GPRC:$src,
4505 (IOHLv4i32 (ILHUv4i32 0x0f0f), 0x0f0f)))>;
4506
4507def : Pat<(i8 (trunc R64C:$src)),
4508 (ORi8_v16i8
4509 (SHUFBv2i64_m32
4510 (ORv2i64_i64 R64C:$src),
4511 (ORv2i64_i64 R64C:$src),
4512 (IOHLv4i32 (ILHUv4i32 0x0707), 0x0707)))>;
4513
4514def : Pat<(i8 (trunc R32C:$src)),
4515 (ORi8_v16i8
4516 (SHUFBv4i32_m32
4517 (ORv4i32_i32 R32C:$src),
4518 (ORv4i32_i32 R32C:$src),
4519 (IOHLv4i32 (ILHUv4i32 0x0303), 0x0303)))>;
4520
4521def : Pat<(i8 (trunc R16C:$src)),
4522 (ORi8_v16i8
4523 (SHUFBv4i32_m32
4524 (ORv8i16_i16 R16C:$src),
4525 (ORv8i16_i16 R16C:$src),
4526 (IOHLv4i32 (ILHUv4i32 0x0303), 0x0303)))>;
4527
4528def : Pat<(i16 (trunc GPRC:$src)),
4529 (ORi16_v8i16
4530 (SHUFBgprc GPRC:$src, GPRC:$src,
4531 (IOHLv4i32 (ILHUv4i32 0x0e0f), 0x0e0f)))>;
4532
4533def : Pat<(i16 (trunc R64C:$src)),
4534 (ORi16_v8i16
4535 (SHUFBv2i64_m32
4536 (ORv2i64_i64 R64C:$src),
4537 (ORv2i64_i64 R64C:$src),
4538 (IOHLv4i32 (ILHUv4i32 0x0607), 0x0607)))>;
4539
4540def : Pat<(i16 (trunc R32C:$src)),
4541 (ORi16_v8i16
4542 (SHUFBv4i32_m32
4543 (ORv4i32_i32 R32C:$src),
4544 (ORv4i32_i32 R32C:$src),
4545 (IOHLv4i32 (ILHUv4i32 0x0203), 0x0203)))>;
4546
4547def : Pat<(i32 (trunc GPRC:$src)),
4548 (ORi32_v4i32
4549 (SHUFBgprc GPRC:$src, GPRC:$src,
4550 (IOHLv4i32 (ILHUv4i32 0x0c0d), 0x0e0f)))>;
4551
4552def : Pat<(i32 (trunc R64C:$src)),
4553 (ORi32_v4i32
4554 (SHUFBv2i64_m32
4555 (ORv2i64_i64 R64C:$src),
4556 (ORv2i64_i64 R64C:$src),
4557 (IOHLv4i32 (ILHUv4i32 0x0405), 0x0607)))>;
4558
4559//===----------------------------------------------------------------------===//
Scott Michel053c1da2008-01-29 02:16:57 +00004560// Address generation: SPU, like PPC, has to split addresses into high and
Scott Michel66377522007-12-04 22:35:58 +00004561// low parts in order to load them into a register.
4562//===----------------------------------------------------------------------===//
4563
Scott Michel053c1da2008-01-29 02:16:57 +00004564def : Pat<(SPUaform tglobaladdr:$in, 0), (ILAlsa tglobaladdr:$in)>;
4565def : Pat<(SPUaform texternalsym:$in, 0), (ILAlsa texternalsym:$in)>;
4566def : Pat<(SPUaform tjumptable:$in, 0), (ILAlsa tjumptable:$in)>;
4567def : Pat<(SPUaform tconstpool:$in, 0), (ILAlsa tconstpool:$in)>;
4568
4569def : Pat<(SPUindirect (SPUhi tglobaladdr:$in, 0),
4570 (SPUlo tglobaladdr:$in, 0)),
Scott Michel9de5d0d2008-01-11 02:53:15 +00004571 (IOHLlo (ILHUhi tglobaladdr:$in), tglobaladdr:$in)>;
Scott Michel58c58182008-01-17 20:38:41 +00004572
Scott Michel053c1da2008-01-29 02:16:57 +00004573def : Pat<(SPUindirect (SPUhi texternalsym:$in, 0),
4574 (SPUlo texternalsym:$in, 0)),
4575 (IOHLlo (ILHUhi texternalsym:$in), texternalsym:$in)>;
4576
4577def : Pat<(SPUindirect (SPUhi tjumptable:$in, 0),
4578 (SPUlo tjumptable:$in, 0)),
Scott Michel9de5d0d2008-01-11 02:53:15 +00004579 (IOHLlo (ILHUhi tjumptable:$in), tjumptable:$in)>;
Scott Michel58c58182008-01-17 20:38:41 +00004580
Scott Michel053c1da2008-01-29 02:16:57 +00004581def : Pat<(SPUindirect (SPUhi tconstpool:$in, 0),
4582 (SPUlo tconstpool:$in, 0)),
4583 (IOHLlo (ILHUhi tconstpool:$in), tconstpool:$in)>;
4584
4585def : Pat<(add (SPUhi tglobaladdr:$in, 0), (SPUlo tglobaladdr:$in, 0)),
4586 (IOHLlo (ILHUhi tglobaladdr:$in), tglobaladdr:$in)>;
4587
4588def : Pat<(add (SPUhi texternalsym:$in, 0), (SPUlo texternalsym:$in, 0)),
4589 (IOHLlo (ILHUhi texternalsym:$in), texternalsym:$in)>;
4590
4591def : Pat<(add (SPUhi tjumptable:$in, 0), (SPUlo tjumptable:$in, 0)),
4592 (IOHLlo (ILHUhi tjumptable:$in), tjumptable:$in)>;
4593
4594def : Pat<(add (SPUhi tconstpool:$in, 0), (SPUlo tconstpool:$in, 0)),
4595 (IOHLlo (ILHUhi tconstpool:$in), tconstpool:$in)>;
Scott Michel66377522007-12-04 22:35:58 +00004596
Scott Michel6e1d1472009-03-16 18:47:25 +00004597// Intrinsics:
Scott Michel66377522007-12-04 22:35:58 +00004598include "CellSDKIntrinsics.td"
Scott Michel02d711b2008-12-30 23:28:25 +00004599// Various math operator instruction sequences
4600include "SPUMathInstr.td"
Scott Michelf0569be2008-12-27 04:51:36 +00004601// 64-bit "instructions"/support
4602include "SPU64InstrInfo.td"
Scott Micheldd950092009-01-06 03:36:14 +00004603// 128-bit "instructions"/support
4604include "SPU128InstrInfo.td"