blob: 5068f77a85be8b0f58ede1c9b20d304a5dece006 [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,
658 [(set R16C:$rT, (sub R16C:$rA, R16C:$rB))]>;
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,
673 [(set (v4i32 VECREG:$rT), (sub (v4i32 VECREG:$rA), (v4i32 VECREG:$rB)))]>;
674
675def SFr32 : RRForm<0b00000010000, (outs R32C:$rT), (ins R32C:$rA, R32C:$rB),
676 "sf\t$rT, $rA, $rB", IntegerOp,
677 [(set R32C:$rT, (sub R32C:$rA, R32C:$rB))]>;
678
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
1271// N.B.: vnot_conv is one of those special target selection pattern fragments,
1272// in which we expect there to be a bit_convert on the constant. Bear in mind
1273// that llvm translates "not <reg>" to "xor <reg>, -1" (or in this case, a
1274// constant -1 vector.)
Scott Michel66377522007-12-04 22:35:58 +00001275
Scott Michela59d4692008-02-23 18:41:37 +00001276class ANDCInst<dag OOL, dag IOL, list<dag> pattern>:
1277 RRForm<0b10000011010, OOL, IOL, "andc\t$rT, $rA, $rB",
1278 IntegerOp, pattern>;
Scott Michel66377522007-12-04 22:35:58 +00001279
Scott Michel7ea02ff2009-03-17 01:15:45 +00001280class ANDCVecInst<ValueType vectype, PatFrag vnot_frag = vnot>:
Scott Michela59d4692008-02-23 18:41:37 +00001281 ANDCInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
Scott Michel7ea02ff2009-03-17 01:15:45 +00001282 [(set (vectype VECREG:$rT),
1283 (and (vectype VECREG:$rA),
1284 (vnot_frag (vectype VECREG:$rB))))]>;
Scott Michel66377522007-12-04 22:35:58 +00001285
Scott Michela59d4692008-02-23 18:41:37 +00001286class ANDCRegInst<RegisterClass rclass>:
1287 ANDCInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB),
1288 [(set rclass:$rT, (and rclass:$rA, (not rclass:$rB)))]>;
Scott Michel66377522007-12-04 22:35:58 +00001289
Scott Michela59d4692008-02-23 18:41:37 +00001290multiclass AndComplement
1291{
1292 def v16i8: ANDCVecInst<v16i8>;
1293 def v8i16: ANDCVecInst<v8i16>;
1294 def v4i32: ANDCVecInst<v4i32>;
1295 def v2i64: ANDCVecInst<v2i64>;
Scott Michel66377522007-12-04 22:35:58 +00001296
Scott Michela59d4692008-02-23 18:41:37 +00001297 def r128: ANDCRegInst<GPRC>;
1298 def r64: ANDCRegInst<R64C>;
1299 def r32: ANDCRegInst<R32C>;
1300 def r16: ANDCRegInst<R16C>;
1301 def r8: ANDCRegInst<R8C>;
Scott Michel7ea02ff2009-03-17 01:15:45 +00001302
1303 // Sometimes, the xor pattern has a bitcast constant:
1304 def v16i8_conv: ANDCVecInst<v16i8, vnot_conv>;
Scott Michela59d4692008-02-23 18:41:37 +00001305}
Scott Michel504c3692007-12-17 22:32:34 +00001306
Scott Michela59d4692008-02-23 18:41:37 +00001307defm ANDC : AndComplement;
Scott Michel66377522007-12-04 22:35:58 +00001308
Scott Michela59d4692008-02-23 18:41:37 +00001309class ANDBIInst<dag OOL, dag IOL, list<dag> pattern>:
1310 RI10Form<0b01101000, OOL, IOL, "andbi\t$rT, $rA, $val",
Scott Michelaedc6372008-12-10 00:15:19 +00001311 ByteOp, pattern>;
Scott Michel504c3692007-12-17 22:32:34 +00001312
Scott Michela59d4692008-02-23 18:41:37 +00001313multiclass AndByteImm
1314{
1315 def v16i8: ANDBIInst<(outs VECREG:$rT), (ins VECREG:$rA, u10imm:$val),
1316 [(set (v16i8 VECREG:$rT),
1317 (and (v16i8 VECREG:$rA),
1318 (v16i8 v16i8U8Imm:$val)))]>;
Scott Michel66377522007-12-04 22:35:58 +00001319
Scott Michela59d4692008-02-23 18:41:37 +00001320 def r8: ANDBIInst<(outs R8C:$rT), (ins R8C:$rA, u10imm_i8:$val),
1321 [(set R8C:$rT, (and R8C:$rA, immU8:$val))]>;
1322}
Scott Michel504c3692007-12-17 22:32:34 +00001323
Scott Michela59d4692008-02-23 18:41:37 +00001324defm ANDBI : AndByteImm;
Scott Michel66377522007-12-04 22:35:58 +00001325
Scott Michela59d4692008-02-23 18:41:37 +00001326class ANDHIInst<dag OOL, dag IOL, list<dag> pattern> :
1327 RI10Form<0b10101000, OOL, IOL, "andhi\t$rT, $rA, $val",
Scott Michelaedc6372008-12-10 00:15:19 +00001328 ByteOp, pattern>;
Scott Michel66377522007-12-04 22:35:58 +00001329
Scott Michela59d4692008-02-23 18:41:37 +00001330multiclass AndHalfwordImm
1331{
1332 def v8i16: ANDHIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
1333 [(set (v8i16 VECREG:$rT),
1334 (and (v8i16 VECREG:$rA), v8i16SExt10Imm:$val))]>;
Scott Michel66377522007-12-04 22:35:58 +00001335
Scott Michela59d4692008-02-23 18:41:37 +00001336 def r16: ANDHIInst<(outs R16C:$rT), (ins R16C:$rA, u10imm:$val),
1337 [(set R16C:$rT, (and R16C:$rA, i16ImmUns10:$val))]>;
Scott Michel504c3692007-12-17 22:32:34 +00001338
Scott Michela59d4692008-02-23 18:41:37 +00001339 // Zero-extend i8 to i16:
1340 def i8i16: ANDHIInst<(outs R16C:$rT), (ins R8C:$rA, u10imm:$val),
1341 [(set R16C:$rT, (and (zext R8C:$rA), i16ImmUns10:$val))]>;
1342}
Scott Michel66377522007-12-04 22:35:58 +00001343
Scott Michela59d4692008-02-23 18:41:37 +00001344defm ANDHI : AndHalfwordImm;
1345
1346class ANDIInst<dag OOL, dag IOL, list<dag> pattern> :
1347 RI10Form<0b00101000, OOL, IOL, "andi\t$rT, $rA, $val",
1348 IntegerOp, pattern>;
1349
1350multiclass AndWordImm
1351{
1352 def v4i32: ANDIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
1353 [(set (v4i32 VECREG:$rT),
1354 (and (v4i32 VECREG:$rA), v4i32SExt10Imm:$val))]>;
1355
1356 def r32: ANDIInst<(outs R32C:$rT), (ins R32C:$rA, s10imm_i32:$val),
1357 [(set R32C:$rT, (and R32C:$rA, i32ImmSExt10:$val))]>;
1358
1359 // Hacked form of ANDI to zero-extend i8 quantities to i32. See the zext 8->32
1360 // pattern below.
1361 def i8i32: ANDIInst<(outs R32C:$rT), (ins R8C:$rA, s10imm_i32:$val),
1362 [(set R32C:$rT,
1363 (and (zext R8C:$rA), i32ImmSExt10:$val))]>;
1364
1365 // Hacked form of ANDI to zero-extend i16 quantities to i32. See the
1366 // zext 16->32 pattern below.
1367 //
1368 // Note that this pattern is somewhat artificial, since it might match
1369 // something the compiler generates but is unlikely to occur in practice.
1370 def i16i32: ANDIInst<(outs R32C:$rT), (ins R16C:$rA, s10imm_i32:$val),
1371 [(set R32C:$rT,
1372 (and (zext R16C:$rA), i32ImmSExt10:$val))]>;
1373}
1374
1375defm ANDI : AndWordImm;
1376
1377//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
Scott Michel66377522007-12-04 22:35:58 +00001378// Bitwise OR group:
Scott Michela59d4692008-02-23 18:41:37 +00001379//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
1380
Scott Michel66377522007-12-04 22:35:58 +00001381// Bitwise "or" (N.B.: These are also register-register copy instructions...)
Scott Michela59d4692008-02-23 18:41:37 +00001382class ORInst<dag OOL, dag IOL, list<dag> pattern>:
1383 RRForm<0b10000010000, OOL, IOL, "or\t$rT, $rA, $rB",
1384 IntegerOp, pattern>;
Scott Michel66377522007-12-04 22:35:58 +00001385
Scott Michela59d4692008-02-23 18:41:37 +00001386class ORVecInst<ValueType vectype>:
1387 ORInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1388 [(set (vectype VECREG:$rT), (or (vectype VECREG:$rA),
1389 (vectype VECREG:$rB)))]>;
Scott Michel66377522007-12-04 22:35:58 +00001390
Scott Michela59d4692008-02-23 18:41:37 +00001391class ORRegInst<RegisterClass rclass>:
1392 ORInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB),
1393 [(set rclass:$rT, (or rclass:$rA, rclass:$rB))]>;
Scott Michel66377522007-12-04 22:35:58 +00001394
Scott Michelf0569be2008-12-27 04:51:36 +00001395// ORCvtForm: OR conversion form
1396//
1397// This is used to "convert" the preferred slot to its vector equivalent, as
1398// well as convert a vector back to its preferred slot.
1399//
1400// These are effectively no-ops, but need to exist for proper type conversion
1401// and type coercion.
1402
Scott Micheld1e8d9c2009-01-21 04:58:48 +00001403class ORCvtForm<dag OOL, dag IOL, list<dag> pattern = [/* no pattern */]>
Scott Michelf0569be2008-12-27 04:51:36 +00001404 : SPUInstr<OOL, IOL, "or\t$rT, $rA, $rA", IntegerOp> {
1405 bits<7> RA;
1406 bits<7> RT;
1407
Scott Micheld1e8d9c2009-01-21 04:58:48 +00001408 let Pattern = pattern;
Scott Michelf0569be2008-12-27 04:51:36 +00001409
1410 let Inst{0-10} = 0b10000010000;
1411 let Inst{11-17} = RA;
1412 let Inst{18-24} = RA;
1413 let Inst{25-31} = RT;
1414}
1415
Scott Michela59d4692008-02-23 18:41:37 +00001416class ORPromoteScalar<RegisterClass rclass>:
Scott Michelf0569be2008-12-27 04:51:36 +00001417 ORCvtForm<(outs VECREG:$rT), (ins rclass:$rA)>;
Scott Michel66377522007-12-04 22:35:58 +00001418
Scott Michela59d4692008-02-23 18:41:37 +00001419class ORExtractElt<RegisterClass rclass>:
Scott Michelf0569be2008-12-27 04:51:36 +00001420 ORCvtForm<(outs rclass:$rT), (ins VECREG:$rA)>;
1421
Scott Micheld1e8d9c2009-01-21 04:58:48 +00001422/* class ORCvtRegGPRC<RegisterClass rclass>:
1423 ORCvtForm<(outs GPRC:$rT), (ins rclass:$rA)>; */
Scott Michelf0569be2008-12-27 04:51:36 +00001424
Scott Micheld1e8d9c2009-01-21 04:58:48 +00001425/* class ORCvtGPRCReg<RegisterClass rclass>:
1426 ORCvtForm<(outs rclass:$rT), (ins GPRC:$rA)>; */
Scott Micheldd950092009-01-06 03:36:14 +00001427
Scott Micheld1e8d9c2009-01-21 04:58:48 +00001428class ORCvtFormR32Reg<RegisterClass rclass, list<dag> pattern = [ ]>:
1429 ORCvtForm<(outs rclass:$rT), (ins R32C:$rA), pattern>;
Scott Micheldd950092009-01-06 03:36:14 +00001430
Scott Micheld1e8d9c2009-01-21 04:58:48 +00001431class ORCvtFormRegR32<RegisterClass rclass, list<dag> pattern = [ ]>:
1432 ORCvtForm<(outs R32C:$rT), (ins rclass:$rA), pattern>;
Scott Micheldd950092009-01-06 03:36:14 +00001433
Scott Micheld1e8d9c2009-01-21 04:58:48 +00001434class ORCvtFormR64Reg<RegisterClass rclass, list<dag> pattern = [ ]>:
1435 ORCvtForm<(outs rclass:$rT), (ins R64C:$rA), pattern>;
Scott Micheldd950092009-01-06 03:36:14 +00001436
Scott Micheld1e8d9c2009-01-21 04:58:48 +00001437class ORCvtFormRegR64<RegisterClass rclass, list<dag> pattern = [ ]>:
1438 ORCvtForm<(outs R64C:$rT), (ins rclass:$rA), pattern>;
Scott Michelf0569be2008-12-27 04:51:36 +00001439
Scott Michel6e1d1472009-03-16 18:47:25 +00001440class ORCvtGPRCVec:
1441 ORCvtForm<(outs VECREG:$rT), (ins GPRC:$rA)>;
1442
1443class ORCvtVecGPRC:
1444 ORCvtForm<(outs GPRC:$rT), (ins VECREG:$rA)>;
Scott Michel66377522007-12-04 22:35:58 +00001445
Scott Michela59d4692008-02-23 18:41:37 +00001446multiclass BitwiseOr
1447{
1448 def v16i8: ORVecInst<v16i8>;
1449 def v8i16: ORVecInst<v8i16>;
1450 def v4i32: ORVecInst<v4i32>;
1451 def v2i64: ORVecInst<v2i64>;
Scott Michel66377522007-12-04 22:35:58 +00001452
Scott Michela59d4692008-02-23 18:41:37 +00001453 def v4f32: ORInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1454 [(set (v4f32 VECREG:$rT),
1455 (v4f32 (bitconvert (or (v4i32 VECREG:$rA),
1456 (v4i32 VECREG:$rB)))))]>;
Scott Michel66377522007-12-04 22:35:58 +00001457
Scott Michela59d4692008-02-23 18:41:37 +00001458 def v2f64: ORInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
Scott Michelf0569be2008-12-27 04:51:36 +00001459 [(set (v2f64 VECREG:$rT),
Scott Michela59d4692008-02-23 18:41:37 +00001460 (v2f64 (bitconvert (or (v2i64 VECREG:$rA),
1461 (v2i64 VECREG:$rB)))))]>;
Scott Michel66377522007-12-04 22:35:58 +00001462
Scott Micheld1e8d9c2009-01-21 04:58:48 +00001463 def r128: ORRegInst<GPRC>;
1464 def r64: ORRegInst<R64C>;
1465 def r32: ORRegInst<R32C>;
1466 def r16: ORRegInst<R16C>;
1467 def r8: ORRegInst<R8C>;
Scott Michel66377522007-12-04 22:35:58 +00001468
Scott Michela59d4692008-02-23 18:41:37 +00001469 // OR instructions used to copy f32 and f64 registers.
1470 def f32: ORInst<(outs R32FP:$rT), (ins R32FP:$rA, R32FP:$rB),
1471 [/* no pattern */]>;
Scott Michel504c3692007-12-17 22:32:34 +00001472
Scott Michela59d4692008-02-23 18:41:37 +00001473 def f64: ORInst<(outs R64FP:$rT), (ins R64FP:$rA, R64FP:$rB),
1474 [/* no pattern */]>;
Scott Michel86c041f2007-12-20 00:44:13 +00001475
Scott Michel02d711b2008-12-30 23:28:25 +00001476 // scalar->vector promotion, prefslot2vec:
Scott Michela59d4692008-02-23 18:41:37 +00001477 def v16i8_i8: ORPromoteScalar<R8C>;
1478 def v8i16_i16: ORPromoteScalar<R16C>;
1479 def v4i32_i32: ORPromoteScalar<R32C>;
1480 def v2i64_i64: ORPromoteScalar<R64C>;
1481 def v4f32_f32: ORPromoteScalar<R32FP>;
1482 def v2f64_f64: ORPromoteScalar<R64FP>;
Scott Michel86c041f2007-12-20 00:44:13 +00001483
Scott Michel02d711b2008-12-30 23:28:25 +00001484 // vector->scalar demotion, vec2prefslot:
Scott Michela59d4692008-02-23 18:41:37 +00001485 def i8_v16i8: ORExtractElt<R8C>;
1486 def i16_v8i16: ORExtractElt<R16C>;
1487 def i32_v4i32: ORExtractElt<R32C>;
1488 def i64_v2i64: ORExtractElt<R64C>;
1489 def f32_v4f32: ORExtractElt<R32FP>;
1490 def f64_v2f64: ORExtractElt<R64FP>;
Scott Michelf0569be2008-12-27 04:51:36 +00001491
Scott Michel6e1d1472009-03-16 18:47:25 +00001492 // Conversion from vector to GPRC
1493 def i128_vec: ORCvtVecGPRC;
1494
1495 // Conversion from GPRC to vector
1496 def vec_i128: ORCvtGPRCVec;
1497
Scott Micheld1e8d9c2009-01-21 04:58:48 +00001498/*
Scott Michel6e1d1472009-03-16 18:47:25 +00001499 // Conversion from register to GPRC
Scott Michelf0569be2008-12-27 04:51:36 +00001500 def i128_r64: ORCvtRegGPRC<R64C>;
1501 def i128_f64: ORCvtRegGPRC<R64FP>;
1502 def i128_r32: ORCvtRegGPRC<R32C>;
1503 def i128_f32: ORCvtRegGPRC<R32FP>;
1504 def i128_r16: ORCvtRegGPRC<R16C>;
1505 def i128_r8: ORCvtRegGPRC<R8C>;
1506
Scott Michel6e1d1472009-03-16 18:47:25 +00001507 // Conversion from GPRC to register
Scott Michelf0569be2008-12-27 04:51:36 +00001508 def r64_i128: ORCvtGPRCReg<R64C>;
1509 def f64_i128: ORCvtGPRCReg<R64FP>;
1510 def r32_i128: ORCvtGPRCReg<R32C>;
1511 def f32_i128: ORCvtGPRCReg<R32FP>;
1512 def r16_i128: ORCvtGPRCReg<R16C>;
1513 def r8_i128: ORCvtGPRCReg<R8C>;
Scott Micheld1e8d9c2009-01-21 04:58:48 +00001514*/
1515/*
Scott Micheldd950092009-01-06 03:36:14 +00001516 // Conversion from register to R32C:
Scott Michel6e1d1472009-03-16 18:47:25 +00001517 def r32_r16: ORCvtFormRegR32<R16C>;
1518 def r32_r8: ORCvtFormRegR32<R8C>;
Scott Micheldd950092009-01-06 03:36:14 +00001519
1520 // Conversion from R32C to register
1521 def r32_r16: ORCvtFormR32Reg<R16C>;
1522 def r32_r8: ORCvtFormR32Reg<R8C>;
Scott Micheld1e8d9c2009-01-21 04:58:48 +00001523*/
Scott Michelc9c8b2a2009-01-26 03:31:40 +00001524
Scott Michel6e1d1472009-03-16 18:47:25 +00001525 // Conversion from R64C to register:
Scott Michelc9c8b2a2009-01-26 03:31:40 +00001526 def r32_r64: ORCvtFormR64Reg<R32C>;
1527 // def r16_r64: ORCvtFormR64Reg<R16C>;
1528 // def r8_r64: ORCvtFormR64Reg<R8C>;
1529
Scott Michel6e1d1472009-03-16 18:47:25 +00001530 // Conversion to R64C from register:
Scott Michelc9c8b2a2009-01-26 03:31:40 +00001531 def r64_r32: ORCvtFormRegR64<R32C>;
1532 // def r64_r16: ORCvtFormRegR64<R16C>;
1533 // def r64_r8: ORCvtFormRegR64<R8C>;
Scott Micheld1e8d9c2009-01-21 04:58:48 +00001534
1535 // bitconvert patterns:
1536 def r32_f32: ORCvtFormR32Reg<R32FP,
1537 [(set R32FP:$rT, (bitconvert R32C:$rA))]>;
1538 def f32_r32: ORCvtFormRegR32<R32FP,
1539 [(set R32C:$rT, (bitconvert R32FP:$rA))]>;
1540
1541 def r64_f64: ORCvtFormR64Reg<R64FP,
1542 [(set R64FP:$rT, (bitconvert R64C:$rA))]>;
1543 def f64_r64: ORCvtFormRegR64<R64FP,
1544 [(set R64C:$rT, (bitconvert R64FP:$rA))]>;
Scott Michela59d4692008-02-23 18:41:37 +00001545}
Scott Michel504c3692007-12-17 22:32:34 +00001546
Scott Michela59d4692008-02-23 18:41:37 +00001547defm OR : BitwiseOr;
1548
Scott Michelf0569be2008-12-27 04:51:36 +00001549// scalar->vector promotion patterns (preferred slot to vector):
1550def : Pat<(v16i8 (SPUprefslot2vec R8C:$rA)),
1551 (ORv16i8_i8 R8C:$rA)>;
Scott Michel504c3692007-12-17 22:32:34 +00001552
Scott Michelf0569be2008-12-27 04:51:36 +00001553def : Pat<(v8i16 (SPUprefslot2vec R16C:$rA)),
1554 (ORv8i16_i16 R16C:$rA)>;
Scott Michel66377522007-12-04 22:35:58 +00001555
Scott Michelf0569be2008-12-27 04:51:36 +00001556def : Pat<(v4i32 (SPUprefslot2vec R32C:$rA)),
1557 (ORv4i32_i32 R32C:$rA)>;
Scott Michel66377522007-12-04 22:35:58 +00001558
Scott Michelf0569be2008-12-27 04:51:36 +00001559def : Pat<(v2i64 (SPUprefslot2vec R64C:$rA)),
1560 (ORv2i64_i64 R64C:$rA)>;
Scott Michel66377522007-12-04 22:35:58 +00001561
Scott Michelf0569be2008-12-27 04:51:36 +00001562def : Pat<(v4f32 (SPUprefslot2vec R32FP:$rA)),
1563 (ORv4f32_f32 R32FP:$rA)>;
Scott Michel66377522007-12-04 22:35:58 +00001564
Scott Michelf0569be2008-12-27 04:51:36 +00001565def : Pat<(v2f64 (SPUprefslot2vec R64FP:$rA)),
1566 (ORv2f64_f64 R64FP:$rA)>;
Scott Michel66377522007-12-04 22:35:58 +00001567
Scott Michelf0569be2008-12-27 04:51:36 +00001568// ORi*_v*: Used to extract vector element 0 (the preferred slot), otherwise
1569// known as converting the vector back to its preferred slot
Scott Michel504c3692007-12-17 22:32:34 +00001570
Scott Michel104de432008-11-24 17:11:17 +00001571def : Pat<(SPUvec2prefslot (v16i8 VECREG:$rA)),
Scott Michelf0569be2008-12-27 04:51:36 +00001572 (ORi8_v16i8 VECREG:$rA)>;
Scott Michel504c3692007-12-17 22:32:34 +00001573
Scott Michel104de432008-11-24 17:11:17 +00001574def : Pat<(SPUvec2prefslot (v8i16 VECREG:$rA)),
Scott Michelf0569be2008-12-27 04:51:36 +00001575 (ORi16_v8i16 VECREG:$rA)>;
Scott Michel66377522007-12-04 22:35:58 +00001576
Scott Michel104de432008-11-24 17:11:17 +00001577def : Pat<(SPUvec2prefslot (v4i32 VECREG:$rA)),
Scott Michelf0569be2008-12-27 04:51:36 +00001578 (ORi32_v4i32 VECREG:$rA)>;
Scott Michel66377522007-12-04 22:35:58 +00001579
Scott Michel104de432008-11-24 17:11:17 +00001580def : Pat<(SPUvec2prefslot (v2i64 VECREG:$rA)),
Scott Michelf0569be2008-12-27 04:51:36 +00001581 (ORi64_v2i64 VECREG:$rA)>;
Scott Michel66377522007-12-04 22:35:58 +00001582
Scott Michel104de432008-11-24 17:11:17 +00001583def : Pat<(SPUvec2prefslot (v4f32 VECREG:$rA)),
Scott Michelf0569be2008-12-27 04:51:36 +00001584 (ORf32_v4f32 VECREG:$rA)>;
Scott Michel66377522007-12-04 22:35:58 +00001585
Scott Michel104de432008-11-24 17:11:17 +00001586def : Pat<(SPUvec2prefslot (v2f64 VECREG:$rA)),
Scott Michelf0569be2008-12-27 04:51:36 +00001587 (ORf64_v2f64 VECREG:$rA)>;
1588
1589// Load Register: This is an assembler alias for a bitwise OR of a register
1590// against itself. It's here because it brings some clarity to assembly
1591// language output.
1592
1593let hasCtrlDep = 1 in {
1594 class LRInst<dag OOL, dag IOL>
1595 : SPUInstr<OOL, IOL, "lr\t$rT, $rA", IntegerOp> {
1596 bits<7> RA;
1597 bits<7> RT;
1598
1599 let Pattern = [/*no pattern*/];
1600
1601 let Inst{0-10} = 0b10000010000; /* It's an OR operation */
1602 let Inst{11-17} = RA;
1603 let Inst{18-24} = RA;
1604 let Inst{25-31} = RT;
1605 }
1606
1607 class LRVecInst<ValueType vectype>:
1608 LRInst<(outs VECREG:$rT), (ins VECREG:$rA)>;
1609
1610 class LRRegInst<RegisterClass rclass>:
1611 LRInst<(outs rclass:$rT), (ins rclass:$rA)>;
1612
1613 multiclass LoadRegister {
1614 def v2i64: LRVecInst<v2i64>;
1615 def v2f64: LRVecInst<v2f64>;
1616 def v4i32: LRVecInst<v4i32>;
1617 def v4f32: LRVecInst<v4f32>;
1618 def v8i16: LRVecInst<v8i16>;
1619 def v16i8: LRVecInst<v16i8>;
1620
1621 def r128: LRRegInst<GPRC>;
1622 def r64: LRRegInst<R64C>;
1623 def f64: LRRegInst<R64FP>;
1624 def r32: LRRegInst<R32C>;
1625 def f32: LRRegInst<R32FP>;
1626 def r16: LRRegInst<R16C>;
1627 def r8: LRRegInst<R8C>;
1628 }
1629
1630 defm LR: LoadRegister;
1631}
Scott Michel66377522007-12-04 22:35:58 +00001632
Scott Michela59d4692008-02-23 18:41:37 +00001633// ORC: Bitwise "or" with complement (c = a | ~b)
Scott Michel66377522007-12-04 22:35:58 +00001634
Scott Michela59d4692008-02-23 18:41:37 +00001635class ORCInst<dag OOL, dag IOL, list<dag> pattern>:
1636 RRForm<0b10010010000, OOL, IOL, "orc\t$rT, $rA, $rB",
1637 IntegerOp, pattern>;
Scott Michel66377522007-12-04 22:35:58 +00001638
Scott Michela59d4692008-02-23 18:41:37 +00001639class ORCVecInst<ValueType vectype>:
1640 ORCInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1641 [(set (vectype VECREG:$rT), (or (vectype VECREG:$rA),
1642 (vnot (vectype VECREG:$rB))))]>;
Scott Michel66377522007-12-04 22:35:58 +00001643
Scott Michela59d4692008-02-23 18:41:37 +00001644class ORCRegInst<RegisterClass rclass>:
1645 ORCInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB),
1646 [(set rclass:$rT, (or rclass:$rA, (not rclass:$rB)))]>;
Scott Michel66377522007-12-04 22:35:58 +00001647
Scott Michela59d4692008-02-23 18:41:37 +00001648multiclass BitwiseOrComplement
1649{
1650 def v16i8: ORCVecInst<v16i8>;
1651 def v8i16: ORCVecInst<v8i16>;
1652 def v4i32: ORCVecInst<v4i32>;
1653 def v2i64: ORCVecInst<v2i64>;
Scott Michel66377522007-12-04 22:35:58 +00001654
Scott Michel6e1d1472009-03-16 18:47:25 +00001655 def r128: ORCRegInst<GPRC>;
Scott Michela59d4692008-02-23 18:41:37 +00001656 def r64: ORCRegInst<R64C>;
1657 def r32: ORCRegInst<R32C>;
1658 def r16: ORCRegInst<R16C>;
1659 def r8: ORCRegInst<R8C>;
1660}
1661
1662defm ORC : BitwiseOrComplement;
Scott Michel504c3692007-12-17 22:32:34 +00001663
Scott Michel66377522007-12-04 22:35:58 +00001664// OR byte immediate
Scott Michela59d4692008-02-23 18:41:37 +00001665class ORBIInst<dag OOL, dag IOL, list<dag> pattern>:
1666 RI10Form<0b01100000, OOL, IOL, "orbi\t$rT, $rA, $val",
1667 IntegerOp, pattern>;
Scott Michel66377522007-12-04 22:35:58 +00001668
Scott Michela59d4692008-02-23 18:41:37 +00001669class ORBIVecInst<ValueType vectype, PatLeaf immpred>:
1670 ORBIInst<(outs VECREG:$rT), (ins VECREG:$rA, u10imm:$val),
1671 [(set (v16i8 VECREG:$rT), (or (vectype VECREG:$rA),
1672 (vectype immpred:$val)))]>;
1673
1674multiclass BitwiseOrByteImm
1675{
1676 def v16i8: ORBIVecInst<v16i8, v16i8U8Imm>;
1677
1678 def r8: ORBIInst<(outs R8C:$rT), (ins R8C:$rA, u10imm_i8:$val),
1679 [(set R8C:$rT, (or R8C:$rA, immU8:$val))]>;
1680}
1681
1682defm ORBI : BitwiseOrByteImm;
Scott Michel504c3692007-12-17 22:32:34 +00001683
Scott Michel66377522007-12-04 22:35:58 +00001684// OR halfword immediate
Scott Michela59d4692008-02-23 18:41:37 +00001685class ORHIInst<dag OOL, dag IOL, list<dag> pattern>:
1686 RI10Form<0b10100000, OOL, IOL, "orhi\t$rT, $rA, $val",
1687 IntegerOp, pattern>;
Scott Michel66377522007-12-04 22:35:58 +00001688
Scott Michela59d4692008-02-23 18:41:37 +00001689class ORHIVecInst<ValueType vectype, PatLeaf immpred>:
1690 ORHIInst<(outs VECREG:$rT), (ins VECREG:$rA, u10imm:$val),
1691 [(set (vectype VECREG:$rT), (or (vectype VECREG:$rA),
1692 immpred:$val))]>;
Scott Michel504c3692007-12-17 22:32:34 +00001693
Scott Michela59d4692008-02-23 18:41:37 +00001694multiclass BitwiseOrHalfwordImm
1695{
1696 def v8i16: ORHIVecInst<v8i16, v8i16Uns10Imm>;
1697
1698 def r16: ORHIInst<(outs R16C:$rT), (ins R16C:$rA, u10imm:$val),
1699 [(set R16C:$rT, (or R16C:$rA, i16ImmUns10:$val))]>;
1700
1701 // Specialized ORHI form used to promote 8-bit registers to 16-bit
1702 def i8i16: ORHIInst<(outs R16C:$rT), (ins R8C:$rA, s10imm:$val),
1703 [(set R16C:$rT, (or (anyext R8C:$rA),
1704 i16ImmSExt10:$val))]>;
1705}
1706
1707defm ORHI : BitwiseOrHalfwordImm;
1708
1709class ORIInst<dag OOL, dag IOL, list<dag> pattern>:
1710 RI10Form<0b00100000, OOL, IOL, "ori\t$rT, $rA, $val",
1711 IntegerOp, pattern>;
1712
1713class ORIVecInst<ValueType vectype, PatLeaf immpred>:
1714 ORIInst<(outs VECREG:$rT), (ins VECREG:$rA, u10imm:$val),
1715 [(set (vectype VECREG:$rT), (or (vectype VECREG:$rA),
1716 immpred:$val))]>;
Scott Michel66377522007-12-04 22:35:58 +00001717
1718// Bitwise "or" with immediate
Scott Michela59d4692008-02-23 18:41:37 +00001719multiclass BitwiseOrImm
1720{
1721 def v4i32: ORIVecInst<v4i32, v4i32Uns10Imm>;
Scott Michel66377522007-12-04 22:35:58 +00001722
Scott Michela59d4692008-02-23 18:41:37 +00001723 def r32: ORIInst<(outs R32C:$rT), (ins R32C:$rA, u10imm_i32:$val),
1724 [(set R32C:$rT, (or R32C:$rA, i32ImmUns10:$val))]>;
Scott Michel66377522007-12-04 22:35:58 +00001725
Scott Michela59d4692008-02-23 18:41:37 +00001726 // i16i32: hacked version of the ori instruction to extend 16-bit quantities
1727 // to 32-bit quantities. used exclusively to match "anyext" conversions (vide
1728 // infra "anyext 16->32" pattern.)
1729 def i16i32: ORIInst<(outs R32C:$rT), (ins R16C:$rA, s10imm_i32:$val),
1730 [(set R32C:$rT, (or (anyext R16C:$rA),
1731 i32ImmSExt10:$val))]>;
Scott Michel66377522007-12-04 22:35:58 +00001732
Scott Michela59d4692008-02-23 18:41:37 +00001733 // i8i32: Hacked version of the ORI instruction to extend 16-bit quantities
1734 // to 32-bit quantities. Used exclusively to match "anyext" conversions (vide
1735 // infra "anyext 16->32" pattern.)
1736 def i8i32: ORIInst<(outs R32C:$rT), (ins R8C:$rA, s10imm_i32:$val),
1737 [(set R32C:$rT, (or (anyext R8C:$rA),
1738 i32ImmSExt10:$val))]>;
1739}
Scott Michel66377522007-12-04 22:35:58 +00001740
Scott Michela59d4692008-02-23 18:41:37 +00001741defm ORI : BitwiseOrImm;
Scott Michel504c3692007-12-17 22:32:34 +00001742
Scott Michel66377522007-12-04 22:35:58 +00001743// ORX: "or" across the vector: or's $rA's word slots leaving the result in
1744// $rT[0], slots 1-3 are zeroed.
1745//
Scott Michel504c3692007-12-17 22:32:34 +00001746// FIXME: Needs to match an intrinsic pattern.
Scott Michel66377522007-12-04 22:35:58 +00001747def ORXv4i32:
1748 RRForm<0b10010010000, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1749 "orx\t$rT, $rA, $rB", IntegerOp,
1750 []>;
1751
Scott Michel504c3692007-12-17 22:32:34 +00001752// XOR:
Scott Michel66377522007-12-04 22:35:58 +00001753
Scott Michelad2715e2008-03-05 23:02:02 +00001754class XORInst<dag OOL, dag IOL, list<dag> pattern> :
1755 RRForm<0b10010010000, OOL, IOL, "xor\t$rT, $rA, $rB",
1756 IntegerOp, pattern>;
Scott Michel66377522007-12-04 22:35:58 +00001757
Scott Michelad2715e2008-03-05 23:02:02 +00001758class XORVecInst<ValueType vectype>:
1759 XORInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1760 [(set (vectype VECREG:$rT), (xor (vectype VECREG:$rA),
1761 (vectype VECREG:$rB)))]>;
Scott Michel66377522007-12-04 22:35:58 +00001762
Scott Michelad2715e2008-03-05 23:02:02 +00001763class XORRegInst<RegisterClass rclass>:
1764 XORInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB),
1765 [(set rclass:$rT, (xor rclass:$rA, rclass:$rB))]>;
1766
1767multiclass BitwiseExclusiveOr
1768{
1769 def v16i8: XORVecInst<v16i8>;
1770 def v8i16: XORVecInst<v8i16>;
1771 def v4i32: XORVecInst<v4i32>;
1772 def v2i64: XORVecInst<v2i64>;
1773
1774 def r128: XORRegInst<GPRC>;
1775 def r64: XORRegInst<R64C>;
1776 def r32: XORRegInst<R32C>;
1777 def r16: XORRegInst<R16C>;
1778 def r8: XORRegInst<R8C>;
Scott Michela82d3f72009-03-17 16:45:16 +00001779
1780 // XOR instructions used to negate f32 and f64 quantities.
1781
1782 def fneg32: XORInst<(outs R32FP:$rT), (ins R32FP:$rA, R32C:$rB),
1783 [/* no pattern */]>;
1784
1785 def fneg64: XORInst<(outs R64FP:$rT), (ins R64FP:$rA, R64C:$rB),
1786 [/* no pattern */]>;
1787
1788 def fnegvec: XORInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1789 [/* no pattern, see fneg{32,64} */]>;
Scott Michelad2715e2008-03-05 23:02:02 +00001790}
1791
1792defm XOR : BitwiseExclusiveOr;
Scott Michel66377522007-12-04 22:35:58 +00001793
1794//==----------------------------------------------------------
Scott Michel504c3692007-12-17 22:32:34 +00001795
Scott Michela59d4692008-02-23 18:41:37 +00001796class XORBIInst<dag OOL, dag IOL, list<dag> pattern>:
1797 RI10Form<0b01100000, OOL, IOL, "xorbi\t$rT, $rA, $val",
1798 IntegerOp, pattern>;
Scott Michel66377522007-12-04 22:35:58 +00001799
Scott Michela59d4692008-02-23 18:41:37 +00001800multiclass XorByteImm
1801{
1802 def v16i8:
1803 XORBIInst<(outs VECREG:$rT), (ins VECREG:$rA, u10imm:$val),
1804 [(set (v16i8 VECREG:$rT), (xor (v16i8 VECREG:$rA), v16i8U8Imm:$val))]>;
1805
1806 def r8:
1807 XORBIInst<(outs R8C:$rT), (ins R8C:$rA, u10imm_i8:$val),
1808 [(set R8C:$rT, (xor R8C:$rA, immU8:$val))]>;
1809}
1810
1811defm XORBI : XorByteImm;
Scott Michel504c3692007-12-17 22:32:34 +00001812
Scott Michel66377522007-12-04 22:35:58 +00001813def XORHIv8i16:
Scott Michela59d4692008-02-23 18:41:37 +00001814 RI10Form<0b10100000, (outs VECREG:$rT), (ins VECREG:$rA, u10imm:$val),
Scott Michel66377522007-12-04 22:35:58 +00001815 "xorhi\t$rT, $rA, $val", IntegerOp,
1816 [(set (v8i16 VECREG:$rT), (xor (v8i16 VECREG:$rA),
1817 v8i16SExt10Imm:$val))]>;
1818
1819def XORHIr16:
1820 RI10Form<0b10100000, (outs R16C:$rT), (ins R16C:$rA, s10imm:$val),
1821 "xorhi\t$rT, $rA, $val", IntegerOp,
1822 [(set R16C:$rT, (xor R16C:$rA, i16ImmSExt10:$val))]>;
1823
1824def XORIv4i32:
Scott Michel78c47fa2008-03-10 16:58:52 +00001825 RI10Form<0b00100000, (outs VECREG:$rT), (ins VECREG:$rA, s10imm_i32:$val),
Scott Michel66377522007-12-04 22:35:58 +00001826 "xori\t$rT, $rA, $val", IntegerOp,
1827 [(set (v4i32 VECREG:$rT), (xor (v4i32 VECREG:$rA),
1828 v4i32SExt10Imm:$val))]>;
1829
1830def XORIr32:
1831 RI10Form<0b00100000, (outs R32C:$rT), (ins R32C:$rA, s10imm_i32:$val),
1832 "xori\t$rT, $rA, $val", IntegerOp,
1833 [(set R32C:$rT, (xor R32C:$rA, i32ImmSExt10:$val))]>;
1834
1835// NAND:
Scott Michel66377522007-12-04 22:35:58 +00001836
Scott Michel6e1d1472009-03-16 18:47:25 +00001837class NANDInst<dag OOL, dag IOL, list<dag> pattern>:
1838 RRForm<0b10010011000, OOL, IOL, "nand\t$rT, $rA, $rB",
1839 IntegerOp, pattern>;
Scott Michel66377522007-12-04 22:35:58 +00001840
Scott Michel6e1d1472009-03-16 18:47:25 +00001841class NANDVecInst<ValueType vectype>:
1842 NANDInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1843 [(set (vectype VECREG:$rT), (vnot (and (vectype VECREG:$rA),
1844 (vectype VECREG:$rB))))]>;
1845class NANDRegInst<RegisterClass rclass>:
1846 NANDInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB),
1847 [(set rclass:$rT, (not (and rclass:$rA, rclass:$rB)))]>;
Scott Michel66377522007-12-04 22:35:58 +00001848
Scott Michel6e1d1472009-03-16 18:47:25 +00001849multiclass BitwiseNand
1850{
1851 def v16i8: NANDVecInst<v16i8>;
1852 def v8i16: NANDVecInst<v8i16>;
1853 def v4i32: NANDVecInst<v4i32>;
1854 def v2i64: NANDVecInst<v2i64>;
Scott Michel66377522007-12-04 22:35:58 +00001855
Scott Michel6e1d1472009-03-16 18:47:25 +00001856 def r128: NANDRegInst<GPRC>;
1857 def r64: NANDRegInst<R64C>;
1858 def r32: NANDRegInst<R32C>;
1859 def r16: NANDRegInst<R16C>;
1860 def r8: NANDRegInst<R8C>;
1861}
Scott Michel66377522007-12-04 22:35:58 +00001862
Scott Michel6e1d1472009-03-16 18:47:25 +00001863defm NAND : BitwiseNand;
Scott Michel504c3692007-12-17 22:32:34 +00001864
Scott Michel66377522007-12-04 22:35:58 +00001865// NOR:
Scott Michel66377522007-12-04 22:35:58 +00001866
Scott Michel6e1d1472009-03-16 18:47:25 +00001867class NORInst<dag OOL, dag IOL, list<dag> pattern>:
1868 RRForm<0b10010010000, OOL, IOL, "nor\t$rT, $rA, $rB",
1869 IntegerOp, pattern>;
Scott Michel66377522007-12-04 22:35:58 +00001870
Scott Michel6e1d1472009-03-16 18:47:25 +00001871class NORVecInst<ValueType vectype>:
1872 NORInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1873 [(set (vectype VECREG:$rT), (vnot (or (vectype VECREG:$rA),
1874 (vectype VECREG:$rB))))]>;
1875class NORRegInst<RegisterClass rclass>:
1876 NORInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB),
1877 [(set rclass:$rT, (not (or rclass:$rA, rclass:$rB)))]>;
Scott Michel66377522007-12-04 22:35:58 +00001878
Scott Michel6e1d1472009-03-16 18:47:25 +00001879multiclass BitwiseNor
1880{
1881 def v16i8: NORVecInst<v16i8>;
1882 def v8i16: NORVecInst<v8i16>;
1883 def v4i32: NORVecInst<v4i32>;
1884 def v2i64: NORVecInst<v2i64>;
Scott Michel66377522007-12-04 22:35:58 +00001885
Scott Michel6e1d1472009-03-16 18:47:25 +00001886 def r128: NORRegInst<GPRC>;
1887 def r64: NORRegInst<R64C>;
1888 def r32: NORRegInst<R32C>;
1889 def r16: NORRegInst<R16C>;
1890 def r8: NORRegInst<R8C>;
1891}
Scott Michel66377522007-12-04 22:35:58 +00001892
Scott Michel6e1d1472009-03-16 18:47:25 +00001893defm NOR : BitwiseNor;
Scott Michel504c3692007-12-17 22:32:34 +00001894
Scott Michel66377522007-12-04 22:35:58 +00001895// Select bits:
Scott Michelad2715e2008-03-05 23:02:02 +00001896class SELBInst<dag OOL, dag IOL, list<dag> pattern>:
1897 RRRForm<0b1000, OOL, IOL, "selb\t$rT, $rA, $rB, $rC",
1898 IntegerOp, pattern>;
Scott Michel66377522007-12-04 22:35:58 +00001899
Scott Michelc9c8b2a2009-01-26 03:31:40 +00001900class SELBVecInst<ValueType vectype, PatFrag vnot_frag = vnot>:
Scott Michelad2715e2008-03-05 23:02:02 +00001901 SELBInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB, VECREG:$rC),
1902 [(set (vectype VECREG:$rT),
1903 (or (and (vectype VECREG:$rC), (vectype VECREG:$rB)),
Scott Michelc9c8b2a2009-01-26 03:31:40 +00001904 (and (vnot_frag (vectype VECREG:$rC)),
Scott Michelad2715e2008-03-05 23:02:02 +00001905 (vectype VECREG:$rA))))]>;
Scott Michel66377522007-12-04 22:35:58 +00001906
Scott Michel02d711b2008-12-30 23:28:25 +00001907class SELBVecVCondInst<ValueType vectype>:
1908 SELBInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB, VECREG:$rC),
1909 [(set (vectype VECREG:$rT),
1910 (select (vectype VECREG:$rC),
1911 (vectype VECREG:$rB),
1912 (vectype VECREG:$rA)))]>;
1913
Scott Michelf0569be2008-12-27 04:51:36 +00001914class SELBVecCondInst<ValueType vectype>:
1915 SELBInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB, R32C:$rC),
1916 [(set (vectype VECREG:$rT),
1917 (select R32C:$rC,
1918 (vectype VECREG:$rB),
1919 (vectype VECREG:$rA)))]>;
1920
Scott Michelad2715e2008-03-05 23:02:02 +00001921class SELBRegInst<RegisterClass rclass>:
1922 SELBInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB, rclass:$rC),
1923 [(set rclass:$rT,
Scott Michel1df30c42008-12-29 03:23:36 +00001924 (or (and rclass:$rB, rclass:$rC),
1925 (and rclass:$rA, (not rclass:$rC))))]>;
Scott Michel66377522007-12-04 22:35:58 +00001926
Scott Michelf0569be2008-12-27 04:51:36 +00001927class SELBRegCondInst<RegisterClass rcond, RegisterClass rclass>:
1928 SELBInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB, rcond:$rC),
1929 [(set rclass:$rT,
1930 (select rcond:$rC, rclass:$rB, rclass:$rA))]>;
1931
Scott Michelad2715e2008-03-05 23:02:02 +00001932multiclass SelectBits
1933{
1934 def v16i8: SELBVecInst<v16i8>;
1935 def v8i16: SELBVecInst<v8i16>;
1936 def v4i32: SELBVecInst<v4i32>;
Scott Michelc9c8b2a2009-01-26 03:31:40 +00001937 def v2i64: SELBVecInst<v2i64, vnot_conv>;
Scott Michel66377522007-12-04 22:35:58 +00001938
Scott Michelad2715e2008-03-05 23:02:02 +00001939 def r128: SELBRegInst<GPRC>;
1940 def r64: SELBRegInst<R64C>;
1941 def r32: SELBRegInst<R32C>;
1942 def r16: SELBRegInst<R16C>;
1943 def r8: SELBRegInst<R8C>;
Scott Michelf0569be2008-12-27 04:51:36 +00001944
1945 def v16i8_cond: SELBVecCondInst<v16i8>;
1946 def v8i16_cond: SELBVecCondInst<v8i16>;
1947 def v4i32_cond: SELBVecCondInst<v4i32>;
1948 def v2i64_cond: SELBVecCondInst<v2i64>;
1949
Scott Michel02d711b2008-12-30 23:28:25 +00001950 def v16i8_vcond: SELBVecCondInst<v16i8>;
1951 def v8i16_vcond: SELBVecCondInst<v8i16>;
1952 def v4i32_vcond: SELBVecCondInst<v4i32>;
1953 def v2i64_vcond: SELBVecCondInst<v2i64>;
1954
1955 def v4f32_cond:
Scott Michel19c10e62009-01-26 03:37:41 +00001956 SELBInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB, VECREG:$rC),
1957 [(set (v4f32 VECREG:$rT),
1958 (select (v4i32 VECREG:$rC),
1959 (v4f32 VECREG:$rB),
1960 (v4f32 VECREG:$rA)))]>;
Scott Michel02d711b2008-12-30 23:28:25 +00001961
Scott Micheld1e8d9c2009-01-21 04:58:48 +00001962 // SELBr64_cond is defined in SPU64InstrInfo.td
Scott Michelf0569be2008-12-27 04:51:36 +00001963 def r32_cond: SELBRegCondInst<R32C, R32C>;
Scott Michel02d711b2008-12-30 23:28:25 +00001964 def f32_cond: SELBRegCondInst<R32C, R32FP>;
Scott Michelf0569be2008-12-27 04:51:36 +00001965 def r16_cond: SELBRegCondInst<R16C, R16C>;
1966 def r8_cond: SELBRegCondInst<R8C, R8C>;
Scott Michelad2715e2008-03-05 23:02:02 +00001967}
Scott Michel66377522007-12-04 22:35:58 +00001968
Scott Michelad2715e2008-03-05 23:02:02 +00001969defm SELB : SelectBits;
Scott Michel66377522007-12-04 22:35:58 +00001970
Scott Michel7a1c9e92008-11-22 23:50:42 +00001971class SPUselbPatVec<ValueType vectype, SPUInstr inst>:
Scott Michelad2715e2008-03-05 23:02:02 +00001972 Pat<(SPUselb (vectype VECREG:$rA), (vectype VECREG:$rB), (vectype VECREG:$rC)),
1973 (inst VECREG:$rA, VECREG:$rB, VECREG:$rC)>;
Scott Michel66377522007-12-04 22:35:58 +00001974
Scott Michel7a1c9e92008-11-22 23:50:42 +00001975def : SPUselbPatVec<v16i8, SELBv16i8>;
1976def : SPUselbPatVec<v8i16, SELBv8i16>;
1977def : SPUselbPatVec<v4i32, SELBv4i32>;
1978def : SPUselbPatVec<v2i64, SELBv2i64>;
1979
1980class SPUselbPatReg<RegisterClass rclass, SPUInstr inst>:
1981 Pat<(SPUselb rclass:$rA, rclass:$rB, rclass:$rC),
1982 (inst rclass:$rA, rclass:$rB, rclass:$rC)>;
1983
1984def : SPUselbPatReg<R8C, SELBr8>;
1985def : SPUselbPatReg<R16C, SELBr16>;
1986def : SPUselbPatReg<R32C, SELBr32>;
1987def : SPUselbPatReg<R64C, SELBr64>;
Scott Michel66377522007-12-04 22:35:58 +00001988
Scott Michelad2715e2008-03-05 23:02:02 +00001989// EQV: Equivalence (1 for each same bit, otherwise 0)
1990//
1991// Note: There are a lot of ways to match this bit operator and these patterns
1992// attempt to be as exhaustive as possible.
Scott Michel66377522007-12-04 22:35:58 +00001993
Scott Michelad2715e2008-03-05 23:02:02 +00001994class EQVInst<dag OOL, dag IOL, list<dag> pattern>:
1995 RRForm<0b10010010000, OOL, IOL, "eqv\t$rT, $rA, $rB",
1996 IntegerOp, pattern>;
Scott Michel66377522007-12-04 22:35:58 +00001997
Scott Michelad2715e2008-03-05 23:02:02 +00001998class EQVVecInst<ValueType vectype>:
1999 EQVInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
2000 [(set (vectype VECREG:$rT),
2001 (or (and (vectype VECREG:$rA), (vectype VECREG:$rB)),
2002 (and (vnot (vectype VECREG:$rA)),
2003 (vnot (vectype VECREG:$rB)))))]>;
Scott Michel66377522007-12-04 22:35:58 +00002004
Scott Michelad2715e2008-03-05 23:02:02 +00002005class EQVRegInst<RegisterClass rclass>:
2006 EQVInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB),
2007 [(set rclass:$rT, (or (and rclass:$rA, rclass:$rB),
2008 (and (not rclass:$rA), (not rclass:$rB))))]>;
Scott Michel66377522007-12-04 22:35:58 +00002009
Scott Michelad2715e2008-03-05 23:02:02 +00002010class EQVVecPattern1<ValueType vectype>:
2011 EQVInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
2012 [(set (vectype VECREG:$rT),
2013 (xor (vectype VECREG:$rA), (vnot (vectype VECREG:$rB))))]>;
Scott Michel66377522007-12-04 22:35:58 +00002014
Scott Michelad2715e2008-03-05 23:02:02 +00002015class EQVRegPattern1<RegisterClass rclass>:
2016 EQVInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB),
2017 [(set rclass:$rT, (xor rclass:$rA, (not rclass:$rB)))]>;
Scott Michel66377522007-12-04 22:35:58 +00002018
Scott Michelad2715e2008-03-05 23:02:02 +00002019class EQVVecPattern2<ValueType vectype>:
2020 EQVInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
2021 [(set (vectype VECREG:$rT),
2022 (or (and (vectype VECREG:$rA), (vectype VECREG:$rB)),
2023 (vnot (or (vectype VECREG:$rA), (vectype VECREG:$rB)))))]>;
Scott Michel66377522007-12-04 22:35:58 +00002024
Scott Michelad2715e2008-03-05 23:02:02 +00002025class EQVRegPattern2<RegisterClass rclass>:
2026 EQVInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB),
2027 [(set rclass:$rT,
2028 (or (and rclass:$rA, rclass:$rB),
2029 (not (or rclass:$rA, rclass:$rB))))]>;
Scott Michel66377522007-12-04 22:35:58 +00002030
Scott Michelad2715e2008-03-05 23:02:02 +00002031class EQVVecPattern3<ValueType vectype>:
2032 EQVInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
2033 [(set (vectype VECREG:$rT),
2034 (not (xor (vectype VECREG:$rA), (vectype VECREG:$rB))))]>;
Scott Michel66377522007-12-04 22:35:58 +00002035
Scott Michelad2715e2008-03-05 23:02:02 +00002036class EQVRegPattern3<RegisterClass rclass>:
2037 EQVInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB),
2038 [(set rclass:$rT, (not (xor rclass:$rA, rclass:$rB)))]>;
Scott Michel66377522007-12-04 22:35:58 +00002039
Scott Michelad2715e2008-03-05 23:02:02 +00002040multiclass BitEquivalence
2041{
2042 def v16i8: EQVVecInst<v16i8>;
2043 def v8i16: EQVVecInst<v8i16>;
2044 def v4i32: EQVVecInst<v4i32>;
2045 def v2i64: EQVVecInst<v2i64>;
Scott Michel66377522007-12-04 22:35:58 +00002046
Scott Michelad2715e2008-03-05 23:02:02 +00002047 def v16i8_1: EQVVecPattern1<v16i8>;
2048 def v8i16_1: EQVVecPattern1<v8i16>;
2049 def v4i32_1: EQVVecPattern1<v4i32>;
2050 def v2i64_1: EQVVecPattern1<v2i64>;
Scott Michel66377522007-12-04 22:35:58 +00002051
Scott Michelad2715e2008-03-05 23:02:02 +00002052 def v16i8_2: EQVVecPattern2<v16i8>;
2053 def v8i16_2: EQVVecPattern2<v8i16>;
2054 def v4i32_2: EQVVecPattern2<v4i32>;
2055 def v2i64_2: EQVVecPattern2<v2i64>;
Scott Michel66377522007-12-04 22:35:58 +00002056
Scott Michelad2715e2008-03-05 23:02:02 +00002057 def v16i8_3: EQVVecPattern3<v16i8>;
2058 def v8i16_3: EQVVecPattern3<v8i16>;
2059 def v4i32_3: EQVVecPattern3<v4i32>;
2060 def v2i64_3: EQVVecPattern3<v2i64>;
Scott Michel66377522007-12-04 22:35:58 +00002061
Scott Michelad2715e2008-03-05 23:02:02 +00002062 def r128: EQVRegInst<GPRC>;
2063 def r64: EQVRegInst<R64C>;
2064 def r32: EQVRegInst<R32C>;
2065 def r16: EQVRegInst<R16C>;
2066 def r8: EQVRegInst<R8C>;
Scott Michel66377522007-12-04 22:35:58 +00002067
Scott Michelad2715e2008-03-05 23:02:02 +00002068 def r128_1: EQVRegPattern1<GPRC>;
2069 def r64_1: EQVRegPattern1<R64C>;
2070 def r32_1: EQVRegPattern1<R32C>;
2071 def r16_1: EQVRegPattern1<R16C>;
2072 def r8_1: EQVRegPattern1<R8C>;
Scott Michel66377522007-12-04 22:35:58 +00002073
Scott Michelad2715e2008-03-05 23:02:02 +00002074 def r128_2: EQVRegPattern2<GPRC>;
2075 def r64_2: EQVRegPattern2<R64C>;
2076 def r32_2: EQVRegPattern2<R32C>;
2077 def r16_2: EQVRegPattern2<R16C>;
2078 def r8_2: EQVRegPattern2<R8C>;
Scott Michel66377522007-12-04 22:35:58 +00002079
Scott Michelad2715e2008-03-05 23:02:02 +00002080 def r128_3: EQVRegPattern3<GPRC>;
2081 def r64_3: EQVRegPattern3<R64C>;
2082 def r32_3: EQVRegPattern3<R32C>;
2083 def r16_3: EQVRegPattern3<R16C>;
2084 def r8_3: EQVRegPattern3<R8C>;
2085}
Scott Michel504c3692007-12-17 22:32:34 +00002086
Scott Michelad2715e2008-03-05 23:02:02 +00002087defm EQV: BitEquivalence;
Scott Michel66377522007-12-04 22:35:58 +00002088
2089//===----------------------------------------------------------------------===//
2090// Vector shuffle...
2091//===----------------------------------------------------------------------===//
Scott Michel66377522007-12-04 22:35:58 +00002092// SPUshuffle is generated in LowerVECTOR_SHUFFLE and gets replaced with SHUFB.
2093// See the SPUshuffle SDNode operand above, which sets up the DAG pattern
2094// matcher to emit something when the LowerVECTOR_SHUFFLE generates a node with
2095// the SPUISD::SHUFB opcode.
Scott Michela59d4692008-02-23 18:41:37 +00002096//===----------------------------------------------------------------------===//
Scott Michel66377522007-12-04 22:35:58 +00002097
Scott Michela59d4692008-02-23 18:41:37 +00002098class SHUFBInst<dag OOL, dag IOL, list<dag> pattern>:
2099 RRRForm<0b1000, OOL, IOL, "shufb\t$rT, $rA, $rB, $rC",
2100 IntegerOp, pattern>;
Scott Michel66377522007-12-04 22:35:58 +00002101
Scott Michel1a6cdb62008-12-01 17:56:02 +00002102class SHUFBVecInst<ValueType resultvec, ValueType maskvec>:
Scott Michela59d4692008-02-23 18:41:37 +00002103 SHUFBInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB, VECREG:$rC),
Scott Michel1a6cdb62008-12-01 17:56:02 +00002104 [(set (resultvec VECREG:$rT),
2105 (SPUshuffle (resultvec VECREG:$rA),
2106 (resultvec VECREG:$rB),
2107 (maskvec VECREG:$rC)))]>;
Scott Michel86c041f2007-12-20 00:44:13 +00002108
Scott Michelf0569be2008-12-27 04:51:36 +00002109class SHUFBGPRCInst:
2110 SHUFBInst<(outs VECREG:$rT), (ins GPRC:$rA, GPRC:$rB, VECREG:$rC),
2111 [/* no pattern */]>;
2112
Scott Michela59d4692008-02-23 18:41:37 +00002113multiclass ShuffleBytes
2114{
Scott Michel1a6cdb62008-12-01 17:56:02 +00002115 def v16i8 : SHUFBVecInst<v16i8, v16i8>;
2116 def v16i8_m32 : SHUFBVecInst<v16i8, v4i32>;
2117 def v8i16 : SHUFBVecInst<v8i16, v16i8>;
2118 def v8i16_m32 : SHUFBVecInst<v8i16, v4i32>;
2119 def v4i32 : SHUFBVecInst<v4i32, v16i8>;
2120 def v4i32_m32 : SHUFBVecInst<v4i32, v4i32>;
2121 def v2i64 : SHUFBVecInst<v2i64, v16i8>;
2122 def v2i64_m32 : SHUFBVecInst<v2i64, v4i32>;
Scott Michel66377522007-12-04 22:35:58 +00002123
Scott Michel1a6cdb62008-12-01 17:56:02 +00002124 def v4f32 : SHUFBVecInst<v4f32, v16i8>;
2125 def v4f32_m32 : SHUFBVecInst<v4f32, v4i32>;
2126
2127 def v2f64 : SHUFBVecInst<v2f64, v16i8>;
2128 def v2f64_m32 : SHUFBVecInst<v2f64, v4i32>;
Scott Michelf0569be2008-12-27 04:51:36 +00002129
2130 def gprc : SHUFBGPRCInst;
Scott Michela59d4692008-02-23 18:41:37 +00002131}
2132
2133defm SHUFB : ShuffleBytes;
2134
Scott Michel66377522007-12-04 22:35:58 +00002135//===----------------------------------------------------------------------===//
2136// Shift and rotate group:
2137//===----------------------------------------------------------------------===//
2138
Scott Michela59d4692008-02-23 18:41:37 +00002139class SHLHInst<dag OOL, dag IOL, list<dag> pattern>:
2140 RRForm<0b11111010000, OOL, IOL, "shlh\t$rT, $rA, $rB",
2141 RotateShift, pattern>;
2142
2143class SHLHVecInst<ValueType vectype>:
2144 SHLHInst<(outs VECREG:$rT), (ins VECREG:$rA, R16C:$rB),
2145 [(set (vectype VECREG:$rT),
2146 (SPUvec_shl (vectype VECREG:$rA), R16C:$rB))]>;
Scott Michel66377522007-12-04 22:35:58 +00002147
Scott Michela59d4692008-02-23 18:41:37 +00002148multiclass ShiftLeftHalfword
2149{
2150 def v8i16: SHLHVecInst<v8i16>;
2151 def r16: SHLHInst<(outs R16C:$rT), (ins R16C:$rA, R16C:$rB),
2152 [(set R16C:$rT, (shl R16C:$rA, R16C:$rB))]>;
2153 def r16_r32: SHLHInst<(outs R16C:$rT), (ins R16C:$rA, R32C:$rB),
2154 [(set R16C:$rT, (shl R16C:$rA, R32C:$rB))]>;
2155}
Scott Michel66377522007-12-04 22:35:58 +00002156
Scott Michela59d4692008-02-23 18:41:37 +00002157defm SHLH : ShiftLeftHalfword;
Scott Michel66377522007-12-04 22:35:58 +00002158
Scott Michela59d4692008-02-23 18:41:37 +00002159//===----------------------------------------------------------------------===//
Scott Michel504c3692007-12-17 22:32:34 +00002160
Scott Michela59d4692008-02-23 18:41:37 +00002161class SHLHIInst<dag OOL, dag IOL, list<dag> pattern>:
2162 RI7Form<0b11111010000, OOL, IOL, "shlhi\t$rT, $rA, $val",
2163 RotateShift, pattern>;
Scott Michel66377522007-12-04 22:35:58 +00002164
Scott Michela59d4692008-02-23 18:41:37 +00002165class SHLHIVecInst<ValueType vectype>:
2166 SHLHIInst<(outs VECREG:$rT), (ins VECREG:$rA, u7imm:$val),
2167 [(set (vectype VECREG:$rT),
2168 (SPUvec_shl (vectype VECREG:$rA), (i16 uimm7:$val)))]>;
Scott Michel66377522007-12-04 22:35:58 +00002169
Scott Michela59d4692008-02-23 18:41:37 +00002170multiclass ShiftLeftHalfwordImm
2171{
2172 def v8i16: SHLHIVecInst<v8i16>;
2173 def r16: SHLHIInst<(outs R16C:$rT), (ins R16C:$rA, u7imm:$val),
2174 [(set R16C:$rT, (shl R16C:$rA, (i16 uimm7:$val)))]>;
2175}
2176
2177defm SHLHI : ShiftLeftHalfwordImm;
2178
2179def : Pat<(SPUvec_shl (v8i16 VECREG:$rA), (i32 uimm7:$val)),
Chris Lattner420c69d2010-03-15 05:53:47 +00002180 (SHLHIv8i16 VECREG:$rA, (TO_IMM16 uimm7:$val))>;
Scott Michela59d4692008-02-23 18:41:37 +00002181
2182def : Pat<(shl R16C:$rA, (i32 uimm7:$val)),
Chris Lattner420c69d2010-03-15 05:53:47 +00002183 (SHLHIr16 R16C:$rA, (TO_IMM16 uimm7:$val))>;
Scott Michel66377522007-12-04 22:35:58 +00002184
Scott Michela59d4692008-02-23 18:41:37 +00002185//===----------------------------------------------------------------------===//
Scott Michel66377522007-12-04 22:35:58 +00002186
Scott Michela59d4692008-02-23 18:41:37 +00002187class SHLInst<dag OOL, dag IOL, list<dag> pattern>:
2188 RRForm<0b11111010000, OOL, IOL, "shl\t$rT, $rA, $rB",
2189 RotateShift, pattern>;
Scott Michel66377522007-12-04 22:35:58 +00002190
Scott Michela59d4692008-02-23 18:41:37 +00002191multiclass ShiftLeftWord
2192{
2193 def v4i32:
2194 SHLInst<(outs VECREG:$rT), (ins VECREG:$rA, R16C:$rB),
2195 [(set (v4i32 VECREG:$rT),
2196 (SPUvec_shl (v4i32 VECREG:$rA), R16C:$rB))]>;
2197 def r32:
2198 SHLInst<(outs R32C:$rT), (ins R32C:$rA, R32C:$rB),
2199 [(set R32C:$rT, (shl R32C:$rA, R32C:$rB))]>;
2200}
Scott Michel66377522007-12-04 22:35:58 +00002201
Scott Michela59d4692008-02-23 18:41:37 +00002202defm SHL: ShiftLeftWord;
Scott Michel504c3692007-12-17 22:32:34 +00002203
Scott Michela59d4692008-02-23 18:41:37 +00002204//===----------------------------------------------------------------------===//
Scott Michel66377522007-12-04 22:35:58 +00002205
Scott Michela59d4692008-02-23 18:41:37 +00002206class SHLIInst<dag OOL, dag IOL, list<dag> pattern>:
2207 RI7Form<0b11111010000, OOL, IOL, "shli\t$rT, $rA, $val",
2208 RotateShift, pattern>;
Scott Michel66377522007-12-04 22:35:58 +00002209
Scott Michela59d4692008-02-23 18:41:37 +00002210multiclass ShiftLeftWordImm
2211{
2212 def v4i32:
2213 SHLIInst<(outs VECREG:$rT), (ins VECREG:$rA, u7imm_i32:$val),
2214 [(set (v4i32 VECREG:$rT),
2215 (SPUvec_shl (v4i32 VECREG:$rA), (i32 uimm7:$val)))]>;
Scott Michel66377522007-12-04 22:35:58 +00002216
Scott Michela59d4692008-02-23 18:41:37 +00002217 def r32:
2218 SHLIInst<(outs R32C:$rT), (ins R32C:$rA, u7imm_i32:$val),
2219 [(set R32C:$rT, (shl R32C:$rA, (i32 uimm7:$val)))]>;
2220}
Scott Michel66377522007-12-04 22:35:58 +00002221
Scott Michela59d4692008-02-23 18:41:37 +00002222defm SHLI : ShiftLeftWordImm;
Scott Michel504c3692007-12-17 22:32:34 +00002223
Scott Michela59d4692008-02-23 18:41:37 +00002224//===----------------------------------------------------------------------===//
Scott Michel66377522007-12-04 22:35:58 +00002225// SHLQBI vec form: Note that this will shift the entire vector (the 128-bit
2226// register) to the left. Vector form is here to ensure type correctness.
Scott Michela59d4692008-02-23 18:41:37 +00002227//
2228// The shift count is in the lowest 3 bits (29-31) of $rB, so only a bit shift
2229// of 7 bits is actually possible.
2230//
2231// Note also that SHLQBI/SHLQBII are used in conjunction with SHLQBY/SHLQBYI
2232// to shift i64 and i128. SHLQBI is the residual left over after shifting by
2233// bytes with SHLQBY.
Scott Michel66377522007-12-04 22:35:58 +00002234
Scott Michela59d4692008-02-23 18:41:37 +00002235class SHLQBIInst<dag OOL, dag IOL, list<dag> pattern>:
2236 RRForm<0b11011011100, OOL, IOL, "shlqbi\t$rT, $rA, $rB",
2237 RotateShift, pattern>;
2238
2239class SHLQBIVecInst<ValueType vectype>:
2240 SHLQBIInst<(outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB),
2241 [(set (vectype VECREG:$rT),
2242 (SPUshlquad_l_bits (vectype VECREG:$rA), R32C:$rB))]>;
2243
Scott Micheld1e8d9c2009-01-21 04:58:48 +00002244class SHLQBIRegInst<RegisterClass rclass>:
2245 SHLQBIInst<(outs rclass:$rT), (ins rclass:$rA, R32C:$rB),
2246 [/* no pattern */]>;
2247
Scott Michela59d4692008-02-23 18:41:37 +00002248multiclass ShiftLeftQuadByBits
2249{
2250 def v16i8: SHLQBIVecInst<v16i8>;
2251 def v8i16: SHLQBIVecInst<v8i16>;
2252 def v4i32: SHLQBIVecInst<v4i32>;
Scott Michel7a1c9e92008-11-22 23:50:42 +00002253 def v4f32: SHLQBIVecInst<v4f32>;
Scott Michela59d4692008-02-23 18:41:37 +00002254 def v2i64: SHLQBIVecInst<v2i64>;
Scott Michel7a1c9e92008-11-22 23:50:42 +00002255 def v2f64: SHLQBIVecInst<v2f64>;
Scott Micheld1e8d9c2009-01-21 04:58:48 +00002256
2257 def r128: SHLQBIRegInst<GPRC>;
Scott Michela59d4692008-02-23 18:41:37 +00002258}
2259
2260defm SHLQBI : ShiftLeftQuadByBits;
2261
2262// See note above on SHLQBI. In this case, the predicate actually does then
2263// enforcement, whereas with SHLQBI, we have to "take it on faith."
2264class SHLQBIIInst<dag OOL, dag IOL, list<dag> pattern>:
2265 RI7Form<0b11011111100, OOL, IOL, "shlqbii\t$rT, $rA, $val",
2266 RotateShift, pattern>;
2267
2268class SHLQBIIVecInst<ValueType vectype>:
2269 SHLQBIIInst<(outs VECREG:$rT), (ins VECREG:$rA, u7imm_i32:$val),
2270 [(set (vectype VECREG:$rT),
2271 (SPUshlquad_l_bits (vectype VECREG:$rA), (i32 bitshift:$val)))]>;
2272
2273multiclass ShiftLeftQuadByBitsImm
2274{
2275 def v16i8 : SHLQBIIVecInst<v16i8>;
2276 def v8i16 : SHLQBIIVecInst<v8i16>;
2277 def v4i32 : SHLQBIIVecInst<v4i32>;
Scott Michel7a1c9e92008-11-22 23:50:42 +00002278 def v4f32 : SHLQBIIVecInst<v4f32>;
Scott Michela59d4692008-02-23 18:41:37 +00002279 def v2i64 : SHLQBIIVecInst<v2i64>;
Scott Michel7a1c9e92008-11-22 23:50:42 +00002280 def v2f64 : SHLQBIIVecInst<v2f64>;
Scott Michela59d4692008-02-23 18:41:37 +00002281}
2282
2283defm SHLQBII : ShiftLeftQuadByBitsImm;
Scott Michel66377522007-12-04 22:35:58 +00002284
2285// SHLQBY, SHLQBYI vector forms: Shift the entire vector to the left by bytes,
Scott Michela59d4692008-02-23 18:41:37 +00002286// not by bits. See notes above on SHLQBI.
Scott Michel66377522007-12-04 22:35:58 +00002287
Scott Michela59d4692008-02-23 18:41:37 +00002288class SHLQBYInst<dag OOL, dag IOL, list<dag> pattern>:
Scott Michel662165d2008-11-25 00:23:16 +00002289 RI7Form<0b11111011100, OOL, IOL, "shlqby\t$rT, $rA, $rB",
Scott Michela59d4692008-02-23 18:41:37 +00002290 RotateShift, pattern>;
Scott Michel66377522007-12-04 22:35:58 +00002291
Scott Michela59d4692008-02-23 18:41:37 +00002292class SHLQBYVecInst<ValueType vectype>:
2293 SHLQBYInst<(outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB),
2294 [(set (vectype VECREG:$rT),
2295 (SPUshlquad_l_bytes (vectype VECREG:$rA), R32C:$rB))]>;
Scott Michel66377522007-12-04 22:35:58 +00002296
Scott Michela59d4692008-02-23 18:41:37 +00002297multiclass ShiftLeftQuadBytes
2298{
2299 def v16i8: SHLQBYVecInst<v16i8>;
2300 def v8i16: SHLQBYVecInst<v8i16>;
2301 def v4i32: SHLQBYVecInst<v4i32>;
Scott Michel7a1c9e92008-11-22 23:50:42 +00002302 def v4f32: SHLQBYVecInst<v4f32>;
Scott Michela59d4692008-02-23 18:41:37 +00002303 def v2i64: SHLQBYVecInst<v2i64>;
Scott Michel7a1c9e92008-11-22 23:50:42 +00002304 def v2f64: SHLQBYVecInst<v2f64>;
Scott Michela59d4692008-02-23 18:41:37 +00002305 def r128: SHLQBYInst<(outs GPRC:$rT), (ins GPRC:$rA, R32C:$rB),
2306 [(set GPRC:$rT, (SPUshlquad_l_bytes GPRC:$rA, R32C:$rB))]>;
2307}
Scott Michel66377522007-12-04 22:35:58 +00002308
Scott Michela59d4692008-02-23 18:41:37 +00002309defm SHLQBY: ShiftLeftQuadBytes;
Scott Michel66377522007-12-04 22:35:58 +00002310
Scott Michela59d4692008-02-23 18:41:37 +00002311class SHLQBYIInst<dag OOL, dag IOL, list<dag> pattern>:
2312 RI7Form<0b11111111100, OOL, IOL, "shlqbyi\t$rT, $rA, $val",
2313 RotateShift, pattern>;
Scott Michel504c3692007-12-17 22:32:34 +00002314
Scott Michela59d4692008-02-23 18:41:37 +00002315class SHLQBYIVecInst<ValueType vectype>:
2316 SHLQBYIInst<(outs VECREG:$rT), (ins VECREG:$rA, u7imm_i32:$val),
2317 [(set (vectype VECREG:$rT),
2318 (SPUshlquad_l_bytes (vectype VECREG:$rA), (i32 uimm7:$val)))]>;
Scott Michel504c3692007-12-17 22:32:34 +00002319
Scott Michela59d4692008-02-23 18:41:37 +00002320multiclass ShiftLeftQuadBytesImm
2321{
2322 def v16i8: SHLQBYIVecInst<v16i8>;
2323 def v8i16: SHLQBYIVecInst<v8i16>;
2324 def v4i32: SHLQBYIVecInst<v4i32>;
Scott Michel7a1c9e92008-11-22 23:50:42 +00002325 def v4f32: SHLQBYIVecInst<v4f32>;
Scott Michela59d4692008-02-23 18:41:37 +00002326 def v2i64: SHLQBYIVecInst<v2i64>;
Scott Michel7a1c9e92008-11-22 23:50:42 +00002327 def v2f64: SHLQBYIVecInst<v2f64>;
Scott Michela59d4692008-02-23 18:41:37 +00002328 def r128: SHLQBYIInst<(outs GPRC:$rT), (ins GPRC:$rA, u7imm_i32:$val),
2329 [(set GPRC:$rT,
2330 (SPUshlquad_l_bytes GPRC:$rA, (i32 uimm7:$val)))]>;
2331}
Scott Michel504c3692007-12-17 22:32:34 +00002332
Scott Michela59d4692008-02-23 18:41:37 +00002333defm SHLQBYI : ShiftLeftQuadBytesImm;
Scott Michel504c3692007-12-17 22:32:34 +00002334
Scott Micheld1e8d9c2009-01-21 04:58:48 +00002335class SHLQBYBIInst<dag OOL, dag IOL, list<dag> pattern>:
2336 RRForm<0b00111001111, OOL, IOL, "shlqbybi\t$rT, $rA, $rB",
2337 RotateShift, pattern>;
2338
2339class SHLQBYBIVecInst<ValueType vectype>:
2340 SHLQBYBIInst<(outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB),
2341 [/* no pattern */]>;
2342
2343class SHLQBYBIRegInst<RegisterClass rclass>:
2344 SHLQBYBIInst<(outs rclass:$rT), (ins rclass:$rA, R32C:$rB),
2345 [/* no pattern */]>;
2346
2347multiclass ShiftLeftQuadBytesBitCount
2348{
2349 def v16i8: SHLQBYBIVecInst<v16i8>;
2350 def v8i16: SHLQBYBIVecInst<v8i16>;
2351 def v4i32: SHLQBYBIVecInst<v4i32>;
2352 def v4f32: SHLQBYBIVecInst<v4f32>;
2353 def v2i64: SHLQBYBIVecInst<v2i64>;
2354 def v2f64: SHLQBYBIVecInst<v2f64>;
2355
2356 def r128: SHLQBYBIRegInst<GPRC>;
2357}
2358
2359defm SHLQBYBI : ShiftLeftQuadBytesBitCount;
2360
Scott Michela59d4692008-02-23 18:41:37 +00002361//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2362// Rotate halfword:
2363//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2364class ROTHInst<dag OOL, dag IOL, list<dag> pattern>:
2365 RRForm<0b00111010000, OOL, IOL, "roth\t$rT, $rA, $rB",
2366 RotateShift, pattern>;
2367
2368class ROTHVecInst<ValueType vectype>:
2369 ROTHInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
2370 [(set (vectype VECREG:$rT),
Chris Lattnerdd6fbd12010-03-08 18:59:49 +00002371 (SPUvec_rotl VECREG:$rA, (v8i16 VECREG:$rB)))]>;
Scott Michela59d4692008-02-23 18:41:37 +00002372
2373class ROTHRegInst<RegisterClass rclass>:
2374 ROTHInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB),
2375 [(set rclass:$rT, (rotl rclass:$rA, rclass:$rB))]>;
2376
2377multiclass RotateLeftHalfword
2378{
2379 def v8i16: ROTHVecInst<v8i16>;
2380 def r16: ROTHRegInst<R16C>;
2381}
2382
2383defm ROTH: RotateLeftHalfword;
2384
2385def ROTHr16_r32: ROTHInst<(outs R16C:$rT), (ins R16C:$rA, R32C:$rB),
2386 [(set R16C:$rT, (rotl R16C:$rA, R32C:$rB))]>;
2387
2388//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2389// Rotate halfword, immediate:
2390//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2391class ROTHIInst<dag OOL, dag IOL, list<dag> pattern>:
2392 RI7Form<0b00111110000, OOL, IOL, "rothi\t$rT, $rA, $val",
2393 RotateShift, pattern>;
2394
2395class ROTHIVecInst<ValueType vectype>:
2396 ROTHIInst<(outs VECREG:$rT), (ins VECREG:$rA, u7imm:$val),
2397 [(set (vectype VECREG:$rT),
2398 (SPUvec_rotl VECREG:$rA, (i16 uimm7:$val)))]>;
2399
2400multiclass RotateLeftHalfwordImm
2401{
2402 def v8i16: ROTHIVecInst<v8i16>;
2403 def r16: ROTHIInst<(outs R16C:$rT), (ins R16C:$rA, u7imm:$val),
2404 [(set R16C:$rT, (rotl R16C:$rA, (i16 uimm7:$val)))]>;
2405 def r16_r32: ROTHIInst<(outs R16C:$rT), (ins R16C:$rA, u7imm_i32:$val),
2406 [(set R16C:$rT, (rotl R16C:$rA, (i32 uimm7:$val)))]>;
2407}
2408
2409defm ROTHI: RotateLeftHalfwordImm;
2410
Chris Lattner420c69d2010-03-15 05:53:47 +00002411def : Pat<(SPUvec_rotl (v8i16 VECREG:$rA), (i32 uimm7:$val)),
2412 (ROTHIv8i16 VECREG:$rA, (TO_IMM16 imm:$val))>;
Scott Michelf0569be2008-12-27 04:51:36 +00002413
Scott Michela59d4692008-02-23 18:41:37 +00002414//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2415// Rotate word:
2416//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
Scott Michel66377522007-12-04 22:35:58 +00002417
Scott Michela59d4692008-02-23 18:41:37 +00002418class ROTInst<dag OOL, dag IOL, list<dag> pattern>:
2419 RRForm<0b00011010000, OOL, IOL, "rot\t$rT, $rA, $rB",
2420 RotateShift, pattern>;
Scott Michel66377522007-12-04 22:35:58 +00002421
Scott Michela59d4692008-02-23 18:41:37 +00002422class ROTVecInst<ValueType vectype>:
2423 ROTInst<(outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB),
2424 [(set (vectype VECREG:$rT),
2425 (SPUvec_rotl (vectype VECREG:$rA), R32C:$rB))]>;
Scott Michel504c3692007-12-17 22:32:34 +00002426
Scott Michela59d4692008-02-23 18:41:37 +00002427class ROTRegInst<RegisterClass rclass>:
2428 ROTInst<(outs rclass:$rT), (ins rclass:$rA, R32C:$rB),
2429 [(set rclass:$rT,
2430 (rotl rclass:$rA, R32C:$rB))]>;
Scott Michel66377522007-12-04 22:35:58 +00002431
Scott Michela59d4692008-02-23 18:41:37 +00002432multiclass RotateLeftWord
2433{
2434 def v4i32: ROTVecInst<v4i32>;
2435 def r32: ROTRegInst<R32C>;
2436}
2437
2438defm ROT: RotateLeftWord;
Scott Michel66377522007-12-04 22:35:58 +00002439
Scott Michel504c3692007-12-17 22:32:34 +00002440// The rotate amount is in the same bits whether we've got an 8-bit, 16-bit or
2441// 32-bit register
2442def ROTr32_r16_anyext:
Scott Michela59d4692008-02-23 18:41:37 +00002443 ROTInst<(outs R32C:$rT), (ins R32C:$rA, R16C:$rB),
2444 [(set R32C:$rT, (rotl R32C:$rA, (i32 (anyext R16C:$rB))))]>;
Scott Michel504c3692007-12-17 22:32:34 +00002445
2446def : Pat<(rotl R32C:$rA, (i32 (zext R16C:$rB))),
2447 (ROTr32_r16_anyext R32C:$rA, R16C:$rB)>;
2448
2449def : Pat<(rotl R32C:$rA, (i32 (sext R16C:$rB))),
2450 (ROTr32_r16_anyext R32C:$rA, R16C:$rB)>;
2451
2452def ROTr32_r8_anyext:
Scott Michela59d4692008-02-23 18:41:37 +00002453 ROTInst<(outs R32C:$rT), (ins R32C:$rA, R8C:$rB),
2454 [(set R32C:$rT, (rotl R32C:$rA, (i32 (anyext R8C:$rB))))]>;
Scott Michel504c3692007-12-17 22:32:34 +00002455
2456def : Pat<(rotl R32C:$rA, (i32 (zext R8C:$rB))),
2457 (ROTr32_r8_anyext R32C:$rA, R8C:$rB)>;
2458
2459def : Pat<(rotl R32C:$rA, (i32 (sext R8C:$rB))),
2460 (ROTr32_r8_anyext R32C:$rA, R8C:$rB)>;
2461
Scott Michela59d4692008-02-23 18:41:37 +00002462//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2463// Rotate word, immediate
2464//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
Scott Michel66377522007-12-04 22:35:58 +00002465
Scott Michela59d4692008-02-23 18:41:37 +00002466class ROTIInst<dag OOL, dag IOL, list<dag> pattern>:
2467 RI7Form<0b00011110000, OOL, IOL, "roti\t$rT, $rA, $val",
2468 RotateShift, pattern>;
Scott Michel66377522007-12-04 22:35:58 +00002469
Scott Michela59d4692008-02-23 18:41:37 +00002470class ROTIVecInst<ValueType vectype, Operand optype, ValueType inttype, PatLeaf pred>:
2471 ROTIInst<(outs VECREG:$rT), (ins VECREG:$rA, optype:$val),
2472 [(set (vectype VECREG:$rT),
2473 (SPUvec_rotl (vectype VECREG:$rA), (inttype pred:$val)))]>;
Scott Michel504c3692007-12-17 22:32:34 +00002474
Scott Michela59d4692008-02-23 18:41:37 +00002475class ROTIRegInst<RegisterClass rclass, Operand optype, ValueType inttype, PatLeaf pred>:
2476 ROTIInst<(outs rclass:$rT), (ins rclass:$rA, optype:$val),
2477 [(set rclass:$rT, (rotl rclass:$rA, (inttype pred:$val)))]>;
Scott Michel66377522007-12-04 22:35:58 +00002478
Scott Michela59d4692008-02-23 18:41:37 +00002479multiclass RotateLeftWordImm
2480{
2481 def v4i32: ROTIVecInst<v4i32, u7imm_i32, i32, uimm7>;
2482 def v4i32_i16: ROTIVecInst<v4i32, u7imm, i16, uimm7>;
2483 def v4i32_i8: ROTIVecInst<v4i32, u7imm_i8, i8, uimm7>;
Scott Michel66377522007-12-04 22:35:58 +00002484
Scott Michela59d4692008-02-23 18:41:37 +00002485 def r32: ROTIRegInst<R32C, u7imm_i32, i32, uimm7>;
2486 def r32_i16: ROTIRegInst<R32C, u7imm, i16, uimm7>;
2487 def r32_i8: ROTIRegInst<R32C, u7imm_i8, i8, uimm7>;
2488}
Scott Michel504c3692007-12-17 22:32:34 +00002489
Scott Michela59d4692008-02-23 18:41:37 +00002490defm ROTI : RotateLeftWordImm;
2491
2492//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2493// Rotate quad by byte (count)
2494//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2495
2496class ROTQBYInst<dag OOL, dag IOL, list<dag> pattern>:
2497 RRForm<0b00111011100, OOL, IOL, "rotqby\t$rT, $rA, $rB",
2498 RotateShift, pattern>;
2499
2500class ROTQBYVecInst<ValueType vectype>:
2501 ROTQBYInst<(outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB),
2502 [(set (vectype VECREG:$rT),
2503 (SPUrotbytes_left (vectype VECREG:$rA), R32C:$rB))]>;
2504
2505multiclass RotateQuadLeftByBytes
2506{
2507 def v16i8: ROTQBYVecInst<v16i8>;
2508 def v8i16: ROTQBYVecInst<v8i16>;
2509 def v4i32: ROTQBYVecInst<v4i32>;
Scott Michelcc188272008-12-04 21:01:44 +00002510 def v4f32: ROTQBYVecInst<v4f32>;
Scott Michela59d4692008-02-23 18:41:37 +00002511 def v2i64: ROTQBYVecInst<v2i64>;
Scott Michelcc188272008-12-04 21:01:44 +00002512 def v2f64: ROTQBYVecInst<v2f64>;
Scott Michela59d4692008-02-23 18:41:37 +00002513}
2514
2515defm ROTQBY: RotateQuadLeftByBytes;
Scott Michel66377522007-12-04 22:35:58 +00002516
Scott Michela59d4692008-02-23 18:41:37 +00002517//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2518// Rotate quad by byte (count), immediate
2519//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2520
2521class ROTQBYIInst<dag OOL, dag IOL, list<dag> pattern>:
2522 RI7Form<0b00111111100, OOL, IOL, "rotqbyi\t$rT, $rA, $val",
2523 RotateShift, pattern>;
2524
2525class ROTQBYIVecInst<ValueType vectype>:
2526 ROTQBYIInst<(outs VECREG:$rT), (ins VECREG:$rA, u7imm:$val),
2527 [(set (vectype VECREG:$rT),
2528 (SPUrotbytes_left (vectype VECREG:$rA), (i16 uimm7:$val)))]>;
2529
2530multiclass RotateQuadByBytesImm
2531{
2532 def v16i8: ROTQBYIVecInst<v16i8>;
2533 def v8i16: ROTQBYIVecInst<v8i16>;
2534 def v4i32: ROTQBYIVecInst<v4i32>;
Scott Michelcc188272008-12-04 21:01:44 +00002535 def v4f32: ROTQBYIVecInst<v4f32>;
Scott Michela59d4692008-02-23 18:41:37 +00002536 def v2i64: ROTQBYIVecInst<v2i64>;
Scott Michelcc188272008-12-04 21:01:44 +00002537 def vfi64: ROTQBYIVecInst<v2f64>;
Scott Michela59d4692008-02-23 18:41:37 +00002538}
2539
2540defm ROTQBYI: RotateQuadByBytesImm;
Scott Michel66377522007-12-04 22:35:58 +00002541
Scott Michel66377522007-12-04 22:35:58 +00002542// See ROTQBY note above.
Scott Michel8bf61e82008-06-02 22:18:03 +00002543class ROTQBYBIInst<dag OOL, dag IOL, list<dag> pattern>:
2544 RI7Form<0b00110011100, OOL, IOL,
2545 "rotqbybi\t$rT, $rA, $shift",
2546 RotateShift, pattern>;
2547
2548class ROTQBYBIVecInst<ValueType vectype, RegisterClass rclass>:
2549 ROTQBYBIInst<(outs VECREG:$rT), (ins VECREG:$rA, rclass:$shift),
2550 [(set (vectype VECREG:$rT),
2551 (SPUrotbytes_left_bits (vectype VECREG:$rA), rclass:$shift))]>;
2552
2553multiclass RotateQuadByBytesByBitshift {
2554 def v16i8_r32: ROTQBYBIVecInst<v16i8, R32C>;
2555 def v8i16_r32: ROTQBYBIVecInst<v8i16, R32C>;
2556 def v4i32_r32: ROTQBYBIVecInst<v4i32, R32C>;
2557 def v2i64_r32: ROTQBYBIVecInst<v2i64, R32C>;
2558}
2559
2560defm ROTQBYBI : RotateQuadByBytesByBitshift;
Scott Michel66377522007-12-04 22:35:58 +00002561
Scott Michela59d4692008-02-23 18:41:37 +00002562//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
Scott Michel66377522007-12-04 22:35:58 +00002563// See ROTQBY note above.
2564//
2565// Assume that the user of this instruction knows to shift the rotate count
2566// into bit 29
Scott Michela59d4692008-02-23 18:41:37 +00002567//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
Scott Michel66377522007-12-04 22:35:58 +00002568
Scott Michela59d4692008-02-23 18:41:37 +00002569class ROTQBIInst<dag OOL, dag IOL, list<dag> pattern>:
2570 RRForm<0b00011011100, OOL, IOL, "rotqbi\t$rT, $rA, $rB",
2571 RotateShift, pattern>;
Scott Michel66377522007-12-04 22:35:58 +00002572
Scott Michela59d4692008-02-23 18:41:37 +00002573class ROTQBIVecInst<ValueType vectype>:
Scott Michel02d711b2008-12-30 23:28:25 +00002574 ROTQBIInst<(outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB),
Scott Michela59d4692008-02-23 18:41:37 +00002575 [/* no pattern yet */]>;
2576
2577class ROTQBIRegInst<RegisterClass rclass>:
Scott Michel02d711b2008-12-30 23:28:25 +00002578 ROTQBIInst<(outs rclass:$rT), (ins rclass:$rA, R32C:$rB),
Scott Michela59d4692008-02-23 18:41:37 +00002579 [/* no pattern yet */]>;
2580
2581multiclass RotateQuadByBitCount
2582{
2583 def v16i8: ROTQBIVecInst<v16i8>;
2584 def v8i16: ROTQBIVecInst<v8i16>;
2585 def v4i32: ROTQBIVecInst<v4i32>;
2586 def v2i64: ROTQBIVecInst<v2i64>;
2587
2588 def r128: ROTQBIRegInst<GPRC>;
2589 def r64: ROTQBIRegInst<R64C>;
2590}
2591
2592defm ROTQBI: RotateQuadByBitCount;
Scott Michelf0569be2008-12-27 04:51:36 +00002593
Scott Michela59d4692008-02-23 18:41:37 +00002594class ROTQBIIInst<dag OOL, dag IOL, list<dag> pattern>:
2595 RI7Form<0b00011111100, OOL, IOL, "rotqbii\t$rT, $rA, $val",
2596 RotateShift, pattern>;
2597
2598class ROTQBIIVecInst<ValueType vectype, Operand optype, ValueType inttype,
2599 PatLeaf pred>:
2600 ROTQBIIInst<(outs VECREG:$rT), (ins VECREG:$rA, optype:$val),
2601 [/* no pattern yet */]>;
2602
2603class ROTQBIIRegInst<RegisterClass rclass, Operand optype, ValueType inttype,
2604 PatLeaf pred>:
2605 ROTQBIIInst<(outs rclass:$rT), (ins rclass:$rA, optype:$val),
2606 [/* no pattern yet */]>;
2607
2608multiclass RotateQuadByBitCountImm
2609{
2610 def v16i8: ROTQBIIVecInst<v16i8, u7imm_i32, i32, uimm7>;
2611 def v8i16: ROTQBIIVecInst<v8i16, u7imm_i32, i32, uimm7>;
2612 def v4i32: ROTQBIIVecInst<v4i32, u7imm_i32, i32, uimm7>;
2613 def v2i64: ROTQBIIVecInst<v2i64, u7imm_i32, i32, uimm7>;
2614
2615 def r128: ROTQBIIRegInst<GPRC, u7imm_i32, i32, uimm7>;
2616 def r64: ROTQBIIRegInst<R64C, u7imm_i32, i32, uimm7>;
2617}
2618
2619defm ROTQBII : RotateQuadByBitCountImm;
2620
2621//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
Scott Michel66377522007-12-04 22:35:58 +00002622// ROTHM v8i16 form:
2623// NOTE(1): No vector rotate is generated by the C/C++ frontend (today),
2624// so this only matches a synthetically generated/lowered code
2625// fragment.
2626// NOTE(2): $rB must be negated before the right rotate!
Scott Michela59d4692008-02-23 18:41:37 +00002627//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
Scott Michel66377522007-12-04 22:35:58 +00002628
Scott Michela59d4692008-02-23 18:41:37 +00002629class ROTHMInst<dag OOL, dag IOL, list<dag> pattern>:
2630 RRForm<0b10111010000, OOL, IOL, "rothm\t$rT, $rA, $rB",
2631 RotateShift, pattern>;
2632
2633def ROTHMv8i16:
2634 ROTHMInst<(outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB),
2635 [/* see patterns below - $rB must be negated */]>;
2636
2637def : Pat<(SPUvec_srl (v8i16 VECREG:$rA), R32C:$rB),
Scott Michel66377522007-12-04 22:35:58 +00002638 (ROTHMv8i16 VECREG:$rA, (SFIr32 R32C:$rB, 0))>;
2639
Scott Michela59d4692008-02-23 18:41:37 +00002640def : Pat<(SPUvec_srl (v8i16 VECREG:$rA), R16C:$rB),
Scott Michel66377522007-12-04 22:35:58 +00002641 (ROTHMv8i16 VECREG:$rA,
2642 (SFIr32 (XSHWr16 R16C:$rB), 0))>;
2643
Scott Michela59d4692008-02-23 18:41:37 +00002644def : Pat<(SPUvec_srl (v8i16 VECREG:$rA), R8C:$rB),
Scott Michel66377522007-12-04 22:35:58 +00002645 (ROTHMv8i16 VECREG:$rA,
Scott Michel504c3692007-12-17 22:32:34 +00002646 (SFIr32 (XSHWr16 (XSBHr8 R8C:$rB) ), 0))>;
Scott Michel66377522007-12-04 22:35:58 +00002647
2648// ROTHM r16 form: Rotate 16-bit quantity to right, zero fill at the left
2649// Note: This instruction doesn't match a pattern because rB must be negated
2650// for the instruction to work. Thus, the pattern below the instruction!
Scott Michela59d4692008-02-23 18:41:37 +00002651
Scott Michel66377522007-12-04 22:35:58 +00002652def ROTHMr16:
Scott Michela59d4692008-02-23 18:41:37 +00002653 ROTHMInst<(outs R16C:$rT), (ins R16C:$rA, R32C:$rB),
2654 [/* see patterns below - $rB must be negated! */]>;
Scott Michel66377522007-12-04 22:35:58 +00002655
2656def : Pat<(srl R16C:$rA, R32C:$rB),
2657 (ROTHMr16 R16C:$rA, (SFIr32 R32C:$rB, 0))>;
2658
2659def : Pat<(srl R16C:$rA, R16C:$rB),
2660 (ROTHMr16 R16C:$rA,
2661 (SFIr32 (XSHWr16 R16C:$rB), 0))>;
2662
Scott Michel504c3692007-12-17 22:32:34 +00002663def : Pat<(srl R16C:$rA, R8C:$rB),
Scott Michel66377522007-12-04 22:35:58 +00002664 (ROTHMr16 R16C:$rA,
Scott Michel504c3692007-12-17 22:32:34 +00002665 (SFIr32 (XSHWr16 (XSBHr8 R8C:$rB) ), 0))>;
Scott Michel66377522007-12-04 22:35:58 +00002666
2667// ROTHMI v8i16 form: See the comment for ROTHM v8i16. The difference here is
2668// that the immediate can be complemented, so that the user doesn't have to
2669// worry about it.
Scott Michel66377522007-12-04 22:35:58 +00002670
Scott Michela59d4692008-02-23 18:41:37 +00002671class ROTHMIInst<dag OOL, dag IOL, list<dag> pattern>:
2672 RI7Form<0b10111110000, OOL, IOL, "rothmi\t$rT, $rA, $val",
2673 RotateShift, pattern>;
2674
2675def ROTHMIv8i16:
2676 ROTHMIInst<(outs VECREG:$rT), (ins VECREG:$rA, rothNeg7imm:$val),
2677 [/* no pattern */]>;
2678
2679def : Pat<(SPUvec_srl (v8i16 VECREG:$rA), (i32 imm:$val)),
2680 (ROTHMIv8i16 VECREG:$rA, imm:$val)>;
2681
2682def: Pat<(SPUvec_srl (v8i16 VECREG:$rA), (i16 imm:$val)),
Chris Lattner420c69d2010-03-15 05:53:47 +00002683 (ROTHMIv8i16 VECREG:$rA, (TO_IMM32 imm:$val))>;
Scott Michelf0569be2008-12-27 04:51:36 +00002684
Scott Michela59d4692008-02-23 18:41:37 +00002685def: Pat<(SPUvec_srl (v8i16 VECREG:$rA), (i8 imm:$val)),
Chris Lattner420c69d2010-03-15 05:53:47 +00002686 (ROTHMIv8i16 VECREG:$rA, (TO_IMM32 imm:$val))>;
Scott Michel66377522007-12-04 22:35:58 +00002687
2688def ROTHMIr16:
Scott Michela59d4692008-02-23 18:41:37 +00002689 ROTHMIInst<(outs R16C:$rT), (ins R16C:$rA, rothNeg7imm:$val),
2690 [/* no pattern */]>;
2691
2692def: Pat<(srl R16C:$rA, (i32 uimm7:$val)),
2693 (ROTHMIr16 R16C:$rA, uimm7:$val)>;
Scott Michel66377522007-12-04 22:35:58 +00002694
2695def: Pat<(srl R16C:$rA, (i16 uimm7:$val)),
Chris Lattner420c69d2010-03-15 05:53:47 +00002696 (ROTHMIr16 R16C:$rA, (TO_IMM32 uimm7:$val))>;
Scott Michel66377522007-12-04 22:35:58 +00002697
Scott Michel504c3692007-12-17 22:32:34 +00002698def: Pat<(srl R16C:$rA, (i8 uimm7:$val)),
Chris Lattner420c69d2010-03-15 05:53:47 +00002699 (ROTHMIr16 R16C:$rA, (TO_IMM32 uimm7:$val))>;
Scott Michel504c3692007-12-17 22:32:34 +00002700
Scott Michel66377522007-12-04 22:35:58 +00002701// ROTM v4i32 form: See the ROTHM v8i16 comments.
Scott Michela59d4692008-02-23 18:41:37 +00002702class ROTMInst<dag OOL, dag IOL, list<dag> pattern>:
2703 RRForm<0b10011010000, OOL, IOL, "rotm\t$rT, $rA, $rB",
2704 RotateShift, pattern>;
Scott Michel66377522007-12-04 22:35:58 +00002705
Scott Michela59d4692008-02-23 18:41:37 +00002706def ROTMv4i32:
2707 ROTMInst<(outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB),
2708 [/* see patterns below - $rB must be negated */]>;
2709
Chris Lattner420c69d2010-03-15 05:53:47 +00002710def : Pat<(SPUvec_srl (v4i32 VECREG:$rA), R32C:$rB),
Scott Michel66377522007-12-04 22:35:58 +00002711 (ROTMv4i32 VECREG:$rA, (SFIr32 R32C:$rB, 0))>;
2712
Chris Lattner420c69d2010-03-15 05:53:47 +00002713def : Pat<(SPUvec_srl (v4i32 VECREG:$rA), R16C:$rB),
Scott Michel66377522007-12-04 22:35:58 +00002714 (ROTMv4i32 VECREG:$rA,
2715 (SFIr32 (XSHWr16 R16C:$rB), 0))>;
2716
Chris Lattner420c69d2010-03-15 05:53:47 +00002717def : Pat<(SPUvec_srl (v4i32 VECREG:$rA), R8C:$rB),
Scott Michel66377522007-12-04 22:35:58 +00002718 (ROTMv4i32 VECREG:$rA,
Scott Michela59d4692008-02-23 18:41:37 +00002719 (SFIr32 (XSHWr16 (XSBHr8 R8C:$rB)), 0))>;
Scott Michel66377522007-12-04 22:35:58 +00002720
2721def ROTMr32:
Scott Michela59d4692008-02-23 18:41:37 +00002722 ROTMInst<(outs R32C:$rT), (ins R32C:$rA, R32C:$rB),
2723 [/* see patterns below - $rB must be negated */]>;
Scott Michel66377522007-12-04 22:35:58 +00002724
2725def : Pat<(srl R32C:$rA, R32C:$rB),
2726 (ROTMr32 R32C:$rA, (SFIr32 R32C:$rB, 0))>;
2727
2728def : Pat<(srl R32C:$rA, R16C:$rB),
2729 (ROTMr32 R32C:$rA,
2730 (SFIr32 (XSHWr16 R16C:$rB), 0))>;
2731
Scott Michel504c3692007-12-17 22:32:34 +00002732def : Pat<(srl R32C:$rA, R8C:$rB),
2733 (ROTMr32 R32C:$rA,
2734 (SFIr32 (XSHWr16 (XSBHr8 R8C:$rB)), 0))>;
2735
Scott Michel66377522007-12-04 22:35:58 +00002736// ROTMI v4i32 form: See the comment for ROTHM v8i16.
2737def ROTMIv4i32:
2738 RI7Form<0b10011110000, (outs VECREG:$rT), (ins VECREG:$rA, rotNeg7imm:$val),
2739 "rotmi\t$rT, $rA, $val", RotateShift,
2740 [(set (v4i32 VECREG:$rT),
Scott Michela59d4692008-02-23 18:41:37 +00002741 (SPUvec_srl VECREG:$rA, (i32 uimm7:$val)))]>;
Scott Michel66377522007-12-04 22:35:58 +00002742
Chris Lattner420c69d2010-03-15 05:53:47 +00002743def : Pat<(SPUvec_srl (v4i32 VECREG:$rA), (i16 uimm7:$val)),
2744 (ROTMIv4i32 VECREG:$rA, (TO_IMM32 uimm7:$val))>;
Scott Michelf0569be2008-12-27 04:51:36 +00002745
Chris Lattner420c69d2010-03-15 05:53:47 +00002746def : Pat<(SPUvec_srl (v4i32 VECREG:$rA), (i8 uimm7:$val)),
2747 (ROTMIv4i32 VECREG:$rA, (TO_IMM32 uimm7:$val))>;
Scott Michel66377522007-12-04 22:35:58 +00002748
2749// ROTMI r32 form: know how to complement the immediate value.
2750def ROTMIr32:
2751 RI7Form<0b10011110000, (outs R32C:$rT), (ins R32C:$rA, rotNeg7imm:$val),
2752 "rotmi\t$rT, $rA, $val", RotateShift,
2753 [(set R32C:$rT, (srl R32C:$rA, (i32 uimm7:$val)))]>;
2754
2755def : Pat<(srl R32C:$rA, (i16 imm:$val)),
Chris Lattner420c69d2010-03-15 05:53:47 +00002756 (ROTMIr32 R32C:$rA, (TO_IMM32 uimm7:$val))>;
Scott Michel66377522007-12-04 22:35:58 +00002757
Scott Michel504c3692007-12-17 22:32:34 +00002758def : Pat<(srl R32C:$rA, (i8 imm:$val)),
Chris Lattner420c69d2010-03-15 05:53:47 +00002759 (ROTMIr32 R32C:$rA, (TO_IMM32 uimm7:$val))>;
Scott Michel504c3692007-12-17 22:32:34 +00002760
Scott Michela59d4692008-02-23 18:41:37 +00002761//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
Scott Micheldd950092009-01-06 03:36:14 +00002762// ROTQMBY: This is a vector form merely so that when used in an
Scott Michel66377522007-12-04 22:35:58 +00002763// instruction pattern, type checking will succeed. This instruction assumes
Scott Michela59d4692008-02-23 18:41:37 +00002764// that the user knew to negate $rB.
Scott Michela59d4692008-02-23 18:41:37 +00002765//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
Scott Michel66377522007-12-04 22:35:58 +00002766
Scott Michela59d4692008-02-23 18:41:37 +00002767class ROTQMBYInst<dag OOL, dag IOL, list<dag> pattern>:
2768 RRForm<0b10111011100, OOL, IOL, "rotqmby\t$rT, $rA, $rB",
2769 RotateShift, pattern>;
Scott Michel66377522007-12-04 22:35:58 +00002770
Scott Michela59d4692008-02-23 18:41:37 +00002771class ROTQMBYVecInst<ValueType vectype>:
2772 ROTQMBYInst<(outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB),
2773 [/* no pattern, $rB must be negated */]>;
Scott Michel66377522007-12-04 22:35:58 +00002774
Scott Michela59d4692008-02-23 18:41:37 +00002775class ROTQMBYRegInst<RegisterClass rclass>:
2776 ROTQMBYInst<(outs rclass:$rT), (ins rclass:$rA, R32C:$rB),
Scott Michel02d711b2008-12-30 23:28:25 +00002777 [/* no pattern */]>;
Scott Michel66377522007-12-04 22:35:58 +00002778
Scott Michela59d4692008-02-23 18:41:37 +00002779multiclass RotateQuadBytes
2780{
2781 def v16i8: ROTQMBYVecInst<v16i8>;
2782 def v8i16: ROTQMBYVecInst<v8i16>;
2783 def v4i32: ROTQMBYVecInst<v4i32>;
2784 def v2i64: ROTQMBYVecInst<v2i64>;
Scott Michel66377522007-12-04 22:35:58 +00002785
Scott Michela59d4692008-02-23 18:41:37 +00002786 def r128: ROTQMBYRegInst<GPRC>;
2787 def r64: ROTQMBYRegInst<R64C>;
2788}
2789
2790defm ROTQMBY : RotateQuadBytes;
2791
Scott Michela59d4692008-02-23 18:41:37 +00002792class ROTQMBYIInst<dag OOL, dag IOL, list<dag> pattern>:
2793 RI7Form<0b10111111100, OOL, IOL, "rotqmbyi\t$rT, $rA, $val",
2794 RotateShift, pattern>;
2795
2796class ROTQMBYIVecInst<ValueType vectype>:
2797 ROTQMBYIInst<(outs VECREG:$rT), (ins VECREG:$rA, rotNeg7imm:$val),
Scott Michel02d711b2008-12-30 23:28:25 +00002798 [/* no pattern */]>;
Scott Michela59d4692008-02-23 18:41:37 +00002799
Scott Micheldd950092009-01-06 03:36:14 +00002800class ROTQMBYIRegInst<RegisterClass rclass, Operand optype, ValueType inttype,
2801 PatLeaf pred>:
Scott Michela59d4692008-02-23 18:41:37 +00002802 ROTQMBYIInst<(outs rclass:$rT), (ins rclass:$rA, optype:$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 +00002805// 128-bit zero extension form:
2806class ROTQMBYIZExtInst<RegisterClass rclass, Operand optype, PatLeaf pred>:
2807 ROTQMBYIInst<(outs GPRC:$rT), (ins rclass:$rA, optype:$val),
2808 [/* no pattern */]>;
2809
Scott Michela59d4692008-02-23 18:41:37 +00002810multiclass RotateQuadBytesImm
2811{
2812 def v16i8: ROTQMBYIVecInst<v16i8>;
2813 def v8i16: ROTQMBYIVecInst<v8i16>;
2814 def v4i32: ROTQMBYIVecInst<v4i32>;
2815 def v2i64: ROTQMBYIVecInst<v2i64>;
2816
2817 def r128: ROTQMBYIRegInst<GPRC, rotNeg7imm, i32, uimm7>;
2818 def r64: ROTQMBYIRegInst<R64C, rotNeg7imm, i32, uimm7>;
Scott Micheldd950092009-01-06 03:36:14 +00002819
2820 def r128_zext_r8: ROTQMBYIZExtInst<R8C, rotNeg7imm, uimm7>;
2821 def r128_zext_r16: ROTQMBYIZExtInst<R16C, rotNeg7imm, uimm7>;
2822 def r128_zext_r32: ROTQMBYIZExtInst<R32C, rotNeg7imm, uimm7>;
2823 def r128_zext_r64: ROTQMBYIZExtInst<R64C, rotNeg7imm, uimm7>;
Scott Michela59d4692008-02-23 18:41:37 +00002824}
2825
2826defm ROTQMBYI : RotateQuadBytesImm;
2827
Scott Michela59d4692008-02-23 18:41:37 +00002828//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2829// Rotate right and mask by bit count
2830//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2831
2832class ROTQMBYBIInst<dag OOL, dag IOL, list<dag> pattern>:
2833 RRForm<0b10110011100, OOL, IOL, "rotqmbybi\t$rT, $rA, $rB",
2834 RotateShift, pattern>;
2835
2836class ROTQMBYBIVecInst<ValueType vectype>:
Scott Michel02d711b2008-12-30 23:28:25 +00002837 ROTQMBYBIInst<(outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB),
2838 [/* no pattern, */]>;
Scott Michela59d4692008-02-23 18:41:37 +00002839
2840multiclass RotateMaskQuadByBitCount
2841{
2842 def v16i8: ROTQMBYBIVecInst<v16i8>;
2843 def v8i16: ROTQMBYBIVecInst<v8i16>;
2844 def v4i32: ROTQMBYBIVecInst<v4i32>;
2845 def v2i64: ROTQMBYBIVecInst<v2i64>;
2846}
2847
2848defm ROTQMBYBI: RotateMaskQuadByBitCount;
2849
2850//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2851// Rotate quad and mask by bits
2852// Note that the rotate amount has to be negated
2853//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2854
2855class ROTQMBIInst<dag OOL, dag IOL, list<dag> pattern>:
2856 RRForm<0b10011011100, OOL, IOL, "rotqmbi\t$rT, $rA, $rB",
2857 RotateShift, pattern>;
2858
2859class ROTQMBIVecInst<ValueType vectype>:
2860 ROTQMBIInst<(outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB),
2861 [/* no pattern */]>;
2862
2863class ROTQMBIRegInst<RegisterClass rclass>:
2864 ROTQMBIInst<(outs rclass:$rT), (ins rclass:$rA, R32C:$rB),
2865 [/* no pattern */]>;
2866
2867multiclass RotateMaskQuadByBits
2868{
2869 def v16i8: ROTQMBIVecInst<v16i8>;
2870 def v8i16: ROTQMBIVecInst<v8i16>;
2871 def v4i32: ROTQMBIVecInst<v4i32>;
2872 def v2i64: ROTQMBIVecInst<v2i64>;
2873
2874 def r128: ROTQMBIRegInst<GPRC>;
2875 def r64: ROTQMBIRegInst<R64C>;
2876}
2877
2878defm ROTQMBI: RotateMaskQuadByBits;
2879
Scott Michela59d4692008-02-23 18:41:37 +00002880//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2881// Rotate quad and mask by bits, immediate
2882//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2883
2884class ROTQMBIIInst<dag OOL, dag IOL, list<dag> pattern>:
2885 RI7Form<0b10011111100, OOL, IOL, "rotqmbii\t$rT, $rA, $val",
2886 RotateShift, pattern>;
2887
2888class ROTQMBIIVecInst<ValueType vectype>:
2889 ROTQMBIIInst<(outs VECREG:$rT), (ins VECREG:$rA, rotNeg7imm:$val),
Scott Michel02d711b2008-12-30 23:28:25 +00002890 [/* no pattern */]>;
Scott Michela59d4692008-02-23 18:41:37 +00002891
2892class ROTQMBIIRegInst<RegisterClass rclass>:
2893 ROTQMBIIInst<(outs rclass:$rT), (ins rclass:$rA, rotNeg7imm:$val),
Scott Michel02d711b2008-12-30 23:28:25 +00002894 [/* no pattern */]>;
Scott Michela59d4692008-02-23 18:41:37 +00002895
2896multiclass RotateMaskQuadByBitsImm
2897{
2898 def v16i8: ROTQMBIIVecInst<v16i8>;
2899 def v8i16: ROTQMBIIVecInst<v8i16>;
2900 def v4i32: ROTQMBIIVecInst<v4i32>;
2901 def v2i64: ROTQMBIIVecInst<v2i64>;
2902
2903 def r128: ROTQMBIIRegInst<GPRC>;
2904 def r64: ROTQMBIIRegInst<R64C>;
2905}
2906
2907defm ROTQMBII: RotateMaskQuadByBitsImm;
2908
2909//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2910//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
Scott Michel66377522007-12-04 22:35:58 +00002911
2912def ROTMAHv8i16:
2913 RRForm<0b01111010000, (outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB),
2914 "rotmah\t$rT, $rA, $rB", RotateShift,
2915 [/* see patterns below - $rB must be negated */]>;
2916
Chris Lattner420c69d2010-03-15 05:53:47 +00002917def : Pat<(SPUvec_sra (v8i16 VECREG:$rA), R32C:$rB),
Scott Michel66377522007-12-04 22:35:58 +00002918 (ROTMAHv8i16 VECREG:$rA, (SFIr32 R32C:$rB, 0))>;
2919
Chris Lattner420c69d2010-03-15 05:53:47 +00002920def : Pat<(SPUvec_sra (v8i16 VECREG:$rA), R16C:$rB),
Scott Michel66377522007-12-04 22:35:58 +00002921 (ROTMAHv8i16 VECREG:$rA,
2922 (SFIr32 (XSHWr16 R16C:$rB), 0))>;
2923
Chris Lattner420c69d2010-03-15 05:53:47 +00002924def : Pat<(SPUvec_sra (v8i16 VECREG:$rA), R8C:$rB),
Scott Michel504c3692007-12-17 22:32:34 +00002925 (ROTMAHv8i16 VECREG:$rA,
2926 (SFIr32 (XSHWr16 (XSBHr8 R8C:$rB)), 0))>;
2927
Scott Michel66377522007-12-04 22:35:58 +00002928def ROTMAHr16:
2929 RRForm<0b01111010000, (outs R16C:$rT), (ins R16C:$rA, R32C:$rB),
2930 "rotmah\t$rT, $rA, $rB", RotateShift,
2931 [/* see patterns below - $rB must be negated */]>;
2932
2933def : Pat<(sra R16C:$rA, R32C:$rB),
2934 (ROTMAHr16 R16C:$rA, (SFIr32 R32C:$rB, 0))>;
2935
2936def : Pat<(sra R16C:$rA, R16C:$rB),
2937 (ROTMAHr16 R16C:$rA,
2938 (SFIr32 (XSHWr16 R16C:$rB), 0))>;
2939
Scott Michel504c3692007-12-17 22:32:34 +00002940def : Pat<(sra R16C:$rA, R8C:$rB),
2941 (ROTMAHr16 R16C:$rA,
2942 (SFIr32 (XSHWr16 (XSBHr8 R8C:$rB)), 0))>;
2943
Scott Michel66377522007-12-04 22:35:58 +00002944def ROTMAHIv8i16:
2945 RRForm<0b01111110000, (outs VECREG:$rT), (ins VECREG:$rA, rothNeg7imm:$val),
2946 "rotmahi\t$rT, $rA, $val", RotateShift,
2947 [(set (v8i16 VECREG:$rT),
Scott Michela59d4692008-02-23 18:41:37 +00002948 (SPUvec_sra (v8i16 VECREG:$rA), (i32 uimm7:$val)))]>;
Scott Michel66377522007-12-04 22:35:58 +00002949
Scott Michela59d4692008-02-23 18:41:37 +00002950def : Pat<(SPUvec_sra (v8i16 VECREG:$rA), (i16 uimm7:$val)),
Chris Lattner420c69d2010-03-15 05:53:47 +00002951 (ROTMAHIv8i16 (v8i16 VECREG:$rA), (TO_IMM32 uimm7:$val))>;
Scott Michel66377522007-12-04 22:35:58 +00002952
Scott Michela59d4692008-02-23 18:41:37 +00002953def : Pat<(SPUvec_sra (v8i16 VECREG:$rA), (i8 uimm7:$val)),
Chris Lattner420c69d2010-03-15 05:53:47 +00002954 (ROTMAHIv8i16 (v8i16 VECREG:$rA), (TO_IMM32 uimm7:$val))>;
Scott Michel504c3692007-12-17 22:32:34 +00002955
Scott Michel66377522007-12-04 22:35:58 +00002956def ROTMAHIr16:
2957 RRForm<0b01111110000, (outs R16C:$rT), (ins R16C:$rA, rothNeg7imm_i16:$val),
2958 "rotmahi\t$rT, $rA, $val", RotateShift,
2959 [(set R16C:$rT, (sra R16C:$rA, (i16 uimm7:$val)))]>;
2960
2961def : Pat<(sra R16C:$rA, (i32 imm:$val)),
Chris Lattner420c69d2010-03-15 05:53:47 +00002962 (ROTMAHIr16 R16C:$rA, (TO_IMM32 uimm7:$val))>;
Scott Michel66377522007-12-04 22:35:58 +00002963
Scott Michel504c3692007-12-17 22:32:34 +00002964def : Pat<(sra R16C:$rA, (i8 imm:$val)),
Chris Lattner420c69d2010-03-15 05:53:47 +00002965 (ROTMAHIr16 R16C:$rA, (TO_IMM32 uimm7:$val))>;
Scott Michel504c3692007-12-17 22:32:34 +00002966
Scott Michel66377522007-12-04 22:35:58 +00002967def ROTMAv4i32:
2968 RRForm<0b01011010000, (outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB),
2969 "rotma\t$rT, $rA, $rB", RotateShift,
2970 [/* see patterns below - $rB must be negated */]>;
2971
Chris Lattner420c69d2010-03-15 05:53:47 +00002972def : Pat<(SPUvec_sra (v4i32 VECREG:$rA), R32C:$rB),
2973 (ROTMAv4i32 VECREG:$rA, (SFIr32 R32C:$rB, 0))>;
Scott Michel66377522007-12-04 22:35:58 +00002974
Chris Lattner420c69d2010-03-15 05:53:47 +00002975def : Pat<(SPUvec_sra (v4i32 VECREG:$rA), R16C:$rB),
2976 (ROTMAv4i32 VECREG:$rA,
Scott Michel66377522007-12-04 22:35:58 +00002977 (SFIr32 (XSHWr16 R16C:$rB), 0))>;
2978
Chris Lattner420c69d2010-03-15 05:53:47 +00002979def : Pat<(SPUvec_sra (v4i32 VECREG:$rA), R8C:$rB),
2980 (ROTMAv4i32 VECREG:$rA,
Scott Michel504c3692007-12-17 22:32:34 +00002981 (SFIr32 (XSHWr16 (XSBHr8 R8C:$rB)), 0))>;
2982
Scott Michel66377522007-12-04 22:35:58 +00002983def ROTMAr32:
2984 RRForm<0b01011010000, (outs R32C:$rT), (ins R32C:$rA, R32C:$rB),
2985 "rotma\t$rT, $rA, $rB", RotateShift,
2986 [/* see patterns below - $rB must be negated */]>;
2987
2988def : Pat<(sra R32C:$rA, R32C:$rB),
2989 (ROTMAr32 R32C:$rA, (SFIr32 R32C:$rB, 0))>;
2990
2991def : Pat<(sra R32C:$rA, R16C:$rB),
2992 (ROTMAr32 R32C:$rA,
2993 (SFIr32 (XSHWr16 R16C:$rB), 0))>;
2994
Scott Michel504c3692007-12-17 22:32:34 +00002995def : Pat<(sra R32C:$rA, R8C:$rB),
2996 (ROTMAr32 R32C:$rA,
2997 (SFIr32 (XSHWr16 (XSBHr8 R8C:$rB)), 0))>;
2998
Scott Michel8bf61e82008-06-02 22:18:03 +00002999class ROTMAIInst<dag OOL, dag IOL, list<dag> pattern>:
3000 RRForm<0b01011110000, OOL, IOL,
3001 "rotmai\t$rT, $rA, $val",
3002 RotateShift, pattern>;
Scott Michel66377522007-12-04 22:35:58 +00003003
Scott Michel8bf61e82008-06-02 22:18:03 +00003004class ROTMAIVecInst<ValueType vectype, Operand intop, ValueType inttype>:
3005 ROTMAIInst<(outs VECREG:$rT), (ins VECREG:$rA, intop:$val),
3006 [(set (vectype VECREG:$rT),
3007 (SPUvec_sra VECREG:$rA, (inttype uimm7:$val)))]>;
Scott Michel66377522007-12-04 22:35:58 +00003008
Scott Michel8bf61e82008-06-02 22:18:03 +00003009class ROTMAIRegInst<RegisterClass rclass, Operand intop, ValueType inttype>:
3010 ROTMAIInst<(outs rclass:$rT), (ins rclass:$rA, intop:$val),
3011 [(set rclass:$rT, (sra rclass:$rA, (inttype uimm7:$val)))]>;
Scott Michel66377522007-12-04 22:35:58 +00003012
Scott Michel8bf61e82008-06-02 22:18:03 +00003013multiclass RotateMaskAlgebraicImm {
3014 def v2i64_i32 : ROTMAIVecInst<v2i64, rotNeg7imm, i32>;
3015 def v4i32_i32 : ROTMAIVecInst<v4i32, rotNeg7imm, i32>;
3016 def r64_i32 : ROTMAIRegInst<R64C, rotNeg7imm, i32>;
3017 def r32_i32 : ROTMAIRegInst<R32C, rotNeg7imm, i32>;
3018}
Scott Michel66377522007-12-04 22:35:58 +00003019
Scott Michel8bf61e82008-06-02 22:18:03 +00003020defm ROTMAI : RotateMaskAlgebraicImm;
Scott Michel504c3692007-12-17 22:32:34 +00003021
Scott Michel66377522007-12-04 22:35:58 +00003022//===----------------------------------------------------------------------===//
3023// Branch and conditionals:
3024//===----------------------------------------------------------------------===//
3025
3026let isTerminator = 1, isBarrier = 1 in {
3027 // Halt If Equal (r32 preferred slot only, no vector form)
3028 def HEQr32:
3029 RRForm_3<0b00011011110, (outs), (ins R32C:$rA, R32C:$rB),
3030 "heq\t$rA, $rB", BranchResolv,
3031 [/* no pattern to match */]>;
3032
3033 def HEQIr32 :
3034 RI10Form_2<0b11111110, (outs), (ins R32C:$rA, s10imm:$val),
3035 "heqi\t$rA, $val", BranchResolv,
3036 [/* no pattern to match */]>;
3037
3038 // HGT/HGTI: These instructions use signed arithmetic for the comparison,
3039 // contrasting with HLGT/HLGTI, which use unsigned comparison:
3040 def HGTr32:
3041 RRForm_3<0b00011010010, (outs), (ins R32C:$rA, R32C:$rB),
3042 "hgt\t$rA, $rB", BranchResolv,
3043 [/* no pattern to match */]>;
3044
Scott Michelf0569be2008-12-27 04:51:36 +00003045 def HGTIr32:
Scott Michel66377522007-12-04 22:35:58 +00003046 RI10Form_2<0b11110010, (outs), (ins R32C:$rA, s10imm:$val),
3047 "hgti\t$rA, $val", BranchResolv,
3048 [/* no pattern to match */]>;
3049
3050 def HLGTr32:
3051 RRForm_3<0b00011011010, (outs), (ins R32C:$rA, R32C:$rB),
3052 "hlgt\t$rA, $rB", BranchResolv,
3053 [/* no pattern to match */]>;
3054
3055 def HLGTIr32:
3056 RI10Form_2<0b11111010, (outs), (ins R32C:$rA, s10imm:$val),
3057 "hlgti\t$rA, $val", BranchResolv,
3058 [/* no pattern to match */]>;
3059}
3060
Scott Michelf0569be2008-12-27 04:51:36 +00003061//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
3062// Comparison operators for i8, i16 and i32:
3063//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
Scott Michel66377522007-12-04 22:35:58 +00003064
Scott Michela59d4692008-02-23 18:41:37 +00003065class CEQBInst<dag OOL, dag IOL, list<dag> pattern> :
3066 RRForm<0b00001011110, OOL, IOL, "ceqb\t$rT, $rA, $rB",
3067 ByteOp, pattern>;
Scott Michel66377522007-12-04 22:35:58 +00003068
Scott Michela59d4692008-02-23 18:41:37 +00003069multiclass CmpEqualByte
3070{
3071 def v16i8 :
3072 CEQBInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
3073 [(set (v16i8 VECREG:$rT), (seteq (v8i16 VECREG:$rA),
3074 (v8i16 VECREG:$rB)))]>;
Scott Michel504c3692007-12-17 22:32:34 +00003075
Scott Michela59d4692008-02-23 18:41:37 +00003076 def r8 :
3077 CEQBInst<(outs R8C:$rT), (ins R8C:$rA, R8C:$rB),
3078 [(set R8C:$rT, (seteq R8C:$rA, R8C:$rB))]>;
3079}
Scott Michel66377522007-12-04 22:35:58 +00003080
Scott Michela59d4692008-02-23 18:41:37 +00003081class CEQBIInst<dag OOL, dag IOL, list<dag> pattern> :
3082 RI10Form<0b01111110, OOL, IOL, "ceqbi\t$rT, $rA, $val",
3083 ByteOp, pattern>;
Scott Michel66377522007-12-04 22:35:58 +00003084
Scott Michela59d4692008-02-23 18:41:37 +00003085multiclass CmpEqualByteImm
3086{
3087 def v16i8 :
3088 CEQBIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm_i8:$val),
3089 [(set (v16i8 VECREG:$rT), (seteq (v16i8 VECREG:$rA),
3090 v16i8SExt8Imm:$val))]>;
3091 def r8:
3092 CEQBIInst<(outs R8C:$rT), (ins R8C:$rA, s10imm_i8:$val),
3093 [(set R8C:$rT, (seteq R8C:$rA, immSExt8:$val))]>;
3094}
Scott Michel66377522007-12-04 22:35:58 +00003095
Scott Michela59d4692008-02-23 18:41:37 +00003096class CEQHInst<dag OOL, dag IOL, list<dag> pattern> :
3097 RRForm<0b00010011110, OOL, IOL, "ceqh\t$rT, $rA, $rB",
3098 ByteOp, pattern>;
Scott Michel66377522007-12-04 22:35:58 +00003099
Scott Michela59d4692008-02-23 18:41:37 +00003100multiclass CmpEqualHalfword
3101{
3102 def v8i16 : CEQHInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
3103 [(set (v8i16 VECREG:$rT), (seteq (v8i16 VECREG:$rA),
3104 (v8i16 VECREG:$rB)))]>;
Scott Michel66377522007-12-04 22:35:58 +00003105
Scott Michela59d4692008-02-23 18:41:37 +00003106 def r16 : CEQHInst<(outs R16C:$rT), (ins R16C:$rA, R16C:$rB),
3107 [(set R16C:$rT, (seteq R16C:$rA, R16C:$rB))]>;
3108}
Scott Michel66377522007-12-04 22:35:58 +00003109
Scott Michela59d4692008-02-23 18:41:37 +00003110class CEQHIInst<dag OOL, dag IOL, list<dag> pattern> :
3111 RI10Form<0b10111110, OOL, IOL, "ceqhi\t$rT, $rA, $val",
3112 ByteOp, pattern>;
Scott Michel66377522007-12-04 22:35:58 +00003113
Scott Michela59d4692008-02-23 18:41:37 +00003114multiclass CmpEqualHalfwordImm
3115{
3116 def v8i16 : CEQHIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
3117 [(set (v8i16 VECREG:$rT),
3118 (seteq (v8i16 VECREG:$rA),
3119 (v8i16 v8i16SExt10Imm:$val)))]>;
3120 def r16 : CEQHIInst<(outs R16C:$rT), (ins R16C:$rA, s10imm:$val),
3121 [(set R16C:$rT, (seteq R16C:$rA, i16ImmSExt10:$val))]>;
3122}
Scott Michel66377522007-12-04 22:35:58 +00003123
Scott Michela59d4692008-02-23 18:41:37 +00003124class CEQInst<dag OOL, dag IOL, list<dag> pattern> :
3125 RRForm<0b00000011110, OOL, IOL, "ceq\t$rT, $rA, $rB",
3126 ByteOp, pattern>;
3127
3128multiclass CmpEqualWord
3129{
3130 def v4i32 : CEQInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
3131 [(set (v4i32 VECREG:$rT),
3132 (seteq (v4i32 VECREG:$rA), (v4i32 VECREG:$rB)))]>;
3133
3134 def r32 : CEQInst<(outs R32C:$rT), (ins R32C:$rA, R32C:$rB),
3135 [(set R32C:$rT, (seteq R32C:$rA, R32C:$rB))]>;
3136}
3137
3138class CEQIInst<dag OOL, dag IOL, list<dag> pattern> :
3139 RI10Form<0b00111110, OOL, IOL, "ceqi\t$rT, $rA, $val",
3140 ByteOp, pattern>;
3141
3142multiclass CmpEqualWordImm
3143{
3144 def v4i32 : CEQIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
3145 [(set (v4i32 VECREG:$rT),
3146 (seteq (v4i32 VECREG:$rA),
3147 (v4i32 v4i32SExt16Imm:$val)))]>;
3148
3149 def r32: CEQIInst<(outs R32C:$rT), (ins R32C:$rA, s10imm_i32:$val),
3150 [(set R32C:$rT, (seteq R32C:$rA, i32ImmSExt10:$val))]>;
3151}
3152
3153class CGTBInst<dag OOL, dag IOL, list<dag> pattern> :
3154 RRForm<0b00001010010, OOL, IOL, "cgtb\t$rT, $rA, $rB",
3155 ByteOp, pattern>;
3156
3157multiclass CmpGtrByte
3158{
3159 def v16i8 :
3160 CGTBInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
3161 [(set (v16i8 VECREG:$rT), (setgt (v8i16 VECREG:$rA),
3162 (v8i16 VECREG:$rB)))]>;
3163
3164 def r8 :
3165 CGTBInst<(outs R8C:$rT), (ins R8C:$rA, R8C:$rB),
3166 [(set R8C:$rT, (setgt R8C:$rA, R8C:$rB))]>;
3167}
3168
3169class CGTBIInst<dag OOL, dag IOL, list<dag> pattern> :
3170 RI10Form<0b01110010, OOL, IOL, "cgtbi\t$rT, $rA, $val",
3171 ByteOp, pattern>;
3172
3173multiclass CmpGtrByteImm
3174{
3175 def v16i8 :
3176 CGTBIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm_i8:$val),
3177 [(set (v16i8 VECREG:$rT), (setgt (v16i8 VECREG:$rA),
3178 v16i8SExt8Imm:$val))]>;
3179 def r8:
3180 CGTBIInst<(outs R8C:$rT), (ins R8C:$rA, s10imm_i8:$val),
Scott Michel79698f62008-03-20 00:51:36 +00003181 [(set R8C:$rT, (setgt R8C:$rA, immSExt8:$val))]>;
Scott Michela59d4692008-02-23 18:41:37 +00003182}
3183
3184class CGTHInst<dag OOL, dag IOL, list<dag> pattern> :
3185 RRForm<0b00010010010, OOL, IOL, "cgth\t$rT, $rA, $rB",
3186 ByteOp, pattern>;
3187
3188multiclass CmpGtrHalfword
3189{
3190 def v8i16 : CGTHInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
3191 [(set (v8i16 VECREG:$rT), (setgt (v8i16 VECREG:$rA),
3192 (v8i16 VECREG:$rB)))]>;
3193
3194 def r16 : CGTHInst<(outs R16C:$rT), (ins R16C:$rA, R16C:$rB),
3195 [(set R16C:$rT, (setgt R16C:$rA, R16C:$rB))]>;
3196}
3197
3198class CGTHIInst<dag OOL, dag IOL, list<dag> pattern> :
3199 RI10Form<0b10110010, OOL, IOL, "cgthi\t$rT, $rA, $val",
3200 ByteOp, pattern>;
3201
3202multiclass CmpGtrHalfwordImm
3203{
3204 def v8i16 : CGTHIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
3205 [(set (v8i16 VECREG:$rT),
3206 (setgt (v8i16 VECREG:$rA),
3207 (v8i16 v8i16SExt10Imm:$val)))]>;
3208 def r16 : CGTHIInst<(outs R16C:$rT), (ins R16C:$rA, s10imm:$val),
3209 [(set R16C:$rT, (setgt R16C:$rA, i16ImmSExt10:$val))]>;
3210}
3211
3212class CGTInst<dag OOL, dag IOL, list<dag> pattern> :
3213 RRForm<0b00000010010, OOL, IOL, "cgt\t$rT, $rA, $rB",
3214 ByteOp, pattern>;
3215
3216multiclass CmpGtrWord
3217{
3218 def v4i32 : CGTInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
3219 [(set (v4i32 VECREG:$rT),
3220 (setgt (v4i32 VECREG:$rA), (v4i32 VECREG:$rB)))]>;
3221
3222 def r32 : CGTInst<(outs R32C:$rT), (ins R32C:$rA, R32C:$rB),
3223 [(set R32C:$rT, (setgt R32C:$rA, R32C:$rB))]>;
3224}
3225
3226class CGTIInst<dag OOL, dag IOL, list<dag> pattern> :
3227 RI10Form<0b00110010, OOL, IOL, "cgti\t$rT, $rA, $val",
3228 ByteOp, pattern>;
3229
3230multiclass CmpGtrWordImm
3231{
3232 def v4i32 : CGTIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
3233 [(set (v4i32 VECREG:$rT),
3234 (setgt (v4i32 VECREG:$rA),
3235 (v4i32 v4i32SExt16Imm:$val)))]>;
3236
3237 def r32: CGTIInst<(outs R32C:$rT), (ins R32C:$rA, s10imm_i32:$val),
3238 [(set R32C:$rT, (setgt R32C:$rA, i32ImmSExt10:$val))]>;
Scott Michel02d711b2008-12-30 23:28:25 +00003239
3240 // CGTIv4f32, CGTIf32: These are used in the f32 fdiv instruction sequence:
3241 def v4f32: CGTIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
3242 [(set (v4i32 VECREG:$rT),
3243 (setgt (v4i32 (bitconvert (v4f32 VECREG:$rA))),
3244 (v4i32 v4i32SExt16Imm:$val)))]>;
3245
3246 def f32: CGTIInst<(outs R32C:$rT), (ins R32FP:$rA, s10imm_i32:$val),
Scott Michel19c10e62009-01-26 03:37:41 +00003247 [/* no pattern */]>;
Scott Michela59d4692008-02-23 18:41:37 +00003248}
3249
3250class CLGTBInst<dag OOL, dag IOL, list<dag> pattern> :
Scott Michelad2715e2008-03-05 23:02:02 +00003251 RRForm<0b00001011010, OOL, IOL, "clgtb\t$rT, $rA, $rB",
Scott Michela59d4692008-02-23 18:41:37 +00003252 ByteOp, pattern>;
3253
3254multiclass CmpLGtrByte
3255{
3256 def v16i8 :
3257 CLGTBInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
3258 [(set (v16i8 VECREG:$rT), (setugt (v8i16 VECREG:$rA),
3259 (v8i16 VECREG:$rB)))]>;
3260
3261 def r8 :
3262 CLGTBInst<(outs R8C:$rT), (ins R8C:$rA, R8C:$rB),
3263 [(set R8C:$rT, (setugt R8C:$rA, R8C:$rB))]>;
3264}
3265
3266class CLGTBIInst<dag OOL, dag IOL, list<dag> pattern> :
Scott Michelad2715e2008-03-05 23:02:02 +00003267 RI10Form<0b01111010, OOL, IOL, "clgtbi\t$rT, $rA, $val",
Scott Michela59d4692008-02-23 18:41:37 +00003268 ByteOp, pattern>;
3269
3270multiclass CmpLGtrByteImm
3271{
3272 def v16i8 :
3273 CLGTBIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm_i8:$val),
3274 [(set (v16i8 VECREG:$rT), (setugt (v16i8 VECREG:$rA),
3275 v16i8SExt8Imm:$val))]>;
3276 def r8:
3277 CLGTBIInst<(outs R8C:$rT), (ins R8C:$rA, s10imm_i8:$val),
3278 [(set R8C:$rT, (setugt R8C:$rA, immSExt8:$val))]>;
3279}
3280
3281class CLGTHInst<dag OOL, dag IOL, list<dag> pattern> :
Scott Michelad2715e2008-03-05 23:02:02 +00003282 RRForm<0b00010011010, OOL, IOL, "clgth\t$rT, $rA, $rB",
Scott Michela59d4692008-02-23 18:41:37 +00003283 ByteOp, pattern>;
3284
3285multiclass CmpLGtrHalfword
3286{
3287 def v8i16 : CLGTHInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
3288 [(set (v8i16 VECREG:$rT), (setugt (v8i16 VECREG:$rA),
3289 (v8i16 VECREG:$rB)))]>;
3290
3291 def r16 : CLGTHInst<(outs R16C:$rT), (ins R16C:$rA, R16C:$rB),
3292 [(set R16C:$rT, (setugt R16C:$rA, R16C:$rB))]>;
3293}
3294
3295class CLGTHIInst<dag OOL, dag IOL, list<dag> pattern> :
Scott Michelad2715e2008-03-05 23:02:02 +00003296 RI10Form<0b10111010, OOL, IOL, "clgthi\t$rT, $rA, $val",
Scott Michela59d4692008-02-23 18:41:37 +00003297 ByteOp, pattern>;
3298
3299multiclass CmpLGtrHalfwordImm
3300{
3301 def v8i16 : CLGTHIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
3302 [(set (v8i16 VECREG:$rT),
3303 (setugt (v8i16 VECREG:$rA),
3304 (v8i16 v8i16SExt10Imm:$val)))]>;
3305 def r16 : CLGTHIInst<(outs R16C:$rT), (ins R16C:$rA, s10imm:$val),
3306 [(set R16C:$rT, (setugt R16C:$rA, i16ImmSExt10:$val))]>;
3307}
3308
3309class CLGTInst<dag OOL, dag IOL, list<dag> pattern> :
Scott Michelad2715e2008-03-05 23:02:02 +00003310 RRForm<0b00000011010, OOL, IOL, "clgt\t$rT, $rA, $rB",
Scott Michela59d4692008-02-23 18:41:37 +00003311 ByteOp, pattern>;
3312
3313multiclass CmpLGtrWord
3314{
3315 def v4i32 : CLGTInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
3316 [(set (v4i32 VECREG:$rT),
3317 (setugt (v4i32 VECREG:$rA), (v4i32 VECREG:$rB)))]>;
3318
3319 def r32 : CLGTInst<(outs R32C:$rT), (ins R32C:$rA, R32C:$rB),
3320 [(set R32C:$rT, (setugt R32C:$rA, R32C:$rB))]>;
3321}
3322
3323class CLGTIInst<dag OOL, dag IOL, list<dag> pattern> :
Scott Michelad2715e2008-03-05 23:02:02 +00003324 RI10Form<0b00111010, OOL, IOL, "clgti\t$rT, $rA, $val",
Scott Michela59d4692008-02-23 18:41:37 +00003325 ByteOp, pattern>;
3326
3327multiclass CmpLGtrWordImm
3328{
3329 def v4i32 : CLGTIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
3330 [(set (v4i32 VECREG:$rT),
3331 (setugt (v4i32 VECREG:$rA),
3332 (v4i32 v4i32SExt16Imm:$val)))]>;
3333
3334 def r32: CLGTIInst<(outs R32C:$rT), (ins R32C:$rA, s10imm_i32:$val),
Scott Michelad2715e2008-03-05 23:02:02 +00003335 [(set R32C:$rT, (setugt R32C:$rA, i32ImmSExt10:$val))]>;
Scott Michela59d4692008-02-23 18:41:37 +00003336}
3337
3338defm CEQB : CmpEqualByte;
3339defm CEQBI : CmpEqualByteImm;
3340defm CEQH : CmpEqualHalfword;
3341defm CEQHI : CmpEqualHalfwordImm;
3342defm CEQ : CmpEqualWord;
3343defm CEQI : CmpEqualWordImm;
3344defm CGTB : CmpGtrByte;
3345defm CGTBI : CmpGtrByteImm;
3346defm CGTH : CmpGtrHalfword;
3347defm CGTHI : CmpGtrHalfwordImm;
3348defm CGT : CmpGtrWord;
3349defm CGTI : CmpGtrWordImm;
3350defm CLGTB : CmpLGtrByte;
3351defm CLGTBI : CmpLGtrByteImm;
3352defm CLGTH : CmpLGtrHalfword;
3353defm CLGTHI : CmpLGtrHalfwordImm;
3354defm CLGT : CmpLGtrWord;
3355defm CLGTI : CmpLGtrWordImm;
3356
Scott Michel78c47fa2008-03-10 16:58:52 +00003357//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
Scott Michela59d4692008-02-23 18:41:37 +00003358// For SETCC primitives not supported above (setlt, setle, setge, etc.)
3359// define a pattern to generate the right code, as a binary operator
3360// (in a manner of speaking.)
Scott Michel78c47fa2008-03-10 16:58:52 +00003361//
Scott Michelf0569be2008-12-27 04:51:36 +00003362// Notes:
3363// 1. This only matches the setcc set of conditionals. Special pattern
3364// matching is used for select conditionals.
3365//
3366// 2. The "DAG" versions of these classes is almost exclusively used for
3367// i64 comparisons. See the tblgen fundamentals documentation for what
3368// ".ResultInstrs[0]" means; see TargetSelectionDAG.td and the Pattern
3369// class for where ResultInstrs originates.
Scott Michel78c47fa2008-03-10 16:58:52 +00003370//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
Scott Michela59d4692008-02-23 18:41:37 +00003371
Scott Michel78c47fa2008-03-10 16:58:52 +00003372class SETCCNegCondReg<PatFrag cond, RegisterClass rclass, ValueType inttype,
3373 SPUInstr xorinst, SPUInstr cmpare>:
3374 Pat<(cond rclass:$rA, rclass:$rB),
3375 (xorinst (cmpare rclass:$rA, rclass:$rB), (inttype -1))>;
3376
3377class SETCCNegCondImm<PatFrag cond, RegisterClass rclass, ValueType inttype,
3378 PatLeaf immpred, SPUInstr xorinst, SPUInstr cmpare>:
3379 Pat<(cond rclass:$rA, (inttype immpred:$imm)),
3380 (xorinst (cmpare rclass:$rA, (inttype immpred:$imm)), (inttype -1))>;
3381
Scott Michelf0569be2008-12-27 04:51:36 +00003382def : SETCCNegCondReg<setne, R8C, i8, XORBIr8, CEQBr8>;
Scott Michel78c47fa2008-03-10 16:58:52 +00003383def : SETCCNegCondImm<setne, R8C, i8, immSExt8, XORBIr8, CEQBIr8>;
3384
Scott Michelf0569be2008-12-27 04:51:36 +00003385def : SETCCNegCondReg<setne, R16C, i16, XORHIr16, CEQHr16>;
Scott Michel78c47fa2008-03-10 16:58:52 +00003386def : SETCCNegCondImm<setne, R16C, i16, i16ImmSExt10, XORHIr16, CEQHIr16>;
3387
3388def : SETCCNegCondReg<setne, R32C, i32, XORIr32, CEQr32>;
3389def : SETCCNegCondImm<setne, R32C, i32, i32ImmSExt10, XORIr32, CEQIr32>;
Scott Michela59d4692008-02-23 18:41:37 +00003390
3391class SETCCBinOpReg<PatFrag cond, RegisterClass rclass,
3392 SPUInstr binop, SPUInstr cmpOp1, SPUInstr cmpOp2>:
3393 Pat<(cond rclass:$rA, rclass:$rB),
3394 (binop (cmpOp1 rclass:$rA, rclass:$rB),
3395 (cmpOp2 rclass:$rA, rclass:$rB))>;
3396
3397class SETCCBinOpImm<PatFrag cond, RegisterClass rclass, PatLeaf immpred,
3398 ValueType immtype,
3399 SPUInstr binop, SPUInstr cmpOp1, SPUInstr cmpOp2>:
3400 Pat<(cond rclass:$rA, (immtype immpred:$imm)),
3401 (binop (cmpOp1 rclass:$rA, (immtype immpred:$imm)),
3402 (cmpOp2 rclass:$rA, (immtype immpred:$imm)))>;
3403
Scott Michel78c47fa2008-03-10 16:58:52 +00003404def : SETCCBinOpReg<setge, R8C, ORr8, CGTBr8, CEQBr8>;
3405def : SETCCBinOpImm<setge, R8C, immSExt8, i8, ORr8, CGTBIr8, CEQBIr8>;
3406def : SETCCBinOpReg<setlt, R8C, NORr8, CGTBr8, CEQBr8>;
3407def : SETCCBinOpImm<setlt, R8C, immSExt8, i8, NORr8, CGTBIr8, CEQBIr8>;
3408def : Pat<(setle R8C:$rA, R8C:$rB),
3409 (XORBIr8 (CGTBr8 R8C:$rA, R8C:$rB), 0xff)>;
3410def : Pat<(setle R8C:$rA, immU8:$imm),
3411 (XORBIr8 (CGTBIr8 R8C:$rA, immU8:$imm), 0xff)>;
Scott Michela59d4692008-02-23 18:41:37 +00003412
Scott Michel78c47fa2008-03-10 16:58:52 +00003413def : SETCCBinOpReg<setge, R16C, ORr16, CGTHr16, CEQHr16>;
3414def : SETCCBinOpImm<setge, R16C, i16ImmSExt10, i16,
3415 ORr16, CGTHIr16, CEQHIr16>;
3416def : SETCCBinOpReg<setlt, R16C, NORr16, CGTHr16, CEQHr16>;
3417def : SETCCBinOpImm<setlt, R16C, i16ImmSExt10, i16, NORr16, CGTHIr16, CEQHIr16>;
3418def : Pat<(setle R16C:$rA, R16C:$rB),
3419 (XORHIr16 (CGTHr16 R16C:$rA, R16C:$rB), 0xffff)>;
3420def : Pat<(setle R16C:$rA, i16ImmSExt10:$imm),
3421 (XORHIr16 (CGTHIr16 R16C:$rA, i16ImmSExt10:$imm), 0xffff)>;
Scott Michela59d4692008-02-23 18:41:37 +00003422
Scott Michel78c47fa2008-03-10 16:58:52 +00003423def : SETCCBinOpReg<setge, R32C, ORr32, CGTr32, CEQr32>;
3424def : SETCCBinOpImm<setge, R32C, i32ImmSExt10, i32,
3425 ORr32, CGTIr32, CEQIr32>;
3426def : SETCCBinOpReg<setlt, R32C, NORr32, CGTr32, CEQr32>;
3427def : SETCCBinOpImm<setlt, R32C, i32ImmSExt10, i32, NORr32, CGTIr32, CEQIr32>;
3428def : Pat<(setle R32C:$rA, R32C:$rB),
3429 (XORIr32 (CGTr32 R32C:$rA, R32C:$rB), 0xffffffff)>;
3430def : Pat<(setle R32C:$rA, i32ImmSExt10:$imm),
3431 (XORIr32 (CGTIr32 R32C:$rA, i32ImmSExt10:$imm), 0xffffffff)>;
Scott Michela59d4692008-02-23 18:41:37 +00003432
Scott Michel78c47fa2008-03-10 16:58:52 +00003433def : SETCCBinOpReg<setuge, R8C, ORr8, CLGTBr8, CEQBr8>;
3434def : SETCCBinOpImm<setuge, R8C, immSExt8, i8, ORr8, CLGTBIr8, CEQBIr8>;
3435def : SETCCBinOpReg<setult, R8C, NORr8, CLGTBr8, CEQBr8>;
3436def : SETCCBinOpImm<setult, R8C, immSExt8, i8, NORr8, CLGTBIr8, CEQBIr8>;
3437def : Pat<(setule R8C:$rA, R8C:$rB),
3438 (XORBIr8 (CLGTBr8 R8C:$rA, R8C:$rB), 0xff)>;
3439def : Pat<(setule R8C:$rA, immU8:$imm),
3440 (XORBIr8 (CLGTBIr8 R8C:$rA, immU8:$imm), 0xff)>;
Scott Michela59d4692008-02-23 18:41:37 +00003441
Scott Michel78c47fa2008-03-10 16:58:52 +00003442def : SETCCBinOpReg<setuge, R16C, ORr16, CLGTHr16, CEQHr16>;
3443def : SETCCBinOpImm<setuge, R16C, i16ImmSExt10, i16,
3444 ORr16, CLGTHIr16, CEQHIr16>;
3445def : SETCCBinOpReg<setult, R16C, NORr16, CLGTHr16, CEQHr16>;
3446def : SETCCBinOpImm<setult, R16C, i16ImmSExt10, i16, NORr16,
3447 CLGTHIr16, CEQHIr16>;
3448def : Pat<(setule R16C:$rA, R16C:$rB),
3449 (XORHIr16 (CLGTHr16 R16C:$rA, R16C:$rB), 0xffff)>;
Scott Michel79698f62008-03-20 00:51:36 +00003450def : Pat<(setule R16C:$rA, i16ImmSExt10:$imm),
Scott Michel78c47fa2008-03-10 16:58:52 +00003451 (XORHIr16 (CLGTHIr16 R16C:$rA, i16ImmSExt10:$imm), 0xffff)>;
Scott Michela59d4692008-02-23 18:41:37 +00003452
Scott Michel78c47fa2008-03-10 16:58:52 +00003453def : SETCCBinOpReg<setuge, R32C, ORr32, CLGTr32, CEQr32>;
Scott Michel79698f62008-03-20 00:51:36 +00003454def : SETCCBinOpImm<setuge, R32C, i32ImmSExt10, i32,
Scott Michel78c47fa2008-03-10 16:58:52 +00003455 ORr32, CLGTIr32, CEQIr32>;
3456def : SETCCBinOpReg<setult, R32C, NORr32, CLGTr32, CEQr32>;
Scott Michel79698f62008-03-20 00:51:36 +00003457def : SETCCBinOpImm<setult, R32C, i32ImmSExt10, i32, NORr32, CLGTIr32, CEQIr32>;
Scott Michel78c47fa2008-03-10 16:58:52 +00003458def : Pat<(setule R32C:$rA, R32C:$rB),
3459 (XORIr32 (CLGTr32 R32C:$rA, R32C:$rB), 0xffffffff)>;
3460def : Pat<(setule R32C:$rA, i32ImmSExt10:$imm),
3461 (XORIr32 (CLGTIr32 R32C:$rA, i32ImmSExt10:$imm), 0xffffffff)>;
Scott Michela59d4692008-02-23 18:41:37 +00003462
Scott Michel78c47fa2008-03-10 16:58:52 +00003463//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
3464// select conditional patterns:
3465//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
3466
3467class SELECTNegCondReg<PatFrag cond, RegisterClass rclass, ValueType inttype,
3468 SPUInstr selinstr, SPUInstr cmpare>:
3469 Pat<(select (inttype (cond rclass:$rA, rclass:$rB)),
3470 rclass:$rTrue, rclass:$rFalse),
3471 (selinstr rclass:$rTrue, rclass:$rFalse,
Bill Wendlingbbf2e062008-07-22 08:50:44 +00003472 (cmpare rclass:$rA, rclass:$rB))>;
Scott Michel78c47fa2008-03-10 16:58:52 +00003473
3474class SELECTNegCondImm<PatFrag cond, RegisterClass rclass, ValueType inttype,
3475 PatLeaf immpred, SPUInstr selinstr, SPUInstr cmpare>:
3476 Pat<(select (inttype (cond rclass:$rA, immpred:$imm)),
Bill Wendlingbbf2e062008-07-22 08:50:44 +00003477 rclass:$rTrue, rclass:$rFalse),
Scott Michel78c47fa2008-03-10 16:58:52 +00003478 (selinstr rclass:$rTrue, rclass:$rFalse,
3479 (cmpare rclass:$rA, immpred:$imm))>;
3480
3481def : SELECTNegCondReg<setne, R8C, i8, SELBr8, CEQBr8>;
3482def : SELECTNegCondImm<setne, R8C, i8, immSExt8, SELBr8, CEQBIr8>;
3483def : SELECTNegCondReg<setle, R8C, i8, SELBr8, CGTBr8>;
3484def : SELECTNegCondImm<setle, R8C, i8, immSExt8, SELBr8, CGTBr8>;
3485def : SELECTNegCondReg<setule, R8C, i8, SELBr8, CLGTBr8>;
3486def : SELECTNegCondImm<setule, R8C, i8, immU8, SELBr8, CLGTBIr8>;
3487
3488def : SELECTNegCondReg<setne, R16C, i16, SELBr16, CEQHr16>;
3489def : SELECTNegCondImm<setne, R16C, i16, i16ImmSExt10, SELBr16, CEQHIr16>;
3490def : SELECTNegCondReg<setle, R16C, i16, SELBr16, CGTHr16>;
3491def : SELECTNegCondImm<setle, R16C, i16, i16ImmSExt10, SELBr16, CGTHIr16>;
3492def : SELECTNegCondReg<setule, R16C, i16, SELBr16, CLGTHr16>;
3493def : SELECTNegCondImm<setule, R16C, i16, i16ImmSExt10, SELBr16, CLGTHIr16>;
3494
3495def : SELECTNegCondReg<setne, R32C, i32, SELBr32, CEQr32>;
3496def : SELECTNegCondImm<setne, R32C, i32, i32ImmSExt10, SELBr32, CEQIr32>;
3497def : SELECTNegCondReg<setle, R32C, i32, SELBr32, CGTr32>;
3498def : SELECTNegCondImm<setle, R32C, i32, i32ImmSExt10, SELBr32, CGTIr32>;
3499def : SELECTNegCondReg<setule, R32C, i32, SELBr32, CLGTr32>;
3500def : SELECTNegCondImm<setule, R32C, i32, i32ImmSExt10, SELBr32, CLGTIr32>;
3501
3502class SELECTBinOpReg<PatFrag cond, RegisterClass rclass, ValueType inttype,
3503 SPUInstr selinstr, SPUInstr binop, SPUInstr cmpOp1,
3504 SPUInstr cmpOp2>:
3505 Pat<(select (inttype (cond rclass:$rA, rclass:$rB)),
Scott Michelf0569be2008-12-27 04:51:36 +00003506 rclass:$rTrue, rclass:$rFalse),
3507 (selinstr rclass:$rFalse, rclass:$rTrue,
Scott Michel78c47fa2008-03-10 16:58:52 +00003508 (binop (cmpOp1 rclass:$rA, rclass:$rB),
3509 (cmpOp2 rclass:$rA, rclass:$rB)))>;
3510
3511class SELECTBinOpImm<PatFrag cond, RegisterClass rclass, PatLeaf immpred,
3512 ValueType inttype,
3513 SPUInstr selinstr, SPUInstr binop, SPUInstr cmpOp1,
3514 SPUInstr cmpOp2>:
3515 Pat<(select (inttype (cond rclass:$rA, (inttype immpred:$imm))),
Bill Wendlingbbf2e062008-07-22 08:50:44 +00003516 rclass:$rTrue, rclass:$rFalse),
Scott Michel78c47fa2008-03-10 16:58:52 +00003517 (selinstr rclass:$rFalse, rclass:$rTrue,
3518 (binop (cmpOp1 rclass:$rA, (inttype immpred:$imm)),
3519 (cmpOp2 rclass:$rA, (inttype immpred:$imm))))>;
3520
3521def : SELECTBinOpReg<setge, R8C, i8, SELBr8, ORr8, CGTBr8, CEQBr8>;
3522def : SELECTBinOpImm<setge, R8C, immSExt8, i8,
3523 SELBr8, ORr8, CGTBIr8, CEQBIr8>;
3524
3525def : SELECTBinOpReg<setge, R16C, i16, SELBr16, ORr16, CGTHr16, CEQHr16>;
3526def : SELECTBinOpImm<setge, R16C, i16ImmSExt10, i16,
3527 SELBr16, ORr16, CGTHIr16, CEQHIr16>;
3528
3529def : SELECTBinOpReg<setge, R32C, i32, SELBr32, ORr32, CGTr32, CEQr32>;
3530def : SELECTBinOpImm<setge, R32C, i32ImmSExt10, i32,
3531 SELBr32, ORr32, CGTIr32, CEQIr32>;
3532
3533def : SELECTBinOpReg<setuge, R8C, i8, SELBr8, ORr8, CLGTBr8, CEQBr8>;
3534def : SELECTBinOpImm<setuge, R8C, immSExt8, i8,
3535 SELBr8, ORr8, CLGTBIr8, CEQBIr8>;
3536
3537def : SELECTBinOpReg<setuge, R16C, i16, SELBr16, ORr16, CLGTHr16, CEQHr16>;
3538def : SELECTBinOpImm<setuge, R16C, i16ImmUns10, i16,
3539 SELBr16, ORr16, CLGTHIr16, CEQHIr16>;
3540
3541def : SELECTBinOpReg<setuge, R32C, i32, SELBr32, ORr32, CLGTr32, CEQr32>;
3542def : SELECTBinOpImm<setuge, R32C, i32ImmUns10, i32,
3543 SELBr32, ORr32, CLGTIr32, CEQIr32>;
Scott Michela59d4692008-02-23 18:41:37 +00003544
3545//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
Scott Michel66377522007-12-04 22:35:58 +00003546
3547let isCall = 1,
3548 // All calls clobber the non-callee-saved registers:
3549 Defs = [R0, R1, R2, R3, R4, R5, R6, R7, R8, R9,
3550 R10,R11,R12,R13,R14,R15,R16,R17,R18,R19,
3551 R20,R21,R22,R23,R24,R25,R26,R27,R28,R29,
3552 R30,R31,R32,R33,R34,R35,R36,R37,R38,R39,
3553 R40,R41,R42,R43,R44,R45,R46,R47,R48,R49,
3554 R50,R51,R52,R53,R54,R55,R56,R57,R58,R59,
3555 R60,R61,R62,R63,R64,R65,R66,R67,R68,R69,
3556 R70,R71,R72,R73,R74,R75,R76,R77,R78,R79],
3557 // All of these instructions use $lr (aka $0)
3558 Uses = [R0] in {
3559 // Branch relative and set link: Used if we actually know that the target
3560 // is within [-32768, 32767] bytes of the target
3561 def BRSL:
3562 BranchSetLink<0b011001100, (outs), (ins relcalltarget:$func, variable_ops),
3563 "brsl\t$$lr, $func",
3564 [(SPUcall (SPUpcrel tglobaladdr:$func, 0))]>;
3565
3566 // Branch absolute and set link: Used if we actually know that the target
3567 // is an absolute address
3568 def BRASL:
3569 BranchSetLink<0b011001100, (outs), (ins calltarget:$func, variable_ops),
3570 "brasl\t$$lr, $func",
Scott Michel9de5d0d2008-01-11 02:53:15 +00003571 [(SPUcall (SPUaform tglobaladdr:$func, 0))]>;
Scott Michel66377522007-12-04 22:35:58 +00003572
3573 // Branch indirect and set link if external data. These instructions are not
3574 // actually generated, matched by an intrinsic:
3575 def BISLED_00: BISLEDForm<0b11, "bisled\t$$lr, $func", [/* empty pattern */]>;
3576 def BISLED_E0: BISLEDForm<0b10, "bisled\t$$lr, $func", [/* empty pattern */]>;
3577 def BISLED_0D: BISLEDForm<0b01, "bisled\t$$lr, $func", [/* empty pattern */]>;
3578 def BISLED_ED: BISLEDForm<0b00, "bisled\t$$lr, $func", [/* empty pattern */]>;
3579
3580 // Branch indirect and set link. This is the "X-form" address version of a
3581 // function call
3582 def BISL:
3583 BIForm<0b10010101100, "bisl\t$$lr, $func", [(SPUcall R32C:$func)]>;
3584}
3585
Scott Michel1df30c42008-12-29 03:23:36 +00003586// Support calls to external symbols:
3587def : Pat<(SPUcall (SPUpcrel texternalsym:$func, 0)),
3588 (BRSL texternalsym:$func)>;
3589
3590def : Pat<(SPUcall (SPUaform texternalsym:$func, 0)),
3591 (BRASL texternalsym:$func)>;
3592
Scott Michel66377522007-12-04 22:35:58 +00003593// Unconditional branches:
Dan Gohman5b37fba2009-11-10 22:16:57 +00003594let isBranch = 1, isTerminator = 1, hasCtrlDep = 1 in {
3595 let isBarrier = 1 in {
3596 def BR :
3597 UncondBranch<0b001001100, (outs), (ins brtarget:$dest),
3598 "br\t$dest",
3599 [(br bb:$dest)]>;
Scott Michel66377522007-12-04 22:35:58 +00003600
Dan Gohman5b37fba2009-11-10 22:16:57 +00003601 // Unconditional, absolute address branch
3602 def BRA:
3603 UncondBranch<0b001100000, (outs), (ins brtarget:$dest),
3604 "bra\t$dest",
3605 [/* no pattern */]>;
Scott Michel66377522007-12-04 22:35:58 +00003606
Dan Gohman5b37fba2009-11-10 22:16:57 +00003607 // Indirect branch
3608 def BI:
3609 BIForm<0b00010101100, "bi\t$func", [(brind R32C:$func)]>;
3610 }
Scott Michel66377522007-12-04 22:35:58 +00003611
Scott Micheled741dd2009-01-05 01:34:35 +00003612 // Conditional branches:
Scott Michelf0569be2008-12-27 04:51:36 +00003613 class BRNZInst<dag IOL, list<dag> pattern>:
3614 RI16Form<0b010000100, (outs), IOL, "brnz\t$rCond,$dest",
3615 BranchResolv, pattern>;
Scott Michel66377522007-12-04 22:35:58 +00003616
Scott Michelf0569be2008-12-27 04:51:36 +00003617 class BRNZRegInst<RegisterClass rclass>:
3618 BRNZInst<(ins rclass:$rCond, brtarget:$dest),
3619 [(brcond rclass:$rCond, bb:$dest)]>;
Scott Michel66377522007-12-04 22:35:58 +00003620
Scott Michelf0569be2008-12-27 04:51:36 +00003621 class BRNZVecInst<ValueType vectype>:
3622 BRNZInst<(ins VECREG:$rCond, brtarget:$dest),
3623 [(brcond (vectype VECREG:$rCond), bb:$dest)]>;
Scott Michel66377522007-12-04 22:35:58 +00003624
Scott Michelf0569be2008-12-27 04:51:36 +00003625 multiclass BranchNotZero {
3626 def v4i32 : BRNZVecInst<v4i32>;
3627 def r32 : BRNZRegInst<R32C>;
3628 }
Scott Michel66377522007-12-04 22:35:58 +00003629
Scott Michelf0569be2008-12-27 04:51:36 +00003630 defm BRNZ : BranchNotZero;
3631
3632 class BRZInst<dag IOL, list<dag> pattern>:
3633 RI16Form<0b000000100, (outs), IOL, "brz\t$rT,$dest",
3634 BranchResolv, pattern>;
3635
3636 class BRZRegInst<RegisterClass rclass>:
3637 BRZInst<(ins rclass:$rT, brtarget:$dest), [/* no pattern */]>;
3638
3639 class BRZVecInst<ValueType vectype>:
3640 BRZInst<(ins VECREG:$rT, brtarget:$dest), [/* no pattern */]>;
3641
3642 multiclass BranchZero {
3643 def v4i32: BRZVecInst<v4i32>;
3644 def r32: BRZRegInst<R32C>;
3645 }
3646
3647 defm BRZ: BranchZero;
3648
3649 // Note: LLVM doesn't do branch conditional, indirect. Otherwise these would
3650 // be useful:
3651 /*
3652 class BINZInst<dag IOL, list<dag> pattern>:
3653 BICondForm<0b10010100100, (outs), IOL, "binz\t$rA, $dest", pattern>;
3654
3655 class BINZRegInst<RegisterClass rclass>:
3656 BINZInst<(ins rclass:$rA, brtarget:$dest),
3657 [(brcond rclass:$rA, R32C:$dest)]>;
3658
3659 class BINZVecInst<ValueType vectype>:
3660 BINZInst<(ins VECREG:$rA, R32C:$dest),
3661 [(brcond (vectype VECREG:$rA), R32C:$dest)]>;
3662
3663 multiclass BranchNotZeroIndirect {
3664 def v4i32: BINZVecInst<v4i32>;
3665 def r32: BINZRegInst<R32C>;
3666 }
3667
3668 defm BINZ: BranchNotZeroIndirect;
3669
3670 class BIZInst<dag IOL, list<dag> pattern>:
3671 BICondForm<0b00010100100, (outs), IOL, "biz\t$rA, $func", pattern>;
3672
3673 class BIZRegInst<RegisterClass rclass>:
3674 BIZInst<(ins rclass:$rA, R32C:$func), [/* no pattern */]>;
3675
3676 class BIZVecInst<ValueType vectype>:
3677 BIZInst<(ins VECREG:$rA, R32C:$func), [/* no pattern */]>;
3678
3679 multiclass BranchZeroIndirect {
3680 def v4i32: BIZVecInst<v4i32>;
3681 def r32: BIZRegInst<R32C>;
3682 }
3683
3684 defm BIZ: BranchZeroIndirect;
3685 */
3686
3687 class BRHNZInst<dag IOL, list<dag> pattern>:
3688 RI16Form<0b011000100, (outs), IOL, "brhnz\t$rCond,$dest", BranchResolv,
3689 pattern>;
3690
3691 class BRHNZRegInst<RegisterClass rclass>:
3692 BRHNZInst<(ins rclass:$rCond, brtarget:$dest),
3693 [(brcond rclass:$rCond, bb:$dest)]>;
3694
3695 class BRHNZVecInst<ValueType vectype>:
3696 BRHNZInst<(ins VECREG:$rCond, brtarget:$dest), [/* no pattern */]>;
3697
3698 multiclass BranchNotZeroHalfword {
3699 def v8i16: BRHNZVecInst<v8i16>;
3700 def r16: BRHNZRegInst<R16C>;
3701 }
3702
3703 defm BRHNZ: BranchNotZeroHalfword;
3704
3705 class BRHZInst<dag IOL, list<dag> pattern>:
3706 RI16Form<0b001000100, (outs), IOL, "brhz\t$rT,$dest", BranchResolv,
3707 pattern>;
3708
3709 class BRHZRegInst<RegisterClass rclass>:
3710 BRHZInst<(ins rclass:$rT, brtarget:$dest), [/* no pattern */]>;
3711
3712 class BRHZVecInst<ValueType vectype>:
3713 BRHZInst<(ins VECREG:$rT, brtarget:$dest), [/* no pattern */]>;
3714
3715 multiclass BranchZeroHalfword {
3716 def v8i16: BRHZVecInst<v8i16>;
3717 def r16: BRHZRegInst<R16C>;
3718 }
3719
3720 defm BRHZ: BranchZeroHalfword;
Scott Michel66377522007-12-04 22:35:58 +00003721}
3722
Scott Michel58c58182008-01-17 20:38:41 +00003723//===----------------------------------------------------------------------===//
Scott Michel053c1da2008-01-29 02:16:57 +00003724// setcc and brcond patterns:
Scott Michel58c58182008-01-17 20:38:41 +00003725//===----------------------------------------------------------------------===//
Scott Michel053c1da2008-01-29 02:16:57 +00003726
Scott Michelf0569be2008-12-27 04:51:36 +00003727def : Pat<(brcond (i16 (seteq R16C:$rA, 0)), bb:$dest),
3728 (BRHZr16 R16C:$rA, bb:$dest)>;
3729def : Pat<(brcond (i16 (setne R16C:$rA, 0)), bb:$dest),
3730 (BRHNZr16 R16C:$rA, bb:$dest)>;
Scott Michela59d4692008-02-23 18:41:37 +00003731
Scott Michelf0569be2008-12-27 04:51:36 +00003732def : Pat<(brcond (i32 (seteq R32C:$rA, 0)), bb:$dest),
3733 (BRZr32 R32C:$rA, bb:$dest)>;
3734def : Pat<(brcond (i32 (setne R32C:$rA, 0)), bb:$dest),
3735 (BRNZr32 R32C:$rA, bb:$dest)>;
Scott Michel66377522007-12-04 22:35:58 +00003736
Scott Michela59d4692008-02-23 18:41:37 +00003737multiclass BranchCondEQ<PatFrag cond, SPUInstr brinst16, SPUInstr brinst32>
3738{
3739 def r16imm: Pat<(brcond (i16 (cond R16C:$rA, i16ImmSExt10:$val)), bb:$dest),
3740 (brinst16 (CEQHIr16 R16C:$rA, i16ImmSExt10:$val), bb:$dest)>;
Scott Michel053c1da2008-01-29 02:16:57 +00003741
Scott Michela59d4692008-02-23 18:41:37 +00003742 def r16 : Pat<(brcond (i16 (cond R16C:$rA, R16C:$rB)), bb:$dest),
3743 (brinst16 (CEQHr16 R16C:$rA, R16:$rB), bb:$dest)>;
3744
3745 def r32imm : Pat<(brcond (i32 (cond R32C:$rA, i32ImmSExt10:$val)), bb:$dest),
3746 (brinst32 (CEQIr32 R32C:$rA, i32ImmSExt10:$val), bb:$dest)>;
3747
3748 def r32 : Pat<(brcond (i32 (cond R32C:$rA, R32C:$rB)), bb:$dest),
3749 (brinst32 (CEQr32 R32C:$rA, R32C:$rB), bb:$dest)>;
3750}
3751
Scott Micheled741dd2009-01-05 01:34:35 +00003752defm BRCONDeq : BranchCondEQ<seteq, BRHNZr16, BRNZr32>;
3753defm BRCONDne : BranchCondEQ<setne, BRHZr16, BRZr32>;
Scott Michela59d4692008-02-23 18:41:37 +00003754
3755multiclass BranchCondLGT<PatFrag cond, SPUInstr brinst16, SPUInstr brinst32>
3756{
3757 def r16imm : Pat<(brcond (i16 (cond R16C:$rA, i16ImmSExt10:$val)), bb:$dest),
3758 (brinst16 (CLGTHIr16 R16C:$rA, i16ImmSExt10:$val), bb:$dest)>;
3759
3760 def r16 : Pat<(brcond (i16 (cond R16C:$rA, R16C:$rB)), bb:$dest),
3761 (brinst16 (CLGTHr16 R16C:$rA, R16:$rB), bb:$dest)>;
3762
3763 def r32imm : Pat<(brcond (i32 (cond R32C:$rA, i32ImmSExt10:$val)), bb:$dest),
3764 (brinst32 (CLGTIr32 R32C:$rA, i32ImmSExt10:$val), bb:$dest)>;
3765
3766 def r32 : Pat<(brcond (i32 (cond R32C:$rA, R32C:$rB)), bb:$dest),
3767 (brinst32 (CLGTr32 R32C:$rA, R32C:$rB), bb:$dest)>;
3768}
3769
Scott Michelf0569be2008-12-27 04:51:36 +00003770defm BRCONDugt : BranchCondLGT<setugt, BRHNZr16, BRNZr32>;
3771defm BRCONDule : BranchCondLGT<setule, BRHZr16, BRZr32>;
Scott Michela59d4692008-02-23 18:41:37 +00003772
3773multiclass BranchCondLGTEQ<PatFrag cond, SPUInstr orinst16, SPUInstr brinst16,
3774 SPUInstr orinst32, SPUInstr brinst32>
3775{
3776 def r16imm: Pat<(brcond (i16 (cond R16C:$rA, i16ImmSExt10:$val)), bb:$dest),
3777 (brinst16 (orinst16 (CLGTHIr16 R16C:$rA, i16ImmSExt10:$val),
3778 (CEQHIr16 R16C:$rA, i16ImmSExt10:$val)),
3779 bb:$dest)>;
3780
3781 def r16: Pat<(brcond (i16 (cond R16C:$rA, R16C:$rB)), bb:$dest),
3782 (brinst16 (orinst16 (CLGTHr16 R16C:$rA, R16:$rB),
3783 (CEQHr16 R16C:$rA, R16:$rB)),
3784 bb:$dest)>;
3785
3786 def r32imm : Pat<(brcond (i32 (cond R32C:$rA, i32ImmSExt10:$val)), bb:$dest),
3787 (brinst32 (orinst32 (CLGTIr32 R32C:$rA, i32ImmSExt10:$val),
3788 (CEQIr32 R32C:$rA, i32ImmSExt10:$val)),
3789 bb:$dest)>;
3790
3791 def r32 : Pat<(brcond (i32 (cond R32C:$rA, R32C:$rB)), bb:$dest),
3792 (brinst32 (orinst32 (CLGTr32 R32C:$rA, R32C:$rB),
3793 (CEQr32 R32C:$rA, R32C:$rB)),
3794 bb:$dest)>;
3795}
3796
Scott Michelf0569be2008-12-27 04:51:36 +00003797defm BRCONDuge : BranchCondLGTEQ<setuge, ORr16, BRHNZr16, ORr32, BRNZr32>;
3798defm BRCONDult : BranchCondLGTEQ<setult, ORr16, BRHZr16, ORr32, BRZr32>;
Scott Michela59d4692008-02-23 18:41:37 +00003799
3800multiclass BranchCondGT<PatFrag cond, SPUInstr brinst16, SPUInstr brinst32>
3801{
3802 def r16imm : Pat<(brcond (i16 (cond R16C:$rA, i16ImmSExt10:$val)), bb:$dest),
3803 (brinst16 (CGTHIr16 R16C:$rA, i16ImmSExt10:$val), bb:$dest)>;
3804
3805 def r16 : Pat<(brcond (i16 (cond R16C:$rA, R16C:$rB)), bb:$dest),
3806 (brinst16 (CGTHr16 R16C:$rA, R16:$rB), bb:$dest)>;
3807
3808 def r32imm : Pat<(brcond (i32 (cond R32C:$rA, i32ImmSExt10:$val)), bb:$dest),
3809 (brinst32 (CGTIr32 R32C:$rA, i32ImmSExt10:$val), bb:$dest)>;
3810
3811 def r32 : Pat<(brcond (i32 (cond R32C:$rA, R32C:$rB)), bb:$dest),
3812 (brinst32 (CGTr32 R32C:$rA, R32C:$rB), bb:$dest)>;
3813}
3814
Scott Michelf0569be2008-12-27 04:51:36 +00003815defm BRCONDgt : BranchCondGT<setgt, BRHNZr16, BRNZr32>;
3816defm BRCONDle : BranchCondGT<setle, BRHZr16, BRZr32>;
Scott Michela59d4692008-02-23 18:41:37 +00003817
3818multiclass BranchCondGTEQ<PatFrag cond, SPUInstr orinst16, SPUInstr brinst16,
3819 SPUInstr orinst32, SPUInstr brinst32>
3820{
3821 def r16imm: Pat<(brcond (i16 (cond R16C:$rA, i16ImmSExt10:$val)), bb:$dest),
3822 (brinst16 (orinst16 (CGTHIr16 R16C:$rA, i16ImmSExt10:$val),
3823 (CEQHIr16 R16C:$rA, i16ImmSExt10:$val)),
3824 bb:$dest)>;
3825
3826 def r16: Pat<(brcond (i16 (cond R16C:$rA, R16C:$rB)), bb:$dest),
3827 (brinst16 (orinst16 (CGTHr16 R16C:$rA, R16:$rB),
3828 (CEQHr16 R16C:$rA, R16:$rB)),
3829 bb:$dest)>;
3830
3831 def r32imm : Pat<(brcond (i32 (cond R32C:$rA, i32ImmSExt10:$val)), bb:$dest),
3832 (brinst32 (orinst32 (CGTIr32 R32C:$rA, i32ImmSExt10:$val),
3833 (CEQIr32 R32C:$rA, i32ImmSExt10:$val)),
3834 bb:$dest)>;
3835
3836 def r32 : Pat<(brcond (i32 (cond R32C:$rA, R32C:$rB)), bb:$dest),
3837 (brinst32 (orinst32 (CGTr32 R32C:$rA, R32C:$rB),
3838 (CEQr32 R32C:$rA, R32C:$rB)),
3839 bb:$dest)>;
3840}
3841
Scott Michelf0569be2008-12-27 04:51:36 +00003842defm BRCONDge : BranchCondGTEQ<setge, ORr16, BRHNZr16, ORr32, BRNZr32>;
3843defm BRCONDlt : BranchCondGTEQ<setlt, ORr16, BRHZr16, ORr32, BRZr32>;
Scott Michel053c1da2008-01-29 02:16:57 +00003844
Scott Michel66377522007-12-04 22:35:58 +00003845let isTerminator = 1, isBarrier = 1 in {
3846 let isReturn = 1 in {
3847 def RET:
3848 RETForm<"bi\t$$lr", [(retflag)]>;
3849 }
3850}
3851
3852//===----------------------------------------------------------------------===//
Scott Michel66377522007-12-04 22:35:58 +00003853// Single precision floating point instructions
3854//===----------------------------------------------------------------------===//
3855
Scott Michelaedc6372008-12-10 00:15:19 +00003856class FAInst<dag OOL, dag IOL, list<dag> pattern>:
3857 RRForm<0b01011000100, OOL, IOL, "fa\t$rT, $rA, $rB",
Scott Michel02d711b2008-12-30 23:28:25 +00003858 SPrecFP, pattern>;
Scott Michelf0569be2008-12-27 04:51:36 +00003859
Scott Michelaedc6372008-12-10 00:15:19 +00003860class FAVecInst<ValueType vectype>:
3861 FAInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
3862 [(set (vectype VECREG:$rT),
Scott Michel02d711b2008-12-30 23:28:25 +00003863 (fadd (vectype VECREG:$rA), (vectype VECREG:$rB)))]>;
Scott Michelf0569be2008-12-27 04:51:36 +00003864
Scott Michelaedc6372008-12-10 00:15:19 +00003865multiclass SFPAdd
3866{
3867 def v4f32: FAVecInst<v4f32>;
Scott Michel02d711b2008-12-30 23:28:25 +00003868 def f32: FAInst<(outs R32FP:$rT), (ins R32FP:$rA, R32FP:$rB),
3869 [(set R32FP:$rT, (fadd R32FP:$rA, R32FP:$rB))]>;
Scott Michelaedc6372008-12-10 00:15:19 +00003870}
Scott Michel66377522007-12-04 22:35:58 +00003871
Scott Michelaedc6372008-12-10 00:15:19 +00003872defm FA : SFPAdd;
Scott Michel66377522007-12-04 22:35:58 +00003873
Scott Michelaedc6372008-12-10 00:15:19 +00003874class FSInst<dag OOL, dag IOL, list<dag> pattern>:
3875 RRForm<0b01011000100, OOL, IOL, "fs\t$rT, $rA, $rB",
Scott Michel02d711b2008-12-30 23:28:25 +00003876 SPrecFP, pattern>;
Scott Michel66377522007-12-04 22:35:58 +00003877
Scott Michelaedc6372008-12-10 00:15:19 +00003878class FSVecInst<ValueType vectype>:
3879 FSInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
Scott Michel02d711b2008-12-30 23:28:25 +00003880 [(set (vectype VECREG:$rT),
3881 (fsub (vectype VECREG:$rA), (vectype VECREG:$rB)))]>;
Scott Michelaedc6372008-12-10 00:15:19 +00003882
3883multiclass SFPSub
3884{
3885 def v4f32: FSVecInst<v4f32>;
Scott Michel02d711b2008-12-30 23:28:25 +00003886 def f32: FSInst<(outs R32FP:$rT), (ins R32FP:$rA, R32FP:$rB),
3887 [(set R32FP:$rT, (fsub R32FP:$rA, R32FP:$rB))]>;
Scott Michelaedc6372008-12-10 00:15:19 +00003888}
3889
3890defm FS : SFPSub;
Scott Michel66377522007-12-04 22:35:58 +00003891
3892// Floating point reciprocal estimate
Scott Michel66377522007-12-04 22:35:58 +00003893
Scott Michel02d711b2008-12-30 23:28:25 +00003894class FRESTInst<dag OOL, dag IOL>:
3895 RRForm_1<0b00110111000, OOL, IOL,
3896 "frest\t$rT, $rA", SPrecFP,
3897 [/* no pattern */]>;
3898
3899def FRESTv4f32 :
3900 FRESTInst<(outs VECREG:$rT), (ins VECREG:$rA)>;
3901
3902def FRESTf32 :
3903 FRESTInst<(outs R32FP:$rT), (ins R32FP:$rA)>;
Scott Michel66377522007-12-04 22:35:58 +00003904
3905// Floating point interpolate (used in conjunction with reciprocal estimate)
3906def FIv4f32 :
3907 RRForm<0b00101011110, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
3908 "fi\t$rT, $rA, $rB", SPrecFP,
Scott Michel02d711b2008-12-30 23:28:25 +00003909 [/* no pattern */]>;
Scott Michel66377522007-12-04 22:35:58 +00003910
3911def FIf32 :
3912 RRForm<0b00101011110, (outs R32FP:$rT), (ins R32FP:$rA, R32FP:$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
Scott Michel9c0c6b22008-11-21 02:56:16 +00003916//--------------------------------------------------------------------------
3917// Basic single precision floating point comparisons:
3918//
3919// Note: There is no support on SPU for single precision NaN. Consequently,
3920// ordered and unordered comparisons are the same.
3921//--------------------------------------------------------------------------
3922
Scott Michel66377522007-12-04 22:35:58 +00003923def FCEQf32 :
3924 RRForm<0b01000011110, (outs R32C:$rT), (ins R32FP:$rA, R32FP:$rB),
3925 "fceq\t$rT, $rA, $rB", SPrecFP,
Scott Michel9c0c6b22008-11-21 02:56:16 +00003926 [(set R32C:$rT, (setueq R32FP:$rA, R32FP:$rB))]>;
3927
3928def : Pat<(setoeq R32FP:$rA, R32FP:$rB),
3929 (FCEQf32 R32FP:$rA, R32FP:$rB)>;
Scott Michel66377522007-12-04 22:35:58 +00003930
3931def FCMEQf32 :
3932 RRForm<0b01010011110, (outs R32C:$rT), (ins R32FP:$rA, R32FP:$rB),
3933 "fcmeq\t$rT, $rA, $rB", SPrecFP,
Scott Michel9c0c6b22008-11-21 02:56:16 +00003934 [(set R32C:$rT, (setueq (fabs R32FP:$rA), (fabs R32FP:$rB)))]>;
3935
3936def : Pat<(setoeq (fabs R32FP:$rA), (fabs R32FP:$rB)),
3937 (FCMEQf32 R32FP:$rA, R32FP:$rB)>;
Scott Michel66377522007-12-04 22:35:58 +00003938
3939def FCGTf32 :
3940 RRForm<0b01000011010, (outs R32C:$rT), (ins R32FP:$rA, R32FP:$rB),
3941 "fcgt\t$rT, $rA, $rB", SPrecFP,
Scott Michel9c0c6b22008-11-21 02:56:16 +00003942 [(set R32C:$rT, (setugt R32FP:$rA, R32FP:$rB))]>;
3943
3944def : Pat<(setugt R32FP:$rA, R32FP:$rB),
3945 (FCGTf32 R32FP:$rA, R32FP:$rB)>;
Scott Michel66377522007-12-04 22:35:58 +00003946
3947def FCMGTf32 :
3948 RRForm<0b01010011010, (outs R32C:$rT), (ins R32FP:$rA, R32FP:$rB),
3949 "fcmgt\t$rT, $rA, $rB", SPrecFP,
Scott Michel9c0c6b22008-11-21 02:56:16 +00003950 [(set R32C:$rT, (setugt (fabs R32FP:$rA), (fabs R32FP:$rB)))]>;
3951
3952def : Pat<(setugt (fabs R32FP:$rA), (fabs R32FP:$rB)),
3953 (FCMGTf32 R32FP:$rA, R32FP:$rB)>;
3954
3955//--------------------------------------------------------------------------
3956// Single precision floating point comparisons and SETCC equivalents:
3957//--------------------------------------------------------------------------
3958
3959def : SETCCNegCondReg<setune, R32FP, i32, XORIr32, FCEQf32>;
3960def : SETCCNegCondReg<setone, R32FP, i32, XORIr32, FCEQf32>;
3961
3962def : SETCCBinOpReg<setuge, R32FP, ORr32, FCGTf32, FCEQf32>;
3963def : SETCCBinOpReg<setoge, R32FP, ORr32, FCGTf32, FCEQf32>;
3964
3965def : SETCCBinOpReg<setult, R32FP, NORr32, FCGTf32, FCEQf32>;
3966def : SETCCBinOpReg<setolt, R32FP, NORr32, FCGTf32, FCEQf32>;
3967
3968def : Pat<(setule R32FP:$rA, R32FP:$rB),
3969 (XORIr32 (FCGTf32 R32FP:$rA, R32FP:$rB), 0xffffffff)>;
3970def : Pat<(setole R32FP:$rA, R32FP:$rB),
3971 (XORIr32 (FCGTf32 R32FP:$rA, R32FP:$rB), 0xffffffff)>;
Scott Michel66377522007-12-04 22:35:58 +00003972
3973// FP Status and Control Register Write
3974// Why isn't rT a don't care in the ISA?
3975// Should we create a special RRForm_3 for this guy and zero out the rT?
3976def FSCRWf32 :
3977 RRForm_1<0b01011101110, (outs R32FP:$rT), (ins R32FP:$rA),
3978 "fscrwr\t$rA", SPrecFP,
3979 [/* This instruction requires an intrinsic. Note: rT is unused. */]>;
3980
3981// FP Status and Control Register Read
3982def FSCRRf32 :
3983 RRForm_2<0b01011101110, (outs R32FP:$rT), (ins),
3984 "fscrrd\t$rT", SPrecFP,
3985 [/* This instruction requires an intrinsic */]>;
3986
3987// llvm instruction space
3988// How do these map onto cell instructions?
3989// fdiv rA rB
3990// frest rC rB # c = 1/b (both lines)
3991// fi rC rB rC
3992// fm rD rA rC # d = a * 1/b
3993// fnms rB rD rB rA # b = - (d * b - a) --should == 0 in a perfect world
3994// fma rB rB rC rD # b = b * c + d
3995// = -(d *b -a) * c + d
3996// = a * c - c ( a *b *c - a)
3997
3998// fcopysign (???)
3999
4000// Library calls:
4001// These llvm instructions will actually map to library calls.
4002// All that's needed, then, is to check that the appropriate library is
4003// imported and do a brsl to the proper function name.
4004// frem # fmod(x, y): x - (x/y) * y
4005// (Note: fmod(double, double), fmodf(float,float)
4006// fsqrt?
4007// fsin?
4008// fcos?
4009// Unimplemented SPU instruction space
4010// floating reciprocal absolute square root estimate (frsqest)
4011
4012// The following are probably just intrinsics
Scott Michelf0569be2008-12-27 04:51:36 +00004013// status and control register write
Scott Michel66377522007-12-04 22:35:58 +00004014// status and control register read
4015
4016//--------------------------------------
4017// Floating point multiply instructions
4018//--------------------------------------
4019
4020def FMv4f32:
4021 RRForm<0b00100011010, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
4022 "fm\t$rT, $rA, $rB", SPrecFP,
4023 [(set (v4f32 VECREG:$rT), (fmul (v4f32 VECREG:$rA),
4024 (v4f32 VECREG:$rB)))]>;
4025
4026def FMf32 :
4027 RRForm<0b01100011010, (outs R32FP:$rT), (ins R32FP:$rA, R32FP:$rB),
4028 "fm\t$rT, $rA, $rB", SPrecFP,
4029 [(set R32FP:$rT, (fmul R32FP:$rA, R32FP:$rB))]>;
4030
4031// Floating point multiply and add
4032// e.g. d = c + (a * b)
4033def FMAv4f32:
4034 RRRForm<0b0111, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB, VECREG:$rC),
4035 "fma\t$rT, $rA, $rB, $rC", SPrecFP,
4036 [(set (v4f32 VECREG:$rT),
4037 (fadd (v4f32 VECREG:$rC),
4038 (fmul (v4f32 VECREG:$rA), (v4f32 VECREG:$rB))))]>;
4039
4040def FMAf32:
4041 RRRForm<0b0111, (outs R32FP:$rT), (ins R32FP:$rA, R32FP:$rB, R32FP:$rC),
4042 "fma\t$rT, $rA, $rB, $rC", SPrecFP,
4043 [(set R32FP:$rT, (fadd R32FP:$rC, (fmul R32FP:$rA, R32FP:$rB)))]>;
4044
4045// FP multiply and subtract
4046// Subtracts value in rC from product
4047// res = a * b - c
4048def FMSv4f32 :
4049 RRRForm<0b0111, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB, VECREG:$rC),
4050 "fms\t$rT, $rA, $rB, $rC", SPrecFP,
4051 [(set (v4f32 VECREG:$rT),
4052 (fsub (fmul (v4f32 VECREG:$rA), (v4f32 VECREG:$rB)),
4053 (v4f32 VECREG:$rC)))]>;
4054
4055def FMSf32 :
4056 RRRForm<0b0111, (outs R32FP:$rT), (ins R32FP:$rA, R32FP:$rB, R32FP:$rC),
4057 "fms\t$rT, $rA, $rB, $rC", SPrecFP,
4058 [(set R32FP:$rT,
4059 (fsub (fmul R32FP:$rA, R32FP:$rB), R32FP:$rC))]>;
4060
4061// Floating Negative Mulitply and Subtract
4062// Subtracts product from value in rC
4063// res = fneg(fms a b c)
4064// = - (a * b - c)
4065// = c - a * b
4066// NOTE: subtraction order
4067// fsub a b = a - b
Scott Michelf0569be2008-12-27 04:51:36 +00004068// fs a b = b - a?
Scott Michel66377522007-12-04 22:35:58 +00004069def FNMSf32 :
4070 RRRForm<0b1101, (outs R32FP:$rT), (ins R32FP:$rA, R32FP:$rB, R32FP:$rC),
4071 "fnms\t$rT, $rA, $rB, $rC", SPrecFP,
4072 [(set R32FP:$rT, (fsub R32FP:$rC, (fmul R32FP:$rA, R32FP:$rB)))]>;
4073
4074def FNMSv4f32 :
4075 RRRForm<0b1101, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB, VECREG:$rC),
4076 "fnms\t$rT, $rA, $rB, $rC", SPrecFP,
Scott Michelf0569be2008-12-27 04:51:36 +00004077 [(set (v4f32 VECREG:$rT),
4078 (fsub (v4f32 VECREG:$rC),
4079 (fmul (v4f32 VECREG:$rA),
Scott Michel66377522007-12-04 22:35:58 +00004080 (v4f32 VECREG:$rB))))]>;
4081
4082//--------------------------------------
4083// Floating Point Conversions
4084// Signed conversions:
4085def CSiFv4f32:
4086 CVTIntFPForm<0b0101101110, (outs VECREG:$rT), (ins VECREG:$rA),
4087 "csflt\t$rT, $rA, 0", SPrecFP,
4088 [(set (v4f32 VECREG:$rT), (sint_to_fp (v4i32 VECREG:$rA)))]>;
4089
Scott Michelf0569be2008-12-27 04:51:36 +00004090// Convert signed integer to floating point
Scott Michel66377522007-12-04 22:35:58 +00004091def CSiFf32 :
4092 CVTIntFPForm<0b0101101110, (outs R32FP:$rT), (ins R32C:$rA),
4093 "csflt\t$rT, $rA, 0", SPrecFP,
4094 [(set R32FP:$rT, (sint_to_fp R32C:$rA))]>;
4095
4096// Convert unsigned into to float
4097def CUiFv4f32 :
4098 CVTIntFPForm<0b1101101110, (outs VECREG:$rT), (ins VECREG:$rA),
4099 "cuflt\t$rT, $rA, 0", SPrecFP,
4100 [(set (v4f32 VECREG:$rT), (uint_to_fp (v4i32 VECREG:$rA)))]>;
4101
4102def CUiFf32 :
4103 CVTIntFPForm<0b1101101110, (outs R32FP:$rT), (ins R32C:$rA),
4104 "cuflt\t$rT, $rA, 0", SPrecFP,
4105 [(set R32FP:$rT, (uint_to_fp R32C:$rA))]>;
4106
Scott Michelf0569be2008-12-27 04:51:36 +00004107// Convert float to unsigned int
Scott Michel66377522007-12-04 22:35:58 +00004108// Assume that scale = 0
4109
4110def CFUiv4f32 :
4111 CVTIntFPForm<0b1101101110, (outs VECREG:$rT), (ins VECREG:$rA),
4112 "cfltu\t$rT, $rA, 0", SPrecFP,
4113 [(set (v4i32 VECREG:$rT), (fp_to_uint (v4f32 VECREG:$rA)))]>;
4114
4115def CFUif32 :
4116 CVTIntFPForm<0b1101101110, (outs R32C:$rT), (ins R32FP:$rA),
4117 "cfltu\t$rT, $rA, 0", SPrecFP,
4118 [(set R32C:$rT, (fp_to_uint R32FP:$rA))]>;
4119
Scott Michelf0569be2008-12-27 04:51:36 +00004120// Convert float to signed int
Scott Michel66377522007-12-04 22:35:58 +00004121// Assume that scale = 0
4122
4123def CFSiv4f32 :
4124 CVTIntFPForm<0b1101101110, (outs VECREG:$rT), (ins VECREG:$rA),
4125 "cflts\t$rT, $rA, 0", SPrecFP,
4126 [(set (v4i32 VECREG:$rT), (fp_to_sint (v4f32 VECREG:$rA)))]>;
4127
4128def CFSif32 :
4129 CVTIntFPForm<0b1101101110, (outs R32C:$rT), (ins R32FP:$rA),
4130 "cflts\t$rT, $rA, 0", SPrecFP,
4131 [(set R32C:$rT, (fp_to_sint R32FP:$rA))]>;
4132
4133//===----------------------------------------------------------------------==//
4134// Single<->Double precision conversions
4135//===----------------------------------------------------------------------==//
4136
4137// NOTE: We use "vec" name suffix here to avoid confusion (e.g. input is a
4138// v4f32, output is v2f64--which goes in the name?)
4139
4140// Floating point extend single to double
4141// NOTE: Not sure if passing in v4f32 to FESDvec is correct since it
4142// operates on two double-word slots (i.e. 1st and 3rd fp numbers
4143// are ignored).
4144def FESDvec :
4145 RRForm_1<0b00011101110, (outs VECREG:$rT), (ins VECREG:$rA),
4146 "fesd\t$rT, $rA", SPrecFP,
Chris Lattnere9eda0f2010-03-19 04:53:47 +00004147 [/*(set (v2f64 VECREG:$rT), (fextend (v4f32 VECREG:$rA)))*/]>;
Scott Michel66377522007-12-04 22:35:58 +00004148
4149def FESDf32 :
4150 RRForm_1<0b00011101110, (outs R64FP:$rT), (ins R32FP:$rA),
4151 "fesd\t$rT, $rA", SPrecFP,
4152 [(set R64FP:$rT, (fextend R32FP:$rA))]>;
4153
4154// Floating point round double to single
4155//def FRDSvec :
4156// RRForm_1<0b10011101110, (outs VECREG:$rT), (ins VECREG:$rA),
4157// "frds\t$rT, $rA,", SPrecFP,
4158// [(set (v4f32 R32FP:$rT), (fround (v2f64 R64FP:$rA)))]>;
4159
4160def FRDSf64 :
4161 RRForm_1<0b10011101110, (outs R32FP:$rT), (ins R64FP:$rA),
4162 "frds\t$rT, $rA", SPrecFP,
4163 [(set R32FP:$rT, (fround R64FP:$rA))]>;
4164
4165//ToDo include anyextend?
4166
4167//===----------------------------------------------------------------------==//
4168// Double precision floating point instructions
4169//===----------------------------------------------------------------------==//
4170def FAf64 :
4171 RRForm<0b00110011010, (outs R64FP:$rT), (ins R64FP:$rA, R64FP:$rB),
4172 "dfa\t$rT, $rA, $rB", DPrecFP,
4173 [(set R64FP:$rT, (fadd R64FP:$rA, R64FP:$rB))]>;
4174
4175def FAv2f64 :
4176 RRForm<0b00110011010, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
4177 "dfa\t$rT, $rA, $rB", DPrecFP,
4178 [(set (v2f64 VECREG:$rT), (fadd (v2f64 VECREG:$rA), (v2f64 VECREG:$rB)))]>;
4179
4180def FSf64 :
4181 RRForm<0b10100011010, (outs R64FP:$rT), (ins R64FP:$rA, R64FP:$rB),
4182 "dfs\t$rT, $rA, $rB", DPrecFP,
4183 [(set R64FP:$rT, (fsub R64FP:$rA, R64FP:$rB))]>;
4184
4185def FSv2f64 :
4186 RRForm<0b10100011010, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
4187 "dfs\t$rT, $rA, $rB", DPrecFP,
4188 [(set (v2f64 VECREG:$rT),
4189 (fsub (v2f64 VECREG:$rA), (v2f64 VECREG:$rB)))]>;
4190
4191def FMf64 :
4192 RRForm<0b01100011010, (outs R64FP:$rT), (ins R64FP:$rA, R64FP:$rB),
4193 "dfm\t$rT, $rA, $rB", DPrecFP,
4194 [(set R64FP:$rT, (fmul R64FP:$rA, R64FP:$rB))]>;
4195
4196def FMv2f64:
4197 RRForm<0b00100011010, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
4198 "dfm\t$rT, $rA, $rB", DPrecFP,
4199 [(set (v2f64 VECREG:$rT),
4200 (fmul (v2f64 VECREG:$rA), (v2f64 VECREG:$rB)))]>;
4201
4202def FMAf64:
4203 RRForm<0b00111010110, (outs R64FP:$rT),
4204 (ins R64FP:$rA, R64FP:$rB, R64FP:$rC),
4205 "dfma\t$rT, $rA, $rB", DPrecFP,
4206 [(set R64FP:$rT, (fadd R64FP:$rC, (fmul R64FP:$rA, R64FP:$rB)))]>,
4207 RegConstraint<"$rC = $rT">,
4208 NoEncode<"$rC">;
4209
4210def FMAv2f64:
4211 RRForm<0b00111010110, (outs VECREG:$rT),
4212 (ins VECREG:$rA, VECREG:$rB, VECREG:$rC),
4213 "dfma\t$rT, $rA, $rB", DPrecFP,
4214 [(set (v2f64 VECREG:$rT),
4215 (fadd (v2f64 VECREG:$rC),
4216 (fmul (v2f64 VECREG:$rA), (v2f64 VECREG:$rB))))]>,
4217 RegConstraint<"$rC = $rT">,
4218 NoEncode<"$rC">;
4219
4220def FMSf64 :
4221 RRForm<0b10111010110, (outs R64FP:$rT),
4222 (ins R64FP:$rA, R64FP:$rB, R64FP:$rC),
4223 "dfms\t$rT, $rA, $rB", DPrecFP,
4224 [(set R64FP:$rT, (fsub (fmul R64FP:$rA, R64FP:$rB), R64FP:$rC))]>,
4225 RegConstraint<"$rC = $rT">,
4226 NoEncode<"$rC">;
4227
4228def FMSv2f64 :
4229 RRForm<0b10111010110, (outs VECREG:$rT),
4230 (ins VECREG:$rA, VECREG:$rB, VECREG:$rC),
4231 "dfms\t$rT, $rA, $rB", DPrecFP,
4232 [(set (v2f64 VECREG:$rT),
4233 (fsub (fmul (v2f64 VECREG:$rA), (v2f64 VECREG:$rB)),
4234 (v2f64 VECREG:$rC)))]>;
4235
Scott Michel7ea02ff2009-03-17 01:15:45 +00004236// DFNMS: - (a * b - c)
Scott Michel66377522007-12-04 22:35:58 +00004237// - (a * b) + c => c - (a * b)
Scott Michel7ea02ff2009-03-17 01:15:45 +00004238
4239class DFNMSInst<dag OOL, dag IOL, list<dag> pattern>:
4240 RRForm<0b01111010110, OOL, IOL, "dfnms\t$rT, $rA, $rB",
4241 DPrecFP, pattern>,
Scott Michel66377522007-12-04 22:35:58 +00004242 RegConstraint<"$rC = $rT">,
4243 NoEncode<"$rC">;
4244
Scott Michel7ea02ff2009-03-17 01:15:45 +00004245class DFNMSVecInst<list<dag> pattern>:
4246 DFNMSInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB, VECREG:$rC),
4247 pattern>;
Scott Michel66377522007-12-04 22:35:58 +00004248
Scott Michel7ea02ff2009-03-17 01:15:45 +00004249class DFNMSRegInst<list<dag> pattern>:
4250 DFNMSInst<(outs R64FP:$rT), (ins R64FP:$rA, R64FP:$rB, R64FP:$rC),
4251 pattern>;
Scott Michel66377522007-12-04 22:35:58 +00004252
Scott Michel7ea02ff2009-03-17 01:15:45 +00004253multiclass DFMultiplySubtract
4254{
4255 def v2f64 : DFNMSVecInst<[(set (v2f64 VECREG:$rT),
4256 (fsub (v2f64 VECREG:$rC),
4257 (fmul (v2f64 VECREG:$rA),
4258 (v2f64 VECREG:$rB))))]>;
4259
4260 def f64 : DFNMSRegInst<[(set R64FP:$rT,
4261 (fsub R64FP:$rC,
4262 (fmul R64FP:$rA, R64FP:$rB)))]>;
4263}
4264
4265defm DFNMS : DFMultiplySubtract;
Scott Michel66377522007-12-04 22:35:58 +00004266
4267// - (a * b + c)
4268// - (a * b) - c
4269def FNMAf64 :
4270 RRForm<0b11111010110, (outs R64FP:$rT),
4271 (ins R64FP:$rA, R64FP:$rB, R64FP:$rC),
4272 "dfnma\t$rT, $rA, $rB", DPrecFP,
4273 [(set R64FP:$rT, (fneg (fadd R64FP:$rC, (fmul R64FP:$rA, R64FP:$rB))))]>,
4274 RegConstraint<"$rC = $rT">,
4275 NoEncode<"$rC">;
4276
4277def FNMAv2f64 :
4278 RRForm<0b11111010110, (outs VECREG:$rT),
4279 (ins VECREG:$rA, VECREG:$rB, VECREG:$rC),
4280 "dfnma\t$rT, $rA, $rB", DPrecFP,
Scott Michelf0569be2008-12-27 04:51:36 +00004281 [(set (v2f64 VECREG:$rT),
4282 (fneg (fadd (v2f64 VECREG:$rC),
4283 (fmul (v2f64 VECREG:$rA),
Scott Michel66377522007-12-04 22:35:58 +00004284 (v2f64 VECREG:$rB)))))]>,
4285 RegConstraint<"$rC = $rT">,
4286 NoEncode<"$rC">;
4287
4288//===----------------------------------------------------------------------==//
4289// Floating point negation and absolute value
4290//===----------------------------------------------------------------------==//
4291
4292def : Pat<(fneg (v4f32 VECREG:$rA)),
Scott Michela82d3f72009-03-17 16:45:16 +00004293 (XORfnegvec (v4f32 VECREG:$rA),
4294 (v4f32 (ILHUv4i32 0x8000)))>;
Scott Michel66377522007-12-04 22:35:58 +00004295
4296def : Pat<(fneg R32FP:$rA),
Scott Michela82d3f72009-03-17 16:45:16 +00004297 (XORfneg32 R32FP:$rA, (ILHUr32 0x8000))>;
Scott Michel66377522007-12-04 22:35:58 +00004298
4299// Floating point absolute value
Scott Michel7ea02ff2009-03-17 01:15:45 +00004300// Note: f64 fabs is custom-selected.
Scott Michel66377522007-12-04 22:35:58 +00004301
4302def : Pat<(fabs R32FP:$rA),
4303 (ANDfabs32 R32FP:$rA, (IOHLr32 (ILHUr32 0x7fff), 0xffff))>;
4304
4305def : Pat<(fabs (v4f32 VECREG:$rA)),
4306 (ANDfabsvec (v4f32 VECREG:$rA),
Scott Michel7ea02ff2009-03-17 01:15:45 +00004307 (IOHLv4i32 (ILHUv4i32 0x7fff), 0xffff))>;
Scott Michelc9c8b2a2009-01-26 03:31:40 +00004308
Scott Michel66377522007-12-04 22:35:58 +00004309//===----------------------------------------------------------------------===//
Scott Michelaedc6372008-12-10 00:15:19 +00004310// Hint for branch instructions:
4311//===----------------------------------------------------------------------===//
4312
4313/* def HBR : SPUInstr<(outs), (ins), "hbr\t" */
4314
4315//===----------------------------------------------------------------------===//
Scott Michel66377522007-12-04 22:35:58 +00004316// Execution, Load NOP (execute NOPs belong in even pipeline, load NOPs belong
4317// in the odd pipeline)
4318//===----------------------------------------------------------------------===//
4319
Scott Michela59d4692008-02-23 18:41:37 +00004320def ENOP : SPUInstr<(outs), (ins), "enop", ExecNOP> {
Scott Michel66377522007-12-04 22:35:58 +00004321 let Pattern = [];
4322
4323 let Inst{0-10} = 0b10000000010;
4324 let Inst{11-17} = 0;
4325 let Inst{18-24} = 0;
4326 let Inst{25-31} = 0;
4327}
4328
Scott Michela59d4692008-02-23 18:41:37 +00004329def LNOP : SPUInstr<(outs), (ins), "lnop", LoadNOP> {
Scott Michel66377522007-12-04 22:35:58 +00004330 let Pattern = [];
4331
4332 let Inst{0-10} = 0b10000000000;
4333 let Inst{11-17} = 0;
4334 let Inst{18-24} = 0;
4335 let Inst{25-31} = 0;
4336}
4337
4338//===----------------------------------------------------------------------===//
4339// Bit conversions (type conversions between vector/packed types)
Scott Michel6e1d1472009-03-16 18:47:25 +00004340// NOTE: Promotions are handled using the XS* instructions.
Scott Michel66377522007-12-04 22:35:58 +00004341//===----------------------------------------------------------------------===//
4342def : Pat<(v16i8 (bitconvert (v8i16 VECREG:$src))), (v16i8 VECREG:$src)>;
4343def : Pat<(v16i8 (bitconvert (v4i32 VECREG:$src))), (v16i8 VECREG:$src)>;
4344def : Pat<(v16i8 (bitconvert (v2i64 VECREG:$src))), (v16i8 VECREG:$src)>;
4345def : Pat<(v16i8 (bitconvert (v4f32 VECREG:$src))), (v16i8 VECREG:$src)>;
4346def : Pat<(v16i8 (bitconvert (v2f64 VECREG:$src))), (v16i8 VECREG:$src)>;
4347
4348def : Pat<(v8i16 (bitconvert (v16i8 VECREG:$src))), (v8i16 VECREG:$src)>;
4349def : Pat<(v8i16 (bitconvert (v4i32 VECREG:$src))), (v8i16 VECREG:$src)>;
4350def : Pat<(v8i16 (bitconvert (v2i64 VECREG:$src))), (v8i16 VECREG:$src)>;
4351def : Pat<(v8i16 (bitconvert (v4f32 VECREG:$src))), (v8i16 VECREG:$src)>;
4352def : Pat<(v8i16 (bitconvert (v2f64 VECREG:$src))), (v8i16 VECREG:$src)>;
4353
4354def : Pat<(v4i32 (bitconvert (v16i8 VECREG:$src))), (v4i32 VECREG:$src)>;
4355def : Pat<(v4i32 (bitconvert (v8i16 VECREG:$src))), (v4i32 VECREG:$src)>;
4356def : Pat<(v4i32 (bitconvert (v2i64 VECREG:$src))), (v4i32 VECREG:$src)>;
4357def : Pat<(v4i32 (bitconvert (v4f32 VECREG:$src))), (v4i32 VECREG:$src)>;
4358def : Pat<(v4i32 (bitconvert (v2f64 VECREG:$src))), (v4i32 VECREG:$src)>;
4359
4360def : Pat<(v2i64 (bitconvert (v16i8 VECREG:$src))), (v2i64 VECREG:$src)>;
4361def : Pat<(v2i64 (bitconvert (v8i16 VECREG:$src))), (v2i64 VECREG:$src)>;
4362def : Pat<(v2i64 (bitconvert (v4i32 VECREG:$src))), (v2i64 VECREG:$src)>;
4363def : Pat<(v2i64 (bitconvert (v4f32 VECREG:$src))), (v2i64 VECREG:$src)>;
4364def : Pat<(v2i64 (bitconvert (v2f64 VECREG:$src))), (v2i64 VECREG:$src)>;
4365
4366def : Pat<(v4f32 (bitconvert (v16i8 VECREG:$src))), (v4f32 VECREG:$src)>;
4367def : Pat<(v4f32 (bitconvert (v8i16 VECREG:$src))), (v4f32 VECREG:$src)>;
4368def : Pat<(v4f32 (bitconvert (v2i64 VECREG:$src))), (v4f32 VECREG:$src)>;
4369def : Pat<(v4f32 (bitconvert (v4i32 VECREG:$src))), (v4f32 VECREG:$src)>;
4370def : Pat<(v4f32 (bitconvert (v2f64 VECREG:$src))), (v4f32 VECREG:$src)>;
4371
4372def : Pat<(v2f64 (bitconvert (v16i8 VECREG:$src))), (v2f64 VECREG:$src)>;
4373def : Pat<(v2f64 (bitconvert (v8i16 VECREG:$src))), (v2f64 VECREG:$src)>;
4374def : Pat<(v2f64 (bitconvert (v4i32 VECREG:$src))), (v2f64 VECREG:$src)>;
4375def : Pat<(v2f64 (bitconvert (v2i64 VECREG:$src))), (v2f64 VECREG:$src)>;
4376def : Pat<(v2f64 (bitconvert (v2f64 VECREG:$src))), (v2f64 VECREG:$src)>;
4377
Scott Michel6e1d1472009-03-16 18:47:25 +00004378def : Pat<(i128 (bitconvert (v16i8 VECREG:$src))),
4379 (ORi128_vec VECREG:$src)>;
4380def : Pat<(i128 (bitconvert (v8i16 VECREG:$src))),
4381 (ORi128_vec VECREG:$src)>;
4382def : Pat<(i128 (bitconvert (v4i32 VECREG:$src))),
4383 (ORi128_vec VECREG:$src)>;
4384def : Pat<(i128 (bitconvert (v2i64 VECREG:$src))),
4385 (ORi128_vec VECREG:$src)>;
4386def : Pat<(i128 (bitconvert (v4f32 VECREG:$src))),
4387 (ORi128_vec VECREG:$src)>;
4388def : Pat<(i128 (bitconvert (v2f64 VECREG:$src))),
4389 (ORi128_vec VECREG:$src)>;
4390
4391def : Pat<(v16i8 (bitconvert (i128 GPRC:$src))),
4392 (v16i8 (ORvec_i128 GPRC:$src))>;
4393def : Pat<(v8i16 (bitconvert (i128 GPRC:$src))),
4394 (v8i16 (ORvec_i128 GPRC:$src))>;
4395def : Pat<(v4i32 (bitconvert (i128 GPRC:$src))),
4396 (v4i32 (ORvec_i128 GPRC:$src))>;
4397def : Pat<(v2i64 (bitconvert (i128 GPRC:$src))),
4398 (v2i64 (ORvec_i128 GPRC:$src))>;
4399def : Pat<(v4f32 (bitconvert (i128 GPRC:$src))),
4400 (v4f32 (ORvec_i128 GPRC:$src))>;
4401def : Pat<(v2f64 (bitconvert (i128 GPRC:$src))),
4402 (v2f64 (ORvec_i128 GPRC:$src))>;
Scott Michel66377522007-12-04 22:35:58 +00004403
4404//===----------------------------------------------------------------------===//
4405// Instruction patterns:
4406//===----------------------------------------------------------------------===//
4407
4408// General 32-bit constants:
4409def : Pat<(i32 imm:$imm),
4410 (IOHLr32 (ILHUr32 (HI16 imm:$imm)), (LO16 imm:$imm))>;
4411
4412// Single precision float constants:
Nate Begemanccef5802008-02-14 18:43:04 +00004413def : Pat<(f32 fpimm:$imm),
Scott Michel66377522007-12-04 22:35:58 +00004414 (IOHLf32 (ILHUf32 (HI16_f32 fpimm:$imm)), (LO16_f32 fpimm:$imm))>;
4415
4416// General constant 32-bit vectors
4417def : Pat<(v4i32 v4i32Imm:$imm),
Scott Michelad2715e2008-03-05 23:02:02 +00004418 (IOHLv4i32 (v4i32 (ILHUv4i32 (HI16_vec v4i32Imm:$imm))),
4419 (LO16_vec v4i32Imm:$imm))>;
Scott Michelf0569be2008-12-27 04:51:36 +00004420
Scott Michel504c3692007-12-17 22:32:34 +00004421// 8-bit constants
4422def : Pat<(i8 imm:$imm),
4423 (ILHr8 imm:$imm)>;
Scott Michel66377522007-12-04 22:35:58 +00004424
4425//===----------------------------------------------------------------------===//
Scott Michel66377522007-12-04 22:35:58 +00004426// Zero/Any/Sign extensions
4427//===----------------------------------------------------------------------===//
4428
Scott Michel66377522007-12-04 22:35:58 +00004429// sext 8->32: Sign extend bytes to words
4430def : Pat<(sext_inreg R32C:$rSrc, i8),
4431 (XSHWr32 (XSBHr32 R32C:$rSrc))>;
4432
Scott Michel504c3692007-12-17 22:32:34 +00004433def : Pat<(i32 (sext R8C:$rSrc)),
4434 (XSHWr16 (XSBHr8 R8C:$rSrc))>;
4435
Scott Micheldd950092009-01-06 03:36:14 +00004436// sext 8->64: Sign extend bytes to double word
4437def : Pat<(sext_inreg R64C:$rSrc, i8),
4438 (XSWDr64_inreg (XSHWr64 (XSBHr64 R64C:$rSrc)))>;
4439
4440def : Pat<(i64 (sext R8C:$rSrc)),
4441 (XSWDr64 (XSHWr16 (XSBHr8 R8C:$rSrc)))>;
4442
Scott Michel504c3692007-12-17 22:32:34 +00004443// zext 8->16: Zero extend bytes to halfwords
4444def : Pat<(i16 (zext R8C:$rSrc)),
Scott Michela59d4692008-02-23 18:41:37 +00004445 (ANDHIi8i16 R8C:$rSrc, 0xff)>;
Scott Michel504c3692007-12-17 22:32:34 +00004446
Scott Michel504c3692007-12-17 22:32:34 +00004447// zext 8->32: Zero extend bytes to words
4448def : Pat<(i32 (zext R8C:$rSrc)),
Scott Michela59d4692008-02-23 18:41:37 +00004449 (ANDIi8i32 R8C:$rSrc, 0xff)>;
Scott Michel504c3692007-12-17 22:32:34 +00004450
Scott Micheldd950092009-01-06 03:36:14 +00004451// zext 8->64: Zero extend bytes to double words
4452def : Pat<(i64 (zext R8C:$rSrc)),
4453 (ORi64_v2i64 (SELBv4i32 (ROTQMBYv4i32
4454 (ORv4i32_i32 (ANDIi8i32 R8C:$rSrc, 0xff)),
4455 0x4),
4456 (ILv4i32 0x0),
4457 (FSMBIv4i32 0x0f0f)))>;
4458
4459// anyext 8->16: Extend 8->16 bits, irrespective of sign, preserves high bits
Scott Michel504c3692007-12-17 22:32:34 +00004460def : Pat<(i16 (anyext R8C:$rSrc)),
Scott Michela59d4692008-02-23 18:41:37 +00004461 (ORHIi8i16 R8C:$rSrc, 0)>;
Scott Michel504c3692007-12-17 22:32:34 +00004462
Scott Micheldd950092009-01-06 03:36:14 +00004463// anyext 8->32: Extend 8->32 bits, irrespective of sign, preserves high bits
Scott Michel504c3692007-12-17 22:32:34 +00004464def : Pat<(i32 (anyext R8C:$rSrc)),
Scott Michela59d4692008-02-23 18:41:37 +00004465 (ORIi8i32 R8C:$rSrc, 0)>;
Scott Michel504c3692007-12-17 22:32:34 +00004466
Scott Micheldd950092009-01-06 03:36:14 +00004467// sext 16->64: Sign extend halfword to double word
4468def : Pat<(sext_inreg R64C:$rSrc, i16),
4469 (XSWDr64_inreg (XSHWr64 R64C:$rSrc))>;
4470
4471def : Pat<(sext R16C:$rSrc),
4472 (XSWDr64 (XSHWr16 R16C:$rSrc))>;
4473
Scott Michela59d4692008-02-23 18:41:37 +00004474// zext 16->32: Zero extend halfwords to words
Scott Michel66377522007-12-04 22:35:58 +00004475def : Pat<(i32 (zext R16C:$rSrc)),
Scott Michela59d4692008-02-23 18:41:37 +00004476 (ANDi16i32 R16C:$rSrc, (ILAr32 0xffff))>;
Scott Michel66377522007-12-04 22:35:58 +00004477
4478def : Pat<(i32 (zext (and R16C:$rSrc, 0xf))),
Scott Michela59d4692008-02-23 18:41:37 +00004479 (ANDIi16i32 R16C:$rSrc, 0xf)>;
Scott Michel66377522007-12-04 22:35:58 +00004480
4481def : Pat<(i32 (zext (and R16C:$rSrc, 0xff))),
Scott Michela59d4692008-02-23 18:41:37 +00004482 (ANDIi16i32 R16C:$rSrc, 0xff)>;
Scott Michel66377522007-12-04 22:35:58 +00004483
4484def : Pat<(i32 (zext (and R16C:$rSrc, 0xfff))),
Scott Michela59d4692008-02-23 18:41:37 +00004485 (ANDIi16i32 R16C:$rSrc, 0xfff)>;
Scott Michel66377522007-12-04 22:35:58 +00004486
4487// anyext 16->32: Extend 16->32 bits, irrespective of sign
4488def : Pat<(i32 (anyext R16C:$rSrc)),
Scott Michela59d4692008-02-23 18:41:37 +00004489 (ORIi16i32 R16C:$rSrc, 0)>;
Scott Michel66377522007-12-04 22:35:58 +00004490
4491//===----------------------------------------------------------------------===//
Scott Michelf0569be2008-12-27 04:51:36 +00004492// Truncates:
4493// These truncates are for the SPU's supported types (i8, i16, i32). i64 and
4494// above are custom lowered.
4495//===----------------------------------------------------------------------===//
4496
4497def : Pat<(i8 (trunc GPRC:$src)),
4498 (ORi8_v16i8
4499 (SHUFBgprc GPRC:$src, GPRC:$src,
4500 (IOHLv4i32 (ILHUv4i32 0x0f0f), 0x0f0f)))>;
4501
4502def : Pat<(i8 (trunc R64C:$src)),
4503 (ORi8_v16i8
4504 (SHUFBv2i64_m32
4505 (ORv2i64_i64 R64C:$src),
4506 (ORv2i64_i64 R64C:$src),
4507 (IOHLv4i32 (ILHUv4i32 0x0707), 0x0707)))>;
4508
4509def : Pat<(i8 (trunc R32C:$src)),
4510 (ORi8_v16i8
4511 (SHUFBv4i32_m32
4512 (ORv4i32_i32 R32C:$src),
4513 (ORv4i32_i32 R32C:$src),
4514 (IOHLv4i32 (ILHUv4i32 0x0303), 0x0303)))>;
4515
4516def : Pat<(i8 (trunc R16C:$src)),
4517 (ORi8_v16i8
4518 (SHUFBv4i32_m32
4519 (ORv8i16_i16 R16C:$src),
4520 (ORv8i16_i16 R16C:$src),
4521 (IOHLv4i32 (ILHUv4i32 0x0303), 0x0303)))>;
4522
4523def : Pat<(i16 (trunc GPRC:$src)),
4524 (ORi16_v8i16
4525 (SHUFBgprc GPRC:$src, GPRC:$src,
4526 (IOHLv4i32 (ILHUv4i32 0x0e0f), 0x0e0f)))>;
4527
4528def : Pat<(i16 (trunc R64C:$src)),
4529 (ORi16_v8i16
4530 (SHUFBv2i64_m32
4531 (ORv2i64_i64 R64C:$src),
4532 (ORv2i64_i64 R64C:$src),
4533 (IOHLv4i32 (ILHUv4i32 0x0607), 0x0607)))>;
4534
4535def : Pat<(i16 (trunc R32C:$src)),
4536 (ORi16_v8i16
4537 (SHUFBv4i32_m32
4538 (ORv4i32_i32 R32C:$src),
4539 (ORv4i32_i32 R32C:$src),
4540 (IOHLv4i32 (ILHUv4i32 0x0203), 0x0203)))>;
4541
4542def : Pat<(i32 (trunc GPRC:$src)),
4543 (ORi32_v4i32
4544 (SHUFBgprc GPRC:$src, GPRC:$src,
4545 (IOHLv4i32 (ILHUv4i32 0x0c0d), 0x0e0f)))>;
4546
4547def : Pat<(i32 (trunc R64C:$src)),
4548 (ORi32_v4i32
4549 (SHUFBv2i64_m32
4550 (ORv2i64_i64 R64C:$src),
4551 (ORv2i64_i64 R64C:$src),
4552 (IOHLv4i32 (ILHUv4i32 0x0405), 0x0607)))>;
4553
4554//===----------------------------------------------------------------------===//
Scott Michel053c1da2008-01-29 02:16:57 +00004555// Address generation: SPU, like PPC, has to split addresses into high and
Scott Michel66377522007-12-04 22:35:58 +00004556// low parts in order to load them into a register.
4557//===----------------------------------------------------------------------===//
4558
Scott Michel053c1da2008-01-29 02:16:57 +00004559def : Pat<(SPUaform tglobaladdr:$in, 0), (ILAlsa tglobaladdr:$in)>;
4560def : Pat<(SPUaform texternalsym:$in, 0), (ILAlsa texternalsym:$in)>;
4561def : Pat<(SPUaform tjumptable:$in, 0), (ILAlsa tjumptable:$in)>;
4562def : Pat<(SPUaform tconstpool:$in, 0), (ILAlsa tconstpool:$in)>;
4563
4564def : Pat<(SPUindirect (SPUhi tglobaladdr:$in, 0),
4565 (SPUlo tglobaladdr:$in, 0)),
Scott Michel9de5d0d2008-01-11 02:53:15 +00004566 (IOHLlo (ILHUhi tglobaladdr:$in), tglobaladdr:$in)>;
Scott Michel58c58182008-01-17 20:38:41 +00004567
Scott Michel053c1da2008-01-29 02:16:57 +00004568def : Pat<(SPUindirect (SPUhi texternalsym:$in, 0),
4569 (SPUlo texternalsym:$in, 0)),
4570 (IOHLlo (ILHUhi texternalsym:$in), texternalsym:$in)>;
4571
4572def : Pat<(SPUindirect (SPUhi tjumptable:$in, 0),
4573 (SPUlo tjumptable:$in, 0)),
Scott Michel9de5d0d2008-01-11 02:53:15 +00004574 (IOHLlo (ILHUhi tjumptable:$in), tjumptable:$in)>;
Scott Michel58c58182008-01-17 20:38:41 +00004575
Scott Michel053c1da2008-01-29 02:16:57 +00004576def : Pat<(SPUindirect (SPUhi tconstpool:$in, 0),
4577 (SPUlo tconstpool:$in, 0)),
4578 (IOHLlo (ILHUhi tconstpool:$in), tconstpool:$in)>;
4579
4580def : Pat<(add (SPUhi tglobaladdr:$in, 0), (SPUlo tglobaladdr:$in, 0)),
4581 (IOHLlo (ILHUhi tglobaladdr:$in), tglobaladdr:$in)>;
4582
4583def : Pat<(add (SPUhi texternalsym:$in, 0), (SPUlo texternalsym:$in, 0)),
4584 (IOHLlo (ILHUhi texternalsym:$in), texternalsym:$in)>;
4585
4586def : Pat<(add (SPUhi tjumptable:$in, 0), (SPUlo tjumptable:$in, 0)),
4587 (IOHLlo (ILHUhi tjumptable:$in), tjumptable:$in)>;
4588
4589def : Pat<(add (SPUhi tconstpool:$in, 0), (SPUlo tconstpool:$in, 0)),
4590 (IOHLlo (ILHUhi tconstpool:$in), tconstpool:$in)>;
Scott Michel66377522007-12-04 22:35:58 +00004591
Scott Michel6e1d1472009-03-16 18:47:25 +00004592// Intrinsics:
Scott Michel66377522007-12-04 22:35:58 +00004593include "CellSDKIntrinsics.td"
Scott Michel02d711b2008-12-30 23:28:25 +00004594// Various math operator instruction sequences
4595include "SPUMathInstr.td"
Scott Michelf0569be2008-12-27 04:51:36 +00004596// 64-bit "instructions"/support
4597include "SPU64InstrInfo.td"
Scott Micheldd950092009-01-06 03:36:14 +00004598// 128-bit "instructions"/support
4599include "SPU128InstrInfo.td"