blob: 86eb61cf86c16d4d99af8334145fc95767fa9b92 [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//===----------------------------------------------------------------------===//
34// DWARF debugging Pseudo Instructions
35//===----------------------------------------------------------------------===//
36
Scott Michelc899a122009-01-26 22:33:37 +000037def DWARF_LOC : Pseudo<(outs), (ins i32imm:$line, i32imm:$col, i32imm:$file),
38 ".loc $file, $line, $col",
39 [(dwarf_loc (i32 imm:$line), (i32 imm:$col), (i32 imm:$file))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +000040
41//===----------------------------------------------------------------------===//
42// Loads:
43// NB: The ordering is actually important, since the instruction selection
44// will try each of the instructions in sequence, i.e., the D-form first with
45// the 10-bit displacement, then the A-form with the 16 bit displacement, and
46// finally the X-form with the register-register.
47//===----------------------------------------------------------------------===//
48
Dan Gohman5574cc72008-12-03 18:15:48 +000049let canFoldAsLoad = 1 in {
Scott Michelf9f42e62008-01-29 02:16:57 +000050 class LoadDFormVec<ValueType vectype>
Scott Michel06eabde2008-12-27 04:51:36 +000051 : RI10Form<0b00101100, (outs VECREG:$rT), (ins dformaddr:$src),
Scott Michelf9f42e62008-01-29 02:16:57 +000052 "lqd\t$rT, $src",
53 LoadStore,
54 [(set (vectype VECREG:$rT), (load dform_addr:$src))]>
55 { }
Scott Michel8b6b4202007-12-04 22:35:58 +000056
Scott Michelf9f42e62008-01-29 02:16:57 +000057 class LoadDForm<RegisterClass rclass>
Scott Michel06eabde2008-12-27 04:51:36 +000058 : RI10Form<0b00101100, (outs rclass:$rT), (ins dformaddr:$src),
Scott Michelf9f42e62008-01-29 02:16:57 +000059 "lqd\t$rT, $src",
60 LoadStore,
61 [(set rclass:$rT, (load dform_addr:$src))]>
62 { }
Scott Michel8b6b4202007-12-04 22:35:58 +000063
Scott Michelf9f42e62008-01-29 02:16:57 +000064 multiclass LoadDForms
65 {
66 def v16i8: LoadDFormVec<v16i8>;
67 def v8i16: LoadDFormVec<v8i16>;
68 def v4i32: LoadDFormVec<v4i32>;
69 def v2i64: LoadDFormVec<v2i64>;
70 def v4f32: LoadDFormVec<v4f32>;
71 def v2f64: LoadDFormVec<v2f64>;
Scott Michel8b6b4202007-12-04 22:35:58 +000072
Scott Michel70741542009-01-06 23:10:38 +000073 def v2i32: LoadDFormVec<v2i32>;
74
Scott Michelf9f42e62008-01-29 02:16:57 +000075 def r128: LoadDForm<GPRC>;
76 def r64: LoadDForm<R64C>;
77 def r32: LoadDForm<R32C>;
78 def f32: LoadDForm<R32FP>;
79 def f64: LoadDForm<R64FP>;
80 def r16: LoadDForm<R16C>;
81 def r8: LoadDForm<R8C>;
82 }
Scott Michel8b6b4202007-12-04 22:35:58 +000083
Scott Michelf9f42e62008-01-29 02:16:57 +000084 class LoadAFormVec<ValueType vectype>
85 : RI16Form<0b100001100, (outs VECREG:$rT), (ins addr256k:$src),
86 "lqa\t$rT, $src",
87 LoadStore,
88 [(set (vectype VECREG:$rT), (load aform_addr:$src))]>
89 { }
Scott Michel8b6b4202007-12-04 22:35:58 +000090
Scott Michelf9f42e62008-01-29 02:16:57 +000091 class LoadAForm<RegisterClass rclass>
92 : RI16Form<0b100001100, (outs rclass:$rT), (ins addr256k:$src),
93 "lqa\t$rT, $src",
94 LoadStore,
95 [(set rclass:$rT, (load aform_addr:$src))]>
96 { }
Scott Michel8b6b4202007-12-04 22:35:58 +000097
Scott Michelf9f42e62008-01-29 02:16:57 +000098 multiclass LoadAForms
99 {
100 def v16i8: LoadAFormVec<v16i8>;
101 def v8i16: LoadAFormVec<v8i16>;
102 def v4i32: LoadAFormVec<v4i32>;
103 def v2i64: LoadAFormVec<v2i64>;
104 def v4f32: LoadAFormVec<v4f32>;
105 def v2f64: LoadAFormVec<v2f64>;
Scott Michel8b6b4202007-12-04 22:35:58 +0000106
Scott Michel70741542009-01-06 23:10:38 +0000107 def v2i32: LoadAFormVec<v2i32>;
108
Scott Michelf9f42e62008-01-29 02:16:57 +0000109 def r128: LoadAForm<GPRC>;
110 def r64: LoadAForm<R64C>;
111 def r32: LoadAForm<R32C>;
112 def f32: LoadAForm<R32FP>;
113 def f64: LoadAForm<R64FP>;
114 def r16: LoadAForm<R16C>;
115 def r8: LoadAForm<R8C>;
116 }
Scott Michel8b6b4202007-12-04 22:35:58 +0000117
Scott Michelf9f42e62008-01-29 02:16:57 +0000118 class LoadXFormVec<ValueType vectype>
119 : RRForm<0b00100011100, (outs VECREG:$rT), (ins memrr:$src),
120 "lqx\t$rT, $src",
121 LoadStore,
122 [(set (vectype VECREG:$rT), (load xform_addr:$src))]>
123 { }
Scott Michel8b6b4202007-12-04 22:35:58 +0000124
Scott Michelf9f42e62008-01-29 02:16:57 +0000125 class LoadXForm<RegisterClass rclass>
126 : RRForm<0b00100011100, (outs rclass:$rT), (ins memrr:$src),
127 "lqx\t$rT, $src",
128 LoadStore,
129 [(set rclass:$rT, (load xform_addr:$src))]>
130 { }
Scott Michel8b6b4202007-12-04 22:35:58 +0000131
Scott Michelf9f42e62008-01-29 02:16:57 +0000132 multiclass LoadXForms
133 {
134 def v16i8: LoadXFormVec<v16i8>;
135 def v8i16: LoadXFormVec<v8i16>;
136 def v4i32: LoadXFormVec<v4i32>;
137 def v2i64: LoadXFormVec<v2i64>;
138 def v4f32: LoadXFormVec<v4f32>;
139 def v2f64: LoadXFormVec<v2f64>;
Scott Michel8b6b4202007-12-04 22:35:58 +0000140
Scott Michel70741542009-01-06 23:10:38 +0000141 def v2i32: LoadXFormVec<v2i32>;
142
Scott Michelf9f42e62008-01-29 02:16:57 +0000143 def r128: LoadXForm<GPRC>;
144 def r64: LoadXForm<R64C>;
145 def r32: LoadXForm<R32C>;
146 def f32: LoadXForm<R32FP>;
147 def f64: LoadXForm<R64FP>;
148 def r16: LoadXForm<R16C>;
149 def r8: LoadXForm<R8C>;
150 }
Scott Michel8b6b4202007-12-04 22:35:58 +0000151
Scott Michelf9f42e62008-01-29 02:16:57 +0000152 defm LQA : LoadAForms;
153 defm LQD : LoadDForms;
154 defm LQX : LoadXForms;
Scott Michel438be252007-12-17 22:32:34 +0000155
Scott Michel8b6b4202007-12-04 22:35:58 +0000156/* Load quadword, PC relative: Not much use at this point in time.
Scott Michelf9f42e62008-01-29 02:16:57 +0000157 Might be of use later for relocatable code. It's effectively the
158 same as LQA, but uses PC-relative addressing.
Scott Michel8b6b4202007-12-04 22:35:58 +0000159 def LQR : RI16Form<0b111001100, (outs VECREG:$rT), (ins s16imm:$disp),
160 "lqr\t$rT, $disp", LoadStore,
161 [(set VECREG:$rT, (load iaddr:$disp))]>;
162 */
Scott Michel8b6b4202007-12-04 22:35:58 +0000163}
164
165//===----------------------------------------------------------------------===//
166// Stores:
167//===----------------------------------------------------------------------===//
Scott Michelf9f42e62008-01-29 02:16:57 +0000168class StoreDFormVec<ValueType vectype>
Scott Michel06eabde2008-12-27 04:51:36 +0000169 : RI10Form<0b00100100, (outs), (ins VECREG:$rT, dformaddr:$src),
Scott Michelf9f42e62008-01-29 02:16:57 +0000170 "stqd\t$rT, $src",
171 LoadStore,
172 [(store (vectype VECREG:$rT), dform_addr:$src)]>
173{ }
Scott Michel8b6b4202007-12-04 22:35:58 +0000174
Scott Michelf9f42e62008-01-29 02:16:57 +0000175class StoreDForm<RegisterClass rclass>
Scott Michel06eabde2008-12-27 04:51:36 +0000176 : RI10Form<0b00100100, (outs), (ins rclass:$rT, dformaddr:$src),
Scott Michelf9f42e62008-01-29 02:16:57 +0000177 "stqd\t$rT, $src",
178 LoadStore,
179 [(store rclass:$rT, dform_addr:$src)]>
180{ }
Scott Michel8b6b4202007-12-04 22:35:58 +0000181
Scott Michelf9f42e62008-01-29 02:16:57 +0000182multiclass StoreDForms
183{
184 def v16i8: StoreDFormVec<v16i8>;
185 def v8i16: StoreDFormVec<v8i16>;
186 def v4i32: StoreDFormVec<v4i32>;
187 def v2i64: StoreDFormVec<v2i64>;
188 def v4f32: StoreDFormVec<v4f32>;
189 def v2f64: StoreDFormVec<v2f64>;
Scott Michel8b6b4202007-12-04 22:35:58 +0000190
Scott Michel70741542009-01-06 23:10:38 +0000191 def v2i32: StoreDFormVec<v2i32>;
192
Scott Michelf9f42e62008-01-29 02:16:57 +0000193 def r128: StoreDForm<GPRC>;
194 def r64: StoreDForm<R64C>;
195 def r32: StoreDForm<R32C>;
196 def f32: StoreDForm<R32FP>;
197 def f64: StoreDForm<R64FP>;
198 def r16: StoreDForm<R16C>;
199 def r8: StoreDForm<R8C>;
200}
Scott Michel8b6b4202007-12-04 22:35:58 +0000201
Scott Michelf9f42e62008-01-29 02:16:57 +0000202class StoreAFormVec<ValueType vectype>
203 : RI16Form<0b0010010, (outs), (ins VECREG:$rT, addr256k:$src),
Scott Michel5a6f17b2008-01-30 02:55:46 +0000204 "stqa\t$rT, $src",
205 LoadStore,
Scott Michel6baba072008-03-05 23:02:02 +0000206 [(store (vectype VECREG:$rT), aform_addr:$src)]>;
Scott Michel8b6b4202007-12-04 22:35:58 +0000207
Scott Michelf9f42e62008-01-29 02:16:57 +0000208class StoreAForm<RegisterClass rclass>
209 : RI16Form<0b001001, (outs), (ins rclass:$rT, addr256k:$src),
Scott Michel5a6f17b2008-01-30 02:55:46 +0000210 "stqa\t$rT, $src",
211 LoadStore,
Scott Michel6baba072008-03-05 23:02:02 +0000212 [(store rclass:$rT, aform_addr:$src)]>;
Scott Michel8b6b4202007-12-04 22:35:58 +0000213
Scott Michelf9f42e62008-01-29 02:16:57 +0000214multiclass StoreAForms
215{
216 def v16i8: StoreAFormVec<v16i8>;
217 def v8i16: StoreAFormVec<v8i16>;
218 def v4i32: StoreAFormVec<v4i32>;
219 def v2i64: StoreAFormVec<v2i64>;
220 def v4f32: StoreAFormVec<v4f32>;
221 def v2f64: StoreAFormVec<v2f64>;
Scott Michel8b6b4202007-12-04 22:35:58 +0000222
Scott Michel70741542009-01-06 23:10:38 +0000223 def v2i32: StoreAFormVec<v2i32>;
224
Scott Michelf9f42e62008-01-29 02:16:57 +0000225 def r128: StoreAForm<GPRC>;
226 def r64: StoreAForm<R64C>;
227 def r32: StoreAForm<R32C>;
228 def f32: StoreAForm<R32FP>;
229 def f64: StoreAForm<R64FP>;
230 def r16: StoreAForm<R16C>;
231 def r8: StoreAForm<R8C>;
232}
Scott Michel8b6b4202007-12-04 22:35:58 +0000233
Scott Michelf9f42e62008-01-29 02:16:57 +0000234class StoreXFormVec<ValueType vectype>
235 : RRForm<0b00100100, (outs), (ins VECREG:$rT, memrr:$src),
Scott Michel5a6f17b2008-01-30 02:55:46 +0000236 "stqx\t$rT, $src",
237 LoadStore,
238 [(store (vectype VECREG:$rT), xform_addr:$src)]>
Scott Michelf9f42e62008-01-29 02:16:57 +0000239{ }
Scott Michel8b6b4202007-12-04 22:35:58 +0000240
Scott Michelf9f42e62008-01-29 02:16:57 +0000241class StoreXForm<RegisterClass rclass>
242 : RRForm<0b00100100, (outs), (ins rclass:$rT, memrr:$src),
Scott Michel5a6f17b2008-01-30 02:55:46 +0000243 "stqx\t$rT, $src",
244 LoadStore,
245 [(store rclass:$rT, xform_addr:$src)]>
Scott Michelf9f42e62008-01-29 02:16:57 +0000246{ }
Scott Michel8b6b4202007-12-04 22:35:58 +0000247
Scott Michelf9f42e62008-01-29 02:16:57 +0000248multiclass StoreXForms
249{
250 def v16i8: StoreXFormVec<v16i8>;
251 def v8i16: StoreXFormVec<v8i16>;
252 def v4i32: StoreXFormVec<v4i32>;
253 def v2i64: StoreXFormVec<v2i64>;
254 def v4f32: StoreXFormVec<v4f32>;
255 def v2f64: StoreXFormVec<v2f64>;
Scott Michel8b6b4202007-12-04 22:35:58 +0000256
Scott Michel70741542009-01-06 23:10:38 +0000257 def v2i32: StoreXFormVec<v2i32>;
258
Scott Michelf9f42e62008-01-29 02:16:57 +0000259 def r128: StoreXForm<GPRC>;
260 def r64: StoreXForm<R64C>;
261 def r32: StoreXForm<R32C>;
262 def f32: StoreXForm<R32FP>;
263 def f64: StoreXForm<R64FP>;
264 def r16: StoreXForm<R16C>;
265 def r8: StoreXForm<R8C>;
266}
Scott Michel8b6b4202007-12-04 22:35:58 +0000267
Scott Michelf9f42e62008-01-29 02:16:57 +0000268defm STQD : StoreDForms;
269defm STQA : StoreAForms;
270defm STQX : StoreXForms;
Scott Michel8b6b4202007-12-04 22:35:58 +0000271
272/* Store quadword, PC relative: Not much use at this point in time. Might
Scott Michelf9f42e62008-01-29 02:16:57 +0000273 be useful for relocatable code.
Chris Lattneref8d6082008-01-06 06:44:58 +0000274def STQR : RI16Form<0b111000100, (outs), (ins VECREG:$rT, s16imm:$disp),
275 "stqr\t$rT, $disp", LoadStore,
276 [(store VECREG:$rT, iaddr:$disp)]>;
277*/
Scott Michel8b6b4202007-12-04 22:35:58 +0000278
279//===----------------------------------------------------------------------===//
280// Generate Controls for Insertion:
281//===----------------------------------------------------------------------===//
282
Scott Michel06eabde2008-12-27 04:51:36 +0000283def CBD: RI7Form<0b10101111100, (outs VECREG:$rT), (ins shufaddr:$src),
Scott Michel0718cd82008-12-01 17:56:02 +0000284 "cbd\t$rT, $src", ShuffleOp,
285 [(set (v16i8 VECREG:$rT), (SPUshufmask dform2_addr:$src))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +0000286
Scott Michel0718cd82008-12-01 17:56:02 +0000287def CBX: RRForm<0b00101011100, (outs VECREG:$rT), (ins memrr:$src),
Scott Michel8b6b4202007-12-04 22:35:58 +0000288 "cbx\t$rT, $src", ShuffleOp,
Scott Michel56a125e2008-11-22 23:50:42 +0000289 [(set (v16i8 VECREG:$rT), (SPUshufmask xform_addr:$src))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +0000290
Scott Michel06eabde2008-12-27 04:51:36 +0000291def CHD: RI7Form<0b10101111100, (outs VECREG:$rT), (ins shufaddr:$src),
Scott Michel8b6b4202007-12-04 22:35:58 +0000292 "chd\t$rT, $src", ShuffleOp,
Scott Michel56a125e2008-11-22 23:50:42 +0000293 [(set (v8i16 VECREG:$rT), (SPUshufmask dform2_addr:$src))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +0000294
Scott Michel0718cd82008-12-01 17:56:02 +0000295def CHX: RRForm<0b10101011100, (outs VECREG:$rT), (ins memrr:$src),
Scott Michel8b6b4202007-12-04 22:35:58 +0000296 "chx\t$rT, $src", ShuffleOp,
Scott Michel56a125e2008-11-22 23:50:42 +0000297 [(set (v8i16 VECREG:$rT), (SPUshufmask xform_addr:$src))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +0000298
Scott Michel06eabde2008-12-27 04:51:36 +0000299def CWD: RI7Form<0b01101111100, (outs VECREG:$rT), (ins shufaddr:$src),
Scott Michel8b6b4202007-12-04 22:35:58 +0000300 "cwd\t$rT, $src", ShuffleOp,
Scott Michel56a125e2008-11-22 23:50:42 +0000301 [(set (v4i32 VECREG:$rT), (SPUshufmask dform2_addr:$src))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +0000302
Scott Michel0718cd82008-12-01 17:56:02 +0000303def CWX: RRForm<0b01101011100, (outs VECREG:$rT), (ins memrr:$src),
Scott Michel8b6b4202007-12-04 22:35:58 +0000304 "cwx\t$rT, $src", ShuffleOp,
Scott Michel56a125e2008-11-22 23:50:42 +0000305 [(set (v4i32 VECREG:$rT), (SPUshufmask xform_addr:$src))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +0000306
Scott Michel06eabde2008-12-27 04:51:36 +0000307def CWDf32: RI7Form<0b01101111100, (outs VECREG:$rT), (ins shufaddr:$src),
Scott Michel0718cd82008-12-01 17:56:02 +0000308 "cwd\t$rT, $src", ShuffleOp,
309 [(set (v4f32 VECREG:$rT), (SPUshufmask dform2_addr:$src))]>;
310
311def CWXf32: RRForm<0b01101011100, (outs VECREG:$rT), (ins memrr:$src),
Scott Michelbc5fbc12008-04-30 00:30:08 +0000312 "cwx\t$rT, $src", ShuffleOp,
Scott Michel56a125e2008-11-22 23:50:42 +0000313 [(set (v4f32 VECREG:$rT), (SPUshufmask xform_addr:$src))]>;
Scott Michelbc5fbc12008-04-30 00:30:08 +0000314
Scott Michel06eabde2008-12-27 04:51:36 +0000315def CDD: RI7Form<0b11101111100, (outs VECREG:$rT), (ins shufaddr:$src),
Scott Michel8b6b4202007-12-04 22:35:58 +0000316 "cdd\t$rT, $src", ShuffleOp,
Scott Michel56a125e2008-11-22 23:50:42 +0000317 [(set (v2i64 VECREG:$rT), (SPUshufmask dform2_addr:$src))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +0000318
Scott Michel0718cd82008-12-01 17:56:02 +0000319def CDX: RRForm<0b11101011100, (outs VECREG:$rT), (ins memrr:$src),
Scott Michel8b6b4202007-12-04 22:35:58 +0000320 "cdx\t$rT, $src", ShuffleOp,
Scott Michel56a125e2008-11-22 23:50:42 +0000321 [(set (v2i64 VECREG:$rT), (SPUshufmask xform_addr:$src))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +0000322
Scott Michel06eabde2008-12-27 04:51:36 +0000323def CDDf64: RI7Form<0b11101111100, (outs VECREG:$rT), (ins shufaddr:$src),
Scott Michel0718cd82008-12-01 17:56:02 +0000324 "cdd\t$rT, $src", ShuffleOp,
325 [(set (v2f64 VECREG:$rT), (SPUshufmask dform2_addr:$src))]>;
326
327def CDXf64: RRForm<0b11101011100, (outs VECREG:$rT), (ins memrr:$src),
Scott Michelbc5fbc12008-04-30 00:30:08 +0000328 "cdx\t$rT, $src", ShuffleOp,
Scott Michel56a125e2008-11-22 23:50:42 +0000329 [(set (v2f64 VECREG:$rT), (SPUshufmask xform_addr:$src))]>;
Scott Michelbc5fbc12008-04-30 00:30:08 +0000330
Scott Michel8b6b4202007-12-04 22:35:58 +0000331//===----------------------------------------------------------------------===//
332// Constant formation:
333//===----------------------------------------------------------------------===//
334
335def ILHv8i16:
336 RI16Form<0b110000010, (outs VECREG:$rT), (ins s16imm:$val),
337 "ilh\t$rT, $val", ImmLoad,
338 [(set (v8i16 VECREG:$rT), (v8i16 v8i16SExt16Imm:$val))]>;
339
340def ILHr16:
341 RI16Form<0b110000010, (outs R16C:$rT), (ins s16imm:$val),
342 "ilh\t$rT, $val", ImmLoad,
343 [(set R16C:$rT, immSExt16:$val)]>;
344
Scott Michel438be252007-12-17 22:32:34 +0000345// Cell SPU doesn't have a native 8-bit immediate load, but ILH works ("with
346// the right constant")
347def ILHr8:
348 RI16Form<0b110000010, (outs R8C:$rT), (ins s16imm_i8:$val),
349 "ilh\t$rT, $val", ImmLoad,
350 [(set R8C:$rT, immSExt8:$val)]>;
351
Scott Michel8b6b4202007-12-04 22:35:58 +0000352// IL does sign extension!
Scott Michel8b6b4202007-12-04 22:35:58 +0000353
Scott Michel6baba072008-03-05 23:02:02 +0000354class ILInst<dag OOL, dag IOL, list<dag> pattern>:
355 RI16Form<0b100000010, OOL, IOL, "il\t$rT, $val",
356 ImmLoad, pattern>;
Scott Michel8b6b4202007-12-04 22:35:58 +0000357
Scott Michel6baba072008-03-05 23:02:02 +0000358class ILVecInst<ValueType vectype, Operand immtype, PatLeaf xform>:
359 ILInst<(outs VECREG:$rT), (ins immtype:$val),
360 [(set (vectype VECREG:$rT), (vectype xform:$val))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +0000361
Scott Michel6baba072008-03-05 23:02:02 +0000362class ILRegInst<RegisterClass rclass, Operand immtype, PatLeaf xform>:
363 ILInst<(outs rclass:$rT), (ins immtype:$val),
364 [(set rclass:$rT, xform:$val)]>;
Scott Michel8b6b4202007-12-04 22:35:58 +0000365
Scott Michel6baba072008-03-05 23:02:02 +0000366multiclass ImmediateLoad
367{
368 def v2i64: ILVecInst<v2i64, s16imm_i64, v2i64SExt16Imm>;
369 def v4i32: ILVecInst<v4i32, s16imm_i32, v4i32SExt16Imm>;
Scott Michel8b6b4202007-12-04 22:35:58 +0000370
Scott Michel6baba072008-03-05 23:02:02 +0000371 // TODO: Need v2f64, v4f32
Scott Michel8b6b4202007-12-04 22:35:58 +0000372
Scott Michel6baba072008-03-05 23:02:02 +0000373 def r64: ILRegInst<R64C, s16imm_i64, immSExt16>;
374 def r32: ILRegInst<R32C, s16imm_i32, immSExt16>;
375 def f32: ILRegInst<R32FP, s16imm_f32, fpimmSExt16>;
376 def f64: ILRegInst<R64FP, s16imm_f64, fpimmSExt16>;
377}
Scott Michel8b6b4202007-12-04 22:35:58 +0000378
Scott Michel6baba072008-03-05 23:02:02 +0000379defm IL : ImmediateLoad;
Scott Michel8b6b4202007-12-04 22:35:58 +0000380
Scott Michel6baba072008-03-05 23:02:02 +0000381class ILHUInst<dag OOL, dag IOL, list<dag> pattern>:
382 RI16Form<0b010000010, OOL, IOL, "ilhu\t$rT, $val",
383 ImmLoad, pattern>;
Scott Michel8b6b4202007-12-04 22:35:58 +0000384
Scott Michel6baba072008-03-05 23:02:02 +0000385class ILHUVecInst<ValueType vectype, Operand immtype, PatLeaf xform>:
386 ILHUInst<(outs VECREG:$rT), (ins immtype:$val),
387 [(set (vectype VECREG:$rT), (vectype xform:$val))]>;
388
389class ILHURegInst<RegisterClass rclass, Operand immtype, PatLeaf xform>:
390 ILHUInst<(outs rclass:$rT), (ins immtype:$val),
391 [(set rclass:$rT, xform:$val)]>;
392
393multiclass ImmLoadHalfwordUpper
394{
395 def v2i64: ILHUVecInst<v2i64, u16imm_i64, immILHUvec_i64>;
Scott Michelbc5fbc12008-04-30 00:30:08 +0000396 def v4i32: ILHUVecInst<v4i32, u16imm_i32, immILHUvec>;
Scott Michel6baba072008-03-05 23:02:02 +0000397
398 def r64: ILHURegInst<R64C, u16imm_i64, hi16>;
Scott Michelbc5fbc12008-04-30 00:30:08 +0000399 def r32: ILHURegInst<R32C, u16imm_i32, hi16>;
Scott Michel6baba072008-03-05 23:02:02 +0000400
401 // Loads the high portion of an address
402 def hi: ILHURegInst<R32C, symbolHi, hi16>;
403
404 // Used in custom lowering constant SFP loads:
405 def f32: ILHURegInst<R32FP, f16imm, hi16_f32>;
406}
407
408defm ILHU : ImmLoadHalfwordUpper;
Scott Michel8b6b4202007-12-04 22:35:58 +0000409
410// Immediate load address (can also be used to load 18-bit unsigned constants,
411// see the zext 16->32 pattern)
Scott Michel6baba072008-03-05 23:02:02 +0000412
Scott Michel97872d32008-02-23 18:41:37 +0000413class ILAInst<dag OOL, dag IOL, list<dag> pattern>:
414 RI18Form<0b1000010, OOL, IOL, "ila\t$rT, $val",
415 LoadNOP, pattern>;
Scott Michel8b6b4202007-12-04 22:35:58 +0000416
Scott Michel6baba072008-03-05 23:02:02 +0000417class ILAVecInst<ValueType vectype, Operand immtype, PatLeaf xform>:
418 ILAInst<(outs VECREG:$rT), (ins immtype:$val),
419 [(set (vectype VECREG:$rT), (vectype xform:$val))]>;
420
421class ILARegInst<RegisterClass rclass, Operand immtype, PatLeaf xform>:
422 ILAInst<(outs rclass:$rT), (ins immtype:$val),
423 [(set rclass:$rT, xform:$val)]>;
424
Scott Michel97872d32008-02-23 18:41:37 +0000425multiclass ImmLoadAddress
426{
Scott Michel6baba072008-03-05 23:02:02 +0000427 def v2i64: ILAVecInst<v2i64, u18imm, v2i64Uns18Imm>;
428 def v4i32: ILAVecInst<v4i32, u18imm, v4i32Uns18Imm>;
Scott Michel8b6b4202007-12-04 22:35:58 +0000429
Scott Michel6baba072008-03-05 23:02:02 +0000430 def r64: ILARegInst<R64C, u18imm_i64, imm18>;
431 def r32: ILARegInst<R32C, u18imm, imm18>;
432 def f32: ILARegInst<R32FP, f18imm, fpimm18>;
433 def f64: ILARegInst<R64FP, f18imm_f64, fpimm18>;
Scott Michel8b6b4202007-12-04 22:35:58 +0000434
Scott Michel06eabde2008-12-27 04:51:36 +0000435 def hi: ILARegInst<R32C, symbolHi, imm18>;
Scott Michel6baba072008-03-05 23:02:02 +0000436 def lo: ILARegInst<R32C, symbolLo, imm18>;
Scott Michel8b6b4202007-12-04 22:35:58 +0000437
Scott Michel97872d32008-02-23 18:41:37 +0000438 def lsa: ILAInst<(outs R32C:$rT), (ins symbolLSA:$val),
439 [/* no pattern */]>;
440}
441
442defm ILA : ImmLoadAddress;
Scott Michel8b6b4202007-12-04 22:35:58 +0000443
444// Immediate OR, Halfword Lower: The "other" part of loading large constants
445// into 32-bit registers. See the anonymous pattern Pat<(i32 imm:$imm), ...>
446// Note that these are really two operand instructions, but they're encoded
447// as three operands with the first two arguments tied-to each other.
448
Scott Michel6baba072008-03-05 23:02:02 +0000449class IOHLInst<dag OOL, dag IOL, list<dag> pattern>:
450 RI16Form<0b100000110, OOL, IOL, "iohl\t$rT, $val",
451 ImmLoad, pattern>,
452 RegConstraint<"$rS = $rT">,
453 NoEncode<"$rS">;
Scott Michel8b6b4202007-12-04 22:35:58 +0000454
Scott Michel6baba072008-03-05 23:02:02 +0000455class IOHLVecInst<ValueType vectype, Operand immtype /* , PatLeaf xform */>:
456 IOHLInst<(outs VECREG:$rT), (ins VECREG:$rS, immtype:$val),
457 [/* no pattern */]>;
Scott Michel8b6b4202007-12-04 22:35:58 +0000458
Scott Michel6baba072008-03-05 23:02:02 +0000459class IOHLRegInst<RegisterClass rclass, Operand immtype /* , PatLeaf xform */>:
460 IOHLInst<(outs rclass:$rT), (ins rclass:$rS, immtype:$val),
461 [/* no pattern */]>;
Scott Michel8b6b4202007-12-04 22:35:58 +0000462
Scott Michel6baba072008-03-05 23:02:02 +0000463multiclass ImmOrHalfwordLower
464{
465 def v2i64: IOHLVecInst<v2i64, u16imm_i64>;
Scott Michelbc5fbc12008-04-30 00:30:08 +0000466 def v4i32: IOHLVecInst<v4i32, u16imm_i32>;
Scott Michel6baba072008-03-05 23:02:02 +0000467
468 def r32: IOHLRegInst<R32C, i32imm>;
469 def f32: IOHLRegInst<R32FP, f32imm>;
470
471 def lo: IOHLRegInst<R32C, symbolLo>;
472}
473
474defm IOHL: ImmOrHalfwordLower;
Scott Micheldbac4cf2008-01-11 02:53:15 +0000475
Scott Michel8b6b4202007-12-04 22:35:58 +0000476// Form select mask for bytes using immediate, used in conjunction with the
477// SELB instruction:
478
Scott Michel6baba072008-03-05 23:02:02 +0000479class FSMBIVec<ValueType vectype>:
480 RI16Form<0b101001100, (outs VECREG:$rT), (ins u16imm:$val),
481 "fsmbi\t$rT, $val",
482 SelectOp,
Scott Michel67224b22008-06-02 22:18:03 +0000483 [(set (vectype VECREG:$rT), (SPUselmask (i16 immU16:$val)))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +0000484
Scott Michel97872d32008-02-23 18:41:37 +0000485multiclass FormSelectMaskBytesImm
Scott Michelf9f42e62008-01-29 02:16:57 +0000486{
487 def v16i8: FSMBIVec<v16i8>;
488 def v8i16: FSMBIVec<v8i16>;
489 def v4i32: FSMBIVec<v4i32>;
490 def v2i64: FSMBIVec<v2i64>;
491}
Scott Michel8b6b4202007-12-04 22:35:58 +0000492
Scott Michel97872d32008-02-23 18:41:37 +0000493defm FSMBI : FormSelectMaskBytesImm;
494
495// fsmb: Form select mask for bytes. N.B. Input operand, $rA, is 16-bits
Scott Michel06eabde2008-12-27 04:51:36 +0000496class FSMBInst<dag OOL, dag IOL, list<dag> pattern>:
497 RRForm_1<0b01101101100, OOL, IOL, "fsmb\t$rT, $rA", SelectOp,
498 pattern>;
499
500class FSMBRegInst<RegisterClass rclass, ValueType vectype>:
501 FSMBInst<(outs VECREG:$rT), (ins rclass:$rA),
502 [(set (vectype VECREG:$rT), (SPUselmask rclass:$rA))]>;
503
504class FSMBVecInst<ValueType vectype>:
505 FSMBInst<(outs VECREG:$rT), (ins VECREG:$rA),
506 [(set (vectype VECREG:$rT),
507 (SPUselmask (vectype VECREG:$rA)))]>;
508
509multiclass FormSelectMaskBits {
510 def v16i8_r16: FSMBRegInst<R16C, v16i8>;
511 def v16i8: FSMBVecInst<v16i8>;
512}
513
514defm FSMB: FormSelectMaskBits;
Scott Michel97872d32008-02-23 18:41:37 +0000515
516// fsmh: Form select mask for halfwords. N.B., Input operand, $rA, is
517// only 8-bits wide (even though it's input as 16-bits here)
Scott Michel06eabde2008-12-27 04:51:36 +0000518
519class FSMHInst<dag OOL, dag IOL, list<dag> pattern>:
520 RRForm_1<0b10101101100, OOL, IOL, "fsmh\t$rT, $rA", SelectOp,
521 pattern>;
522
523class FSMHRegInst<RegisterClass rclass, ValueType vectype>:
524 FSMHInst<(outs VECREG:$rT), (ins rclass:$rA),
525 [(set (vectype VECREG:$rT), (SPUselmask rclass:$rA))]>;
526
527class FSMHVecInst<ValueType vectype>:
528 FSMHInst<(outs VECREG:$rT), (ins VECREG:$rA),
529 [(set (vectype VECREG:$rT),
530 (SPUselmask (vectype VECREG:$rA)))]>;
531
532multiclass FormSelectMaskHalfword {
533 def v8i16_r16: FSMHRegInst<R16C, v8i16>;
534 def v8i16: FSMHVecInst<v8i16>;
535}
536
537defm FSMH: FormSelectMaskHalfword;
Scott Michel97872d32008-02-23 18:41:37 +0000538
539// fsm: Form select mask for words. Like the other fsm* instructions,
540// only the lower 4 bits of $rA are significant.
Scott Michel06eabde2008-12-27 04:51:36 +0000541
542class FSMInst<dag OOL, dag IOL, list<dag> pattern>:
543 RRForm_1<0b00101101100, OOL, IOL, "fsm\t$rT, $rA", SelectOp,
544 pattern>;
545
546class FSMRegInst<ValueType vectype, RegisterClass rclass>:
547 FSMInst<(outs VECREG:$rT), (ins rclass:$rA),
548 [(set (vectype VECREG:$rT), (SPUselmask rclass:$rA))]>;
549
550class FSMVecInst<ValueType vectype>:
551 FSMInst<(outs VECREG:$rT), (ins VECREG:$rA),
552 [(set (vectype VECREG:$rT), (SPUselmask (vectype VECREG:$rA)))]>;
Scott Michel67224b22008-06-02 22:18:03 +0000553
554multiclass FormSelectMaskWord {
Scott Michel06eabde2008-12-27 04:51:36 +0000555 def v4i32: FSMVecInst<v4i32>;
556
557 def r32 : FSMRegInst<v4i32, R32C>;
558 def r16 : FSMRegInst<v4i32, R16C>;
Scott Michel67224b22008-06-02 22:18:03 +0000559}
560
561defm FSM : FormSelectMaskWord;
562
563// Special case when used for i64 math operations
564multiclass FormSelectMaskWord64 {
Scott Michel06eabde2008-12-27 04:51:36 +0000565 def r32 : FSMRegInst<v2i64, R32C>;
566 def r16 : FSMRegInst<v2i64, R16C>;
Scott Michel67224b22008-06-02 22:18:03 +0000567}
568
569defm FSM64 : FormSelectMaskWord64;
Scott Michel8b6b4202007-12-04 22:35:58 +0000570
571//===----------------------------------------------------------------------===//
572// Integer and Logical Operations:
573//===----------------------------------------------------------------------===//
574
575def AHv8i16:
576 RRForm<0b00010011000, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
577 "ah\t$rT, $rA, $rB", IntegerOp,
578 [(set (v8i16 VECREG:$rT), (int_spu_si_ah VECREG:$rA, VECREG:$rB))]>;
579
580def : Pat<(add (v8i16 VECREG:$rA), (v8i16 VECREG:$rB)),
581 (AHv8i16 VECREG:$rA, VECREG:$rB)>;
582
Scott Michel8b6b4202007-12-04 22:35:58 +0000583def AHr16:
584 RRForm<0b00010011000, (outs R16C:$rT), (ins R16C:$rA, R16C:$rB),
585 "ah\t$rT, $rA, $rB", IntegerOp,
586 [(set R16C:$rT, (add R16C:$rA, R16C:$rB))]>;
587
588def AHIvec:
589 RI10Form<0b10111000, (outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
590 "ahi\t$rT, $rA, $val", IntegerOp,
591 [(set (v8i16 VECREG:$rT), (add (v8i16 VECREG:$rA),
592 v8i16SExt10Imm:$val))]>;
593
Scott Michel97872d32008-02-23 18:41:37 +0000594def AHIr16:
595 RI10Form<0b10111000, (outs R16C:$rT), (ins R16C:$rA, s10imm:$val),
596 "ahi\t$rT, $rA, $val", IntegerOp,
Scott Michel4d07fb72008-12-30 23:28:25 +0000597 [(set R16C:$rT, (add R16C:$rA, i16ImmSExt10:$val))]>;
598
599// v4i32, i32 add instruction:
Scott Michel8b6b4202007-12-04 22:35:58 +0000600
Scott Michelae5cbf52008-12-29 03:23:36 +0000601class AInst<dag OOL, dag IOL, list<dag> pattern>:
602 RRForm<0b00000011000, OOL, IOL,
603 "a\t$rT, $rA, $rB", IntegerOp,
604 pattern>;
Scott Michel8b6b4202007-12-04 22:35:58 +0000605
Scott Michelae5cbf52008-12-29 03:23:36 +0000606class AVecInst<ValueType vectype>:
607 AInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
608 [(set (vectype VECREG:$rT), (add (vectype VECREG:$rA),
609 (vectype VECREG:$rB)))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +0000610
Scott Michelae5cbf52008-12-29 03:23:36 +0000611class ARegInst<RegisterClass rclass>:
612 AInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB),
613 [(set rclass:$rT, (add rclass:$rA, rclass:$rB))]>;
614
615multiclass AddInstruction {
616 def v4i32: AVecInst<v4i32>;
617 def v16i8: AVecInst<v16i8>;
618
619 def r32: ARegInst<R32C>;
Scott Michelae5cbf52008-12-29 03:23:36 +0000620}
Scott Michel8b6b4202007-12-04 22:35:58 +0000621
Scott Michelae5cbf52008-12-29 03:23:36 +0000622defm A : AddInstruction;
Scott Michel438be252007-12-17 22:32:34 +0000623
Scott Michel4d07fb72008-12-30 23:28:25 +0000624class AIInst<dag OOL, dag IOL, list<dag> pattern>:
625 RI10Form<0b00111000, OOL, IOL,
pingbakb8913342009-01-26 03:37:41 +0000626 "ai\t$rT, $rA, $val", IntegerOp,
627 pattern>;
Scott Michel8b6b4202007-12-04 22:35:58 +0000628
Scott Michel4d07fb72008-12-30 23:28:25 +0000629class AIVecInst<ValueType vectype, PatLeaf immpred>:
630 AIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
pingbakb8913342009-01-26 03:37:41 +0000631 [(set (vectype VECREG:$rT), (add (vectype VECREG:$rA), immpred:$val))]>;
Scott Michel4d07fb72008-12-30 23:28:25 +0000632
633class AIFPVecInst<ValueType vectype, PatLeaf immpred>:
634 AIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
pingbakb8913342009-01-26 03:37:41 +0000635 [/* no pattern */]>;
Scott Michel4d07fb72008-12-30 23:28:25 +0000636
637class AIRegInst<RegisterClass rclass, PatLeaf immpred>:
638 AIInst<(outs rclass:$rT), (ins rclass:$rA, s10imm_i32:$val),
pingbakb8913342009-01-26 03:37:41 +0000639 [(set rclass:$rT, (add rclass:$rA, immpred:$val))]>;
Scott Michel4d07fb72008-12-30 23:28:25 +0000640
641// This is used to add epsilons to floating point numbers in the f32 fdiv code:
642class AIFPInst<RegisterClass rclass, PatLeaf immpred>:
643 AIInst<(outs rclass:$rT), (ins rclass:$rA, s10imm_i32:$val),
pingbakb8913342009-01-26 03:37:41 +0000644 [/* no pattern */]>;
Scott Michel4d07fb72008-12-30 23:28:25 +0000645
646multiclass AddImmediate {
647 def v4i32: AIVecInst<v4i32, v4i32SExt10Imm>;
648
649 def r32: AIRegInst<R32C, i32ImmSExt10>;
650
651 def v4f32: AIFPVecInst<v4f32, v4i32SExt10Imm>;
652 def f32: AIFPInst<R32FP, i32ImmSExt10>;
653}
654
655defm AI : AddImmediate;
Scott Michel8b6b4202007-12-04 22:35:58 +0000656
Scott Michel438be252007-12-17 22:32:34 +0000657def SFHvec:
658 RRForm<0b00010010000, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
659 "sfh\t$rT, $rA, $rB", IntegerOp,
660 [(set (v8i16 VECREG:$rT), (sub (v8i16 VECREG:$rA),
661 (v8i16 VECREG:$rB)))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +0000662
Scott Michel438be252007-12-17 22:32:34 +0000663def SFHr16:
664 RRForm<0b00010010000, (outs R16C:$rT), (ins R16C:$rA, R16C:$rB),
665 "sfh\t$rT, $rA, $rB", IntegerOp,
666 [(set R16C:$rT, (sub R16C:$rA, R16C:$rB))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +0000667
668def SFHIvec:
669 RI10Form<0b10110000, (outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
670 "sfhi\t$rT, $rA, $val", IntegerOp,
671 [(set (v8i16 VECREG:$rT), (sub v8i16SExt10Imm:$val,
672 (v8i16 VECREG:$rA)))]>;
673
674def SFHIr16 : RI10Form<0b10110000, (outs R16C:$rT), (ins R16C:$rA, s10imm:$val),
675 "sfhi\t$rT, $rA, $val", IntegerOp,
676 [(set R16C:$rT, (sub i16ImmSExt10:$val, R16C:$rA))]>;
677
678def SFvec : RRForm<0b00000010000, (outs VECREG:$rT),
679 (ins VECREG:$rA, VECREG:$rB),
680 "sf\t$rT, $rA, $rB", IntegerOp,
681 [(set (v4i32 VECREG:$rT), (sub (v4i32 VECREG:$rA), (v4i32 VECREG:$rB)))]>;
682
683def SFr32 : RRForm<0b00000010000, (outs R32C:$rT), (ins R32C:$rA, R32C:$rB),
684 "sf\t$rT, $rA, $rB", IntegerOp,
685 [(set R32C:$rT, (sub R32C:$rA, R32C:$rB))]>;
686
687def SFIvec:
688 RI10Form<0b00110000, (outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
689 "sfi\t$rT, $rA, $val", IntegerOp,
690 [(set (v4i32 VECREG:$rT), (sub v4i32SExt10Imm:$val,
691 (v4i32 VECREG:$rA)))]>;
692
693def SFIr32 : RI10Form<0b00110000, (outs R32C:$rT),
694 (ins R32C:$rA, s10imm_i32:$val),
695 "sfi\t$rT, $rA, $val", IntegerOp,
696 [(set R32C:$rT, (sub i32ImmSExt10:$val, R32C:$rA))]>;
697
698// ADDX: only available in vector form, doesn't match a pattern.
Scott Michel67224b22008-06-02 22:18:03 +0000699class ADDXInst<dag OOL, dag IOL, list<dag> pattern>:
700 RRForm<0b00000010110, OOL, IOL,
701 "addx\t$rT, $rA, $rB",
702 IntegerOp, pattern>;
703
704class ADDXVecInst<ValueType vectype>:
705 ADDXInst<(outs VECREG:$rT),
706 (ins VECREG:$rA, VECREG:$rB, VECREG:$rCarry),
Scott Michel750b93f2009-01-15 04:41:47 +0000707 [/* no pattern */]>,
Scott Michel8b6b4202007-12-04 22:35:58 +0000708 RegConstraint<"$rCarry = $rT">,
709 NoEncode<"$rCarry">;
710
Scott Michel67224b22008-06-02 22:18:03 +0000711class ADDXRegInst<RegisterClass rclass>:
712 ADDXInst<(outs rclass:$rT),
713 (ins rclass:$rA, rclass:$rB, rclass:$rCarry),
Scott Michel750b93f2009-01-15 04:41:47 +0000714 [/* no pattern */]>,
Scott Michel8b6b4202007-12-04 22:35:58 +0000715 RegConstraint<"$rCarry = $rT">,
716 NoEncode<"$rCarry">;
717
Scott Michel67224b22008-06-02 22:18:03 +0000718multiclass AddExtended {
719 def v2i64 : ADDXVecInst<v2i64>;
720 def v4i32 : ADDXVecInst<v4i32>;
721 def r64 : ADDXRegInst<R64C>;
722 def r32 : ADDXRegInst<R32C>;
723}
724
725defm ADDX : AddExtended;
726
727// CG: Generate carry for add
728class CGInst<dag OOL, dag IOL, list<dag> pattern>:
729 RRForm<0b01000011000, OOL, IOL,
730 "cg\t$rT, $rA, $rB",
731 IntegerOp, pattern>;
732
733class CGVecInst<ValueType vectype>:
734 CGInst<(outs VECREG:$rT),
735 (ins VECREG:$rA, VECREG:$rB),
Scott Michel750b93f2009-01-15 04:41:47 +0000736 [/* no pattern */]>;
Scott Michel67224b22008-06-02 22:18:03 +0000737
738class CGRegInst<RegisterClass rclass>:
739 CGInst<(outs rclass:$rT),
740 (ins rclass:$rA, rclass:$rB),
Scott Michel750b93f2009-01-15 04:41:47 +0000741 [/* no pattern */]>;
Scott Michel67224b22008-06-02 22:18:03 +0000742
743multiclass CarryGenerate {
744 def v2i64 : CGVecInst<v2i64>;
745 def v4i32 : CGVecInst<v4i32>;
746 def r64 : CGRegInst<R64C>;
747 def r32 : CGRegInst<R32C>;
748}
749
750defm CG : CarryGenerate;
751
752// SFX: Subract from, extended. This is used in conjunction with BG to subtract
753// with carry (borrow, in this case)
754class SFXInst<dag OOL, dag IOL, list<dag> pattern>:
755 RRForm<0b10000010110, OOL, IOL,
756 "sfx\t$rT, $rA, $rB",
757 IntegerOp, pattern>;
758
759class SFXVecInst<ValueType vectype>:
760 SFXInst<(outs VECREG:$rT),
761 (ins VECREG:$rA, VECREG:$rB, VECREG:$rCarry),
Scott Michel750b93f2009-01-15 04:41:47 +0000762 [/* no pattern */]>,
Scott Michel8b6b4202007-12-04 22:35:58 +0000763 RegConstraint<"$rCarry = $rT">,
764 NoEncode<"$rCarry">;
765
Scott Michel67224b22008-06-02 22:18:03 +0000766class SFXRegInst<RegisterClass rclass>:
767 SFXInst<(outs rclass:$rT),
768 (ins rclass:$rA, rclass:$rB, rclass:$rCarry),
Scott Michel750b93f2009-01-15 04:41:47 +0000769 [/* no pattern */]>,
Scott Michel67224b22008-06-02 22:18:03 +0000770 RegConstraint<"$rCarry = $rT">,
771 NoEncode<"$rCarry">;
772
773multiclass SubtractExtended {
774 def v2i64 : SFXVecInst<v2i64>;
775 def v4i32 : SFXVecInst<v4i32>;
776 def r64 : SFXRegInst<R64C>;
777 def r32 : SFXRegInst<R32C>;
778}
779
780defm SFX : SubtractExtended;
781
Scott Michel8b6b4202007-12-04 22:35:58 +0000782// BG: only available in vector form, doesn't match a pattern.
Scott Michel67224b22008-06-02 22:18:03 +0000783class BGInst<dag OOL, dag IOL, list<dag> pattern>:
784 RRForm<0b01000010000, OOL, IOL,
785 "bg\t$rT, $rA, $rB",
786 IntegerOp, pattern>;
Scott Michel8b6b4202007-12-04 22:35:58 +0000787
Scott Michel67224b22008-06-02 22:18:03 +0000788class BGVecInst<ValueType vectype>:
789 BGInst<(outs VECREG:$rT),
790 (ins VECREG:$rA, VECREG:$rB),
Scott Michel750b93f2009-01-15 04:41:47 +0000791 [/* no pattern */]>;
Scott Michel67224b22008-06-02 22:18:03 +0000792
793class BGRegInst<RegisterClass rclass>:
794 BGInst<(outs rclass:$rT),
795 (ins rclass:$rA, rclass:$rB),
Scott Michel750b93f2009-01-15 04:41:47 +0000796 [/* no pattern */]>;
Scott Michel67224b22008-06-02 22:18:03 +0000797
798multiclass BorrowGenerate {
799 def v4i32 : BGVecInst<v4i32>;
800 def v2i64 : BGVecInst<v2i64>;
801 def r64 : BGRegInst<R64C>;
802 def r32 : BGRegInst<R32C>;
803}
804
805defm BG : BorrowGenerate;
806
807// BGX: Borrow generate, extended.
Scott Michel8b6b4202007-12-04 22:35:58 +0000808def BGXvec:
809 RRForm<0b11000010110, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB,
Scott Michel06eabde2008-12-27 04:51:36 +0000810 VECREG:$rCarry),
Scott Michel8b6b4202007-12-04 22:35:58 +0000811 "bgx\t$rT, $rA, $rB", IntegerOp,
812 []>,
813 RegConstraint<"$rCarry = $rT">,
814 NoEncode<"$rCarry">;
815
816// Halfword multiply variants:
817// N.B: These can be used to build up larger quantities (16x16 -> 32)
818
819def MPYv8i16:
820 RRForm<0b00100011110, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
821 "mpy\t$rT, $rA, $rB", IntegerMulDiv,
Scott Michel4d07fb72008-12-30 23:28:25 +0000822 [/* no pattern */]>;
Scott Michel8b6b4202007-12-04 22:35:58 +0000823
824def MPYr16:
825 RRForm<0b00100011110, (outs R16C:$rT), (ins R16C:$rA, R16C:$rB),
826 "mpy\t$rT, $rA, $rB", IntegerMulDiv,
827 [(set R16C:$rT, (mul R16C:$rA, R16C:$rB))]>;
828
Scott Michelae5cbf52008-12-29 03:23:36 +0000829// Unsigned 16-bit multiply:
830
831class MPYUInst<dag OOL, dag IOL, list<dag> pattern>:
832 RRForm<0b00110011110, OOL, IOL,
833 "mpyu\t$rT, $rA, $rB", IntegerMulDiv,
834 pattern>;
835
Scott Michel8b6b4202007-12-04 22:35:58 +0000836def MPYUv4i32:
Scott Michelae5cbf52008-12-29 03:23:36 +0000837 MPYUInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
Scott Michel4d07fb72008-12-30 23:28:25 +0000838 [/* no pattern */]>;
Scott Michel8b6b4202007-12-04 22:35:58 +0000839
840def MPYUr16:
Scott Michelae5cbf52008-12-29 03:23:36 +0000841 MPYUInst<(outs R32C:$rT), (ins R16C:$rA, R16C:$rB),
842 [(set R32C:$rT, (mul (zext R16C:$rA), (zext R16C:$rB)))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +0000843
844def MPYUr32:
Scott Michelae5cbf52008-12-29 03:23:36 +0000845 MPYUInst<(outs R32C:$rT), (ins R32C:$rA, R32C:$rB),
Scott Michel4d07fb72008-12-30 23:28:25 +0000846 [/* no pattern */]>;
Scott Michel8b6b4202007-12-04 22:35:58 +0000847
Scott Michelae5cbf52008-12-29 03:23:36 +0000848// mpyi: multiply 16 x s10imm -> 32 result.
849
850class MPYIInst<dag OOL, dag IOL, list<dag> pattern>:
851 RI10Form<0b00101110, OOL, IOL,
Scott Michel8b6b4202007-12-04 22:35:58 +0000852 "mpyi\t$rT, $rA, $val", IntegerMulDiv,
Scott Michelae5cbf52008-12-29 03:23:36 +0000853 pattern>;
854
855def MPYIvec:
856 MPYIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
857 [(set (v8i16 VECREG:$rT),
858 (mul (v8i16 VECREG:$rA), v8i16SExt10Imm:$val))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +0000859
860def MPYIr16:
Scott Michelae5cbf52008-12-29 03:23:36 +0000861 MPYIInst<(outs R16C:$rT), (ins R16C:$rA, s10imm:$val),
862 [(set R16C:$rT, (mul R16C:$rA, i16ImmSExt10:$val))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +0000863
864// mpyui: same issues as other multiplies, plus, this doesn't match a
865// pattern... but may be used during target DAG selection or lowering
Scott Michelae5cbf52008-12-29 03:23:36 +0000866
867class MPYUIInst<dag OOL, dag IOL, list<dag> pattern>:
868 RI10Form<0b10101110, OOL, IOL,
869 "mpyui\t$rT, $rA, $val", IntegerMulDiv,
870 pattern>;
871
Scott Michel8b6b4202007-12-04 22:35:58 +0000872def MPYUIvec:
Scott Michelae5cbf52008-12-29 03:23:36 +0000873 MPYUIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
874 []>;
Scott Michel8b6b4202007-12-04 22:35:58 +0000875
876def MPYUIr16:
Scott Michelae5cbf52008-12-29 03:23:36 +0000877 MPYUIInst<(outs R16C:$rT), (ins R16C:$rA, s10imm:$val),
878 []>;
Scott Michel8b6b4202007-12-04 22:35:58 +0000879
880// mpya: 16 x 16 + 16 -> 32 bit result
Scott Michelae5cbf52008-12-29 03:23:36 +0000881class MPYAInst<dag OOL, dag IOL, list<dag> pattern>:
882 RRRForm<0b0011, OOL, IOL,
883 "mpya\t$rT, $rA, $rB, $rC", IntegerMulDiv,
884 pattern>;
885
Scott Michel750b93f2009-01-15 04:41:47 +0000886def MPYAv4i32:
Scott Michelae5cbf52008-12-29 03:23:36 +0000887 MPYAInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB, VECREG:$rC),
888 [(set (v4i32 VECREG:$rT),
889 (add (v4i32 (bitconvert (mul (v8i16 VECREG:$rA),
890 (v8i16 VECREG:$rB)))),
891 (v4i32 VECREG:$rC)))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +0000892
893def MPYAr32:
Scott Michelae5cbf52008-12-29 03:23:36 +0000894 MPYAInst<(outs R32C:$rT), (ins R16C:$rA, R16C:$rB, R32C:$rC),
895 [(set R32C:$rT, (add (sext (mul R16C:$rA, R16C:$rB)),
896 R32C:$rC))]>;
897
898def MPYAr32_sext:
899 MPYAInst<(outs R32C:$rT), (ins R16C:$rA, R16C:$rB, R32C:$rC),
900 [(set R32C:$rT, (add (mul (sext R16C:$rA), (sext R16C:$rB)),
901 R32C:$rC))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +0000902
903def MPYAr32_sextinreg:
Scott Michelae5cbf52008-12-29 03:23:36 +0000904 MPYAInst<(outs R32C:$rT), (ins R32C:$rA, R32C:$rB, R32C:$rC),
905 [(set R32C:$rT, (add (mul (sext_inreg R32C:$rA, i16),
906 (sext_inreg R32C:$rB, i16)),
907 R32C:$rC))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +0000908
909// mpyh: multiply high, used to synthesize 32-bit multiplies
Scott Michelae5cbf52008-12-29 03:23:36 +0000910class MPYHInst<dag OOL, dag IOL, list<dag> pattern>:
911 RRForm<0b10100011110, OOL, IOL,
912 "mpyh\t$rT, $rA, $rB", IntegerMulDiv,
913 pattern>;
914
Scott Michel8b6b4202007-12-04 22:35:58 +0000915def MPYHv4i32:
Scott Michelae5cbf52008-12-29 03:23:36 +0000916 MPYHInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
Scott Michel4d07fb72008-12-30 23:28:25 +0000917 [/* no pattern */]>;
Scott Michel8b6b4202007-12-04 22:35:58 +0000918
919def MPYHr32:
Scott Michelae5cbf52008-12-29 03:23:36 +0000920 MPYHInst<(outs R32C:$rT), (ins R32C:$rA, R32C:$rB),
Scott Michel4d07fb72008-12-30 23:28:25 +0000921 [/* no pattern */]>;
Scott Michel8b6b4202007-12-04 22:35:58 +0000922
923// mpys: multiply high and shift right (returns the top half of
924// a 16-bit multiply, sign extended to 32 bits.)
Scott Michel8b6b4202007-12-04 22:35:58 +0000925
Scott Michel4d07fb72008-12-30 23:28:25 +0000926class MPYSInst<dag OOL, dag IOL>:
927 RRForm<0b11100011110, OOL, IOL,
Scott Michel8b6b4202007-12-04 22:35:58 +0000928 "mpys\t$rT, $rA, $rB", IntegerMulDiv,
Scott Michel4d07fb72008-12-30 23:28:25 +0000929 [/* no pattern */]>;
930
Scott Michel750b93f2009-01-15 04:41:47 +0000931def MPYSv4i32:
Scott Michel4d07fb72008-12-30 23:28:25 +0000932 MPYSInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB)>;
933
934def MPYSr16:
935 MPYSInst<(outs R32C:$rT), (ins R16C:$rA, R16C:$rB)>;
Scott Michel8b6b4202007-12-04 22:35:58 +0000936
937// mpyhh: multiply high-high (returns the 32-bit result from multiplying
938// the top 16 bits of the $rA, $rB)
Scott Michel4d07fb72008-12-30 23:28:25 +0000939
940class MPYHHInst<dag OOL, dag IOL>:
941 RRForm<0b01100011110, OOL, IOL,
942 "mpyhh\t$rT, $rA, $rB", IntegerMulDiv,
943 [/* no pattern */]>;
944
Scott Michel8b6b4202007-12-04 22:35:58 +0000945def MPYHHv8i16:
Scott Michel4d07fb72008-12-30 23:28:25 +0000946 MPYHHInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB)>;
Scott Michel8b6b4202007-12-04 22:35:58 +0000947
948def MPYHHr32:
Scott Michel4d07fb72008-12-30 23:28:25 +0000949 MPYHHInst<(outs R32C:$rT), (ins R32C:$rA, R32C:$rB)>;
Scott Michel8b6b4202007-12-04 22:35:58 +0000950
951// mpyhha: Multiply high-high, add to $rT:
Scott Michel8b6b4202007-12-04 22:35:58 +0000952
Scott Michel4d07fb72008-12-30 23:28:25 +0000953class MPYHHAInst<dag OOL, dag IOL>:
954 RRForm<0b01100010110, OOL, IOL,
Scott Michel8b6b4202007-12-04 22:35:58 +0000955 "mpyhha\t$rT, $rA, $rB", IntegerMulDiv,
Scott Michel4d07fb72008-12-30 23:28:25 +0000956 [/* no pattern */]>;
957
958def MPYHHAvec:
959 MPYHHAInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB)>;
960
961def MPYHHAr32:
962 MPYHHAInst<(outs R32C:$rT), (ins R32C:$rA, R32C:$rB)>;
Scott Michel8b6b4202007-12-04 22:35:58 +0000963
Scott Michel750b93f2009-01-15 04:41:47 +0000964// mpyhhu: Multiply high-high, unsigned, e.g.:
965//
966// +-------+-------+ +-------+-------+ +---------+
967// | a0 . a1 | x | b0 . b1 | = | a0 x b0 |
968// +-------+-------+ +-------+-------+ +---------+
969//
970// where a0, b0 are the upper 16 bits of the 32-bit word
Scott Michel8b6b4202007-12-04 22:35:58 +0000971
Scott Michel4d07fb72008-12-30 23:28:25 +0000972class MPYHHUInst<dag OOL, dag IOL>:
973 RRForm<0b01110011110, OOL, IOL,
Scott Michel8b6b4202007-12-04 22:35:58 +0000974 "mpyhhu\t$rT, $rA, $rB", IntegerMulDiv,
Scott Michel4d07fb72008-12-30 23:28:25 +0000975 [/* no pattern */]>;
976
Scott Michel750b93f2009-01-15 04:41:47 +0000977def MPYHHUv4i32:
Scott Michel4d07fb72008-12-30 23:28:25 +0000978 MPYHHUInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB)>;
979
980def MPYHHUr32:
981 MPYHHUInst<(outs R32C:$rT), (ins R32C:$rA, R32C:$rB)>;
Scott Michel8b6b4202007-12-04 22:35:58 +0000982
983// mpyhhau: Multiply high-high, unsigned
Scott Michel4d07fb72008-12-30 23:28:25 +0000984
985class MPYHHAUInst<dag OOL, dag IOL>:
986 RRForm<0b01110010110, OOL, IOL,
987 "mpyhhau\t$rT, $rA, $rB", IntegerMulDiv,
988 [/* no pattern */]>;
989
Scott Michel8b6b4202007-12-04 22:35:58 +0000990def MPYHHAUvec:
Scott Michel4d07fb72008-12-30 23:28:25 +0000991 MPYHHAUInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB)>;
992
Scott Michel8b6b4202007-12-04 22:35:58 +0000993def MPYHHAUr32:
Scott Michel4d07fb72008-12-30 23:28:25 +0000994 MPYHHAUInst<(outs R32C:$rT), (ins R32C:$rA, R32C:$rB)>;
Scott Michelae5cbf52008-12-29 03:23:36 +0000995
996//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
Scott Michel8b6b4202007-12-04 22:35:58 +0000997// clz: Count leading zeroes
Scott Michelae5cbf52008-12-29 03:23:36 +0000998//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
Scott Michel06eabde2008-12-27 04:51:36 +0000999class CLZInst<dag OOL, dag IOL, list<dag> pattern>:
1000 RRForm_1<0b10100101010, OOL, IOL, "clz\t$rT, $rA",
1001 IntegerOp, pattern>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001002
Scott Michel06eabde2008-12-27 04:51:36 +00001003class CLZRegInst<RegisterClass rclass>:
1004 CLZInst<(outs rclass:$rT), (ins rclass:$rA),
Scott Michel4d07fb72008-12-30 23:28:25 +00001005 [(set rclass:$rT, (ctlz rclass:$rA))]>;
Scott Michel06eabde2008-12-27 04:51:36 +00001006
1007class CLZVecInst<ValueType vectype>:
1008 CLZInst<(outs VECREG:$rT), (ins VECREG:$rA),
1009 [(set (vectype VECREG:$rT), (ctlz (vectype VECREG:$rA)))]>;
1010
1011multiclass CountLeadingZeroes {
1012 def v4i32 : CLZVecInst<v4i32>;
1013 def r32 : CLZRegInst<R32C>;
1014}
1015
1016defm CLZ : CountLeadingZeroes;
Scott Michel8b6b4202007-12-04 22:35:58 +00001017
1018// cntb: Count ones in bytes (aka "population count")
Scott Michel06eabde2008-12-27 04:51:36 +00001019//
Scott Michel8b6b4202007-12-04 22:35:58 +00001020// NOTE: This instruction is really a vector instruction, but the custom
1021// lowering code uses it in unorthodox ways to support CTPOP for other
1022// data types!
Scott Michel06eabde2008-12-27 04:51:36 +00001023
Scott Michel8b6b4202007-12-04 22:35:58 +00001024def CNTBv16i8:
1025 RRForm_1<0b00101101010, (outs VECREG:$rT), (ins VECREG:$rA),
1026 "cntb\t$rT, $rA", IntegerOp,
Scott Michel67224b22008-06-02 22:18:03 +00001027 [(set (v16i8 VECREG:$rT), (SPUcntb (v16i8 VECREG:$rA)))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001028
1029def CNTBv8i16 :
1030 RRForm_1<0b00101101010, (outs VECREG:$rT), (ins VECREG:$rA),
1031 "cntb\t$rT, $rA", IntegerOp,
Scott Michel67224b22008-06-02 22:18:03 +00001032 [(set (v8i16 VECREG:$rT), (SPUcntb (v8i16 VECREG:$rA)))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001033
1034def CNTBv4i32 :
1035 RRForm_1<0b00101101010, (outs VECREG:$rT), (ins VECREG:$rA),
1036 "cntb\t$rT, $rA", IntegerOp,
Scott Michel67224b22008-06-02 22:18:03 +00001037 [(set (v4i32 VECREG:$rT), (SPUcntb (v4i32 VECREG:$rA)))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001038
Scott Michel06eabde2008-12-27 04:51:36 +00001039// gbb: Gather the low order bits from each byte in $rA into a single 16-bit
1040// quantity stored into $rT's slot 0, upper 16 bits are zeroed, as are
1041// slots 1-3.
1042//
1043// Note: This instruction "pairs" with the fsmb instruction for all of the
1044// various types defined here.
1045//
1046// Note 2: The "VecInst" and "RegInst" forms refer to the result being either
1047// a vector or register.
1048
1049class GBBInst<dag OOL, dag IOL, list<dag> pattern>:
1050 RRForm_1<0b01001101100, OOL, IOL, "gbb\t$rT, $rA", GatherOp, pattern>;
1051
1052class GBBRegInst<RegisterClass rclass, ValueType vectype>:
1053 GBBInst<(outs rclass:$rT), (ins VECREG:$rA),
Scott Michel70741542009-01-06 23:10:38 +00001054 [/* no pattern */]>;
Scott Michel06eabde2008-12-27 04:51:36 +00001055
1056class GBBVecInst<ValueType vectype>:
1057 GBBInst<(outs VECREG:$rT), (ins VECREG:$rA),
Scott Michel70741542009-01-06 23:10:38 +00001058 [/* no pattern */]>;
Scott Michel06eabde2008-12-27 04:51:36 +00001059
1060multiclass GatherBitsFromBytes {
1061 def v16i8_r32: GBBRegInst<R32C, v16i8>;
1062 def v16i8_r16: GBBRegInst<R16C, v16i8>;
1063 def v16i8: GBBVecInst<v16i8>;
1064}
1065
1066defm GBB: GatherBitsFromBytes;
Scott Michel8b6b4202007-12-04 22:35:58 +00001067
1068// gbh: Gather all low order bits from each halfword in $rA into a single
Scott Michel06eabde2008-12-27 04:51:36 +00001069// 8-bit quantity stored in $rT's slot 0, with the upper bits of $rT set to 0
1070// and slots 1-3 also set to 0.
1071//
1072// See notes for GBBInst, above.
1073
1074class GBHInst<dag OOL, dag IOL, list<dag> pattern>:
1075 RRForm_1<0b10001101100, OOL, IOL, "gbh\t$rT, $rA", GatherOp,
1076 pattern>;
1077
1078class GBHRegInst<RegisterClass rclass, ValueType vectype>:
1079 GBHInst<(outs rclass:$rT), (ins VECREG:$rA),
Scott Michel70741542009-01-06 23:10:38 +00001080 [/* no pattern */]>;
Scott Michel06eabde2008-12-27 04:51:36 +00001081
1082class GBHVecInst<ValueType vectype>:
1083 GBHInst<(outs VECREG:$rT), (ins VECREG:$rA),
Scott Michel70741542009-01-06 23:10:38 +00001084 [/* no pattern */]>;
Scott Michel06eabde2008-12-27 04:51:36 +00001085
1086multiclass GatherBitsHalfword {
1087 def v8i16_r32: GBHRegInst<R32C, v8i16>;
1088 def v8i16_r16: GBHRegInst<R16C, v8i16>;
1089 def v8i16: GBHVecInst<v8i16>;
1090}
1091
1092defm GBH: GatherBitsHalfword;
Scott Michel8b6b4202007-12-04 22:35:58 +00001093
1094// gb: Gather all low order bits from each word in $rA into a single
Scott Michel06eabde2008-12-27 04:51:36 +00001095// 4-bit quantity stored in $rT's slot 0, upper bits in $rT set to 0,
1096// as well as slots 1-3.
1097//
1098// See notes for gbb, above.
1099
1100class GBInst<dag OOL, dag IOL, list<dag> pattern>:
1101 RRForm_1<0b00001101100, OOL, IOL, "gb\t$rT, $rA", GatherOp,
1102 pattern>;
1103
1104class GBRegInst<RegisterClass rclass, ValueType vectype>:
1105 GBInst<(outs rclass:$rT), (ins VECREG:$rA),
Scott Michel70741542009-01-06 23:10:38 +00001106 [/* no pattern */]>;
Scott Michel06eabde2008-12-27 04:51:36 +00001107
1108class GBVecInst<ValueType vectype>:
1109 GBInst<(outs VECREG:$rT), (ins VECREG:$rA),
Scott Michel70741542009-01-06 23:10:38 +00001110 [/* no pattern */]>;
Scott Michel06eabde2008-12-27 04:51:36 +00001111
1112multiclass GatherBitsWord {
1113 def v4i32_r32: GBRegInst<R32C, v4i32>;
1114 def v4i32_r16: GBRegInst<R16C, v4i32>;
1115 def v4i32: GBVecInst<v4i32>;
1116}
1117
1118defm GB: GatherBitsWord;
Scott Michel8b6b4202007-12-04 22:35:58 +00001119
1120// avgb: average bytes
1121def AVGB:
1122 RRForm<0b11001011000, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1123 "avgb\t$rT, $rA, $rB", ByteOp,
1124 []>;
1125
1126// absdb: absolute difference of bytes
1127def ABSDB:
1128 RRForm<0b11001010000, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1129 "absdb\t$rT, $rA, $rB", ByteOp,
1130 []>;
1131
1132// sumb: sum bytes into halfwords
1133def SUMB:
1134 RRForm<0b11001010010, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1135 "sumb\t$rT, $rA, $rB", ByteOp,
1136 []>;
1137
1138// Sign extension operations:
Scott Michel67224b22008-06-02 22:18:03 +00001139class XSBHInst<dag OOL, dag IOL, list<dag> pattern>:
1140 RRForm_1<0b01101101010, OOL, IOL,
1141 "xsbh\t$rDst, $rSrc",
1142 IntegerOp, pattern>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001143
Scott Michel67224b22008-06-02 22:18:03 +00001144class XSBHVecInst<ValueType vectype>:
1145 XSBHInst<(outs VECREG:$rDst), (ins VECREG:$rSrc),
1146 [(set (v8i16 VECREG:$rDst), (sext (vectype VECREG:$rSrc)))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001147
Scott Michel2ef773a2009-01-06 03:36:14 +00001148class XSBHInRegInst<RegisterClass rclass, list<dag> pattern>:
Scott Michel67224b22008-06-02 22:18:03 +00001149 XSBHInst<(outs rclass:$rDst), (ins rclass:$rSrc),
Scott Michel2ef773a2009-01-06 03:36:14 +00001150 pattern>;
Scott Michel67224b22008-06-02 22:18:03 +00001151
1152multiclass ExtendByteHalfword {
Scott Michel2ef773a2009-01-06 03:36:14 +00001153 def v16i8: XSBHVecInst<v8i16>;
1154 def r8: XSBHInst<(outs R16C:$rDst), (ins R8C:$rSrc),
1155 [(set R16C:$rDst, (sext R8C:$rSrc))]>;
1156 def r16: XSBHInRegInst<R16C,
1157 [(set R16C:$rDst, (sext_inreg R16C:$rSrc, i8))]>;
Scott Michel67224b22008-06-02 22:18:03 +00001158
1159 // 32-bit form for XSBH: used to sign extend 8-bit quantities to 16-bit
1160 // quantities to 32-bit quantities via a 32-bit register (see the sext 8->32
1161 // pattern below). Intentionally doesn't match a pattern because we want the
1162 // sext 8->32 pattern to do the work for us, namely because we need the extra
1163 // XSHWr32.
Scott Michel2ef773a2009-01-06 03:36:14 +00001164 def r32: XSBHInRegInst<R32C, [/* no pattern */]>;
1165
1166 // Same as the 32-bit version, but for i64
1167 def r64: XSBHInRegInst<R64C, [/* no pattern */]>;
Scott Michel67224b22008-06-02 22:18:03 +00001168}
1169
1170defm XSBH : ExtendByteHalfword;
1171
Scott Michel8b6b4202007-12-04 22:35:58 +00001172// Sign extend halfwords to words:
Scott Michel8b6b4202007-12-04 22:35:58 +00001173
Scott Michel2ef773a2009-01-06 03:36:14 +00001174class XSHWInst<dag OOL, dag IOL, list<dag> pattern>:
1175 RRForm_1<0b01101101010, OOL, IOL, "xshw\t$rDest, $rSrc",
1176 IntegerOp, pattern>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001177
Scott Michel2ef773a2009-01-06 03:36:14 +00001178class XSHWVecInst<ValueType in_vectype, ValueType out_vectype>:
1179 XSHWInst<(outs VECREG:$rDest), (ins VECREG:$rSrc),
1180 [(set (out_vectype VECREG:$rDest),
1181 (sext (in_vectype VECREG:$rSrc)))]>;
1182
1183class XSHWInRegInst<RegisterClass rclass, list<dag> pattern>:
1184 XSHWInst<(outs rclass:$rDest), (ins rclass:$rSrc),
1185 pattern>;
1186
1187class XSHWRegInst<RegisterClass rclass>:
1188 XSHWInst<(outs rclass:$rDest), (ins R16C:$rSrc),
1189 [(set rclass:$rDest, (sext R16C:$rSrc))]>;
1190
1191multiclass ExtendHalfwordWord {
1192 def v4i32: XSHWVecInst<v4i32, v8i16>;
1193
1194 def r16: XSHWRegInst<R32C>;
1195
1196 def r32: XSHWInRegInst<R32C,
1197 [(set R32C:$rDest, (sext_inreg R32C:$rSrc, i16))]>;
1198 def r64: XSHWInRegInst<R64C, [/* no pattern */]>;
1199}
1200
1201defm XSHW : ExtendHalfwordWord;
Scott Michel8b6b4202007-12-04 22:35:58 +00001202
Scott Michele0168c12009-01-05 01:34:35 +00001203// Sign-extend words to doublewords (32->64 bits)
Scott Michel8b6b4202007-12-04 22:35:58 +00001204
Scott Michele0168c12009-01-05 01:34:35 +00001205class XSWDInst<dag OOL, dag IOL, list<dag> pattern>:
Scott Michel2ef773a2009-01-06 03:36:14 +00001206 RRForm_1<0b01100101010, OOL, IOL, "xswd\t$rDst, $rSrc",
1207 IntegerOp, pattern>;
Scott Michele0168c12009-01-05 01:34:35 +00001208
1209class XSWDVecInst<ValueType in_vectype, ValueType out_vectype>:
1210 XSWDInst<(outs VECREG:$rDst), (ins VECREG:$rSrc),
1211 [(set (out_vectype VECREG:$rDst),
1212 (sext (out_vectype VECREG:$rSrc)))]>;
1213
1214class XSWDRegInst<RegisterClass in_rclass, RegisterClass out_rclass>:
1215 XSWDInst<(outs out_rclass:$rDst), (ins in_rclass:$rSrc),
1216 [(set out_rclass:$rDst, (sext in_rclass:$rSrc))]>;
1217
1218multiclass ExtendWordToDoubleWord {
1219 def v2i64: XSWDVecInst<v4i32, v2i64>;
1220 def r64: XSWDRegInst<R32C, R64C>;
1221
1222 def r64_inreg: XSWDInst<(outs R64C:$rDst), (ins R64C:$rSrc),
1223 [(set R64C:$rDst, (sext_inreg R64C:$rSrc, i32))]>;
1224}
Scott Michel8b6b4202007-12-04 22:35:58 +00001225
Scott Michele0168c12009-01-05 01:34:35 +00001226defm XSWD : ExtendWordToDoubleWord;
Scott Michel8b6b4202007-12-04 22:35:58 +00001227
1228// AND operations
Scott Michel8b6b4202007-12-04 22:35:58 +00001229
Scott Michel97872d32008-02-23 18:41:37 +00001230class ANDInst<dag OOL, dag IOL, list<dag> pattern> :
1231 RRForm<0b10000011000, OOL, IOL, "and\t$rT, $rA, $rB",
1232 IntegerOp, pattern>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001233
Scott Michel97872d32008-02-23 18:41:37 +00001234class ANDVecInst<ValueType vectype>:
1235 ANDInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1236 [(set (vectype VECREG:$rT), (and (vectype VECREG:$rA),
1237 (vectype VECREG:$rB)))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001238
Scott Michel6baba072008-03-05 23:02:02 +00001239class ANDRegInst<RegisterClass rclass>:
1240 ANDInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB),
1241 [(set rclass:$rT, (and rclass:$rA, rclass:$rB))]>;
1242
Scott Michel97872d32008-02-23 18:41:37 +00001243multiclass BitwiseAnd
1244{
1245 def v16i8: ANDVecInst<v16i8>;
1246 def v8i16: ANDVecInst<v8i16>;
1247 def v4i32: ANDVecInst<v4i32>;
1248 def v2i64: ANDVecInst<v2i64>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001249
Scott Michel6baba072008-03-05 23:02:02 +00001250 def r128: ANDRegInst<GPRC>;
1251 def r64: ANDRegInst<R64C>;
1252 def r32: ANDRegInst<R32C>;
1253 def r16: ANDRegInst<R16C>;
1254 def r8: ANDRegInst<R8C>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001255
Scott Michel97872d32008-02-23 18:41:37 +00001256 //===---------------------------------------------
1257 // Special instructions to perform the fabs instruction
1258 def fabs32: ANDInst<(outs R32FP:$rT), (ins R32FP:$rA, R32C:$rB),
1259 [/* Intentionally does not match a pattern */]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001260
Scott Michel0d5eae02009-03-17 01:15:45 +00001261 def fabs64: ANDInst<(outs R64FP:$rT), (ins R64FP:$rA, R64C:$rB),
pingbak2f387e82009-01-26 03:31:40 +00001262 [/* Intentionally does not match a pattern */]>;
1263
Scott Michel97872d32008-02-23 18:41:37 +00001264 def fabsvec: ANDInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1265 [/* Intentionally does not match a pattern */]>;
1266
1267 //===---------------------------------------------
1268
1269 // Hacked form of AND to zero-extend 16-bit quantities to 32-bit
1270 // quantities -- see 16->32 zext pattern.
1271 //
1272 // This pattern is somewhat artificial, since it might match some
1273 // compiler generated pattern but it is unlikely to do so.
1274
1275 def i16i32: ANDInst<(outs R32C:$rT), (ins R16C:$rA, R32C:$rB),
1276 [(set R32C:$rT, (and (zext R16C:$rA), R32C:$rB))]>;
1277}
1278
1279defm AND : BitwiseAnd;
Scott Michel8b6b4202007-12-04 22:35:58 +00001280
1281// N.B.: vnot_conv is one of those special target selection pattern fragments,
1282// in which we expect there to be a bit_convert on the constant. Bear in mind
1283// that llvm translates "not <reg>" to "xor <reg>, -1" (or in this case, a
1284// constant -1 vector.)
Scott Michel8b6b4202007-12-04 22:35:58 +00001285
Scott Michel97872d32008-02-23 18:41:37 +00001286class ANDCInst<dag OOL, dag IOL, list<dag> pattern>:
1287 RRForm<0b10000011010, OOL, IOL, "andc\t$rT, $rA, $rB",
1288 IntegerOp, pattern>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001289
Scott Michel0d5eae02009-03-17 01:15:45 +00001290class ANDCVecInst<ValueType vectype, PatFrag vnot_frag = vnot>:
Scott Michel97872d32008-02-23 18:41:37 +00001291 ANDCInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
Scott Michel0d5eae02009-03-17 01:15:45 +00001292 [(set (vectype VECREG:$rT),
1293 (and (vectype VECREG:$rA),
1294 (vnot_frag (vectype VECREG:$rB))))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001295
Scott Michel97872d32008-02-23 18:41:37 +00001296class ANDCRegInst<RegisterClass rclass>:
1297 ANDCInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB),
1298 [(set rclass:$rT, (and rclass:$rA, (not rclass:$rB)))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001299
Scott Michel97872d32008-02-23 18:41:37 +00001300multiclass AndComplement
1301{
1302 def v16i8: ANDCVecInst<v16i8>;
1303 def v8i16: ANDCVecInst<v8i16>;
1304 def v4i32: ANDCVecInst<v4i32>;
1305 def v2i64: ANDCVecInst<v2i64>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001306
Scott Michel97872d32008-02-23 18:41:37 +00001307 def r128: ANDCRegInst<GPRC>;
1308 def r64: ANDCRegInst<R64C>;
1309 def r32: ANDCRegInst<R32C>;
1310 def r16: ANDCRegInst<R16C>;
1311 def r8: ANDCRegInst<R8C>;
Scott Michel0d5eae02009-03-17 01:15:45 +00001312
1313 // Sometimes, the xor pattern has a bitcast constant:
1314 def v16i8_conv: ANDCVecInst<v16i8, vnot_conv>;
Scott Michel97872d32008-02-23 18:41:37 +00001315}
Scott Michel438be252007-12-17 22:32:34 +00001316
Scott Michel97872d32008-02-23 18:41:37 +00001317defm ANDC : AndComplement;
Scott Michel8b6b4202007-12-04 22:35:58 +00001318
Scott Michel97872d32008-02-23 18:41:37 +00001319class ANDBIInst<dag OOL, dag IOL, list<dag> pattern>:
1320 RI10Form<0b01101000, OOL, IOL, "andbi\t$rT, $rA, $val",
Scott Michel61895fe2008-12-10 00:15:19 +00001321 ByteOp, pattern>;
Scott Michel438be252007-12-17 22:32:34 +00001322
Scott Michel97872d32008-02-23 18:41:37 +00001323multiclass AndByteImm
1324{
1325 def v16i8: ANDBIInst<(outs VECREG:$rT), (ins VECREG:$rA, u10imm:$val),
1326 [(set (v16i8 VECREG:$rT),
1327 (and (v16i8 VECREG:$rA),
1328 (v16i8 v16i8U8Imm:$val)))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001329
Scott Michel97872d32008-02-23 18:41:37 +00001330 def r8: ANDBIInst<(outs R8C:$rT), (ins R8C:$rA, u10imm_i8:$val),
1331 [(set R8C:$rT, (and R8C:$rA, immU8:$val))]>;
1332}
Scott Michel438be252007-12-17 22:32:34 +00001333
Scott Michel97872d32008-02-23 18:41:37 +00001334defm ANDBI : AndByteImm;
Scott Michel8b6b4202007-12-04 22:35:58 +00001335
Scott Michel97872d32008-02-23 18:41:37 +00001336class ANDHIInst<dag OOL, dag IOL, list<dag> pattern> :
1337 RI10Form<0b10101000, OOL, IOL, "andhi\t$rT, $rA, $val",
Scott Michel61895fe2008-12-10 00:15:19 +00001338 ByteOp, pattern>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001339
Scott Michel97872d32008-02-23 18:41:37 +00001340multiclass AndHalfwordImm
1341{
1342 def v8i16: ANDHIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
1343 [(set (v8i16 VECREG:$rT),
1344 (and (v8i16 VECREG:$rA), v8i16SExt10Imm:$val))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001345
Scott Michel97872d32008-02-23 18:41:37 +00001346 def r16: ANDHIInst<(outs R16C:$rT), (ins R16C:$rA, u10imm:$val),
1347 [(set R16C:$rT, (and R16C:$rA, i16ImmUns10:$val))]>;
Scott Michel438be252007-12-17 22:32:34 +00001348
Scott Michel97872d32008-02-23 18:41:37 +00001349 // Zero-extend i8 to i16:
1350 def i8i16: ANDHIInst<(outs R16C:$rT), (ins R8C:$rA, u10imm:$val),
1351 [(set R16C:$rT, (and (zext R8C:$rA), i16ImmUns10:$val))]>;
1352}
Scott Michel8b6b4202007-12-04 22:35:58 +00001353
Scott Michel97872d32008-02-23 18:41:37 +00001354defm ANDHI : AndHalfwordImm;
1355
1356class ANDIInst<dag OOL, dag IOL, list<dag> pattern> :
1357 RI10Form<0b00101000, OOL, IOL, "andi\t$rT, $rA, $val",
1358 IntegerOp, pattern>;
1359
1360multiclass AndWordImm
1361{
1362 def v4i32: ANDIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
1363 [(set (v4i32 VECREG:$rT),
1364 (and (v4i32 VECREG:$rA), v4i32SExt10Imm:$val))]>;
1365
1366 def r32: ANDIInst<(outs R32C:$rT), (ins R32C:$rA, s10imm_i32:$val),
1367 [(set R32C:$rT, (and R32C:$rA, i32ImmSExt10:$val))]>;
1368
1369 // Hacked form of ANDI to zero-extend i8 quantities to i32. See the zext 8->32
1370 // pattern below.
1371 def i8i32: ANDIInst<(outs R32C:$rT), (ins R8C:$rA, s10imm_i32:$val),
1372 [(set R32C:$rT,
1373 (and (zext R8C:$rA), i32ImmSExt10:$val))]>;
1374
1375 // Hacked form of ANDI to zero-extend i16 quantities to i32. See the
1376 // zext 16->32 pattern below.
1377 //
1378 // Note that this pattern is somewhat artificial, since it might match
1379 // something the compiler generates but is unlikely to occur in practice.
1380 def i16i32: ANDIInst<(outs R32C:$rT), (ins R16C:$rA, s10imm_i32:$val),
1381 [(set R32C:$rT,
1382 (and (zext R16C:$rA), i32ImmSExt10:$val))]>;
1383}
1384
1385defm ANDI : AndWordImm;
1386
1387//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
Scott Michel8b6b4202007-12-04 22:35:58 +00001388// Bitwise OR group:
Scott Michel97872d32008-02-23 18:41:37 +00001389//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
1390
Scott Michel8b6b4202007-12-04 22:35:58 +00001391// Bitwise "or" (N.B.: These are also register-register copy instructions...)
Scott Michel97872d32008-02-23 18:41:37 +00001392class ORInst<dag OOL, dag IOL, list<dag> pattern>:
1393 RRForm<0b10000010000, OOL, IOL, "or\t$rT, $rA, $rB",
1394 IntegerOp, pattern>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001395
Scott Michel97872d32008-02-23 18:41:37 +00001396class ORVecInst<ValueType vectype>:
1397 ORInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1398 [(set (vectype VECREG:$rT), (or (vectype VECREG:$rA),
1399 (vectype VECREG:$rB)))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001400
Scott Michel97872d32008-02-23 18:41:37 +00001401class ORRegInst<RegisterClass rclass>:
1402 ORInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB),
1403 [(set rclass:$rT, (or rclass:$rA, rclass:$rB))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001404
Scott Michel06eabde2008-12-27 04:51:36 +00001405// ORCvtForm: OR conversion form
1406//
1407// This is used to "convert" the preferred slot to its vector equivalent, as
1408// well as convert a vector back to its preferred slot.
1409//
1410// These are effectively no-ops, but need to exist for proper type conversion
1411// and type coercion.
1412
Scott Michel8c67fa42009-01-21 04:58:48 +00001413class ORCvtForm<dag OOL, dag IOL, list<dag> pattern = [/* no pattern */]>
Scott Michel06eabde2008-12-27 04:51:36 +00001414 : SPUInstr<OOL, IOL, "or\t$rT, $rA, $rA", IntegerOp> {
1415 bits<7> RA;
1416 bits<7> RT;
1417
Scott Michel8c67fa42009-01-21 04:58:48 +00001418 let Pattern = pattern;
Scott Michel06eabde2008-12-27 04:51:36 +00001419
1420 let Inst{0-10} = 0b10000010000;
1421 let Inst{11-17} = RA;
1422 let Inst{18-24} = RA;
1423 let Inst{25-31} = RT;
1424}
1425
Scott Michel97872d32008-02-23 18:41:37 +00001426class ORPromoteScalar<RegisterClass rclass>:
Scott Michel06eabde2008-12-27 04:51:36 +00001427 ORCvtForm<(outs VECREG:$rT), (ins rclass:$rA)>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001428
Scott Michel97872d32008-02-23 18:41:37 +00001429class ORExtractElt<RegisterClass rclass>:
Scott Michel06eabde2008-12-27 04:51:36 +00001430 ORCvtForm<(outs rclass:$rT), (ins VECREG:$rA)>;
1431
Scott Michel8c67fa42009-01-21 04:58:48 +00001432/* class ORCvtRegGPRC<RegisterClass rclass>:
1433 ORCvtForm<(outs GPRC:$rT), (ins rclass:$rA)>; */
Scott Michel06eabde2008-12-27 04:51:36 +00001434
Scott Michel8c67fa42009-01-21 04:58:48 +00001435/* class ORCvtGPRCReg<RegisterClass rclass>:
1436 ORCvtForm<(outs rclass:$rT), (ins GPRC:$rA)>; */
Scott Michel2ef773a2009-01-06 03:36:14 +00001437
Scott Michel8c67fa42009-01-21 04:58:48 +00001438class ORCvtFormR32Reg<RegisterClass rclass, list<dag> pattern = [ ]>:
1439 ORCvtForm<(outs rclass:$rT), (ins R32C:$rA), pattern>;
Scott Michel2ef773a2009-01-06 03:36:14 +00001440
Scott Michel8c67fa42009-01-21 04:58:48 +00001441class ORCvtFormRegR32<RegisterClass rclass, list<dag> pattern = [ ]>:
1442 ORCvtForm<(outs R32C:$rT), (ins rclass:$rA), pattern>;
Scott Michel2ef773a2009-01-06 03:36:14 +00001443
Scott Michel8c67fa42009-01-21 04:58:48 +00001444class ORCvtFormR64Reg<RegisterClass rclass, list<dag> pattern = [ ]>:
1445 ORCvtForm<(outs rclass:$rT), (ins R64C:$rA), pattern>;
Scott Michel2ef773a2009-01-06 03:36:14 +00001446
Scott Michel8c67fa42009-01-21 04:58:48 +00001447class ORCvtFormRegR64<RegisterClass rclass, list<dag> pattern = [ ]>:
1448 ORCvtForm<(outs R64C:$rT), (ins rclass:$rA), pattern>;
Scott Michel06eabde2008-12-27 04:51:36 +00001449
Scott Michel34712c32009-03-16 18:47:25 +00001450class ORCvtGPRCVec:
1451 ORCvtForm<(outs VECREG:$rT), (ins GPRC:$rA)>;
1452
1453class ORCvtVecGPRC:
1454 ORCvtForm<(outs GPRC:$rT), (ins VECREG:$rA)>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001455
Scott Michel97872d32008-02-23 18:41:37 +00001456multiclass BitwiseOr
1457{
1458 def v16i8: ORVecInst<v16i8>;
1459 def v8i16: ORVecInst<v8i16>;
1460 def v4i32: ORVecInst<v4i32>;
1461 def v2i64: ORVecInst<v2i64>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001462
Scott Michel97872d32008-02-23 18:41:37 +00001463 def v4f32: ORInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1464 [(set (v4f32 VECREG:$rT),
1465 (v4f32 (bitconvert (or (v4i32 VECREG:$rA),
1466 (v4i32 VECREG:$rB)))))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001467
Scott Michel97872d32008-02-23 18:41:37 +00001468 def v2f64: ORInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
Scott Michel06eabde2008-12-27 04:51:36 +00001469 [(set (v2f64 VECREG:$rT),
Scott Michel97872d32008-02-23 18:41:37 +00001470 (v2f64 (bitconvert (or (v2i64 VECREG:$rA),
1471 (v2i64 VECREG:$rB)))))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001472
Scott Michel8c67fa42009-01-21 04:58:48 +00001473 def r128: ORRegInst<GPRC>;
1474 def r64: ORRegInst<R64C>;
1475 def r32: ORRegInst<R32C>;
1476 def r16: ORRegInst<R16C>;
1477 def r8: ORRegInst<R8C>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001478
Scott Michel97872d32008-02-23 18:41:37 +00001479 // OR instructions used to copy f32 and f64 registers.
1480 def f32: ORInst<(outs R32FP:$rT), (ins R32FP:$rA, R32FP:$rB),
1481 [/* no pattern */]>;
Scott Michel438be252007-12-17 22:32:34 +00001482
Scott Michel97872d32008-02-23 18:41:37 +00001483 def f64: ORInst<(outs R64FP:$rT), (ins R64FP:$rA, R64FP:$rB),
1484 [/* no pattern */]>;
Scott Michel754d8662007-12-20 00:44:13 +00001485
Scott Michel0d5eae02009-03-17 01:15:45 +00001486 // OR instructions used to negate f32 and f64 quantities.
1487
1488 def fneg32: ORInst<(outs R32FP:$rT), (ins R32FP:$rA, R32C:$rB),
1489 [/* no pattern */]>;
1490
1491 def fneg64: ORInst<(outs R64FP:$rT), (ins R64FP:$rA, R64C:$rB),
1492 [/* no pattern */]>;
1493
1494 def fnegvec: ORInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1495 [/* no pattern, see fneg{32,64} */]>;
1496
Scott Michel4d07fb72008-12-30 23:28:25 +00001497 // scalar->vector promotion, prefslot2vec:
Scott Michel97872d32008-02-23 18:41:37 +00001498 def v16i8_i8: ORPromoteScalar<R8C>;
1499 def v8i16_i16: ORPromoteScalar<R16C>;
1500 def v4i32_i32: ORPromoteScalar<R32C>;
1501 def v2i64_i64: ORPromoteScalar<R64C>;
1502 def v4f32_f32: ORPromoteScalar<R32FP>;
1503 def v2f64_f64: ORPromoteScalar<R64FP>;
Scott Michel754d8662007-12-20 00:44:13 +00001504
Scott Michel4d07fb72008-12-30 23:28:25 +00001505 // vector->scalar demotion, vec2prefslot:
Scott Michel97872d32008-02-23 18:41:37 +00001506 def i8_v16i8: ORExtractElt<R8C>;
1507 def i16_v8i16: ORExtractElt<R16C>;
1508 def i32_v4i32: ORExtractElt<R32C>;
1509 def i64_v2i64: ORExtractElt<R64C>;
1510 def f32_v4f32: ORExtractElt<R32FP>;
1511 def f64_v2f64: ORExtractElt<R64FP>;
Scott Michel06eabde2008-12-27 04:51:36 +00001512
Scott Michel34712c32009-03-16 18:47:25 +00001513 // Conversion from vector to GPRC
1514 def i128_vec: ORCvtVecGPRC;
1515
1516 // Conversion from GPRC to vector
1517 def vec_i128: ORCvtGPRCVec;
1518
Scott Michel8c67fa42009-01-21 04:58:48 +00001519/*
Scott Michel34712c32009-03-16 18:47:25 +00001520 // Conversion from register to GPRC
Scott Michel06eabde2008-12-27 04:51:36 +00001521 def i128_r64: ORCvtRegGPRC<R64C>;
1522 def i128_f64: ORCvtRegGPRC<R64FP>;
1523 def i128_r32: ORCvtRegGPRC<R32C>;
1524 def i128_f32: ORCvtRegGPRC<R32FP>;
1525 def i128_r16: ORCvtRegGPRC<R16C>;
1526 def i128_r8: ORCvtRegGPRC<R8C>;
1527
Scott Michel34712c32009-03-16 18:47:25 +00001528 // Conversion from GPRC to register
Scott Michel06eabde2008-12-27 04:51:36 +00001529 def r64_i128: ORCvtGPRCReg<R64C>;
1530 def f64_i128: ORCvtGPRCReg<R64FP>;
1531 def r32_i128: ORCvtGPRCReg<R32C>;
1532 def f32_i128: ORCvtGPRCReg<R32FP>;
1533 def r16_i128: ORCvtGPRCReg<R16C>;
1534 def r8_i128: ORCvtGPRCReg<R8C>;
Scott Michel8c67fa42009-01-21 04:58:48 +00001535*/
1536/*
Scott Michel2ef773a2009-01-06 03:36:14 +00001537 // Conversion from register to R32C:
Scott Michel34712c32009-03-16 18:47:25 +00001538 def r32_r16: ORCvtFormRegR32<R16C>;
1539 def r32_r8: ORCvtFormRegR32<R8C>;
Scott Michel2ef773a2009-01-06 03:36:14 +00001540
1541 // Conversion from R32C to register
1542 def r32_r16: ORCvtFormR32Reg<R16C>;
1543 def r32_r8: ORCvtFormR32Reg<R8C>;
Scott Michel8c67fa42009-01-21 04:58:48 +00001544*/
pingbak2f387e82009-01-26 03:31:40 +00001545
Scott Michel34712c32009-03-16 18:47:25 +00001546 // Conversion from R64C to register:
pingbak2f387e82009-01-26 03:31:40 +00001547 def r32_r64: ORCvtFormR64Reg<R32C>;
1548 // def r16_r64: ORCvtFormR64Reg<R16C>;
1549 // def r8_r64: ORCvtFormR64Reg<R8C>;
1550
Scott Michel34712c32009-03-16 18:47:25 +00001551 // Conversion to R64C from register:
pingbak2f387e82009-01-26 03:31:40 +00001552 def r64_r32: ORCvtFormRegR64<R32C>;
1553 // def r64_r16: ORCvtFormRegR64<R16C>;
1554 // def r64_r8: ORCvtFormRegR64<R8C>;
Scott Michel8c67fa42009-01-21 04:58:48 +00001555
1556 // bitconvert patterns:
1557 def r32_f32: ORCvtFormR32Reg<R32FP,
1558 [(set R32FP:$rT, (bitconvert R32C:$rA))]>;
1559 def f32_r32: ORCvtFormRegR32<R32FP,
1560 [(set R32C:$rT, (bitconvert R32FP:$rA))]>;
1561
1562 def r64_f64: ORCvtFormR64Reg<R64FP,
1563 [(set R64FP:$rT, (bitconvert R64C:$rA))]>;
1564 def f64_r64: ORCvtFormRegR64<R64FP,
1565 [(set R64C:$rT, (bitconvert R64FP:$rA))]>;
Scott Michel97872d32008-02-23 18:41:37 +00001566}
Scott Michel438be252007-12-17 22:32:34 +00001567
Scott Michel97872d32008-02-23 18:41:37 +00001568defm OR : BitwiseOr;
1569
Scott Michel06eabde2008-12-27 04:51:36 +00001570// scalar->vector promotion patterns (preferred slot to vector):
1571def : Pat<(v16i8 (SPUprefslot2vec R8C:$rA)),
1572 (ORv16i8_i8 R8C:$rA)>;
Scott Michel438be252007-12-17 22:32:34 +00001573
Scott Michel06eabde2008-12-27 04:51:36 +00001574def : Pat<(v8i16 (SPUprefslot2vec R16C:$rA)),
1575 (ORv8i16_i16 R16C:$rA)>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001576
Scott Michel06eabde2008-12-27 04:51:36 +00001577def : Pat<(v4i32 (SPUprefslot2vec R32C:$rA)),
1578 (ORv4i32_i32 R32C:$rA)>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001579
Scott Michel06eabde2008-12-27 04:51:36 +00001580def : Pat<(v2i64 (SPUprefslot2vec R64C:$rA)),
1581 (ORv2i64_i64 R64C:$rA)>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001582
Scott Michel06eabde2008-12-27 04:51:36 +00001583def : Pat<(v4f32 (SPUprefslot2vec R32FP:$rA)),
1584 (ORv4f32_f32 R32FP:$rA)>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001585
Scott Michel06eabde2008-12-27 04:51:36 +00001586def : Pat<(v2f64 (SPUprefslot2vec R64FP:$rA)),
1587 (ORv2f64_f64 R64FP:$rA)>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001588
Scott Michel06eabde2008-12-27 04:51:36 +00001589// ORi*_v*: Used to extract vector element 0 (the preferred slot), otherwise
1590// known as converting the vector back to its preferred slot
Scott Michel438be252007-12-17 22:32:34 +00001591
Scott Michelc630c412008-11-24 17:11:17 +00001592def : Pat<(SPUvec2prefslot (v16i8 VECREG:$rA)),
Scott Michel06eabde2008-12-27 04:51:36 +00001593 (ORi8_v16i8 VECREG:$rA)>;
Scott Michel438be252007-12-17 22:32:34 +00001594
Scott Michelc630c412008-11-24 17:11:17 +00001595def : Pat<(SPUvec2prefslot (v8i16 VECREG:$rA)),
Scott Michel06eabde2008-12-27 04:51:36 +00001596 (ORi16_v8i16 VECREG:$rA)>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001597
Scott Michelc630c412008-11-24 17:11:17 +00001598def : Pat<(SPUvec2prefslot (v4i32 VECREG:$rA)),
Scott Michel06eabde2008-12-27 04:51:36 +00001599 (ORi32_v4i32 VECREG:$rA)>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001600
Scott Michelc630c412008-11-24 17:11:17 +00001601def : Pat<(SPUvec2prefslot (v2i64 VECREG:$rA)),
Scott Michel06eabde2008-12-27 04:51:36 +00001602 (ORi64_v2i64 VECREG:$rA)>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001603
Scott Michelc630c412008-11-24 17:11:17 +00001604def : Pat<(SPUvec2prefslot (v4f32 VECREG:$rA)),
Scott Michel06eabde2008-12-27 04:51:36 +00001605 (ORf32_v4f32 VECREG:$rA)>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001606
Scott Michelc630c412008-11-24 17:11:17 +00001607def : Pat<(SPUvec2prefslot (v2f64 VECREG:$rA)),
Scott Michel06eabde2008-12-27 04:51:36 +00001608 (ORf64_v2f64 VECREG:$rA)>;
1609
1610// Load Register: This is an assembler alias for a bitwise OR of a register
1611// against itself. It's here because it brings some clarity to assembly
1612// language output.
1613
1614let hasCtrlDep = 1 in {
1615 class LRInst<dag OOL, dag IOL>
1616 : SPUInstr<OOL, IOL, "lr\t$rT, $rA", IntegerOp> {
1617 bits<7> RA;
1618 bits<7> RT;
1619
1620 let Pattern = [/*no pattern*/];
1621
1622 let Inst{0-10} = 0b10000010000; /* It's an OR operation */
1623 let Inst{11-17} = RA;
1624 let Inst{18-24} = RA;
1625 let Inst{25-31} = RT;
1626 }
1627
1628 class LRVecInst<ValueType vectype>:
1629 LRInst<(outs VECREG:$rT), (ins VECREG:$rA)>;
1630
1631 class LRRegInst<RegisterClass rclass>:
1632 LRInst<(outs rclass:$rT), (ins rclass:$rA)>;
1633
1634 multiclass LoadRegister {
1635 def v2i64: LRVecInst<v2i64>;
1636 def v2f64: LRVecInst<v2f64>;
1637 def v4i32: LRVecInst<v4i32>;
1638 def v4f32: LRVecInst<v4f32>;
1639 def v8i16: LRVecInst<v8i16>;
1640 def v16i8: LRVecInst<v16i8>;
1641
1642 def r128: LRRegInst<GPRC>;
1643 def r64: LRRegInst<R64C>;
1644 def f64: LRRegInst<R64FP>;
1645 def r32: LRRegInst<R32C>;
1646 def f32: LRRegInst<R32FP>;
1647 def r16: LRRegInst<R16C>;
1648 def r8: LRRegInst<R8C>;
1649 }
1650
1651 defm LR: LoadRegister;
1652}
Scott Michel8b6b4202007-12-04 22:35:58 +00001653
Scott Michel97872d32008-02-23 18:41:37 +00001654// ORC: Bitwise "or" with complement (c = a | ~b)
Scott Michel8b6b4202007-12-04 22:35:58 +00001655
Scott Michel97872d32008-02-23 18:41:37 +00001656class ORCInst<dag OOL, dag IOL, list<dag> pattern>:
1657 RRForm<0b10010010000, OOL, IOL, "orc\t$rT, $rA, $rB",
1658 IntegerOp, pattern>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001659
Scott Michel97872d32008-02-23 18:41:37 +00001660class ORCVecInst<ValueType vectype>:
1661 ORCInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1662 [(set (vectype VECREG:$rT), (or (vectype VECREG:$rA),
1663 (vnot (vectype VECREG:$rB))))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001664
Scott Michel97872d32008-02-23 18:41:37 +00001665class ORCRegInst<RegisterClass rclass>:
1666 ORCInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB),
1667 [(set rclass:$rT, (or rclass:$rA, (not rclass:$rB)))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001668
Scott Michel97872d32008-02-23 18:41:37 +00001669multiclass BitwiseOrComplement
1670{
1671 def v16i8: ORCVecInst<v16i8>;
1672 def v8i16: ORCVecInst<v8i16>;
1673 def v4i32: ORCVecInst<v4i32>;
1674 def v2i64: ORCVecInst<v2i64>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001675
Scott Michel34712c32009-03-16 18:47:25 +00001676 def r128: ORCRegInst<GPRC>;
Scott Michel97872d32008-02-23 18:41:37 +00001677 def r64: ORCRegInst<R64C>;
1678 def r32: ORCRegInst<R32C>;
1679 def r16: ORCRegInst<R16C>;
1680 def r8: ORCRegInst<R8C>;
1681}
1682
1683defm ORC : BitwiseOrComplement;
Scott Michel438be252007-12-17 22:32:34 +00001684
Scott Michel8b6b4202007-12-04 22:35:58 +00001685// OR byte immediate
Scott Michel97872d32008-02-23 18:41:37 +00001686class ORBIInst<dag OOL, dag IOL, list<dag> pattern>:
1687 RI10Form<0b01100000, OOL, IOL, "orbi\t$rT, $rA, $val",
1688 IntegerOp, pattern>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001689
Scott Michel97872d32008-02-23 18:41:37 +00001690class ORBIVecInst<ValueType vectype, PatLeaf immpred>:
1691 ORBIInst<(outs VECREG:$rT), (ins VECREG:$rA, u10imm:$val),
1692 [(set (v16i8 VECREG:$rT), (or (vectype VECREG:$rA),
1693 (vectype immpred:$val)))]>;
1694
1695multiclass BitwiseOrByteImm
1696{
1697 def v16i8: ORBIVecInst<v16i8, v16i8U8Imm>;
1698
1699 def r8: ORBIInst<(outs R8C:$rT), (ins R8C:$rA, u10imm_i8:$val),
1700 [(set R8C:$rT, (or R8C:$rA, immU8:$val))]>;
1701}
1702
1703defm ORBI : BitwiseOrByteImm;
Scott Michel438be252007-12-17 22:32:34 +00001704
Scott Michel8b6b4202007-12-04 22:35:58 +00001705// OR halfword immediate
Scott Michel97872d32008-02-23 18:41:37 +00001706class ORHIInst<dag OOL, dag IOL, list<dag> pattern>:
1707 RI10Form<0b10100000, OOL, IOL, "orhi\t$rT, $rA, $val",
1708 IntegerOp, pattern>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001709
Scott Michel97872d32008-02-23 18:41:37 +00001710class ORHIVecInst<ValueType vectype, PatLeaf immpred>:
1711 ORHIInst<(outs VECREG:$rT), (ins VECREG:$rA, u10imm:$val),
1712 [(set (vectype VECREG:$rT), (or (vectype VECREG:$rA),
1713 immpred:$val))]>;
Scott Michel438be252007-12-17 22:32:34 +00001714
Scott Michel97872d32008-02-23 18:41:37 +00001715multiclass BitwiseOrHalfwordImm
1716{
1717 def v8i16: ORHIVecInst<v8i16, v8i16Uns10Imm>;
1718
1719 def r16: ORHIInst<(outs R16C:$rT), (ins R16C:$rA, u10imm:$val),
1720 [(set R16C:$rT, (or R16C:$rA, i16ImmUns10:$val))]>;
1721
1722 // Specialized ORHI form used to promote 8-bit registers to 16-bit
1723 def i8i16: ORHIInst<(outs R16C:$rT), (ins R8C:$rA, s10imm:$val),
1724 [(set R16C:$rT, (or (anyext R8C:$rA),
1725 i16ImmSExt10:$val))]>;
1726}
1727
1728defm ORHI : BitwiseOrHalfwordImm;
1729
1730class ORIInst<dag OOL, dag IOL, list<dag> pattern>:
1731 RI10Form<0b00100000, OOL, IOL, "ori\t$rT, $rA, $val",
1732 IntegerOp, pattern>;
1733
1734class ORIVecInst<ValueType vectype, PatLeaf immpred>:
1735 ORIInst<(outs VECREG:$rT), (ins VECREG:$rA, u10imm:$val),
1736 [(set (vectype VECREG:$rT), (or (vectype VECREG:$rA),
1737 immpred:$val))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001738
1739// Bitwise "or" with immediate
Scott Michel97872d32008-02-23 18:41:37 +00001740multiclass BitwiseOrImm
1741{
1742 def v4i32: ORIVecInst<v4i32, v4i32Uns10Imm>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001743
Scott Michel97872d32008-02-23 18:41:37 +00001744 def r32: ORIInst<(outs R32C:$rT), (ins R32C:$rA, u10imm_i32:$val),
1745 [(set R32C:$rT, (or R32C:$rA, i32ImmUns10:$val))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001746
Scott Michel97872d32008-02-23 18:41:37 +00001747 // i16i32: hacked version of the ori instruction to extend 16-bit quantities
1748 // to 32-bit quantities. used exclusively to match "anyext" conversions (vide
1749 // infra "anyext 16->32" pattern.)
1750 def i16i32: ORIInst<(outs R32C:$rT), (ins R16C:$rA, s10imm_i32:$val),
1751 [(set R32C:$rT, (or (anyext R16C:$rA),
1752 i32ImmSExt10:$val))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001753
Scott Michel97872d32008-02-23 18:41:37 +00001754 // i8i32: Hacked version of the ORI instruction to extend 16-bit quantities
1755 // to 32-bit quantities. Used exclusively to match "anyext" conversions (vide
1756 // infra "anyext 16->32" pattern.)
1757 def i8i32: ORIInst<(outs R32C:$rT), (ins R8C:$rA, s10imm_i32:$val),
1758 [(set R32C:$rT, (or (anyext R8C:$rA),
1759 i32ImmSExt10:$val))]>;
1760}
Scott Michel8b6b4202007-12-04 22:35:58 +00001761
Scott Michel97872d32008-02-23 18:41:37 +00001762defm ORI : BitwiseOrImm;
Scott Michel438be252007-12-17 22:32:34 +00001763
Scott Michel8b6b4202007-12-04 22:35:58 +00001764// ORX: "or" across the vector: or's $rA's word slots leaving the result in
1765// $rT[0], slots 1-3 are zeroed.
1766//
Scott Michel438be252007-12-17 22:32:34 +00001767// FIXME: Needs to match an intrinsic pattern.
Scott Michel8b6b4202007-12-04 22:35:58 +00001768def ORXv4i32:
1769 RRForm<0b10010010000, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1770 "orx\t$rT, $rA, $rB", IntegerOp,
1771 []>;
1772
Scott Michel438be252007-12-17 22:32:34 +00001773// XOR:
Scott Michel8b6b4202007-12-04 22:35:58 +00001774
Scott Michel6baba072008-03-05 23:02:02 +00001775class XORInst<dag OOL, dag IOL, list<dag> pattern> :
1776 RRForm<0b10010010000, OOL, IOL, "xor\t$rT, $rA, $rB",
1777 IntegerOp, pattern>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001778
Scott Michel6baba072008-03-05 23:02:02 +00001779class XORVecInst<ValueType vectype>:
1780 XORInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1781 [(set (vectype VECREG:$rT), (xor (vectype VECREG:$rA),
1782 (vectype VECREG:$rB)))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001783
Scott Michel6baba072008-03-05 23:02:02 +00001784class XORRegInst<RegisterClass rclass>:
1785 XORInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB),
1786 [(set rclass:$rT, (xor rclass:$rA, rclass:$rB))]>;
1787
1788multiclass BitwiseExclusiveOr
1789{
1790 def v16i8: XORVecInst<v16i8>;
1791 def v8i16: XORVecInst<v8i16>;
1792 def v4i32: XORVecInst<v4i32>;
1793 def v2i64: XORVecInst<v2i64>;
1794
1795 def r128: XORRegInst<GPRC>;
1796 def r64: XORRegInst<R64C>;
1797 def r32: XORRegInst<R32C>;
1798 def r16: XORRegInst<R16C>;
1799 def r8: XORRegInst<R8C>;
Scott Michel6baba072008-03-05 23:02:02 +00001800}
1801
1802defm XOR : BitwiseExclusiveOr;
Scott Michel8b6b4202007-12-04 22:35:58 +00001803
1804//==----------------------------------------------------------
Scott Michel438be252007-12-17 22:32:34 +00001805
Scott Michel97872d32008-02-23 18:41:37 +00001806class XORBIInst<dag OOL, dag IOL, list<dag> pattern>:
1807 RI10Form<0b01100000, OOL, IOL, "xorbi\t$rT, $rA, $val",
1808 IntegerOp, pattern>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001809
Scott Michel97872d32008-02-23 18:41:37 +00001810multiclass XorByteImm
1811{
1812 def v16i8:
1813 XORBIInst<(outs VECREG:$rT), (ins VECREG:$rA, u10imm:$val),
1814 [(set (v16i8 VECREG:$rT), (xor (v16i8 VECREG:$rA), v16i8U8Imm:$val))]>;
1815
1816 def r8:
1817 XORBIInst<(outs R8C:$rT), (ins R8C:$rA, u10imm_i8:$val),
1818 [(set R8C:$rT, (xor R8C:$rA, immU8:$val))]>;
1819}
1820
1821defm XORBI : XorByteImm;
Scott Michel438be252007-12-17 22:32:34 +00001822
Scott Michel8b6b4202007-12-04 22:35:58 +00001823def XORHIv8i16:
Scott Michel97872d32008-02-23 18:41:37 +00001824 RI10Form<0b10100000, (outs VECREG:$rT), (ins VECREG:$rA, u10imm:$val),
Scott Michel8b6b4202007-12-04 22:35:58 +00001825 "xorhi\t$rT, $rA, $val", IntegerOp,
1826 [(set (v8i16 VECREG:$rT), (xor (v8i16 VECREG:$rA),
1827 v8i16SExt10Imm:$val))]>;
1828
1829def XORHIr16:
1830 RI10Form<0b10100000, (outs R16C:$rT), (ins R16C:$rA, s10imm:$val),
1831 "xorhi\t$rT, $rA, $val", IntegerOp,
1832 [(set R16C:$rT, (xor R16C:$rA, i16ImmSExt10:$val))]>;
1833
1834def XORIv4i32:
Scott Michel53ab7792008-03-10 16:58:52 +00001835 RI10Form<0b00100000, (outs VECREG:$rT), (ins VECREG:$rA, s10imm_i32:$val),
Scott Michel8b6b4202007-12-04 22:35:58 +00001836 "xori\t$rT, $rA, $val", IntegerOp,
1837 [(set (v4i32 VECREG:$rT), (xor (v4i32 VECREG:$rA),
1838 v4i32SExt10Imm:$val))]>;
1839
1840def XORIr32:
1841 RI10Form<0b00100000, (outs R32C:$rT), (ins R32C:$rA, s10imm_i32:$val),
1842 "xori\t$rT, $rA, $val", IntegerOp,
1843 [(set R32C:$rT, (xor R32C:$rA, i32ImmSExt10:$val))]>;
1844
1845// NAND:
Scott Michel8b6b4202007-12-04 22:35:58 +00001846
Scott Michel34712c32009-03-16 18:47:25 +00001847class NANDInst<dag OOL, dag IOL, list<dag> pattern>:
1848 RRForm<0b10010011000, OOL, IOL, "nand\t$rT, $rA, $rB",
1849 IntegerOp, pattern>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001850
Scott Michel34712c32009-03-16 18:47:25 +00001851class NANDVecInst<ValueType vectype>:
1852 NANDInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1853 [(set (vectype VECREG:$rT), (vnot (and (vectype VECREG:$rA),
1854 (vectype VECREG:$rB))))]>;
1855class NANDRegInst<RegisterClass rclass>:
1856 NANDInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB),
1857 [(set rclass:$rT, (not (and rclass:$rA, rclass:$rB)))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001858
Scott Michel34712c32009-03-16 18:47:25 +00001859multiclass BitwiseNand
1860{
1861 def v16i8: NANDVecInst<v16i8>;
1862 def v8i16: NANDVecInst<v8i16>;
1863 def v4i32: NANDVecInst<v4i32>;
1864 def v2i64: NANDVecInst<v2i64>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001865
Scott Michel34712c32009-03-16 18:47:25 +00001866 def r128: NANDRegInst<GPRC>;
1867 def r64: NANDRegInst<R64C>;
1868 def r32: NANDRegInst<R32C>;
1869 def r16: NANDRegInst<R16C>;
1870 def r8: NANDRegInst<R8C>;
1871}
Scott Michel8b6b4202007-12-04 22:35:58 +00001872
Scott Michel34712c32009-03-16 18:47:25 +00001873defm NAND : BitwiseNand;
Scott Michel438be252007-12-17 22:32:34 +00001874
Scott Michel8b6b4202007-12-04 22:35:58 +00001875// NOR:
Scott Michel8b6b4202007-12-04 22:35:58 +00001876
Scott Michel34712c32009-03-16 18:47:25 +00001877class NORInst<dag OOL, dag IOL, list<dag> pattern>:
1878 RRForm<0b10010010000, OOL, IOL, "nor\t$rT, $rA, $rB",
1879 IntegerOp, pattern>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001880
Scott Michel34712c32009-03-16 18:47:25 +00001881class NORVecInst<ValueType vectype>:
1882 NORInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1883 [(set (vectype VECREG:$rT), (vnot (or (vectype VECREG:$rA),
1884 (vectype VECREG:$rB))))]>;
1885class NORRegInst<RegisterClass rclass>:
1886 NORInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB),
1887 [(set rclass:$rT, (not (or rclass:$rA, rclass:$rB)))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001888
Scott Michel34712c32009-03-16 18:47:25 +00001889multiclass BitwiseNor
1890{
1891 def v16i8: NORVecInst<v16i8>;
1892 def v8i16: NORVecInst<v8i16>;
1893 def v4i32: NORVecInst<v4i32>;
1894 def v2i64: NORVecInst<v2i64>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001895
Scott Michel34712c32009-03-16 18:47:25 +00001896 def r128: NORRegInst<GPRC>;
1897 def r64: NORRegInst<R64C>;
1898 def r32: NORRegInst<R32C>;
1899 def r16: NORRegInst<R16C>;
1900 def r8: NORRegInst<R8C>;
1901}
Scott Michel8b6b4202007-12-04 22:35:58 +00001902
Scott Michel34712c32009-03-16 18:47:25 +00001903defm NOR : BitwiseNor;
Scott Michel438be252007-12-17 22:32:34 +00001904
Scott Michel8b6b4202007-12-04 22:35:58 +00001905// Select bits:
Scott Michel6baba072008-03-05 23:02:02 +00001906class SELBInst<dag OOL, dag IOL, list<dag> pattern>:
1907 RRRForm<0b1000, OOL, IOL, "selb\t$rT, $rA, $rB, $rC",
1908 IntegerOp, pattern>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001909
pingbak2f387e82009-01-26 03:31:40 +00001910class SELBVecInst<ValueType vectype, PatFrag vnot_frag = vnot>:
Scott Michel6baba072008-03-05 23:02:02 +00001911 SELBInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB, VECREG:$rC),
1912 [(set (vectype VECREG:$rT),
1913 (or (and (vectype VECREG:$rC), (vectype VECREG:$rB)),
pingbak2f387e82009-01-26 03:31:40 +00001914 (and (vnot_frag (vectype VECREG:$rC)),
Scott Michel6baba072008-03-05 23:02:02 +00001915 (vectype VECREG:$rA))))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001916
Scott Michel4d07fb72008-12-30 23:28:25 +00001917class SELBVecVCondInst<ValueType vectype>:
1918 SELBInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB, VECREG:$rC),
1919 [(set (vectype VECREG:$rT),
1920 (select (vectype VECREG:$rC),
1921 (vectype VECREG:$rB),
1922 (vectype VECREG:$rA)))]>;
1923
Scott Michel06eabde2008-12-27 04:51:36 +00001924class SELBVecCondInst<ValueType vectype>:
1925 SELBInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB, R32C:$rC),
1926 [(set (vectype VECREG:$rT),
1927 (select R32C:$rC,
1928 (vectype VECREG:$rB),
1929 (vectype VECREG:$rA)))]>;
1930
Scott Michel6baba072008-03-05 23:02:02 +00001931class SELBRegInst<RegisterClass rclass>:
1932 SELBInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB, rclass:$rC),
1933 [(set rclass:$rT,
Scott Michelae5cbf52008-12-29 03:23:36 +00001934 (or (and rclass:$rB, rclass:$rC),
1935 (and rclass:$rA, (not rclass:$rC))))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001936
Scott Michel06eabde2008-12-27 04:51:36 +00001937class SELBRegCondInst<RegisterClass rcond, RegisterClass rclass>:
1938 SELBInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB, rcond:$rC),
1939 [(set rclass:$rT,
1940 (select rcond:$rC, rclass:$rB, rclass:$rA))]>;
1941
Scott Michel6baba072008-03-05 23:02:02 +00001942multiclass SelectBits
1943{
1944 def v16i8: SELBVecInst<v16i8>;
1945 def v8i16: SELBVecInst<v8i16>;
1946 def v4i32: SELBVecInst<v4i32>;
pingbak2f387e82009-01-26 03:31:40 +00001947 def v2i64: SELBVecInst<v2i64, vnot_conv>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001948
Scott Michel6baba072008-03-05 23:02:02 +00001949 def r128: SELBRegInst<GPRC>;
1950 def r64: SELBRegInst<R64C>;
1951 def r32: SELBRegInst<R32C>;
1952 def r16: SELBRegInst<R16C>;
1953 def r8: SELBRegInst<R8C>;
Scott Michel06eabde2008-12-27 04:51:36 +00001954
1955 def v16i8_cond: SELBVecCondInst<v16i8>;
1956 def v8i16_cond: SELBVecCondInst<v8i16>;
1957 def v4i32_cond: SELBVecCondInst<v4i32>;
1958 def v2i64_cond: SELBVecCondInst<v2i64>;
1959
Scott Michel4d07fb72008-12-30 23:28:25 +00001960 def v16i8_vcond: SELBVecCondInst<v16i8>;
1961 def v8i16_vcond: SELBVecCondInst<v8i16>;
1962 def v4i32_vcond: SELBVecCondInst<v4i32>;
1963 def v2i64_vcond: SELBVecCondInst<v2i64>;
1964
1965 def v4f32_cond:
pingbakb8913342009-01-26 03:37:41 +00001966 SELBInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB, VECREG:$rC),
1967 [(set (v4f32 VECREG:$rT),
1968 (select (v4i32 VECREG:$rC),
1969 (v4f32 VECREG:$rB),
1970 (v4f32 VECREG:$rA)))]>;
Scott Michel4d07fb72008-12-30 23:28:25 +00001971
Scott Michel8c67fa42009-01-21 04:58:48 +00001972 // SELBr64_cond is defined in SPU64InstrInfo.td
Scott Michel06eabde2008-12-27 04:51:36 +00001973 def r32_cond: SELBRegCondInst<R32C, R32C>;
Scott Michel4d07fb72008-12-30 23:28:25 +00001974 def f32_cond: SELBRegCondInst<R32C, R32FP>;
Scott Michel06eabde2008-12-27 04:51:36 +00001975 def r16_cond: SELBRegCondInst<R16C, R16C>;
1976 def r8_cond: SELBRegCondInst<R8C, R8C>;
Scott Michel6baba072008-03-05 23:02:02 +00001977}
Scott Michel8b6b4202007-12-04 22:35:58 +00001978
Scott Michel6baba072008-03-05 23:02:02 +00001979defm SELB : SelectBits;
Scott Michel8b6b4202007-12-04 22:35:58 +00001980
Scott Michel56a125e2008-11-22 23:50:42 +00001981class SPUselbPatVec<ValueType vectype, SPUInstr inst>:
Scott Michel6baba072008-03-05 23:02:02 +00001982 Pat<(SPUselb (vectype VECREG:$rA), (vectype VECREG:$rB), (vectype VECREG:$rC)),
1983 (inst VECREG:$rA, VECREG:$rB, VECREG:$rC)>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001984
Scott Michel56a125e2008-11-22 23:50:42 +00001985def : SPUselbPatVec<v16i8, SELBv16i8>;
1986def : SPUselbPatVec<v8i16, SELBv8i16>;
1987def : SPUselbPatVec<v4i32, SELBv4i32>;
1988def : SPUselbPatVec<v2i64, SELBv2i64>;
1989
1990class SPUselbPatReg<RegisterClass rclass, SPUInstr inst>:
1991 Pat<(SPUselb rclass:$rA, rclass:$rB, rclass:$rC),
1992 (inst rclass:$rA, rclass:$rB, rclass:$rC)>;
1993
1994def : SPUselbPatReg<R8C, SELBr8>;
1995def : SPUselbPatReg<R16C, SELBr16>;
1996def : SPUselbPatReg<R32C, SELBr32>;
1997def : SPUselbPatReg<R64C, SELBr64>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001998
Scott Michel6baba072008-03-05 23:02:02 +00001999// EQV: Equivalence (1 for each same bit, otherwise 0)
2000//
2001// Note: There are a lot of ways to match this bit operator and these patterns
2002// attempt to be as exhaustive as possible.
Scott Michel8b6b4202007-12-04 22:35:58 +00002003
Scott Michel6baba072008-03-05 23:02:02 +00002004class EQVInst<dag OOL, dag IOL, list<dag> pattern>:
2005 RRForm<0b10010010000, OOL, IOL, "eqv\t$rT, $rA, $rB",
2006 IntegerOp, pattern>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002007
Scott Michel6baba072008-03-05 23:02:02 +00002008class EQVVecInst<ValueType vectype>:
2009 EQVInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
2010 [(set (vectype VECREG:$rT),
2011 (or (and (vectype VECREG:$rA), (vectype VECREG:$rB)),
2012 (and (vnot (vectype VECREG:$rA)),
2013 (vnot (vectype VECREG:$rB)))))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002014
Scott Michel6baba072008-03-05 23:02:02 +00002015class EQVRegInst<RegisterClass rclass>:
2016 EQVInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB),
2017 [(set rclass:$rT, (or (and rclass:$rA, rclass:$rB),
2018 (and (not rclass:$rA), (not rclass:$rB))))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002019
Scott Michel6baba072008-03-05 23:02:02 +00002020class EQVVecPattern1<ValueType vectype>:
2021 EQVInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
2022 [(set (vectype VECREG:$rT),
2023 (xor (vectype VECREG:$rA), (vnot (vectype VECREG:$rB))))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002024
Scott Michel6baba072008-03-05 23:02:02 +00002025class EQVRegPattern1<RegisterClass rclass>:
2026 EQVInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB),
2027 [(set rclass:$rT, (xor rclass:$rA, (not rclass:$rB)))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002028
Scott Michel6baba072008-03-05 23:02:02 +00002029class EQVVecPattern2<ValueType vectype>:
2030 EQVInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
2031 [(set (vectype VECREG:$rT),
2032 (or (and (vectype VECREG:$rA), (vectype VECREG:$rB)),
2033 (vnot (or (vectype VECREG:$rA), (vectype VECREG:$rB)))))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002034
Scott Michel6baba072008-03-05 23:02:02 +00002035class EQVRegPattern2<RegisterClass rclass>:
2036 EQVInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB),
2037 [(set rclass:$rT,
2038 (or (and rclass:$rA, rclass:$rB),
2039 (not (or rclass:$rA, rclass:$rB))))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002040
Scott Michel6baba072008-03-05 23:02:02 +00002041class EQVVecPattern3<ValueType vectype>:
2042 EQVInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
2043 [(set (vectype VECREG:$rT),
2044 (not (xor (vectype VECREG:$rA), (vectype VECREG:$rB))))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002045
Scott Michel6baba072008-03-05 23:02:02 +00002046class EQVRegPattern3<RegisterClass rclass>:
2047 EQVInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB),
2048 [(set rclass:$rT, (not (xor rclass:$rA, rclass:$rB)))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002049
Scott Michel6baba072008-03-05 23:02:02 +00002050multiclass BitEquivalence
2051{
2052 def v16i8: EQVVecInst<v16i8>;
2053 def v8i16: EQVVecInst<v8i16>;
2054 def v4i32: EQVVecInst<v4i32>;
2055 def v2i64: EQVVecInst<v2i64>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002056
Scott Michel6baba072008-03-05 23:02:02 +00002057 def v16i8_1: EQVVecPattern1<v16i8>;
2058 def v8i16_1: EQVVecPattern1<v8i16>;
2059 def v4i32_1: EQVVecPattern1<v4i32>;
2060 def v2i64_1: EQVVecPattern1<v2i64>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002061
Scott Michel6baba072008-03-05 23:02:02 +00002062 def v16i8_2: EQVVecPattern2<v16i8>;
2063 def v8i16_2: EQVVecPattern2<v8i16>;
2064 def v4i32_2: EQVVecPattern2<v4i32>;
2065 def v2i64_2: EQVVecPattern2<v2i64>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002066
Scott Michel6baba072008-03-05 23:02:02 +00002067 def v16i8_3: EQVVecPattern3<v16i8>;
2068 def v8i16_3: EQVVecPattern3<v8i16>;
2069 def v4i32_3: EQVVecPattern3<v4i32>;
2070 def v2i64_3: EQVVecPattern3<v2i64>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002071
Scott Michel6baba072008-03-05 23:02:02 +00002072 def r128: EQVRegInst<GPRC>;
2073 def r64: EQVRegInst<R64C>;
2074 def r32: EQVRegInst<R32C>;
2075 def r16: EQVRegInst<R16C>;
2076 def r8: EQVRegInst<R8C>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002077
Scott Michel6baba072008-03-05 23:02:02 +00002078 def r128_1: EQVRegPattern1<GPRC>;
2079 def r64_1: EQVRegPattern1<R64C>;
2080 def r32_1: EQVRegPattern1<R32C>;
2081 def r16_1: EQVRegPattern1<R16C>;
2082 def r8_1: EQVRegPattern1<R8C>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002083
Scott Michel6baba072008-03-05 23:02:02 +00002084 def r128_2: EQVRegPattern2<GPRC>;
2085 def r64_2: EQVRegPattern2<R64C>;
2086 def r32_2: EQVRegPattern2<R32C>;
2087 def r16_2: EQVRegPattern2<R16C>;
2088 def r8_2: EQVRegPattern2<R8C>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002089
Scott Michel6baba072008-03-05 23:02:02 +00002090 def r128_3: EQVRegPattern3<GPRC>;
2091 def r64_3: EQVRegPattern3<R64C>;
2092 def r32_3: EQVRegPattern3<R32C>;
2093 def r16_3: EQVRegPattern3<R16C>;
2094 def r8_3: EQVRegPattern3<R8C>;
2095}
Scott Michel438be252007-12-17 22:32:34 +00002096
Scott Michel6baba072008-03-05 23:02:02 +00002097defm EQV: BitEquivalence;
Scott Michel8b6b4202007-12-04 22:35:58 +00002098
2099//===----------------------------------------------------------------------===//
2100// Vector shuffle...
2101//===----------------------------------------------------------------------===//
Scott Michel8b6b4202007-12-04 22:35:58 +00002102// SPUshuffle is generated in LowerVECTOR_SHUFFLE and gets replaced with SHUFB.
2103// See the SPUshuffle SDNode operand above, which sets up the DAG pattern
2104// matcher to emit something when the LowerVECTOR_SHUFFLE generates a node with
2105// the SPUISD::SHUFB opcode.
Scott Michel97872d32008-02-23 18:41:37 +00002106//===----------------------------------------------------------------------===//
Scott Michel8b6b4202007-12-04 22:35:58 +00002107
Scott Michel97872d32008-02-23 18:41:37 +00002108class SHUFBInst<dag OOL, dag IOL, list<dag> pattern>:
2109 RRRForm<0b1000, OOL, IOL, "shufb\t$rT, $rA, $rB, $rC",
2110 IntegerOp, pattern>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002111
Scott Michel0718cd82008-12-01 17:56:02 +00002112class SHUFBVecInst<ValueType resultvec, ValueType maskvec>:
Scott Michel97872d32008-02-23 18:41:37 +00002113 SHUFBInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB, VECREG:$rC),
Scott Michel0718cd82008-12-01 17:56:02 +00002114 [(set (resultvec VECREG:$rT),
2115 (SPUshuffle (resultvec VECREG:$rA),
2116 (resultvec VECREG:$rB),
2117 (maskvec VECREG:$rC)))]>;
Scott Michel754d8662007-12-20 00:44:13 +00002118
Scott Michel06eabde2008-12-27 04:51:36 +00002119class SHUFBGPRCInst:
2120 SHUFBInst<(outs VECREG:$rT), (ins GPRC:$rA, GPRC:$rB, VECREG:$rC),
2121 [/* no pattern */]>;
2122
Scott Michel97872d32008-02-23 18:41:37 +00002123multiclass ShuffleBytes
2124{
Scott Michel0718cd82008-12-01 17:56:02 +00002125 def v16i8 : SHUFBVecInst<v16i8, v16i8>;
2126 def v16i8_m32 : SHUFBVecInst<v16i8, v4i32>;
2127 def v8i16 : SHUFBVecInst<v8i16, v16i8>;
2128 def v8i16_m32 : SHUFBVecInst<v8i16, v4i32>;
2129 def v4i32 : SHUFBVecInst<v4i32, v16i8>;
2130 def v4i32_m32 : SHUFBVecInst<v4i32, v4i32>;
2131 def v2i64 : SHUFBVecInst<v2i64, v16i8>;
2132 def v2i64_m32 : SHUFBVecInst<v2i64, v4i32>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002133
Scott Michel0718cd82008-12-01 17:56:02 +00002134 def v4f32 : SHUFBVecInst<v4f32, v16i8>;
2135 def v4f32_m32 : SHUFBVecInst<v4f32, v4i32>;
2136
2137 def v2f64 : SHUFBVecInst<v2f64, v16i8>;
2138 def v2f64_m32 : SHUFBVecInst<v2f64, v4i32>;
Scott Michel06eabde2008-12-27 04:51:36 +00002139
2140 def gprc : SHUFBGPRCInst;
Scott Michel97872d32008-02-23 18:41:37 +00002141}
2142
2143defm SHUFB : ShuffleBytes;
2144
Scott Michel8b6b4202007-12-04 22:35:58 +00002145//===----------------------------------------------------------------------===//
2146// Shift and rotate group:
2147//===----------------------------------------------------------------------===//
2148
Scott Michel97872d32008-02-23 18:41:37 +00002149class SHLHInst<dag OOL, dag IOL, list<dag> pattern>:
2150 RRForm<0b11111010000, OOL, IOL, "shlh\t$rT, $rA, $rB",
2151 RotateShift, pattern>;
2152
2153class SHLHVecInst<ValueType vectype>:
2154 SHLHInst<(outs VECREG:$rT), (ins VECREG:$rA, R16C:$rB),
2155 [(set (vectype VECREG:$rT),
2156 (SPUvec_shl (vectype VECREG:$rA), R16C:$rB))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002157
Scott Michel97872d32008-02-23 18:41:37 +00002158multiclass ShiftLeftHalfword
2159{
2160 def v8i16: SHLHVecInst<v8i16>;
2161 def r16: SHLHInst<(outs R16C:$rT), (ins R16C:$rA, R16C:$rB),
2162 [(set R16C:$rT, (shl R16C:$rA, R16C:$rB))]>;
2163 def r16_r32: SHLHInst<(outs R16C:$rT), (ins R16C:$rA, R32C:$rB),
2164 [(set R16C:$rT, (shl R16C:$rA, R32C:$rB))]>;
2165}
Scott Michel8b6b4202007-12-04 22:35:58 +00002166
Scott Michel97872d32008-02-23 18:41:37 +00002167defm SHLH : ShiftLeftHalfword;
Scott Michel8b6b4202007-12-04 22:35:58 +00002168
Scott Michel97872d32008-02-23 18:41:37 +00002169//===----------------------------------------------------------------------===//
Scott Michel438be252007-12-17 22:32:34 +00002170
Scott Michel97872d32008-02-23 18:41:37 +00002171class SHLHIInst<dag OOL, dag IOL, list<dag> pattern>:
2172 RI7Form<0b11111010000, OOL, IOL, "shlhi\t$rT, $rA, $val",
2173 RotateShift, pattern>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002174
Scott Michel97872d32008-02-23 18:41:37 +00002175class SHLHIVecInst<ValueType vectype>:
2176 SHLHIInst<(outs VECREG:$rT), (ins VECREG:$rA, u7imm:$val),
2177 [(set (vectype VECREG:$rT),
2178 (SPUvec_shl (vectype VECREG:$rA), (i16 uimm7:$val)))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002179
Scott Michel97872d32008-02-23 18:41:37 +00002180multiclass ShiftLeftHalfwordImm
2181{
2182 def v8i16: SHLHIVecInst<v8i16>;
2183 def r16: SHLHIInst<(outs R16C:$rT), (ins R16C:$rA, u7imm:$val),
2184 [(set R16C:$rT, (shl R16C:$rA, (i16 uimm7:$val)))]>;
2185}
2186
2187defm SHLHI : ShiftLeftHalfwordImm;
2188
2189def : Pat<(SPUvec_shl (v8i16 VECREG:$rA), (i32 uimm7:$val)),
2190 (SHLHIv8i16 VECREG:$rA, uimm7:$val)>;
2191
2192def : Pat<(shl R16C:$rA, (i32 uimm7:$val)),
Scott Michel438be252007-12-17 22:32:34 +00002193 (SHLHIr16 R16C:$rA, uimm7:$val)>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002194
Scott Michel97872d32008-02-23 18:41:37 +00002195//===----------------------------------------------------------------------===//
Scott Michel8b6b4202007-12-04 22:35:58 +00002196
Scott Michel97872d32008-02-23 18:41:37 +00002197class SHLInst<dag OOL, dag IOL, list<dag> pattern>:
2198 RRForm<0b11111010000, OOL, IOL, "shl\t$rT, $rA, $rB",
2199 RotateShift, pattern>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002200
Scott Michel97872d32008-02-23 18:41:37 +00002201multiclass ShiftLeftWord
2202{
2203 def v4i32:
2204 SHLInst<(outs VECREG:$rT), (ins VECREG:$rA, R16C:$rB),
2205 [(set (v4i32 VECREG:$rT),
2206 (SPUvec_shl (v4i32 VECREG:$rA), R16C:$rB))]>;
2207 def r32:
2208 SHLInst<(outs R32C:$rT), (ins R32C:$rA, R32C:$rB),
2209 [(set R32C:$rT, (shl R32C:$rA, R32C:$rB))]>;
2210}
Scott Michel8b6b4202007-12-04 22:35:58 +00002211
Scott Michel97872d32008-02-23 18:41:37 +00002212defm SHL: ShiftLeftWord;
Scott Michel438be252007-12-17 22:32:34 +00002213
Scott Michel97872d32008-02-23 18:41:37 +00002214//===----------------------------------------------------------------------===//
Scott Michel8b6b4202007-12-04 22:35:58 +00002215
Scott Michel97872d32008-02-23 18:41:37 +00002216class SHLIInst<dag OOL, dag IOL, list<dag> pattern>:
2217 RI7Form<0b11111010000, OOL, IOL, "shli\t$rT, $rA, $val",
2218 RotateShift, pattern>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002219
Scott Michel97872d32008-02-23 18:41:37 +00002220multiclass ShiftLeftWordImm
2221{
2222 def v4i32:
2223 SHLIInst<(outs VECREG:$rT), (ins VECREG:$rA, u7imm_i32:$val),
2224 [(set (v4i32 VECREG:$rT),
2225 (SPUvec_shl (v4i32 VECREG:$rA), (i32 uimm7:$val)))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002226
Scott Michel97872d32008-02-23 18:41:37 +00002227 def r32:
2228 SHLIInst<(outs R32C:$rT), (ins R32C:$rA, u7imm_i32:$val),
2229 [(set R32C:$rT, (shl R32C:$rA, (i32 uimm7:$val)))]>;
2230}
Scott Michel8b6b4202007-12-04 22:35:58 +00002231
Scott Michel97872d32008-02-23 18:41:37 +00002232defm SHLI : ShiftLeftWordImm;
Scott Michel438be252007-12-17 22:32:34 +00002233
Scott Michel97872d32008-02-23 18:41:37 +00002234//===----------------------------------------------------------------------===//
Scott Michel8b6b4202007-12-04 22:35:58 +00002235// SHLQBI vec form: Note that this will shift the entire vector (the 128-bit
2236// register) to the left. Vector form is here to ensure type correctness.
Scott Michel97872d32008-02-23 18:41:37 +00002237//
2238// The shift count is in the lowest 3 bits (29-31) of $rB, so only a bit shift
2239// of 7 bits is actually possible.
2240//
2241// Note also that SHLQBI/SHLQBII are used in conjunction with SHLQBY/SHLQBYI
2242// to shift i64 and i128. SHLQBI is the residual left over after shifting by
2243// bytes with SHLQBY.
Scott Michel8b6b4202007-12-04 22:35:58 +00002244
Scott Michel97872d32008-02-23 18:41:37 +00002245class SHLQBIInst<dag OOL, dag IOL, list<dag> pattern>:
2246 RRForm<0b11011011100, OOL, IOL, "shlqbi\t$rT, $rA, $rB",
2247 RotateShift, pattern>;
2248
2249class SHLQBIVecInst<ValueType vectype>:
2250 SHLQBIInst<(outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB),
2251 [(set (vectype VECREG:$rT),
2252 (SPUshlquad_l_bits (vectype VECREG:$rA), R32C:$rB))]>;
2253
Scott Michel8c67fa42009-01-21 04:58:48 +00002254class SHLQBIRegInst<RegisterClass rclass>:
2255 SHLQBIInst<(outs rclass:$rT), (ins rclass:$rA, R32C:$rB),
2256 [/* no pattern */]>;
2257
Scott Michel97872d32008-02-23 18:41:37 +00002258multiclass ShiftLeftQuadByBits
2259{
2260 def v16i8: SHLQBIVecInst<v16i8>;
2261 def v8i16: SHLQBIVecInst<v8i16>;
2262 def v4i32: SHLQBIVecInst<v4i32>;
Scott Michel56a125e2008-11-22 23:50:42 +00002263 def v4f32: SHLQBIVecInst<v4f32>;
Scott Michel97872d32008-02-23 18:41:37 +00002264 def v2i64: SHLQBIVecInst<v2i64>;
Scott Michel56a125e2008-11-22 23:50:42 +00002265 def v2f64: SHLQBIVecInst<v2f64>;
Scott Michel8c67fa42009-01-21 04:58:48 +00002266
2267 def r128: SHLQBIRegInst<GPRC>;
Scott Michel97872d32008-02-23 18:41:37 +00002268}
2269
2270defm SHLQBI : ShiftLeftQuadByBits;
2271
2272// See note above on SHLQBI. In this case, the predicate actually does then
2273// enforcement, whereas with SHLQBI, we have to "take it on faith."
2274class SHLQBIIInst<dag OOL, dag IOL, list<dag> pattern>:
2275 RI7Form<0b11011111100, OOL, IOL, "shlqbii\t$rT, $rA, $val",
2276 RotateShift, pattern>;
2277
2278class SHLQBIIVecInst<ValueType vectype>:
2279 SHLQBIIInst<(outs VECREG:$rT), (ins VECREG:$rA, u7imm_i32:$val),
2280 [(set (vectype VECREG:$rT),
2281 (SPUshlquad_l_bits (vectype VECREG:$rA), (i32 bitshift:$val)))]>;
2282
2283multiclass ShiftLeftQuadByBitsImm
2284{
2285 def v16i8 : SHLQBIIVecInst<v16i8>;
2286 def v8i16 : SHLQBIIVecInst<v8i16>;
2287 def v4i32 : SHLQBIIVecInst<v4i32>;
Scott Michel56a125e2008-11-22 23:50:42 +00002288 def v4f32 : SHLQBIIVecInst<v4f32>;
Scott Michel97872d32008-02-23 18:41:37 +00002289 def v2i64 : SHLQBIIVecInst<v2i64>;
Scott Michel56a125e2008-11-22 23:50:42 +00002290 def v2f64 : SHLQBIIVecInst<v2f64>;
Scott Michel97872d32008-02-23 18:41:37 +00002291}
2292
2293defm SHLQBII : ShiftLeftQuadByBitsImm;
Scott Michel8b6b4202007-12-04 22:35:58 +00002294
2295// SHLQBY, SHLQBYI vector forms: Shift the entire vector to the left by bytes,
Scott Michel97872d32008-02-23 18:41:37 +00002296// not by bits. See notes above on SHLQBI.
Scott Michel8b6b4202007-12-04 22:35:58 +00002297
Scott Michel97872d32008-02-23 18:41:37 +00002298class SHLQBYInst<dag OOL, dag IOL, list<dag> pattern>:
Scott Michelfa888632008-11-25 00:23:16 +00002299 RI7Form<0b11111011100, OOL, IOL, "shlqby\t$rT, $rA, $rB",
Scott Michel97872d32008-02-23 18:41:37 +00002300 RotateShift, pattern>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002301
Scott Michel97872d32008-02-23 18:41:37 +00002302class SHLQBYVecInst<ValueType vectype>:
2303 SHLQBYInst<(outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB),
2304 [(set (vectype VECREG:$rT),
2305 (SPUshlquad_l_bytes (vectype VECREG:$rA), R32C:$rB))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002306
Scott Michel97872d32008-02-23 18:41:37 +00002307multiclass ShiftLeftQuadBytes
2308{
2309 def v16i8: SHLQBYVecInst<v16i8>;
2310 def v8i16: SHLQBYVecInst<v8i16>;
2311 def v4i32: SHLQBYVecInst<v4i32>;
Scott Michel56a125e2008-11-22 23:50:42 +00002312 def v4f32: SHLQBYVecInst<v4f32>;
Scott Michel97872d32008-02-23 18:41:37 +00002313 def v2i64: SHLQBYVecInst<v2i64>;
Scott Michel56a125e2008-11-22 23:50:42 +00002314 def v2f64: SHLQBYVecInst<v2f64>;
Scott Michel97872d32008-02-23 18:41:37 +00002315 def r128: SHLQBYInst<(outs GPRC:$rT), (ins GPRC:$rA, R32C:$rB),
2316 [(set GPRC:$rT, (SPUshlquad_l_bytes GPRC:$rA, R32C:$rB))]>;
2317}
Scott Michel8b6b4202007-12-04 22:35:58 +00002318
Scott Michel97872d32008-02-23 18:41:37 +00002319defm SHLQBY: ShiftLeftQuadBytes;
Scott Michel8b6b4202007-12-04 22:35:58 +00002320
Scott Michel97872d32008-02-23 18:41:37 +00002321class SHLQBYIInst<dag OOL, dag IOL, list<dag> pattern>:
2322 RI7Form<0b11111111100, OOL, IOL, "shlqbyi\t$rT, $rA, $val",
2323 RotateShift, pattern>;
Scott Michel438be252007-12-17 22:32:34 +00002324
Scott Michel97872d32008-02-23 18:41:37 +00002325class SHLQBYIVecInst<ValueType vectype>:
2326 SHLQBYIInst<(outs VECREG:$rT), (ins VECREG:$rA, u7imm_i32:$val),
2327 [(set (vectype VECREG:$rT),
2328 (SPUshlquad_l_bytes (vectype VECREG:$rA), (i32 uimm7:$val)))]>;
Scott Michel438be252007-12-17 22:32:34 +00002329
Scott Michel97872d32008-02-23 18:41:37 +00002330multiclass ShiftLeftQuadBytesImm
2331{
2332 def v16i8: SHLQBYIVecInst<v16i8>;
2333 def v8i16: SHLQBYIVecInst<v8i16>;
2334 def v4i32: SHLQBYIVecInst<v4i32>;
Scott Michel56a125e2008-11-22 23:50:42 +00002335 def v4f32: SHLQBYIVecInst<v4f32>;
Scott Michel97872d32008-02-23 18:41:37 +00002336 def v2i64: SHLQBYIVecInst<v2i64>;
Scott Michel56a125e2008-11-22 23:50:42 +00002337 def v2f64: SHLQBYIVecInst<v2f64>;
Scott Michel97872d32008-02-23 18:41:37 +00002338 def r128: SHLQBYIInst<(outs GPRC:$rT), (ins GPRC:$rA, u7imm_i32:$val),
2339 [(set GPRC:$rT,
2340 (SPUshlquad_l_bytes GPRC:$rA, (i32 uimm7:$val)))]>;
2341}
Scott Michel438be252007-12-17 22:32:34 +00002342
Scott Michel97872d32008-02-23 18:41:37 +00002343defm SHLQBYI : ShiftLeftQuadBytesImm;
Scott Michel438be252007-12-17 22:32:34 +00002344
Scott Michel8c67fa42009-01-21 04:58:48 +00002345class SHLQBYBIInst<dag OOL, dag IOL, list<dag> pattern>:
2346 RRForm<0b00111001111, OOL, IOL, "shlqbybi\t$rT, $rA, $rB",
2347 RotateShift, pattern>;
2348
2349class SHLQBYBIVecInst<ValueType vectype>:
2350 SHLQBYBIInst<(outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB),
2351 [/* no pattern */]>;
2352
2353class SHLQBYBIRegInst<RegisterClass rclass>:
2354 SHLQBYBIInst<(outs rclass:$rT), (ins rclass:$rA, R32C:$rB),
2355 [/* no pattern */]>;
2356
2357multiclass ShiftLeftQuadBytesBitCount
2358{
2359 def v16i8: SHLQBYBIVecInst<v16i8>;
2360 def v8i16: SHLQBYBIVecInst<v8i16>;
2361 def v4i32: SHLQBYBIVecInst<v4i32>;
2362 def v4f32: SHLQBYBIVecInst<v4f32>;
2363 def v2i64: SHLQBYBIVecInst<v2i64>;
2364 def v2f64: SHLQBYBIVecInst<v2f64>;
2365
2366 def r128: SHLQBYBIRegInst<GPRC>;
2367}
2368
2369defm SHLQBYBI : ShiftLeftQuadBytesBitCount;
2370
Scott Michel97872d32008-02-23 18:41:37 +00002371//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2372// Rotate halfword:
2373//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2374class ROTHInst<dag OOL, dag IOL, list<dag> pattern>:
2375 RRForm<0b00111010000, OOL, IOL, "roth\t$rT, $rA, $rB",
2376 RotateShift, pattern>;
2377
2378class ROTHVecInst<ValueType vectype>:
2379 ROTHInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
2380 [(set (vectype VECREG:$rT),
2381 (SPUvec_rotl VECREG:$rA, VECREG:$rB))]>;
2382
2383class ROTHRegInst<RegisterClass rclass>:
2384 ROTHInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB),
2385 [(set rclass:$rT, (rotl rclass:$rA, rclass:$rB))]>;
2386
2387multiclass RotateLeftHalfword
2388{
2389 def v8i16: ROTHVecInst<v8i16>;
2390 def r16: ROTHRegInst<R16C>;
2391}
2392
2393defm ROTH: RotateLeftHalfword;
2394
2395def ROTHr16_r32: ROTHInst<(outs R16C:$rT), (ins R16C:$rA, R32C:$rB),
2396 [(set R16C:$rT, (rotl R16C:$rA, R32C:$rB))]>;
2397
2398//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2399// Rotate halfword, immediate:
2400//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2401class ROTHIInst<dag OOL, dag IOL, list<dag> pattern>:
2402 RI7Form<0b00111110000, OOL, IOL, "rothi\t$rT, $rA, $val",
2403 RotateShift, pattern>;
2404
2405class ROTHIVecInst<ValueType vectype>:
2406 ROTHIInst<(outs VECREG:$rT), (ins VECREG:$rA, u7imm:$val),
2407 [(set (vectype VECREG:$rT),
2408 (SPUvec_rotl VECREG:$rA, (i16 uimm7:$val)))]>;
2409
2410multiclass RotateLeftHalfwordImm
2411{
2412 def v8i16: ROTHIVecInst<v8i16>;
2413 def r16: ROTHIInst<(outs R16C:$rT), (ins R16C:$rA, u7imm:$val),
2414 [(set R16C:$rT, (rotl R16C:$rA, (i16 uimm7:$val)))]>;
2415 def r16_r32: ROTHIInst<(outs R16C:$rT), (ins R16C:$rA, u7imm_i32:$val),
2416 [(set R16C:$rT, (rotl R16C:$rA, (i32 uimm7:$val)))]>;
2417}
2418
2419defm ROTHI: RotateLeftHalfwordImm;
2420
2421def : Pat<(SPUvec_rotl VECREG:$rA, (i32 uimm7:$val)),
Scott Michel8b6b4202007-12-04 22:35:58 +00002422 (ROTHIv8i16 VECREG:$rA, imm:$val)>;
Scott Michel06eabde2008-12-27 04:51:36 +00002423
Scott Michel97872d32008-02-23 18:41:37 +00002424//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2425// Rotate word:
2426//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
Scott Michel8b6b4202007-12-04 22:35:58 +00002427
Scott Michel97872d32008-02-23 18:41:37 +00002428class ROTInst<dag OOL, dag IOL, list<dag> pattern>:
2429 RRForm<0b00011010000, OOL, IOL, "rot\t$rT, $rA, $rB",
2430 RotateShift, pattern>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002431
Scott Michel97872d32008-02-23 18:41:37 +00002432class ROTVecInst<ValueType vectype>:
2433 ROTInst<(outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB),
2434 [(set (vectype VECREG:$rT),
2435 (SPUvec_rotl (vectype VECREG:$rA), R32C:$rB))]>;
Scott Michel438be252007-12-17 22:32:34 +00002436
Scott Michel97872d32008-02-23 18:41:37 +00002437class ROTRegInst<RegisterClass rclass>:
2438 ROTInst<(outs rclass:$rT), (ins rclass:$rA, R32C:$rB),
2439 [(set rclass:$rT,
2440 (rotl rclass:$rA, R32C:$rB))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002441
Scott Michel97872d32008-02-23 18:41:37 +00002442multiclass RotateLeftWord
2443{
2444 def v4i32: ROTVecInst<v4i32>;
2445 def r32: ROTRegInst<R32C>;
2446}
2447
2448defm ROT: RotateLeftWord;
Scott Michel8b6b4202007-12-04 22:35:58 +00002449
Scott Michel438be252007-12-17 22:32:34 +00002450// The rotate amount is in the same bits whether we've got an 8-bit, 16-bit or
2451// 32-bit register
2452def ROTr32_r16_anyext:
Scott Michel97872d32008-02-23 18:41:37 +00002453 ROTInst<(outs R32C:$rT), (ins R32C:$rA, R16C:$rB),
2454 [(set R32C:$rT, (rotl R32C:$rA, (i32 (anyext R16C:$rB))))]>;
Scott Michel438be252007-12-17 22:32:34 +00002455
2456def : Pat<(rotl R32C:$rA, (i32 (zext R16C:$rB))),
2457 (ROTr32_r16_anyext R32C:$rA, R16C:$rB)>;
2458
2459def : Pat<(rotl R32C:$rA, (i32 (sext R16C:$rB))),
2460 (ROTr32_r16_anyext R32C:$rA, R16C:$rB)>;
2461
2462def ROTr32_r8_anyext:
Scott Michel97872d32008-02-23 18:41:37 +00002463 ROTInst<(outs R32C:$rT), (ins R32C:$rA, R8C:$rB),
2464 [(set R32C:$rT, (rotl R32C:$rA, (i32 (anyext R8C:$rB))))]>;
Scott Michel438be252007-12-17 22:32:34 +00002465
2466def : Pat<(rotl R32C:$rA, (i32 (zext R8C:$rB))),
2467 (ROTr32_r8_anyext R32C:$rA, R8C:$rB)>;
2468
2469def : Pat<(rotl R32C:$rA, (i32 (sext R8C:$rB))),
2470 (ROTr32_r8_anyext R32C:$rA, R8C:$rB)>;
2471
Scott Michel97872d32008-02-23 18:41:37 +00002472//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2473// Rotate word, immediate
2474//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
Scott Michel8b6b4202007-12-04 22:35:58 +00002475
Scott Michel97872d32008-02-23 18:41:37 +00002476class ROTIInst<dag OOL, dag IOL, list<dag> pattern>:
2477 RI7Form<0b00011110000, OOL, IOL, "roti\t$rT, $rA, $val",
2478 RotateShift, pattern>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002479
Scott Michel97872d32008-02-23 18:41:37 +00002480class ROTIVecInst<ValueType vectype, Operand optype, ValueType inttype, PatLeaf pred>:
2481 ROTIInst<(outs VECREG:$rT), (ins VECREG:$rA, optype:$val),
2482 [(set (vectype VECREG:$rT),
2483 (SPUvec_rotl (vectype VECREG:$rA), (inttype pred:$val)))]>;
Scott Michel438be252007-12-17 22:32:34 +00002484
Scott Michel97872d32008-02-23 18:41:37 +00002485class ROTIRegInst<RegisterClass rclass, Operand optype, ValueType inttype, PatLeaf pred>:
2486 ROTIInst<(outs rclass:$rT), (ins rclass:$rA, optype:$val),
2487 [(set rclass:$rT, (rotl rclass:$rA, (inttype pred:$val)))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002488
Scott Michel97872d32008-02-23 18:41:37 +00002489multiclass RotateLeftWordImm
2490{
2491 def v4i32: ROTIVecInst<v4i32, u7imm_i32, i32, uimm7>;
2492 def v4i32_i16: ROTIVecInst<v4i32, u7imm, i16, uimm7>;
2493 def v4i32_i8: ROTIVecInst<v4i32, u7imm_i8, i8, uimm7>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002494
Scott Michel97872d32008-02-23 18:41:37 +00002495 def r32: ROTIRegInst<R32C, u7imm_i32, i32, uimm7>;
2496 def r32_i16: ROTIRegInst<R32C, u7imm, i16, uimm7>;
2497 def r32_i8: ROTIRegInst<R32C, u7imm_i8, i8, uimm7>;
2498}
Scott Michel438be252007-12-17 22:32:34 +00002499
Scott Michel97872d32008-02-23 18:41:37 +00002500defm ROTI : RotateLeftWordImm;
2501
2502//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2503// Rotate quad by byte (count)
2504//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2505
2506class ROTQBYInst<dag OOL, dag IOL, list<dag> pattern>:
2507 RRForm<0b00111011100, OOL, IOL, "rotqby\t$rT, $rA, $rB",
2508 RotateShift, pattern>;
2509
2510class ROTQBYVecInst<ValueType vectype>:
2511 ROTQBYInst<(outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB),
2512 [(set (vectype VECREG:$rT),
2513 (SPUrotbytes_left (vectype VECREG:$rA), R32C:$rB))]>;
2514
2515multiclass RotateQuadLeftByBytes
2516{
2517 def v16i8: ROTQBYVecInst<v16i8>;
2518 def v8i16: ROTQBYVecInst<v8i16>;
2519 def v4i32: ROTQBYVecInst<v4i32>;
Scott Michele2641a12008-12-04 21:01:44 +00002520 def v4f32: ROTQBYVecInst<v4f32>;
Scott Michel97872d32008-02-23 18:41:37 +00002521 def v2i64: ROTQBYVecInst<v2i64>;
Scott Michele2641a12008-12-04 21:01:44 +00002522 def v2f64: ROTQBYVecInst<v2f64>;
Scott Michel97872d32008-02-23 18:41:37 +00002523}
2524
2525defm ROTQBY: RotateQuadLeftByBytes;
Scott Michel8b6b4202007-12-04 22:35:58 +00002526
Scott Michel97872d32008-02-23 18:41:37 +00002527//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2528// Rotate quad by byte (count), immediate
2529//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2530
2531class ROTQBYIInst<dag OOL, dag IOL, list<dag> pattern>:
2532 RI7Form<0b00111111100, OOL, IOL, "rotqbyi\t$rT, $rA, $val",
2533 RotateShift, pattern>;
2534
2535class ROTQBYIVecInst<ValueType vectype>:
2536 ROTQBYIInst<(outs VECREG:$rT), (ins VECREG:$rA, u7imm:$val),
2537 [(set (vectype VECREG:$rT),
2538 (SPUrotbytes_left (vectype VECREG:$rA), (i16 uimm7:$val)))]>;
2539
2540multiclass RotateQuadByBytesImm
2541{
2542 def v16i8: ROTQBYIVecInst<v16i8>;
2543 def v8i16: ROTQBYIVecInst<v8i16>;
2544 def v4i32: ROTQBYIVecInst<v4i32>;
Scott Michele2641a12008-12-04 21:01:44 +00002545 def v4f32: ROTQBYIVecInst<v4f32>;
Scott Michel97872d32008-02-23 18:41:37 +00002546 def v2i64: ROTQBYIVecInst<v2i64>;
Scott Michele2641a12008-12-04 21:01:44 +00002547 def vfi64: ROTQBYIVecInst<v2f64>;
Scott Michel97872d32008-02-23 18:41:37 +00002548}
2549
2550defm ROTQBYI: RotateQuadByBytesImm;
Scott Michel8b6b4202007-12-04 22:35:58 +00002551
Scott Michel8b6b4202007-12-04 22:35:58 +00002552// See ROTQBY note above.
Scott Michel67224b22008-06-02 22:18:03 +00002553class ROTQBYBIInst<dag OOL, dag IOL, list<dag> pattern>:
2554 RI7Form<0b00110011100, OOL, IOL,
2555 "rotqbybi\t$rT, $rA, $shift",
2556 RotateShift, pattern>;
2557
2558class ROTQBYBIVecInst<ValueType vectype, RegisterClass rclass>:
2559 ROTQBYBIInst<(outs VECREG:$rT), (ins VECREG:$rA, rclass:$shift),
2560 [(set (vectype VECREG:$rT),
2561 (SPUrotbytes_left_bits (vectype VECREG:$rA), rclass:$shift))]>;
2562
2563multiclass RotateQuadByBytesByBitshift {
2564 def v16i8_r32: ROTQBYBIVecInst<v16i8, R32C>;
2565 def v8i16_r32: ROTQBYBIVecInst<v8i16, R32C>;
2566 def v4i32_r32: ROTQBYBIVecInst<v4i32, R32C>;
2567 def v2i64_r32: ROTQBYBIVecInst<v2i64, R32C>;
2568}
2569
2570defm ROTQBYBI : RotateQuadByBytesByBitshift;
Scott Michel8b6b4202007-12-04 22:35:58 +00002571
Scott Michel97872d32008-02-23 18:41:37 +00002572//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
Scott Michel8b6b4202007-12-04 22:35:58 +00002573// See ROTQBY note above.
2574//
2575// Assume that the user of this instruction knows to shift the rotate count
2576// into bit 29
Scott Michel97872d32008-02-23 18:41:37 +00002577//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
Scott Michel8b6b4202007-12-04 22:35:58 +00002578
Scott Michel97872d32008-02-23 18:41:37 +00002579class ROTQBIInst<dag OOL, dag IOL, list<dag> pattern>:
2580 RRForm<0b00011011100, OOL, IOL, "rotqbi\t$rT, $rA, $rB",
2581 RotateShift, pattern>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002582
Scott Michel97872d32008-02-23 18:41:37 +00002583class ROTQBIVecInst<ValueType vectype>:
Scott Michel4d07fb72008-12-30 23:28:25 +00002584 ROTQBIInst<(outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB),
Scott Michel97872d32008-02-23 18:41:37 +00002585 [/* no pattern yet */]>;
2586
2587class ROTQBIRegInst<RegisterClass rclass>:
Scott Michel4d07fb72008-12-30 23:28:25 +00002588 ROTQBIInst<(outs rclass:$rT), (ins rclass:$rA, R32C:$rB),
Scott Michel97872d32008-02-23 18:41:37 +00002589 [/* no pattern yet */]>;
2590
2591multiclass RotateQuadByBitCount
2592{
2593 def v16i8: ROTQBIVecInst<v16i8>;
2594 def v8i16: ROTQBIVecInst<v8i16>;
2595 def v4i32: ROTQBIVecInst<v4i32>;
2596 def v2i64: ROTQBIVecInst<v2i64>;
2597
2598 def r128: ROTQBIRegInst<GPRC>;
2599 def r64: ROTQBIRegInst<R64C>;
2600}
2601
2602defm ROTQBI: RotateQuadByBitCount;
Scott Michel06eabde2008-12-27 04:51:36 +00002603
Scott Michel97872d32008-02-23 18:41:37 +00002604class ROTQBIIInst<dag OOL, dag IOL, list<dag> pattern>:
2605 RI7Form<0b00011111100, OOL, IOL, "rotqbii\t$rT, $rA, $val",
2606 RotateShift, pattern>;
2607
2608class ROTQBIIVecInst<ValueType vectype, Operand optype, ValueType inttype,
2609 PatLeaf pred>:
2610 ROTQBIIInst<(outs VECREG:$rT), (ins VECREG:$rA, optype:$val),
2611 [/* no pattern yet */]>;
2612
2613class ROTQBIIRegInst<RegisterClass rclass, Operand optype, ValueType inttype,
2614 PatLeaf pred>:
2615 ROTQBIIInst<(outs rclass:$rT), (ins rclass:$rA, optype:$val),
2616 [/* no pattern yet */]>;
2617
2618multiclass RotateQuadByBitCountImm
2619{
2620 def v16i8: ROTQBIIVecInst<v16i8, u7imm_i32, i32, uimm7>;
2621 def v8i16: ROTQBIIVecInst<v8i16, u7imm_i32, i32, uimm7>;
2622 def v4i32: ROTQBIIVecInst<v4i32, u7imm_i32, i32, uimm7>;
2623 def v2i64: ROTQBIIVecInst<v2i64, u7imm_i32, i32, uimm7>;
2624
2625 def r128: ROTQBIIRegInst<GPRC, u7imm_i32, i32, uimm7>;
2626 def r64: ROTQBIIRegInst<R64C, u7imm_i32, i32, uimm7>;
2627}
2628
2629defm ROTQBII : RotateQuadByBitCountImm;
2630
2631//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
Scott Michel8b6b4202007-12-04 22:35:58 +00002632// ROTHM v8i16 form:
2633// NOTE(1): No vector rotate is generated by the C/C++ frontend (today),
2634// so this only matches a synthetically generated/lowered code
2635// fragment.
2636// NOTE(2): $rB must be negated before the right rotate!
Scott Michel97872d32008-02-23 18:41:37 +00002637//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
Scott Michel8b6b4202007-12-04 22:35:58 +00002638
Scott Michel97872d32008-02-23 18:41:37 +00002639class ROTHMInst<dag OOL, dag IOL, list<dag> pattern>:
2640 RRForm<0b10111010000, OOL, IOL, "rothm\t$rT, $rA, $rB",
2641 RotateShift, pattern>;
2642
2643def ROTHMv8i16:
2644 ROTHMInst<(outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB),
2645 [/* see patterns below - $rB must be negated */]>;
2646
2647def : Pat<(SPUvec_srl (v8i16 VECREG:$rA), R32C:$rB),
Scott Michel8b6b4202007-12-04 22:35:58 +00002648 (ROTHMv8i16 VECREG:$rA, (SFIr32 R32C:$rB, 0))>;
2649
Scott Michel97872d32008-02-23 18:41:37 +00002650def : Pat<(SPUvec_srl (v8i16 VECREG:$rA), R16C:$rB),
Scott Michel8b6b4202007-12-04 22:35:58 +00002651 (ROTHMv8i16 VECREG:$rA,
2652 (SFIr32 (XSHWr16 R16C:$rB), 0))>;
2653
Scott Michel97872d32008-02-23 18:41:37 +00002654def : Pat<(SPUvec_srl (v8i16 VECREG:$rA), R8C:$rB),
Scott Michel8b6b4202007-12-04 22:35:58 +00002655 (ROTHMv8i16 VECREG:$rA,
Scott Michel438be252007-12-17 22:32:34 +00002656 (SFIr32 (XSHWr16 (XSBHr8 R8C:$rB) ), 0))>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002657
2658// ROTHM r16 form: Rotate 16-bit quantity to right, zero fill at the left
2659// Note: This instruction doesn't match a pattern because rB must be negated
2660// for the instruction to work. Thus, the pattern below the instruction!
Scott Michel97872d32008-02-23 18:41:37 +00002661
Scott Michel8b6b4202007-12-04 22:35:58 +00002662def ROTHMr16:
Scott Michel97872d32008-02-23 18:41:37 +00002663 ROTHMInst<(outs R16C:$rT), (ins R16C:$rA, R32C:$rB),
2664 [/* see patterns below - $rB must be negated! */]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002665
2666def : Pat<(srl R16C:$rA, R32C:$rB),
2667 (ROTHMr16 R16C:$rA, (SFIr32 R32C:$rB, 0))>;
2668
2669def : Pat<(srl R16C:$rA, R16C:$rB),
2670 (ROTHMr16 R16C:$rA,
2671 (SFIr32 (XSHWr16 R16C:$rB), 0))>;
2672
Scott Michel438be252007-12-17 22:32:34 +00002673def : Pat<(srl R16C:$rA, R8C:$rB),
Scott Michel8b6b4202007-12-04 22:35:58 +00002674 (ROTHMr16 R16C:$rA,
Scott Michel438be252007-12-17 22:32:34 +00002675 (SFIr32 (XSHWr16 (XSBHr8 R8C:$rB) ), 0))>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002676
2677// ROTHMI v8i16 form: See the comment for ROTHM v8i16. The difference here is
2678// that the immediate can be complemented, so that the user doesn't have to
2679// worry about it.
Scott Michel8b6b4202007-12-04 22:35:58 +00002680
Scott Michel97872d32008-02-23 18:41:37 +00002681class ROTHMIInst<dag OOL, dag IOL, list<dag> pattern>:
2682 RI7Form<0b10111110000, OOL, IOL, "rothmi\t$rT, $rA, $val",
2683 RotateShift, pattern>;
2684
2685def ROTHMIv8i16:
2686 ROTHMIInst<(outs VECREG:$rT), (ins VECREG:$rA, rothNeg7imm:$val),
2687 [/* no pattern */]>;
2688
2689def : Pat<(SPUvec_srl (v8i16 VECREG:$rA), (i32 imm:$val)),
2690 (ROTHMIv8i16 VECREG:$rA, imm:$val)>;
2691
2692def: Pat<(SPUvec_srl (v8i16 VECREG:$rA), (i16 imm:$val)),
Scott Michel8b6b4202007-12-04 22:35:58 +00002693 (ROTHMIv8i16 VECREG:$rA, imm:$val)>;
Scott Michel06eabde2008-12-27 04:51:36 +00002694
Scott Michel97872d32008-02-23 18:41:37 +00002695def: Pat<(SPUvec_srl (v8i16 VECREG:$rA), (i8 imm:$val)),
Scott Michel5a6f17b2008-01-30 02:55:46 +00002696 (ROTHMIv8i16 VECREG:$rA, imm:$val)>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002697
2698def ROTHMIr16:
Scott Michel97872d32008-02-23 18:41:37 +00002699 ROTHMIInst<(outs R16C:$rT), (ins R16C:$rA, rothNeg7imm:$val),
2700 [/* no pattern */]>;
2701
2702def: Pat<(srl R16C:$rA, (i32 uimm7:$val)),
2703 (ROTHMIr16 R16C:$rA, uimm7:$val)>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002704
2705def: Pat<(srl R16C:$rA, (i16 uimm7:$val)),
2706 (ROTHMIr16 R16C:$rA, uimm7:$val)>;
2707
Scott Michel438be252007-12-17 22:32:34 +00002708def: Pat<(srl R16C:$rA, (i8 uimm7:$val)),
2709 (ROTHMIr16 R16C:$rA, uimm7:$val)>;
2710
Scott Michel8b6b4202007-12-04 22:35:58 +00002711// ROTM v4i32 form: See the ROTHM v8i16 comments.
Scott Michel97872d32008-02-23 18:41:37 +00002712class ROTMInst<dag OOL, dag IOL, list<dag> pattern>:
2713 RRForm<0b10011010000, OOL, IOL, "rotm\t$rT, $rA, $rB",
2714 RotateShift, pattern>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002715
Scott Michel97872d32008-02-23 18:41:37 +00002716def ROTMv4i32:
2717 ROTMInst<(outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB),
2718 [/* see patterns below - $rB must be negated */]>;
2719
2720def : Pat<(SPUvec_srl VECREG:$rA, R32C:$rB),
Scott Michel8b6b4202007-12-04 22:35:58 +00002721 (ROTMv4i32 VECREG:$rA, (SFIr32 R32C:$rB, 0))>;
2722
Scott Michel97872d32008-02-23 18:41:37 +00002723def : Pat<(SPUvec_srl VECREG:$rA, R16C:$rB),
Scott Michel8b6b4202007-12-04 22:35:58 +00002724 (ROTMv4i32 VECREG:$rA,
2725 (SFIr32 (XSHWr16 R16C:$rB), 0))>;
2726
Scott Michel97872d32008-02-23 18:41:37 +00002727def : Pat<(SPUvec_srl VECREG:$rA, R8C:$rB),
Scott Michel8b6b4202007-12-04 22:35:58 +00002728 (ROTMv4i32 VECREG:$rA,
Scott Michel97872d32008-02-23 18:41:37 +00002729 (SFIr32 (XSHWr16 (XSBHr8 R8C:$rB)), 0))>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002730
2731def ROTMr32:
Scott Michel97872d32008-02-23 18:41:37 +00002732 ROTMInst<(outs R32C:$rT), (ins R32C:$rA, R32C:$rB),
2733 [/* see patterns below - $rB must be negated */]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002734
2735def : Pat<(srl R32C:$rA, R32C:$rB),
2736 (ROTMr32 R32C:$rA, (SFIr32 R32C:$rB, 0))>;
2737
2738def : Pat<(srl R32C:$rA, R16C:$rB),
2739 (ROTMr32 R32C:$rA,
2740 (SFIr32 (XSHWr16 R16C:$rB), 0))>;
2741
Scott Michel438be252007-12-17 22:32:34 +00002742def : Pat<(srl R32C:$rA, R8C:$rB),
2743 (ROTMr32 R32C:$rA,
2744 (SFIr32 (XSHWr16 (XSBHr8 R8C:$rB)), 0))>;
2745
Scott Michel8b6b4202007-12-04 22:35:58 +00002746// ROTMI v4i32 form: See the comment for ROTHM v8i16.
2747def ROTMIv4i32:
2748 RI7Form<0b10011110000, (outs VECREG:$rT), (ins VECREG:$rA, rotNeg7imm:$val),
2749 "rotmi\t$rT, $rA, $val", RotateShift,
2750 [(set (v4i32 VECREG:$rT),
Scott Michel97872d32008-02-23 18:41:37 +00002751 (SPUvec_srl VECREG:$rA, (i32 uimm7:$val)))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002752
Scott Michel97872d32008-02-23 18:41:37 +00002753def : Pat<(SPUvec_srl VECREG:$rA, (i16 uimm7:$val)),
Scott Michel8b6b4202007-12-04 22:35:58 +00002754 (ROTMIv4i32 VECREG:$rA, uimm7:$val)>;
Scott Michel06eabde2008-12-27 04:51:36 +00002755
Scott Michel97872d32008-02-23 18:41:37 +00002756def : Pat<(SPUvec_srl VECREG:$rA, (i8 uimm7:$val)),
Scott Michel438be252007-12-17 22:32:34 +00002757 (ROTMIv4i32 VECREG:$rA, uimm7:$val)>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002758
2759// ROTMI r32 form: know how to complement the immediate value.
2760def ROTMIr32:
2761 RI7Form<0b10011110000, (outs R32C:$rT), (ins R32C:$rA, rotNeg7imm:$val),
2762 "rotmi\t$rT, $rA, $val", RotateShift,
2763 [(set R32C:$rT, (srl R32C:$rA, (i32 uimm7:$val)))]>;
2764
2765def : Pat<(srl R32C:$rA, (i16 imm:$val)),
2766 (ROTMIr32 R32C:$rA, uimm7:$val)>;
2767
Scott Michel438be252007-12-17 22:32:34 +00002768def : Pat<(srl R32C:$rA, (i8 imm:$val)),
2769 (ROTMIr32 R32C:$rA, uimm7:$val)>;
2770
Scott Michel97872d32008-02-23 18:41:37 +00002771//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
Scott Michel2ef773a2009-01-06 03:36:14 +00002772// ROTQMBY: This is a vector form merely so that when used in an
Scott Michel8b6b4202007-12-04 22:35:58 +00002773// instruction pattern, type checking will succeed. This instruction assumes
Scott Michel97872d32008-02-23 18:41:37 +00002774// that the user knew to negate $rB.
Scott Michel97872d32008-02-23 18:41:37 +00002775//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
Scott Michel8b6b4202007-12-04 22:35:58 +00002776
Scott Michel97872d32008-02-23 18:41:37 +00002777class ROTQMBYInst<dag OOL, dag IOL, list<dag> pattern>:
2778 RRForm<0b10111011100, OOL, IOL, "rotqmby\t$rT, $rA, $rB",
2779 RotateShift, pattern>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002780
Scott Michel97872d32008-02-23 18:41:37 +00002781class ROTQMBYVecInst<ValueType vectype>:
2782 ROTQMBYInst<(outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB),
2783 [/* no pattern, $rB must be negated */]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002784
Scott Michel97872d32008-02-23 18:41:37 +00002785class ROTQMBYRegInst<RegisterClass rclass>:
2786 ROTQMBYInst<(outs rclass:$rT), (ins rclass:$rA, R32C:$rB),
Scott Michel4d07fb72008-12-30 23:28:25 +00002787 [/* no pattern */]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002788
Scott Michel97872d32008-02-23 18:41:37 +00002789multiclass RotateQuadBytes
2790{
2791 def v16i8: ROTQMBYVecInst<v16i8>;
2792 def v8i16: ROTQMBYVecInst<v8i16>;
2793 def v4i32: ROTQMBYVecInst<v4i32>;
2794 def v2i64: ROTQMBYVecInst<v2i64>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002795
Scott Michel97872d32008-02-23 18:41:37 +00002796 def r128: ROTQMBYRegInst<GPRC>;
2797 def r64: ROTQMBYRegInst<R64C>;
2798}
2799
2800defm ROTQMBY : RotateQuadBytes;
2801
Scott Michel97872d32008-02-23 18:41:37 +00002802class ROTQMBYIInst<dag OOL, dag IOL, list<dag> pattern>:
2803 RI7Form<0b10111111100, OOL, IOL, "rotqmbyi\t$rT, $rA, $val",
2804 RotateShift, pattern>;
2805
2806class ROTQMBYIVecInst<ValueType vectype>:
2807 ROTQMBYIInst<(outs VECREG:$rT), (ins VECREG:$rA, rotNeg7imm:$val),
Scott Michel4d07fb72008-12-30 23:28:25 +00002808 [/* no pattern */]>;
Scott Michel97872d32008-02-23 18:41:37 +00002809
Scott Michel2ef773a2009-01-06 03:36:14 +00002810class ROTQMBYIRegInst<RegisterClass rclass, Operand optype, ValueType inttype,
2811 PatLeaf pred>:
Scott Michel97872d32008-02-23 18:41:37 +00002812 ROTQMBYIInst<(outs rclass:$rT), (ins rclass:$rA, optype:$val),
Scott Michel4d07fb72008-12-30 23:28:25 +00002813 [/* no pattern */]>;
Scott Michel97872d32008-02-23 18:41:37 +00002814
Scott Michel2ef773a2009-01-06 03:36:14 +00002815// 128-bit zero extension form:
2816class ROTQMBYIZExtInst<RegisterClass rclass, Operand optype, PatLeaf pred>:
2817 ROTQMBYIInst<(outs GPRC:$rT), (ins rclass:$rA, optype:$val),
2818 [/* no pattern */]>;
2819
Scott Michel97872d32008-02-23 18:41:37 +00002820multiclass RotateQuadBytesImm
2821{
2822 def v16i8: ROTQMBYIVecInst<v16i8>;
2823 def v8i16: ROTQMBYIVecInst<v8i16>;
2824 def v4i32: ROTQMBYIVecInst<v4i32>;
2825 def v2i64: ROTQMBYIVecInst<v2i64>;
2826
2827 def r128: ROTQMBYIRegInst<GPRC, rotNeg7imm, i32, uimm7>;
2828 def r64: ROTQMBYIRegInst<R64C, rotNeg7imm, i32, uimm7>;
Scott Michel2ef773a2009-01-06 03:36:14 +00002829
2830 def r128_zext_r8: ROTQMBYIZExtInst<R8C, rotNeg7imm, uimm7>;
2831 def r128_zext_r16: ROTQMBYIZExtInst<R16C, rotNeg7imm, uimm7>;
2832 def r128_zext_r32: ROTQMBYIZExtInst<R32C, rotNeg7imm, uimm7>;
2833 def r128_zext_r64: ROTQMBYIZExtInst<R64C, rotNeg7imm, uimm7>;
Scott Michel97872d32008-02-23 18:41:37 +00002834}
2835
2836defm ROTQMBYI : RotateQuadBytesImm;
2837
Scott Michel97872d32008-02-23 18:41:37 +00002838//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2839// Rotate right and mask by bit count
2840//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2841
2842class ROTQMBYBIInst<dag OOL, dag IOL, list<dag> pattern>:
2843 RRForm<0b10110011100, OOL, IOL, "rotqmbybi\t$rT, $rA, $rB",
2844 RotateShift, pattern>;
2845
2846class ROTQMBYBIVecInst<ValueType vectype>:
Scott Michel4d07fb72008-12-30 23:28:25 +00002847 ROTQMBYBIInst<(outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB),
2848 [/* no pattern, */]>;
Scott Michel97872d32008-02-23 18:41:37 +00002849
2850multiclass RotateMaskQuadByBitCount
2851{
2852 def v16i8: ROTQMBYBIVecInst<v16i8>;
2853 def v8i16: ROTQMBYBIVecInst<v8i16>;
2854 def v4i32: ROTQMBYBIVecInst<v4i32>;
2855 def v2i64: ROTQMBYBIVecInst<v2i64>;
2856}
2857
2858defm ROTQMBYBI: RotateMaskQuadByBitCount;
2859
2860//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2861// Rotate quad and mask by bits
2862// Note that the rotate amount has to be negated
2863//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2864
2865class ROTQMBIInst<dag OOL, dag IOL, list<dag> pattern>:
2866 RRForm<0b10011011100, OOL, IOL, "rotqmbi\t$rT, $rA, $rB",
2867 RotateShift, pattern>;
2868
2869class ROTQMBIVecInst<ValueType vectype>:
2870 ROTQMBIInst<(outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB),
2871 [/* no pattern */]>;
2872
2873class ROTQMBIRegInst<RegisterClass rclass>:
2874 ROTQMBIInst<(outs rclass:$rT), (ins rclass:$rA, R32C:$rB),
2875 [/* no pattern */]>;
2876
2877multiclass RotateMaskQuadByBits
2878{
2879 def v16i8: ROTQMBIVecInst<v16i8>;
2880 def v8i16: ROTQMBIVecInst<v8i16>;
2881 def v4i32: ROTQMBIVecInst<v4i32>;
2882 def v2i64: ROTQMBIVecInst<v2i64>;
2883
2884 def r128: ROTQMBIRegInst<GPRC>;
2885 def r64: ROTQMBIRegInst<R64C>;
2886}
2887
2888defm ROTQMBI: RotateMaskQuadByBits;
2889
Scott Michel97872d32008-02-23 18:41:37 +00002890//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2891// Rotate quad and mask by bits, immediate
2892//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2893
2894class ROTQMBIIInst<dag OOL, dag IOL, list<dag> pattern>:
2895 RI7Form<0b10011111100, OOL, IOL, "rotqmbii\t$rT, $rA, $val",
2896 RotateShift, pattern>;
2897
2898class ROTQMBIIVecInst<ValueType vectype>:
2899 ROTQMBIIInst<(outs VECREG:$rT), (ins VECREG:$rA, rotNeg7imm:$val),
Scott Michel4d07fb72008-12-30 23:28:25 +00002900 [/* no pattern */]>;
Scott Michel97872d32008-02-23 18:41:37 +00002901
2902class ROTQMBIIRegInst<RegisterClass rclass>:
2903 ROTQMBIIInst<(outs rclass:$rT), (ins rclass:$rA, rotNeg7imm:$val),
Scott Michel4d07fb72008-12-30 23:28:25 +00002904 [/* no pattern */]>;
Scott Michel97872d32008-02-23 18:41:37 +00002905
2906multiclass RotateMaskQuadByBitsImm
2907{
2908 def v16i8: ROTQMBIIVecInst<v16i8>;
2909 def v8i16: ROTQMBIIVecInst<v8i16>;
2910 def v4i32: ROTQMBIIVecInst<v4i32>;
2911 def v2i64: ROTQMBIIVecInst<v2i64>;
2912
2913 def r128: ROTQMBIIRegInst<GPRC>;
2914 def r64: ROTQMBIIRegInst<R64C>;
2915}
2916
2917defm ROTQMBII: RotateMaskQuadByBitsImm;
2918
2919//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2920//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
Scott Michel8b6b4202007-12-04 22:35:58 +00002921
2922def ROTMAHv8i16:
2923 RRForm<0b01111010000, (outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB),
2924 "rotmah\t$rT, $rA, $rB", RotateShift,
2925 [/* see patterns below - $rB must be negated */]>;
2926
Scott Michel97872d32008-02-23 18:41:37 +00002927def : Pat<(SPUvec_sra VECREG:$rA, R32C:$rB),
Scott Michel8b6b4202007-12-04 22:35:58 +00002928 (ROTMAHv8i16 VECREG:$rA, (SFIr32 R32C:$rB, 0))>;
2929
Scott Michel97872d32008-02-23 18:41:37 +00002930def : Pat<(SPUvec_sra VECREG:$rA, R16C:$rB),
Scott Michel8b6b4202007-12-04 22:35:58 +00002931 (ROTMAHv8i16 VECREG:$rA,
2932 (SFIr32 (XSHWr16 R16C:$rB), 0))>;
2933
Scott Michel97872d32008-02-23 18:41:37 +00002934def : Pat<(SPUvec_sra VECREG:$rA, R8C:$rB),
Scott Michel438be252007-12-17 22:32:34 +00002935 (ROTMAHv8i16 VECREG:$rA,
2936 (SFIr32 (XSHWr16 (XSBHr8 R8C:$rB)), 0))>;
2937
Scott Michel8b6b4202007-12-04 22:35:58 +00002938def ROTMAHr16:
2939 RRForm<0b01111010000, (outs R16C:$rT), (ins R16C:$rA, R32C:$rB),
2940 "rotmah\t$rT, $rA, $rB", RotateShift,
2941 [/* see patterns below - $rB must be negated */]>;
2942
2943def : Pat<(sra R16C:$rA, R32C:$rB),
2944 (ROTMAHr16 R16C:$rA, (SFIr32 R32C:$rB, 0))>;
2945
2946def : Pat<(sra R16C:$rA, R16C:$rB),
2947 (ROTMAHr16 R16C:$rA,
2948 (SFIr32 (XSHWr16 R16C:$rB), 0))>;
2949
Scott Michel438be252007-12-17 22:32:34 +00002950def : Pat<(sra R16C:$rA, R8C:$rB),
2951 (ROTMAHr16 R16C:$rA,
2952 (SFIr32 (XSHWr16 (XSBHr8 R8C:$rB)), 0))>;
2953
Scott Michel8b6b4202007-12-04 22:35:58 +00002954def ROTMAHIv8i16:
2955 RRForm<0b01111110000, (outs VECREG:$rT), (ins VECREG:$rA, rothNeg7imm:$val),
2956 "rotmahi\t$rT, $rA, $val", RotateShift,
2957 [(set (v8i16 VECREG:$rT),
Scott Michel97872d32008-02-23 18:41:37 +00002958 (SPUvec_sra (v8i16 VECREG:$rA), (i32 uimm7:$val)))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002959
Scott Michel97872d32008-02-23 18:41:37 +00002960def : Pat<(SPUvec_sra (v8i16 VECREG:$rA), (i16 uimm7:$val)),
Scott Michel8b6b4202007-12-04 22:35:58 +00002961 (ROTMAHIv8i16 (v8i16 VECREG:$rA), (i32 uimm7:$val))>;
2962
Scott Michel97872d32008-02-23 18:41:37 +00002963def : Pat<(SPUvec_sra (v8i16 VECREG:$rA), (i8 uimm7:$val)),
Scott Michel438be252007-12-17 22:32:34 +00002964 (ROTMAHIv8i16 (v8i16 VECREG:$rA), (i32 uimm7:$val))>;
2965
Scott Michel8b6b4202007-12-04 22:35:58 +00002966def ROTMAHIr16:
2967 RRForm<0b01111110000, (outs R16C:$rT), (ins R16C:$rA, rothNeg7imm_i16:$val),
2968 "rotmahi\t$rT, $rA, $val", RotateShift,
2969 [(set R16C:$rT, (sra R16C:$rA, (i16 uimm7:$val)))]>;
2970
2971def : Pat<(sra R16C:$rA, (i32 imm:$val)),
2972 (ROTMAHIr16 R16C:$rA, uimm7:$val)>;
2973
Scott Michel438be252007-12-17 22:32:34 +00002974def : Pat<(sra R16C:$rA, (i8 imm:$val)),
2975 (ROTMAHIr16 R16C:$rA, uimm7:$val)>;
2976
Scott Michel8b6b4202007-12-04 22:35:58 +00002977def ROTMAv4i32:
2978 RRForm<0b01011010000, (outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB),
2979 "rotma\t$rT, $rA, $rB", RotateShift,
2980 [/* see patterns below - $rB must be negated */]>;
2981
Scott Michel97872d32008-02-23 18:41:37 +00002982def : Pat<(SPUvec_sra VECREG:$rA, R32C:$rB),
Scott Michel8b6b4202007-12-04 22:35:58 +00002983 (ROTMAv4i32 (v4i32 VECREG:$rA), (SFIr32 R32C:$rB, 0))>;
2984
Scott Michel97872d32008-02-23 18:41:37 +00002985def : Pat<(SPUvec_sra VECREG:$rA, R16C:$rB),
Scott Michel8b6b4202007-12-04 22:35:58 +00002986 (ROTMAv4i32 (v4i32 VECREG:$rA),
2987 (SFIr32 (XSHWr16 R16C:$rB), 0))>;
2988
Scott Michel97872d32008-02-23 18:41:37 +00002989def : Pat<(SPUvec_sra VECREG:$rA, R8C:$rB),
Scott Michel438be252007-12-17 22:32:34 +00002990 (ROTMAv4i32 (v4i32 VECREG:$rA),
2991 (SFIr32 (XSHWr16 (XSBHr8 R8C:$rB)), 0))>;
2992
Scott Michel8b6b4202007-12-04 22:35:58 +00002993def ROTMAr32:
2994 RRForm<0b01011010000, (outs R32C:$rT), (ins R32C:$rA, R32C:$rB),
2995 "rotma\t$rT, $rA, $rB", RotateShift,
2996 [/* see patterns below - $rB must be negated */]>;
2997
2998def : Pat<(sra R32C:$rA, R32C:$rB),
2999 (ROTMAr32 R32C:$rA, (SFIr32 R32C:$rB, 0))>;
3000
3001def : Pat<(sra R32C:$rA, R16C:$rB),
3002 (ROTMAr32 R32C:$rA,
3003 (SFIr32 (XSHWr16 R16C:$rB), 0))>;
3004
Scott Michel438be252007-12-17 22:32:34 +00003005def : Pat<(sra R32C:$rA, R8C:$rB),
3006 (ROTMAr32 R32C:$rA,
3007 (SFIr32 (XSHWr16 (XSBHr8 R8C:$rB)), 0))>;
3008
Scott Michel67224b22008-06-02 22:18:03 +00003009class ROTMAIInst<dag OOL, dag IOL, list<dag> pattern>:
3010 RRForm<0b01011110000, OOL, IOL,
3011 "rotmai\t$rT, $rA, $val",
3012 RotateShift, pattern>;
Scott Michel8b6b4202007-12-04 22:35:58 +00003013
Scott Michel67224b22008-06-02 22:18:03 +00003014class ROTMAIVecInst<ValueType vectype, Operand intop, ValueType inttype>:
3015 ROTMAIInst<(outs VECREG:$rT), (ins VECREG:$rA, intop:$val),
3016 [(set (vectype VECREG:$rT),
3017 (SPUvec_sra VECREG:$rA, (inttype uimm7:$val)))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00003018
Scott Michel67224b22008-06-02 22:18:03 +00003019class ROTMAIRegInst<RegisterClass rclass, Operand intop, ValueType inttype>:
3020 ROTMAIInst<(outs rclass:$rT), (ins rclass:$rA, intop:$val),
3021 [(set rclass:$rT, (sra rclass:$rA, (inttype uimm7:$val)))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00003022
Scott Michel67224b22008-06-02 22:18:03 +00003023multiclass RotateMaskAlgebraicImm {
3024 def v2i64_i32 : ROTMAIVecInst<v2i64, rotNeg7imm, i32>;
3025 def v4i32_i32 : ROTMAIVecInst<v4i32, rotNeg7imm, i32>;
3026 def r64_i32 : ROTMAIRegInst<R64C, rotNeg7imm, i32>;
3027 def r32_i32 : ROTMAIRegInst<R32C, rotNeg7imm, i32>;
3028}
Scott Michel8b6b4202007-12-04 22:35:58 +00003029
Scott Michel67224b22008-06-02 22:18:03 +00003030defm ROTMAI : RotateMaskAlgebraicImm;
Scott Michel438be252007-12-17 22:32:34 +00003031
Scott Michel8b6b4202007-12-04 22:35:58 +00003032//===----------------------------------------------------------------------===//
3033// Branch and conditionals:
3034//===----------------------------------------------------------------------===//
3035
3036let isTerminator = 1, isBarrier = 1 in {
3037 // Halt If Equal (r32 preferred slot only, no vector form)
3038 def HEQr32:
3039 RRForm_3<0b00011011110, (outs), (ins R32C:$rA, R32C:$rB),
3040 "heq\t$rA, $rB", BranchResolv,
3041 [/* no pattern to match */]>;
3042
3043 def HEQIr32 :
3044 RI10Form_2<0b11111110, (outs), (ins R32C:$rA, s10imm:$val),
3045 "heqi\t$rA, $val", BranchResolv,
3046 [/* no pattern to match */]>;
3047
3048 // HGT/HGTI: These instructions use signed arithmetic for the comparison,
3049 // contrasting with HLGT/HLGTI, which use unsigned comparison:
3050 def HGTr32:
3051 RRForm_3<0b00011010010, (outs), (ins R32C:$rA, R32C:$rB),
3052 "hgt\t$rA, $rB", BranchResolv,
3053 [/* no pattern to match */]>;
3054
Scott Michel06eabde2008-12-27 04:51:36 +00003055 def HGTIr32:
Scott Michel8b6b4202007-12-04 22:35:58 +00003056 RI10Form_2<0b11110010, (outs), (ins R32C:$rA, s10imm:$val),
3057 "hgti\t$rA, $val", BranchResolv,
3058 [/* no pattern to match */]>;
3059
3060 def HLGTr32:
3061 RRForm_3<0b00011011010, (outs), (ins R32C:$rA, R32C:$rB),
3062 "hlgt\t$rA, $rB", BranchResolv,
3063 [/* no pattern to match */]>;
3064
3065 def HLGTIr32:
3066 RI10Form_2<0b11111010, (outs), (ins R32C:$rA, s10imm:$val),
3067 "hlgti\t$rA, $val", BranchResolv,
3068 [/* no pattern to match */]>;
3069}
3070
Scott Michel06eabde2008-12-27 04:51:36 +00003071//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
3072// Comparison operators for i8, i16 and i32:
3073//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
Scott Michel8b6b4202007-12-04 22:35:58 +00003074
Scott Michel97872d32008-02-23 18:41:37 +00003075class CEQBInst<dag OOL, dag IOL, list<dag> pattern> :
3076 RRForm<0b00001011110, OOL, IOL, "ceqb\t$rT, $rA, $rB",
3077 ByteOp, pattern>;
Scott Michel8b6b4202007-12-04 22:35:58 +00003078
Scott Michel97872d32008-02-23 18:41:37 +00003079multiclass CmpEqualByte
3080{
3081 def v16i8 :
3082 CEQBInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
3083 [(set (v16i8 VECREG:$rT), (seteq (v8i16 VECREG:$rA),
3084 (v8i16 VECREG:$rB)))]>;
Scott Michel438be252007-12-17 22:32:34 +00003085
Scott Michel97872d32008-02-23 18:41:37 +00003086 def r8 :
3087 CEQBInst<(outs R8C:$rT), (ins R8C:$rA, R8C:$rB),
3088 [(set R8C:$rT, (seteq R8C:$rA, R8C:$rB))]>;
3089}
Scott Michel8b6b4202007-12-04 22:35:58 +00003090
Scott Michel97872d32008-02-23 18:41:37 +00003091class CEQBIInst<dag OOL, dag IOL, list<dag> pattern> :
3092 RI10Form<0b01111110, OOL, IOL, "ceqbi\t$rT, $rA, $val",
3093 ByteOp, pattern>;
Scott Michel8b6b4202007-12-04 22:35:58 +00003094
Scott Michel97872d32008-02-23 18:41:37 +00003095multiclass CmpEqualByteImm
3096{
3097 def v16i8 :
3098 CEQBIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm_i8:$val),
3099 [(set (v16i8 VECREG:$rT), (seteq (v16i8 VECREG:$rA),
3100 v16i8SExt8Imm:$val))]>;
3101 def r8:
3102 CEQBIInst<(outs R8C:$rT), (ins R8C:$rA, s10imm_i8:$val),
3103 [(set R8C:$rT, (seteq R8C:$rA, immSExt8:$val))]>;
3104}
Scott Michel8b6b4202007-12-04 22:35:58 +00003105
Scott Michel97872d32008-02-23 18:41:37 +00003106class CEQHInst<dag OOL, dag IOL, list<dag> pattern> :
3107 RRForm<0b00010011110, OOL, IOL, "ceqh\t$rT, $rA, $rB",
3108 ByteOp, pattern>;
Scott Michel8b6b4202007-12-04 22:35:58 +00003109
Scott Michel97872d32008-02-23 18:41:37 +00003110multiclass CmpEqualHalfword
3111{
3112 def v8i16 : CEQHInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
3113 [(set (v8i16 VECREG:$rT), (seteq (v8i16 VECREG:$rA),
3114 (v8i16 VECREG:$rB)))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00003115
Scott Michel97872d32008-02-23 18:41:37 +00003116 def r16 : CEQHInst<(outs R16C:$rT), (ins R16C:$rA, R16C:$rB),
3117 [(set R16C:$rT, (seteq R16C:$rA, R16C:$rB))]>;
3118}
Scott Michel8b6b4202007-12-04 22:35:58 +00003119
Scott Michel97872d32008-02-23 18:41:37 +00003120class CEQHIInst<dag OOL, dag IOL, list<dag> pattern> :
3121 RI10Form<0b10111110, OOL, IOL, "ceqhi\t$rT, $rA, $val",
3122 ByteOp, pattern>;
Scott Michel8b6b4202007-12-04 22:35:58 +00003123
Scott Michel97872d32008-02-23 18:41:37 +00003124multiclass CmpEqualHalfwordImm
3125{
3126 def v8i16 : CEQHIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
3127 [(set (v8i16 VECREG:$rT),
3128 (seteq (v8i16 VECREG:$rA),
3129 (v8i16 v8i16SExt10Imm:$val)))]>;
3130 def r16 : CEQHIInst<(outs R16C:$rT), (ins R16C:$rA, s10imm:$val),
3131 [(set R16C:$rT, (seteq R16C:$rA, i16ImmSExt10:$val))]>;
3132}
Scott Michel8b6b4202007-12-04 22:35:58 +00003133
Scott Michel97872d32008-02-23 18:41:37 +00003134class CEQInst<dag OOL, dag IOL, list<dag> pattern> :
3135 RRForm<0b00000011110, OOL, IOL, "ceq\t$rT, $rA, $rB",
3136 ByteOp, pattern>;
3137
3138multiclass CmpEqualWord
3139{
3140 def v4i32 : CEQInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
3141 [(set (v4i32 VECREG:$rT),
3142 (seteq (v4i32 VECREG:$rA), (v4i32 VECREG:$rB)))]>;
3143
3144 def r32 : CEQInst<(outs R32C:$rT), (ins R32C:$rA, R32C:$rB),
3145 [(set R32C:$rT, (seteq R32C:$rA, R32C:$rB))]>;
3146}
3147
3148class CEQIInst<dag OOL, dag IOL, list<dag> pattern> :
3149 RI10Form<0b00111110, OOL, IOL, "ceqi\t$rT, $rA, $val",
3150 ByteOp, pattern>;
3151
3152multiclass CmpEqualWordImm
3153{
3154 def v4i32 : CEQIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
3155 [(set (v4i32 VECREG:$rT),
3156 (seteq (v4i32 VECREG:$rA),
3157 (v4i32 v4i32SExt16Imm:$val)))]>;
3158
3159 def r32: CEQIInst<(outs R32C:$rT), (ins R32C:$rA, s10imm_i32:$val),
3160 [(set R32C:$rT, (seteq R32C:$rA, i32ImmSExt10:$val))]>;
3161}
3162
3163class CGTBInst<dag OOL, dag IOL, list<dag> pattern> :
3164 RRForm<0b00001010010, OOL, IOL, "cgtb\t$rT, $rA, $rB",
3165 ByteOp, pattern>;
3166
3167multiclass CmpGtrByte
3168{
3169 def v16i8 :
3170 CGTBInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
3171 [(set (v16i8 VECREG:$rT), (setgt (v8i16 VECREG:$rA),
3172 (v8i16 VECREG:$rB)))]>;
3173
3174 def r8 :
3175 CGTBInst<(outs R8C:$rT), (ins R8C:$rA, R8C:$rB),
3176 [(set R8C:$rT, (setgt R8C:$rA, R8C:$rB))]>;
3177}
3178
3179class CGTBIInst<dag OOL, dag IOL, list<dag> pattern> :
3180 RI10Form<0b01110010, OOL, IOL, "cgtbi\t$rT, $rA, $val",
3181 ByteOp, pattern>;
3182
3183multiclass CmpGtrByteImm
3184{
3185 def v16i8 :
3186 CGTBIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm_i8:$val),
3187 [(set (v16i8 VECREG:$rT), (setgt (v16i8 VECREG:$rA),
3188 v16i8SExt8Imm:$val))]>;
3189 def r8:
3190 CGTBIInst<(outs R8C:$rT), (ins R8C:$rA, s10imm_i8:$val),
Scott Michel7833d472008-03-20 00:51:36 +00003191 [(set R8C:$rT, (setgt R8C:$rA, immSExt8:$val))]>;
Scott Michel97872d32008-02-23 18:41:37 +00003192}
3193
3194class CGTHInst<dag OOL, dag IOL, list<dag> pattern> :
3195 RRForm<0b00010010010, OOL, IOL, "cgth\t$rT, $rA, $rB",
3196 ByteOp, pattern>;
3197
3198multiclass CmpGtrHalfword
3199{
3200 def v8i16 : CGTHInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
3201 [(set (v8i16 VECREG:$rT), (setgt (v8i16 VECREG:$rA),
3202 (v8i16 VECREG:$rB)))]>;
3203
3204 def r16 : CGTHInst<(outs R16C:$rT), (ins R16C:$rA, R16C:$rB),
3205 [(set R16C:$rT, (setgt R16C:$rA, R16C:$rB))]>;
3206}
3207
3208class CGTHIInst<dag OOL, dag IOL, list<dag> pattern> :
3209 RI10Form<0b10110010, OOL, IOL, "cgthi\t$rT, $rA, $val",
3210 ByteOp, pattern>;
3211
3212multiclass CmpGtrHalfwordImm
3213{
3214 def v8i16 : CGTHIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
3215 [(set (v8i16 VECREG:$rT),
3216 (setgt (v8i16 VECREG:$rA),
3217 (v8i16 v8i16SExt10Imm:$val)))]>;
3218 def r16 : CGTHIInst<(outs R16C:$rT), (ins R16C:$rA, s10imm:$val),
3219 [(set R16C:$rT, (setgt R16C:$rA, i16ImmSExt10:$val))]>;
3220}
3221
3222class CGTInst<dag OOL, dag IOL, list<dag> pattern> :
3223 RRForm<0b00000010010, OOL, IOL, "cgt\t$rT, $rA, $rB",
3224 ByteOp, pattern>;
3225
3226multiclass CmpGtrWord
3227{
3228 def v4i32 : CGTInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
3229 [(set (v4i32 VECREG:$rT),
3230 (setgt (v4i32 VECREG:$rA), (v4i32 VECREG:$rB)))]>;
3231
3232 def r32 : CGTInst<(outs R32C:$rT), (ins R32C:$rA, R32C:$rB),
3233 [(set R32C:$rT, (setgt R32C:$rA, R32C:$rB))]>;
3234}
3235
3236class CGTIInst<dag OOL, dag IOL, list<dag> pattern> :
3237 RI10Form<0b00110010, OOL, IOL, "cgti\t$rT, $rA, $val",
3238 ByteOp, pattern>;
3239
3240multiclass CmpGtrWordImm
3241{
3242 def v4i32 : CGTIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
3243 [(set (v4i32 VECREG:$rT),
3244 (setgt (v4i32 VECREG:$rA),
3245 (v4i32 v4i32SExt16Imm:$val)))]>;
3246
3247 def r32: CGTIInst<(outs R32C:$rT), (ins R32C:$rA, s10imm_i32:$val),
3248 [(set R32C:$rT, (setgt R32C:$rA, i32ImmSExt10:$val))]>;
Scott Michel4d07fb72008-12-30 23:28:25 +00003249
3250 // CGTIv4f32, CGTIf32: These are used in the f32 fdiv instruction sequence:
3251 def v4f32: CGTIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
3252 [(set (v4i32 VECREG:$rT),
3253 (setgt (v4i32 (bitconvert (v4f32 VECREG:$rA))),
3254 (v4i32 v4i32SExt16Imm:$val)))]>;
3255
3256 def f32: CGTIInst<(outs R32C:$rT), (ins R32FP:$rA, s10imm_i32:$val),
pingbakb8913342009-01-26 03:37:41 +00003257 [/* no pattern */]>;
Scott Michel97872d32008-02-23 18:41:37 +00003258}
3259
3260class CLGTBInst<dag OOL, dag IOL, list<dag> pattern> :
Scott Michel6baba072008-03-05 23:02:02 +00003261 RRForm<0b00001011010, OOL, IOL, "clgtb\t$rT, $rA, $rB",
Scott Michel97872d32008-02-23 18:41:37 +00003262 ByteOp, pattern>;
3263
3264multiclass CmpLGtrByte
3265{
3266 def v16i8 :
3267 CLGTBInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
3268 [(set (v16i8 VECREG:$rT), (setugt (v8i16 VECREG:$rA),
3269 (v8i16 VECREG:$rB)))]>;
3270
3271 def r8 :
3272 CLGTBInst<(outs R8C:$rT), (ins R8C:$rA, R8C:$rB),
3273 [(set R8C:$rT, (setugt R8C:$rA, R8C:$rB))]>;
3274}
3275
3276class CLGTBIInst<dag OOL, dag IOL, list<dag> pattern> :
Scott Michel6baba072008-03-05 23:02:02 +00003277 RI10Form<0b01111010, OOL, IOL, "clgtbi\t$rT, $rA, $val",
Scott Michel97872d32008-02-23 18:41:37 +00003278 ByteOp, pattern>;
3279
3280multiclass CmpLGtrByteImm
3281{
3282 def v16i8 :
3283 CLGTBIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm_i8:$val),
3284 [(set (v16i8 VECREG:$rT), (setugt (v16i8 VECREG:$rA),
3285 v16i8SExt8Imm:$val))]>;
3286 def r8:
3287 CLGTBIInst<(outs R8C:$rT), (ins R8C:$rA, s10imm_i8:$val),
3288 [(set R8C:$rT, (setugt R8C:$rA, immSExt8:$val))]>;
3289}
3290
3291class CLGTHInst<dag OOL, dag IOL, list<dag> pattern> :
Scott Michel6baba072008-03-05 23:02:02 +00003292 RRForm<0b00010011010, OOL, IOL, "clgth\t$rT, $rA, $rB",
Scott Michel97872d32008-02-23 18:41:37 +00003293 ByteOp, pattern>;
3294
3295multiclass CmpLGtrHalfword
3296{
3297 def v8i16 : CLGTHInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
3298 [(set (v8i16 VECREG:$rT), (setugt (v8i16 VECREG:$rA),
3299 (v8i16 VECREG:$rB)))]>;
3300
3301 def r16 : CLGTHInst<(outs R16C:$rT), (ins R16C:$rA, R16C:$rB),
3302 [(set R16C:$rT, (setugt R16C:$rA, R16C:$rB))]>;
3303}
3304
3305class CLGTHIInst<dag OOL, dag IOL, list<dag> pattern> :
Scott Michel6baba072008-03-05 23:02:02 +00003306 RI10Form<0b10111010, OOL, IOL, "clgthi\t$rT, $rA, $val",
Scott Michel97872d32008-02-23 18:41:37 +00003307 ByteOp, pattern>;
3308
3309multiclass CmpLGtrHalfwordImm
3310{
3311 def v8i16 : CLGTHIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
3312 [(set (v8i16 VECREG:$rT),
3313 (setugt (v8i16 VECREG:$rA),
3314 (v8i16 v8i16SExt10Imm:$val)))]>;
3315 def r16 : CLGTHIInst<(outs R16C:$rT), (ins R16C:$rA, s10imm:$val),
3316 [(set R16C:$rT, (setugt R16C:$rA, i16ImmSExt10:$val))]>;
3317}
3318
3319class CLGTInst<dag OOL, dag IOL, list<dag> pattern> :
Scott Michel6baba072008-03-05 23:02:02 +00003320 RRForm<0b00000011010, OOL, IOL, "clgt\t$rT, $rA, $rB",
Scott Michel97872d32008-02-23 18:41:37 +00003321 ByteOp, pattern>;
3322
3323multiclass CmpLGtrWord
3324{
3325 def v4i32 : CLGTInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
3326 [(set (v4i32 VECREG:$rT),
3327 (setugt (v4i32 VECREG:$rA), (v4i32 VECREG:$rB)))]>;
3328
3329 def r32 : CLGTInst<(outs R32C:$rT), (ins R32C:$rA, R32C:$rB),
3330 [(set R32C:$rT, (setugt R32C:$rA, R32C:$rB))]>;
3331}
3332
3333class CLGTIInst<dag OOL, dag IOL, list<dag> pattern> :
Scott Michel6baba072008-03-05 23:02:02 +00003334 RI10Form<0b00111010, OOL, IOL, "clgti\t$rT, $rA, $val",
Scott Michel97872d32008-02-23 18:41:37 +00003335 ByteOp, pattern>;
3336
3337multiclass CmpLGtrWordImm
3338{
3339 def v4i32 : CLGTIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
3340 [(set (v4i32 VECREG:$rT),
3341 (setugt (v4i32 VECREG:$rA),
3342 (v4i32 v4i32SExt16Imm:$val)))]>;
3343
3344 def r32: CLGTIInst<(outs R32C:$rT), (ins R32C:$rA, s10imm_i32:$val),
Scott Michel6baba072008-03-05 23:02:02 +00003345 [(set R32C:$rT, (setugt R32C:$rA, i32ImmSExt10:$val))]>;
Scott Michel97872d32008-02-23 18:41:37 +00003346}
3347
3348defm CEQB : CmpEqualByte;
3349defm CEQBI : CmpEqualByteImm;
3350defm CEQH : CmpEqualHalfword;
3351defm CEQHI : CmpEqualHalfwordImm;
3352defm CEQ : CmpEqualWord;
3353defm CEQI : CmpEqualWordImm;
3354defm CGTB : CmpGtrByte;
3355defm CGTBI : CmpGtrByteImm;
3356defm CGTH : CmpGtrHalfword;
3357defm CGTHI : CmpGtrHalfwordImm;
3358defm CGT : CmpGtrWord;
3359defm CGTI : CmpGtrWordImm;
3360defm CLGTB : CmpLGtrByte;
3361defm CLGTBI : CmpLGtrByteImm;
3362defm CLGTH : CmpLGtrHalfword;
3363defm CLGTHI : CmpLGtrHalfwordImm;
3364defm CLGT : CmpLGtrWord;
3365defm CLGTI : CmpLGtrWordImm;
3366
Scott Michel53ab7792008-03-10 16:58:52 +00003367//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
Scott Michel97872d32008-02-23 18:41:37 +00003368// For SETCC primitives not supported above (setlt, setle, setge, etc.)
3369// define a pattern to generate the right code, as a binary operator
3370// (in a manner of speaking.)
Scott Michel53ab7792008-03-10 16:58:52 +00003371//
Scott Michel06eabde2008-12-27 04:51:36 +00003372// Notes:
3373// 1. This only matches the setcc set of conditionals. Special pattern
3374// matching is used for select conditionals.
3375//
3376// 2. The "DAG" versions of these classes is almost exclusively used for
3377// i64 comparisons. See the tblgen fundamentals documentation for what
3378// ".ResultInstrs[0]" means; see TargetSelectionDAG.td and the Pattern
3379// class for where ResultInstrs originates.
Scott Michel53ab7792008-03-10 16:58:52 +00003380//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
Scott Michel97872d32008-02-23 18:41:37 +00003381
Scott Michel53ab7792008-03-10 16:58:52 +00003382class SETCCNegCondReg<PatFrag cond, RegisterClass rclass, ValueType inttype,
3383 SPUInstr xorinst, SPUInstr cmpare>:
3384 Pat<(cond rclass:$rA, rclass:$rB),
3385 (xorinst (cmpare rclass:$rA, rclass:$rB), (inttype -1))>;
3386
3387class SETCCNegCondImm<PatFrag cond, RegisterClass rclass, ValueType inttype,
3388 PatLeaf immpred, SPUInstr xorinst, SPUInstr cmpare>:
3389 Pat<(cond rclass:$rA, (inttype immpred:$imm)),
3390 (xorinst (cmpare rclass:$rA, (inttype immpred:$imm)), (inttype -1))>;
3391
Scott Michel06eabde2008-12-27 04:51:36 +00003392def : SETCCNegCondReg<setne, R8C, i8, XORBIr8, CEQBr8>;
Scott Michel53ab7792008-03-10 16:58:52 +00003393def : SETCCNegCondImm<setne, R8C, i8, immSExt8, XORBIr8, CEQBIr8>;
3394
Scott Michel06eabde2008-12-27 04:51:36 +00003395def : SETCCNegCondReg<setne, R16C, i16, XORHIr16, CEQHr16>;
Scott Michel53ab7792008-03-10 16:58:52 +00003396def : SETCCNegCondImm<setne, R16C, i16, i16ImmSExt10, XORHIr16, CEQHIr16>;
3397
3398def : SETCCNegCondReg<setne, R32C, i32, XORIr32, CEQr32>;
3399def : SETCCNegCondImm<setne, R32C, i32, i32ImmSExt10, XORIr32, CEQIr32>;
Scott Michel97872d32008-02-23 18:41:37 +00003400
3401class SETCCBinOpReg<PatFrag cond, RegisterClass rclass,
3402 SPUInstr binop, SPUInstr cmpOp1, SPUInstr cmpOp2>:
3403 Pat<(cond rclass:$rA, rclass:$rB),
3404 (binop (cmpOp1 rclass:$rA, rclass:$rB),
3405 (cmpOp2 rclass:$rA, rclass:$rB))>;
3406
3407class SETCCBinOpImm<PatFrag cond, RegisterClass rclass, PatLeaf immpred,
3408 ValueType immtype,
3409 SPUInstr binop, SPUInstr cmpOp1, SPUInstr cmpOp2>:
3410 Pat<(cond rclass:$rA, (immtype immpred:$imm)),
3411 (binop (cmpOp1 rclass:$rA, (immtype immpred:$imm)),
3412 (cmpOp2 rclass:$rA, (immtype immpred:$imm)))>;
3413
Scott Michel53ab7792008-03-10 16:58:52 +00003414def : SETCCBinOpReg<setge, R8C, ORr8, CGTBr8, CEQBr8>;
3415def : SETCCBinOpImm<setge, R8C, immSExt8, i8, ORr8, CGTBIr8, CEQBIr8>;
3416def : SETCCBinOpReg<setlt, R8C, NORr8, CGTBr8, CEQBr8>;
3417def : SETCCBinOpImm<setlt, R8C, immSExt8, i8, NORr8, CGTBIr8, CEQBIr8>;
3418def : Pat<(setle R8C:$rA, R8C:$rB),
3419 (XORBIr8 (CGTBr8 R8C:$rA, R8C:$rB), 0xff)>;
3420def : Pat<(setle R8C:$rA, immU8:$imm),
3421 (XORBIr8 (CGTBIr8 R8C:$rA, immU8:$imm), 0xff)>;
Scott Michel97872d32008-02-23 18:41:37 +00003422
Scott Michel53ab7792008-03-10 16:58:52 +00003423def : SETCCBinOpReg<setge, R16C, ORr16, CGTHr16, CEQHr16>;
3424def : SETCCBinOpImm<setge, R16C, i16ImmSExt10, i16,
3425 ORr16, CGTHIr16, CEQHIr16>;
3426def : SETCCBinOpReg<setlt, R16C, NORr16, CGTHr16, CEQHr16>;
3427def : SETCCBinOpImm<setlt, R16C, i16ImmSExt10, i16, NORr16, CGTHIr16, CEQHIr16>;
3428def : Pat<(setle R16C:$rA, R16C:$rB),
3429 (XORHIr16 (CGTHr16 R16C:$rA, R16C:$rB), 0xffff)>;
3430def : Pat<(setle R16C:$rA, i16ImmSExt10:$imm),
3431 (XORHIr16 (CGTHIr16 R16C:$rA, i16ImmSExt10:$imm), 0xffff)>;
Scott Michel97872d32008-02-23 18:41:37 +00003432
Scott Michel53ab7792008-03-10 16:58:52 +00003433def : SETCCBinOpReg<setge, R32C, ORr32, CGTr32, CEQr32>;
3434def : SETCCBinOpImm<setge, R32C, i32ImmSExt10, i32,
3435 ORr32, CGTIr32, CEQIr32>;
3436def : SETCCBinOpReg<setlt, R32C, NORr32, CGTr32, CEQr32>;
3437def : SETCCBinOpImm<setlt, R32C, i32ImmSExt10, i32, NORr32, CGTIr32, CEQIr32>;
3438def : Pat<(setle R32C:$rA, R32C:$rB),
3439 (XORIr32 (CGTr32 R32C:$rA, R32C:$rB), 0xffffffff)>;
3440def : Pat<(setle R32C:$rA, i32ImmSExt10:$imm),
3441 (XORIr32 (CGTIr32 R32C:$rA, i32ImmSExt10:$imm), 0xffffffff)>;
Scott Michel97872d32008-02-23 18:41:37 +00003442
Scott Michel53ab7792008-03-10 16:58:52 +00003443def : SETCCBinOpReg<setuge, R8C, ORr8, CLGTBr8, CEQBr8>;
3444def : SETCCBinOpImm<setuge, R8C, immSExt8, i8, ORr8, CLGTBIr8, CEQBIr8>;
3445def : SETCCBinOpReg<setult, R8C, NORr8, CLGTBr8, CEQBr8>;
3446def : SETCCBinOpImm<setult, R8C, immSExt8, i8, NORr8, CLGTBIr8, CEQBIr8>;
3447def : Pat<(setule R8C:$rA, R8C:$rB),
3448 (XORBIr8 (CLGTBr8 R8C:$rA, R8C:$rB), 0xff)>;
3449def : Pat<(setule R8C:$rA, immU8:$imm),
3450 (XORBIr8 (CLGTBIr8 R8C:$rA, immU8:$imm), 0xff)>;
Scott Michel97872d32008-02-23 18:41:37 +00003451
Scott Michel53ab7792008-03-10 16:58:52 +00003452def : SETCCBinOpReg<setuge, R16C, ORr16, CLGTHr16, CEQHr16>;
3453def : SETCCBinOpImm<setuge, R16C, i16ImmSExt10, i16,
3454 ORr16, CLGTHIr16, CEQHIr16>;
3455def : SETCCBinOpReg<setult, R16C, NORr16, CLGTHr16, CEQHr16>;
3456def : SETCCBinOpImm<setult, R16C, i16ImmSExt10, i16, NORr16,
3457 CLGTHIr16, CEQHIr16>;
3458def : Pat<(setule R16C:$rA, R16C:$rB),
3459 (XORHIr16 (CLGTHr16 R16C:$rA, R16C:$rB), 0xffff)>;
Scott Michel7833d472008-03-20 00:51:36 +00003460def : Pat<(setule R16C:$rA, i16ImmSExt10:$imm),
Scott Michel53ab7792008-03-10 16:58:52 +00003461 (XORHIr16 (CLGTHIr16 R16C:$rA, i16ImmSExt10:$imm), 0xffff)>;
Scott Michel97872d32008-02-23 18:41:37 +00003462
Scott Michel53ab7792008-03-10 16:58:52 +00003463def : SETCCBinOpReg<setuge, R32C, ORr32, CLGTr32, CEQr32>;
Scott Michel7833d472008-03-20 00:51:36 +00003464def : SETCCBinOpImm<setuge, R32C, i32ImmSExt10, i32,
Scott Michel53ab7792008-03-10 16:58:52 +00003465 ORr32, CLGTIr32, CEQIr32>;
3466def : SETCCBinOpReg<setult, R32C, NORr32, CLGTr32, CEQr32>;
Scott Michel7833d472008-03-20 00:51:36 +00003467def : SETCCBinOpImm<setult, R32C, i32ImmSExt10, i32, NORr32, CLGTIr32, CEQIr32>;
Scott Michel53ab7792008-03-10 16:58:52 +00003468def : Pat<(setule R32C:$rA, R32C:$rB),
3469 (XORIr32 (CLGTr32 R32C:$rA, R32C:$rB), 0xffffffff)>;
3470def : Pat<(setule R32C:$rA, i32ImmSExt10:$imm),
3471 (XORIr32 (CLGTIr32 R32C:$rA, i32ImmSExt10:$imm), 0xffffffff)>;
Scott Michel97872d32008-02-23 18:41:37 +00003472
Scott Michel53ab7792008-03-10 16:58:52 +00003473//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
3474// select conditional patterns:
3475//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
3476
3477class SELECTNegCondReg<PatFrag cond, RegisterClass rclass, ValueType inttype,
3478 SPUInstr selinstr, SPUInstr cmpare>:
3479 Pat<(select (inttype (cond rclass:$rA, rclass:$rB)),
3480 rclass:$rTrue, rclass:$rFalse),
3481 (selinstr rclass:$rTrue, rclass:$rFalse,
Bill Wendling8f6608b2008-07-22 08:50:44 +00003482 (cmpare rclass:$rA, rclass:$rB))>;
Scott Michel53ab7792008-03-10 16:58:52 +00003483
3484class SELECTNegCondImm<PatFrag cond, RegisterClass rclass, ValueType inttype,
3485 PatLeaf immpred, SPUInstr selinstr, SPUInstr cmpare>:
3486 Pat<(select (inttype (cond rclass:$rA, immpred:$imm)),
Bill Wendling8f6608b2008-07-22 08:50:44 +00003487 rclass:$rTrue, rclass:$rFalse),
Scott Michel53ab7792008-03-10 16:58:52 +00003488 (selinstr rclass:$rTrue, rclass:$rFalse,
3489 (cmpare rclass:$rA, immpred:$imm))>;
3490
3491def : SELECTNegCondReg<setne, R8C, i8, SELBr8, CEQBr8>;
3492def : SELECTNegCondImm<setne, R8C, i8, immSExt8, SELBr8, CEQBIr8>;
3493def : SELECTNegCondReg<setle, R8C, i8, SELBr8, CGTBr8>;
3494def : SELECTNegCondImm<setle, R8C, i8, immSExt8, SELBr8, CGTBr8>;
3495def : SELECTNegCondReg<setule, R8C, i8, SELBr8, CLGTBr8>;
3496def : SELECTNegCondImm<setule, R8C, i8, immU8, SELBr8, CLGTBIr8>;
3497
3498def : SELECTNegCondReg<setne, R16C, i16, SELBr16, CEQHr16>;
3499def : SELECTNegCondImm<setne, R16C, i16, i16ImmSExt10, SELBr16, CEQHIr16>;
3500def : SELECTNegCondReg<setle, R16C, i16, SELBr16, CGTHr16>;
3501def : SELECTNegCondImm<setle, R16C, i16, i16ImmSExt10, SELBr16, CGTHIr16>;
3502def : SELECTNegCondReg<setule, R16C, i16, SELBr16, CLGTHr16>;
3503def : SELECTNegCondImm<setule, R16C, i16, i16ImmSExt10, SELBr16, CLGTHIr16>;
3504
3505def : SELECTNegCondReg<setne, R32C, i32, SELBr32, CEQr32>;
3506def : SELECTNegCondImm<setne, R32C, i32, i32ImmSExt10, SELBr32, CEQIr32>;
3507def : SELECTNegCondReg<setle, R32C, i32, SELBr32, CGTr32>;
3508def : SELECTNegCondImm<setle, R32C, i32, i32ImmSExt10, SELBr32, CGTIr32>;
3509def : SELECTNegCondReg<setule, R32C, i32, SELBr32, CLGTr32>;
3510def : SELECTNegCondImm<setule, R32C, i32, i32ImmSExt10, SELBr32, CLGTIr32>;
3511
3512class SELECTBinOpReg<PatFrag cond, RegisterClass rclass, ValueType inttype,
3513 SPUInstr selinstr, SPUInstr binop, SPUInstr cmpOp1,
3514 SPUInstr cmpOp2>:
3515 Pat<(select (inttype (cond rclass:$rA, rclass:$rB)),
Scott Michel06eabde2008-12-27 04:51:36 +00003516 rclass:$rTrue, rclass:$rFalse),
3517 (selinstr rclass:$rFalse, rclass:$rTrue,
Scott Michel53ab7792008-03-10 16:58:52 +00003518 (binop (cmpOp1 rclass:$rA, rclass:$rB),
3519 (cmpOp2 rclass:$rA, rclass:$rB)))>;
3520
3521class SELECTBinOpImm<PatFrag cond, RegisterClass rclass, PatLeaf immpred,
3522 ValueType inttype,
3523 SPUInstr selinstr, SPUInstr binop, SPUInstr cmpOp1,
3524 SPUInstr cmpOp2>:
3525 Pat<(select (inttype (cond rclass:$rA, (inttype immpred:$imm))),
Bill Wendling8f6608b2008-07-22 08:50:44 +00003526 rclass:$rTrue, rclass:$rFalse),
Scott Michel53ab7792008-03-10 16:58:52 +00003527 (selinstr rclass:$rFalse, rclass:$rTrue,
3528 (binop (cmpOp1 rclass:$rA, (inttype immpred:$imm)),
3529 (cmpOp2 rclass:$rA, (inttype immpred:$imm))))>;
3530
3531def : SELECTBinOpReg<setge, R8C, i8, SELBr8, ORr8, CGTBr8, CEQBr8>;
3532def : SELECTBinOpImm<setge, R8C, immSExt8, i8,
3533 SELBr8, ORr8, CGTBIr8, CEQBIr8>;
3534
3535def : SELECTBinOpReg<setge, R16C, i16, SELBr16, ORr16, CGTHr16, CEQHr16>;
3536def : SELECTBinOpImm<setge, R16C, i16ImmSExt10, i16,
3537 SELBr16, ORr16, CGTHIr16, CEQHIr16>;
3538
3539def : SELECTBinOpReg<setge, R32C, i32, SELBr32, ORr32, CGTr32, CEQr32>;
3540def : SELECTBinOpImm<setge, R32C, i32ImmSExt10, i32,
3541 SELBr32, ORr32, CGTIr32, CEQIr32>;
3542
3543def : SELECTBinOpReg<setuge, R8C, i8, SELBr8, ORr8, CLGTBr8, CEQBr8>;
3544def : SELECTBinOpImm<setuge, R8C, immSExt8, i8,
3545 SELBr8, ORr8, CLGTBIr8, CEQBIr8>;
3546
3547def : SELECTBinOpReg<setuge, R16C, i16, SELBr16, ORr16, CLGTHr16, CEQHr16>;
3548def : SELECTBinOpImm<setuge, R16C, i16ImmUns10, i16,
3549 SELBr16, ORr16, CLGTHIr16, CEQHIr16>;
3550
3551def : SELECTBinOpReg<setuge, R32C, i32, SELBr32, ORr32, CLGTr32, CEQr32>;
3552def : SELECTBinOpImm<setuge, R32C, i32ImmUns10, i32,
3553 SELBr32, ORr32, CLGTIr32, CEQIr32>;
Scott Michel97872d32008-02-23 18:41:37 +00003554
3555//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
Scott Michel8b6b4202007-12-04 22:35:58 +00003556
3557let isCall = 1,
3558 // All calls clobber the non-callee-saved registers:
3559 Defs = [R0, R1, R2, R3, R4, R5, R6, R7, R8, R9,
3560 R10,R11,R12,R13,R14,R15,R16,R17,R18,R19,
3561 R20,R21,R22,R23,R24,R25,R26,R27,R28,R29,
3562 R30,R31,R32,R33,R34,R35,R36,R37,R38,R39,
3563 R40,R41,R42,R43,R44,R45,R46,R47,R48,R49,
3564 R50,R51,R52,R53,R54,R55,R56,R57,R58,R59,
3565 R60,R61,R62,R63,R64,R65,R66,R67,R68,R69,
3566 R70,R71,R72,R73,R74,R75,R76,R77,R78,R79],
3567 // All of these instructions use $lr (aka $0)
3568 Uses = [R0] in {
3569 // Branch relative and set link: Used if we actually know that the target
3570 // is within [-32768, 32767] bytes of the target
3571 def BRSL:
3572 BranchSetLink<0b011001100, (outs), (ins relcalltarget:$func, variable_ops),
3573 "brsl\t$$lr, $func",
3574 [(SPUcall (SPUpcrel tglobaladdr:$func, 0))]>;
3575
3576 // Branch absolute and set link: Used if we actually know that the target
3577 // is an absolute address
3578 def BRASL:
3579 BranchSetLink<0b011001100, (outs), (ins calltarget:$func, variable_ops),
3580 "brasl\t$$lr, $func",
Scott Micheldbac4cf2008-01-11 02:53:15 +00003581 [(SPUcall (SPUaform tglobaladdr:$func, 0))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00003582
3583 // Branch indirect and set link if external data. These instructions are not
3584 // actually generated, matched by an intrinsic:
3585 def BISLED_00: BISLEDForm<0b11, "bisled\t$$lr, $func", [/* empty pattern */]>;
3586 def BISLED_E0: BISLEDForm<0b10, "bisled\t$$lr, $func", [/* empty pattern */]>;
3587 def BISLED_0D: BISLEDForm<0b01, "bisled\t$$lr, $func", [/* empty pattern */]>;
3588 def BISLED_ED: BISLEDForm<0b00, "bisled\t$$lr, $func", [/* empty pattern */]>;
3589
3590 // Branch indirect and set link. This is the "X-form" address version of a
3591 // function call
3592 def BISL:
3593 BIForm<0b10010101100, "bisl\t$$lr, $func", [(SPUcall R32C:$func)]>;
3594}
3595
Scott Michelae5cbf52008-12-29 03:23:36 +00003596// Support calls to external symbols:
3597def : Pat<(SPUcall (SPUpcrel texternalsym:$func, 0)),
3598 (BRSL texternalsym:$func)>;
3599
3600def : Pat<(SPUcall (SPUaform texternalsym:$func, 0)),
3601 (BRASL texternalsym:$func)>;
3602
Scott Michel8b6b4202007-12-04 22:35:58 +00003603// Unconditional branches:
3604let isBranch = 1, isTerminator = 1, hasCtrlDep = 1, isBarrier = 1 in {
3605 def BR :
3606 UncondBranch<0b001001100, (outs), (ins brtarget:$dest),
3607 "br\t$dest",
3608 [(br bb:$dest)]>;
3609
3610 // Unconditional, absolute address branch
3611 def BRA:
3612 UncondBranch<0b001100000, (outs), (ins brtarget:$dest),
3613 "bra\t$dest",
3614 [/* no pattern */]>;
3615
3616 // Indirect branch
3617 def BI:
3618 BIForm<0b00010101100, "bi\t$func", [(brind R32C:$func)]>;
3619
Scott Michele0168c12009-01-05 01:34:35 +00003620 // Conditional branches:
Scott Michel06eabde2008-12-27 04:51:36 +00003621 class BRNZInst<dag IOL, list<dag> pattern>:
3622 RI16Form<0b010000100, (outs), IOL, "brnz\t$rCond,$dest",
3623 BranchResolv, pattern>;
Scott Michel8b6b4202007-12-04 22:35:58 +00003624
Scott Michel06eabde2008-12-27 04:51:36 +00003625 class BRNZRegInst<RegisterClass rclass>:
3626 BRNZInst<(ins rclass:$rCond, brtarget:$dest),
3627 [(brcond rclass:$rCond, bb:$dest)]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00003628
Scott Michel06eabde2008-12-27 04:51:36 +00003629 class BRNZVecInst<ValueType vectype>:
3630 BRNZInst<(ins VECREG:$rCond, brtarget:$dest),
3631 [(brcond (vectype VECREG:$rCond), bb:$dest)]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00003632
Scott Michel06eabde2008-12-27 04:51:36 +00003633 multiclass BranchNotZero {
3634 def v4i32 : BRNZVecInst<v4i32>;
3635 def r32 : BRNZRegInst<R32C>;
3636 }
Scott Michel8b6b4202007-12-04 22:35:58 +00003637
Scott Michel06eabde2008-12-27 04:51:36 +00003638 defm BRNZ : BranchNotZero;
3639
3640 class BRZInst<dag IOL, list<dag> pattern>:
3641 RI16Form<0b000000100, (outs), IOL, "brz\t$rT,$dest",
3642 BranchResolv, pattern>;
3643
3644 class BRZRegInst<RegisterClass rclass>:
3645 BRZInst<(ins rclass:$rT, brtarget:$dest), [/* no pattern */]>;
3646
3647 class BRZVecInst<ValueType vectype>:
3648 BRZInst<(ins VECREG:$rT, brtarget:$dest), [/* no pattern */]>;
3649
3650 multiclass BranchZero {
3651 def v4i32: BRZVecInst<v4i32>;
3652 def r32: BRZRegInst<R32C>;
3653 }
3654
3655 defm BRZ: BranchZero;
3656
3657 // Note: LLVM doesn't do branch conditional, indirect. Otherwise these would
3658 // be useful:
3659 /*
3660 class BINZInst<dag IOL, list<dag> pattern>:
3661 BICondForm<0b10010100100, (outs), IOL, "binz\t$rA, $dest", pattern>;
3662
3663 class BINZRegInst<RegisterClass rclass>:
3664 BINZInst<(ins rclass:$rA, brtarget:$dest),
3665 [(brcond rclass:$rA, R32C:$dest)]>;
3666
3667 class BINZVecInst<ValueType vectype>:
3668 BINZInst<(ins VECREG:$rA, R32C:$dest),
3669 [(brcond (vectype VECREG:$rA), R32C:$dest)]>;
3670
3671 multiclass BranchNotZeroIndirect {
3672 def v4i32: BINZVecInst<v4i32>;
3673 def r32: BINZRegInst<R32C>;
3674 }
3675
3676 defm BINZ: BranchNotZeroIndirect;
3677
3678 class BIZInst<dag IOL, list<dag> pattern>:
3679 BICondForm<0b00010100100, (outs), IOL, "biz\t$rA, $func", pattern>;
3680
3681 class BIZRegInst<RegisterClass rclass>:
3682 BIZInst<(ins rclass:$rA, R32C:$func), [/* no pattern */]>;
3683
3684 class BIZVecInst<ValueType vectype>:
3685 BIZInst<(ins VECREG:$rA, R32C:$func), [/* no pattern */]>;
3686
3687 multiclass BranchZeroIndirect {
3688 def v4i32: BIZVecInst<v4i32>;
3689 def r32: BIZRegInst<R32C>;
3690 }
3691
3692 defm BIZ: BranchZeroIndirect;
3693 */
3694
3695 class BRHNZInst<dag IOL, list<dag> pattern>:
3696 RI16Form<0b011000100, (outs), IOL, "brhnz\t$rCond,$dest", BranchResolv,
3697 pattern>;
3698
3699 class BRHNZRegInst<RegisterClass rclass>:
3700 BRHNZInst<(ins rclass:$rCond, brtarget:$dest),
3701 [(brcond rclass:$rCond, bb:$dest)]>;
3702
3703 class BRHNZVecInst<ValueType vectype>:
3704 BRHNZInst<(ins VECREG:$rCond, brtarget:$dest), [/* no pattern */]>;
3705
3706 multiclass BranchNotZeroHalfword {
3707 def v8i16: BRHNZVecInst<v8i16>;
3708 def r16: BRHNZRegInst<R16C>;
3709 }
3710
3711 defm BRHNZ: BranchNotZeroHalfword;
3712
3713 class BRHZInst<dag IOL, list<dag> pattern>:
3714 RI16Form<0b001000100, (outs), IOL, "brhz\t$rT,$dest", BranchResolv,
3715 pattern>;
3716
3717 class BRHZRegInst<RegisterClass rclass>:
3718 BRHZInst<(ins rclass:$rT, brtarget:$dest), [/* no pattern */]>;
3719
3720 class BRHZVecInst<ValueType vectype>:
3721 BRHZInst<(ins VECREG:$rT, brtarget:$dest), [/* no pattern */]>;
3722
3723 multiclass BranchZeroHalfword {
3724 def v8i16: BRHZVecInst<v8i16>;
3725 def r16: BRHZRegInst<R16C>;
3726 }
3727
3728 defm BRHZ: BranchZeroHalfword;
Scott Michel8b6b4202007-12-04 22:35:58 +00003729}
3730
Scott Michel394e26d2008-01-17 20:38:41 +00003731//===----------------------------------------------------------------------===//
Scott Michelf9f42e62008-01-29 02:16:57 +00003732// setcc and brcond patterns:
Scott Michel394e26d2008-01-17 20:38:41 +00003733//===----------------------------------------------------------------------===//
Scott Michelf9f42e62008-01-29 02:16:57 +00003734
Scott Michel06eabde2008-12-27 04:51:36 +00003735def : Pat<(brcond (i16 (seteq R16C:$rA, 0)), bb:$dest),
3736 (BRHZr16 R16C:$rA, bb:$dest)>;
3737def : Pat<(brcond (i16 (setne R16C:$rA, 0)), bb:$dest),
3738 (BRHNZr16 R16C:$rA, bb:$dest)>;
Scott Michel97872d32008-02-23 18:41:37 +00003739
Scott Michel06eabde2008-12-27 04:51:36 +00003740def : Pat<(brcond (i32 (seteq R32C:$rA, 0)), bb:$dest),
3741 (BRZr32 R32C:$rA, bb:$dest)>;
3742def : Pat<(brcond (i32 (setne R32C:$rA, 0)), bb:$dest),
3743 (BRNZr32 R32C:$rA, bb:$dest)>;
Scott Michel8b6b4202007-12-04 22:35:58 +00003744
Scott Michel97872d32008-02-23 18:41:37 +00003745multiclass BranchCondEQ<PatFrag cond, SPUInstr brinst16, SPUInstr brinst32>
3746{
3747 def r16imm: Pat<(brcond (i16 (cond R16C:$rA, i16ImmSExt10:$val)), bb:$dest),
3748 (brinst16 (CEQHIr16 R16C:$rA, i16ImmSExt10:$val), bb:$dest)>;
Scott Michelf9f42e62008-01-29 02:16:57 +00003749
Scott Michel97872d32008-02-23 18:41:37 +00003750 def r16 : Pat<(brcond (i16 (cond R16C:$rA, R16C:$rB)), bb:$dest),
3751 (brinst16 (CEQHr16 R16C:$rA, R16:$rB), bb:$dest)>;
3752
3753 def r32imm : Pat<(brcond (i32 (cond R32C:$rA, i32ImmSExt10:$val)), bb:$dest),
3754 (brinst32 (CEQIr32 R32C:$rA, i32ImmSExt10:$val), bb:$dest)>;
3755
3756 def r32 : Pat<(brcond (i32 (cond R32C:$rA, R32C:$rB)), bb:$dest),
3757 (brinst32 (CEQr32 R32C:$rA, R32C:$rB), bb:$dest)>;
3758}
3759
Scott Michele0168c12009-01-05 01:34:35 +00003760defm BRCONDeq : BranchCondEQ<seteq, BRHNZr16, BRNZr32>;
3761defm BRCONDne : BranchCondEQ<setne, BRHZr16, BRZr32>;
Scott Michel97872d32008-02-23 18:41:37 +00003762
3763multiclass BranchCondLGT<PatFrag cond, SPUInstr brinst16, SPUInstr brinst32>
3764{
3765 def r16imm : Pat<(brcond (i16 (cond R16C:$rA, i16ImmSExt10:$val)), bb:$dest),
3766 (brinst16 (CLGTHIr16 R16C:$rA, i16ImmSExt10:$val), bb:$dest)>;
3767
3768 def r16 : Pat<(brcond (i16 (cond R16C:$rA, R16C:$rB)), bb:$dest),
3769 (brinst16 (CLGTHr16 R16C:$rA, R16:$rB), bb:$dest)>;
3770
3771 def r32imm : Pat<(brcond (i32 (cond R32C:$rA, i32ImmSExt10:$val)), bb:$dest),
3772 (brinst32 (CLGTIr32 R32C:$rA, i32ImmSExt10:$val), bb:$dest)>;
3773
3774 def r32 : Pat<(brcond (i32 (cond R32C:$rA, R32C:$rB)), bb:$dest),
3775 (brinst32 (CLGTr32 R32C:$rA, R32C:$rB), bb:$dest)>;
3776}
3777
Scott Michel06eabde2008-12-27 04:51:36 +00003778defm BRCONDugt : BranchCondLGT<setugt, BRHNZr16, BRNZr32>;
3779defm BRCONDule : BranchCondLGT<setule, BRHZr16, BRZr32>;
Scott Michel97872d32008-02-23 18:41:37 +00003780
3781multiclass BranchCondLGTEQ<PatFrag cond, SPUInstr orinst16, SPUInstr brinst16,
3782 SPUInstr orinst32, SPUInstr brinst32>
3783{
3784 def r16imm: Pat<(brcond (i16 (cond R16C:$rA, i16ImmSExt10:$val)), bb:$dest),
3785 (brinst16 (orinst16 (CLGTHIr16 R16C:$rA, i16ImmSExt10:$val),
3786 (CEQHIr16 R16C:$rA, i16ImmSExt10:$val)),
3787 bb:$dest)>;
3788
3789 def r16: Pat<(brcond (i16 (cond R16C:$rA, R16C:$rB)), bb:$dest),
3790 (brinst16 (orinst16 (CLGTHr16 R16C:$rA, R16:$rB),
3791 (CEQHr16 R16C:$rA, R16:$rB)),
3792 bb:$dest)>;
3793
3794 def r32imm : Pat<(brcond (i32 (cond R32C:$rA, i32ImmSExt10:$val)), bb:$dest),
3795 (brinst32 (orinst32 (CLGTIr32 R32C:$rA, i32ImmSExt10:$val),
3796 (CEQIr32 R32C:$rA, i32ImmSExt10:$val)),
3797 bb:$dest)>;
3798
3799 def r32 : Pat<(brcond (i32 (cond R32C:$rA, R32C:$rB)), bb:$dest),
3800 (brinst32 (orinst32 (CLGTr32 R32C:$rA, R32C:$rB),
3801 (CEQr32 R32C:$rA, R32C:$rB)),
3802 bb:$dest)>;
3803}
3804
Scott Michel06eabde2008-12-27 04:51:36 +00003805defm BRCONDuge : BranchCondLGTEQ<setuge, ORr16, BRHNZr16, ORr32, BRNZr32>;
3806defm BRCONDult : BranchCondLGTEQ<setult, ORr16, BRHZr16, ORr32, BRZr32>;
Scott Michel97872d32008-02-23 18:41:37 +00003807
3808multiclass BranchCondGT<PatFrag cond, SPUInstr brinst16, SPUInstr brinst32>
3809{
3810 def r16imm : Pat<(brcond (i16 (cond R16C:$rA, i16ImmSExt10:$val)), bb:$dest),
3811 (brinst16 (CGTHIr16 R16C:$rA, i16ImmSExt10:$val), bb:$dest)>;
3812
3813 def r16 : Pat<(brcond (i16 (cond R16C:$rA, R16C:$rB)), bb:$dest),
3814 (brinst16 (CGTHr16 R16C:$rA, R16:$rB), bb:$dest)>;
3815
3816 def r32imm : Pat<(brcond (i32 (cond R32C:$rA, i32ImmSExt10:$val)), bb:$dest),
3817 (brinst32 (CGTIr32 R32C:$rA, i32ImmSExt10:$val), bb:$dest)>;
3818
3819 def r32 : Pat<(brcond (i32 (cond R32C:$rA, R32C:$rB)), bb:$dest),
3820 (brinst32 (CGTr32 R32C:$rA, R32C:$rB), bb:$dest)>;
3821}
3822
Scott Michel06eabde2008-12-27 04:51:36 +00003823defm BRCONDgt : BranchCondGT<setgt, BRHNZr16, BRNZr32>;
3824defm BRCONDle : BranchCondGT<setle, BRHZr16, BRZr32>;
Scott Michel97872d32008-02-23 18:41:37 +00003825
3826multiclass BranchCondGTEQ<PatFrag cond, SPUInstr orinst16, SPUInstr brinst16,
3827 SPUInstr orinst32, SPUInstr brinst32>
3828{
3829 def r16imm: Pat<(brcond (i16 (cond R16C:$rA, i16ImmSExt10:$val)), bb:$dest),
3830 (brinst16 (orinst16 (CGTHIr16 R16C:$rA, i16ImmSExt10:$val),
3831 (CEQHIr16 R16C:$rA, i16ImmSExt10:$val)),
3832 bb:$dest)>;
3833
3834 def r16: Pat<(brcond (i16 (cond R16C:$rA, R16C:$rB)), bb:$dest),
3835 (brinst16 (orinst16 (CGTHr16 R16C:$rA, R16:$rB),
3836 (CEQHr16 R16C:$rA, R16:$rB)),
3837 bb:$dest)>;
3838
3839 def r32imm : Pat<(brcond (i32 (cond R32C:$rA, i32ImmSExt10:$val)), bb:$dest),
3840 (brinst32 (orinst32 (CGTIr32 R32C:$rA, i32ImmSExt10:$val),
3841 (CEQIr32 R32C:$rA, i32ImmSExt10:$val)),
3842 bb:$dest)>;
3843
3844 def r32 : Pat<(brcond (i32 (cond R32C:$rA, R32C:$rB)), bb:$dest),
3845 (brinst32 (orinst32 (CGTr32 R32C:$rA, R32C:$rB),
3846 (CEQr32 R32C:$rA, R32C:$rB)),
3847 bb:$dest)>;
3848}
3849
Scott Michel06eabde2008-12-27 04:51:36 +00003850defm BRCONDge : BranchCondGTEQ<setge, ORr16, BRHNZr16, ORr32, BRNZr32>;
3851defm BRCONDlt : BranchCondGTEQ<setlt, ORr16, BRHZr16, ORr32, BRZr32>;
Scott Michelf9f42e62008-01-29 02:16:57 +00003852
Scott Michel8b6b4202007-12-04 22:35:58 +00003853let isTerminator = 1, isBarrier = 1 in {
3854 let isReturn = 1 in {
3855 def RET:
3856 RETForm<"bi\t$$lr", [(retflag)]>;
3857 }
3858}
3859
3860//===----------------------------------------------------------------------===//
Scott Michel8b6b4202007-12-04 22:35:58 +00003861// Single precision floating point instructions
3862//===----------------------------------------------------------------------===//
3863
Scott Michel61895fe2008-12-10 00:15:19 +00003864class FAInst<dag OOL, dag IOL, list<dag> pattern>:
3865 RRForm<0b01011000100, OOL, IOL, "fa\t$rT, $rA, $rB",
Scott Michel4d07fb72008-12-30 23:28:25 +00003866 SPrecFP, pattern>;
Scott Michel06eabde2008-12-27 04:51:36 +00003867
Scott Michel61895fe2008-12-10 00:15:19 +00003868class FAVecInst<ValueType vectype>:
3869 FAInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
3870 [(set (vectype VECREG:$rT),
Scott Michel4d07fb72008-12-30 23:28:25 +00003871 (fadd (vectype VECREG:$rA), (vectype VECREG:$rB)))]>;
Scott Michel06eabde2008-12-27 04:51:36 +00003872
Scott Michel61895fe2008-12-10 00:15:19 +00003873multiclass SFPAdd
3874{
3875 def v4f32: FAVecInst<v4f32>;
Scott Michel4d07fb72008-12-30 23:28:25 +00003876 def f32: FAInst<(outs R32FP:$rT), (ins R32FP:$rA, R32FP:$rB),
3877 [(set R32FP:$rT, (fadd R32FP:$rA, R32FP:$rB))]>;
Scott Michel61895fe2008-12-10 00:15:19 +00003878}
Scott Michel8b6b4202007-12-04 22:35:58 +00003879
Scott Michel61895fe2008-12-10 00:15:19 +00003880defm FA : SFPAdd;
Scott Michel8b6b4202007-12-04 22:35:58 +00003881
Scott Michel61895fe2008-12-10 00:15:19 +00003882class FSInst<dag OOL, dag IOL, list<dag> pattern>:
3883 RRForm<0b01011000100, OOL, IOL, "fs\t$rT, $rA, $rB",
Scott Michel4d07fb72008-12-30 23:28:25 +00003884 SPrecFP, pattern>;
Scott Michel8b6b4202007-12-04 22:35:58 +00003885
Scott Michel61895fe2008-12-10 00:15:19 +00003886class FSVecInst<ValueType vectype>:
3887 FSInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
Scott Michel4d07fb72008-12-30 23:28:25 +00003888 [(set (vectype VECREG:$rT),
3889 (fsub (vectype VECREG:$rA), (vectype VECREG:$rB)))]>;
Scott Michel61895fe2008-12-10 00:15:19 +00003890
3891multiclass SFPSub
3892{
3893 def v4f32: FSVecInst<v4f32>;
Scott Michel4d07fb72008-12-30 23:28:25 +00003894 def f32: FSInst<(outs R32FP:$rT), (ins R32FP:$rA, R32FP:$rB),
3895 [(set R32FP:$rT, (fsub R32FP:$rA, R32FP:$rB))]>;
Scott Michel61895fe2008-12-10 00:15:19 +00003896}
3897
3898defm FS : SFPSub;
Scott Michel8b6b4202007-12-04 22:35:58 +00003899
3900// Floating point reciprocal estimate
Scott Michel8b6b4202007-12-04 22:35:58 +00003901
Scott Michel4d07fb72008-12-30 23:28:25 +00003902class FRESTInst<dag OOL, dag IOL>:
3903 RRForm_1<0b00110111000, OOL, IOL,
3904 "frest\t$rT, $rA", SPrecFP,
3905 [/* no pattern */]>;
3906
3907def FRESTv4f32 :
3908 FRESTInst<(outs VECREG:$rT), (ins VECREG:$rA)>;
3909
3910def FRESTf32 :
3911 FRESTInst<(outs R32FP:$rT), (ins R32FP:$rA)>;
Scott Michel8b6b4202007-12-04 22:35:58 +00003912
3913// Floating point interpolate (used in conjunction with reciprocal estimate)
3914def FIv4f32 :
3915 RRForm<0b00101011110, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
3916 "fi\t$rT, $rA, $rB", SPrecFP,
Scott Michel4d07fb72008-12-30 23:28:25 +00003917 [/* no pattern */]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00003918
3919def FIf32 :
3920 RRForm<0b00101011110, (outs R32FP:$rT), (ins R32FP:$rA, R32FP:$rB),
3921 "fi\t$rT, $rA, $rB", SPrecFP,
Scott Michel4d07fb72008-12-30 23:28:25 +00003922 [/* no pattern */]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00003923
Scott Michel33d73eb2008-11-21 02:56:16 +00003924//--------------------------------------------------------------------------
3925// Basic single precision floating point comparisons:
3926//
3927// Note: There is no support on SPU for single precision NaN. Consequently,
3928// ordered and unordered comparisons are the same.
3929//--------------------------------------------------------------------------
3930
Scott Michel8b6b4202007-12-04 22:35:58 +00003931def FCEQf32 :
3932 RRForm<0b01000011110, (outs R32C:$rT), (ins R32FP:$rA, R32FP:$rB),
3933 "fceq\t$rT, $rA, $rB", SPrecFP,
Scott Michel33d73eb2008-11-21 02:56:16 +00003934 [(set R32C:$rT, (setueq R32FP:$rA, R32FP:$rB))]>;
3935
3936def : Pat<(setoeq R32FP:$rA, R32FP:$rB),
3937 (FCEQf32 R32FP:$rA, R32FP:$rB)>;
Scott Michel8b6b4202007-12-04 22:35:58 +00003938
3939def FCMEQf32 :
3940 RRForm<0b01010011110, (outs R32C:$rT), (ins R32FP:$rA, R32FP:$rB),
3941 "fcmeq\t$rT, $rA, $rB", SPrecFP,
Scott Michel33d73eb2008-11-21 02:56:16 +00003942 [(set R32C:$rT, (setueq (fabs R32FP:$rA), (fabs R32FP:$rB)))]>;
3943
3944def : Pat<(setoeq (fabs R32FP:$rA), (fabs R32FP:$rB)),
3945 (FCMEQf32 R32FP:$rA, R32FP:$rB)>;
Scott Michel8b6b4202007-12-04 22:35:58 +00003946
3947def FCGTf32 :
3948 RRForm<0b01000011010, (outs R32C:$rT), (ins R32FP:$rA, R32FP:$rB),
3949 "fcgt\t$rT, $rA, $rB", SPrecFP,
Scott Michel33d73eb2008-11-21 02:56:16 +00003950 [(set R32C:$rT, (setugt R32FP:$rA, R32FP:$rB))]>;
3951
3952def : Pat<(setugt R32FP:$rA, R32FP:$rB),
3953 (FCGTf32 R32FP:$rA, R32FP:$rB)>;
Scott Michel8b6b4202007-12-04 22:35:58 +00003954
3955def FCMGTf32 :
3956 RRForm<0b01010011010, (outs R32C:$rT), (ins R32FP:$rA, R32FP:$rB),
3957 "fcmgt\t$rT, $rA, $rB", SPrecFP,
Scott Michel33d73eb2008-11-21 02:56:16 +00003958 [(set R32C:$rT, (setugt (fabs R32FP:$rA), (fabs R32FP:$rB)))]>;
3959
3960def : Pat<(setugt (fabs R32FP:$rA), (fabs R32FP:$rB)),
3961 (FCMGTf32 R32FP:$rA, R32FP:$rB)>;
3962
3963//--------------------------------------------------------------------------
3964// Single precision floating point comparisons and SETCC equivalents:
3965//--------------------------------------------------------------------------
3966
3967def : SETCCNegCondReg<setune, R32FP, i32, XORIr32, FCEQf32>;
3968def : SETCCNegCondReg<setone, R32FP, i32, XORIr32, FCEQf32>;
3969
3970def : SETCCBinOpReg<setuge, R32FP, ORr32, FCGTf32, FCEQf32>;
3971def : SETCCBinOpReg<setoge, R32FP, ORr32, FCGTf32, FCEQf32>;
3972
3973def : SETCCBinOpReg<setult, R32FP, NORr32, FCGTf32, FCEQf32>;
3974def : SETCCBinOpReg<setolt, R32FP, NORr32, FCGTf32, FCEQf32>;
3975
3976def : Pat<(setule R32FP:$rA, R32FP:$rB),
3977 (XORIr32 (FCGTf32 R32FP:$rA, R32FP:$rB), 0xffffffff)>;
3978def : Pat<(setole R32FP:$rA, R32FP:$rB),
3979 (XORIr32 (FCGTf32 R32FP:$rA, R32FP:$rB), 0xffffffff)>;
Scott Michel8b6b4202007-12-04 22:35:58 +00003980
3981// FP Status and Control Register Write
3982// Why isn't rT a don't care in the ISA?
3983// Should we create a special RRForm_3 for this guy and zero out the rT?
3984def FSCRWf32 :
3985 RRForm_1<0b01011101110, (outs R32FP:$rT), (ins R32FP:$rA),
3986 "fscrwr\t$rA", SPrecFP,
3987 [/* This instruction requires an intrinsic. Note: rT is unused. */]>;
3988
3989// FP Status and Control Register Read
3990def FSCRRf32 :
3991 RRForm_2<0b01011101110, (outs R32FP:$rT), (ins),
3992 "fscrrd\t$rT", SPrecFP,
3993 [/* This instruction requires an intrinsic */]>;
3994
3995// llvm instruction space
3996// How do these map onto cell instructions?
3997// fdiv rA rB
3998// frest rC rB # c = 1/b (both lines)
3999// fi rC rB rC
4000// fm rD rA rC # d = a * 1/b
4001// fnms rB rD rB rA # b = - (d * b - a) --should == 0 in a perfect world
4002// fma rB rB rC rD # b = b * c + d
4003// = -(d *b -a) * c + d
4004// = a * c - c ( a *b *c - a)
4005
4006// fcopysign (???)
4007
4008// Library calls:
4009// These llvm instructions will actually map to library calls.
4010// All that's needed, then, is to check that the appropriate library is
4011// imported and do a brsl to the proper function name.
4012// frem # fmod(x, y): x - (x/y) * y
4013// (Note: fmod(double, double), fmodf(float,float)
4014// fsqrt?
4015// fsin?
4016// fcos?
4017// Unimplemented SPU instruction space
4018// floating reciprocal absolute square root estimate (frsqest)
4019
4020// The following are probably just intrinsics
Scott Michel06eabde2008-12-27 04:51:36 +00004021// status and control register write
Scott Michel8b6b4202007-12-04 22:35:58 +00004022// status and control register read
4023
4024//--------------------------------------
4025// Floating point multiply instructions
4026//--------------------------------------
4027
4028def FMv4f32:
4029 RRForm<0b00100011010, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
4030 "fm\t$rT, $rA, $rB", SPrecFP,
4031 [(set (v4f32 VECREG:$rT), (fmul (v4f32 VECREG:$rA),
4032 (v4f32 VECREG:$rB)))]>;
4033
4034def FMf32 :
4035 RRForm<0b01100011010, (outs R32FP:$rT), (ins R32FP:$rA, R32FP:$rB),
4036 "fm\t$rT, $rA, $rB", SPrecFP,
4037 [(set R32FP:$rT, (fmul R32FP:$rA, R32FP:$rB))]>;
4038
4039// Floating point multiply and add
4040// e.g. d = c + (a * b)
4041def FMAv4f32:
4042 RRRForm<0b0111, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB, VECREG:$rC),
4043 "fma\t$rT, $rA, $rB, $rC", SPrecFP,
4044 [(set (v4f32 VECREG:$rT),
4045 (fadd (v4f32 VECREG:$rC),
4046 (fmul (v4f32 VECREG:$rA), (v4f32 VECREG:$rB))))]>;
4047
4048def FMAf32:
4049 RRRForm<0b0111, (outs R32FP:$rT), (ins R32FP:$rA, R32FP:$rB, R32FP:$rC),
4050 "fma\t$rT, $rA, $rB, $rC", SPrecFP,
4051 [(set R32FP:$rT, (fadd R32FP:$rC, (fmul R32FP:$rA, R32FP:$rB)))]>;
4052
4053// FP multiply and subtract
4054// Subtracts value in rC from product
4055// res = a * b - c
4056def FMSv4f32 :
4057 RRRForm<0b0111, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB, VECREG:$rC),
4058 "fms\t$rT, $rA, $rB, $rC", SPrecFP,
4059 [(set (v4f32 VECREG:$rT),
4060 (fsub (fmul (v4f32 VECREG:$rA), (v4f32 VECREG:$rB)),
4061 (v4f32 VECREG:$rC)))]>;
4062
4063def FMSf32 :
4064 RRRForm<0b0111, (outs R32FP:$rT), (ins R32FP:$rA, R32FP:$rB, R32FP:$rC),
4065 "fms\t$rT, $rA, $rB, $rC", SPrecFP,
4066 [(set R32FP:$rT,
4067 (fsub (fmul R32FP:$rA, R32FP:$rB), R32FP:$rC))]>;
4068
4069// Floating Negative Mulitply and Subtract
4070// Subtracts product from value in rC
4071// res = fneg(fms a b c)
4072// = - (a * b - c)
4073// = c - a * b
4074// NOTE: subtraction order
4075// fsub a b = a - b
Scott Michel06eabde2008-12-27 04:51:36 +00004076// fs a b = b - a?
Scott Michel8b6b4202007-12-04 22:35:58 +00004077def FNMSf32 :
4078 RRRForm<0b1101, (outs R32FP:$rT), (ins R32FP:$rA, R32FP:$rB, R32FP:$rC),
4079 "fnms\t$rT, $rA, $rB, $rC", SPrecFP,
4080 [(set R32FP:$rT, (fsub R32FP:$rC, (fmul R32FP:$rA, R32FP:$rB)))]>;
4081
4082def FNMSv4f32 :
4083 RRRForm<0b1101, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB, VECREG:$rC),
4084 "fnms\t$rT, $rA, $rB, $rC", SPrecFP,
Scott Michel06eabde2008-12-27 04:51:36 +00004085 [(set (v4f32 VECREG:$rT),
4086 (fsub (v4f32 VECREG:$rC),
4087 (fmul (v4f32 VECREG:$rA),
Scott Michel8b6b4202007-12-04 22:35:58 +00004088 (v4f32 VECREG:$rB))))]>;
4089
4090//--------------------------------------
4091// Floating Point Conversions
4092// Signed conversions:
4093def CSiFv4f32:
4094 CVTIntFPForm<0b0101101110, (outs VECREG:$rT), (ins VECREG:$rA),
4095 "csflt\t$rT, $rA, 0", SPrecFP,
4096 [(set (v4f32 VECREG:$rT), (sint_to_fp (v4i32 VECREG:$rA)))]>;
4097
Scott Michel06eabde2008-12-27 04:51:36 +00004098// Convert signed integer to floating point
Scott Michel8b6b4202007-12-04 22:35:58 +00004099def CSiFf32 :
4100 CVTIntFPForm<0b0101101110, (outs R32FP:$rT), (ins R32C:$rA),
4101 "csflt\t$rT, $rA, 0", SPrecFP,
4102 [(set R32FP:$rT, (sint_to_fp R32C:$rA))]>;
4103
4104// Convert unsigned into to float
4105def CUiFv4f32 :
4106 CVTIntFPForm<0b1101101110, (outs VECREG:$rT), (ins VECREG:$rA),
4107 "cuflt\t$rT, $rA, 0", SPrecFP,
4108 [(set (v4f32 VECREG:$rT), (uint_to_fp (v4i32 VECREG:$rA)))]>;
4109
4110def CUiFf32 :
4111 CVTIntFPForm<0b1101101110, (outs R32FP:$rT), (ins R32C:$rA),
4112 "cuflt\t$rT, $rA, 0", SPrecFP,
4113 [(set R32FP:$rT, (uint_to_fp R32C:$rA))]>;
4114
Scott Michel06eabde2008-12-27 04:51:36 +00004115// Convert float to unsigned int
Scott Michel8b6b4202007-12-04 22:35:58 +00004116// Assume that scale = 0
4117
4118def CFUiv4f32 :
4119 CVTIntFPForm<0b1101101110, (outs VECREG:$rT), (ins VECREG:$rA),
4120 "cfltu\t$rT, $rA, 0", SPrecFP,
4121 [(set (v4i32 VECREG:$rT), (fp_to_uint (v4f32 VECREG:$rA)))]>;
4122
4123def CFUif32 :
4124 CVTIntFPForm<0b1101101110, (outs R32C:$rT), (ins R32FP:$rA),
4125 "cfltu\t$rT, $rA, 0", SPrecFP,
4126 [(set R32C:$rT, (fp_to_uint R32FP:$rA))]>;
4127
Scott Michel06eabde2008-12-27 04:51:36 +00004128// Convert float to signed int
Scott Michel8b6b4202007-12-04 22:35:58 +00004129// Assume that scale = 0
4130
4131def CFSiv4f32 :
4132 CVTIntFPForm<0b1101101110, (outs VECREG:$rT), (ins VECREG:$rA),
4133 "cflts\t$rT, $rA, 0", SPrecFP,
4134 [(set (v4i32 VECREG:$rT), (fp_to_sint (v4f32 VECREG:$rA)))]>;
4135
4136def CFSif32 :
4137 CVTIntFPForm<0b1101101110, (outs R32C:$rT), (ins R32FP:$rA),
4138 "cflts\t$rT, $rA, 0", SPrecFP,
4139 [(set R32C:$rT, (fp_to_sint R32FP:$rA))]>;
4140
4141//===----------------------------------------------------------------------==//
4142// Single<->Double precision conversions
4143//===----------------------------------------------------------------------==//
4144
4145// NOTE: We use "vec" name suffix here to avoid confusion (e.g. input is a
4146// v4f32, output is v2f64--which goes in the name?)
4147
4148// Floating point extend single to double
4149// NOTE: Not sure if passing in v4f32 to FESDvec is correct since it
4150// operates on two double-word slots (i.e. 1st and 3rd fp numbers
4151// are ignored).
4152def FESDvec :
4153 RRForm_1<0b00011101110, (outs VECREG:$rT), (ins VECREG:$rA),
4154 "fesd\t$rT, $rA", SPrecFP,
4155 [(set (v2f64 VECREG:$rT), (fextend (v4f32 VECREG:$rA)))]>;
4156
4157def FESDf32 :
4158 RRForm_1<0b00011101110, (outs R64FP:$rT), (ins R32FP:$rA),
4159 "fesd\t$rT, $rA", SPrecFP,
4160 [(set R64FP:$rT, (fextend R32FP:$rA))]>;
4161
4162// Floating point round double to single
4163//def FRDSvec :
4164// RRForm_1<0b10011101110, (outs VECREG:$rT), (ins VECREG:$rA),
4165// "frds\t$rT, $rA,", SPrecFP,
4166// [(set (v4f32 R32FP:$rT), (fround (v2f64 R64FP:$rA)))]>;
4167
4168def FRDSf64 :
4169 RRForm_1<0b10011101110, (outs R32FP:$rT), (ins R64FP:$rA),
4170 "frds\t$rT, $rA", SPrecFP,
4171 [(set R32FP:$rT, (fround R64FP:$rA))]>;
4172
4173//ToDo include anyextend?
4174
4175//===----------------------------------------------------------------------==//
4176// Double precision floating point instructions
4177//===----------------------------------------------------------------------==//
4178def FAf64 :
4179 RRForm<0b00110011010, (outs R64FP:$rT), (ins R64FP:$rA, R64FP:$rB),
4180 "dfa\t$rT, $rA, $rB", DPrecFP,
4181 [(set R64FP:$rT, (fadd R64FP:$rA, R64FP:$rB))]>;
4182
4183def FAv2f64 :
4184 RRForm<0b00110011010, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
4185 "dfa\t$rT, $rA, $rB", DPrecFP,
4186 [(set (v2f64 VECREG:$rT), (fadd (v2f64 VECREG:$rA), (v2f64 VECREG:$rB)))]>;
4187
4188def FSf64 :
4189 RRForm<0b10100011010, (outs R64FP:$rT), (ins R64FP:$rA, R64FP:$rB),
4190 "dfs\t$rT, $rA, $rB", DPrecFP,
4191 [(set R64FP:$rT, (fsub R64FP:$rA, R64FP:$rB))]>;
4192
4193def FSv2f64 :
4194 RRForm<0b10100011010, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
4195 "dfs\t$rT, $rA, $rB", DPrecFP,
4196 [(set (v2f64 VECREG:$rT),
4197 (fsub (v2f64 VECREG:$rA), (v2f64 VECREG:$rB)))]>;
4198
4199def FMf64 :
4200 RRForm<0b01100011010, (outs R64FP:$rT), (ins R64FP:$rA, R64FP:$rB),
4201 "dfm\t$rT, $rA, $rB", DPrecFP,
4202 [(set R64FP:$rT, (fmul R64FP:$rA, R64FP:$rB))]>;
4203
4204def FMv2f64:
4205 RRForm<0b00100011010, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
4206 "dfm\t$rT, $rA, $rB", DPrecFP,
4207 [(set (v2f64 VECREG:$rT),
4208 (fmul (v2f64 VECREG:$rA), (v2f64 VECREG:$rB)))]>;
4209
4210def FMAf64:
4211 RRForm<0b00111010110, (outs R64FP:$rT),
4212 (ins R64FP:$rA, R64FP:$rB, R64FP:$rC),
4213 "dfma\t$rT, $rA, $rB", DPrecFP,
4214 [(set R64FP:$rT, (fadd R64FP:$rC, (fmul R64FP:$rA, R64FP:$rB)))]>,
4215 RegConstraint<"$rC = $rT">,
4216 NoEncode<"$rC">;
4217
4218def FMAv2f64:
4219 RRForm<0b00111010110, (outs VECREG:$rT),
4220 (ins VECREG:$rA, VECREG:$rB, VECREG:$rC),
4221 "dfma\t$rT, $rA, $rB", DPrecFP,
4222 [(set (v2f64 VECREG:$rT),
4223 (fadd (v2f64 VECREG:$rC),
4224 (fmul (v2f64 VECREG:$rA), (v2f64 VECREG:$rB))))]>,
4225 RegConstraint<"$rC = $rT">,
4226 NoEncode<"$rC">;
4227
4228def FMSf64 :
4229 RRForm<0b10111010110, (outs R64FP:$rT),
4230 (ins R64FP:$rA, R64FP:$rB, R64FP:$rC),
4231 "dfms\t$rT, $rA, $rB", DPrecFP,
4232 [(set R64FP:$rT, (fsub (fmul R64FP:$rA, R64FP:$rB), R64FP:$rC))]>,
4233 RegConstraint<"$rC = $rT">,
4234 NoEncode<"$rC">;
4235
4236def FMSv2f64 :
4237 RRForm<0b10111010110, (outs VECREG:$rT),
4238 (ins VECREG:$rA, VECREG:$rB, VECREG:$rC),
4239 "dfms\t$rT, $rA, $rB", DPrecFP,
4240 [(set (v2f64 VECREG:$rT),
4241 (fsub (fmul (v2f64 VECREG:$rA), (v2f64 VECREG:$rB)),
4242 (v2f64 VECREG:$rC)))]>;
4243
Scott Michel0d5eae02009-03-17 01:15:45 +00004244// DFNMS: - (a * b - c)
Scott Michel8b6b4202007-12-04 22:35:58 +00004245// - (a * b) + c => c - (a * b)
Scott Michel0d5eae02009-03-17 01:15:45 +00004246
4247class DFNMSInst<dag OOL, dag IOL, list<dag> pattern>:
4248 RRForm<0b01111010110, OOL, IOL, "dfnms\t$rT, $rA, $rB",
4249 DPrecFP, pattern>,
Scott Michel8b6b4202007-12-04 22:35:58 +00004250 RegConstraint<"$rC = $rT">,
4251 NoEncode<"$rC">;
4252
Scott Michel0d5eae02009-03-17 01:15:45 +00004253class DFNMSVecInst<list<dag> pattern>:
4254 DFNMSInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB, VECREG:$rC),
4255 pattern>;
Scott Michel8b6b4202007-12-04 22:35:58 +00004256
Scott Michel0d5eae02009-03-17 01:15:45 +00004257class DFNMSRegInst<list<dag> pattern>:
4258 DFNMSInst<(outs R64FP:$rT), (ins R64FP:$rA, R64FP:$rB, R64FP:$rC),
4259 pattern>;
Scott Michel8b6b4202007-12-04 22:35:58 +00004260
Scott Michel0d5eae02009-03-17 01:15:45 +00004261multiclass DFMultiplySubtract
4262{
4263 def v2f64 : DFNMSVecInst<[(set (v2f64 VECREG:$rT),
4264 (fsub (v2f64 VECREG:$rC),
4265 (fmul (v2f64 VECREG:$rA),
4266 (v2f64 VECREG:$rB))))]>;
4267
4268 def f64 : DFNMSRegInst<[(set R64FP:$rT,
4269 (fsub R64FP:$rC,
4270 (fmul R64FP:$rA, R64FP:$rB)))]>;
4271}
4272
4273defm DFNMS : DFMultiplySubtract;
Scott Michel8b6b4202007-12-04 22:35:58 +00004274
4275// - (a * b + c)
4276// - (a * b) - c
4277def FNMAf64 :
4278 RRForm<0b11111010110, (outs R64FP:$rT),
4279 (ins R64FP:$rA, R64FP:$rB, R64FP:$rC),
4280 "dfnma\t$rT, $rA, $rB", DPrecFP,
4281 [(set R64FP:$rT, (fneg (fadd R64FP:$rC, (fmul R64FP:$rA, R64FP:$rB))))]>,
4282 RegConstraint<"$rC = $rT">,
4283 NoEncode<"$rC">;
4284
4285def FNMAv2f64 :
4286 RRForm<0b11111010110, (outs VECREG:$rT),
4287 (ins VECREG:$rA, VECREG:$rB, VECREG:$rC),
4288 "dfnma\t$rT, $rA, $rB", DPrecFP,
Scott Michel06eabde2008-12-27 04:51:36 +00004289 [(set (v2f64 VECREG:$rT),
4290 (fneg (fadd (v2f64 VECREG:$rC),
4291 (fmul (v2f64 VECREG:$rA),
Scott Michel8b6b4202007-12-04 22:35:58 +00004292 (v2f64 VECREG:$rB)))))]>,
4293 RegConstraint<"$rC = $rT">,
4294 NoEncode<"$rC">;
4295
4296//===----------------------------------------------------------------------==//
4297// Floating point negation and absolute value
4298//===----------------------------------------------------------------------==//
4299
4300def : Pat<(fneg (v4f32 VECREG:$rA)),
Scott Michel0d5eae02009-03-17 01:15:45 +00004301 (ORfnegvec (v4f32 VECREG:$rA),
4302 (v4f32 (ILHUv4i32 0x8000)))>;
Scott Michel8b6b4202007-12-04 22:35:58 +00004303
4304def : Pat<(fneg R32FP:$rA),
Scott Michel0d5eae02009-03-17 01:15:45 +00004305 (ORfneg32 R32FP:$rA, (ILHUr32 0x8000))>;
Scott Michel8b6b4202007-12-04 22:35:58 +00004306
4307// Floating point absolute value
Scott Michel0d5eae02009-03-17 01:15:45 +00004308// Note: f64 fabs is custom-selected.
Scott Michel8b6b4202007-12-04 22:35:58 +00004309
4310def : Pat<(fabs R32FP:$rA),
4311 (ANDfabs32 R32FP:$rA, (IOHLr32 (ILHUr32 0x7fff), 0xffff))>;
4312
4313def : Pat<(fabs (v4f32 VECREG:$rA)),
4314 (ANDfabsvec (v4f32 VECREG:$rA),
Scott Michel0d5eae02009-03-17 01:15:45 +00004315 (IOHLv4i32 (ILHUv4i32 0x7fff), 0xffff))>;
pingbak2f387e82009-01-26 03:31:40 +00004316
Scott Michel8b6b4202007-12-04 22:35:58 +00004317//===----------------------------------------------------------------------===//
Scott Michel61895fe2008-12-10 00:15:19 +00004318// Hint for branch instructions:
4319//===----------------------------------------------------------------------===//
4320
4321/* def HBR : SPUInstr<(outs), (ins), "hbr\t" */
4322
4323//===----------------------------------------------------------------------===//
Scott Michel8b6b4202007-12-04 22:35:58 +00004324// Execution, Load NOP (execute NOPs belong in even pipeline, load NOPs belong
4325// in the odd pipeline)
4326//===----------------------------------------------------------------------===//
4327
Scott Michel97872d32008-02-23 18:41:37 +00004328def ENOP : SPUInstr<(outs), (ins), "enop", ExecNOP> {
Scott Michel8b6b4202007-12-04 22:35:58 +00004329 let Pattern = [];
4330
4331 let Inst{0-10} = 0b10000000010;
4332 let Inst{11-17} = 0;
4333 let Inst{18-24} = 0;
4334 let Inst{25-31} = 0;
4335}
4336
Scott Michel97872d32008-02-23 18:41:37 +00004337def LNOP : SPUInstr<(outs), (ins), "lnop", LoadNOP> {
Scott Michel8b6b4202007-12-04 22:35:58 +00004338 let Pattern = [];
4339
4340 let Inst{0-10} = 0b10000000000;
4341 let Inst{11-17} = 0;
4342 let Inst{18-24} = 0;
4343 let Inst{25-31} = 0;
4344}
4345
4346//===----------------------------------------------------------------------===//
4347// Bit conversions (type conversions between vector/packed types)
Scott Michel34712c32009-03-16 18:47:25 +00004348// NOTE: Promotions are handled using the XS* instructions.
Scott Michel8b6b4202007-12-04 22:35:58 +00004349//===----------------------------------------------------------------------===//
4350def : Pat<(v16i8 (bitconvert (v8i16 VECREG:$src))), (v16i8 VECREG:$src)>;
4351def : Pat<(v16i8 (bitconvert (v4i32 VECREG:$src))), (v16i8 VECREG:$src)>;
4352def : Pat<(v16i8 (bitconvert (v2i64 VECREG:$src))), (v16i8 VECREG:$src)>;
4353def : Pat<(v16i8 (bitconvert (v4f32 VECREG:$src))), (v16i8 VECREG:$src)>;
4354def : Pat<(v16i8 (bitconvert (v2f64 VECREG:$src))), (v16i8 VECREG:$src)>;
4355
4356def : Pat<(v8i16 (bitconvert (v16i8 VECREG:$src))), (v8i16 VECREG:$src)>;
4357def : Pat<(v8i16 (bitconvert (v4i32 VECREG:$src))), (v8i16 VECREG:$src)>;
4358def : Pat<(v8i16 (bitconvert (v2i64 VECREG:$src))), (v8i16 VECREG:$src)>;
4359def : Pat<(v8i16 (bitconvert (v4f32 VECREG:$src))), (v8i16 VECREG:$src)>;
4360def : Pat<(v8i16 (bitconvert (v2f64 VECREG:$src))), (v8i16 VECREG:$src)>;
4361
4362def : Pat<(v4i32 (bitconvert (v16i8 VECREG:$src))), (v4i32 VECREG:$src)>;
4363def : Pat<(v4i32 (bitconvert (v8i16 VECREG:$src))), (v4i32 VECREG:$src)>;
4364def : Pat<(v4i32 (bitconvert (v2i64 VECREG:$src))), (v4i32 VECREG:$src)>;
4365def : Pat<(v4i32 (bitconvert (v4f32 VECREG:$src))), (v4i32 VECREG:$src)>;
4366def : Pat<(v4i32 (bitconvert (v2f64 VECREG:$src))), (v4i32 VECREG:$src)>;
4367
4368def : Pat<(v2i64 (bitconvert (v16i8 VECREG:$src))), (v2i64 VECREG:$src)>;
4369def : Pat<(v2i64 (bitconvert (v8i16 VECREG:$src))), (v2i64 VECREG:$src)>;
4370def : Pat<(v2i64 (bitconvert (v4i32 VECREG:$src))), (v2i64 VECREG:$src)>;
4371def : Pat<(v2i64 (bitconvert (v4f32 VECREG:$src))), (v2i64 VECREG:$src)>;
4372def : Pat<(v2i64 (bitconvert (v2f64 VECREG:$src))), (v2i64 VECREG:$src)>;
4373
4374def : Pat<(v4f32 (bitconvert (v16i8 VECREG:$src))), (v4f32 VECREG:$src)>;
4375def : Pat<(v4f32 (bitconvert (v8i16 VECREG:$src))), (v4f32 VECREG:$src)>;
4376def : Pat<(v4f32 (bitconvert (v2i64 VECREG:$src))), (v4f32 VECREG:$src)>;
4377def : Pat<(v4f32 (bitconvert (v4i32 VECREG:$src))), (v4f32 VECREG:$src)>;
4378def : Pat<(v4f32 (bitconvert (v2f64 VECREG:$src))), (v4f32 VECREG:$src)>;
4379
4380def : Pat<(v2f64 (bitconvert (v16i8 VECREG:$src))), (v2f64 VECREG:$src)>;
4381def : Pat<(v2f64 (bitconvert (v8i16 VECREG:$src))), (v2f64 VECREG:$src)>;
4382def : Pat<(v2f64 (bitconvert (v4i32 VECREG:$src))), (v2f64 VECREG:$src)>;
4383def : Pat<(v2f64 (bitconvert (v2i64 VECREG:$src))), (v2f64 VECREG:$src)>;
4384def : Pat<(v2f64 (bitconvert (v2f64 VECREG:$src))), (v2f64 VECREG:$src)>;
4385
Scott Michel34712c32009-03-16 18:47:25 +00004386def : Pat<(i128 (bitconvert (v16i8 VECREG:$src))),
4387 (ORi128_vec VECREG:$src)>;
4388def : Pat<(i128 (bitconvert (v8i16 VECREG:$src))),
4389 (ORi128_vec VECREG:$src)>;
4390def : Pat<(i128 (bitconvert (v4i32 VECREG:$src))),
4391 (ORi128_vec VECREG:$src)>;
4392def : Pat<(i128 (bitconvert (v2i64 VECREG:$src))),
4393 (ORi128_vec VECREG:$src)>;
4394def : Pat<(i128 (bitconvert (v4f32 VECREG:$src))),
4395 (ORi128_vec VECREG:$src)>;
4396def : Pat<(i128 (bitconvert (v2f64 VECREG:$src))),
4397 (ORi128_vec VECREG:$src)>;
4398
4399def : Pat<(v16i8 (bitconvert (i128 GPRC:$src))),
4400 (v16i8 (ORvec_i128 GPRC:$src))>;
4401def : Pat<(v8i16 (bitconvert (i128 GPRC:$src))),
4402 (v8i16 (ORvec_i128 GPRC:$src))>;
4403def : Pat<(v4i32 (bitconvert (i128 GPRC:$src))),
4404 (v4i32 (ORvec_i128 GPRC:$src))>;
4405def : Pat<(v2i64 (bitconvert (i128 GPRC:$src))),
4406 (v2i64 (ORvec_i128 GPRC:$src))>;
4407def : Pat<(v4f32 (bitconvert (i128 GPRC:$src))),
4408 (v4f32 (ORvec_i128 GPRC:$src))>;
4409def : Pat<(v2f64 (bitconvert (i128 GPRC:$src))),
4410 (v2f64 (ORvec_i128 GPRC:$src))>;
Scott Michel8b6b4202007-12-04 22:35:58 +00004411
4412//===----------------------------------------------------------------------===//
4413// Instruction patterns:
4414//===----------------------------------------------------------------------===//
4415
4416// General 32-bit constants:
4417def : Pat<(i32 imm:$imm),
4418 (IOHLr32 (ILHUr32 (HI16 imm:$imm)), (LO16 imm:$imm))>;
4419
4420// Single precision float constants:
Nate Begeman78125042008-02-14 18:43:04 +00004421def : Pat<(f32 fpimm:$imm),
Scott Michel8b6b4202007-12-04 22:35:58 +00004422 (IOHLf32 (ILHUf32 (HI16_f32 fpimm:$imm)), (LO16_f32 fpimm:$imm))>;
4423
4424// General constant 32-bit vectors
4425def : Pat<(v4i32 v4i32Imm:$imm),
Scott Michel6baba072008-03-05 23:02:02 +00004426 (IOHLv4i32 (v4i32 (ILHUv4i32 (HI16_vec v4i32Imm:$imm))),
4427 (LO16_vec v4i32Imm:$imm))>;
Scott Michel06eabde2008-12-27 04:51:36 +00004428
Scott Michel438be252007-12-17 22:32:34 +00004429// 8-bit constants
4430def : Pat<(i8 imm:$imm),
4431 (ILHr8 imm:$imm)>;
Scott Michel8b6b4202007-12-04 22:35:58 +00004432
4433//===----------------------------------------------------------------------===//
4434// Call instruction patterns:
4435//===----------------------------------------------------------------------===//
4436// Return void
4437def : Pat<(ret),
4438 (RET)>;
4439
4440//===----------------------------------------------------------------------===//
4441// Zero/Any/Sign extensions
4442//===----------------------------------------------------------------------===//
4443
Scott Michel8b6b4202007-12-04 22:35:58 +00004444// sext 8->32: Sign extend bytes to words
4445def : Pat<(sext_inreg R32C:$rSrc, i8),
4446 (XSHWr32 (XSBHr32 R32C:$rSrc))>;
4447
Scott Michel438be252007-12-17 22:32:34 +00004448def : Pat<(i32 (sext R8C:$rSrc)),
4449 (XSHWr16 (XSBHr8 R8C:$rSrc))>;
4450
Scott Michel2ef773a2009-01-06 03:36:14 +00004451// sext 8->64: Sign extend bytes to double word
4452def : Pat<(sext_inreg R64C:$rSrc, i8),
4453 (XSWDr64_inreg (XSHWr64 (XSBHr64 R64C:$rSrc)))>;
4454
4455def : Pat<(i64 (sext R8C:$rSrc)),
4456 (XSWDr64 (XSHWr16 (XSBHr8 R8C:$rSrc)))>;
4457
Scott Michel438be252007-12-17 22:32:34 +00004458// zext 8->16: Zero extend bytes to halfwords
4459def : Pat<(i16 (zext R8C:$rSrc)),
Scott Michel97872d32008-02-23 18:41:37 +00004460 (ANDHIi8i16 R8C:$rSrc, 0xff)>;
Scott Michel438be252007-12-17 22:32:34 +00004461
Scott Michel438be252007-12-17 22:32:34 +00004462// zext 8->32: Zero extend bytes to words
4463def : Pat<(i32 (zext R8C:$rSrc)),
Scott Michel97872d32008-02-23 18:41:37 +00004464 (ANDIi8i32 R8C:$rSrc, 0xff)>;
Scott Michel438be252007-12-17 22:32:34 +00004465
Scott Michel2ef773a2009-01-06 03:36:14 +00004466// zext 8->64: Zero extend bytes to double words
4467def : Pat<(i64 (zext R8C:$rSrc)),
4468 (ORi64_v2i64 (SELBv4i32 (ROTQMBYv4i32
4469 (ORv4i32_i32 (ANDIi8i32 R8C:$rSrc, 0xff)),
4470 0x4),
4471 (ILv4i32 0x0),
4472 (FSMBIv4i32 0x0f0f)))>;
4473
4474// anyext 8->16: Extend 8->16 bits, irrespective of sign, preserves high bits
Scott Michel438be252007-12-17 22:32:34 +00004475def : Pat<(i16 (anyext R8C:$rSrc)),
Scott Michel97872d32008-02-23 18:41:37 +00004476 (ORHIi8i16 R8C:$rSrc, 0)>;
Scott Michel438be252007-12-17 22:32:34 +00004477
Scott Michel2ef773a2009-01-06 03:36:14 +00004478// anyext 8->32: Extend 8->32 bits, irrespective of sign, preserves high bits
Scott Michel438be252007-12-17 22:32:34 +00004479def : Pat<(i32 (anyext R8C:$rSrc)),
Scott Michel97872d32008-02-23 18:41:37 +00004480 (ORIi8i32 R8C:$rSrc, 0)>;
Scott Michel438be252007-12-17 22:32:34 +00004481
Scott Michel2ef773a2009-01-06 03:36:14 +00004482// sext 16->64: Sign extend halfword to double word
4483def : Pat<(sext_inreg R64C:$rSrc, i16),
4484 (XSWDr64_inreg (XSHWr64 R64C:$rSrc))>;
4485
4486def : Pat<(sext R16C:$rSrc),
4487 (XSWDr64 (XSHWr16 R16C:$rSrc))>;
4488
Scott Michel97872d32008-02-23 18:41:37 +00004489// zext 16->32: Zero extend halfwords to words
Scott Michel8b6b4202007-12-04 22:35:58 +00004490def : Pat<(i32 (zext R16C:$rSrc)),
Scott Michel97872d32008-02-23 18:41:37 +00004491 (ANDi16i32 R16C:$rSrc, (ILAr32 0xffff))>;
Scott Michel8b6b4202007-12-04 22:35:58 +00004492
4493def : Pat<(i32 (zext (and R16C:$rSrc, 0xf))),
Scott Michel97872d32008-02-23 18:41:37 +00004494 (ANDIi16i32 R16C:$rSrc, 0xf)>;
Scott Michel8b6b4202007-12-04 22:35:58 +00004495
4496def : Pat<(i32 (zext (and R16C:$rSrc, 0xff))),
Scott Michel97872d32008-02-23 18:41:37 +00004497 (ANDIi16i32 R16C:$rSrc, 0xff)>;
Scott Michel8b6b4202007-12-04 22:35:58 +00004498
4499def : Pat<(i32 (zext (and R16C:$rSrc, 0xfff))),
Scott Michel97872d32008-02-23 18:41:37 +00004500 (ANDIi16i32 R16C:$rSrc, 0xfff)>;
Scott Michel8b6b4202007-12-04 22:35:58 +00004501
4502// anyext 16->32: Extend 16->32 bits, irrespective of sign
4503def : Pat<(i32 (anyext R16C:$rSrc)),
Scott Michel97872d32008-02-23 18:41:37 +00004504 (ORIi16i32 R16C:$rSrc, 0)>;
Scott Michel8b6b4202007-12-04 22:35:58 +00004505
4506//===----------------------------------------------------------------------===//
Scott Michel06eabde2008-12-27 04:51:36 +00004507// Truncates:
4508// These truncates are for the SPU's supported types (i8, i16, i32). i64 and
4509// above are custom lowered.
4510//===----------------------------------------------------------------------===//
4511
4512def : Pat<(i8 (trunc GPRC:$src)),
4513 (ORi8_v16i8
4514 (SHUFBgprc GPRC:$src, GPRC:$src,
4515 (IOHLv4i32 (ILHUv4i32 0x0f0f), 0x0f0f)))>;
4516
4517def : Pat<(i8 (trunc R64C:$src)),
4518 (ORi8_v16i8
4519 (SHUFBv2i64_m32
4520 (ORv2i64_i64 R64C:$src),
4521 (ORv2i64_i64 R64C:$src),
4522 (IOHLv4i32 (ILHUv4i32 0x0707), 0x0707)))>;
4523
4524def : Pat<(i8 (trunc R32C:$src)),
4525 (ORi8_v16i8
4526 (SHUFBv4i32_m32
4527 (ORv4i32_i32 R32C:$src),
4528 (ORv4i32_i32 R32C:$src),
4529 (IOHLv4i32 (ILHUv4i32 0x0303), 0x0303)))>;
4530
4531def : Pat<(i8 (trunc R16C:$src)),
4532 (ORi8_v16i8
4533 (SHUFBv4i32_m32
4534 (ORv8i16_i16 R16C:$src),
4535 (ORv8i16_i16 R16C:$src),
4536 (IOHLv4i32 (ILHUv4i32 0x0303), 0x0303)))>;
4537
4538def : Pat<(i16 (trunc GPRC:$src)),
4539 (ORi16_v8i16
4540 (SHUFBgprc GPRC:$src, GPRC:$src,
4541 (IOHLv4i32 (ILHUv4i32 0x0e0f), 0x0e0f)))>;
4542
4543def : Pat<(i16 (trunc R64C:$src)),
4544 (ORi16_v8i16
4545 (SHUFBv2i64_m32
4546 (ORv2i64_i64 R64C:$src),
4547 (ORv2i64_i64 R64C:$src),
4548 (IOHLv4i32 (ILHUv4i32 0x0607), 0x0607)))>;
4549
4550def : Pat<(i16 (trunc R32C:$src)),
4551 (ORi16_v8i16
4552 (SHUFBv4i32_m32
4553 (ORv4i32_i32 R32C:$src),
4554 (ORv4i32_i32 R32C:$src),
4555 (IOHLv4i32 (ILHUv4i32 0x0203), 0x0203)))>;
4556
4557def : Pat<(i32 (trunc GPRC:$src)),
4558 (ORi32_v4i32
4559 (SHUFBgprc GPRC:$src, GPRC:$src,
4560 (IOHLv4i32 (ILHUv4i32 0x0c0d), 0x0e0f)))>;
4561
4562def : Pat<(i32 (trunc R64C:$src)),
4563 (ORi32_v4i32
4564 (SHUFBv2i64_m32
4565 (ORv2i64_i64 R64C:$src),
4566 (ORv2i64_i64 R64C:$src),
4567 (IOHLv4i32 (ILHUv4i32 0x0405), 0x0607)))>;
4568
4569//===----------------------------------------------------------------------===//
Scott Michelf9f42e62008-01-29 02:16:57 +00004570// Address generation: SPU, like PPC, has to split addresses into high and
Scott Michel8b6b4202007-12-04 22:35:58 +00004571// low parts in order to load them into a register.
4572//===----------------------------------------------------------------------===//
4573
Scott Michelf9f42e62008-01-29 02:16:57 +00004574def : Pat<(SPUaform tglobaladdr:$in, 0), (ILAlsa tglobaladdr:$in)>;
4575def : Pat<(SPUaform texternalsym:$in, 0), (ILAlsa texternalsym:$in)>;
4576def : Pat<(SPUaform tjumptable:$in, 0), (ILAlsa tjumptable:$in)>;
4577def : Pat<(SPUaform tconstpool:$in, 0), (ILAlsa tconstpool:$in)>;
4578
4579def : Pat<(SPUindirect (SPUhi tglobaladdr:$in, 0),
4580 (SPUlo tglobaladdr:$in, 0)),
Scott Micheldbac4cf2008-01-11 02:53:15 +00004581 (IOHLlo (ILHUhi tglobaladdr:$in), tglobaladdr:$in)>;
Scott Michel394e26d2008-01-17 20:38:41 +00004582
Scott Michelf9f42e62008-01-29 02:16:57 +00004583def : Pat<(SPUindirect (SPUhi texternalsym:$in, 0),
4584 (SPUlo texternalsym:$in, 0)),
4585 (IOHLlo (ILHUhi texternalsym:$in), texternalsym:$in)>;
4586
4587def : Pat<(SPUindirect (SPUhi tjumptable:$in, 0),
4588 (SPUlo tjumptable:$in, 0)),
Scott Micheldbac4cf2008-01-11 02:53:15 +00004589 (IOHLlo (ILHUhi tjumptable:$in), tjumptable:$in)>;
Scott Michel394e26d2008-01-17 20:38:41 +00004590
Scott Michelf9f42e62008-01-29 02:16:57 +00004591def : Pat<(SPUindirect (SPUhi tconstpool:$in, 0),
4592 (SPUlo tconstpool:$in, 0)),
4593 (IOHLlo (ILHUhi tconstpool:$in), tconstpool:$in)>;
4594
4595def : Pat<(add (SPUhi tglobaladdr:$in, 0), (SPUlo tglobaladdr:$in, 0)),
4596 (IOHLlo (ILHUhi tglobaladdr:$in), tglobaladdr:$in)>;
4597
4598def : Pat<(add (SPUhi texternalsym:$in, 0), (SPUlo texternalsym:$in, 0)),
4599 (IOHLlo (ILHUhi texternalsym:$in), texternalsym:$in)>;
4600
4601def : Pat<(add (SPUhi tjumptable:$in, 0), (SPUlo tjumptable:$in, 0)),
4602 (IOHLlo (ILHUhi tjumptable:$in), tjumptable:$in)>;
4603
4604def : Pat<(add (SPUhi tconstpool:$in, 0), (SPUlo tconstpool:$in, 0)),
4605 (IOHLlo (ILHUhi tconstpool:$in), tconstpool:$in)>;
Scott Michel8b6b4202007-12-04 22:35:58 +00004606
Scott Michel34712c32009-03-16 18:47:25 +00004607// Intrinsics:
Scott Michel8b6b4202007-12-04 22:35:58 +00004608include "CellSDKIntrinsics.td"
Scott Michel4d07fb72008-12-30 23:28:25 +00004609// Various math operator instruction sequences
4610include "SPUMathInstr.td"
Scott Michel06eabde2008-12-27 04:51:36 +00004611// 64-bit "instructions"/support
4612include "SPU64InstrInfo.td"
Scott Michel2ef773a2009-01-06 03:36:14 +00004613// 128-bit "instructions"/support
4614include "SPU128InstrInfo.td"