blob: f24ffd2f8d4d30d5e23c7ec42b830afddaf9c977 [file] [log] [blame]
Scott Michel8b6b4202007-12-04 22:35:58 +00001//==- SPUInstrInfo.td - Describe the Cell SPU Instructions -*- tablegen -*-==//
Scott Michel06eabde2008-12-27 04:51:36 +00002//
Scott Michel8b6b4202007-12-04 22:35:58 +00003// The LLVM Compiler Infrastructure
4//
Chris Lattner081ce942007-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 Michel06eabde2008-12-27 04:51:36 +00007//
Scott Michel8b6b4202007-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 Michelbc5fbc12008-04-30 00:30:08 +000025 def ADJCALLSTACKDOWN : Pseudo<(outs), (ins u16imm_i32:$amt),
Scott Michel8b6b4202007-12-04 22:35:58 +000026 "${:comment} ADJCALLSTACKDOWN",
Chris Lattnerfe5d4022008-10-11 22:08:30 +000027 [(callseq_start timm:$amt)]>;
Scott Michelbc5fbc12008-04-30 00:30:08 +000028 def ADJCALLSTACKUP : Pseudo<(outs), (ins u16imm_i32:$amt),
Scott Michel8b6b4202007-12-04 22:35:58 +000029 "${:comment} ADJCALLSTACKUP",
Chris Lattnerfe5d4022008-10-11 22:08:30 +000030 [(callseq_end timm:$amt)]>;
Scott Michel8b6b4202007-12-04 22:35:58 +000031}
32
33//===----------------------------------------------------------------------===//
Scott Michel8b6b4202007-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 Gohman5574cc72008-12-03 18:15:48 +000041let canFoldAsLoad = 1 in {
Scott Michelf9f42e62008-01-29 02:16:57 +000042 class LoadDFormVec<ValueType vectype>
Scott Michel06eabde2008-12-27 04:51:36 +000043 : RI10Form<0b00101100, (outs VECREG:$rT), (ins dformaddr:$src),
Scott Michelf9f42e62008-01-29 02:16:57 +000044 "lqd\t$rT, $src",
45 LoadStore,
46 [(set (vectype VECREG:$rT), (load dform_addr:$src))]>
47 { }
Scott Michel8b6b4202007-12-04 22:35:58 +000048
Scott Michelf9f42e62008-01-29 02:16:57 +000049 class LoadDForm<RegisterClass rclass>
Scott Michel06eabde2008-12-27 04:51:36 +000050 : RI10Form<0b00101100, (outs rclass:$rT), (ins dformaddr:$src),
Scott Michelf9f42e62008-01-29 02:16:57 +000051 "lqd\t$rT, $src",
52 LoadStore,
53 [(set rclass:$rT, (load dform_addr:$src))]>
54 { }
Scott Michel8b6b4202007-12-04 22:35:58 +000055
Scott Michelf9f42e62008-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 Michel8b6b4202007-12-04 22:35:58 +000064
Scott Michel70741542009-01-06 23:10:38 +000065 def v2i32: LoadDFormVec<v2i32>;
66
Scott Michelf9f42e62008-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 Michel8b6b4202007-12-04 22:35:58 +000075
Scott Michelf9f42e62008-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 Michel8b6b4202007-12-04 22:35:58 +000082
Scott Michelf9f42e62008-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 Michel8b6b4202007-12-04 22:35:58 +000089
Scott Michelf9f42e62008-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 Michel8b6b4202007-12-04 22:35:58 +000098
Scott Michel70741542009-01-06 23:10:38 +000099 def v2i32: LoadAFormVec<v2i32>;
100
Scott Michelf9f42e62008-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 Michel8b6b4202007-12-04 22:35:58 +0000109
Scott Michelf9f42e62008-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 Michel8b6b4202007-12-04 22:35:58 +0000116
Scott Michelf9f42e62008-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 Michel8b6b4202007-12-04 22:35:58 +0000123
Scott Michelf9f42e62008-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 Michel8b6b4202007-12-04 22:35:58 +0000132
Scott Michel70741542009-01-06 23:10:38 +0000133 def v2i32: LoadXFormVec<v2i32>;
134
Scott Michelf9f42e62008-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 Michel8b6b4202007-12-04 22:35:58 +0000143
Scott Michelf9f42e62008-01-29 02:16:57 +0000144 defm LQA : LoadAForms;
145 defm LQD : LoadDForms;
146 defm LQX : LoadXForms;
Scott Michel438be252007-12-17 22:32:34 +0000147
Scott Michel8b6b4202007-12-04 22:35:58 +0000148/* Load quadword, PC relative: Not much use at this point in time.
Scott Michelf9f42e62008-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 Michel8b6b4202007-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 Michel8b6b4202007-12-04 22:35:58 +0000155}
156
157//===----------------------------------------------------------------------===//
158// Stores:
159//===----------------------------------------------------------------------===//
Scott Michelf9f42e62008-01-29 02:16:57 +0000160class StoreDFormVec<ValueType vectype>
Scott Michel06eabde2008-12-27 04:51:36 +0000161 : RI10Form<0b00100100, (outs), (ins VECREG:$rT, dformaddr:$src),
Scott Michelf9f42e62008-01-29 02:16:57 +0000162 "stqd\t$rT, $src",
163 LoadStore,
164 [(store (vectype VECREG:$rT), dform_addr:$src)]>
165{ }
Scott Michel8b6b4202007-12-04 22:35:58 +0000166
Scott Michelf9f42e62008-01-29 02:16:57 +0000167class StoreDForm<RegisterClass rclass>
Scott Michel06eabde2008-12-27 04:51:36 +0000168 : RI10Form<0b00100100, (outs), (ins rclass:$rT, dformaddr:$src),
Scott Michelf9f42e62008-01-29 02:16:57 +0000169 "stqd\t$rT, $src",
170 LoadStore,
171 [(store rclass:$rT, dform_addr:$src)]>
172{ }
Scott Michel8b6b4202007-12-04 22:35:58 +0000173
Scott Michelf9f42e62008-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 Michel8b6b4202007-12-04 22:35:58 +0000182
Scott Michel70741542009-01-06 23:10:38 +0000183 def v2i32: StoreDFormVec<v2i32>;
184
Scott Michelf9f42e62008-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 Michel8b6b4202007-12-04 22:35:58 +0000193
Scott Michelf9f42e62008-01-29 02:16:57 +0000194class StoreAFormVec<ValueType vectype>
195 : RI16Form<0b0010010, (outs), (ins VECREG:$rT, addr256k:$src),
Scott Michel5a6f17b2008-01-30 02:55:46 +0000196 "stqa\t$rT, $src",
197 LoadStore,
Scott Michel6baba072008-03-05 23:02:02 +0000198 [(store (vectype VECREG:$rT), aform_addr:$src)]>;
Scott Michel8b6b4202007-12-04 22:35:58 +0000199
Scott Michelf9f42e62008-01-29 02:16:57 +0000200class StoreAForm<RegisterClass rclass>
201 : RI16Form<0b001001, (outs), (ins rclass:$rT, addr256k:$src),
Scott Michel5a6f17b2008-01-30 02:55:46 +0000202 "stqa\t$rT, $src",
203 LoadStore,
Scott Michel6baba072008-03-05 23:02:02 +0000204 [(store rclass:$rT, aform_addr:$src)]>;
Scott Michel8b6b4202007-12-04 22:35:58 +0000205
Scott Michelf9f42e62008-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 Michel8b6b4202007-12-04 22:35:58 +0000214
Scott Michel70741542009-01-06 23:10:38 +0000215 def v2i32: StoreAFormVec<v2i32>;
216
Scott Michelf9f42e62008-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 Michel8b6b4202007-12-04 22:35:58 +0000225
Scott Michelf9f42e62008-01-29 02:16:57 +0000226class StoreXFormVec<ValueType vectype>
227 : RRForm<0b00100100, (outs), (ins VECREG:$rT, memrr:$src),
Scott Michel5a6f17b2008-01-30 02:55:46 +0000228 "stqx\t$rT, $src",
229 LoadStore,
230 [(store (vectype VECREG:$rT), xform_addr:$src)]>
Scott Michelf9f42e62008-01-29 02:16:57 +0000231{ }
Scott Michel8b6b4202007-12-04 22:35:58 +0000232
Scott Michelf9f42e62008-01-29 02:16:57 +0000233class StoreXForm<RegisterClass rclass>
234 : RRForm<0b00100100, (outs), (ins rclass:$rT, memrr:$src),
Scott Michel5a6f17b2008-01-30 02:55:46 +0000235 "stqx\t$rT, $src",
236 LoadStore,
237 [(store rclass:$rT, xform_addr:$src)]>
Scott Michelf9f42e62008-01-29 02:16:57 +0000238{ }
Scott Michel8b6b4202007-12-04 22:35:58 +0000239
Scott Michelf9f42e62008-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 Michel8b6b4202007-12-04 22:35:58 +0000248
Scott Michel70741542009-01-06 23:10:38 +0000249 def v2i32: StoreXFormVec<v2i32>;
250
Scott Michelf9f42e62008-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 Michel8b6b4202007-12-04 22:35:58 +0000259
Scott Michelf9f42e62008-01-29 02:16:57 +0000260defm STQD : StoreDForms;
261defm STQA : StoreAForms;
262defm STQX : StoreXForms;
Scott Michel8b6b4202007-12-04 22:35:58 +0000263
264/* Store quadword, PC relative: Not much use at this point in time. Might
Scott Michelf9f42e62008-01-29 02:16:57 +0000265 be useful for relocatable code.
Chris Lattneref8d6082008-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 Michel8b6b4202007-12-04 22:35:58 +0000270
271//===----------------------------------------------------------------------===//
272// Generate Controls for Insertion:
273//===----------------------------------------------------------------------===//
274
Scott Michel06eabde2008-12-27 04:51:36 +0000275def CBD: RI7Form<0b10101111100, (outs VECREG:$rT), (ins shufaddr:$src),
Scott Michel0718cd82008-12-01 17:56:02 +0000276 "cbd\t$rT, $src", ShuffleOp,
277 [(set (v16i8 VECREG:$rT), (SPUshufmask dform2_addr:$src))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +0000278
Scott Michel0718cd82008-12-01 17:56:02 +0000279def CBX: RRForm<0b00101011100, (outs VECREG:$rT), (ins memrr:$src),
Scott Michel8b6b4202007-12-04 22:35:58 +0000280 "cbx\t$rT, $src", ShuffleOp,
Scott Michel56a125e2008-11-22 23:50:42 +0000281 [(set (v16i8 VECREG:$rT), (SPUshufmask xform_addr:$src))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +0000282
Scott Michel06eabde2008-12-27 04:51:36 +0000283def CHD: RI7Form<0b10101111100, (outs VECREG:$rT), (ins shufaddr:$src),
Scott Michel8b6b4202007-12-04 22:35:58 +0000284 "chd\t$rT, $src", ShuffleOp,
Scott Michel56a125e2008-11-22 23:50:42 +0000285 [(set (v8i16 VECREG:$rT), (SPUshufmask dform2_addr:$src))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +0000286
Scott Michel0718cd82008-12-01 17:56:02 +0000287def CHX: RRForm<0b10101011100, (outs VECREG:$rT), (ins memrr:$src),
Scott Michel8b6b4202007-12-04 22:35:58 +0000288 "chx\t$rT, $src", ShuffleOp,
Scott Michel56a125e2008-11-22 23:50:42 +0000289 [(set (v8i16 VECREG:$rT), (SPUshufmask xform_addr:$src))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +0000290
Scott Michel06eabde2008-12-27 04:51:36 +0000291def CWD: RI7Form<0b01101111100, (outs VECREG:$rT), (ins shufaddr:$src),
Scott Michel8b6b4202007-12-04 22:35:58 +0000292 "cwd\t$rT, $src", ShuffleOp,
Scott Michel56a125e2008-11-22 23:50:42 +0000293 [(set (v4i32 VECREG:$rT), (SPUshufmask dform2_addr:$src))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +0000294
Scott Michel0718cd82008-12-01 17:56:02 +0000295def CWX: RRForm<0b01101011100, (outs VECREG:$rT), (ins memrr:$src),
Scott Michel8b6b4202007-12-04 22:35:58 +0000296 "cwx\t$rT, $src", ShuffleOp,
Scott Michel56a125e2008-11-22 23:50:42 +0000297 [(set (v4i32 VECREG:$rT), (SPUshufmask xform_addr:$src))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +0000298
Scott Michel06eabde2008-12-27 04:51:36 +0000299def CWDf32: RI7Form<0b01101111100, (outs VECREG:$rT), (ins shufaddr:$src),
Scott Michel0718cd82008-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 Michelbc5fbc12008-04-30 00:30:08 +0000304 "cwx\t$rT, $src", ShuffleOp,
Scott Michel56a125e2008-11-22 23:50:42 +0000305 [(set (v4f32 VECREG:$rT), (SPUshufmask xform_addr:$src))]>;
Scott Michelbc5fbc12008-04-30 00:30:08 +0000306
Scott Michel06eabde2008-12-27 04:51:36 +0000307def CDD: RI7Form<0b11101111100, (outs VECREG:$rT), (ins shufaddr:$src),
Scott Michel8b6b4202007-12-04 22:35:58 +0000308 "cdd\t$rT, $src", ShuffleOp,
Scott Michel56a125e2008-11-22 23:50:42 +0000309 [(set (v2i64 VECREG:$rT), (SPUshufmask dform2_addr:$src))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +0000310
Scott Michel0718cd82008-12-01 17:56:02 +0000311def CDX: RRForm<0b11101011100, (outs VECREG:$rT), (ins memrr:$src),
Scott Michel8b6b4202007-12-04 22:35:58 +0000312 "cdx\t$rT, $src", ShuffleOp,
Scott Michel56a125e2008-11-22 23:50:42 +0000313 [(set (v2i64 VECREG:$rT), (SPUshufmask xform_addr:$src))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +0000314
Scott Michel06eabde2008-12-27 04:51:36 +0000315def CDDf64: RI7Form<0b11101111100, (outs VECREG:$rT), (ins shufaddr:$src),
Scott Michel0718cd82008-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 Michelbc5fbc12008-04-30 00:30:08 +0000320 "cdx\t$rT, $src", ShuffleOp,
Scott Michel56a125e2008-11-22 23:50:42 +0000321 [(set (v2f64 VECREG:$rT), (SPUshufmask xform_addr:$src))]>;
Scott Michelbc5fbc12008-04-30 00:30:08 +0000322
Scott Michel8b6b4202007-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 Michel438be252007-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 Michel8b6b4202007-12-04 22:35:58 +0000344// IL does sign extension!
Scott Michel8b6b4202007-12-04 22:35:58 +0000345
Scott Michel6baba072008-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 Michel8b6b4202007-12-04 22:35:58 +0000349
Scott Michel6baba072008-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 Michel8b6b4202007-12-04 22:35:58 +0000353
Scott Michel6baba072008-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 Michel8b6b4202007-12-04 22:35:58 +0000357
Scott Michel6baba072008-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 Michel8b6b4202007-12-04 22:35:58 +0000362
Scott Michel6baba072008-03-05 23:02:02 +0000363 // TODO: Need v2f64, v4f32
Scott Michel8b6b4202007-12-04 22:35:58 +0000364
Scott Michel6baba072008-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 Michel8b6b4202007-12-04 22:35:58 +0000370
Scott Michel6baba072008-03-05 23:02:02 +0000371defm IL : ImmediateLoad;
Scott Michel8b6b4202007-12-04 22:35:58 +0000372
Scott Michel6baba072008-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 Michel8b6b4202007-12-04 22:35:58 +0000376
Scott Michel6baba072008-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 Michelbc5fbc12008-04-30 00:30:08 +0000388 def v4i32: ILHUVecInst<v4i32, u16imm_i32, immILHUvec>;
Scott Michel6baba072008-03-05 23:02:02 +0000389
390 def r64: ILHURegInst<R64C, u16imm_i64, hi16>;
Scott Michelbc5fbc12008-04-30 00:30:08 +0000391 def r32: ILHURegInst<R32C, u16imm_i32, hi16>;
Scott Michel6baba072008-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 Michel8b6b4202007-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 Michel6baba072008-03-05 23:02:02 +0000404
Scott Michel97872d32008-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 Michel8b6b4202007-12-04 22:35:58 +0000408
Scott Michel6baba072008-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 Michel97872d32008-02-23 18:41:37 +0000417multiclass ImmLoadAddress
418{
Scott Michel6baba072008-03-05 23:02:02 +0000419 def v2i64: ILAVecInst<v2i64, u18imm, v2i64Uns18Imm>;
420 def v4i32: ILAVecInst<v4i32, u18imm, v4i32Uns18Imm>;
Scott Michel8b6b4202007-12-04 22:35:58 +0000421
Scott Michel6baba072008-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 Michel8b6b4202007-12-04 22:35:58 +0000426
Scott Michel06eabde2008-12-27 04:51:36 +0000427 def hi: ILARegInst<R32C, symbolHi, imm18>;
Scott Michel6baba072008-03-05 23:02:02 +0000428 def lo: ILARegInst<R32C, symbolLo, imm18>;
Scott Michel8b6b4202007-12-04 22:35:58 +0000429
Scott Michel97872d32008-02-23 18:41:37 +0000430 def lsa: ILAInst<(outs R32C:$rT), (ins symbolLSA:$val),
431 [/* no pattern */]>;
432}
433
434defm ILA : ImmLoadAddress;
Scott Michel8b6b4202007-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 Michel6baba072008-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 Michel8b6b4202007-12-04 22:35:58 +0000446
Scott Michel6baba072008-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 Michel8b6b4202007-12-04 22:35:58 +0000450
Scott Michel6baba072008-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 Michel8b6b4202007-12-04 22:35:58 +0000454
Scott Michel6baba072008-03-05 23:02:02 +0000455multiclass ImmOrHalfwordLower
456{
457 def v2i64: IOHLVecInst<v2i64, u16imm_i64>;
Scott Michelbc5fbc12008-04-30 00:30:08 +0000458 def v4i32: IOHLVecInst<v4i32, u16imm_i32>;
Scott Michel6baba072008-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 Micheldbac4cf2008-01-11 02:53:15 +0000467
Scott Michel8b6b4202007-12-04 22:35:58 +0000468// Form select mask for bytes using immediate, used in conjunction with the
469// SELB instruction:
470
Scott Michel6baba072008-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 Michel67224b22008-06-02 22:18:03 +0000475 [(set (vectype VECREG:$rT), (SPUselmask (i16 immU16:$val)))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +0000476
Scott Michel97872d32008-02-23 18:41:37 +0000477multiclass FormSelectMaskBytesImm
Scott Michelf9f42e62008-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 Michel8b6b4202007-12-04 22:35:58 +0000484
Scott Michel97872d32008-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 Michel06eabde2008-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 Michel97872d32008-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 Michel06eabde2008-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 Michel97872d32008-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 Michel06eabde2008-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 Michel67224b22008-06-02 22:18:03 +0000545
546multiclass FormSelectMaskWord {
Scott Michel06eabde2008-12-27 04:51:36 +0000547 def v4i32: FSMVecInst<v4i32>;
548
549 def r32 : FSMRegInst<v4i32, R32C>;
550 def r16 : FSMRegInst<v4i32, R16C>;
Scott Michel67224b22008-06-02 22:18:03 +0000551}
552
553defm FSM : FormSelectMaskWord;
554
555// Special case when used for i64 math operations
556multiclass FormSelectMaskWord64 {
Scott Michel06eabde2008-12-27 04:51:36 +0000557 def r32 : FSMRegInst<v2i64, R32C>;
558 def r16 : FSMRegInst<v2i64, R16C>;
Scott Michel67224b22008-06-02 22:18:03 +0000559}
560
561defm FSM64 : FormSelectMaskWord64;
Scott Michel8b6b4202007-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 Michel8b6b4202007-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 Michel97872d32008-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 Michel4d07fb72008-12-30 23:28:25 +0000589 [(set R16C:$rT, (add R16C:$rA, i16ImmSExt10:$val))]>;
590
591// v4i32, i32 add instruction:
Scott Michel8b6b4202007-12-04 22:35:58 +0000592
Scott Michelae5cbf52008-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 Michel8b6b4202007-12-04 22:35:58 +0000597
Scott Michelae5cbf52008-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 Michel8b6b4202007-12-04 22:35:58 +0000602
Scott Michelae5cbf52008-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 Michelae5cbf52008-12-29 03:23:36 +0000612}
Scott Michel8b6b4202007-12-04 22:35:58 +0000613
Scott Michelae5cbf52008-12-29 03:23:36 +0000614defm A : AddInstruction;
Scott Michel438be252007-12-17 22:32:34 +0000615
Scott Michel4d07fb72008-12-30 23:28:25 +0000616class AIInst<dag OOL, dag IOL, list<dag> pattern>:
617 RI10Form<0b00111000, OOL, IOL,
pingbakb8913342009-01-26 03:37:41 +0000618 "ai\t$rT, $rA, $val", IntegerOp,
619 pattern>;
Scott Michel8b6b4202007-12-04 22:35:58 +0000620
Scott Michel4d07fb72008-12-30 23:28:25 +0000621class AIVecInst<ValueType vectype, PatLeaf immpred>:
622 AIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
pingbakb8913342009-01-26 03:37:41 +0000623 [(set (vectype VECREG:$rT), (add (vectype VECREG:$rA), immpred:$val))]>;
Scott Michel4d07fb72008-12-30 23:28:25 +0000624
625class AIFPVecInst<ValueType vectype, PatLeaf immpred>:
626 AIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
pingbakb8913342009-01-26 03:37:41 +0000627 [/* no pattern */]>;
Scott Michel4d07fb72008-12-30 23:28:25 +0000628
629class AIRegInst<RegisterClass rclass, PatLeaf immpred>:
630 AIInst<(outs rclass:$rT), (ins rclass:$rA, s10imm_i32:$val),
pingbakb8913342009-01-26 03:37:41 +0000631 [(set rclass:$rT, (add rclass:$rA, immpred:$val))]>;
Scott Michel4d07fb72008-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),
pingbakb8913342009-01-26 03:37:41 +0000636 [/* no pattern */]>;
Scott Michel4d07fb72008-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 Michel8b6b4202007-12-04 22:35:58 +0000648
Scott Michel438be252007-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 Michel8b6b4202007-12-04 22:35:58 +0000654
Scott Michel438be252007-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 Michel8b6b4202007-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 Michel67224b22008-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 Michel750b93f2009-01-15 04:41:47 +0000699 [/* no pattern */]>,
Scott Michel8b6b4202007-12-04 22:35:58 +0000700 RegConstraint<"$rCarry = $rT">,
701 NoEncode<"$rCarry">;
702
Scott Michel67224b22008-06-02 22:18:03 +0000703class ADDXRegInst<RegisterClass rclass>:
704 ADDXInst<(outs rclass:$rT),
705 (ins rclass:$rA, rclass:$rB, rclass:$rCarry),
Scott Michel750b93f2009-01-15 04:41:47 +0000706 [/* no pattern */]>,
Scott Michel8b6b4202007-12-04 22:35:58 +0000707 RegConstraint<"$rCarry = $rT">,
708 NoEncode<"$rCarry">;
709
Scott Michel67224b22008-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 Michel750b93f2009-01-15 04:41:47 +0000728 [/* no pattern */]>;
Scott Michel67224b22008-06-02 22:18:03 +0000729
730class CGRegInst<RegisterClass rclass>:
731 CGInst<(outs rclass:$rT),
732 (ins rclass:$rA, rclass:$rB),
Scott Michel750b93f2009-01-15 04:41:47 +0000733 [/* no pattern */]>;
Scott Michel67224b22008-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 Michel750b93f2009-01-15 04:41:47 +0000754 [/* no pattern */]>,
Scott Michel8b6b4202007-12-04 22:35:58 +0000755 RegConstraint<"$rCarry = $rT">,
756 NoEncode<"$rCarry">;
757
Scott Michel67224b22008-06-02 22:18:03 +0000758class SFXRegInst<RegisterClass rclass>:
759 SFXInst<(outs rclass:$rT),
760 (ins rclass:$rA, rclass:$rB, rclass:$rCarry),
Scott Michel750b93f2009-01-15 04:41:47 +0000761 [/* no pattern */]>,
Scott Michel67224b22008-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 Michel8b6b4202007-12-04 22:35:58 +0000774// BG: only available in vector form, doesn't match a pattern.
Scott Michel67224b22008-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 Michel8b6b4202007-12-04 22:35:58 +0000779
Scott Michel67224b22008-06-02 22:18:03 +0000780class BGVecInst<ValueType vectype>:
781 BGInst<(outs VECREG:$rT),
782 (ins VECREG:$rA, VECREG:$rB),
Scott Michel750b93f2009-01-15 04:41:47 +0000783 [/* no pattern */]>;
Scott Michel67224b22008-06-02 22:18:03 +0000784
785class BGRegInst<RegisterClass rclass>:
786 BGInst<(outs rclass:$rT),
787 (ins rclass:$rA, rclass:$rB),
Scott Michel750b93f2009-01-15 04:41:47 +0000788 [/* no pattern */]>;
Scott Michel67224b22008-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 Michel8b6b4202007-12-04 22:35:58 +0000800def BGXvec:
801 RRForm<0b11000010110, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB,
Scott Michel06eabde2008-12-27 04:51:36 +0000802 VECREG:$rCarry),
Scott Michel8b6b4202007-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 Michel4d07fb72008-12-30 23:28:25 +0000814 [/* no pattern */]>;
Scott Michel8b6b4202007-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 Michelae5cbf52008-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 Michel8b6b4202007-12-04 22:35:58 +0000828def MPYUv4i32:
Scott Michelae5cbf52008-12-29 03:23:36 +0000829 MPYUInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
Scott Michel4d07fb72008-12-30 23:28:25 +0000830 [/* no pattern */]>;
Scott Michel8b6b4202007-12-04 22:35:58 +0000831
832def MPYUr16:
Scott Michelae5cbf52008-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 Michel8b6b4202007-12-04 22:35:58 +0000835
836def MPYUr32:
Scott Michelae5cbf52008-12-29 03:23:36 +0000837 MPYUInst<(outs R32C:$rT), (ins R32C:$rA, R32C:$rB),
Scott Michel4d07fb72008-12-30 23:28:25 +0000838 [/* no pattern */]>;
Scott Michel8b6b4202007-12-04 22:35:58 +0000839
Scott Michelae5cbf52008-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 Michel8b6b4202007-12-04 22:35:58 +0000844 "mpyi\t$rT, $rA, $val", IntegerMulDiv,
Scott Michelae5cbf52008-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 Michel8b6b4202007-12-04 22:35:58 +0000851
852def MPYIr16:
Scott Michelae5cbf52008-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 Michel8b6b4202007-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 Michelae5cbf52008-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 Michel8b6b4202007-12-04 22:35:58 +0000864def MPYUIvec:
Scott Michelae5cbf52008-12-29 03:23:36 +0000865 MPYUIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
866 []>;
Scott Michel8b6b4202007-12-04 22:35:58 +0000867
868def MPYUIr16:
Scott Michelae5cbf52008-12-29 03:23:36 +0000869 MPYUIInst<(outs R16C:$rT), (ins R16C:$rA, s10imm:$val),
870 []>;
Scott Michel8b6b4202007-12-04 22:35:58 +0000871
872// mpya: 16 x 16 + 16 -> 32 bit result
Scott Michelae5cbf52008-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 Michel750b93f2009-01-15 04:41:47 +0000878def MPYAv4i32:
Scott Michelae5cbf52008-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 Michel8b6b4202007-12-04 22:35:58 +0000884
885def MPYAr32:
Scott Michelae5cbf52008-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 Michel8b6b4202007-12-04 22:35:58 +0000894
895def MPYAr32_sextinreg:
Scott Michelae5cbf52008-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 Michel8b6b4202007-12-04 22:35:58 +0000900
901// mpyh: multiply high, used to synthesize 32-bit multiplies
Scott Michelae5cbf52008-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 Michel8b6b4202007-12-04 22:35:58 +0000907def MPYHv4i32:
Scott Michelae5cbf52008-12-29 03:23:36 +0000908 MPYHInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
Scott Michel4d07fb72008-12-30 23:28:25 +0000909 [/* no pattern */]>;
Scott Michel8b6b4202007-12-04 22:35:58 +0000910
911def MPYHr32:
Scott Michelae5cbf52008-12-29 03:23:36 +0000912 MPYHInst<(outs R32C:$rT), (ins R32C:$rA, R32C:$rB),
Scott Michel4d07fb72008-12-30 23:28:25 +0000913 [/* no pattern */]>;
Scott Michel8b6b4202007-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 Michel8b6b4202007-12-04 22:35:58 +0000917
Scott Michel4d07fb72008-12-30 23:28:25 +0000918class MPYSInst<dag OOL, dag IOL>:
919 RRForm<0b11100011110, OOL, IOL,
Scott Michel8b6b4202007-12-04 22:35:58 +0000920 "mpys\t$rT, $rA, $rB", IntegerMulDiv,
Scott Michel4d07fb72008-12-30 23:28:25 +0000921 [/* no pattern */]>;
922
Scott Michel750b93f2009-01-15 04:41:47 +0000923def MPYSv4i32:
Scott Michel4d07fb72008-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 Michel8b6b4202007-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 Michel4d07fb72008-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 Michel8b6b4202007-12-04 22:35:58 +0000937def MPYHHv8i16:
Scott Michel4d07fb72008-12-30 23:28:25 +0000938 MPYHHInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB)>;
Scott Michel8b6b4202007-12-04 22:35:58 +0000939
940def MPYHHr32:
Scott Michel4d07fb72008-12-30 23:28:25 +0000941 MPYHHInst<(outs R32C:$rT), (ins R32C:$rA, R32C:$rB)>;
Scott Michel8b6b4202007-12-04 22:35:58 +0000942
943// mpyhha: Multiply high-high, add to $rT:
Scott Michel8b6b4202007-12-04 22:35:58 +0000944
Scott Michel4d07fb72008-12-30 23:28:25 +0000945class MPYHHAInst<dag OOL, dag IOL>:
946 RRForm<0b01100010110, OOL, IOL,
Scott Michel8b6b4202007-12-04 22:35:58 +0000947 "mpyhha\t$rT, $rA, $rB", IntegerMulDiv,
Scott Michel4d07fb72008-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 Michel8b6b4202007-12-04 22:35:58 +0000955
Scott Michel750b93f2009-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 Michel8b6b4202007-12-04 22:35:58 +0000963
Scott Michel4d07fb72008-12-30 23:28:25 +0000964class MPYHHUInst<dag OOL, dag IOL>:
965 RRForm<0b01110011110, OOL, IOL,
Scott Michel8b6b4202007-12-04 22:35:58 +0000966 "mpyhhu\t$rT, $rA, $rB", IntegerMulDiv,
Scott Michel4d07fb72008-12-30 23:28:25 +0000967 [/* no pattern */]>;
968
Scott Michel750b93f2009-01-15 04:41:47 +0000969def MPYHHUv4i32:
Scott Michel4d07fb72008-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 Michel8b6b4202007-12-04 22:35:58 +0000974
975// mpyhhau: Multiply high-high, unsigned
Scott Michel4d07fb72008-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 Michel8b6b4202007-12-04 22:35:58 +0000982def MPYHHAUvec:
Scott Michel4d07fb72008-12-30 23:28:25 +0000983 MPYHHAUInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB)>;
984
Scott Michel8b6b4202007-12-04 22:35:58 +0000985def MPYHHAUr32:
Scott Michel4d07fb72008-12-30 23:28:25 +0000986 MPYHHAUInst<(outs R32C:$rT), (ins R32C:$rA, R32C:$rB)>;
Scott Michelae5cbf52008-12-29 03:23:36 +0000987
988//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
Scott Michel8b6b4202007-12-04 22:35:58 +0000989// clz: Count leading zeroes
Scott Michelae5cbf52008-12-29 03:23:36 +0000990//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
Scott Michel06eabde2008-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 Michel8b6b4202007-12-04 22:35:58 +0000994
Scott Michel06eabde2008-12-27 04:51:36 +0000995class CLZRegInst<RegisterClass rclass>:
996 CLZInst<(outs rclass:$rT), (ins rclass:$rA),
Scott Michel4d07fb72008-12-30 23:28:25 +0000997 [(set rclass:$rT, (ctlz rclass:$rA))]>;
Scott Michel06eabde2008-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 Michel8b6b4202007-12-04 22:35:58 +00001009
1010// cntb: Count ones in bytes (aka "population count")
Scott Michel06eabde2008-12-27 04:51:36 +00001011//
Scott Michel8b6b4202007-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 Michel06eabde2008-12-27 04:51:36 +00001015
Scott Michel8b6b4202007-12-04 22:35:58 +00001016def CNTBv16i8:
1017 RRForm_1<0b00101101010, (outs VECREG:$rT), (ins VECREG:$rA),
1018 "cntb\t$rT, $rA", IntegerOp,
Scott Michel67224b22008-06-02 22:18:03 +00001019 [(set (v16i8 VECREG:$rT), (SPUcntb (v16i8 VECREG:$rA)))]>;
Scott Michel8b6b4202007-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 Michel67224b22008-06-02 22:18:03 +00001024 [(set (v8i16 VECREG:$rT), (SPUcntb (v8i16 VECREG:$rA)))]>;
Scott Michel8b6b4202007-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 Michel67224b22008-06-02 22:18:03 +00001029 [(set (v4i32 VECREG:$rT), (SPUcntb (v4i32 VECREG:$rA)))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001030
Scott Michel06eabde2008-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 Michel70741542009-01-06 23:10:38 +00001046 [/* no pattern */]>;
Scott Michel06eabde2008-12-27 04:51:36 +00001047
1048class GBBVecInst<ValueType vectype>:
1049 GBBInst<(outs VECREG:$rT), (ins VECREG:$rA),
Scott Michel70741542009-01-06 23:10:38 +00001050 [/* no pattern */]>;
Scott Michel06eabde2008-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 Michel8b6b4202007-12-04 22:35:58 +00001059
1060// gbh: Gather all low order bits from each halfword in $rA into a single
Scott Michel06eabde2008-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 Michel70741542009-01-06 23:10:38 +00001072 [/* no pattern */]>;
Scott Michel06eabde2008-12-27 04:51:36 +00001073
1074class GBHVecInst<ValueType vectype>:
1075 GBHInst<(outs VECREG:$rT), (ins VECREG:$rA),
Scott Michel70741542009-01-06 23:10:38 +00001076 [/* no pattern */]>;
Scott Michel06eabde2008-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 Michel8b6b4202007-12-04 22:35:58 +00001085
1086// gb: Gather all low order bits from each word in $rA into a single
Scott Michel06eabde2008-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 Michel70741542009-01-06 23:10:38 +00001098 [/* no pattern */]>;
Scott Michel06eabde2008-12-27 04:51:36 +00001099
1100class GBVecInst<ValueType vectype>:
1101 GBInst<(outs VECREG:$rT), (ins VECREG:$rA),
Scott Michel70741542009-01-06 23:10:38 +00001102 [/* no pattern */]>;
Scott Michel06eabde2008-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 Michel8b6b4202007-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 Michel67224b22008-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 Michel8b6b4202007-12-04 22:35:58 +00001135
Scott Michel67224b22008-06-02 22:18:03 +00001136class XSBHVecInst<ValueType vectype>:
1137 XSBHInst<(outs VECREG:$rDst), (ins VECREG:$rSrc),
1138 [(set (v8i16 VECREG:$rDst), (sext (vectype VECREG:$rSrc)))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001139
Scott Michel2ef773a2009-01-06 03:36:14 +00001140class XSBHInRegInst<RegisterClass rclass, list<dag> pattern>:
Scott Michel67224b22008-06-02 22:18:03 +00001141 XSBHInst<(outs rclass:$rDst), (ins rclass:$rSrc),
Scott Michel2ef773a2009-01-06 03:36:14 +00001142 pattern>;
Scott Michel67224b22008-06-02 22:18:03 +00001143
1144multiclass ExtendByteHalfword {
Scott Michel2ef773a2009-01-06 03:36:14 +00001145 def v16i8: XSBHVecInst<v8i16>;
1146 def r8: XSBHInst<(outs R16C:$rDst), (ins R8C:$rSrc),
1147 [(set R16C:$rDst, (sext R8C:$rSrc))]>;
1148 def r16: XSBHInRegInst<R16C,
1149 [(set R16C:$rDst, (sext_inreg R16C:$rSrc, i8))]>;
Scott Michel67224b22008-06-02 22:18:03 +00001150
1151 // 32-bit form for XSBH: used to sign extend 8-bit quantities to 16-bit
1152 // quantities to 32-bit quantities via a 32-bit register (see the sext 8->32
1153 // pattern below). Intentionally doesn't match a pattern because we want the
1154 // sext 8->32 pattern to do the work for us, namely because we need the extra
1155 // XSHWr32.
Scott Michel2ef773a2009-01-06 03:36:14 +00001156 def r32: XSBHInRegInst<R32C, [/* no pattern */]>;
1157
1158 // Same as the 32-bit version, but for i64
1159 def r64: XSBHInRegInst<R64C, [/* no pattern */]>;
Scott Michel67224b22008-06-02 22:18:03 +00001160}
1161
1162defm XSBH : ExtendByteHalfword;
1163
Scott Michel8b6b4202007-12-04 22:35:58 +00001164// Sign extend halfwords to words:
Scott Michel8b6b4202007-12-04 22:35:58 +00001165
Scott Michel2ef773a2009-01-06 03:36:14 +00001166class XSHWInst<dag OOL, dag IOL, list<dag> pattern>:
1167 RRForm_1<0b01101101010, OOL, IOL, "xshw\t$rDest, $rSrc",
1168 IntegerOp, pattern>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001169
Scott Michel2ef773a2009-01-06 03:36:14 +00001170class XSHWVecInst<ValueType in_vectype, ValueType out_vectype>:
1171 XSHWInst<(outs VECREG:$rDest), (ins VECREG:$rSrc),
1172 [(set (out_vectype VECREG:$rDest),
1173 (sext (in_vectype VECREG:$rSrc)))]>;
1174
1175class XSHWInRegInst<RegisterClass rclass, list<dag> pattern>:
1176 XSHWInst<(outs rclass:$rDest), (ins rclass:$rSrc),
1177 pattern>;
1178
1179class XSHWRegInst<RegisterClass rclass>:
1180 XSHWInst<(outs rclass:$rDest), (ins R16C:$rSrc),
1181 [(set rclass:$rDest, (sext R16C:$rSrc))]>;
1182
1183multiclass ExtendHalfwordWord {
1184 def v4i32: XSHWVecInst<v4i32, v8i16>;
1185
1186 def r16: XSHWRegInst<R32C>;
1187
1188 def r32: XSHWInRegInst<R32C,
1189 [(set R32C:$rDest, (sext_inreg R32C:$rSrc, i16))]>;
1190 def r64: XSHWInRegInst<R64C, [/* no pattern */]>;
1191}
1192
1193defm XSHW : ExtendHalfwordWord;
Scott Michel8b6b4202007-12-04 22:35:58 +00001194
Scott Michele0168c12009-01-05 01:34:35 +00001195// Sign-extend words to doublewords (32->64 bits)
Scott Michel8b6b4202007-12-04 22:35:58 +00001196
Scott Michele0168c12009-01-05 01:34:35 +00001197class XSWDInst<dag OOL, dag IOL, list<dag> pattern>:
Scott Michel2ef773a2009-01-06 03:36:14 +00001198 RRForm_1<0b01100101010, OOL, IOL, "xswd\t$rDst, $rSrc",
1199 IntegerOp, pattern>;
Scott Michele0168c12009-01-05 01:34:35 +00001200
1201class XSWDVecInst<ValueType in_vectype, ValueType out_vectype>:
1202 XSWDInst<(outs VECREG:$rDst), (ins VECREG:$rSrc),
1203 [(set (out_vectype VECREG:$rDst),
1204 (sext (out_vectype VECREG:$rSrc)))]>;
1205
1206class XSWDRegInst<RegisterClass in_rclass, RegisterClass out_rclass>:
1207 XSWDInst<(outs out_rclass:$rDst), (ins in_rclass:$rSrc),
1208 [(set out_rclass:$rDst, (sext in_rclass:$rSrc))]>;
1209
1210multiclass ExtendWordToDoubleWord {
1211 def v2i64: XSWDVecInst<v4i32, v2i64>;
1212 def r64: XSWDRegInst<R32C, R64C>;
1213
1214 def r64_inreg: XSWDInst<(outs R64C:$rDst), (ins R64C:$rSrc),
1215 [(set R64C:$rDst, (sext_inreg R64C:$rSrc, i32))]>;
1216}
Scott Michel8b6b4202007-12-04 22:35:58 +00001217
Scott Michele0168c12009-01-05 01:34:35 +00001218defm XSWD : ExtendWordToDoubleWord;
Scott Michel8b6b4202007-12-04 22:35:58 +00001219
1220// AND operations
Scott Michel8b6b4202007-12-04 22:35:58 +00001221
Scott Michel97872d32008-02-23 18:41:37 +00001222class ANDInst<dag OOL, dag IOL, list<dag> pattern> :
1223 RRForm<0b10000011000, OOL, IOL, "and\t$rT, $rA, $rB",
1224 IntegerOp, pattern>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001225
Scott Michel97872d32008-02-23 18:41:37 +00001226class ANDVecInst<ValueType vectype>:
1227 ANDInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1228 [(set (vectype VECREG:$rT), (and (vectype VECREG:$rA),
1229 (vectype VECREG:$rB)))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001230
Scott Michel6baba072008-03-05 23:02:02 +00001231class ANDRegInst<RegisterClass rclass>:
1232 ANDInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB),
1233 [(set rclass:$rT, (and rclass:$rA, rclass:$rB))]>;
1234
Scott Michel97872d32008-02-23 18:41:37 +00001235multiclass BitwiseAnd
1236{
1237 def v16i8: ANDVecInst<v16i8>;
1238 def v8i16: ANDVecInst<v8i16>;
1239 def v4i32: ANDVecInst<v4i32>;
1240 def v2i64: ANDVecInst<v2i64>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001241
Scott Michel6baba072008-03-05 23:02:02 +00001242 def r128: ANDRegInst<GPRC>;
1243 def r64: ANDRegInst<R64C>;
1244 def r32: ANDRegInst<R32C>;
1245 def r16: ANDRegInst<R16C>;
1246 def r8: ANDRegInst<R8C>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001247
Scott Michel97872d32008-02-23 18:41:37 +00001248 //===---------------------------------------------
1249 // Special instructions to perform the fabs instruction
1250 def fabs32: ANDInst<(outs R32FP:$rT), (ins R32FP:$rA, R32C:$rB),
1251 [/* Intentionally does not match a pattern */]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001252
Scott Michel0d5eae02009-03-17 01:15:45 +00001253 def fabs64: ANDInst<(outs R64FP:$rT), (ins R64FP:$rA, R64C:$rB),
pingbak2f387e82009-01-26 03:31:40 +00001254 [/* Intentionally does not match a pattern */]>;
1255
Scott Michel97872d32008-02-23 18:41:37 +00001256 def fabsvec: ANDInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1257 [/* Intentionally does not match a pattern */]>;
1258
1259 //===---------------------------------------------
1260
1261 // Hacked form of AND to zero-extend 16-bit quantities to 32-bit
1262 // quantities -- see 16->32 zext pattern.
1263 //
1264 // This pattern is somewhat artificial, since it might match some
1265 // compiler generated pattern but it is unlikely to do so.
1266
1267 def i16i32: ANDInst<(outs R32C:$rT), (ins R16C:$rA, R32C:$rB),
1268 [(set R32C:$rT, (and (zext R16C:$rA), R32C:$rB))]>;
1269}
1270
1271defm AND : BitwiseAnd;
Scott Michel8b6b4202007-12-04 22:35:58 +00001272
1273// N.B.: vnot_conv is one of those special target selection pattern fragments,
1274// in which we expect there to be a bit_convert on the constant. Bear in mind
1275// that llvm translates "not <reg>" to "xor <reg>, -1" (or in this case, a
1276// constant -1 vector.)
Scott Michel8b6b4202007-12-04 22:35:58 +00001277
Scott Michel97872d32008-02-23 18:41:37 +00001278class ANDCInst<dag OOL, dag IOL, list<dag> pattern>:
1279 RRForm<0b10000011010, OOL, IOL, "andc\t$rT, $rA, $rB",
1280 IntegerOp, pattern>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001281
Scott Michel0d5eae02009-03-17 01:15:45 +00001282class ANDCVecInst<ValueType vectype, PatFrag vnot_frag = vnot>:
Scott Michel97872d32008-02-23 18:41:37 +00001283 ANDCInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
Scott Michel0d5eae02009-03-17 01:15:45 +00001284 [(set (vectype VECREG:$rT),
1285 (and (vectype VECREG:$rA),
1286 (vnot_frag (vectype VECREG:$rB))))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001287
Scott Michel97872d32008-02-23 18:41:37 +00001288class ANDCRegInst<RegisterClass rclass>:
1289 ANDCInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB),
1290 [(set rclass:$rT, (and rclass:$rA, (not rclass:$rB)))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001291
Scott Michel97872d32008-02-23 18:41:37 +00001292multiclass AndComplement
1293{
1294 def v16i8: ANDCVecInst<v16i8>;
1295 def v8i16: ANDCVecInst<v8i16>;
1296 def v4i32: ANDCVecInst<v4i32>;
1297 def v2i64: ANDCVecInst<v2i64>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001298
Scott Michel97872d32008-02-23 18:41:37 +00001299 def r128: ANDCRegInst<GPRC>;
1300 def r64: ANDCRegInst<R64C>;
1301 def r32: ANDCRegInst<R32C>;
1302 def r16: ANDCRegInst<R16C>;
1303 def r8: ANDCRegInst<R8C>;
Scott Michel0d5eae02009-03-17 01:15:45 +00001304
1305 // Sometimes, the xor pattern has a bitcast constant:
1306 def v16i8_conv: ANDCVecInst<v16i8, vnot_conv>;
Scott Michel97872d32008-02-23 18:41:37 +00001307}
Scott Michel438be252007-12-17 22:32:34 +00001308
Scott Michel97872d32008-02-23 18:41:37 +00001309defm ANDC : AndComplement;
Scott Michel8b6b4202007-12-04 22:35:58 +00001310
Scott Michel97872d32008-02-23 18:41:37 +00001311class ANDBIInst<dag OOL, dag IOL, list<dag> pattern>:
1312 RI10Form<0b01101000, OOL, IOL, "andbi\t$rT, $rA, $val",
Scott Michel61895fe2008-12-10 00:15:19 +00001313 ByteOp, pattern>;
Scott Michel438be252007-12-17 22:32:34 +00001314
Scott Michel97872d32008-02-23 18:41:37 +00001315multiclass AndByteImm
1316{
1317 def v16i8: ANDBIInst<(outs VECREG:$rT), (ins VECREG:$rA, u10imm:$val),
1318 [(set (v16i8 VECREG:$rT),
1319 (and (v16i8 VECREG:$rA),
1320 (v16i8 v16i8U8Imm:$val)))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001321
Scott Michel97872d32008-02-23 18:41:37 +00001322 def r8: ANDBIInst<(outs R8C:$rT), (ins R8C:$rA, u10imm_i8:$val),
1323 [(set R8C:$rT, (and R8C:$rA, immU8:$val))]>;
1324}
Scott Michel438be252007-12-17 22:32:34 +00001325
Scott Michel97872d32008-02-23 18:41:37 +00001326defm ANDBI : AndByteImm;
Scott Michel8b6b4202007-12-04 22:35:58 +00001327
Scott Michel97872d32008-02-23 18:41:37 +00001328class ANDHIInst<dag OOL, dag IOL, list<dag> pattern> :
1329 RI10Form<0b10101000, OOL, IOL, "andhi\t$rT, $rA, $val",
Scott Michel61895fe2008-12-10 00:15:19 +00001330 ByteOp, pattern>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001331
Scott Michel97872d32008-02-23 18:41:37 +00001332multiclass AndHalfwordImm
1333{
1334 def v8i16: ANDHIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
1335 [(set (v8i16 VECREG:$rT),
1336 (and (v8i16 VECREG:$rA), v8i16SExt10Imm:$val))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001337
Scott Michel97872d32008-02-23 18:41:37 +00001338 def r16: ANDHIInst<(outs R16C:$rT), (ins R16C:$rA, u10imm:$val),
1339 [(set R16C:$rT, (and R16C:$rA, i16ImmUns10:$val))]>;
Scott Michel438be252007-12-17 22:32:34 +00001340
Scott Michel97872d32008-02-23 18:41:37 +00001341 // Zero-extend i8 to i16:
1342 def i8i16: ANDHIInst<(outs R16C:$rT), (ins R8C:$rA, u10imm:$val),
1343 [(set R16C:$rT, (and (zext R8C:$rA), i16ImmUns10:$val))]>;
1344}
Scott Michel8b6b4202007-12-04 22:35:58 +00001345
Scott Michel97872d32008-02-23 18:41:37 +00001346defm ANDHI : AndHalfwordImm;
1347
1348class ANDIInst<dag OOL, dag IOL, list<dag> pattern> :
1349 RI10Form<0b00101000, OOL, IOL, "andi\t$rT, $rA, $val",
1350 IntegerOp, pattern>;
1351
1352multiclass AndWordImm
1353{
1354 def v4i32: ANDIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
1355 [(set (v4i32 VECREG:$rT),
1356 (and (v4i32 VECREG:$rA), v4i32SExt10Imm:$val))]>;
1357
1358 def r32: ANDIInst<(outs R32C:$rT), (ins R32C:$rA, s10imm_i32:$val),
1359 [(set R32C:$rT, (and R32C:$rA, i32ImmSExt10:$val))]>;
1360
1361 // Hacked form of ANDI to zero-extend i8 quantities to i32. See the zext 8->32
1362 // pattern below.
1363 def i8i32: ANDIInst<(outs R32C:$rT), (ins R8C:$rA, s10imm_i32:$val),
1364 [(set R32C:$rT,
1365 (and (zext R8C:$rA), i32ImmSExt10:$val))]>;
1366
1367 // Hacked form of ANDI to zero-extend i16 quantities to i32. See the
1368 // zext 16->32 pattern below.
1369 //
1370 // Note that this pattern is somewhat artificial, since it might match
1371 // something the compiler generates but is unlikely to occur in practice.
1372 def i16i32: ANDIInst<(outs R32C:$rT), (ins R16C:$rA, s10imm_i32:$val),
1373 [(set R32C:$rT,
1374 (and (zext R16C:$rA), i32ImmSExt10:$val))]>;
1375}
1376
1377defm ANDI : AndWordImm;
1378
1379//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
Scott Michel8b6b4202007-12-04 22:35:58 +00001380// Bitwise OR group:
Scott Michel97872d32008-02-23 18:41:37 +00001381//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
1382
Scott Michel8b6b4202007-12-04 22:35:58 +00001383// Bitwise "or" (N.B.: These are also register-register copy instructions...)
Scott Michel97872d32008-02-23 18:41:37 +00001384class ORInst<dag OOL, dag IOL, list<dag> pattern>:
1385 RRForm<0b10000010000, OOL, IOL, "or\t$rT, $rA, $rB",
1386 IntegerOp, pattern>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001387
Scott Michel97872d32008-02-23 18:41:37 +00001388class ORVecInst<ValueType vectype>:
1389 ORInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1390 [(set (vectype VECREG:$rT), (or (vectype VECREG:$rA),
1391 (vectype VECREG:$rB)))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001392
Scott Michel97872d32008-02-23 18:41:37 +00001393class ORRegInst<RegisterClass rclass>:
1394 ORInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB),
1395 [(set rclass:$rT, (or rclass:$rA, rclass:$rB))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001396
Scott Michel06eabde2008-12-27 04:51:36 +00001397// ORCvtForm: OR conversion form
1398//
1399// This is used to "convert" the preferred slot to its vector equivalent, as
1400// well as convert a vector back to its preferred slot.
1401//
1402// These are effectively no-ops, but need to exist for proper type conversion
1403// and type coercion.
1404
Scott Michel8c67fa42009-01-21 04:58:48 +00001405class ORCvtForm<dag OOL, dag IOL, list<dag> pattern = [/* no pattern */]>
Scott Michel06eabde2008-12-27 04:51:36 +00001406 : SPUInstr<OOL, IOL, "or\t$rT, $rA, $rA", IntegerOp> {
1407 bits<7> RA;
1408 bits<7> RT;
1409
Scott Michel8c67fa42009-01-21 04:58:48 +00001410 let Pattern = pattern;
Scott Michel06eabde2008-12-27 04:51:36 +00001411
1412 let Inst{0-10} = 0b10000010000;
1413 let Inst{11-17} = RA;
1414 let Inst{18-24} = RA;
1415 let Inst{25-31} = RT;
1416}
1417
Scott Michel97872d32008-02-23 18:41:37 +00001418class ORPromoteScalar<RegisterClass rclass>:
Scott Michel06eabde2008-12-27 04:51:36 +00001419 ORCvtForm<(outs VECREG:$rT), (ins rclass:$rA)>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001420
Scott Michel97872d32008-02-23 18:41:37 +00001421class ORExtractElt<RegisterClass rclass>:
Scott Michel06eabde2008-12-27 04:51:36 +00001422 ORCvtForm<(outs rclass:$rT), (ins VECREG:$rA)>;
1423
Scott Michel8c67fa42009-01-21 04:58:48 +00001424/* class ORCvtRegGPRC<RegisterClass rclass>:
1425 ORCvtForm<(outs GPRC:$rT), (ins rclass:$rA)>; */
Scott Michel06eabde2008-12-27 04:51:36 +00001426
Scott Michel8c67fa42009-01-21 04:58:48 +00001427/* class ORCvtGPRCReg<RegisterClass rclass>:
1428 ORCvtForm<(outs rclass:$rT), (ins GPRC:$rA)>; */
Scott Michel2ef773a2009-01-06 03:36:14 +00001429
Scott Michel8c67fa42009-01-21 04:58:48 +00001430class ORCvtFormR32Reg<RegisterClass rclass, list<dag> pattern = [ ]>:
1431 ORCvtForm<(outs rclass:$rT), (ins R32C:$rA), pattern>;
Scott Michel2ef773a2009-01-06 03:36:14 +00001432
Scott Michel8c67fa42009-01-21 04:58:48 +00001433class ORCvtFormRegR32<RegisterClass rclass, list<dag> pattern = [ ]>:
1434 ORCvtForm<(outs R32C:$rT), (ins rclass:$rA), pattern>;
Scott Michel2ef773a2009-01-06 03:36:14 +00001435
Scott Michel8c67fa42009-01-21 04:58:48 +00001436class ORCvtFormR64Reg<RegisterClass rclass, list<dag> pattern = [ ]>:
1437 ORCvtForm<(outs rclass:$rT), (ins R64C:$rA), pattern>;
Scott Michel2ef773a2009-01-06 03:36:14 +00001438
Scott Michel8c67fa42009-01-21 04:58:48 +00001439class ORCvtFormRegR64<RegisterClass rclass, list<dag> pattern = [ ]>:
1440 ORCvtForm<(outs R64C:$rT), (ins rclass:$rA), pattern>;
Scott Michel06eabde2008-12-27 04:51:36 +00001441
Scott Michel34712c32009-03-16 18:47:25 +00001442class ORCvtGPRCVec:
1443 ORCvtForm<(outs VECREG:$rT), (ins GPRC:$rA)>;
1444
1445class ORCvtVecGPRC:
1446 ORCvtForm<(outs GPRC:$rT), (ins VECREG:$rA)>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001447
Scott Michel97872d32008-02-23 18:41:37 +00001448multiclass BitwiseOr
1449{
1450 def v16i8: ORVecInst<v16i8>;
1451 def v8i16: ORVecInst<v8i16>;
1452 def v4i32: ORVecInst<v4i32>;
1453 def v2i64: ORVecInst<v2i64>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001454
Scott Michel97872d32008-02-23 18:41:37 +00001455 def v4f32: ORInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1456 [(set (v4f32 VECREG:$rT),
1457 (v4f32 (bitconvert (or (v4i32 VECREG:$rA),
1458 (v4i32 VECREG:$rB)))))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001459
Scott Michel97872d32008-02-23 18:41:37 +00001460 def v2f64: ORInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
Scott Michel06eabde2008-12-27 04:51:36 +00001461 [(set (v2f64 VECREG:$rT),
Scott Michel97872d32008-02-23 18:41:37 +00001462 (v2f64 (bitconvert (or (v2i64 VECREG:$rA),
1463 (v2i64 VECREG:$rB)))))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001464
Scott Michel8c67fa42009-01-21 04:58:48 +00001465 def r128: ORRegInst<GPRC>;
1466 def r64: ORRegInst<R64C>;
1467 def r32: ORRegInst<R32C>;
1468 def r16: ORRegInst<R16C>;
1469 def r8: ORRegInst<R8C>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001470
Scott Michel97872d32008-02-23 18:41:37 +00001471 // OR instructions used to copy f32 and f64 registers.
1472 def f32: ORInst<(outs R32FP:$rT), (ins R32FP:$rA, R32FP:$rB),
1473 [/* no pattern */]>;
Scott Michel438be252007-12-17 22:32:34 +00001474
Scott Michel97872d32008-02-23 18:41:37 +00001475 def f64: ORInst<(outs R64FP:$rT), (ins R64FP:$rA, R64FP:$rB),
1476 [/* no pattern */]>;
Scott Michel754d8662007-12-20 00:44:13 +00001477
Scott Michel4d07fb72008-12-30 23:28:25 +00001478 // scalar->vector promotion, prefslot2vec:
Scott Michel97872d32008-02-23 18:41:37 +00001479 def v16i8_i8: ORPromoteScalar<R8C>;
1480 def v8i16_i16: ORPromoteScalar<R16C>;
1481 def v4i32_i32: ORPromoteScalar<R32C>;
1482 def v2i64_i64: ORPromoteScalar<R64C>;
1483 def v4f32_f32: ORPromoteScalar<R32FP>;
1484 def v2f64_f64: ORPromoteScalar<R64FP>;
Scott Michel754d8662007-12-20 00:44:13 +00001485
Scott Michel4d07fb72008-12-30 23:28:25 +00001486 // vector->scalar demotion, vec2prefslot:
Scott Michel97872d32008-02-23 18:41:37 +00001487 def i8_v16i8: ORExtractElt<R8C>;
1488 def i16_v8i16: ORExtractElt<R16C>;
1489 def i32_v4i32: ORExtractElt<R32C>;
1490 def i64_v2i64: ORExtractElt<R64C>;
1491 def f32_v4f32: ORExtractElt<R32FP>;
1492 def f64_v2f64: ORExtractElt<R64FP>;
Scott Michel06eabde2008-12-27 04:51:36 +00001493
Scott Michel34712c32009-03-16 18:47:25 +00001494 // Conversion from vector to GPRC
1495 def i128_vec: ORCvtVecGPRC;
1496
1497 // Conversion from GPRC to vector
1498 def vec_i128: ORCvtGPRCVec;
1499
Scott Michel8c67fa42009-01-21 04:58:48 +00001500/*
Scott Michel34712c32009-03-16 18:47:25 +00001501 // Conversion from register to GPRC
Scott Michel06eabde2008-12-27 04:51:36 +00001502 def i128_r64: ORCvtRegGPRC<R64C>;
1503 def i128_f64: ORCvtRegGPRC<R64FP>;
1504 def i128_r32: ORCvtRegGPRC<R32C>;
1505 def i128_f32: ORCvtRegGPRC<R32FP>;
1506 def i128_r16: ORCvtRegGPRC<R16C>;
1507 def i128_r8: ORCvtRegGPRC<R8C>;
1508
Scott Michel34712c32009-03-16 18:47:25 +00001509 // Conversion from GPRC to register
Scott Michel06eabde2008-12-27 04:51:36 +00001510 def r64_i128: ORCvtGPRCReg<R64C>;
1511 def f64_i128: ORCvtGPRCReg<R64FP>;
1512 def r32_i128: ORCvtGPRCReg<R32C>;
1513 def f32_i128: ORCvtGPRCReg<R32FP>;
1514 def r16_i128: ORCvtGPRCReg<R16C>;
1515 def r8_i128: ORCvtGPRCReg<R8C>;
Scott Michel8c67fa42009-01-21 04:58:48 +00001516*/
1517/*
Scott Michel2ef773a2009-01-06 03:36:14 +00001518 // Conversion from register to R32C:
Scott Michel34712c32009-03-16 18:47:25 +00001519 def r32_r16: ORCvtFormRegR32<R16C>;
1520 def r32_r8: ORCvtFormRegR32<R8C>;
Scott Michel2ef773a2009-01-06 03:36:14 +00001521
1522 // Conversion from R32C to register
1523 def r32_r16: ORCvtFormR32Reg<R16C>;
1524 def r32_r8: ORCvtFormR32Reg<R8C>;
Scott Michel8c67fa42009-01-21 04:58:48 +00001525*/
pingbak2f387e82009-01-26 03:31:40 +00001526
Scott Michel34712c32009-03-16 18:47:25 +00001527 // Conversion from R64C to register:
pingbak2f387e82009-01-26 03:31:40 +00001528 def r32_r64: ORCvtFormR64Reg<R32C>;
1529 // def r16_r64: ORCvtFormR64Reg<R16C>;
1530 // def r8_r64: ORCvtFormR64Reg<R8C>;
1531
Scott Michel34712c32009-03-16 18:47:25 +00001532 // Conversion to R64C from register:
pingbak2f387e82009-01-26 03:31:40 +00001533 def r64_r32: ORCvtFormRegR64<R32C>;
1534 // def r64_r16: ORCvtFormRegR64<R16C>;
1535 // def r64_r8: ORCvtFormRegR64<R8C>;
Scott Michel8c67fa42009-01-21 04:58:48 +00001536
1537 // bitconvert patterns:
1538 def r32_f32: ORCvtFormR32Reg<R32FP,
1539 [(set R32FP:$rT, (bitconvert R32C:$rA))]>;
1540 def f32_r32: ORCvtFormRegR32<R32FP,
1541 [(set R32C:$rT, (bitconvert R32FP:$rA))]>;
1542
1543 def r64_f64: ORCvtFormR64Reg<R64FP,
1544 [(set R64FP:$rT, (bitconvert R64C:$rA))]>;
1545 def f64_r64: ORCvtFormRegR64<R64FP,
1546 [(set R64C:$rT, (bitconvert R64FP:$rA))]>;
Scott Michel97872d32008-02-23 18:41:37 +00001547}
Scott Michel438be252007-12-17 22:32:34 +00001548
Scott Michel97872d32008-02-23 18:41:37 +00001549defm OR : BitwiseOr;
1550
Scott Michel06eabde2008-12-27 04:51:36 +00001551// scalar->vector promotion patterns (preferred slot to vector):
1552def : Pat<(v16i8 (SPUprefslot2vec R8C:$rA)),
1553 (ORv16i8_i8 R8C:$rA)>;
Scott Michel438be252007-12-17 22:32:34 +00001554
Scott Michel06eabde2008-12-27 04:51:36 +00001555def : Pat<(v8i16 (SPUprefslot2vec R16C:$rA)),
1556 (ORv8i16_i16 R16C:$rA)>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001557
Scott Michel06eabde2008-12-27 04:51:36 +00001558def : Pat<(v4i32 (SPUprefslot2vec R32C:$rA)),
1559 (ORv4i32_i32 R32C:$rA)>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001560
Scott Michel06eabde2008-12-27 04:51:36 +00001561def : Pat<(v2i64 (SPUprefslot2vec R64C:$rA)),
1562 (ORv2i64_i64 R64C:$rA)>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001563
Scott Michel06eabde2008-12-27 04:51:36 +00001564def : Pat<(v4f32 (SPUprefslot2vec R32FP:$rA)),
1565 (ORv4f32_f32 R32FP:$rA)>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001566
Scott Michel06eabde2008-12-27 04:51:36 +00001567def : Pat<(v2f64 (SPUprefslot2vec R64FP:$rA)),
1568 (ORv2f64_f64 R64FP:$rA)>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001569
Scott Michel06eabde2008-12-27 04:51:36 +00001570// ORi*_v*: Used to extract vector element 0 (the preferred slot), otherwise
1571// known as converting the vector back to its preferred slot
Scott Michel438be252007-12-17 22:32:34 +00001572
Scott Michelc630c412008-11-24 17:11:17 +00001573def : Pat<(SPUvec2prefslot (v16i8 VECREG:$rA)),
Scott Michel06eabde2008-12-27 04:51:36 +00001574 (ORi8_v16i8 VECREG:$rA)>;
Scott Michel438be252007-12-17 22:32:34 +00001575
Scott Michelc630c412008-11-24 17:11:17 +00001576def : Pat<(SPUvec2prefslot (v8i16 VECREG:$rA)),
Scott Michel06eabde2008-12-27 04:51:36 +00001577 (ORi16_v8i16 VECREG:$rA)>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001578
Scott Michelc630c412008-11-24 17:11:17 +00001579def : Pat<(SPUvec2prefslot (v4i32 VECREG:$rA)),
Scott Michel06eabde2008-12-27 04:51:36 +00001580 (ORi32_v4i32 VECREG:$rA)>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001581
Scott Michelc630c412008-11-24 17:11:17 +00001582def : Pat<(SPUvec2prefslot (v2i64 VECREG:$rA)),
Scott Michel06eabde2008-12-27 04:51:36 +00001583 (ORi64_v2i64 VECREG:$rA)>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001584
Scott Michelc630c412008-11-24 17:11:17 +00001585def : Pat<(SPUvec2prefslot (v4f32 VECREG:$rA)),
Scott Michel06eabde2008-12-27 04:51:36 +00001586 (ORf32_v4f32 VECREG:$rA)>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001587
Scott Michelc630c412008-11-24 17:11:17 +00001588def : Pat<(SPUvec2prefslot (v2f64 VECREG:$rA)),
Scott Michel06eabde2008-12-27 04:51:36 +00001589 (ORf64_v2f64 VECREG:$rA)>;
1590
1591// Load Register: This is an assembler alias for a bitwise OR of a register
1592// against itself. It's here because it brings some clarity to assembly
1593// language output.
1594
1595let hasCtrlDep = 1 in {
1596 class LRInst<dag OOL, dag IOL>
1597 : SPUInstr<OOL, IOL, "lr\t$rT, $rA", IntegerOp> {
1598 bits<7> RA;
1599 bits<7> RT;
1600
1601 let Pattern = [/*no pattern*/];
1602
1603 let Inst{0-10} = 0b10000010000; /* It's an OR operation */
1604 let Inst{11-17} = RA;
1605 let Inst{18-24} = RA;
1606 let Inst{25-31} = RT;
1607 }
1608
1609 class LRVecInst<ValueType vectype>:
1610 LRInst<(outs VECREG:$rT), (ins VECREG:$rA)>;
1611
1612 class LRRegInst<RegisterClass rclass>:
1613 LRInst<(outs rclass:$rT), (ins rclass:$rA)>;
1614
1615 multiclass LoadRegister {
1616 def v2i64: LRVecInst<v2i64>;
1617 def v2f64: LRVecInst<v2f64>;
1618 def v4i32: LRVecInst<v4i32>;
1619 def v4f32: LRVecInst<v4f32>;
1620 def v8i16: LRVecInst<v8i16>;
1621 def v16i8: LRVecInst<v16i8>;
1622
1623 def r128: LRRegInst<GPRC>;
1624 def r64: LRRegInst<R64C>;
1625 def f64: LRRegInst<R64FP>;
1626 def r32: LRRegInst<R32C>;
1627 def f32: LRRegInst<R32FP>;
1628 def r16: LRRegInst<R16C>;
1629 def r8: LRRegInst<R8C>;
1630 }
1631
1632 defm LR: LoadRegister;
1633}
Scott Michel8b6b4202007-12-04 22:35:58 +00001634
Scott Michel97872d32008-02-23 18:41:37 +00001635// ORC: Bitwise "or" with complement (c = a | ~b)
Scott Michel8b6b4202007-12-04 22:35:58 +00001636
Scott Michel97872d32008-02-23 18:41:37 +00001637class ORCInst<dag OOL, dag IOL, list<dag> pattern>:
1638 RRForm<0b10010010000, OOL, IOL, "orc\t$rT, $rA, $rB",
1639 IntegerOp, pattern>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001640
Scott Michel97872d32008-02-23 18:41:37 +00001641class ORCVecInst<ValueType vectype>:
1642 ORCInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1643 [(set (vectype VECREG:$rT), (or (vectype VECREG:$rA),
1644 (vnot (vectype VECREG:$rB))))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001645
Scott Michel97872d32008-02-23 18:41:37 +00001646class ORCRegInst<RegisterClass rclass>:
1647 ORCInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB),
1648 [(set rclass:$rT, (or rclass:$rA, (not rclass:$rB)))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001649
Scott Michel97872d32008-02-23 18:41:37 +00001650multiclass BitwiseOrComplement
1651{
1652 def v16i8: ORCVecInst<v16i8>;
1653 def v8i16: ORCVecInst<v8i16>;
1654 def v4i32: ORCVecInst<v4i32>;
1655 def v2i64: ORCVecInst<v2i64>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001656
Scott Michel34712c32009-03-16 18:47:25 +00001657 def r128: ORCRegInst<GPRC>;
Scott Michel97872d32008-02-23 18:41:37 +00001658 def r64: ORCRegInst<R64C>;
1659 def r32: ORCRegInst<R32C>;
1660 def r16: ORCRegInst<R16C>;
1661 def r8: ORCRegInst<R8C>;
1662}
1663
1664defm ORC : BitwiseOrComplement;
Scott Michel438be252007-12-17 22:32:34 +00001665
Scott Michel8b6b4202007-12-04 22:35:58 +00001666// OR byte immediate
Scott Michel97872d32008-02-23 18:41:37 +00001667class ORBIInst<dag OOL, dag IOL, list<dag> pattern>:
1668 RI10Form<0b01100000, OOL, IOL, "orbi\t$rT, $rA, $val",
1669 IntegerOp, pattern>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001670
Scott Michel97872d32008-02-23 18:41:37 +00001671class ORBIVecInst<ValueType vectype, PatLeaf immpred>:
1672 ORBIInst<(outs VECREG:$rT), (ins VECREG:$rA, u10imm:$val),
1673 [(set (v16i8 VECREG:$rT), (or (vectype VECREG:$rA),
1674 (vectype immpred:$val)))]>;
1675
1676multiclass BitwiseOrByteImm
1677{
1678 def v16i8: ORBIVecInst<v16i8, v16i8U8Imm>;
1679
1680 def r8: ORBIInst<(outs R8C:$rT), (ins R8C:$rA, u10imm_i8:$val),
1681 [(set R8C:$rT, (or R8C:$rA, immU8:$val))]>;
1682}
1683
1684defm ORBI : BitwiseOrByteImm;
Scott Michel438be252007-12-17 22:32:34 +00001685
Scott Michel8b6b4202007-12-04 22:35:58 +00001686// OR halfword immediate
Scott Michel97872d32008-02-23 18:41:37 +00001687class ORHIInst<dag OOL, dag IOL, list<dag> pattern>:
1688 RI10Form<0b10100000, OOL, IOL, "orhi\t$rT, $rA, $val",
1689 IntegerOp, pattern>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001690
Scott Michel97872d32008-02-23 18:41:37 +00001691class ORHIVecInst<ValueType vectype, PatLeaf immpred>:
1692 ORHIInst<(outs VECREG:$rT), (ins VECREG:$rA, u10imm:$val),
1693 [(set (vectype VECREG:$rT), (or (vectype VECREG:$rA),
1694 immpred:$val))]>;
Scott Michel438be252007-12-17 22:32:34 +00001695
Scott Michel97872d32008-02-23 18:41:37 +00001696multiclass BitwiseOrHalfwordImm
1697{
1698 def v8i16: ORHIVecInst<v8i16, v8i16Uns10Imm>;
1699
1700 def r16: ORHIInst<(outs R16C:$rT), (ins R16C:$rA, u10imm:$val),
1701 [(set R16C:$rT, (or R16C:$rA, i16ImmUns10:$val))]>;
1702
1703 // Specialized ORHI form used to promote 8-bit registers to 16-bit
1704 def i8i16: ORHIInst<(outs R16C:$rT), (ins R8C:$rA, s10imm:$val),
1705 [(set R16C:$rT, (or (anyext R8C:$rA),
1706 i16ImmSExt10:$val))]>;
1707}
1708
1709defm ORHI : BitwiseOrHalfwordImm;
1710
1711class ORIInst<dag OOL, dag IOL, list<dag> pattern>:
1712 RI10Form<0b00100000, OOL, IOL, "ori\t$rT, $rA, $val",
1713 IntegerOp, pattern>;
1714
1715class ORIVecInst<ValueType vectype, PatLeaf immpred>:
1716 ORIInst<(outs VECREG:$rT), (ins VECREG:$rA, u10imm:$val),
1717 [(set (vectype VECREG:$rT), (or (vectype VECREG:$rA),
1718 immpred:$val))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001719
1720// Bitwise "or" with immediate
Scott Michel97872d32008-02-23 18:41:37 +00001721multiclass BitwiseOrImm
1722{
1723 def v4i32: ORIVecInst<v4i32, v4i32Uns10Imm>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001724
Scott Michel97872d32008-02-23 18:41:37 +00001725 def r32: ORIInst<(outs R32C:$rT), (ins R32C:$rA, u10imm_i32:$val),
1726 [(set R32C:$rT, (or R32C:$rA, i32ImmUns10:$val))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001727
Scott Michel97872d32008-02-23 18:41:37 +00001728 // i16i32: hacked version of the ori instruction to extend 16-bit quantities
1729 // to 32-bit quantities. used exclusively to match "anyext" conversions (vide
1730 // infra "anyext 16->32" pattern.)
1731 def i16i32: ORIInst<(outs R32C:$rT), (ins R16C:$rA, s10imm_i32:$val),
1732 [(set R32C:$rT, (or (anyext R16C:$rA),
1733 i32ImmSExt10:$val))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001734
Scott Michel97872d32008-02-23 18:41:37 +00001735 // i8i32: Hacked version of the ORI instruction to extend 16-bit quantities
1736 // to 32-bit quantities. Used exclusively to match "anyext" conversions (vide
1737 // infra "anyext 16->32" pattern.)
1738 def i8i32: ORIInst<(outs R32C:$rT), (ins R8C:$rA, s10imm_i32:$val),
1739 [(set R32C:$rT, (or (anyext R8C:$rA),
1740 i32ImmSExt10:$val))]>;
1741}
Scott Michel8b6b4202007-12-04 22:35:58 +00001742
Scott Michel97872d32008-02-23 18:41:37 +00001743defm ORI : BitwiseOrImm;
Scott Michel438be252007-12-17 22:32:34 +00001744
Scott Michel8b6b4202007-12-04 22:35:58 +00001745// ORX: "or" across the vector: or's $rA's word slots leaving the result in
1746// $rT[0], slots 1-3 are zeroed.
1747//
Scott Michel438be252007-12-17 22:32:34 +00001748// FIXME: Needs to match an intrinsic pattern.
Scott Michel8b6b4202007-12-04 22:35:58 +00001749def ORXv4i32:
1750 RRForm<0b10010010000, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1751 "orx\t$rT, $rA, $rB", IntegerOp,
1752 []>;
1753
Scott Michel438be252007-12-17 22:32:34 +00001754// XOR:
Scott Michel8b6b4202007-12-04 22:35:58 +00001755
Scott Michel6baba072008-03-05 23:02:02 +00001756class XORInst<dag OOL, dag IOL, list<dag> pattern> :
1757 RRForm<0b10010010000, OOL, IOL, "xor\t$rT, $rA, $rB",
1758 IntegerOp, pattern>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001759
Scott Michel6baba072008-03-05 23:02:02 +00001760class XORVecInst<ValueType vectype>:
1761 XORInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1762 [(set (vectype VECREG:$rT), (xor (vectype VECREG:$rA),
1763 (vectype VECREG:$rB)))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001764
Scott Michel6baba072008-03-05 23:02:02 +00001765class XORRegInst<RegisterClass rclass>:
1766 XORInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB),
1767 [(set rclass:$rT, (xor rclass:$rA, rclass:$rB))]>;
1768
1769multiclass BitwiseExclusiveOr
1770{
1771 def v16i8: XORVecInst<v16i8>;
1772 def v8i16: XORVecInst<v8i16>;
1773 def v4i32: XORVecInst<v4i32>;
1774 def v2i64: XORVecInst<v2i64>;
1775
1776 def r128: XORRegInst<GPRC>;
1777 def r64: XORRegInst<R64C>;
1778 def r32: XORRegInst<R32C>;
1779 def r16: XORRegInst<R16C>;
1780 def r8: XORRegInst<R8C>;
Scott Michele13d8392009-03-17 16:45:16 +00001781
1782 // XOR instructions used to negate f32 and f64 quantities.
1783
1784 def fneg32: XORInst<(outs R32FP:$rT), (ins R32FP:$rA, R32C:$rB),
1785 [/* no pattern */]>;
1786
1787 def fneg64: XORInst<(outs R64FP:$rT), (ins R64FP:$rA, R64C:$rB),
1788 [/* no pattern */]>;
1789
1790 def fnegvec: XORInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1791 [/* no pattern, see fneg{32,64} */]>;
Scott Michel6baba072008-03-05 23:02:02 +00001792}
1793
1794defm XOR : BitwiseExclusiveOr;
Scott Michel8b6b4202007-12-04 22:35:58 +00001795
1796//==----------------------------------------------------------
Scott Michel438be252007-12-17 22:32:34 +00001797
Scott Michel97872d32008-02-23 18:41:37 +00001798class XORBIInst<dag OOL, dag IOL, list<dag> pattern>:
1799 RI10Form<0b01100000, OOL, IOL, "xorbi\t$rT, $rA, $val",
1800 IntegerOp, pattern>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001801
Scott Michel97872d32008-02-23 18:41:37 +00001802multiclass XorByteImm
1803{
1804 def v16i8:
1805 XORBIInst<(outs VECREG:$rT), (ins VECREG:$rA, u10imm:$val),
1806 [(set (v16i8 VECREG:$rT), (xor (v16i8 VECREG:$rA), v16i8U8Imm:$val))]>;
1807
1808 def r8:
1809 XORBIInst<(outs R8C:$rT), (ins R8C:$rA, u10imm_i8:$val),
1810 [(set R8C:$rT, (xor R8C:$rA, immU8:$val))]>;
1811}
1812
1813defm XORBI : XorByteImm;
Scott Michel438be252007-12-17 22:32:34 +00001814
Scott Michel8b6b4202007-12-04 22:35:58 +00001815def XORHIv8i16:
Scott Michel97872d32008-02-23 18:41:37 +00001816 RI10Form<0b10100000, (outs VECREG:$rT), (ins VECREG:$rA, u10imm:$val),
Scott Michel8b6b4202007-12-04 22:35:58 +00001817 "xorhi\t$rT, $rA, $val", IntegerOp,
1818 [(set (v8i16 VECREG:$rT), (xor (v8i16 VECREG:$rA),
1819 v8i16SExt10Imm:$val))]>;
1820
1821def XORHIr16:
1822 RI10Form<0b10100000, (outs R16C:$rT), (ins R16C:$rA, s10imm:$val),
1823 "xorhi\t$rT, $rA, $val", IntegerOp,
1824 [(set R16C:$rT, (xor R16C:$rA, i16ImmSExt10:$val))]>;
1825
1826def XORIv4i32:
Scott Michel53ab7792008-03-10 16:58:52 +00001827 RI10Form<0b00100000, (outs VECREG:$rT), (ins VECREG:$rA, s10imm_i32:$val),
Scott Michel8b6b4202007-12-04 22:35:58 +00001828 "xori\t$rT, $rA, $val", IntegerOp,
1829 [(set (v4i32 VECREG:$rT), (xor (v4i32 VECREG:$rA),
1830 v4i32SExt10Imm:$val))]>;
1831
1832def XORIr32:
1833 RI10Form<0b00100000, (outs R32C:$rT), (ins R32C:$rA, s10imm_i32:$val),
1834 "xori\t$rT, $rA, $val", IntegerOp,
1835 [(set R32C:$rT, (xor R32C:$rA, i32ImmSExt10:$val))]>;
1836
1837// NAND:
Scott Michel8b6b4202007-12-04 22:35:58 +00001838
Scott Michel34712c32009-03-16 18:47:25 +00001839class NANDInst<dag OOL, dag IOL, list<dag> pattern>:
1840 RRForm<0b10010011000, OOL, IOL, "nand\t$rT, $rA, $rB",
1841 IntegerOp, pattern>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001842
Scott Michel34712c32009-03-16 18:47:25 +00001843class NANDVecInst<ValueType vectype>:
1844 NANDInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1845 [(set (vectype VECREG:$rT), (vnot (and (vectype VECREG:$rA),
1846 (vectype VECREG:$rB))))]>;
1847class NANDRegInst<RegisterClass rclass>:
1848 NANDInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB),
1849 [(set rclass:$rT, (not (and rclass:$rA, rclass:$rB)))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001850
Scott Michel34712c32009-03-16 18:47:25 +00001851multiclass BitwiseNand
1852{
1853 def v16i8: NANDVecInst<v16i8>;
1854 def v8i16: NANDVecInst<v8i16>;
1855 def v4i32: NANDVecInst<v4i32>;
1856 def v2i64: NANDVecInst<v2i64>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001857
Scott Michel34712c32009-03-16 18:47:25 +00001858 def r128: NANDRegInst<GPRC>;
1859 def r64: NANDRegInst<R64C>;
1860 def r32: NANDRegInst<R32C>;
1861 def r16: NANDRegInst<R16C>;
1862 def r8: NANDRegInst<R8C>;
1863}
Scott Michel8b6b4202007-12-04 22:35:58 +00001864
Scott Michel34712c32009-03-16 18:47:25 +00001865defm NAND : BitwiseNand;
Scott Michel438be252007-12-17 22:32:34 +00001866
Scott Michel8b6b4202007-12-04 22:35:58 +00001867// NOR:
Scott Michel8b6b4202007-12-04 22:35:58 +00001868
Scott Michel34712c32009-03-16 18:47:25 +00001869class NORInst<dag OOL, dag IOL, list<dag> pattern>:
1870 RRForm<0b10010010000, OOL, IOL, "nor\t$rT, $rA, $rB",
1871 IntegerOp, pattern>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001872
Scott Michel34712c32009-03-16 18:47:25 +00001873class NORVecInst<ValueType vectype>:
1874 NORInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1875 [(set (vectype VECREG:$rT), (vnot (or (vectype VECREG:$rA),
1876 (vectype VECREG:$rB))))]>;
1877class NORRegInst<RegisterClass rclass>:
1878 NORInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB),
1879 [(set rclass:$rT, (not (or rclass:$rA, rclass:$rB)))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001880
Scott Michel34712c32009-03-16 18:47:25 +00001881multiclass BitwiseNor
1882{
1883 def v16i8: NORVecInst<v16i8>;
1884 def v8i16: NORVecInst<v8i16>;
1885 def v4i32: NORVecInst<v4i32>;
1886 def v2i64: NORVecInst<v2i64>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001887
Scott Michel34712c32009-03-16 18:47:25 +00001888 def r128: NORRegInst<GPRC>;
1889 def r64: NORRegInst<R64C>;
1890 def r32: NORRegInst<R32C>;
1891 def r16: NORRegInst<R16C>;
1892 def r8: NORRegInst<R8C>;
1893}
Scott Michel8b6b4202007-12-04 22:35:58 +00001894
Scott Michel34712c32009-03-16 18:47:25 +00001895defm NOR : BitwiseNor;
Scott Michel438be252007-12-17 22:32:34 +00001896
Scott Michel8b6b4202007-12-04 22:35:58 +00001897// Select bits:
Scott Michel6baba072008-03-05 23:02:02 +00001898class SELBInst<dag OOL, dag IOL, list<dag> pattern>:
1899 RRRForm<0b1000, OOL, IOL, "selb\t$rT, $rA, $rB, $rC",
1900 IntegerOp, pattern>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001901
pingbak2f387e82009-01-26 03:31:40 +00001902class SELBVecInst<ValueType vectype, PatFrag vnot_frag = vnot>:
Scott Michel6baba072008-03-05 23:02:02 +00001903 SELBInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB, VECREG:$rC),
1904 [(set (vectype VECREG:$rT),
1905 (or (and (vectype VECREG:$rC), (vectype VECREG:$rB)),
pingbak2f387e82009-01-26 03:31:40 +00001906 (and (vnot_frag (vectype VECREG:$rC)),
Scott Michel6baba072008-03-05 23:02:02 +00001907 (vectype VECREG:$rA))))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001908
Scott Michel4d07fb72008-12-30 23:28:25 +00001909class SELBVecVCondInst<ValueType vectype>:
1910 SELBInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB, VECREG:$rC),
1911 [(set (vectype VECREG:$rT),
1912 (select (vectype VECREG:$rC),
1913 (vectype VECREG:$rB),
1914 (vectype VECREG:$rA)))]>;
1915
Scott Michel06eabde2008-12-27 04:51:36 +00001916class SELBVecCondInst<ValueType vectype>:
1917 SELBInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB, R32C:$rC),
1918 [(set (vectype VECREG:$rT),
1919 (select R32C:$rC,
1920 (vectype VECREG:$rB),
1921 (vectype VECREG:$rA)))]>;
1922
Scott Michel6baba072008-03-05 23:02:02 +00001923class SELBRegInst<RegisterClass rclass>:
1924 SELBInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB, rclass:$rC),
1925 [(set rclass:$rT,
Scott Michelae5cbf52008-12-29 03:23:36 +00001926 (or (and rclass:$rB, rclass:$rC),
1927 (and rclass:$rA, (not rclass:$rC))))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001928
Scott Michel06eabde2008-12-27 04:51:36 +00001929class SELBRegCondInst<RegisterClass rcond, RegisterClass rclass>:
1930 SELBInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB, rcond:$rC),
1931 [(set rclass:$rT,
1932 (select rcond:$rC, rclass:$rB, rclass:$rA))]>;
1933
Scott Michel6baba072008-03-05 23:02:02 +00001934multiclass SelectBits
1935{
1936 def v16i8: SELBVecInst<v16i8>;
1937 def v8i16: SELBVecInst<v8i16>;
1938 def v4i32: SELBVecInst<v4i32>;
pingbak2f387e82009-01-26 03:31:40 +00001939 def v2i64: SELBVecInst<v2i64, vnot_conv>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001940
Scott Michel6baba072008-03-05 23:02:02 +00001941 def r128: SELBRegInst<GPRC>;
1942 def r64: SELBRegInst<R64C>;
1943 def r32: SELBRegInst<R32C>;
1944 def r16: SELBRegInst<R16C>;
1945 def r8: SELBRegInst<R8C>;
Scott Michel06eabde2008-12-27 04:51:36 +00001946
1947 def v16i8_cond: SELBVecCondInst<v16i8>;
1948 def v8i16_cond: SELBVecCondInst<v8i16>;
1949 def v4i32_cond: SELBVecCondInst<v4i32>;
1950 def v2i64_cond: SELBVecCondInst<v2i64>;
1951
Scott Michel4d07fb72008-12-30 23:28:25 +00001952 def v16i8_vcond: SELBVecCondInst<v16i8>;
1953 def v8i16_vcond: SELBVecCondInst<v8i16>;
1954 def v4i32_vcond: SELBVecCondInst<v4i32>;
1955 def v2i64_vcond: SELBVecCondInst<v2i64>;
1956
1957 def v4f32_cond:
pingbakb8913342009-01-26 03:37:41 +00001958 SELBInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB, VECREG:$rC),
1959 [(set (v4f32 VECREG:$rT),
1960 (select (v4i32 VECREG:$rC),
1961 (v4f32 VECREG:$rB),
1962 (v4f32 VECREG:$rA)))]>;
Scott Michel4d07fb72008-12-30 23:28:25 +00001963
Scott Michel8c67fa42009-01-21 04:58:48 +00001964 // SELBr64_cond is defined in SPU64InstrInfo.td
Scott Michel06eabde2008-12-27 04:51:36 +00001965 def r32_cond: SELBRegCondInst<R32C, R32C>;
Scott Michel4d07fb72008-12-30 23:28:25 +00001966 def f32_cond: SELBRegCondInst<R32C, R32FP>;
Scott Michel06eabde2008-12-27 04:51:36 +00001967 def r16_cond: SELBRegCondInst<R16C, R16C>;
1968 def r8_cond: SELBRegCondInst<R8C, R8C>;
Scott Michel6baba072008-03-05 23:02:02 +00001969}
Scott Michel8b6b4202007-12-04 22:35:58 +00001970
Scott Michel6baba072008-03-05 23:02:02 +00001971defm SELB : SelectBits;
Scott Michel8b6b4202007-12-04 22:35:58 +00001972
Scott Michel56a125e2008-11-22 23:50:42 +00001973class SPUselbPatVec<ValueType vectype, SPUInstr inst>:
Scott Michel6baba072008-03-05 23:02:02 +00001974 Pat<(SPUselb (vectype VECREG:$rA), (vectype VECREG:$rB), (vectype VECREG:$rC)),
1975 (inst VECREG:$rA, VECREG:$rB, VECREG:$rC)>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001976
Scott Michel56a125e2008-11-22 23:50:42 +00001977def : SPUselbPatVec<v16i8, SELBv16i8>;
1978def : SPUselbPatVec<v8i16, SELBv8i16>;
1979def : SPUselbPatVec<v4i32, SELBv4i32>;
1980def : SPUselbPatVec<v2i64, SELBv2i64>;
1981
1982class SPUselbPatReg<RegisterClass rclass, SPUInstr inst>:
1983 Pat<(SPUselb rclass:$rA, rclass:$rB, rclass:$rC),
1984 (inst rclass:$rA, rclass:$rB, rclass:$rC)>;
1985
1986def : SPUselbPatReg<R8C, SELBr8>;
1987def : SPUselbPatReg<R16C, SELBr16>;
1988def : SPUselbPatReg<R32C, SELBr32>;
1989def : SPUselbPatReg<R64C, SELBr64>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001990
Scott Michel6baba072008-03-05 23:02:02 +00001991// EQV: Equivalence (1 for each same bit, otherwise 0)
1992//
1993// Note: There are a lot of ways to match this bit operator and these patterns
1994// attempt to be as exhaustive as possible.
Scott Michel8b6b4202007-12-04 22:35:58 +00001995
Scott Michel6baba072008-03-05 23:02:02 +00001996class EQVInst<dag OOL, dag IOL, list<dag> pattern>:
1997 RRForm<0b10010010000, OOL, IOL, "eqv\t$rT, $rA, $rB",
1998 IntegerOp, pattern>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001999
Scott Michel6baba072008-03-05 23:02:02 +00002000class EQVVecInst<ValueType vectype>:
2001 EQVInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
2002 [(set (vectype VECREG:$rT),
2003 (or (and (vectype VECREG:$rA), (vectype VECREG:$rB)),
2004 (and (vnot (vectype VECREG:$rA)),
2005 (vnot (vectype VECREG:$rB)))))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002006
Scott Michel6baba072008-03-05 23:02:02 +00002007class EQVRegInst<RegisterClass rclass>:
2008 EQVInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB),
2009 [(set rclass:$rT, (or (and rclass:$rA, rclass:$rB),
2010 (and (not rclass:$rA), (not rclass:$rB))))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002011
Scott Michel6baba072008-03-05 23:02:02 +00002012class EQVVecPattern1<ValueType vectype>:
2013 EQVInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
2014 [(set (vectype VECREG:$rT),
2015 (xor (vectype VECREG:$rA), (vnot (vectype VECREG:$rB))))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002016
Scott Michel6baba072008-03-05 23:02:02 +00002017class EQVRegPattern1<RegisterClass rclass>:
2018 EQVInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB),
2019 [(set rclass:$rT, (xor rclass:$rA, (not rclass:$rB)))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002020
Scott Michel6baba072008-03-05 23:02:02 +00002021class EQVVecPattern2<ValueType vectype>:
2022 EQVInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
2023 [(set (vectype VECREG:$rT),
2024 (or (and (vectype VECREG:$rA), (vectype VECREG:$rB)),
2025 (vnot (or (vectype VECREG:$rA), (vectype VECREG:$rB)))))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002026
Scott Michel6baba072008-03-05 23:02:02 +00002027class EQVRegPattern2<RegisterClass rclass>:
2028 EQVInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB),
2029 [(set rclass:$rT,
2030 (or (and rclass:$rA, rclass:$rB),
2031 (not (or rclass:$rA, rclass:$rB))))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002032
Scott Michel6baba072008-03-05 23:02:02 +00002033class EQVVecPattern3<ValueType vectype>:
2034 EQVInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
2035 [(set (vectype VECREG:$rT),
2036 (not (xor (vectype VECREG:$rA), (vectype VECREG:$rB))))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002037
Scott Michel6baba072008-03-05 23:02:02 +00002038class EQVRegPattern3<RegisterClass rclass>:
2039 EQVInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB),
2040 [(set rclass:$rT, (not (xor rclass:$rA, rclass:$rB)))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002041
Scott Michel6baba072008-03-05 23:02:02 +00002042multiclass BitEquivalence
2043{
2044 def v16i8: EQVVecInst<v16i8>;
2045 def v8i16: EQVVecInst<v8i16>;
2046 def v4i32: EQVVecInst<v4i32>;
2047 def v2i64: EQVVecInst<v2i64>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002048
Scott Michel6baba072008-03-05 23:02:02 +00002049 def v16i8_1: EQVVecPattern1<v16i8>;
2050 def v8i16_1: EQVVecPattern1<v8i16>;
2051 def v4i32_1: EQVVecPattern1<v4i32>;
2052 def v2i64_1: EQVVecPattern1<v2i64>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002053
Scott Michel6baba072008-03-05 23:02:02 +00002054 def v16i8_2: EQVVecPattern2<v16i8>;
2055 def v8i16_2: EQVVecPattern2<v8i16>;
2056 def v4i32_2: EQVVecPattern2<v4i32>;
2057 def v2i64_2: EQVVecPattern2<v2i64>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002058
Scott Michel6baba072008-03-05 23:02:02 +00002059 def v16i8_3: EQVVecPattern3<v16i8>;
2060 def v8i16_3: EQVVecPattern3<v8i16>;
2061 def v4i32_3: EQVVecPattern3<v4i32>;
2062 def v2i64_3: EQVVecPattern3<v2i64>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002063
Scott Michel6baba072008-03-05 23:02:02 +00002064 def r128: EQVRegInst<GPRC>;
2065 def r64: EQVRegInst<R64C>;
2066 def r32: EQVRegInst<R32C>;
2067 def r16: EQVRegInst<R16C>;
2068 def r8: EQVRegInst<R8C>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002069
Scott Michel6baba072008-03-05 23:02:02 +00002070 def r128_1: EQVRegPattern1<GPRC>;
2071 def r64_1: EQVRegPattern1<R64C>;
2072 def r32_1: EQVRegPattern1<R32C>;
2073 def r16_1: EQVRegPattern1<R16C>;
2074 def r8_1: EQVRegPattern1<R8C>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002075
Scott Michel6baba072008-03-05 23:02:02 +00002076 def r128_2: EQVRegPattern2<GPRC>;
2077 def r64_2: EQVRegPattern2<R64C>;
2078 def r32_2: EQVRegPattern2<R32C>;
2079 def r16_2: EQVRegPattern2<R16C>;
2080 def r8_2: EQVRegPattern2<R8C>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002081
Scott Michel6baba072008-03-05 23:02:02 +00002082 def r128_3: EQVRegPattern3<GPRC>;
2083 def r64_3: EQVRegPattern3<R64C>;
2084 def r32_3: EQVRegPattern3<R32C>;
2085 def r16_3: EQVRegPattern3<R16C>;
2086 def r8_3: EQVRegPattern3<R8C>;
2087}
Scott Michel438be252007-12-17 22:32:34 +00002088
Scott Michel6baba072008-03-05 23:02:02 +00002089defm EQV: BitEquivalence;
Scott Michel8b6b4202007-12-04 22:35:58 +00002090
2091//===----------------------------------------------------------------------===//
2092// Vector shuffle...
2093//===----------------------------------------------------------------------===//
Scott Michel8b6b4202007-12-04 22:35:58 +00002094// SPUshuffle is generated in LowerVECTOR_SHUFFLE and gets replaced with SHUFB.
2095// See the SPUshuffle SDNode operand above, which sets up the DAG pattern
2096// matcher to emit something when the LowerVECTOR_SHUFFLE generates a node with
2097// the SPUISD::SHUFB opcode.
Scott Michel97872d32008-02-23 18:41:37 +00002098//===----------------------------------------------------------------------===//
Scott Michel8b6b4202007-12-04 22:35:58 +00002099
Scott Michel97872d32008-02-23 18:41:37 +00002100class SHUFBInst<dag OOL, dag IOL, list<dag> pattern>:
2101 RRRForm<0b1000, OOL, IOL, "shufb\t$rT, $rA, $rB, $rC",
2102 IntegerOp, pattern>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002103
Scott Michel0718cd82008-12-01 17:56:02 +00002104class SHUFBVecInst<ValueType resultvec, ValueType maskvec>:
Scott Michel97872d32008-02-23 18:41:37 +00002105 SHUFBInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB, VECREG:$rC),
Scott Michel0718cd82008-12-01 17:56:02 +00002106 [(set (resultvec VECREG:$rT),
2107 (SPUshuffle (resultvec VECREG:$rA),
2108 (resultvec VECREG:$rB),
2109 (maskvec VECREG:$rC)))]>;
Scott Michel754d8662007-12-20 00:44:13 +00002110
Scott Michel06eabde2008-12-27 04:51:36 +00002111class SHUFBGPRCInst:
2112 SHUFBInst<(outs VECREG:$rT), (ins GPRC:$rA, GPRC:$rB, VECREG:$rC),
2113 [/* no pattern */]>;
2114
Scott Michel97872d32008-02-23 18:41:37 +00002115multiclass ShuffleBytes
2116{
Scott Michel0718cd82008-12-01 17:56:02 +00002117 def v16i8 : SHUFBVecInst<v16i8, v16i8>;
2118 def v16i8_m32 : SHUFBVecInst<v16i8, v4i32>;
2119 def v8i16 : SHUFBVecInst<v8i16, v16i8>;
2120 def v8i16_m32 : SHUFBVecInst<v8i16, v4i32>;
2121 def v4i32 : SHUFBVecInst<v4i32, v16i8>;
2122 def v4i32_m32 : SHUFBVecInst<v4i32, v4i32>;
2123 def v2i64 : SHUFBVecInst<v2i64, v16i8>;
2124 def v2i64_m32 : SHUFBVecInst<v2i64, v4i32>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002125
Scott Michel0718cd82008-12-01 17:56:02 +00002126 def v4f32 : SHUFBVecInst<v4f32, v16i8>;
2127 def v4f32_m32 : SHUFBVecInst<v4f32, v4i32>;
2128
2129 def v2f64 : SHUFBVecInst<v2f64, v16i8>;
2130 def v2f64_m32 : SHUFBVecInst<v2f64, v4i32>;
Scott Michel06eabde2008-12-27 04:51:36 +00002131
2132 def gprc : SHUFBGPRCInst;
Scott Michel97872d32008-02-23 18:41:37 +00002133}
2134
2135defm SHUFB : ShuffleBytes;
2136
Scott Michel8b6b4202007-12-04 22:35:58 +00002137//===----------------------------------------------------------------------===//
2138// Shift and rotate group:
2139//===----------------------------------------------------------------------===//
2140
Scott Michel97872d32008-02-23 18:41:37 +00002141class SHLHInst<dag OOL, dag IOL, list<dag> pattern>:
2142 RRForm<0b11111010000, OOL, IOL, "shlh\t$rT, $rA, $rB",
2143 RotateShift, pattern>;
2144
2145class SHLHVecInst<ValueType vectype>:
2146 SHLHInst<(outs VECREG:$rT), (ins VECREG:$rA, R16C:$rB),
2147 [(set (vectype VECREG:$rT),
2148 (SPUvec_shl (vectype VECREG:$rA), R16C:$rB))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002149
Scott Michel97872d32008-02-23 18:41:37 +00002150multiclass ShiftLeftHalfword
2151{
2152 def v8i16: SHLHVecInst<v8i16>;
2153 def r16: SHLHInst<(outs R16C:$rT), (ins R16C:$rA, R16C:$rB),
2154 [(set R16C:$rT, (shl R16C:$rA, R16C:$rB))]>;
2155 def r16_r32: SHLHInst<(outs R16C:$rT), (ins R16C:$rA, R32C:$rB),
2156 [(set R16C:$rT, (shl R16C:$rA, R32C:$rB))]>;
2157}
Scott Michel8b6b4202007-12-04 22:35:58 +00002158
Scott Michel97872d32008-02-23 18:41:37 +00002159defm SHLH : ShiftLeftHalfword;
Scott Michel8b6b4202007-12-04 22:35:58 +00002160
Scott Michel97872d32008-02-23 18:41:37 +00002161//===----------------------------------------------------------------------===//
Scott Michel438be252007-12-17 22:32:34 +00002162
Scott Michel97872d32008-02-23 18:41:37 +00002163class SHLHIInst<dag OOL, dag IOL, list<dag> pattern>:
2164 RI7Form<0b11111010000, OOL, IOL, "shlhi\t$rT, $rA, $val",
2165 RotateShift, pattern>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002166
Scott Michel97872d32008-02-23 18:41:37 +00002167class SHLHIVecInst<ValueType vectype>:
2168 SHLHIInst<(outs VECREG:$rT), (ins VECREG:$rA, u7imm:$val),
2169 [(set (vectype VECREG:$rT),
2170 (SPUvec_shl (vectype VECREG:$rA), (i16 uimm7:$val)))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002171
Scott Michel97872d32008-02-23 18:41:37 +00002172multiclass ShiftLeftHalfwordImm
2173{
2174 def v8i16: SHLHIVecInst<v8i16>;
2175 def r16: SHLHIInst<(outs R16C:$rT), (ins R16C:$rA, u7imm:$val),
2176 [(set R16C:$rT, (shl R16C:$rA, (i16 uimm7:$val)))]>;
2177}
2178
2179defm SHLHI : ShiftLeftHalfwordImm;
2180
2181def : Pat<(SPUvec_shl (v8i16 VECREG:$rA), (i32 uimm7:$val)),
2182 (SHLHIv8i16 VECREG:$rA, uimm7:$val)>;
2183
2184def : Pat<(shl R16C:$rA, (i32 uimm7:$val)),
Scott Michel438be252007-12-17 22:32:34 +00002185 (SHLHIr16 R16C:$rA, uimm7:$val)>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002186
Scott Michel97872d32008-02-23 18:41:37 +00002187//===----------------------------------------------------------------------===//
Scott Michel8b6b4202007-12-04 22:35:58 +00002188
Scott Michel97872d32008-02-23 18:41:37 +00002189class SHLInst<dag OOL, dag IOL, list<dag> pattern>:
2190 RRForm<0b11111010000, OOL, IOL, "shl\t$rT, $rA, $rB",
2191 RotateShift, pattern>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002192
Scott Michel97872d32008-02-23 18:41:37 +00002193multiclass ShiftLeftWord
2194{
2195 def v4i32:
2196 SHLInst<(outs VECREG:$rT), (ins VECREG:$rA, R16C:$rB),
2197 [(set (v4i32 VECREG:$rT),
2198 (SPUvec_shl (v4i32 VECREG:$rA), R16C:$rB))]>;
2199 def r32:
2200 SHLInst<(outs R32C:$rT), (ins R32C:$rA, R32C:$rB),
2201 [(set R32C:$rT, (shl R32C:$rA, R32C:$rB))]>;
2202}
Scott Michel8b6b4202007-12-04 22:35:58 +00002203
Scott Michel97872d32008-02-23 18:41:37 +00002204defm SHL: ShiftLeftWord;
Scott Michel438be252007-12-17 22:32:34 +00002205
Scott Michel97872d32008-02-23 18:41:37 +00002206//===----------------------------------------------------------------------===//
Scott Michel8b6b4202007-12-04 22:35:58 +00002207
Scott Michel97872d32008-02-23 18:41:37 +00002208class SHLIInst<dag OOL, dag IOL, list<dag> pattern>:
2209 RI7Form<0b11111010000, OOL, IOL, "shli\t$rT, $rA, $val",
2210 RotateShift, pattern>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002211
Scott Michel97872d32008-02-23 18:41:37 +00002212multiclass ShiftLeftWordImm
2213{
2214 def v4i32:
2215 SHLIInst<(outs VECREG:$rT), (ins VECREG:$rA, u7imm_i32:$val),
2216 [(set (v4i32 VECREG:$rT),
2217 (SPUvec_shl (v4i32 VECREG:$rA), (i32 uimm7:$val)))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002218
Scott Michel97872d32008-02-23 18:41:37 +00002219 def r32:
2220 SHLIInst<(outs R32C:$rT), (ins R32C:$rA, u7imm_i32:$val),
2221 [(set R32C:$rT, (shl R32C:$rA, (i32 uimm7:$val)))]>;
2222}
Scott Michel8b6b4202007-12-04 22:35:58 +00002223
Scott Michel97872d32008-02-23 18:41:37 +00002224defm SHLI : ShiftLeftWordImm;
Scott Michel438be252007-12-17 22:32:34 +00002225
Scott Michel97872d32008-02-23 18:41:37 +00002226//===----------------------------------------------------------------------===//
Scott Michel8b6b4202007-12-04 22:35:58 +00002227// SHLQBI vec form: Note that this will shift the entire vector (the 128-bit
2228// register) to the left. Vector form is here to ensure type correctness.
Scott Michel97872d32008-02-23 18:41:37 +00002229//
2230// The shift count is in the lowest 3 bits (29-31) of $rB, so only a bit shift
2231// of 7 bits is actually possible.
2232//
2233// Note also that SHLQBI/SHLQBII are used in conjunction with SHLQBY/SHLQBYI
2234// to shift i64 and i128. SHLQBI is the residual left over after shifting by
2235// bytes with SHLQBY.
Scott Michel8b6b4202007-12-04 22:35:58 +00002236
Scott Michel97872d32008-02-23 18:41:37 +00002237class SHLQBIInst<dag OOL, dag IOL, list<dag> pattern>:
2238 RRForm<0b11011011100, OOL, IOL, "shlqbi\t$rT, $rA, $rB",
2239 RotateShift, pattern>;
2240
2241class SHLQBIVecInst<ValueType vectype>:
2242 SHLQBIInst<(outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB),
2243 [(set (vectype VECREG:$rT),
2244 (SPUshlquad_l_bits (vectype VECREG:$rA), R32C:$rB))]>;
2245
Scott Michel8c67fa42009-01-21 04:58:48 +00002246class SHLQBIRegInst<RegisterClass rclass>:
2247 SHLQBIInst<(outs rclass:$rT), (ins rclass:$rA, R32C:$rB),
2248 [/* no pattern */]>;
2249
Scott Michel97872d32008-02-23 18:41:37 +00002250multiclass ShiftLeftQuadByBits
2251{
2252 def v16i8: SHLQBIVecInst<v16i8>;
2253 def v8i16: SHLQBIVecInst<v8i16>;
2254 def v4i32: SHLQBIVecInst<v4i32>;
Scott Michel56a125e2008-11-22 23:50:42 +00002255 def v4f32: SHLQBIVecInst<v4f32>;
Scott Michel97872d32008-02-23 18:41:37 +00002256 def v2i64: SHLQBIVecInst<v2i64>;
Scott Michel56a125e2008-11-22 23:50:42 +00002257 def v2f64: SHLQBIVecInst<v2f64>;
Scott Michel8c67fa42009-01-21 04:58:48 +00002258
2259 def r128: SHLQBIRegInst<GPRC>;
Scott Michel97872d32008-02-23 18:41:37 +00002260}
2261
2262defm SHLQBI : ShiftLeftQuadByBits;
2263
2264// See note above on SHLQBI. In this case, the predicate actually does then
2265// enforcement, whereas with SHLQBI, we have to "take it on faith."
2266class SHLQBIIInst<dag OOL, dag IOL, list<dag> pattern>:
2267 RI7Form<0b11011111100, OOL, IOL, "shlqbii\t$rT, $rA, $val",
2268 RotateShift, pattern>;
2269
2270class SHLQBIIVecInst<ValueType vectype>:
2271 SHLQBIIInst<(outs VECREG:$rT), (ins VECREG:$rA, u7imm_i32:$val),
2272 [(set (vectype VECREG:$rT),
2273 (SPUshlquad_l_bits (vectype VECREG:$rA), (i32 bitshift:$val)))]>;
2274
2275multiclass ShiftLeftQuadByBitsImm
2276{
2277 def v16i8 : SHLQBIIVecInst<v16i8>;
2278 def v8i16 : SHLQBIIVecInst<v8i16>;
2279 def v4i32 : SHLQBIIVecInst<v4i32>;
Scott Michel56a125e2008-11-22 23:50:42 +00002280 def v4f32 : SHLQBIIVecInst<v4f32>;
Scott Michel97872d32008-02-23 18:41:37 +00002281 def v2i64 : SHLQBIIVecInst<v2i64>;
Scott Michel56a125e2008-11-22 23:50:42 +00002282 def v2f64 : SHLQBIIVecInst<v2f64>;
Scott Michel97872d32008-02-23 18:41:37 +00002283}
2284
2285defm SHLQBII : ShiftLeftQuadByBitsImm;
Scott Michel8b6b4202007-12-04 22:35:58 +00002286
2287// SHLQBY, SHLQBYI vector forms: Shift the entire vector to the left by bytes,
Scott Michel97872d32008-02-23 18:41:37 +00002288// not by bits. See notes above on SHLQBI.
Scott Michel8b6b4202007-12-04 22:35:58 +00002289
Scott Michel97872d32008-02-23 18:41:37 +00002290class SHLQBYInst<dag OOL, dag IOL, list<dag> pattern>:
Scott Michelfa888632008-11-25 00:23:16 +00002291 RI7Form<0b11111011100, OOL, IOL, "shlqby\t$rT, $rA, $rB",
Scott Michel97872d32008-02-23 18:41:37 +00002292 RotateShift, pattern>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002293
Scott Michel97872d32008-02-23 18:41:37 +00002294class SHLQBYVecInst<ValueType vectype>:
2295 SHLQBYInst<(outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB),
2296 [(set (vectype VECREG:$rT),
2297 (SPUshlquad_l_bytes (vectype VECREG:$rA), R32C:$rB))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002298
Scott Michel97872d32008-02-23 18:41:37 +00002299multiclass ShiftLeftQuadBytes
2300{
2301 def v16i8: SHLQBYVecInst<v16i8>;
2302 def v8i16: SHLQBYVecInst<v8i16>;
2303 def v4i32: SHLQBYVecInst<v4i32>;
Scott Michel56a125e2008-11-22 23:50:42 +00002304 def v4f32: SHLQBYVecInst<v4f32>;
Scott Michel97872d32008-02-23 18:41:37 +00002305 def v2i64: SHLQBYVecInst<v2i64>;
Scott Michel56a125e2008-11-22 23:50:42 +00002306 def v2f64: SHLQBYVecInst<v2f64>;
Scott Michel97872d32008-02-23 18:41:37 +00002307 def r128: SHLQBYInst<(outs GPRC:$rT), (ins GPRC:$rA, R32C:$rB),
2308 [(set GPRC:$rT, (SPUshlquad_l_bytes GPRC:$rA, R32C:$rB))]>;
2309}
Scott Michel8b6b4202007-12-04 22:35:58 +00002310
Scott Michel97872d32008-02-23 18:41:37 +00002311defm SHLQBY: ShiftLeftQuadBytes;
Scott Michel8b6b4202007-12-04 22:35:58 +00002312
Scott Michel97872d32008-02-23 18:41:37 +00002313class SHLQBYIInst<dag OOL, dag IOL, list<dag> pattern>:
2314 RI7Form<0b11111111100, OOL, IOL, "shlqbyi\t$rT, $rA, $val",
2315 RotateShift, pattern>;
Scott Michel438be252007-12-17 22:32:34 +00002316
Scott Michel97872d32008-02-23 18:41:37 +00002317class SHLQBYIVecInst<ValueType vectype>:
2318 SHLQBYIInst<(outs VECREG:$rT), (ins VECREG:$rA, u7imm_i32:$val),
2319 [(set (vectype VECREG:$rT),
2320 (SPUshlquad_l_bytes (vectype VECREG:$rA), (i32 uimm7:$val)))]>;
Scott Michel438be252007-12-17 22:32:34 +00002321
Scott Michel97872d32008-02-23 18:41:37 +00002322multiclass ShiftLeftQuadBytesImm
2323{
2324 def v16i8: SHLQBYIVecInst<v16i8>;
2325 def v8i16: SHLQBYIVecInst<v8i16>;
2326 def v4i32: SHLQBYIVecInst<v4i32>;
Scott Michel56a125e2008-11-22 23:50:42 +00002327 def v4f32: SHLQBYIVecInst<v4f32>;
Scott Michel97872d32008-02-23 18:41:37 +00002328 def v2i64: SHLQBYIVecInst<v2i64>;
Scott Michel56a125e2008-11-22 23:50:42 +00002329 def v2f64: SHLQBYIVecInst<v2f64>;
Scott Michel97872d32008-02-23 18:41:37 +00002330 def r128: SHLQBYIInst<(outs GPRC:$rT), (ins GPRC:$rA, u7imm_i32:$val),
2331 [(set GPRC:$rT,
2332 (SPUshlquad_l_bytes GPRC:$rA, (i32 uimm7:$val)))]>;
2333}
Scott Michel438be252007-12-17 22:32:34 +00002334
Scott Michel97872d32008-02-23 18:41:37 +00002335defm SHLQBYI : ShiftLeftQuadBytesImm;
Scott Michel438be252007-12-17 22:32:34 +00002336
Scott Michel8c67fa42009-01-21 04:58:48 +00002337class SHLQBYBIInst<dag OOL, dag IOL, list<dag> pattern>:
2338 RRForm<0b00111001111, OOL, IOL, "shlqbybi\t$rT, $rA, $rB",
2339 RotateShift, pattern>;
2340
2341class SHLQBYBIVecInst<ValueType vectype>:
2342 SHLQBYBIInst<(outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB),
2343 [/* no pattern */]>;
2344
2345class SHLQBYBIRegInst<RegisterClass rclass>:
2346 SHLQBYBIInst<(outs rclass:$rT), (ins rclass:$rA, R32C:$rB),
2347 [/* no pattern */]>;
2348
2349multiclass ShiftLeftQuadBytesBitCount
2350{
2351 def v16i8: SHLQBYBIVecInst<v16i8>;
2352 def v8i16: SHLQBYBIVecInst<v8i16>;
2353 def v4i32: SHLQBYBIVecInst<v4i32>;
2354 def v4f32: SHLQBYBIVecInst<v4f32>;
2355 def v2i64: SHLQBYBIVecInst<v2i64>;
2356 def v2f64: SHLQBYBIVecInst<v2f64>;
2357
2358 def r128: SHLQBYBIRegInst<GPRC>;
2359}
2360
2361defm SHLQBYBI : ShiftLeftQuadBytesBitCount;
2362
Scott Michel97872d32008-02-23 18:41:37 +00002363//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2364// Rotate halfword:
2365//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2366class ROTHInst<dag OOL, dag IOL, list<dag> pattern>:
2367 RRForm<0b00111010000, OOL, IOL, "roth\t$rT, $rA, $rB",
2368 RotateShift, pattern>;
2369
2370class ROTHVecInst<ValueType vectype>:
2371 ROTHInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
2372 [(set (vectype VECREG:$rT),
2373 (SPUvec_rotl VECREG:$rA, VECREG:$rB))]>;
2374
2375class ROTHRegInst<RegisterClass rclass>:
2376 ROTHInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB),
2377 [(set rclass:$rT, (rotl rclass:$rA, rclass:$rB))]>;
2378
2379multiclass RotateLeftHalfword
2380{
2381 def v8i16: ROTHVecInst<v8i16>;
2382 def r16: ROTHRegInst<R16C>;
2383}
2384
2385defm ROTH: RotateLeftHalfword;
2386
2387def ROTHr16_r32: ROTHInst<(outs R16C:$rT), (ins R16C:$rA, R32C:$rB),
2388 [(set R16C:$rT, (rotl R16C:$rA, R32C:$rB))]>;
2389
2390//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2391// Rotate halfword, immediate:
2392//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2393class ROTHIInst<dag OOL, dag IOL, list<dag> pattern>:
2394 RI7Form<0b00111110000, OOL, IOL, "rothi\t$rT, $rA, $val",
2395 RotateShift, pattern>;
2396
2397class ROTHIVecInst<ValueType vectype>:
2398 ROTHIInst<(outs VECREG:$rT), (ins VECREG:$rA, u7imm:$val),
2399 [(set (vectype VECREG:$rT),
2400 (SPUvec_rotl VECREG:$rA, (i16 uimm7:$val)))]>;
2401
2402multiclass RotateLeftHalfwordImm
2403{
2404 def v8i16: ROTHIVecInst<v8i16>;
2405 def r16: ROTHIInst<(outs R16C:$rT), (ins R16C:$rA, u7imm:$val),
2406 [(set R16C:$rT, (rotl R16C:$rA, (i16 uimm7:$val)))]>;
2407 def r16_r32: ROTHIInst<(outs R16C:$rT), (ins R16C:$rA, u7imm_i32:$val),
2408 [(set R16C:$rT, (rotl R16C:$rA, (i32 uimm7:$val)))]>;
2409}
2410
2411defm ROTHI: RotateLeftHalfwordImm;
2412
2413def : Pat<(SPUvec_rotl VECREG:$rA, (i32 uimm7:$val)),
Scott Michel8b6b4202007-12-04 22:35:58 +00002414 (ROTHIv8i16 VECREG:$rA, imm:$val)>;
Scott Michel06eabde2008-12-27 04:51:36 +00002415
Scott Michel97872d32008-02-23 18:41:37 +00002416//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2417// Rotate word:
2418//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
Scott Michel8b6b4202007-12-04 22:35:58 +00002419
Scott Michel97872d32008-02-23 18:41:37 +00002420class ROTInst<dag OOL, dag IOL, list<dag> pattern>:
2421 RRForm<0b00011010000, OOL, IOL, "rot\t$rT, $rA, $rB",
2422 RotateShift, pattern>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002423
Scott Michel97872d32008-02-23 18:41:37 +00002424class ROTVecInst<ValueType vectype>:
2425 ROTInst<(outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB),
2426 [(set (vectype VECREG:$rT),
2427 (SPUvec_rotl (vectype VECREG:$rA), R32C:$rB))]>;
Scott Michel438be252007-12-17 22:32:34 +00002428
Scott Michel97872d32008-02-23 18:41:37 +00002429class ROTRegInst<RegisterClass rclass>:
2430 ROTInst<(outs rclass:$rT), (ins rclass:$rA, R32C:$rB),
2431 [(set rclass:$rT,
2432 (rotl rclass:$rA, R32C:$rB))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002433
Scott Michel97872d32008-02-23 18:41:37 +00002434multiclass RotateLeftWord
2435{
2436 def v4i32: ROTVecInst<v4i32>;
2437 def r32: ROTRegInst<R32C>;
2438}
2439
2440defm ROT: RotateLeftWord;
Scott Michel8b6b4202007-12-04 22:35:58 +00002441
Scott Michel438be252007-12-17 22:32:34 +00002442// The rotate amount is in the same bits whether we've got an 8-bit, 16-bit or
2443// 32-bit register
2444def ROTr32_r16_anyext:
Scott Michel97872d32008-02-23 18:41:37 +00002445 ROTInst<(outs R32C:$rT), (ins R32C:$rA, R16C:$rB),
2446 [(set R32C:$rT, (rotl R32C:$rA, (i32 (anyext R16C:$rB))))]>;
Scott Michel438be252007-12-17 22:32:34 +00002447
2448def : Pat<(rotl R32C:$rA, (i32 (zext R16C:$rB))),
2449 (ROTr32_r16_anyext R32C:$rA, R16C:$rB)>;
2450
2451def : Pat<(rotl R32C:$rA, (i32 (sext R16C:$rB))),
2452 (ROTr32_r16_anyext R32C:$rA, R16C:$rB)>;
2453
2454def ROTr32_r8_anyext:
Scott Michel97872d32008-02-23 18:41:37 +00002455 ROTInst<(outs R32C:$rT), (ins R32C:$rA, R8C:$rB),
2456 [(set R32C:$rT, (rotl R32C:$rA, (i32 (anyext R8C:$rB))))]>;
Scott Michel438be252007-12-17 22:32:34 +00002457
2458def : Pat<(rotl R32C:$rA, (i32 (zext R8C:$rB))),
2459 (ROTr32_r8_anyext R32C:$rA, R8C:$rB)>;
2460
2461def : Pat<(rotl R32C:$rA, (i32 (sext R8C:$rB))),
2462 (ROTr32_r8_anyext R32C:$rA, R8C:$rB)>;
2463
Scott Michel97872d32008-02-23 18:41:37 +00002464//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2465// Rotate word, immediate
2466//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
Scott Michel8b6b4202007-12-04 22:35:58 +00002467
Scott Michel97872d32008-02-23 18:41:37 +00002468class ROTIInst<dag OOL, dag IOL, list<dag> pattern>:
2469 RI7Form<0b00011110000, OOL, IOL, "roti\t$rT, $rA, $val",
2470 RotateShift, pattern>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002471
Scott Michel97872d32008-02-23 18:41:37 +00002472class ROTIVecInst<ValueType vectype, Operand optype, ValueType inttype, PatLeaf pred>:
2473 ROTIInst<(outs VECREG:$rT), (ins VECREG:$rA, optype:$val),
2474 [(set (vectype VECREG:$rT),
2475 (SPUvec_rotl (vectype VECREG:$rA), (inttype pred:$val)))]>;
Scott Michel438be252007-12-17 22:32:34 +00002476
Scott Michel97872d32008-02-23 18:41:37 +00002477class ROTIRegInst<RegisterClass rclass, Operand optype, ValueType inttype, PatLeaf pred>:
2478 ROTIInst<(outs rclass:$rT), (ins rclass:$rA, optype:$val),
2479 [(set rclass:$rT, (rotl rclass:$rA, (inttype pred:$val)))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002480
Scott Michel97872d32008-02-23 18:41:37 +00002481multiclass RotateLeftWordImm
2482{
2483 def v4i32: ROTIVecInst<v4i32, u7imm_i32, i32, uimm7>;
2484 def v4i32_i16: ROTIVecInst<v4i32, u7imm, i16, uimm7>;
2485 def v4i32_i8: ROTIVecInst<v4i32, u7imm_i8, i8, uimm7>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002486
Scott Michel97872d32008-02-23 18:41:37 +00002487 def r32: ROTIRegInst<R32C, u7imm_i32, i32, uimm7>;
2488 def r32_i16: ROTIRegInst<R32C, u7imm, i16, uimm7>;
2489 def r32_i8: ROTIRegInst<R32C, u7imm_i8, i8, uimm7>;
2490}
Scott Michel438be252007-12-17 22:32:34 +00002491
Scott Michel97872d32008-02-23 18:41:37 +00002492defm ROTI : RotateLeftWordImm;
2493
2494//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2495// Rotate quad by byte (count)
2496//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2497
2498class ROTQBYInst<dag OOL, dag IOL, list<dag> pattern>:
2499 RRForm<0b00111011100, OOL, IOL, "rotqby\t$rT, $rA, $rB",
2500 RotateShift, pattern>;
2501
2502class ROTQBYVecInst<ValueType vectype>:
2503 ROTQBYInst<(outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB),
2504 [(set (vectype VECREG:$rT),
2505 (SPUrotbytes_left (vectype VECREG:$rA), R32C:$rB))]>;
2506
2507multiclass RotateQuadLeftByBytes
2508{
2509 def v16i8: ROTQBYVecInst<v16i8>;
2510 def v8i16: ROTQBYVecInst<v8i16>;
2511 def v4i32: ROTQBYVecInst<v4i32>;
Scott Michele2641a12008-12-04 21:01:44 +00002512 def v4f32: ROTQBYVecInst<v4f32>;
Scott Michel97872d32008-02-23 18:41:37 +00002513 def v2i64: ROTQBYVecInst<v2i64>;
Scott Michele2641a12008-12-04 21:01:44 +00002514 def v2f64: ROTQBYVecInst<v2f64>;
Scott Michel97872d32008-02-23 18:41:37 +00002515}
2516
2517defm ROTQBY: RotateQuadLeftByBytes;
Scott Michel8b6b4202007-12-04 22:35:58 +00002518
Scott Michel97872d32008-02-23 18:41:37 +00002519//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2520// Rotate quad by byte (count), immediate
2521//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2522
2523class ROTQBYIInst<dag OOL, dag IOL, list<dag> pattern>:
2524 RI7Form<0b00111111100, OOL, IOL, "rotqbyi\t$rT, $rA, $val",
2525 RotateShift, pattern>;
2526
2527class ROTQBYIVecInst<ValueType vectype>:
2528 ROTQBYIInst<(outs VECREG:$rT), (ins VECREG:$rA, u7imm:$val),
2529 [(set (vectype VECREG:$rT),
2530 (SPUrotbytes_left (vectype VECREG:$rA), (i16 uimm7:$val)))]>;
2531
2532multiclass RotateQuadByBytesImm
2533{
2534 def v16i8: ROTQBYIVecInst<v16i8>;
2535 def v8i16: ROTQBYIVecInst<v8i16>;
2536 def v4i32: ROTQBYIVecInst<v4i32>;
Scott Michele2641a12008-12-04 21:01:44 +00002537 def v4f32: ROTQBYIVecInst<v4f32>;
Scott Michel97872d32008-02-23 18:41:37 +00002538 def v2i64: ROTQBYIVecInst<v2i64>;
Scott Michele2641a12008-12-04 21:01:44 +00002539 def vfi64: ROTQBYIVecInst<v2f64>;
Scott Michel97872d32008-02-23 18:41:37 +00002540}
2541
2542defm ROTQBYI: RotateQuadByBytesImm;
Scott Michel8b6b4202007-12-04 22:35:58 +00002543
Scott Michel8b6b4202007-12-04 22:35:58 +00002544// See ROTQBY note above.
Scott Michel67224b22008-06-02 22:18:03 +00002545class ROTQBYBIInst<dag OOL, dag IOL, list<dag> pattern>:
2546 RI7Form<0b00110011100, OOL, IOL,
2547 "rotqbybi\t$rT, $rA, $shift",
2548 RotateShift, pattern>;
2549
2550class ROTQBYBIVecInst<ValueType vectype, RegisterClass rclass>:
2551 ROTQBYBIInst<(outs VECREG:$rT), (ins VECREG:$rA, rclass:$shift),
2552 [(set (vectype VECREG:$rT),
2553 (SPUrotbytes_left_bits (vectype VECREG:$rA), rclass:$shift))]>;
2554
2555multiclass RotateQuadByBytesByBitshift {
2556 def v16i8_r32: ROTQBYBIVecInst<v16i8, R32C>;
2557 def v8i16_r32: ROTQBYBIVecInst<v8i16, R32C>;
2558 def v4i32_r32: ROTQBYBIVecInst<v4i32, R32C>;
2559 def v2i64_r32: ROTQBYBIVecInst<v2i64, R32C>;
2560}
2561
2562defm ROTQBYBI : RotateQuadByBytesByBitshift;
Scott Michel8b6b4202007-12-04 22:35:58 +00002563
Scott Michel97872d32008-02-23 18:41:37 +00002564//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
Scott Michel8b6b4202007-12-04 22:35:58 +00002565// See ROTQBY note above.
2566//
2567// Assume that the user of this instruction knows to shift the rotate count
2568// into bit 29
Scott Michel97872d32008-02-23 18:41:37 +00002569//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
Scott Michel8b6b4202007-12-04 22:35:58 +00002570
Scott Michel97872d32008-02-23 18:41:37 +00002571class ROTQBIInst<dag OOL, dag IOL, list<dag> pattern>:
2572 RRForm<0b00011011100, OOL, IOL, "rotqbi\t$rT, $rA, $rB",
2573 RotateShift, pattern>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002574
Scott Michel97872d32008-02-23 18:41:37 +00002575class ROTQBIVecInst<ValueType vectype>:
Scott Michel4d07fb72008-12-30 23:28:25 +00002576 ROTQBIInst<(outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB),
Scott Michel97872d32008-02-23 18:41:37 +00002577 [/* no pattern yet */]>;
2578
2579class ROTQBIRegInst<RegisterClass rclass>:
Scott Michel4d07fb72008-12-30 23:28:25 +00002580 ROTQBIInst<(outs rclass:$rT), (ins rclass:$rA, R32C:$rB),
Scott Michel97872d32008-02-23 18:41:37 +00002581 [/* no pattern yet */]>;
2582
2583multiclass RotateQuadByBitCount
2584{
2585 def v16i8: ROTQBIVecInst<v16i8>;
2586 def v8i16: ROTQBIVecInst<v8i16>;
2587 def v4i32: ROTQBIVecInst<v4i32>;
2588 def v2i64: ROTQBIVecInst<v2i64>;
2589
2590 def r128: ROTQBIRegInst<GPRC>;
2591 def r64: ROTQBIRegInst<R64C>;
2592}
2593
2594defm ROTQBI: RotateQuadByBitCount;
Scott Michel06eabde2008-12-27 04:51:36 +00002595
Scott Michel97872d32008-02-23 18:41:37 +00002596class ROTQBIIInst<dag OOL, dag IOL, list<dag> pattern>:
2597 RI7Form<0b00011111100, OOL, IOL, "rotqbii\t$rT, $rA, $val",
2598 RotateShift, pattern>;
2599
2600class ROTQBIIVecInst<ValueType vectype, Operand optype, ValueType inttype,
2601 PatLeaf pred>:
2602 ROTQBIIInst<(outs VECREG:$rT), (ins VECREG:$rA, optype:$val),
2603 [/* no pattern yet */]>;
2604
2605class ROTQBIIRegInst<RegisterClass rclass, Operand optype, ValueType inttype,
2606 PatLeaf pred>:
2607 ROTQBIIInst<(outs rclass:$rT), (ins rclass:$rA, optype:$val),
2608 [/* no pattern yet */]>;
2609
2610multiclass RotateQuadByBitCountImm
2611{
2612 def v16i8: ROTQBIIVecInst<v16i8, u7imm_i32, i32, uimm7>;
2613 def v8i16: ROTQBIIVecInst<v8i16, u7imm_i32, i32, uimm7>;
2614 def v4i32: ROTQBIIVecInst<v4i32, u7imm_i32, i32, uimm7>;
2615 def v2i64: ROTQBIIVecInst<v2i64, u7imm_i32, i32, uimm7>;
2616
2617 def r128: ROTQBIIRegInst<GPRC, u7imm_i32, i32, uimm7>;
2618 def r64: ROTQBIIRegInst<R64C, u7imm_i32, i32, uimm7>;
2619}
2620
2621defm ROTQBII : RotateQuadByBitCountImm;
2622
2623//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
Scott Michel8b6b4202007-12-04 22:35:58 +00002624// ROTHM v8i16 form:
2625// NOTE(1): No vector rotate is generated by the C/C++ frontend (today),
2626// so this only matches a synthetically generated/lowered code
2627// fragment.
2628// NOTE(2): $rB must be negated before the right rotate!
Scott Michel97872d32008-02-23 18:41:37 +00002629//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
Scott Michel8b6b4202007-12-04 22:35:58 +00002630
Scott Michel97872d32008-02-23 18:41:37 +00002631class ROTHMInst<dag OOL, dag IOL, list<dag> pattern>:
2632 RRForm<0b10111010000, OOL, IOL, "rothm\t$rT, $rA, $rB",
2633 RotateShift, pattern>;
2634
2635def ROTHMv8i16:
2636 ROTHMInst<(outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB),
2637 [/* see patterns below - $rB must be negated */]>;
2638
2639def : Pat<(SPUvec_srl (v8i16 VECREG:$rA), R32C:$rB),
Scott Michel8b6b4202007-12-04 22:35:58 +00002640 (ROTHMv8i16 VECREG:$rA, (SFIr32 R32C:$rB, 0))>;
2641
Scott Michel97872d32008-02-23 18:41:37 +00002642def : Pat<(SPUvec_srl (v8i16 VECREG:$rA), R16C:$rB),
Scott Michel8b6b4202007-12-04 22:35:58 +00002643 (ROTHMv8i16 VECREG:$rA,
2644 (SFIr32 (XSHWr16 R16C:$rB), 0))>;
2645
Scott Michel97872d32008-02-23 18:41:37 +00002646def : Pat<(SPUvec_srl (v8i16 VECREG:$rA), R8C:$rB),
Scott Michel8b6b4202007-12-04 22:35:58 +00002647 (ROTHMv8i16 VECREG:$rA,
Scott Michel438be252007-12-17 22:32:34 +00002648 (SFIr32 (XSHWr16 (XSBHr8 R8C:$rB) ), 0))>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002649
2650// ROTHM r16 form: Rotate 16-bit quantity to right, zero fill at the left
2651// Note: This instruction doesn't match a pattern because rB must be negated
2652// for the instruction to work. Thus, the pattern below the instruction!
Scott Michel97872d32008-02-23 18:41:37 +00002653
Scott Michel8b6b4202007-12-04 22:35:58 +00002654def ROTHMr16:
Scott Michel97872d32008-02-23 18:41:37 +00002655 ROTHMInst<(outs R16C:$rT), (ins R16C:$rA, R32C:$rB),
2656 [/* see patterns below - $rB must be negated! */]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002657
2658def : Pat<(srl R16C:$rA, R32C:$rB),
2659 (ROTHMr16 R16C:$rA, (SFIr32 R32C:$rB, 0))>;
2660
2661def : Pat<(srl R16C:$rA, R16C:$rB),
2662 (ROTHMr16 R16C:$rA,
2663 (SFIr32 (XSHWr16 R16C:$rB), 0))>;
2664
Scott Michel438be252007-12-17 22:32:34 +00002665def : Pat<(srl R16C:$rA, R8C:$rB),
Scott Michel8b6b4202007-12-04 22:35:58 +00002666 (ROTHMr16 R16C:$rA,
Scott Michel438be252007-12-17 22:32:34 +00002667 (SFIr32 (XSHWr16 (XSBHr8 R8C:$rB) ), 0))>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002668
2669// ROTHMI v8i16 form: See the comment for ROTHM v8i16. The difference here is
2670// that the immediate can be complemented, so that the user doesn't have to
2671// worry about it.
Scott Michel8b6b4202007-12-04 22:35:58 +00002672
Scott Michel97872d32008-02-23 18:41:37 +00002673class ROTHMIInst<dag OOL, dag IOL, list<dag> pattern>:
2674 RI7Form<0b10111110000, OOL, IOL, "rothmi\t$rT, $rA, $val",
2675 RotateShift, pattern>;
2676
2677def ROTHMIv8i16:
2678 ROTHMIInst<(outs VECREG:$rT), (ins VECREG:$rA, rothNeg7imm:$val),
2679 [/* no pattern */]>;
2680
2681def : Pat<(SPUvec_srl (v8i16 VECREG:$rA), (i32 imm:$val)),
2682 (ROTHMIv8i16 VECREG:$rA, imm:$val)>;
2683
2684def: Pat<(SPUvec_srl (v8i16 VECREG:$rA), (i16 imm:$val)),
Scott Michel8b6b4202007-12-04 22:35:58 +00002685 (ROTHMIv8i16 VECREG:$rA, imm:$val)>;
Scott Michel06eabde2008-12-27 04:51:36 +00002686
Scott Michel97872d32008-02-23 18:41:37 +00002687def: Pat<(SPUvec_srl (v8i16 VECREG:$rA), (i8 imm:$val)),
Scott Michel5a6f17b2008-01-30 02:55:46 +00002688 (ROTHMIv8i16 VECREG:$rA, imm:$val)>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002689
2690def ROTHMIr16:
Scott Michel97872d32008-02-23 18:41:37 +00002691 ROTHMIInst<(outs R16C:$rT), (ins R16C:$rA, rothNeg7imm:$val),
2692 [/* no pattern */]>;
2693
2694def: Pat<(srl R16C:$rA, (i32 uimm7:$val)),
2695 (ROTHMIr16 R16C:$rA, uimm7:$val)>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002696
2697def: Pat<(srl R16C:$rA, (i16 uimm7:$val)),
2698 (ROTHMIr16 R16C:$rA, uimm7:$val)>;
2699
Scott Michel438be252007-12-17 22:32:34 +00002700def: Pat<(srl R16C:$rA, (i8 uimm7:$val)),
2701 (ROTHMIr16 R16C:$rA, uimm7:$val)>;
2702
Scott Michel8b6b4202007-12-04 22:35:58 +00002703// ROTM v4i32 form: See the ROTHM v8i16 comments.
Scott Michel97872d32008-02-23 18:41:37 +00002704class ROTMInst<dag OOL, dag IOL, list<dag> pattern>:
2705 RRForm<0b10011010000, OOL, IOL, "rotm\t$rT, $rA, $rB",
2706 RotateShift, pattern>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002707
Scott Michel97872d32008-02-23 18:41:37 +00002708def ROTMv4i32:
2709 ROTMInst<(outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB),
2710 [/* see patterns below - $rB must be negated */]>;
2711
2712def : Pat<(SPUvec_srl VECREG:$rA, R32C:$rB),
Scott Michel8b6b4202007-12-04 22:35:58 +00002713 (ROTMv4i32 VECREG:$rA, (SFIr32 R32C:$rB, 0))>;
2714
Scott Michel97872d32008-02-23 18:41:37 +00002715def : Pat<(SPUvec_srl VECREG:$rA, R16C:$rB),
Scott Michel8b6b4202007-12-04 22:35:58 +00002716 (ROTMv4i32 VECREG:$rA,
2717 (SFIr32 (XSHWr16 R16C:$rB), 0))>;
2718
Scott Michel97872d32008-02-23 18:41:37 +00002719def : Pat<(SPUvec_srl VECREG:$rA, R8C:$rB),
Scott Michel8b6b4202007-12-04 22:35:58 +00002720 (ROTMv4i32 VECREG:$rA,
Scott Michel97872d32008-02-23 18:41:37 +00002721 (SFIr32 (XSHWr16 (XSBHr8 R8C:$rB)), 0))>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002722
2723def ROTMr32:
Scott Michel97872d32008-02-23 18:41:37 +00002724 ROTMInst<(outs R32C:$rT), (ins R32C:$rA, R32C:$rB),
2725 [/* see patterns below - $rB must be negated */]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002726
2727def : Pat<(srl R32C:$rA, R32C:$rB),
2728 (ROTMr32 R32C:$rA, (SFIr32 R32C:$rB, 0))>;
2729
2730def : Pat<(srl R32C:$rA, R16C:$rB),
2731 (ROTMr32 R32C:$rA,
2732 (SFIr32 (XSHWr16 R16C:$rB), 0))>;
2733
Scott Michel438be252007-12-17 22:32:34 +00002734def : Pat<(srl R32C:$rA, R8C:$rB),
2735 (ROTMr32 R32C:$rA,
2736 (SFIr32 (XSHWr16 (XSBHr8 R8C:$rB)), 0))>;
2737
Scott Michel8b6b4202007-12-04 22:35:58 +00002738// ROTMI v4i32 form: See the comment for ROTHM v8i16.
2739def ROTMIv4i32:
2740 RI7Form<0b10011110000, (outs VECREG:$rT), (ins VECREG:$rA, rotNeg7imm:$val),
2741 "rotmi\t$rT, $rA, $val", RotateShift,
2742 [(set (v4i32 VECREG:$rT),
Scott Michel97872d32008-02-23 18:41:37 +00002743 (SPUvec_srl VECREG:$rA, (i32 uimm7:$val)))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002744
Scott Michel97872d32008-02-23 18:41:37 +00002745def : Pat<(SPUvec_srl VECREG:$rA, (i16 uimm7:$val)),
Scott Michel8b6b4202007-12-04 22:35:58 +00002746 (ROTMIv4i32 VECREG:$rA, uimm7:$val)>;
Scott Michel06eabde2008-12-27 04:51:36 +00002747
Scott Michel97872d32008-02-23 18:41:37 +00002748def : Pat<(SPUvec_srl VECREG:$rA, (i8 uimm7:$val)),
Scott Michel438be252007-12-17 22:32:34 +00002749 (ROTMIv4i32 VECREG:$rA, uimm7:$val)>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002750
2751// ROTMI r32 form: know how to complement the immediate value.
2752def ROTMIr32:
2753 RI7Form<0b10011110000, (outs R32C:$rT), (ins R32C:$rA, rotNeg7imm:$val),
2754 "rotmi\t$rT, $rA, $val", RotateShift,
2755 [(set R32C:$rT, (srl R32C:$rA, (i32 uimm7:$val)))]>;
2756
2757def : Pat<(srl R32C:$rA, (i16 imm:$val)),
2758 (ROTMIr32 R32C:$rA, uimm7:$val)>;
2759
Scott Michel438be252007-12-17 22:32:34 +00002760def : Pat<(srl R32C:$rA, (i8 imm:$val)),
2761 (ROTMIr32 R32C:$rA, uimm7:$val)>;
2762
Scott Michel97872d32008-02-23 18:41:37 +00002763//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
Scott Michel2ef773a2009-01-06 03:36:14 +00002764// ROTQMBY: This is a vector form merely so that when used in an
Scott Michel8b6b4202007-12-04 22:35:58 +00002765// instruction pattern, type checking will succeed. This instruction assumes
Scott Michel97872d32008-02-23 18:41:37 +00002766// that the user knew to negate $rB.
Scott Michel97872d32008-02-23 18:41:37 +00002767//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
Scott Michel8b6b4202007-12-04 22:35:58 +00002768
Scott Michel97872d32008-02-23 18:41:37 +00002769class ROTQMBYInst<dag OOL, dag IOL, list<dag> pattern>:
2770 RRForm<0b10111011100, OOL, IOL, "rotqmby\t$rT, $rA, $rB",
2771 RotateShift, pattern>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002772
Scott Michel97872d32008-02-23 18:41:37 +00002773class ROTQMBYVecInst<ValueType vectype>:
2774 ROTQMBYInst<(outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB),
2775 [/* no pattern, $rB must be negated */]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002776
Scott Michel97872d32008-02-23 18:41:37 +00002777class ROTQMBYRegInst<RegisterClass rclass>:
2778 ROTQMBYInst<(outs rclass:$rT), (ins rclass:$rA, R32C:$rB),
Scott Michel4d07fb72008-12-30 23:28:25 +00002779 [/* no pattern */]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002780
Scott Michel97872d32008-02-23 18:41:37 +00002781multiclass RotateQuadBytes
2782{
2783 def v16i8: ROTQMBYVecInst<v16i8>;
2784 def v8i16: ROTQMBYVecInst<v8i16>;
2785 def v4i32: ROTQMBYVecInst<v4i32>;
2786 def v2i64: ROTQMBYVecInst<v2i64>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002787
Scott Michel97872d32008-02-23 18:41:37 +00002788 def r128: ROTQMBYRegInst<GPRC>;
2789 def r64: ROTQMBYRegInst<R64C>;
2790}
2791
2792defm ROTQMBY : RotateQuadBytes;
2793
Scott Michel97872d32008-02-23 18:41:37 +00002794class ROTQMBYIInst<dag OOL, dag IOL, list<dag> pattern>:
2795 RI7Form<0b10111111100, OOL, IOL, "rotqmbyi\t$rT, $rA, $val",
2796 RotateShift, pattern>;
2797
2798class ROTQMBYIVecInst<ValueType vectype>:
2799 ROTQMBYIInst<(outs VECREG:$rT), (ins VECREG:$rA, rotNeg7imm:$val),
Scott Michel4d07fb72008-12-30 23:28:25 +00002800 [/* no pattern */]>;
Scott Michel97872d32008-02-23 18:41:37 +00002801
Scott Michel2ef773a2009-01-06 03:36:14 +00002802class ROTQMBYIRegInst<RegisterClass rclass, Operand optype, ValueType inttype,
2803 PatLeaf pred>:
Scott Michel97872d32008-02-23 18:41:37 +00002804 ROTQMBYIInst<(outs rclass:$rT), (ins rclass:$rA, optype:$val),
Scott Michel4d07fb72008-12-30 23:28:25 +00002805 [/* no pattern */]>;
Scott Michel97872d32008-02-23 18:41:37 +00002806
Scott Michel2ef773a2009-01-06 03:36:14 +00002807// 128-bit zero extension form:
2808class ROTQMBYIZExtInst<RegisterClass rclass, Operand optype, PatLeaf pred>:
2809 ROTQMBYIInst<(outs GPRC:$rT), (ins rclass:$rA, optype:$val),
2810 [/* no pattern */]>;
2811
Scott Michel97872d32008-02-23 18:41:37 +00002812multiclass RotateQuadBytesImm
2813{
2814 def v16i8: ROTQMBYIVecInst<v16i8>;
2815 def v8i16: ROTQMBYIVecInst<v8i16>;
2816 def v4i32: ROTQMBYIVecInst<v4i32>;
2817 def v2i64: ROTQMBYIVecInst<v2i64>;
2818
2819 def r128: ROTQMBYIRegInst<GPRC, rotNeg7imm, i32, uimm7>;
2820 def r64: ROTQMBYIRegInst<R64C, rotNeg7imm, i32, uimm7>;
Scott Michel2ef773a2009-01-06 03:36:14 +00002821
2822 def r128_zext_r8: ROTQMBYIZExtInst<R8C, rotNeg7imm, uimm7>;
2823 def r128_zext_r16: ROTQMBYIZExtInst<R16C, rotNeg7imm, uimm7>;
2824 def r128_zext_r32: ROTQMBYIZExtInst<R32C, rotNeg7imm, uimm7>;
2825 def r128_zext_r64: ROTQMBYIZExtInst<R64C, rotNeg7imm, uimm7>;
Scott Michel97872d32008-02-23 18:41:37 +00002826}
2827
2828defm ROTQMBYI : RotateQuadBytesImm;
2829
Scott Michel97872d32008-02-23 18:41:37 +00002830//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2831// Rotate right and mask by bit count
2832//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2833
2834class ROTQMBYBIInst<dag OOL, dag IOL, list<dag> pattern>:
2835 RRForm<0b10110011100, OOL, IOL, "rotqmbybi\t$rT, $rA, $rB",
2836 RotateShift, pattern>;
2837
2838class ROTQMBYBIVecInst<ValueType vectype>:
Scott Michel4d07fb72008-12-30 23:28:25 +00002839 ROTQMBYBIInst<(outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB),
2840 [/* no pattern, */]>;
Scott Michel97872d32008-02-23 18:41:37 +00002841
2842multiclass RotateMaskQuadByBitCount
2843{
2844 def v16i8: ROTQMBYBIVecInst<v16i8>;
2845 def v8i16: ROTQMBYBIVecInst<v8i16>;
2846 def v4i32: ROTQMBYBIVecInst<v4i32>;
2847 def v2i64: ROTQMBYBIVecInst<v2i64>;
2848}
2849
2850defm ROTQMBYBI: RotateMaskQuadByBitCount;
2851
2852//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2853// Rotate quad and mask by bits
2854// Note that the rotate amount has to be negated
2855//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2856
2857class ROTQMBIInst<dag OOL, dag IOL, list<dag> pattern>:
2858 RRForm<0b10011011100, OOL, IOL, "rotqmbi\t$rT, $rA, $rB",
2859 RotateShift, pattern>;
2860
2861class ROTQMBIVecInst<ValueType vectype>:
2862 ROTQMBIInst<(outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB),
2863 [/* no pattern */]>;
2864
2865class ROTQMBIRegInst<RegisterClass rclass>:
2866 ROTQMBIInst<(outs rclass:$rT), (ins rclass:$rA, R32C:$rB),
2867 [/* no pattern */]>;
2868
2869multiclass RotateMaskQuadByBits
2870{
2871 def v16i8: ROTQMBIVecInst<v16i8>;
2872 def v8i16: ROTQMBIVecInst<v8i16>;
2873 def v4i32: ROTQMBIVecInst<v4i32>;
2874 def v2i64: ROTQMBIVecInst<v2i64>;
2875
2876 def r128: ROTQMBIRegInst<GPRC>;
2877 def r64: ROTQMBIRegInst<R64C>;
2878}
2879
2880defm ROTQMBI: RotateMaskQuadByBits;
2881
Scott Michel97872d32008-02-23 18:41:37 +00002882//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2883// Rotate quad and mask by bits, immediate
2884//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2885
2886class ROTQMBIIInst<dag OOL, dag IOL, list<dag> pattern>:
2887 RI7Form<0b10011111100, OOL, IOL, "rotqmbii\t$rT, $rA, $val",
2888 RotateShift, pattern>;
2889
2890class ROTQMBIIVecInst<ValueType vectype>:
2891 ROTQMBIIInst<(outs VECREG:$rT), (ins VECREG:$rA, rotNeg7imm:$val),
Scott Michel4d07fb72008-12-30 23:28:25 +00002892 [/* no pattern */]>;
Scott Michel97872d32008-02-23 18:41:37 +00002893
2894class ROTQMBIIRegInst<RegisterClass rclass>:
2895 ROTQMBIIInst<(outs rclass:$rT), (ins rclass:$rA, rotNeg7imm:$val),
Scott Michel4d07fb72008-12-30 23:28:25 +00002896 [/* no pattern */]>;
Scott Michel97872d32008-02-23 18:41:37 +00002897
2898multiclass RotateMaskQuadByBitsImm
2899{
2900 def v16i8: ROTQMBIIVecInst<v16i8>;
2901 def v8i16: ROTQMBIIVecInst<v8i16>;
2902 def v4i32: ROTQMBIIVecInst<v4i32>;
2903 def v2i64: ROTQMBIIVecInst<v2i64>;
2904
2905 def r128: ROTQMBIIRegInst<GPRC>;
2906 def r64: ROTQMBIIRegInst<R64C>;
2907}
2908
2909defm ROTQMBII: RotateMaskQuadByBitsImm;
2910
2911//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2912//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
Scott Michel8b6b4202007-12-04 22:35:58 +00002913
2914def ROTMAHv8i16:
2915 RRForm<0b01111010000, (outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB),
2916 "rotmah\t$rT, $rA, $rB", RotateShift,
2917 [/* see patterns below - $rB must be negated */]>;
2918
Scott Michel97872d32008-02-23 18:41:37 +00002919def : Pat<(SPUvec_sra VECREG:$rA, R32C:$rB),
Scott Michel8b6b4202007-12-04 22:35:58 +00002920 (ROTMAHv8i16 VECREG:$rA, (SFIr32 R32C:$rB, 0))>;
2921
Scott Michel97872d32008-02-23 18:41:37 +00002922def : Pat<(SPUvec_sra VECREG:$rA, R16C:$rB),
Scott Michel8b6b4202007-12-04 22:35:58 +00002923 (ROTMAHv8i16 VECREG:$rA,
2924 (SFIr32 (XSHWr16 R16C:$rB), 0))>;
2925
Scott Michel97872d32008-02-23 18:41:37 +00002926def : Pat<(SPUvec_sra VECREG:$rA, R8C:$rB),
Scott Michel438be252007-12-17 22:32:34 +00002927 (ROTMAHv8i16 VECREG:$rA,
2928 (SFIr32 (XSHWr16 (XSBHr8 R8C:$rB)), 0))>;
2929
Scott Michel8b6b4202007-12-04 22:35:58 +00002930def ROTMAHr16:
2931 RRForm<0b01111010000, (outs R16C:$rT), (ins R16C:$rA, R32C:$rB),
2932 "rotmah\t$rT, $rA, $rB", RotateShift,
2933 [/* see patterns below - $rB must be negated */]>;
2934
2935def : Pat<(sra R16C:$rA, R32C:$rB),
2936 (ROTMAHr16 R16C:$rA, (SFIr32 R32C:$rB, 0))>;
2937
2938def : Pat<(sra R16C:$rA, R16C:$rB),
2939 (ROTMAHr16 R16C:$rA,
2940 (SFIr32 (XSHWr16 R16C:$rB), 0))>;
2941
Scott Michel438be252007-12-17 22:32:34 +00002942def : Pat<(sra R16C:$rA, R8C:$rB),
2943 (ROTMAHr16 R16C:$rA,
2944 (SFIr32 (XSHWr16 (XSBHr8 R8C:$rB)), 0))>;
2945
Scott Michel8b6b4202007-12-04 22:35:58 +00002946def ROTMAHIv8i16:
2947 RRForm<0b01111110000, (outs VECREG:$rT), (ins VECREG:$rA, rothNeg7imm:$val),
2948 "rotmahi\t$rT, $rA, $val", RotateShift,
2949 [(set (v8i16 VECREG:$rT),
Scott Michel97872d32008-02-23 18:41:37 +00002950 (SPUvec_sra (v8i16 VECREG:$rA), (i32 uimm7:$val)))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002951
Scott Michel97872d32008-02-23 18:41:37 +00002952def : Pat<(SPUvec_sra (v8i16 VECREG:$rA), (i16 uimm7:$val)),
Scott Michel8b6b4202007-12-04 22:35:58 +00002953 (ROTMAHIv8i16 (v8i16 VECREG:$rA), (i32 uimm7:$val))>;
2954
Scott Michel97872d32008-02-23 18:41:37 +00002955def : Pat<(SPUvec_sra (v8i16 VECREG:$rA), (i8 uimm7:$val)),
Scott Michel438be252007-12-17 22:32:34 +00002956 (ROTMAHIv8i16 (v8i16 VECREG:$rA), (i32 uimm7:$val))>;
2957
Scott Michel8b6b4202007-12-04 22:35:58 +00002958def ROTMAHIr16:
2959 RRForm<0b01111110000, (outs R16C:$rT), (ins R16C:$rA, rothNeg7imm_i16:$val),
2960 "rotmahi\t$rT, $rA, $val", RotateShift,
2961 [(set R16C:$rT, (sra R16C:$rA, (i16 uimm7:$val)))]>;
2962
2963def : Pat<(sra R16C:$rA, (i32 imm:$val)),
2964 (ROTMAHIr16 R16C:$rA, uimm7:$val)>;
2965
Scott Michel438be252007-12-17 22:32:34 +00002966def : Pat<(sra R16C:$rA, (i8 imm:$val)),
2967 (ROTMAHIr16 R16C:$rA, uimm7:$val)>;
2968
Scott Michel8b6b4202007-12-04 22:35:58 +00002969def ROTMAv4i32:
2970 RRForm<0b01011010000, (outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB),
2971 "rotma\t$rT, $rA, $rB", RotateShift,
2972 [/* see patterns below - $rB must be negated */]>;
2973
Scott Michel97872d32008-02-23 18:41:37 +00002974def : Pat<(SPUvec_sra VECREG:$rA, R32C:$rB),
Scott Michel8b6b4202007-12-04 22:35:58 +00002975 (ROTMAv4i32 (v4i32 VECREG:$rA), (SFIr32 R32C:$rB, 0))>;
2976
Scott Michel97872d32008-02-23 18:41:37 +00002977def : Pat<(SPUvec_sra VECREG:$rA, R16C:$rB),
Scott Michel8b6b4202007-12-04 22:35:58 +00002978 (ROTMAv4i32 (v4i32 VECREG:$rA),
2979 (SFIr32 (XSHWr16 R16C:$rB), 0))>;
2980
Scott Michel97872d32008-02-23 18:41:37 +00002981def : Pat<(SPUvec_sra VECREG:$rA, R8C:$rB),
Scott Michel438be252007-12-17 22:32:34 +00002982 (ROTMAv4i32 (v4i32 VECREG:$rA),
2983 (SFIr32 (XSHWr16 (XSBHr8 R8C:$rB)), 0))>;
2984
Scott Michel8b6b4202007-12-04 22:35:58 +00002985def ROTMAr32:
2986 RRForm<0b01011010000, (outs R32C:$rT), (ins R32C:$rA, R32C:$rB),
2987 "rotma\t$rT, $rA, $rB", RotateShift,
2988 [/* see patterns below - $rB must be negated */]>;
2989
2990def : Pat<(sra R32C:$rA, R32C:$rB),
2991 (ROTMAr32 R32C:$rA, (SFIr32 R32C:$rB, 0))>;
2992
2993def : Pat<(sra R32C:$rA, R16C:$rB),
2994 (ROTMAr32 R32C:$rA,
2995 (SFIr32 (XSHWr16 R16C:$rB), 0))>;
2996
Scott Michel438be252007-12-17 22:32:34 +00002997def : Pat<(sra R32C:$rA, R8C:$rB),
2998 (ROTMAr32 R32C:$rA,
2999 (SFIr32 (XSHWr16 (XSBHr8 R8C:$rB)), 0))>;
3000
Scott Michel67224b22008-06-02 22:18:03 +00003001class ROTMAIInst<dag OOL, dag IOL, list<dag> pattern>:
3002 RRForm<0b01011110000, OOL, IOL,
3003 "rotmai\t$rT, $rA, $val",
3004 RotateShift, pattern>;
Scott Michel8b6b4202007-12-04 22:35:58 +00003005
Scott Michel67224b22008-06-02 22:18:03 +00003006class ROTMAIVecInst<ValueType vectype, Operand intop, ValueType inttype>:
3007 ROTMAIInst<(outs VECREG:$rT), (ins VECREG:$rA, intop:$val),
3008 [(set (vectype VECREG:$rT),
3009 (SPUvec_sra VECREG:$rA, (inttype uimm7:$val)))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00003010
Scott Michel67224b22008-06-02 22:18:03 +00003011class ROTMAIRegInst<RegisterClass rclass, Operand intop, ValueType inttype>:
3012 ROTMAIInst<(outs rclass:$rT), (ins rclass:$rA, intop:$val),
3013 [(set rclass:$rT, (sra rclass:$rA, (inttype uimm7:$val)))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00003014
Scott Michel67224b22008-06-02 22:18:03 +00003015multiclass RotateMaskAlgebraicImm {
3016 def v2i64_i32 : ROTMAIVecInst<v2i64, rotNeg7imm, i32>;
3017 def v4i32_i32 : ROTMAIVecInst<v4i32, rotNeg7imm, i32>;
3018 def r64_i32 : ROTMAIRegInst<R64C, rotNeg7imm, i32>;
3019 def r32_i32 : ROTMAIRegInst<R32C, rotNeg7imm, i32>;
3020}
Scott Michel8b6b4202007-12-04 22:35:58 +00003021
Scott Michel67224b22008-06-02 22:18:03 +00003022defm ROTMAI : RotateMaskAlgebraicImm;
Scott Michel438be252007-12-17 22:32:34 +00003023
Scott Michel8b6b4202007-12-04 22:35:58 +00003024//===----------------------------------------------------------------------===//
3025// Branch and conditionals:
3026//===----------------------------------------------------------------------===//
3027
3028let isTerminator = 1, isBarrier = 1 in {
3029 // Halt If Equal (r32 preferred slot only, no vector form)
3030 def HEQr32:
3031 RRForm_3<0b00011011110, (outs), (ins R32C:$rA, R32C:$rB),
3032 "heq\t$rA, $rB", BranchResolv,
3033 [/* no pattern to match */]>;
3034
3035 def HEQIr32 :
3036 RI10Form_2<0b11111110, (outs), (ins R32C:$rA, s10imm:$val),
3037 "heqi\t$rA, $val", BranchResolv,
3038 [/* no pattern to match */]>;
3039
3040 // HGT/HGTI: These instructions use signed arithmetic for the comparison,
3041 // contrasting with HLGT/HLGTI, which use unsigned comparison:
3042 def HGTr32:
3043 RRForm_3<0b00011010010, (outs), (ins R32C:$rA, R32C:$rB),
3044 "hgt\t$rA, $rB", BranchResolv,
3045 [/* no pattern to match */]>;
3046
Scott Michel06eabde2008-12-27 04:51:36 +00003047 def HGTIr32:
Scott Michel8b6b4202007-12-04 22:35:58 +00003048 RI10Form_2<0b11110010, (outs), (ins R32C:$rA, s10imm:$val),
3049 "hgti\t$rA, $val", BranchResolv,
3050 [/* no pattern to match */]>;
3051
3052 def HLGTr32:
3053 RRForm_3<0b00011011010, (outs), (ins R32C:$rA, R32C:$rB),
3054 "hlgt\t$rA, $rB", BranchResolv,
3055 [/* no pattern to match */]>;
3056
3057 def HLGTIr32:
3058 RI10Form_2<0b11111010, (outs), (ins R32C:$rA, s10imm:$val),
3059 "hlgti\t$rA, $val", BranchResolv,
3060 [/* no pattern to match */]>;
3061}
3062
Scott Michel06eabde2008-12-27 04:51:36 +00003063//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
3064// Comparison operators for i8, i16 and i32:
3065//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
Scott Michel8b6b4202007-12-04 22:35:58 +00003066
Scott Michel97872d32008-02-23 18:41:37 +00003067class CEQBInst<dag OOL, dag IOL, list<dag> pattern> :
3068 RRForm<0b00001011110, OOL, IOL, "ceqb\t$rT, $rA, $rB",
3069 ByteOp, pattern>;
Scott Michel8b6b4202007-12-04 22:35:58 +00003070
Scott Michel97872d32008-02-23 18:41:37 +00003071multiclass CmpEqualByte
3072{
3073 def v16i8 :
3074 CEQBInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
3075 [(set (v16i8 VECREG:$rT), (seteq (v8i16 VECREG:$rA),
3076 (v8i16 VECREG:$rB)))]>;
Scott Michel438be252007-12-17 22:32:34 +00003077
Scott Michel97872d32008-02-23 18:41:37 +00003078 def r8 :
3079 CEQBInst<(outs R8C:$rT), (ins R8C:$rA, R8C:$rB),
3080 [(set R8C:$rT, (seteq R8C:$rA, R8C:$rB))]>;
3081}
Scott Michel8b6b4202007-12-04 22:35:58 +00003082
Scott Michel97872d32008-02-23 18:41:37 +00003083class CEQBIInst<dag OOL, dag IOL, list<dag> pattern> :
3084 RI10Form<0b01111110, OOL, IOL, "ceqbi\t$rT, $rA, $val",
3085 ByteOp, pattern>;
Scott Michel8b6b4202007-12-04 22:35:58 +00003086
Scott Michel97872d32008-02-23 18:41:37 +00003087multiclass CmpEqualByteImm
3088{
3089 def v16i8 :
3090 CEQBIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm_i8:$val),
3091 [(set (v16i8 VECREG:$rT), (seteq (v16i8 VECREG:$rA),
3092 v16i8SExt8Imm:$val))]>;
3093 def r8:
3094 CEQBIInst<(outs R8C:$rT), (ins R8C:$rA, s10imm_i8:$val),
3095 [(set R8C:$rT, (seteq R8C:$rA, immSExt8:$val))]>;
3096}
Scott Michel8b6b4202007-12-04 22:35:58 +00003097
Scott Michel97872d32008-02-23 18:41:37 +00003098class CEQHInst<dag OOL, dag IOL, list<dag> pattern> :
3099 RRForm<0b00010011110, OOL, IOL, "ceqh\t$rT, $rA, $rB",
3100 ByteOp, pattern>;
Scott Michel8b6b4202007-12-04 22:35:58 +00003101
Scott Michel97872d32008-02-23 18:41:37 +00003102multiclass CmpEqualHalfword
3103{
3104 def v8i16 : CEQHInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
3105 [(set (v8i16 VECREG:$rT), (seteq (v8i16 VECREG:$rA),
3106 (v8i16 VECREG:$rB)))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00003107
Scott Michel97872d32008-02-23 18:41:37 +00003108 def r16 : CEQHInst<(outs R16C:$rT), (ins R16C:$rA, R16C:$rB),
3109 [(set R16C:$rT, (seteq R16C:$rA, R16C:$rB))]>;
3110}
Scott Michel8b6b4202007-12-04 22:35:58 +00003111
Scott Michel97872d32008-02-23 18:41:37 +00003112class CEQHIInst<dag OOL, dag IOL, list<dag> pattern> :
3113 RI10Form<0b10111110, OOL, IOL, "ceqhi\t$rT, $rA, $val",
3114 ByteOp, pattern>;
Scott Michel8b6b4202007-12-04 22:35:58 +00003115
Scott Michel97872d32008-02-23 18:41:37 +00003116multiclass CmpEqualHalfwordImm
3117{
3118 def v8i16 : CEQHIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
3119 [(set (v8i16 VECREG:$rT),
3120 (seteq (v8i16 VECREG:$rA),
3121 (v8i16 v8i16SExt10Imm:$val)))]>;
3122 def r16 : CEQHIInst<(outs R16C:$rT), (ins R16C:$rA, s10imm:$val),
3123 [(set R16C:$rT, (seteq R16C:$rA, i16ImmSExt10:$val))]>;
3124}
Scott Michel8b6b4202007-12-04 22:35:58 +00003125
Scott Michel97872d32008-02-23 18:41:37 +00003126class CEQInst<dag OOL, dag IOL, list<dag> pattern> :
3127 RRForm<0b00000011110, OOL, IOL, "ceq\t$rT, $rA, $rB",
3128 ByteOp, pattern>;
3129
3130multiclass CmpEqualWord
3131{
3132 def v4i32 : CEQInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
3133 [(set (v4i32 VECREG:$rT),
3134 (seteq (v4i32 VECREG:$rA), (v4i32 VECREG:$rB)))]>;
3135
3136 def r32 : CEQInst<(outs R32C:$rT), (ins R32C:$rA, R32C:$rB),
3137 [(set R32C:$rT, (seteq R32C:$rA, R32C:$rB))]>;
3138}
3139
3140class CEQIInst<dag OOL, dag IOL, list<dag> pattern> :
3141 RI10Form<0b00111110, OOL, IOL, "ceqi\t$rT, $rA, $val",
3142 ByteOp, pattern>;
3143
3144multiclass CmpEqualWordImm
3145{
3146 def v4i32 : CEQIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
3147 [(set (v4i32 VECREG:$rT),
3148 (seteq (v4i32 VECREG:$rA),
3149 (v4i32 v4i32SExt16Imm:$val)))]>;
3150
3151 def r32: CEQIInst<(outs R32C:$rT), (ins R32C:$rA, s10imm_i32:$val),
3152 [(set R32C:$rT, (seteq R32C:$rA, i32ImmSExt10:$val))]>;
3153}
3154
3155class CGTBInst<dag OOL, dag IOL, list<dag> pattern> :
3156 RRForm<0b00001010010, OOL, IOL, "cgtb\t$rT, $rA, $rB",
3157 ByteOp, pattern>;
3158
3159multiclass CmpGtrByte
3160{
3161 def v16i8 :
3162 CGTBInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
3163 [(set (v16i8 VECREG:$rT), (setgt (v8i16 VECREG:$rA),
3164 (v8i16 VECREG:$rB)))]>;
3165
3166 def r8 :
3167 CGTBInst<(outs R8C:$rT), (ins R8C:$rA, R8C:$rB),
3168 [(set R8C:$rT, (setgt R8C:$rA, R8C:$rB))]>;
3169}
3170
3171class CGTBIInst<dag OOL, dag IOL, list<dag> pattern> :
3172 RI10Form<0b01110010, OOL, IOL, "cgtbi\t$rT, $rA, $val",
3173 ByteOp, pattern>;
3174
3175multiclass CmpGtrByteImm
3176{
3177 def v16i8 :
3178 CGTBIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm_i8:$val),
3179 [(set (v16i8 VECREG:$rT), (setgt (v16i8 VECREG:$rA),
3180 v16i8SExt8Imm:$val))]>;
3181 def r8:
3182 CGTBIInst<(outs R8C:$rT), (ins R8C:$rA, s10imm_i8:$val),
Scott Michel7833d472008-03-20 00:51:36 +00003183 [(set R8C:$rT, (setgt R8C:$rA, immSExt8:$val))]>;
Scott Michel97872d32008-02-23 18:41:37 +00003184}
3185
3186class CGTHInst<dag OOL, dag IOL, list<dag> pattern> :
3187 RRForm<0b00010010010, OOL, IOL, "cgth\t$rT, $rA, $rB",
3188 ByteOp, pattern>;
3189
3190multiclass CmpGtrHalfword
3191{
3192 def v8i16 : CGTHInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
3193 [(set (v8i16 VECREG:$rT), (setgt (v8i16 VECREG:$rA),
3194 (v8i16 VECREG:$rB)))]>;
3195
3196 def r16 : CGTHInst<(outs R16C:$rT), (ins R16C:$rA, R16C:$rB),
3197 [(set R16C:$rT, (setgt R16C:$rA, R16C:$rB))]>;
3198}
3199
3200class CGTHIInst<dag OOL, dag IOL, list<dag> pattern> :
3201 RI10Form<0b10110010, OOL, IOL, "cgthi\t$rT, $rA, $val",
3202 ByteOp, pattern>;
3203
3204multiclass CmpGtrHalfwordImm
3205{
3206 def v8i16 : CGTHIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
3207 [(set (v8i16 VECREG:$rT),
3208 (setgt (v8i16 VECREG:$rA),
3209 (v8i16 v8i16SExt10Imm:$val)))]>;
3210 def r16 : CGTHIInst<(outs R16C:$rT), (ins R16C:$rA, s10imm:$val),
3211 [(set R16C:$rT, (setgt R16C:$rA, i16ImmSExt10:$val))]>;
3212}
3213
3214class CGTInst<dag OOL, dag IOL, list<dag> pattern> :
3215 RRForm<0b00000010010, OOL, IOL, "cgt\t$rT, $rA, $rB",
3216 ByteOp, pattern>;
3217
3218multiclass CmpGtrWord
3219{
3220 def v4i32 : CGTInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
3221 [(set (v4i32 VECREG:$rT),
3222 (setgt (v4i32 VECREG:$rA), (v4i32 VECREG:$rB)))]>;
3223
3224 def r32 : CGTInst<(outs R32C:$rT), (ins R32C:$rA, R32C:$rB),
3225 [(set R32C:$rT, (setgt R32C:$rA, R32C:$rB))]>;
3226}
3227
3228class CGTIInst<dag OOL, dag IOL, list<dag> pattern> :
3229 RI10Form<0b00110010, OOL, IOL, "cgti\t$rT, $rA, $val",
3230 ByteOp, pattern>;
3231
3232multiclass CmpGtrWordImm
3233{
3234 def v4i32 : CGTIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
3235 [(set (v4i32 VECREG:$rT),
3236 (setgt (v4i32 VECREG:$rA),
3237 (v4i32 v4i32SExt16Imm:$val)))]>;
3238
3239 def r32: CGTIInst<(outs R32C:$rT), (ins R32C:$rA, s10imm_i32:$val),
3240 [(set R32C:$rT, (setgt R32C:$rA, i32ImmSExt10:$val))]>;
Scott Michel4d07fb72008-12-30 23:28:25 +00003241
3242 // CGTIv4f32, CGTIf32: These are used in the f32 fdiv instruction sequence:
3243 def v4f32: CGTIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
3244 [(set (v4i32 VECREG:$rT),
3245 (setgt (v4i32 (bitconvert (v4f32 VECREG:$rA))),
3246 (v4i32 v4i32SExt16Imm:$val)))]>;
3247
3248 def f32: CGTIInst<(outs R32C:$rT), (ins R32FP:$rA, s10imm_i32:$val),
pingbakb8913342009-01-26 03:37:41 +00003249 [/* no pattern */]>;
Scott Michel97872d32008-02-23 18:41:37 +00003250}
3251
3252class CLGTBInst<dag OOL, dag IOL, list<dag> pattern> :
Scott Michel6baba072008-03-05 23:02:02 +00003253 RRForm<0b00001011010, OOL, IOL, "clgtb\t$rT, $rA, $rB",
Scott Michel97872d32008-02-23 18:41:37 +00003254 ByteOp, pattern>;
3255
3256multiclass CmpLGtrByte
3257{
3258 def v16i8 :
3259 CLGTBInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
3260 [(set (v16i8 VECREG:$rT), (setugt (v8i16 VECREG:$rA),
3261 (v8i16 VECREG:$rB)))]>;
3262
3263 def r8 :
3264 CLGTBInst<(outs R8C:$rT), (ins R8C:$rA, R8C:$rB),
3265 [(set R8C:$rT, (setugt R8C:$rA, R8C:$rB))]>;
3266}
3267
3268class CLGTBIInst<dag OOL, dag IOL, list<dag> pattern> :
Scott Michel6baba072008-03-05 23:02:02 +00003269 RI10Form<0b01111010, OOL, IOL, "clgtbi\t$rT, $rA, $val",
Scott Michel97872d32008-02-23 18:41:37 +00003270 ByteOp, pattern>;
3271
3272multiclass CmpLGtrByteImm
3273{
3274 def v16i8 :
3275 CLGTBIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm_i8:$val),
3276 [(set (v16i8 VECREG:$rT), (setugt (v16i8 VECREG:$rA),
3277 v16i8SExt8Imm:$val))]>;
3278 def r8:
3279 CLGTBIInst<(outs R8C:$rT), (ins R8C:$rA, s10imm_i8:$val),
3280 [(set R8C:$rT, (setugt R8C:$rA, immSExt8:$val))]>;
3281}
3282
3283class CLGTHInst<dag OOL, dag IOL, list<dag> pattern> :
Scott Michel6baba072008-03-05 23:02:02 +00003284 RRForm<0b00010011010, OOL, IOL, "clgth\t$rT, $rA, $rB",
Scott Michel97872d32008-02-23 18:41:37 +00003285 ByteOp, pattern>;
3286
3287multiclass CmpLGtrHalfword
3288{
3289 def v8i16 : CLGTHInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
3290 [(set (v8i16 VECREG:$rT), (setugt (v8i16 VECREG:$rA),
3291 (v8i16 VECREG:$rB)))]>;
3292
3293 def r16 : CLGTHInst<(outs R16C:$rT), (ins R16C:$rA, R16C:$rB),
3294 [(set R16C:$rT, (setugt R16C:$rA, R16C:$rB))]>;
3295}
3296
3297class CLGTHIInst<dag OOL, dag IOL, list<dag> pattern> :
Scott Michel6baba072008-03-05 23:02:02 +00003298 RI10Form<0b10111010, OOL, IOL, "clgthi\t$rT, $rA, $val",
Scott Michel97872d32008-02-23 18:41:37 +00003299 ByteOp, pattern>;
3300
3301multiclass CmpLGtrHalfwordImm
3302{
3303 def v8i16 : CLGTHIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
3304 [(set (v8i16 VECREG:$rT),
3305 (setugt (v8i16 VECREG:$rA),
3306 (v8i16 v8i16SExt10Imm:$val)))]>;
3307 def r16 : CLGTHIInst<(outs R16C:$rT), (ins R16C:$rA, s10imm:$val),
3308 [(set R16C:$rT, (setugt R16C:$rA, i16ImmSExt10:$val))]>;
3309}
3310
3311class CLGTInst<dag OOL, dag IOL, list<dag> pattern> :
Scott Michel6baba072008-03-05 23:02:02 +00003312 RRForm<0b00000011010, OOL, IOL, "clgt\t$rT, $rA, $rB",
Scott Michel97872d32008-02-23 18:41:37 +00003313 ByteOp, pattern>;
3314
3315multiclass CmpLGtrWord
3316{
3317 def v4i32 : CLGTInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
3318 [(set (v4i32 VECREG:$rT),
3319 (setugt (v4i32 VECREG:$rA), (v4i32 VECREG:$rB)))]>;
3320
3321 def r32 : CLGTInst<(outs R32C:$rT), (ins R32C:$rA, R32C:$rB),
3322 [(set R32C:$rT, (setugt R32C:$rA, R32C:$rB))]>;
3323}
3324
3325class CLGTIInst<dag OOL, dag IOL, list<dag> pattern> :
Scott Michel6baba072008-03-05 23:02:02 +00003326 RI10Form<0b00111010, OOL, IOL, "clgti\t$rT, $rA, $val",
Scott Michel97872d32008-02-23 18:41:37 +00003327 ByteOp, pattern>;
3328
3329multiclass CmpLGtrWordImm
3330{
3331 def v4i32 : CLGTIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
3332 [(set (v4i32 VECREG:$rT),
3333 (setugt (v4i32 VECREG:$rA),
3334 (v4i32 v4i32SExt16Imm:$val)))]>;
3335
3336 def r32: CLGTIInst<(outs R32C:$rT), (ins R32C:$rA, s10imm_i32:$val),
Scott Michel6baba072008-03-05 23:02:02 +00003337 [(set R32C:$rT, (setugt R32C:$rA, i32ImmSExt10:$val))]>;
Scott Michel97872d32008-02-23 18:41:37 +00003338}
3339
3340defm CEQB : CmpEqualByte;
3341defm CEQBI : CmpEqualByteImm;
3342defm CEQH : CmpEqualHalfword;
3343defm CEQHI : CmpEqualHalfwordImm;
3344defm CEQ : CmpEqualWord;
3345defm CEQI : CmpEqualWordImm;
3346defm CGTB : CmpGtrByte;
3347defm CGTBI : CmpGtrByteImm;
3348defm CGTH : CmpGtrHalfword;
3349defm CGTHI : CmpGtrHalfwordImm;
3350defm CGT : CmpGtrWord;
3351defm CGTI : CmpGtrWordImm;
3352defm CLGTB : CmpLGtrByte;
3353defm CLGTBI : CmpLGtrByteImm;
3354defm CLGTH : CmpLGtrHalfword;
3355defm CLGTHI : CmpLGtrHalfwordImm;
3356defm CLGT : CmpLGtrWord;
3357defm CLGTI : CmpLGtrWordImm;
3358
Scott Michel53ab7792008-03-10 16:58:52 +00003359//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
Scott Michel97872d32008-02-23 18:41:37 +00003360// For SETCC primitives not supported above (setlt, setle, setge, etc.)
3361// define a pattern to generate the right code, as a binary operator
3362// (in a manner of speaking.)
Scott Michel53ab7792008-03-10 16:58:52 +00003363//
Scott Michel06eabde2008-12-27 04:51:36 +00003364// Notes:
3365// 1. This only matches the setcc set of conditionals. Special pattern
3366// matching is used for select conditionals.
3367//
3368// 2. The "DAG" versions of these classes is almost exclusively used for
3369// i64 comparisons. See the tblgen fundamentals documentation for what
3370// ".ResultInstrs[0]" means; see TargetSelectionDAG.td and the Pattern
3371// class for where ResultInstrs originates.
Scott Michel53ab7792008-03-10 16:58:52 +00003372//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
Scott Michel97872d32008-02-23 18:41:37 +00003373
Scott Michel53ab7792008-03-10 16:58:52 +00003374class SETCCNegCondReg<PatFrag cond, RegisterClass rclass, ValueType inttype,
3375 SPUInstr xorinst, SPUInstr cmpare>:
3376 Pat<(cond rclass:$rA, rclass:$rB),
3377 (xorinst (cmpare rclass:$rA, rclass:$rB), (inttype -1))>;
3378
3379class SETCCNegCondImm<PatFrag cond, RegisterClass rclass, ValueType inttype,
3380 PatLeaf immpred, SPUInstr xorinst, SPUInstr cmpare>:
3381 Pat<(cond rclass:$rA, (inttype immpred:$imm)),
3382 (xorinst (cmpare rclass:$rA, (inttype immpred:$imm)), (inttype -1))>;
3383
Scott Michel06eabde2008-12-27 04:51:36 +00003384def : SETCCNegCondReg<setne, R8C, i8, XORBIr8, CEQBr8>;
Scott Michel53ab7792008-03-10 16:58:52 +00003385def : SETCCNegCondImm<setne, R8C, i8, immSExt8, XORBIr8, CEQBIr8>;
3386
Scott Michel06eabde2008-12-27 04:51:36 +00003387def : SETCCNegCondReg<setne, R16C, i16, XORHIr16, CEQHr16>;
Scott Michel53ab7792008-03-10 16:58:52 +00003388def : SETCCNegCondImm<setne, R16C, i16, i16ImmSExt10, XORHIr16, CEQHIr16>;
3389
3390def : SETCCNegCondReg<setne, R32C, i32, XORIr32, CEQr32>;
3391def : SETCCNegCondImm<setne, R32C, i32, i32ImmSExt10, XORIr32, CEQIr32>;
Scott Michel97872d32008-02-23 18:41:37 +00003392
3393class SETCCBinOpReg<PatFrag cond, RegisterClass rclass,
3394 SPUInstr binop, SPUInstr cmpOp1, SPUInstr cmpOp2>:
3395 Pat<(cond rclass:$rA, rclass:$rB),
3396 (binop (cmpOp1 rclass:$rA, rclass:$rB),
3397 (cmpOp2 rclass:$rA, rclass:$rB))>;
3398
3399class SETCCBinOpImm<PatFrag cond, RegisterClass rclass, PatLeaf immpred,
3400 ValueType immtype,
3401 SPUInstr binop, SPUInstr cmpOp1, SPUInstr cmpOp2>:
3402 Pat<(cond rclass:$rA, (immtype immpred:$imm)),
3403 (binop (cmpOp1 rclass:$rA, (immtype immpred:$imm)),
3404 (cmpOp2 rclass:$rA, (immtype immpred:$imm)))>;
3405
Scott Michel53ab7792008-03-10 16:58:52 +00003406def : SETCCBinOpReg<setge, R8C, ORr8, CGTBr8, CEQBr8>;
3407def : SETCCBinOpImm<setge, R8C, immSExt8, i8, ORr8, CGTBIr8, CEQBIr8>;
3408def : SETCCBinOpReg<setlt, R8C, NORr8, CGTBr8, CEQBr8>;
3409def : SETCCBinOpImm<setlt, R8C, immSExt8, i8, NORr8, CGTBIr8, CEQBIr8>;
3410def : Pat<(setle R8C:$rA, R8C:$rB),
3411 (XORBIr8 (CGTBr8 R8C:$rA, R8C:$rB), 0xff)>;
3412def : Pat<(setle R8C:$rA, immU8:$imm),
3413 (XORBIr8 (CGTBIr8 R8C:$rA, immU8:$imm), 0xff)>;
Scott Michel97872d32008-02-23 18:41:37 +00003414
Scott Michel53ab7792008-03-10 16:58:52 +00003415def : SETCCBinOpReg<setge, R16C, ORr16, CGTHr16, CEQHr16>;
3416def : SETCCBinOpImm<setge, R16C, i16ImmSExt10, i16,
3417 ORr16, CGTHIr16, CEQHIr16>;
3418def : SETCCBinOpReg<setlt, R16C, NORr16, CGTHr16, CEQHr16>;
3419def : SETCCBinOpImm<setlt, R16C, i16ImmSExt10, i16, NORr16, CGTHIr16, CEQHIr16>;
3420def : Pat<(setle R16C:$rA, R16C:$rB),
3421 (XORHIr16 (CGTHr16 R16C:$rA, R16C:$rB), 0xffff)>;
3422def : Pat<(setle R16C:$rA, i16ImmSExt10:$imm),
3423 (XORHIr16 (CGTHIr16 R16C:$rA, i16ImmSExt10:$imm), 0xffff)>;
Scott Michel97872d32008-02-23 18:41:37 +00003424
Scott Michel53ab7792008-03-10 16:58:52 +00003425def : SETCCBinOpReg<setge, R32C, ORr32, CGTr32, CEQr32>;
3426def : SETCCBinOpImm<setge, R32C, i32ImmSExt10, i32,
3427 ORr32, CGTIr32, CEQIr32>;
3428def : SETCCBinOpReg<setlt, R32C, NORr32, CGTr32, CEQr32>;
3429def : SETCCBinOpImm<setlt, R32C, i32ImmSExt10, i32, NORr32, CGTIr32, CEQIr32>;
3430def : Pat<(setle R32C:$rA, R32C:$rB),
3431 (XORIr32 (CGTr32 R32C:$rA, R32C:$rB), 0xffffffff)>;
3432def : Pat<(setle R32C:$rA, i32ImmSExt10:$imm),
3433 (XORIr32 (CGTIr32 R32C:$rA, i32ImmSExt10:$imm), 0xffffffff)>;
Scott Michel97872d32008-02-23 18:41:37 +00003434
Scott Michel53ab7792008-03-10 16:58:52 +00003435def : SETCCBinOpReg<setuge, R8C, ORr8, CLGTBr8, CEQBr8>;
3436def : SETCCBinOpImm<setuge, R8C, immSExt8, i8, ORr8, CLGTBIr8, CEQBIr8>;
3437def : SETCCBinOpReg<setult, R8C, NORr8, CLGTBr8, CEQBr8>;
3438def : SETCCBinOpImm<setult, R8C, immSExt8, i8, NORr8, CLGTBIr8, CEQBIr8>;
3439def : Pat<(setule R8C:$rA, R8C:$rB),
3440 (XORBIr8 (CLGTBr8 R8C:$rA, R8C:$rB), 0xff)>;
3441def : Pat<(setule R8C:$rA, immU8:$imm),
3442 (XORBIr8 (CLGTBIr8 R8C:$rA, immU8:$imm), 0xff)>;
Scott Michel97872d32008-02-23 18:41:37 +00003443
Scott Michel53ab7792008-03-10 16:58:52 +00003444def : SETCCBinOpReg<setuge, R16C, ORr16, CLGTHr16, CEQHr16>;
3445def : SETCCBinOpImm<setuge, R16C, i16ImmSExt10, i16,
3446 ORr16, CLGTHIr16, CEQHIr16>;
3447def : SETCCBinOpReg<setult, R16C, NORr16, CLGTHr16, CEQHr16>;
3448def : SETCCBinOpImm<setult, R16C, i16ImmSExt10, i16, NORr16,
3449 CLGTHIr16, CEQHIr16>;
3450def : Pat<(setule R16C:$rA, R16C:$rB),
3451 (XORHIr16 (CLGTHr16 R16C:$rA, R16C:$rB), 0xffff)>;
Scott Michel7833d472008-03-20 00:51:36 +00003452def : Pat<(setule R16C:$rA, i16ImmSExt10:$imm),
Scott Michel53ab7792008-03-10 16:58:52 +00003453 (XORHIr16 (CLGTHIr16 R16C:$rA, i16ImmSExt10:$imm), 0xffff)>;
Scott Michel97872d32008-02-23 18:41:37 +00003454
Scott Michel53ab7792008-03-10 16:58:52 +00003455def : SETCCBinOpReg<setuge, R32C, ORr32, CLGTr32, CEQr32>;
Scott Michel7833d472008-03-20 00:51:36 +00003456def : SETCCBinOpImm<setuge, R32C, i32ImmSExt10, i32,
Scott Michel53ab7792008-03-10 16:58:52 +00003457 ORr32, CLGTIr32, CEQIr32>;
3458def : SETCCBinOpReg<setult, R32C, NORr32, CLGTr32, CEQr32>;
Scott Michel7833d472008-03-20 00:51:36 +00003459def : SETCCBinOpImm<setult, R32C, i32ImmSExt10, i32, NORr32, CLGTIr32, CEQIr32>;
Scott Michel53ab7792008-03-10 16:58:52 +00003460def : Pat<(setule R32C:$rA, R32C:$rB),
3461 (XORIr32 (CLGTr32 R32C:$rA, R32C:$rB), 0xffffffff)>;
3462def : Pat<(setule R32C:$rA, i32ImmSExt10:$imm),
3463 (XORIr32 (CLGTIr32 R32C:$rA, i32ImmSExt10:$imm), 0xffffffff)>;
Scott Michel97872d32008-02-23 18:41:37 +00003464
Scott Michel53ab7792008-03-10 16:58:52 +00003465//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
3466// select conditional patterns:
3467//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
3468
3469class SELECTNegCondReg<PatFrag cond, RegisterClass rclass, ValueType inttype,
3470 SPUInstr selinstr, SPUInstr cmpare>:
3471 Pat<(select (inttype (cond rclass:$rA, rclass:$rB)),
3472 rclass:$rTrue, rclass:$rFalse),
3473 (selinstr rclass:$rTrue, rclass:$rFalse,
Bill Wendling8f6608b2008-07-22 08:50:44 +00003474 (cmpare rclass:$rA, rclass:$rB))>;
Scott Michel53ab7792008-03-10 16:58:52 +00003475
3476class SELECTNegCondImm<PatFrag cond, RegisterClass rclass, ValueType inttype,
3477 PatLeaf immpred, SPUInstr selinstr, SPUInstr cmpare>:
3478 Pat<(select (inttype (cond rclass:$rA, immpred:$imm)),
Bill Wendling8f6608b2008-07-22 08:50:44 +00003479 rclass:$rTrue, rclass:$rFalse),
Scott Michel53ab7792008-03-10 16:58:52 +00003480 (selinstr rclass:$rTrue, rclass:$rFalse,
3481 (cmpare rclass:$rA, immpred:$imm))>;
3482
3483def : SELECTNegCondReg<setne, R8C, i8, SELBr8, CEQBr8>;
3484def : SELECTNegCondImm<setne, R8C, i8, immSExt8, SELBr8, CEQBIr8>;
3485def : SELECTNegCondReg<setle, R8C, i8, SELBr8, CGTBr8>;
3486def : SELECTNegCondImm<setle, R8C, i8, immSExt8, SELBr8, CGTBr8>;
3487def : SELECTNegCondReg<setule, R8C, i8, SELBr8, CLGTBr8>;
3488def : SELECTNegCondImm<setule, R8C, i8, immU8, SELBr8, CLGTBIr8>;
3489
3490def : SELECTNegCondReg<setne, R16C, i16, SELBr16, CEQHr16>;
3491def : SELECTNegCondImm<setne, R16C, i16, i16ImmSExt10, SELBr16, CEQHIr16>;
3492def : SELECTNegCondReg<setle, R16C, i16, SELBr16, CGTHr16>;
3493def : SELECTNegCondImm<setle, R16C, i16, i16ImmSExt10, SELBr16, CGTHIr16>;
3494def : SELECTNegCondReg<setule, R16C, i16, SELBr16, CLGTHr16>;
3495def : SELECTNegCondImm<setule, R16C, i16, i16ImmSExt10, SELBr16, CLGTHIr16>;
3496
3497def : SELECTNegCondReg<setne, R32C, i32, SELBr32, CEQr32>;
3498def : SELECTNegCondImm<setne, R32C, i32, i32ImmSExt10, SELBr32, CEQIr32>;
3499def : SELECTNegCondReg<setle, R32C, i32, SELBr32, CGTr32>;
3500def : SELECTNegCondImm<setle, R32C, i32, i32ImmSExt10, SELBr32, CGTIr32>;
3501def : SELECTNegCondReg<setule, R32C, i32, SELBr32, CLGTr32>;
3502def : SELECTNegCondImm<setule, R32C, i32, i32ImmSExt10, SELBr32, CLGTIr32>;
3503
3504class SELECTBinOpReg<PatFrag cond, RegisterClass rclass, ValueType inttype,
3505 SPUInstr selinstr, SPUInstr binop, SPUInstr cmpOp1,
3506 SPUInstr cmpOp2>:
3507 Pat<(select (inttype (cond rclass:$rA, rclass:$rB)),
Scott Michel06eabde2008-12-27 04:51:36 +00003508 rclass:$rTrue, rclass:$rFalse),
3509 (selinstr rclass:$rFalse, rclass:$rTrue,
Scott Michel53ab7792008-03-10 16:58:52 +00003510 (binop (cmpOp1 rclass:$rA, rclass:$rB),
3511 (cmpOp2 rclass:$rA, rclass:$rB)))>;
3512
3513class SELECTBinOpImm<PatFrag cond, RegisterClass rclass, PatLeaf immpred,
3514 ValueType inttype,
3515 SPUInstr selinstr, SPUInstr binop, SPUInstr cmpOp1,
3516 SPUInstr cmpOp2>:
3517 Pat<(select (inttype (cond rclass:$rA, (inttype immpred:$imm))),
Bill Wendling8f6608b2008-07-22 08:50:44 +00003518 rclass:$rTrue, rclass:$rFalse),
Scott Michel53ab7792008-03-10 16:58:52 +00003519 (selinstr rclass:$rFalse, rclass:$rTrue,
3520 (binop (cmpOp1 rclass:$rA, (inttype immpred:$imm)),
3521 (cmpOp2 rclass:$rA, (inttype immpred:$imm))))>;
3522
3523def : SELECTBinOpReg<setge, R8C, i8, SELBr8, ORr8, CGTBr8, CEQBr8>;
3524def : SELECTBinOpImm<setge, R8C, immSExt8, i8,
3525 SELBr8, ORr8, CGTBIr8, CEQBIr8>;
3526
3527def : SELECTBinOpReg<setge, R16C, i16, SELBr16, ORr16, CGTHr16, CEQHr16>;
3528def : SELECTBinOpImm<setge, R16C, i16ImmSExt10, i16,
3529 SELBr16, ORr16, CGTHIr16, CEQHIr16>;
3530
3531def : SELECTBinOpReg<setge, R32C, i32, SELBr32, ORr32, CGTr32, CEQr32>;
3532def : SELECTBinOpImm<setge, R32C, i32ImmSExt10, i32,
3533 SELBr32, ORr32, CGTIr32, CEQIr32>;
3534
3535def : SELECTBinOpReg<setuge, R8C, i8, SELBr8, ORr8, CLGTBr8, CEQBr8>;
3536def : SELECTBinOpImm<setuge, R8C, immSExt8, i8,
3537 SELBr8, ORr8, CLGTBIr8, CEQBIr8>;
3538
3539def : SELECTBinOpReg<setuge, R16C, i16, SELBr16, ORr16, CLGTHr16, CEQHr16>;
3540def : SELECTBinOpImm<setuge, R16C, i16ImmUns10, i16,
3541 SELBr16, ORr16, CLGTHIr16, CEQHIr16>;
3542
3543def : SELECTBinOpReg<setuge, R32C, i32, SELBr32, ORr32, CLGTr32, CEQr32>;
3544def : SELECTBinOpImm<setuge, R32C, i32ImmUns10, i32,
3545 SELBr32, ORr32, CLGTIr32, CEQIr32>;
Scott Michel97872d32008-02-23 18:41:37 +00003546
3547//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
Scott Michel8b6b4202007-12-04 22:35:58 +00003548
3549let isCall = 1,
3550 // All calls clobber the non-callee-saved registers:
3551 Defs = [R0, R1, R2, R3, R4, R5, R6, R7, R8, R9,
3552 R10,R11,R12,R13,R14,R15,R16,R17,R18,R19,
3553 R20,R21,R22,R23,R24,R25,R26,R27,R28,R29,
3554 R30,R31,R32,R33,R34,R35,R36,R37,R38,R39,
3555 R40,R41,R42,R43,R44,R45,R46,R47,R48,R49,
3556 R50,R51,R52,R53,R54,R55,R56,R57,R58,R59,
3557 R60,R61,R62,R63,R64,R65,R66,R67,R68,R69,
3558 R70,R71,R72,R73,R74,R75,R76,R77,R78,R79],
3559 // All of these instructions use $lr (aka $0)
3560 Uses = [R0] in {
3561 // Branch relative and set link: Used if we actually know that the target
3562 // is within [-32768, 32767] bytes of the target
3563 def BRSL:
3564 BranchSetLink<0b011001100, (outs), (ins relcalltarget:$func, variable_ops),
3565 "brsl\t$$lr, $func",
3566 [(SPUcall (SPUpcrel tglobaladdr:$func, 0))]>;
3567
3568 // Branch absolute and set link: Used if we actually know that the target
3569 // is an absolute address
3570 def BRASL:
3571 BranchSetLink<0b011001100, (outs), (ins calltarget:$func, variable_ops),
3572 "brasl\t$$lr, $func",
Scott Micheldbac4cf2008-01-11 02:53:15 +00003573 [(SPUcall (SPUaform tglobaladdr:$func, 0))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00003574
3575 // Branch indirect and set link if external data. These instructions are not
3576 // actually generated, matched by an intrinsic:
3577 def BISLED_00: BISLEDForm<0b11, "bisled\t$$lr, $func", [/* empty pattern */]>;
3578 def BISLED_E0: BISLEDForm<0b10, "bisled\t$$lr, $func", [/* empty pattern */]>;
3579 def BISLED_0D: BISLEDForm<0b01, "bisled\t$$lr, $func", [/* empty pattern */]>;
3580 def BISLED_ED: BISLEDForm<0b00, "bisled\t$$lr, $func", [/* empty pattern */]>;
3581
3582 // Branch indirect and set link. This is the "X-form" address version of a
3583 // function call
3584 def BISL:
3585 BIForm<0b10010101100, "bisl\t$$lr, $func", [(SPUcall R32C:$func)]>;
3586}
3587
Scott Michelae5cbf52008-12-29 03:23:36 +00003588// Support calls to external symbols:
3589def : Pat<(SPUcall (SPUpcrel texternalsym:$func, 0)),
3590 (BRSL texternalsym:$func)>;
3591
3592def : Pat<(SPUcall (SPUaform texternalsym:$func, 0)),
3593 (BRASL texternalsym:$func)>;
3594
Scott Michel8b6b4202007-12-04 22:35:58 +00003595// Unconditional branches:
Dan Gohman7a94dac2009-11-10 22:16:57 +00003596let isBranch = 1, isTerminator = 1, hasCtrlDep = 1 in {
3597 let isBarrier = 1 in {
3598 def BR :
3599 UncondBranch<0b001001100, (outs), (ins brtarget:$dest),
3600 "br\t$dest",
3601 [(br bb:$dest)]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00003602
Dan Gohman7a94dac2009-11-10 22:16:57 +00003603 // Unconditional, absolute address branch
3604 def BRA:
3605 UncondBranch<0b001100000, (outs), (ins brtarget:$dest),
3606 "bra\t$dest",
3607 [/* no pattern */]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00003608
Dan Gohman7a94dac2009-11-10 22:16:57 +00003609 // Indirect branch
3610 def BI:
3611 BIForm<0b00010101100, "bi\t$func", [(brind R32C:$func)]>;
3612 }
Scott Michel8b6b4202007-12-04 22:35:58 +00003613
Scott Michele0168c12009-01-05 01:34:35 +00003614 // Conditional branches:
Scott Michel06eabde2008-12-27 04:51:36 +00003615 class BRNZInst<dag IOL, list<dag> pattern>:
3616 RI16Form<0b010000100, (outs), IOL, "brnz\t$rCond,$dest",
3617 BranchResolv, pattern>;
Scott Michel8b6b4202007-12-04 22:35:58 +00003618
Scott Michel06eabde2008-12-27 04:51:36 +00003619 class BRNZRegInst<RegisterClass rclass>:
3620 BRNZInst<(ins rclass:$rCond, brtarget:$dest),
3621 [(brcond rclass:$rCond, bb:$dest)]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00003622
Scott Michel06eabde2008-12-27 04:51:36 +00003623 class BRNZVecInst<ValueType vectype>:
3624 BRNZInst<(ins VECREG:$rCond, brtarget:$dest),
3625 [(brcond (vectype VECREG:$rCond), bb:$dest)]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00003626
Scott Michel06eabde2008-12-27 04:51:36 +00003627 multiclass BranchNotZero {
3628 def v4i32 : BRNZVecInst<v4i32>;
3629 def r32 : BRNZRegInst<R32C>;
3630 }
Scott Michel8b6b4202007-12-04 22:35:58 +00003631
Scott Michel06eabde2008-12-27 04:51:36 +00003632 defm BRNZ : BranchNotZero;
3633
3634 class BRZInst<dag IOL, list<dag> pattern>:
3635 RI16Form<0b000000100, (outs), IOL, "brz\t$rT,$dest",
3636 BranchResolv, pattern>;
3637
3638 class BRZRegInst<RegisterClass rclass>:
3639 BRZInst<(ins rclass:$rT, brtarget:$dest), [/* no pattern */]>;
3640
3641 class BRZVecInst<ValueType vectype>:
3642 BRZInst<(ins VECREG:$rT, brtarget:$dest), [/* no pattern */]>;
3643
3644 multiclass BranchZero {
3645 def v4i32: BRZVecInst<v4i32>;
3646 def r32: BRZRegInst<R32C>;
3647 }
3648
3649 defm BRZ: BranchZero;
3650
3651 // Note: LLVM doesn't do branch conditional, indirect. Otherwise these would
3652 // be useful:
3653 /*
3654 class BINZInst<dag IOL, list<dag> pattern>:
3655 BICondForm<0b10010100100, (outs), IOL, "binz\t$rA, $dest", pattern>;
3656
3657 class BINZRegInst<RegisterClass rclass>:
3658 BINZInst<(ins rclass:$rA, brtarget:$dest),
3659 [(brcond rclass:$rA, R32C:$dest)]>;
3660
3661 class BINZVecInst<ValueType vectype>:
3662 BINZInst<(ins VECREG:$rA, R32C:$dest),
3663 [(brcond (vectype VECREG:$rA), R32C:$dest)]>;
3664
3665 multiclass BranchNotZeroIndirect {
3666 def v4i32: BINZVecInst<v4i32>;
3667 def r32: BINZRegInst<R32C>;
3668 }
3669
3670 defm BINZ: BranchNotZeroIndirect;
3671
3672 class BIZInst<dag IOL, list<dag> pattern>:
3673 BICondForm<0b00010100100, (outs), IOL, "biz\t$rA, $func", pattern>;
3674
3675 class BIZRegInst<RegisterClass rclass>:
3676 BIZInst<(ins rclass:$rA, R32C:$func), [/* no pattern */]>;
3677
3678 class BIZVecInst<ValueType vectype>:
3679 BIZInst<(ins VECREG:$rA, R32C:$func), [/* no pattern */]>;
3680
3681 multiclass BranchZeroIndirect {
3682 def v4i32: BIZVecInst<v4i32>;
3683 def r32: BIZRegInst<R32C>;
3684 }
3685
3686 defm BIZ: BranchZeroIndirect;
3687 */
3688
3689 class BRHNZInst<dag IOL, list<dag> pattern>:
3690 RI16Form<0b011000100, (outs), IOL, "brhnz\t$rCond,$dest", BranchResolv,
3691 pattern>;
3692
3693 class BRHNZRegInst<RegisterClass rclass>:
3694 BRHNZInst<(ins rclass:$rCond, brtarget:$dest),
3695 [(brcond rclass:$rCond, bb:$dest)]>;
3696
3697 class BRHNZVecInst<ValueType vectype>:
3698 BRHNZInst<(ins VECREG:$rCond, brtarget:$dest), [/* no pattern */]>;
3699
3700 multiclass BranchNotZeroHalfword {
3701 def v8i16: BRHNZVecInst<v8i16>;
3702 def r16: BRHNZRegInst<R16C>;
3703 }
3704
3705 defm BRHNZ: BranchNotZeroHalfword;
3706
3707 class BRHZInst<dag IOL, list<dag> pattern>:
3708 RI16Form<0b001000100, (outs), IOL, "brhz\t$rT,$dest", BranchResolv,
3709 pattern>;
3710
3711 class BRHZRegInst<RegisterClass rclass>:
3712 BRHZInst<(ins rclass:$rT, brtarget:$dest), [/* no pattern */]>;
3713
3714 class BRHZVecInst<ValueType vectype>:
3715 BRHZInst<(ins VECREG:$rT, brtarget:$dest), [/* no pattern */]>;
3716
3717 multiclass BranchZeroHalfword {
3718 def v8i16: BRHZVecInst<v8i16>;
3719 def r16: BRHZRegInst<R16C>;
3720 }
3721
3722 defm BRHZ: BranchZeroHalfword;
Scott Michel8b6b4202007-12-04 22:35:58 +00003723}
3724
Scott Michel394e26d2008-01-17 20:38:41 +00003725//===----------------------------------------------------------------------===//
Scott Michelf9f42e62008-01-29 02:16:57 +00003726// setcc and brcond patterns:
Scott Michel394e26d2008-01-17 20:38:41 +00003727//===----------------------------------------------------------------------===//
Scott Michelf9f42e62008-01-29 02:16:57 +00003728
Scott Michel06eabde2008-12-27 04:51:36 +00003729def : Pat<(brcond (i16 (seteq R16C:$rA, 0)), bb:$dest),
3730 (BRHZr16 R16C:$rA, bb:$dest)>;
3731def : Pat<(brcond (i16 (setne R16C:$rA, 0)), bb:$dest),
3732 (BRHNZr16 R16C:$rA, bb:$dest)>;
Scott Michel97872d32008-02-23 18:41:37 +00003733
Scott Michel06eabde2008-12-27 04:51:36 +00003734def : Pat<(brcond (i32 (seteq R32C:$rA, 0)), bb:$dest),
3735 (BRZr32 R32C:$rA, bb:$dest)>;
3736def : Pat<(brcond (i32 (setne R32C:$rA, 0)), bb:$dest),
3737 (BRNZr32 R32C:$rA, bb:$dest)>;
Scott Michel8b6b4202007-12-04 22:35:58 +00003738
Scott Michel97872d32008-02-23 18:41:37 +00003739multiclass BranchCondEQ<PatFrag cond, SPUInstr brinst16, SPUInstr brinst32>
3740{
3741 def r16imm: Pat<(brcond (i16 (cond R16C:$rA, i16ImmSExt10:$val)), bb:$dest),
3742 (brinst16 (CEQHIr16 R16C:$rA, i16ImmSExt10:$val), bb:$dest)>;
Scott Michelf9f42e62008-01-29 02:16:57 +00003743
Scott Michel97872d32008-02-23 18:41:37 +00003744 def r16 : Pat<(brcond (i16 (cond R16C:$rA, R16C:$rB)), bb:$dest),
3745 (brinst16 (CEQHr16 R16C:$rA, R16:$rB), bb:$dest)>;
3746
3747 def r32imm : Pat<(brcond (i32 (cond R32C:$rA, i32ImmSExt10:$val)), bb:$dest),
3748 (brinst32 (CEQIr32 R32C:$rA, i32ImmSExt10:$val), bb:$dest)>;
3749
3750 def r32 : Pat<(brcond (i32 (cond R32C:$rA, R32C:$rB)), bb:$dest),
3751 (brinst32 (CEQr32 R32C:$rA, R32C:$rB), bb:$dest)>;
3752}
3753
Scott Michele0168c12009-01-05 01:34:35 +00003754defm BRCONDeq : BranchCondEQ<seteq, BRHNZr16, BRNZr32>;
3755defm BRCONDne : BranchCondEQ<setne, BRHZr16, BRZr32>;
Scott Michel97872d32008-02-23 18:41:37 +00003756
3757multiclass BranchCondLGT<PatFrag cond, SPUInstr brinst16, SPUInstr brinst32>
3758{
3759 def r16imm : Pat<(brcond (i16 (cond R16C:$rA, i16ImmSExt10:$val)), bb:$dest),
3760 (brinst16 (CLGTHIr16 R16C:$rA, i16ImmSExt10:$val), bb:$dest)>;
3761
3762 def r16 : Pat<(brcond (i16 (cond R16C:$rA, R16C:$rB)), bb:$dest),
3763 (brinst16 (CLGTHr16 R16C:$rA, R16:$rB), bb:$dest)>;
3764
3765 def r32imm : Pat<(brcond (i32 (cond R32C:$rA, i32ImmSExt10:$val)), bb:$dest),
3766 (brinst32 (CLGTIr32 R32C:$rA, i32ImmSExt10:$val), bb:$dest)>;
3767
3768 def r32 : Pat<(brcond (i32 (cond R32C:$rA, R32C:$rB)), bb:$dest),
3769 (brinst32 (CLGTr32 R32C:$rA, R32C:$rB), bb:$dest)>;
3770}
3771
Scott Michel06eabde2008-12-27 04:51:36 +00003772defm BRCONDugt : BranchCondLGT<setugt, BRHNZr16, BRNZr32>;
3773defm BRCONDule : BranchCondLGT<setule, BRHZr16, BRZr32>;
Scott Michel97872d32008-02-23 18:41:37 +00003774
3775multiclass BranchCondLGTEQ<PatFrag cond, SPUInstr orinst16, SPUInstr brinst16,
3776 SPUInstr orinst32, SPUInstr brinst32>
3777{
3778 def r16imm: Pat<(brcond (i16 (cond R16C:$rA, i16ImmSExt10:$val)), bb:$dest),
3779 (brinst16 (orinst16 (CLGTHIr16 R16C:$rA, i16ImmSExt10:$val),
3780 (CEQHIr16 R16C:$rA, i16ImmSExt10:$val)),
3781 bb:$dest)>;
3782
3783 def r16: Pat<(brcond (i16 (cond R16C:$rA, R16C:$rB)), bb:$dest),
3784 (brinst16 (orinst16 (CLGTHr16 R16C:$rA, R16:$rB),
3785 (CEQHr16 R16C:$rA, R16:$rB)),
3786 bb:$dest)>;
3787
3788 def r32imm : Pat<(brcond (i32 (cond R32C:$rA, i32ImmSExt10:$val)), bb:$dest),
3789 (brinst32 (orinst32 (CLGTIr32 R32C:$rA, i32ImmSExt10:$val),
3790 (CEQIr32 R32C:$rA, i32ImmSExt10:$val)),
3791 bb:$dest)>;
3792
3793 def r32 : Pat<(brcond (i32 (cond R32C:$rA, R32C:$rB)), bb:$dest),
3794 (brinst32 (orinst32 (CLGTr32 R32C:$rA, R32C:$rB),
3795 (CEQr32 R32C:$rA, R32C:$rB)),
3796 bb:$dest)>;
3797}
3798
Scott Michel06eabde2008-12-27 04:51:36 +00003799defm BRCONDuge : BranchCondLGTEQ<setuge, ORr16, BRHNZr16, ORr32, BRNZr32>;
3800defm BRCONDult : BranchCondLGTEQ<setult, ORr16, BRHZr16, ORr32, BRZr32>;
Scott Michel97872d32008-02-23 18:41:37 +00003801
3802multiclass BranchCondGT<PatFrag cond, SPUInstr brinst16, SPUInstr brinst32>
3803{
3804 def r16imm : Pat<(brcond (i16 (cond R16C:$rA, i16ImmSExt10:$val)), bb:$dest),
3805 (brinst16 (CGTHIr16 R16C:$rA, i16ImmSExt10:$val), bb:$dest)>;
3806
3807 def r16 : Pat<(brcond (i16 (cond R16C:$rA, R16C:$rB)), bb:$dest),
3808 (brinst16 (CGTHr16 R16C:$rA, R16:$rB), bb:$dest)>;
3809
3810 def r32imm : Pat<(brcond (i32 (cond R32C:$rA, i32ImmSExt10:$val)), bb:$dest),
3811 (brinst32 (CGTIr32 R32C:$rA, i32ImmSExt10:$val), bb:$dest)>;
3812
3813 def r32 : Pat<(brcond (i32 (cond R32C:$rA, R32C:$rB)), bb:$dest),
3814 (brinst32 (CGTr32 R32C:$rA, R32C:$rB), bb:$dest)>;
3815}
3816
Scott Michel06eabde2008-12-27 04:51:36 +00003817defm BRCONDgt : BranchCondGT<setgt, BRHNZr16, BRNZr32>;
3818defm BRCONDle : BranchCondGT<setle, BRHZr16, BRZr32>;
Scott Michel97872d32008-02-23 18:41:37 +00003819
3820multiclass BranchCondGTEQ<PatFrag cond, SPUInstr orinst16, SPUInstr brinst16,
3821 SPUInstr orinst32, SPUInstr brinst32>
3822{
3823 def r16imm: Pat<(brcond (i16 (cond R16C:$rA, i16ImmSExt10:$val)), bb:$dest),
3824 (brinst16 (orinst16 (CGTHIr16 R16C:$rA, i16ImmSExt10:$val),
3825 (CEQHIr16 R16C:$rA, i16ImmSExt10:$val)),
3826 bb:$dest)>;
3827
3828 def r16: Pat<(brcond (i16 (cond R16C:$rA, R16C:$rB)), bb:$dest),
3829 (brinst16 (orinst16 (CGTHr16 R16C:$rA, R16:$rB),
3830 (CEQHr16 R16C:$rA, R16:$rB)),
3831 bb:$dest)>;
3832
3833 def r32imm : Pat<(brcond (i32 (cond R32C:$rA, i32ImmSExt10:$val)), bb:$dest),
3834 (brinst32 (orinst32 (CGTIr32 R32C:$rA, i32ImmSExt10:$val),
3835 (CEQIr32 R32C:$rA, i32ImmSExt10:$val)),
3836 bb:$dest)>;
3837
3838 def r32 : Pat<(brcond (i32 (cond R32C:$rA, R32C:$rB)), bb:$dest),
3839 (brinst32 (orinst32 (CGTr32 R32C:$rA, R32C:$rB),
3840 (CEQr32 R32C:$rA, R32C:$rB)),
3841 bb:$dest)>;
3842}
3843
Scott Michel06eabde2008-12-27 04:51:36 +00003844defm BRCONDge : BranchCondGTEQ<setge, ORr16, BRHNZr16, ORr32, BRNZr32>;
3845defm BRCONDlt : BranchCondGTEQ<setlt, ORr16, BRHZr16, ORr32, BRZr32>;
Scott Michelf9f42e62008-01-29 02:16:57 +00003846
Scott Michel8b6b4202007-12-04 22:35:58 +00003847let isTerminator = 1, isBarrier = 1 in {
3848 let isReturn = 1 in {
3849 def RET:
3850 RETForm<"bi\t$$lr", [(retflag)]>;
3851 }
3852}
3853
3854//===----------------------------------------------------------------------===//
Scott Michel8b6b4202007-12-04 22:35:58 +00003855// Single precision floating point instructions
3856//===----------------------------------------------------------------------===//
3857
Scott Michel61895fe2008-12-10 00:15:19 +00003858class FAInst<dag OOL, dag IOL, list<dag> pattern>:
3859 RRForm<0b01011000100, OOL, IOL, "fa\t$rT, $rA, $rB",
Scott Michel4d07fb72008-12-30 23:28:25 +00003860 SPrecFP, pattern>;
Scott Michel06eabde2008-12-27 04:51:36 +00003861
Scott Michel61895fe2008-12-10 00:15:19 +00003862class FAVecInst<ValueType vectype>:
3863 FAInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
3864 [(set (vectype VECREG:$rT),
Scott Michel4d07fb72008-12-30 23:28:25 +00003865 (fadd (vectype VECREG:$rA), (vectype VECREG:$rB)))]>;
Scott Michel06eabde2008-12-27 04:51:36 +00003866
Scott Michel61895fe2008-12-10 00:15:19 +00003867multiclass SFPAdd
3868{
3869 def v4f32: FAVecInst<v4f32>;
Scott Michel4d07fb72008-12-30 23:28:25 +00003870 def f32: FAInst<(outs R32FP:$rT), (ins R32FP:$rA, R32FP:$rB),
3871 [(set R32FP:$rT, (fadd R32FP:$rA, R32FP:$rB))]>;
Scott Michel61895fe2008-12-10 00:15:19 +00003872}
Scott Michel8b6b4202007-12-04 22:35:58 +00003873
Scott Michel61895fe2008-12-10 00:15:19 +00003874defm FA : SFPAdd;
Scott Michel8b6b4202007-12-04 22:35:58 +00003875
Scott Michel61895fe2008-12-10 00:15:19 +00003876class FSInst<dag OOL, dag IOL, list<dag> pattern>:
3877 RRForm<0b01011000100, OOL, IOL, "fs\t$rT, $rA, $rB",
Scott Michel4d07fb72008-12-30 23:28:25 +00003878 SPrecFP, pattern>;
Scott Michel8b6b4202007-12-04 22:35:58 +00003879
Scott Michel61895fe2008-12-10 00:15:19 +00003880class FSVecInst<ValueType vectype>:
3881 FSInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
Scott Michel4d07fb72008-12-30 23:28:25 +00003882 [(set (vectype VECREG:$rT),
3883 (fsub (vectype VECREG:$rA), (vectype VECREG:$rB)))]>;
Scott Michel61895fe2008-12-10 00:15:19 +00003884
3885multiclass SFPSub
3886{
3887 def v4f32: FSVecInst<v4f32>;
Scott Michel4d07fb72008-12-30 23:28:25 +00003888 def f32: FSInst<(outs R32FP:$rT), (ins R32FP:$rA, R32FP:$rB),
3889 [(set R32FP:$rT, (fsub R32FP:$rA, R32FP:$rB))]>;
Scott Michel61895fe2008-12-10 00:15:19 +00003890}
3891
3892defm FS : SFPSub;
Scott Michel8b6b4202007-12-04 22:35:58 +00003893
3894// Floating point reciprocal estimate
Scott Michel8b6b4202007-12-04 22:35:58 +00003895
Scott Michel4d07fb72008-12-30 23:28:25 +00003896class FRESTInst<dag OOL, dag IOL>:
3897 RRForm_1<0b00110111000, OOL, IOL,
3898 "frest\t$rT, $rA", SPrecFP,
3899 [/* no pattern */]>;
3900
3901def FRESTv4f32 :
3902 FRESTInst<(outs VECREG:$rT), (ins VECREG:$rA)>;
3903
3904def FRESTf32 :
3905 FRESTInst<(outs R32FP:$rT), (ins R32FP:$rA)>;
Scott Michel8b6b4202007-12-04 22:35:58 +00003906
3907// Floating point interpolate (used in conjunction with reciprocal estimate)
3908def FIv4f32 :
3909 RRForm<0b00101011110, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
3910 "fi\t$rT, $rA, $rB", SPrecFP,
Scott Michel4d07fb72008-12-30 23:28:25 +00003911 [/* no pattern */]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00003912
3913def FIf32 :
3914 RRForm<0b00101011110, (outs R32FP:$rT), (ins R32FP:$rA, R32FP:$rB),
3915 "fi\t$rT, $rA, $rB", SPrecFP,
Scott Michel4d07fb72008-12-30 23:28:25 +00003916 [/* no pattern */]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00003917
Scott Michel33d73eb2008-11-21 02:56:16 +00003918//--------------------------------------------------------------------------
3919// Basic single precision floating point comparisons:
3920//
3921// Note: There is no support on SPU for single precision NaN. Consequently,
3922// ordered and unordered comparisons are the same.
3923//--------------------------------------------------------------------------
3924
Scott Michel8b6b4202007-12-04 22:35:58 +00003925def FCEQf32 :
3926 RRForm<0b01000011110, (outs R32C:$rT), (ins R32FP:$rA, R32FP:$rB),
3927 "fceq\t$rT, $rA, $rB", SPrecFP,
Scott Michel33d73eb2008-11-21 02:56:16 +00003928 [(set R32C:$rT, (setueq R32FP:$rA, R32FP:$rB))]>;
3929
3930def : Pat<(setoeq R32FP:$rA, R32FP:$rB),
3931 (FCEQf32 R32FP:$rA, R32FP:$rB)>;
Scott Michel8b6b4202007-12-04 22:35:58 +00003932
3933def FCMEQf32 :
3934 RRForm<0b01010011110, (outs R32C:$rT), (ins R32FP:$rA, R32FP:$rB),
3935 "fcmeq\t$rT, $rA, $rB", SPrecFP,
Scott Michel33d73eb2008-11-21 02:56:16 +00003936 [(set R32C:$rT, (setueq (fabs R32FP:$rA), (fabs R32FP:$rB)))]>;
3937
3938def : Pat<(setoeq (fabs R32FP:$rA), (fabs R32FP:$rB)),
3939 (FCMEQf32 R32FP:$rA, R32FP:$rB)>;
Scott Michel8b6b4202007-12-04 22:35:58 +00003940
3941def FCGTf32 :
3942 RRForm<0b01000011010, (outs R32C:$rT), (ins R32FP:$rA, R32FP:$rB),
3943 "fcgt\t$rT, $rA, $rB", SPrecFP,
Scott Michel33d73eb2008-11-21 02:56:16 +00003944 [(set R32C:$rT, (setugt R32FP:$rA, R32FP:$rB))]>;
3945
3946def : Pat<(setugt R32FP:$rA, R32FP:$rB),
3947 (FCGTf32 R32FP:$rA, R32FP:$rB)>;
Scott Michel8b6b4202007-12-04 22:35:58 +00003948
3949def FCMGTf32 :
3950 RRForm<0b01010011010, (outs R32C:$rT), (ins R32FP:$rA, R32FP:$rB),
3951 "fcmgt\t$rT, $rA, $rB", SPrecFP,
Scott Michel33d73eb2008-11-21 02:56:16 +00003952 [(set R32C:$rT, (setugt (fabs R32FP:$rA), (fabs R32FP:$rB)))]>;
3953
3954def : Pat<(setugt (fabs R32FP:$rA), (fabs R32FP:$rB)),
3955 (FCMGTf32 R32FP:$rA, R32FP:$rB)>;
3956
3957//--------------------------------------------------------------------------
3958// Single precision floating point comparisons and SETCC equivalents:
3959//--------------------------------------------------------------------------
3960
3961def : SETCCNegCondReg<setune, R32FP, i32, XORIr32, FCEQf32>;
3962def : SETCCNegCondReg<setone, R32FP, i32, XORIr32, FCEQf32>;
3963
3964def : SETCCBinOpReg<setuge, R32FP, ORr32, FCGTf32, FCEQf32>;
3965def : SETCCBinOpReg<setoge, R32FP, ORr32, FCGTf32, FCEQf32>;
3966
3967def : SETCCBinOpReg<setult, R32FP, NORr32, FCGTf32, FCEQf32>;
3968def : SETCCBinOpReg<setolt, R32FP, NORr32, FCGTf32, FCEQf32>;
3969
3970def : Pat<(setule R32FP:$rA, R32FP:$rB),
3971 (XORIr32 (FCGTf32 R32FP:$rA, R32FP:$rB), 0xffffffff)>;
3972def : Pat<(setole R32FP:$rA, R32FP:$rB),
3973 (XORIr32 (FCGTf32 R32FP:$rA, R32FP:$rB), 0xffffffff)>;
Scott Michel8b6b4202007-12-04 22:35:58 +00003974
3975// FP Status and Control Register Write
3976// Why isn't rT a don't care in the ISA?
3977// Should we create a special RRForm_3 for this guy and zero out the rT?
3978def FSCRWf32 :
3979 RRForm_1<0b01011101110, (outs R32FP:$rT), (ins R32FP:$rA),
3980 "fscrwr\t$rA", SPrecFP,
3981 [/* This instruction requires an intrinsic. Note: rT is unused. */]>;
3982
3983// FP Status and Control Register Read
3984def FSCRRf32 :
3985 RRForm_2<0b01011101110, (outs R32FP:$rT), (ins),
3986 "fscrrd\t$rT", SPrecFP,
3987 [/* This instruction requires an intrinsic */]>;
3988
3989// llvm instruction space
3990// How do these map onto cell instructions?
3991// fdiv rA rB
3992// frest rC rB # c = 1/b (both lines)
3993// fi rC rB rC
3994// fm rD rA rC # d = a * 1/b
3995// fnms rB rD rB rA # b = - (d * b - a) --should == 0 in a perfect world
3996// fma rB rB rC rD # b = b * c + d
3997// = -(d *b -a) * c + d
3998// = a * c - c ( a *b *c - a)
3999
4000// fcopysign (???)
4001
4002// Library calls:
4003// These llvm instructions will actually map to library calls.
4004// All that's needed, then, is to check that the appropriate library is
4005// imported and do a brsl to the proper function name.
4006// frem # fmod(x, y): x - (x/y) * y
4007// (Note: fmod(double, double), fmodf(float,float)
4008// fsqrt?
4009// fsin?
4010// fcos?
4011// Unimplemented SPU instruction space
4012// floating reciprocal absolute square root estimate (frsqest)
4013
4014// The following are probably just intrinsics
Scott Michel06eabde2008-12-27 04:51:36 +00004015// status and control register write
Scott Michel8b6b4202007-12-04 22:35:58 +00004016// status and control register read
4017
4018//--------------------------------------
4019// Floating point multiply instructions
4020//--------------------------------------
4021
4022def FMv4f32:
4023 RRForm<0b00100011010, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
4024 "fm\t$rT, $rA, $rB", SPrecFP,
4025 [(set (v4f32 VECREG:$rT), (fmul (v4f32 VECREG:$rA),
4026 (v4f32 VECREG:$rB)))]>;
4027
4028def FMf32 :
4029 RRForm<0b01100011010, (outs R32FP:$rT), (ins R32FP:$rA, R32FP:$rB),
4030 "fm\t$rT, $rA, $rB", SPrecFP,
4031 [(set R32FP:$rT, (fmul R32FP:$rA, R32FP:$rB))]>;
4032
4033// Floating point multiply and add
4034// e.g. d = c + (a * b)
4035def FMAv4f32:
4036 RRRForm<0b0111, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB, VECREG:$rC),
4037 "fma\t$rT, $rA, $rB, $rC", SPrecFP,
4038 [(set (v4f32 VECREG:$rT),
4039 (fadd (v4f32 VECREG:$rC),
4040 (fmul (v4f32 VECREG:$rA), (v4f32 VECREG:$rB))))]>;
4041
4042def FMAf32:
4043 RRRForm<0b0111, (outs R32FP:$rT), (ins R32FP:$rA, R32FP:$rB, R32FP:$rC),
4044 "fma\t$rT, $rA, $rB, $rC", SPrecFP,
4045 [(set R32FP:$rT, (fadd R32FP:$rC, (fmul R32FP:$rA, R32FP:$rB)))]>;
4046
4047// FP multiply and subtract
4048// Subtracts value in rC from product
4049// res = a * b - c
4050def FMSv4f32 :
4051 RRRForm<0b0111, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB, VECREG:$rC),
4052 "fms\t$rT, $rA, $rB, $rC", SPrecFP,
4053 [(set (v4f32 VECREG:$rT),
4054 (fsub (fmul (v4f32 VECREG:$rA), (v4f32 VECREG:$rB)),
4055 (v4f32 VECREG:$rC)))]>;
4056
4057def FMSf32 :
4058 RRRForm<0b0111, (outs R32FP:$rT), (ins R32FP:$rA, R32FP:$rB, R32FP:$rC),
4059 "fms\t$rT, $rA, $rB, $rC", SPrecFP,
4060 [(set R32FP:$rT,
4061 (fsub (fmul R32FP:$rA, R32FP:$rB), R32FP:$rC))]>;
4062
4063// Floating Negative Mulitply and Subtract
4064// Subtracts product from value in rC
4065// res = fneg(fms a b c)
4066// = - (a * b - c)
4067// = c - a * b
4068// NOTE: subtraction order
4069// fsub a b = a - b
Scott Michel06eabde2008-12-27 04:51:36 +00004070// fs a b = b - a?
Scott Michel8b6b4202007-12-04 22:35:58 +00004071def FNMSf32 :
4072 RRRForm<0b1101, (outs R32FP:$rT), (ins R32FP:$rA, R32FP:$rB, R32FP:$rC),
4073 "fnms\t$rT, $rA, $rB, $rC", SPrecFP,
4074 [(set R32FP:$rT, (fsub R32FP:$rC, (fmul R32FP:$rA, R32FP:$rB)))]>;
4075
4076def FNMSv4f32 :
4077 RRRForm<0b1101, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB, VECREG:$rC),
4078 "fnms\t$rT, $rA, $rB, $rC", SPrecFP,
Scott Michel06eabde2008-12-27 04:51:36 +00004079 [(set (v4f32 VECREG:$rT),
4080 (fsub (v4f32 VECREG:$rC),
4081 (fmul (v4f32 VECREG:$rA),
Scott Michel8b6b4202007-12-04 22:35:58 +00004082 (v4f32 VECREG:$rB))))]>;
4083
4084//--------------------------------------
4085// Floating Point Conversions
4086// Signed conversions:
4087def CSiFv4f32:
4088 CVTIntFPForm<0b0101101110, (outs VECREG:$rT), (ins VECREG:$rA),
4089 "csflt\t$rT, $rA, 0", SPrecFP,
4090 [(set (v4f32 VECREG:$rT), (sint_to_fp (v4i32 VECREG:$rA)))]>;
4091
Scott Michel06eabde2008-12-27 04:51:36 +00004092// Convert signed integer to floating point
Scott Michel8b6b4202007-12-04 22:35:58 +00004093def CSiFf32 :
4094 CVTIntFPForm<0b0101101110, (outs R32FP:$rT), (ins R32C:$rA),
4095 "csflt\t$rT, $rA, 0", SPrecFP,
4096 [(set R32FP:$rT, (sint_to_fp R32C:$rA))]>;
4097
4098// Convert unsigned into to float
4099def CUiFv4f32 :
4100 CVTIntFPForm<0b1101101110, (outs VECREG:$rT), (ins VECREG:$rA),
4101 "cuflt\t$rT, $rA, 0", SPrecFP,
4102 [(set (v4f32 VECREG:$rT), (uint_to_fp (v4i32 VECREG:$rA)))]>;
4103
4104def CUiFf32 :
4105 CVTIntFPForm<0b1101101110, (outs R32FP:$rT), (ins R32C:$rA),
4106 "cuflt\t$rT, $rA, 0", SPrecFP,
4107 [(set R32FP:$rT, (uint_to_fp R32C:$rA))]>;
4108
Scott Michel06eabde2008-12-27 04:51:36 +00004109// Convert float to unsigned int
Scott Michel8b6b4202007-12-04 22:35:58 +00004110// Assume that scale = 0
4111
4112def CFUiv4f32 :
4113 CVTIntFPForm<0b1101101110, (outs VECREG:$rT), (ins VECREG:$rA),
4114 "cfltu\t$rT, $rA, 0", SPrecFP,
4115 [(set (v4i32 VECREG:$rT), (fp_to_uint (v4f32 VECREG:$rA)))]>;
4116
4117def CFUif32 :
4118 CVTIntFPForm<0b1101101110, (outs R32C:$rT), (ins R32FP:$rA),
4119 "cfltu\t$rT, $rA, 0", SPrecFP,
4120 [(set R32C:$rT, (fp_to_uint R32FP:$rA))]>;
4121
Scott Michel06eabde2008-12-27 04:51:36 +00004122// Convert float to signed int
Scott Michel8b6b4202007-12-04 22:35:58 +00004123// Assume that scale = 0
4124
4125def CFSiv4f32 :
4126 CVTIntFPForm<0b1101101110, (outs VECREG:$rT), (ins VECREG:$rA),
4127 "cflts\t$rT, $rA, 0", SPrecFP,
4128 [(set (v4i32 VECREG:$rT), (fp_to_sint (v4f32 VECREG:$rA)))]>;
4129
4130def CFSif32 :
4131 CVTIntFPForm<0b1101101110, (outs R32C:$rT), (ins R32FP:$rA),
4132 "cflts\t$rT, $rA, 0", SPrecFP,
4133 [(set R32C:$rT, (fp_to_sint R32FP:$rA))]>;
4134
4135//===----------------------------------------------------------------------==//
4136// Single<->Double precision conversions
4137//===----------------------------------------------------------------------==//
4138
4139// NOTE: We use "vec" name suffix here to avoid confusion (e.g. input is a
4140// v4f32, output is v2f64--which goes in the name?)
4141
4142// Floating point extend single to double
4143// NOTE: Not sure if passing in v4f32 to FESDvec is correct since it
4144// operates on two double-word slots (i.e. 1st and 3rd fp numbers
4145// are ignored).
4146def FESDvec :
4147 RRForm_1<0b00011101110, (outs VECREG:$rT), (ins VECREG:$rA),
4148 "fesd\t$rT, $rA", SPrecFP,
4149 [(set (v2f64 VECREG:$rT), (fextend (v4f32 VECREG:$rA)))]>;
4150
4151def FESDf32 :
4152 RRForm_1<0b00011101110, (outs R64FP:$rT), (ins R32FP:$rA),
4153 "fesd\t$rT, $rA", SPrecFP,
4154 [(set R64FP:$rT, (fextend R32FP:$rA))]>;
4155
4156// Floating point round double to single
4157//def FRDSvec :
4158// RRForm_1<0b10011101110, (outs VECREG:$rT), (ins VECREG:$rA),
4159// "frds\t$rT, $rA,", SPrecFP,
4160// [(set (v4f32 R32FP:$rT), (fround (v2f64 R64FP:$rA)))]>;
4161
4162def FRDSf64 :
4163 RRForm_1<0b10011101110, (outs R32FP:$rT), (ins R64FP:$rA),
4164 "frds\t$rT, $rA", SPrecFP,
4165 [(set R32FP:$rT, (fround R64FP:$rA))]>;
4166
4167//ToDo include anyextend?
4168
4169//===----------------------------------------------------------------------==//
4170// Double precision floating point instructions
4171//===----------------------------------------------------------------------==//
4172def FAf64 :
4173 RRForm<0b00110011010, (outs R64FP:$rT), (ins R64FP:$rA, R64FP:$rB),
4174 "dfa\t$rT, $rA, $rB", DPrecFP,
4175 [(set R64FP:$rT, (fadd R64FP:$rA, R64FP:$rB))]>;
4176
4177def FAv2f64 :
4178 RRForm<0b00110011010, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
4179 "dfa\t$rT, $rA, $rB", DPrecFP,
4180 [(set (v2f64 VECREG:$rT), (fadd (v2f64 VECREG:$rA), (v2f64 VECREG:$rB)))]>;
4181
4182def FSf64 :
4183 RRForm<0b10100011010, (outs R64FP:$rT), (ins R64FP:$rA, R64FP:$rB),
4184 "dfs\t$rT, $rA, $rB", DPrecFP,
4185 [(set R64FP:$rT, (fsub R64FP:$rA, R64FP:$rB))]>;
4186
4187def FSv2f64 :
4188 RRForm<0b10100011010, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
4189 "dfs\t$rT, $rA, $rB", DPrecFP,
4190 [(set (v2f64 VECREG:$rT),
4191 (fsub (v2f64 VECREG:$rA), (v2f64 VECREG:$rB)))]>;
4192
4193def FMf64 :
4194 RRForm<0b01100011010, (outs R64FP:$rT), (ins R64FP:$rA, R64FP:$rB),
4195 "dfm\t$rT, $rA, $rB", DPrecFP,
4196 [(set R64FP:$rT, (fmul R64FP:$rA, R64FP:$rB))]>;
4197
4198def FMv2f64:
4199 RRForm<0b00100011010, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
4200 "dfm\t$rT, $rA, $rB", DPrecFP,
4201 [(set (v2f64 VECREG:$rT),
4202 (fmul (v2f64 VECREG:$rA), (v2f64 VECREG:$rB)))]>;
4203
4204def FMAf64:
4205 RRForm<0b00111010110, (outs R64FP:$rT),
4206 (ins R64FP:$rA, R64FP:$rB, R64FP:$rC),
4207 "dfma\t$rT, $rA, $rB", DPrecFP,
4208 [(set R64FP:$rT, (fadd R64FP:$rC, (fmul R64FP:$rA, R64FP:$rB)))]>,
4209 RegConstraint<"$rC = $rT">,
4210 NoEncode<"$rC">;
4211
4212def FMAv2f64:
4213 RRForm<0b00111010110, (outs VECREG:$rT),
4214 (ins VECREG:$rA, VECREG:$rB, VECREG:$rC),
4215 "dfma\t$rT, $rA, $rB", DPrecFP,
4216 [(set (v2f64 VECREG:$rT),
4217 (fadd (v2f64 VECREG:$rC),
4218 (fmul (v2f64 VECREG:$rA), (v2f64 VECREG:$rB))))]>,
4219 RegConstraint<"$rC = $rT">,
4220 NoEncode<"$rC">;
4221
4222def FMSf64 :
4223 RRForm<0b10111010110, (outs R64FP:$rT),
4224 (ins R64FP:$rA, R64FP:$rB, R64FP:$rC),
4225 "dfms\t$rT, $rA, $rB", DPrecFP,
4226 [(set R64FP:$rT, (fsub (fmul R64FP:$rA, R64FP:$rB), R64FP:$rC))]>,
4227 RegConstraint<"$rC = $rT">,
4228 NoEncode<"$rC">;
4229
4230def FMSv2f64 :
4231 RRForm<0b10111010110, (outs VECREG:$rT),
4232 (ins VECREG:$rA, VECREG:$rB, VECREG:$rC),
4233 "dfms\t$rT, $rA, $rB", DPrecFP,
4234 [(set (v2f64 VECREG:$rT),
4235 (fsub (fmul (v2f64 VECREG:$rA), (v2f64 VECREG:$rB)),
4236 (v2f64 VECREG:$rC)))]>;
4237
Scott Michel0d5eae02009-03-17 01:15:45 +00004238// DFNMS: - (a * b - c)
Scott Michel8b6b4202007-12-04 22:35:58 +00004239// - (a * b) + c => c - (a * b)
Scott Michel0d5eae02009-03-17 01:15:45 +00004240
4241class DFNMSInst<dag OOL, dag IOL, list<dag> pattern>:
4242 RRForm<0b01111010110, OOL, IOL, "dfnms\t$rT, $rA, $rB",
4243 DPrecFP, pattern>,
Scott Michel8b6b4202007-12-04 22:35:58 +00004244 RegConstraint<"$rC = $rT">,
4245 NoEncode<"$rC">;
4246
Scott Michel0d5eae02009-03-17 01:15:45 +00004247class DFNMSVecInst<list<dag> pattern>:
4248 DFNMSInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB, VECREG:$rC),
4249 pattern>;
Scott Michel8b6b4202007-12-04 22:35:58 +00004250
Scott Michel0d5eae02009-03-17 01:15:45 +00004251class DFNMSRegInst<list<dag> pattern>:
4252 DFNMSInst<(outs R64FP:$rT), (ins R64FP:$rA, R64FP:$rB, R64FP:$rC),
4253 pattern>;
Scott Michel8b6b4202007-12-04 22:35:58 +00004254
Scott Michel0d5eae02009-03-17 01:15:45 +00004255multiclass DFMultiplySubtract
4256{
4257 def v2f64 : DFNMSVecInst<[(set (v2f64 VECREG:$rT),
4258 (fsub (v2f64 VECREG:$rC),
4259 (fmul (v2f64 VECREG:$rA),
4260 (v2f64 VECREG:$rB))))]>;
4261
4262 def f64 : DFNMSRegInst<[(set R64FP:$rT,
4263 (fsub R64FP:$rC,
4264 (fmul R64FP:$rA, R64FP:$rB)))]>;
4265}
4266
4267defm DFNMS : DFMultiplySubtract;
Scott Michel8b6b4202007-12-04 22:35:58 +00004268
4269// - (a * b + c)
4270// - (a * b) - c
4271def FNMAf64 :
4272 RRForm<0b11111010110, (outs R64FP:$rT),
4273 (ins R64FP:$rA, R64FP:$rB, R64FP:$rC),
4274 "dfnma\t$rT, $rA, $rB", DPrecFP,
4275 [(set R64FP:$rT, (fneg (fadd R64FP:$rC, (fmul R64FP:$rA, R64FP:$rB))))]>,
4276 RegConstraint<"$rC = $rT">,
4277 NoEncode<"$rC">;
4278
4279def FNMAv2f64 :
4280 RRForm<0b11111010110, (outs VECREG:$rT),
4281 (ins VECREG:$rA, VECREG:$rB, VECREG:$rC),
4282 "dfnma\t$rT, $rA, $rB", DPrecFP,
Scott Michel06eabde2008-12-27 04:51:36 +00004283 [(set (v2f64 VECREG:$rT),
4284 (fneg (fadd (v2f64 VECREG:$rC),
4285 (fmul (v2f64 VECREG:$rA),
Scott Michel8b6b4202007-12-04 22:35:58 +00004286 (v2f64 VECREG:$rB)))))]>,
4287 RegConstraint<"$rC = $rT">,
4288 NoEncode<"$rC">;
4289
4290//===----------------------------------------------------------------------==//
4291// Floating point negation and absolute value
4292//===----------------------------------------------------------------------==//
4293
4294def : Pat<(fneg (v4f32 VECREG:$rA)),
Scott Michele13d8392009-03-17 16:45:16 +00004295 (XORfnegvec (v4f32 VECREG:$rA),
4296 (v4f32 (ILHUv4i32 0x8000)))>;
Scott Michel8b6b4202007-12-04 22:35:58 +00004297
4298def : Pat<(fneg R32FP:$rA),
Scott Michele13d8392009-03-17 16:45:16 +00004299 (XORfneg32 R32FP:$rA, (ILHUr32 0x8000))>;
Scott Michel8b6b4202007-12-04 22:35:58 +00004300
4301// Floating point absolute value
Scott Michel0d5eae02009-03-17 01:15:45 +00004302// Note: f64 fabs is custom-selected.
Scott Michel8b6b4202007-12-04 22:35:58 +00004303
4304def : Pat<(fabs R32FP:$rA),
4305 (ANDfabs32 R32FP:$rA, (IOHLr32 (ILHUr32 0x7fff), 0xffff))>;
4306
4307def : Pat<(fabs (v4f32 VECREG:$rA)),
4308 (ANDfabsvec (v4f32 VECREG:$rA),
Scott Michel0d5eae02009-03-17 01:15:45 +00004309 (IOHLv4i32 (ILHUv4i32 0x7fff), 0xffff))>;
pingbak2f387e82009-01-26 03:31:40 +00004310
Scott Michel8b6b4202007-12-04 22:35:58 +00004311//===----------------------------------------------------------------------===//
Scott Michel61895fe2008-12-10 00:15:19 +00004312// Hint for branch instructions:
4313//===----------------------------------------------------------------------===//
4314
4315/* def HBR : SPUInstr<(outs), (ins), "hbr\t" */
4316
4317//===----------------------------------------------------------------------===//
Scott Michel8b6b4202007-12-04 22:35:58 +00004318// Execution, Load NOP (execute NOPs belong in even pipeline, load NOPs belong
4319// in the odd pipeline)
4320//===----------------------------------------------------------------------===//
4321
Scott Michel97872d32008-02-23 18:41:37 +00004322def ENOP : SPUInstr<(outs), (ins), "enop", ExecNOP> {
Scott Michel8b6b4202007-12-04 22:35:58 +00004323 let Pattern = [];
4324
4325 let Inst{0-10} = 0b10000000010;
4326 let Inst{11-17} = 0;
4327 let Inst{18-24} = 0;
4328 let Inst{25-31} = 0;
4329}
4330
Scott Michel97872d32008-02-23 18:41:37 +00004331def LNOP : SPUInstr<(outs), (ins), "lnop", LoadNOP> {
Scott Michel8b6b4202007-12-04 22:35:58 +00004332 let Pattern = [];
4333
4334 let Inst{0-10} = 0b10000000000;
4335 let Inst{11-17} = 0;
4336 let Inst{18-24} = 0;
4337 let Inst{25-31} = 0;
4338}
4339
4340//===----------------------------------------------------------------------===//
4341// Bit conversions (type conversions between vector/packed types)
Scott Michel34712c32009-03-16 18:47:25 +00004342// NOTE: Promotions are handled using the XS* instructions.
Scott Michel8b6b4202007-12-04 22:35:58 +00004343//===----------------------------------------------------------------------===//
4344def : Pat<(v16i8 (bitconvert (v8i16 VECREG:$src))), (v16i8 VECREG:$src)>;
4345def : Pat<(v16i8 (bitconvert (v4i32 VECREG:$src))), (v16i8 VECREG:$src)>;
4346def : Pat<(v16i8 (bitconvert (v2i64 VECREG:$src))), (v16i8 VECREG:$src)>;
4347def : Pat<(v16i8 (bitconvert (v4f32 VECREG:$src))), (v16i8 VECREG:$src)>;
4348def : Pat<(v16i8 (bitconvert (v2f64 VECREG:$src))), (v16i8 VECREG:$src)>;
4349
4350def : Pat<(v8i16 (bitconvert (v16i8 VECREG:$src))), (v8i16 VECREG:$src)>;
4351def : Pat<(v8i16 (bitconvert (v4i32 VECREG:$src))), (v8i16 VECREG:$src)>;
4352def : Pat<(v8i16 (bitconvert (v2i64 VECREG:$src))), (v8i16 VECREG:$src)>;
4353def : Pat<(v8i16 (bitconvert (v4f32 VECREG:$src))), (v8i16 VECREG:$src)>;
4354def : Pat<(v8i16 (bitconvert (v2f64 VECREG:$src))), (v8i16 VECREG:$src)>;
4355
4356def : Pat<(v4i32 (bitconvert (v16i8 VECREG:$src))), (v4i32 VECREG:$src)>;
4357def : Pat<(v4i32 (bitconvert (v8i16 VECREG:$src))), (v4i32 VECREG:$src)>;
4358def : Pat<(v4i32 (bitconvert (v2i64 VECREG:$src))), (v4i32 VECREG:$src)>;
4359def : Pat<(v4i32 (bitconvert (v4f32 VECREG:$src))), (v4i32 VECREG:$src)>;
4360def : Pat<(v4i32 (bitconvert (v2f64 VECREG:$src))), (v4i32 VECREG:$src)>;
4361
4362def : Pat<(v2i64 (bitconvert (v16i8 VECREG:$src))), (v2i64 VECREG:$src)>;
4363def : Pat<(v2i64 (bitconvert (v8i16 VECREG:$src))), (v2i64 VECREG:$src)>;
4364def : Pat<(v2i64 (bitconvert (v4i32 VECREG:$src))), (v2i64 VECREG:$src)>;
4365def : Pat<(v2i64 (bitconvert (v4f32 VECREG:$src))), (v2i64 VECREG:$src)>;
4366def : Pat<(v2i64 (bitconvert (v2f64 VECREG:$src))), (v2i64 VECREG:$src)>;
4367
4368def : Pat<(v4f32 (bitconvert (v16i8 VECREG:$src))), (v4f32 VECREG:$src)>;
4369def : Pat<(v4f32 (bitconvert (v8i16 VECREG:$src))), (v4f32 VECREG:$src)>;
4370def : Pat<(v4f32 (bitconvert (v2i64 VECREG:$src))), (v4f32 VECREG:$src)>;
4371def : Pat<(v4f32 (bitconvert (v4i32 VECREG:$src))), (v4f32 VECREG:$src)>;
4372def : Pat<(v4f32 (bitconvert (v2f64 VECREG:$src))), (v4f32 VECREG:$src)>;
4373
4374def : Pat<(v2f64 (bitconvert (v16i8 VECREG:$src))), (v2f64 VECREG:$src)>;
4375def : Pat<(v2f64 (bitconvert (v8i16 VECREG:$src))), (v2f64 VECREG:$src)>;
4376def : Pat<(v2f64 (bitconvert (v4i32 VECREG:$src))), (v2f64 VECREG:$src)>;
4377def : Pat<(v2f64 (bitconvert (v2i64 VECREG:$src))), (v2f64 VECREG:$src)>;
4378def : Pat<(v2f64 (bitconvert (v2f64 VECREG:$src))), (v2f64 VECREG:$src)>;
4379
Scott Michel34712c32009-03-16 18:47:25 +00004380def : Pat<(i128 (bitconvert (v16i8 VECREG:$src))),
4381 (ORi128_vec VECREG:$src)>;
4382def : Pat<(i128 (bitconvert (v8i16 VECREG:$src))),
4383 (ORi128_vec VECREG:$src)>;
4384def : Pat<(i128 (bitconvert (v4i32 VECREG:$src))),
4385 (ORi128_vec VECREG:$src)>;
4386def : Pat<(i128 (bitconvert (v2i64 VECREG:$src))),
4387 (ORi128_vec VECREG:$src)>;
4388def : Pat<(i128 (bitconvert (v4f32 VECREG:$src))),
4389 (ORi128_vec VECREG:$src)>;
4390def : Pat<(i128 (bitconvert (v2f64 VECREG:$src))),
4391 (ORi128_vec VECREG:$src)>;
4392
4393def : Pat<(v16i8 (bitconvert (i128 GPRC:$src))),
4394 (v16i8 (ORvec_i128 GPRC:$src))>;
4395def : Pat<(v8i16 (bitconvert (i128 GPRC:$src))),
4396 (v8i16 (ORvec_i128 GPRC:$src))>;
4397def : Pat<(v4i32 (bitconvert (i128 GPRC:$src))),
4398 (v4i32 (ORvec_i128 GPRC:$src))>;
4399def : Pat<(v2i64 (bitconvert (i128 GPRC:$src))),
4400 (v2i64 (ORvec_i128 GPRC:$src))>;
4401def : Pat<(v4f32 (bitconvert (i128 GPRC:$src))),
4402 (v4f32 (ORvec_i128 GPRC:$src))>;
4403def : Pat<(v2f64 (bitconvert (i128 GPRC:$src))),
4404 (v2f64 (ORvec_i128 GPRC:$src))>;
Scott Michel8b6b4202007-12-04 22:35:58 +00004405
4406//===----------------------------------------------------------------------===//
4407// Instruction patterns:
4408//===----------------------------------------------------------------------===//
4409
4410// General 32-bit constants:
4411def : Pat<(i32 imm:$imm),
4412 (IOHLr32 (ILHUr32 (HI16 imm:$imm)), (LO16 imm:$imm))>;
4413
4414// Single precision float constants:
Nate Begeman78125042008-02-14 18:43:04 +00004415def : Pat<(f32 fpimm:$imm),
Scott Michel8b6b4202007-12-04 22:35:58 +00004416 (IOHLf32 (ILHUf32 (HI16_f32 fpimm:$imm)), (LO16_f32 fpimm:$imm))>;
4417
4418// General constant 32-bit vectors
4419def : Pat<(v4i32 v4i32Imm:$imm),
Scott Michel6baba072008-03-05 23:02:02 +00004420 (IOHLv4i32 (v4i32 (ILHUv4i32 (HI16_vec v4i32Imm:$imm))),
4421 (LO16_vec v4i32Imm:$imm))>;
Scott Michel06eabde2008-12-27 04:51:36 +00004422
Scott Michel438be252007-12-17 22:32:34 +00004423// 8-bit constants
4424def : Pat<(i8 imm:$imm),
4425 (ILHr8 imm:$imm)>;
Scott Michel8b6b4202007-12-04 22:35:58 +00004426
4427//===----------------------------------------------------------------------===//
Scott Michel8b6b4202007-12-04 22:35:58 +00004428// Zero/Any/Sign extensions
4429//===----------------------------------------------------------------------===//
4430
Scott Michel8b6b4202007-12-04 22:35:58 +00004431// sext 8->32: Sign extend bytes to words
4432def : Pat<(sext_inreg R32C:$rSrc, i8),
4433 (XSHWr32 (XSBHr32 R32C:$rSrc))>;
4434
Scott Michel438be252007-12-17 22:32:34 +00004435def : Pat<(i32 (sext R8C:$rSrc)),
4436 (XSHWr16 (XSBHr8 R8C:$rSrc))>;
4437
Scott Michel2ef773a2009-01-06 03:36:14 +00004438// sext 8->64: Sign extend bytes to double word
4439def : Pat<(sext_inreg R64C:$rSrc, i8),
4440 (XSWDr64_inreg (XSHWr64 (XSBHr64 R64C:$rSrc)))>;
4441
4442def : Pat<(i64 (sext R8C:$rSrc)),
4443 (XSWDr64 (XSHWr16 (XSBHr8 R8C:$rSrc)))>;
4444
Scott Michel438be252007-12-17 22:32:34 +00004445// zext 8->16: Zero extend bytes to halfwords
4446def : Pat<(i16 (zext R8C:$rSrc)),
Scott Michel97872d32008-02-23 18:41:37 +00004447 (ANDHIi8i16 R8C:$rSrc, 0xff)>;
Scott Michel438be252007-12-17 22:32:34 +00004448
Scott Michel438be252007-12-17 22:32:34 +00004449// zext 8->32: Zero extend bytes to words
4450def : Pat<(i32 (zext R8C:$rSrc)),
Scott Michel97872d32008-02-23 18:41:37 +00004451 (ANDIi8i32 R8C:$rSrc, 0xff)>;
Scott Michel438be252007-12-17 22:32:34 +00004452
Scott Michel2ef773a2009-01-06 03:36:14 +00004453// zext 8->64: Zero extend bytes to double words
4454def : Pat<(i64 (zext R8C:$rSrc)),
4455 (ORi64_v2i64 (SELBv4i32 (ROTQMBYv4i32
4456 (ORv4i32_i32 (ANDIi8i32 R8C:$rSrc, 0xff)),
4457 0x4),
4458 (ILv4i32 0x0),
4459 (FSMBIv4i32 0x0f0f)))>;
4460
4461// anyext 8->16: Extend 8->16 bits, irrespective of sign, preserves high bits
Scott Michel438be252007-12-17 22:32:34 +00004462def : Pat<(i16 (anyext R8C:$rSrc)),
Scott Michel97872d32008-02-23 18:41:37 +00004463 (ORHIi8i16 R8C:$rSrc, 0)>;
Scott Michel438be252007-12-17 22:32:34 +00004464
Scott Michel2ef773a2009-01-06 03:36:14 +00004465// anyext 8->32: Extend 8->32 bits, irrespective of sign, preserves high bits
Scott Michel438be252007-12-17 22:32:34 +00004466def : Pat<(i32 (anyext R8C:$rSrc)),
Scott Michel97872d32008-02-23 18:41:37 +00004467 (ORIi8i32 R8C:$rSrc, 0)>;
Scott Michel438be252007-12-17 22:32:34 +00004468
Scott Michel2ef773a2009-01-06 03:36:14 +00004469// sext 16->64: Sign extend halfword to double word
4470def : Pat<(sext_inreg R64C:$rSrc, i16),
4471 (XSWDr64_inreg (XSHWr64 R64C:$rSrc))>;
4472
4473def : Pat<(sext R16C:$rSrc),
4474 (XSWDr64 (XSHWr16 R16C:$rSrc))>;
4475
Scott Michel97872d32008-02-23 18:41:37 +00004476// zext 16->32: Zero extend halfwords to words
Scott Michel8b6b4202007-12-04 22:35:58 +00004477def : Pat<(i32 (zext R16C:$rSrc)),
Scott Michel97872d32008-02-23 18:41:37 +00004478 (ANDi16i32 R16C:$rSrc, (ILAr32 0xffff))>;
Scott Michel8b6b4202007-12-04 22:35:58 +00004479
4480def : Pat<(i32 (zext (and R16C:$rSrc, 0xf))),
Scott Michel97872d32008-02-23 18:41:37 +00004481 (ANDIi16i32 R16C:$rSrc, 0xf)>;
Scott Michel8b6b4202007-12-04 22:35:58 +00004482
4483def : Pat<(i32 (zext (and R16C:$rSrc, 0xff))),
Scott Michel97872d32008-02-23 18:41:37 +00004484 (ANDIi16i32 R16C:$rSrc, 0xff)>;
Scott Michel8b6b4202007-12-04 22:35:58 +00004485
4486def : Pat<(i32 (zext (and R16C:$rSrc, 0xfff))),
Scott Michel97872d32008-02-23 18:41:37 +00004487 (ANDIi16i32 R16C:$rSrc, 0xfff)>;
Scott Michel8b6b4202007-12-04 22:35:58 +00004488
4489// anyext 16->32: Extend 16->32 bits, irrespective of sign
4490def : Pat<(i32 (anyext R16C:$rSrc)),
Scott Michel97872d32008-02-23 18:41:37 +00004491 (ORIi16i32 R16C:$rSrc, 0)>;
Scott Michel8b6b4202007-12-04 22:35:58 +00004492
4493//===----------------------------------------------------------------------===//
Scott Michel06eabde2008-12-27 04:51:36 +00004494// Truncates:
4495// These truncates are for the SPU's supported types (i8, i16, i32). i64 and
4496// above are custom lowered.
4497//===----------------------------------------------------------------------===//
4498
4499def : Pat<(i8 (trunc GPRC:$src)),
4500 (ORi8_v16i8
4501 (SHUFBgprc GPRC:$src, GPRC:$src,
4502 (IOHLv4i32 (ILHUv4i32 0x0f0f), 0x0f0f)))>;
4503
4504def : Pat<(i8 (trunc R64C:$src)),
4505 (ORi8_v16i8
4506 (SHUFBv2i64_m32
4507 (ORv2i64_i64 R64C:$src),
4508 (ORv2i64_i64 R64C:$src),
4509 (IOHLv4i32 (ILHUv4i32 0x0707), 0x0707)))>;
4510
4511def : Pat<(i8 (trunc R32C:$src)),
4512 (ORi8_v16i8
4513 (SHUFBv4i32_m32
4514 (ORv4i32_i32 R32C:$src),
4515 (ORv4i32_i32 R32C:$src),
4516 (IOHLv4i32 (ILHUv4i32 0x0303), 0x0303)))>;
4517
4518def : Pat<(i8 (trunc R16C:$src)),
4519 (ORi8_v16i8
4520 (SHUFBv4i32_m32
4521 (ORv8i16_i16 R16C:$src),
4522 (ORv8i16_i16 R16C:$src),
4523 (IOHLv4i32 (ILHUv4i32 0x0303), 0x0303)))>;
4524
4525def : Pat<(i16 (trunc GPRC:$src)),
4526 (ORi16_v8i16
4527 (SHUFBgprc GPRC:$src, GPRC:$src,
4528 (IOHLv4i32 (ILHUv4i32 0x0e0f), 0x0e0f)))>;
4529
4530def : Pat<(i16 (trunc R64C:$src)),
4531 (ORi16_v8i16
4532 (SHUFBv2i64_m32
4533 (ORv2i64_i64 R64C:$src),
4534 (ORv2i64_i64 R64C:$src),
4535 (IOHLv4i32 (ILHUv4i32 0x0607), 0x0607)))>;
4536
4537def : Pat<(i16 (trunc R32C:$src)),
4538 (ORi16_v8i16
4539 (SHUFBv4i32_m32
4540 (ORv4i32_i32 R32C:$src),
4541 (ORv4i32_i32 R32C:$src),
4542 (IOHLv4i32 (ILHUv4i32 0x0203), 0x0203)))>;
4543
4544def : Pat<(i32 (trunc GPRC:$src)),
4545 (ORi32_v4i32
4546 (SHUFBgprc GPRC:$src, GPRC:$src,
4547 (IOHLv4i32 (ILHUv4i32 0x0c0d), 0x0e0f)))>;
4548
4549def : Pat<(i32 (trunc R64C:$src)),
4550 (ORi32_v4i32
4551 (SHUFBv2i64_m32
4552 (ORv2i64_i64 R64C:$src),
4553 (ORv2i64_i64 R64C:$src),
4554 (IOHLv4i32 (ILHUv4i32 0x0405), 0x0607)))>;
4555
4556//===----------------------------------------------------------------------===//
Scott Michelf9f42e62008-01-29 02:16:57 +00004557// Address generation: SPU, like PPC, has to split addresses into high and
Scott Michel8b6b4202007-12-04 22:35:58 +00004558// low parts in order to load them into a register.
4559//===----------------------------------------------------------------------===//
4560
Scott Michelf9f42e62008-01-29 02:16:57 +00004561def : Pat<(SPUaform tglobaladdr:$in, 0), (ILAlsa tglobaladdr:$in)>;
4562def : Pat<(SPUaform texternalsym:$in, 0), (ILAlsa texternalsym:$in)>;
4563def : Pat<(SPUaform tjumptable:$in, 0), (ILAlsa tjumptable:$in)>;
4564def : Pat<(SPUaform tconstpool:$in, 0), (ILAlsa tconstpool:$in)>;
4565
4566def : Pat<(SPUindirect (SPUhi tglobaladdr:$in, 0),
4567 (SPUlo tglobaladdr:$in, 0)),
Scott Micheldbac4cf2008-01-11 02:53:15 +00004568 (IOHLlo (ILHUhi tglobaladdr:$in), tglobaladdr:$in)>;
Scott Michel394e26d2008-01-17 20:38:41 +00004569
Scott Michelf9f42e62008-01-29 02:16:57 +00004570def : Pat<(SPUindirect (SPUhi texternalsym:$in, 0),
4571 (SPUlo texternalsym:$in, 0)),
4572 (IOHLlo (ILHUhi texternalsym:$in), texternalsym:$in)>;
4573
4574def : Pat<(SPUindirect (SPUhi tjumptable:$in, 0),
4575 (SPUlo tjumptable:$in, 0)),
Scott Micheldbac4cf2008-01-11 02:53:15 +00004576 (IOHLlo (ILHUhi tjumptable:$in), tjumptable:$in)>;
Scott Michel394e26d2008-01-17 20:38:41 +00004577
Scott Michelf9f42e62008-01-29 02:16:57 +00004578def : Pat<(SPUindirect (SPUhi tconstpool:$in, 0),
4579 (SPUlo tconstpool:$in, 0)),
4580 (IOHLlo (ILHUhi tconstpool:$in), tconstpool:$in)>;
4581
4582def : Pat<(add (SPUhi tglobaladdr:$in, 0), (SPUlo tglobaladdr:$in, 0)),
4583 (IOHLlo (ILHUhi tglobaladdr:$in), tglobaladdr:$in)>;
4584
4585def : Pat<(add (SPUhi texternalsym:$in, 0), (SPUlo texternalsym:$in, 0)),
4586 (IOHLlo (ILHUhi texternalsym:$in), texternalsym:$in)>;
4587
4588def : Pat<(add (SPUhi tjumptable:$in, 0), (SPUlo tjumptable:$in, 0)),
4589 (IOHLlo (ILHUhi tjumptable:$in), tjumptable:$in)>;
4590
4591def : Pat<(add (SPUhi tconstpool:$in, 0), (SPUlo tconstpool:$in, 0)),
4592 (IOHLlo (ILHUhi tconstpool:$in), tconstpool:$in)>;
Scott Michel8b6b4202007-12-04 22:35:58 +00004593
Scott Michel34712c32009-03-16 18:47:25 +00004594// Intrinsics:
Scott Michel8b6b4202007-12-04 22:35:58 +00004595include "CellSDKIntrinsics.td"
Scott Michel4d07fb72008-12-30 23:28:25 +00004596// Various math operator instruction sequences
4597include "SPUMathInstr.td"
Scott Michel06eabde2008-12-27 04:51:36 +00004598// 64-bit "instructions"/support
4599include "SPU64InstrInfo.td"
Scott Michel2ef773a2009-01-06 03:36:14 +00004600// 128-bit "instructions"/support
4601include "SPU128InstrInfo.td"