blob: e1d9228ef93b18e30905c481183606b70638cb2e [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
pingbak2f387e82009-01-26 03:31:40 +00001261 def fabs64: ANDInst<(outs R64FP:$rT), (ins R64FP:$rA, VECREG:$rB),
1262 [/* Intentionally does not match a pattern */]>;
1263
Scott Michel97872d32008-02-23 18:41:37 +00001264 // Could use v4i32, but won't for clarity
1265 def fabsvec: ANDInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1266 [/* Intentionally does not match a pattern */]>;
1267
1268 //===---------------------------------------------
1269
1270 // Hacked form of AND to zero-extend 16-bit quantities to 32-bit
1271 // quantities -- see 16->32 zext pattern.
1272 //
1273 // This pattern is somewhat artificial, since it might match some
1274 // compiler generated pattern but it is unlikely to do so.
1275
1276 def i16i32: ANDInst<(outs R32C:$rT), (ins R16C:$rA, R32C:$rB),
1277 [(set R32C:$rT, (and (zext R16C:$rA), R32C:$rB))]>;
1278}
1279
1280defm AND : BitwiseAnd;
Scott Michel8b6b4202007-12-04 22:35:58 +00001281
1282// N.B.: vnot_conv is one of those special target selection pattern fragments,
1283// in which we expect there to be a bit_convert on the constant. Bear in mind
1284// that llvm translates "not <reg>" to "xor <reg>, -1" (or in this case, a
1285// constant -1 vector.)
Scott Michel8b6b4202007-12-04 22:35:58 +00001286
Scott Michel97872d32008-02-23 18:41:37 +00001287class ANDCInst<dag OOL, dag IOL, list<dag> pattern>:
1288 RRForm<0b10000011010, OOL, IOL, "andc\t$rT, $rA, $rB",
1289 IntegerOp, pattern>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001290
Scott Michel97872d32008-02-23 18:41:37 +00001291class ANDCVecInst<ValueType vectype>:
1292 ANDCInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1293 [(set (vectype VECREG:$rT), (and (vectype VECREG:$rA),
1294 (vnot (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>;
1312}
Scott Michel438be252007-12-17 22:32:34 +00001313
Scott Michel97872d32008-02-23 18:41:37 +00001314defm ANDC : AndComplement;
Scott Michel8b6b4202007-12-04 22:35:58 +00001315
Scott Michel97872d32008-02-23 18:41:37 +00001316class ANDBIInst<dag OOL, dag IOL, list<dag> pattern>:
1317 RI10Form<0b01101000, OOL, IOL, "andbi\t$rT, $rA, $val",
Scott Michel61895fe2008-12-10 00:15:19 +00001318 ByteOp, pattern>;
Scott Michel438be252007-12-17 22:32:34 +00001319
Scott Michel97872d32008-02-23 18:41:37 +00001320multiclass AndByteImm
1321{
1322 def v16i8: ANDBIInst<(outs VECREG:$rT), (ins VECREG:$rA, u10imm:$val),
1323 [(set (v16i8 VECREG:$rT),
1324 (and (v16i8 VECREG:$rA),
1325 (v16i8 v16i8U8Imm:$val)))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001326
Scott Michel97872d32008-02-23 18:41:37 +00001327 def r8: ANDBIInst<(outs R8C:$rT), (ins R8C:$rA, u10imm_i8:$val),
1328 [(set R8C:$rT, (and R8C:$rA, immU8:$val))]>;
1329}
Scott Michel438be252007-12-17 22:32:34 +00001330
Scott Michel97872d32008-02-23 18:41:37 +00001331defm ANDBI : AndByteImm;
Scott Michel8b6b4202007-12-04 22:35:58 +00001332
Scott Michel97872d32008-02-23 18:41:37 +00001333class ANDHIInst<dag OOL, dag IOL, list<dag> pattern> :
1334 RI10Form<0b10101000, OOL, IOL, "andhi\t$rT, $rA, $val",
Scott Michel61895fe2008-12-10 00:15:19 +00001335 ByteOp, pattern>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001336
Scott Michel97872d32008-02-23 18:41:37 +00001337multiclass AndHalfwordImm
1338{
1339 def v8i16: ANDHIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
1340 [(set (v8i16 VECREG:$rT),
1341 (and (v8i16 VECREG:$rA), v8i16SExt10Imm:$val))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001342
Scott Michel97872d32008-02-23 18:41:37 +00001343 def r16: ANDHIInst<(outs R16C:$rT), (ins R16C:$rA, u10imm:$val),
1344 [(set R16C:$rT, (and R16C:$rA, i16ImmUns10:$val))]>;
Scott Michel438be252007-12-17 22:32:34 +00001345
Scott Michel97872d32008-02-23 18:41:37 +00001346 // Zero-extend i8 to i16:
1347 def i8i16: ANDHIInst<(outs R16C:$rT), (ins R8C:$rA, u10imm:$val),
1348 [(set R16C:$rT, (and (zext R8C:$rA), i16ImmUns10:$val))]>;
1349}
Scott Michel8b6b4202007-12-04 22:35:58 +00001350
Scott Michel97872d32008-02-23 18:41:37 +00001351defm ANDHI : AndHalfwordImm;
1352
1353class ANDIInst<dag OOL, dag IOL, list<dag> pattern> :
1354 RI10Form<0b00101000, OOL, IOL, "andi\t$rT, $rA, $val",
1355 IntegerOp, pattern>;
1356
1357multiclass AndWordImm
1358{
1359 def v4i32: ANDIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
1360 [(set (v4i32 VECREG:$rT),
1361 (and (v4i32 VECREG:$rA), v4i32SExt10Imm:$val))]>;
1362
1363 def r32: ANDIInst<(outs R32C:$rT), (ins R32C:$rA, s10imm_i32:$val),
1364 [(set R32C:$rT, (and R32C:$rA, i32ImmSExt10:$val))]>;
1365
1366 // Hacked form of ANDI to zero-extend i8 quantities to i32. See the zext 8->32
1367 // pattern below.
1368 def i8i32: ANDIInst<(outs R32C:$rT), (ins R8C:$rA, s10imm_i32:$val),
1369 [(set R32C:$rT,
1370 (and (zext R8C:$rA), i32ImmSExt10:$val))]>;
1371
1372 // Hacked form of ANDI to zero-extend i16 quantities to i32. See the
1373 // zext 16->32 pattern below.
1374 //
1375 // Note that this pattern is somewhat artificial, since it might match
1376 // something the compiler generates but is unlikely to occur in practice.
1377 def i16i32: ANDIInst<(outs R32C:$rT), (ins R16C:$rA, s10imm_i32:$val),
1378 [(set R32C:$rT,
1379 (and (zext R16C:$rA), i32ImmSExt10:$val))]>;
1380}
1381
1382defm ANDI : AndWordImm;
1383
1384//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
Scott Michel8b6b4202007-12-04 22:35:58 +00001385// Bitwise OR group:
Scott Michel97872d32008-02-23 18:41:37 +00001386//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
1387
Scott Michel8b6b4202007-12-04 22:35:58 +00001388// Bitwise "or" (N.B.: These are also register-register copy instructions...)
Scott Michel97872d32008-02-23 18:41:37 +00001389class ORInst<dag OOL, dag IOL, list<dag> pattern>:
1390 RRForm<0b10000010000, OOL, IOL, "or\t$rT, $rA, $rB",
1391 IntegerOp, pattern>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001392
Scott Michel97872d32008-02-23 18:41:37 +00001393class ORVecInst<ValueType vectype>:
1394 ORInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1395 [(set (vectype VECREG:$rT), (or (vectype VECREG:$rA),
1396 (vectype VECREG:$rB)))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001397
Scott Michel97872d32008-02-23 18:41:37 +00001398class ORRegInst<RegisterClass rclass>:
1399 ORInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB),
1400 [(set rclass:$rT, (or rclass:$rA, rclass:$rB))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001401
Scott Michel06eabde2008-12-27 04:51:36 +00001402// ORCvtForm: OR conversion form
1403//
1404// This is used to "convert" the preferred slot to its vector equivalent, as
1405// well as convert a vector back to its preferred slot.
1406//
1407// These are effectively no-ops, but need to exist for proper type conversion
1408// and type coercion.
1409
Scott Michel8c67fa42009-01-21 04:58:48 +00001410class ORCvtForm<dag OOL, dag IOL, list<dag> pattern = [/* no pattern */]>
Scott Michel06eabde2008-12-27 04:51:36 +00001411 : SPUInstr<OOL, IOL, "or\t$rT, $rA, $rA", IntegerOp> {
1412 bits<7> RA;
1413 bits<7> RT;
1414
Scott Michel8c67fa42009-01-21 04:58:48 +00001415 let Pattern = pattern;
Scott Michel06eabde2008-12-27 04:51:36 +00001416
1417 let Inst{0-10} = 0b10000010000;
1418 let Inst{11-17} = RA;
1419 let Inst{18-24} = RA;
1420 let Inst{25-31} = RT;
1421}
1422
Scott Michel97872d32008-02-23 18:41:37 +00001423class ORPromoteScalar<RegisterClass rclass>:
Scott Michel06eabde2008-12-27 04:51:36 +00001424 ORCvtForm<(outs VECREG:$rT), (ins rclass:$rA)>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001425
Scott Michel97872d32008-02-23 18:41:37 +00001426class ORExtractElt<RegisterClass rclass>:
Scott Michel06eabde2008-12-27 04:51:36 +00001427 ORCvtForm<(outs rclass:$rT), (ins VECREG:$rA)>;
1428
Scott Michel8c67fa42009-01-21 04:58:48 +00001429/* class ORCvtRegGPRC<RegisterClass rclass>:
1430 ORCvtForm<(outs GPRC:$rT), (ins rclass:$rA)>; */
Scott Michel06eabde2008-12-27 04:51:36 +00001431
Scott Michel8c67fa42009-01-21 04:58:48 +00001432/* class ORCvtGPRCReg<RegisterClass rclass>:
1433 ORCvtForm<(outs rclass:$rT), (ins GPRC:$rA)>; */
Scott Michel2ef773a2009-01-06 03:36:14 +00001434
Scott Michel8c67fa42009-01-21 04:58:48 +00001435class ORCvtFormR32Reg<RegisterClass rclass, list<dag> pattern = [ ]>:
1436 ORCvtForm<(outs rclass:$rT), (ins R32C:$rA), pattern>;
Scott Michel2ef773a2009-01-06 03:36:14 +00001437
Scott Michel8c67fa42009-01-21 04:58:48 +00001438class ORCvtFormRegR32<RegisterClass rclass, list<dag> pattern = [ ]>:
1439 ORCvtForm<(outs R32C:$rT), (ins rclass:$rA), pattern>;
Scott Michel2ef773a2009-01-06 03:36:14 +00001440
Scott Michel8c67fa42009-01-21 04:58:48 +00001441class ORCvtFormR64Reg<RegisterClass rclass, list<dag> pattern = [ ]>:
1442 ORCvtForm<(outs rclass:$rT), (ins R64C:$rA), pattern>;
Scott Michel2ef773a2009-01-06 03:36:14 +00001443
Scott Michel8c67fa42009-01-21 04:58:48 +00001444class ORCvtFormRegR64<RegisterClass rclass, list<dag> pattern = [ ]>:
1445 ORCvtForm<(outs R64C:$rT), (ins rclass:$rA), pattern>;
Scott Michel06eabde2008-12-27 04:51:36 +00001446
Scott Michel34712c32009-03-16 18:47:25 +00001447class ORCvtGPRCVec:
1448 ORCvtForm<(outs VECREG:$rT), (ins GPRC:$rA)>;
1449
1450class ORCvtVecGPRC:
1451 ORCvtForm<(outs GPRC:$rT), (ins VECREG:$rA)>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001452
Scott Michel97872d32008-02-23 18:41:37 +00001453multiclass BitwiseOr
1454{
1455 def v16i8: ORVecInst<v16i8>;
1456 def v8i16: ORVecInst<v8i16>;
1457 def v4i32: ORVecInst<v4i32>;
1458 def v2i64: ORVecInst<v2i64>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001459
Scott Michel97872d32008-02-23 18:41:37 +00001460 def v4f32: ORInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1461 [(set (v4f32 VECREG:$rT),
1462 (v4f32 (bitconvert (or (v4i32 VECREG:$rA),
1463 (v4i32 VECREG:$rB)))))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001464
Scott Michel97872d32008-02-23 18:41:37 +00001465 def v2f64: ORInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
Scott Michel06eabde2008-12-27 04:51:36 +00001466 [(set (v2f64 VECREG:$rT),
Scott Michel97872d32008-02-23 18:41:37 +00001467 (v2f64 (bitconvert (or (v2i64 VECREG:$rA),
1468 (v2i64 VECREG:$rB)))))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001469
Scott Michel8c67fa42009-01-21 04:58:48 +00001470 def r128: ORRegInst<GPRC>;
1471 def r64: ORRegInst<R64C>;
1472 def r32: ORRegInst<R32C>;
1473 def r16: ORRegInst<R16C>;
1474 def r8: ORRegInst<R8C>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001475
Scott Michel97872d32008-02-23 18:41:37 +00001476 // OR instructions used to copy f32 and f64 registers.
1477 def f32: ORInst<(outs R32FP:$rT), (ins R32FP:$rA, R32FP:$rB),
1478 [/* no pattern */]>;
Scott Michel438be252007-12-17 22:32:34 +00001479
Scott Michel97872d32008-02-23 18:41:37 +00001480 def f64: ORInst<(outs R64FP:$rT), (ins R64FP:$rA, R64FP:$rB),
1481 [/* no pattern */]>;
Scott Michel754d8662007-12-20 00:44:13 +00001482
Scott Michel4d07fb72008-12-30 23:28:25 +00001483 // scalar->vector promotion, prefslot2vec:
Scott Michel97872d32008-02-23 18:41:37 +00001484 def v16i8_i8: ORPromoteScalar<R8C>;
1485 def v8i16_i16: ORPromoteScalar<R16C>;
1486 def v4i32_i32: ORPromoteScalar<R32C>;
1487 def v2i64_i64: ORPromoteScalar<R64C>;
1488 def v4f32_f32: ORPromoteScalar<R32FP>;
1489 def v2f64_f64: ORPromoteScalar<R64FP>;
Scott Michel754d8662007-12-20 00:44:13 +00001490
Scott Michel4d07fb72008-12-30 23:28:25 +00001491 // vector->scalar demotion, vec2prefslot:
Scott Michel97872d32008-02-23 18:41:37 +00001492 def i8_v16i8: ORExtractElt<R8C>;
1493 def i16_v8i16: ORExtractElt<R16C>;
1494 def i32_v4i32: ORExtractElt<R32C>;
1495 def i64_v2i64: ORExtractElt<R64C>;
1496 def f32_v4f32: ORExtractElt<R32FP>;
1497 def f64_v2f64: ORExtractElt<R64FP>;
Scott Michel06eabde2008-12-27 04:51:36 +00001498
Scott Michel34712c32009-03-16 18:47:25 +00001499 // Conversion from vector to GPRC
1500 def i128_vec: ORCvtVecGPRC;
1501
1502 // Conversion from GPRC to vector
1503 def vec_i128: ORCvtGPRCVec;
1504
Scott Michel8c67fa42009-01-21 04:58:48 +00001505/*
Scott Michel34712c32009-03-16 18:47:25 +00001506 // Conversion from register to GPRC
Scott Michel06eabde2008-12-27 04:51:36 +00001507 def i128_r64: ORCvtRegGPRC<R64C>;
1508 def i128_f64: ORCvtRegGPRC<R64FP>;
1509 def i128_r32: ORCvtRegGPRC<R32C>;
1510 def i128_f32: ORCvtRegGPRC<R32FP>;
1511 def i128_r16: ORCvtRegGPRC<R16C>;
1512 def i128_r8: ORCvtRegGPRC<R8C>;
1513
Scott Michel34712c32009-03-16 18:47:25 +00001514 // Conversion from GPRC to register
Scott Michel06eabde2008-12-27 04:51:36 +00001515 def r64_i128: ORCvtGPRCReg<R64C>;
1516 def f64_i128: ORCvtGPRCReg<R64FP>;
1517 def r32_i128: ORCvtGPRCReg<R32C>;
1518 def f32_i128: ORCvtGPRCReg<R32FP>;
1519 def r16_i128: ORCvtGPRCReg<R16C>;
1520 def r8_i128: ORCvtGPRCReg<R8C>;
Scott Michel8c67fa42009-01-21 04:58:48 +00001521*/
1522/*
Scott Michel2ef773a2009-01-06 03:36:14 +00001523 // Conversion from register to R32C:
Scott Michel34712c32009-03-16 18:47:25 +00001524 def r32_r16: ORCvtFormRegR32<R16C>;
1525 def r32_r8: ORCvtFormRegR32<R8C>;
Scott Michel2ef773a2009-01-06 03:36:14 +00001526
1527 // Conversion from R32C to register
1528 def r32_r16: ORCvtFormR32Reg<R16C>;
1529 def r32_r8: ORCvtFormR32Reg<R8C>;
Scott Michel8c67fa42009-01-21 04:58:48 +00001530*/
pingbak2f387e82009-01-26 03:31:40 +00001531
Scott Michel34712c32009-03-16 18:47:25 +00001532 // Conversion from R64C to register:
pingbak2f387e82009-01-26 03:31:40 +00001533 def r32_r64: ORCvtFormR64Reg<R32C>;
1534 // def r16_r64: ORCvtFormR64Reg<R16C>;
1535 // def r8_r64: ORCvtFormR64Reg<R8C>;
1536
Scott Michel34712c32009-03-16 18:47:25 +00001537 // Conversion to R64C from register:
pingbak2f387e82009-01-26 03:31:40 +00001538 def r64_r32: ORCvtFormRegR64<R32C>;
1539 // def r64_r16: ORCvtFormRegR64<R16C>;
1540 // def r64_r8: ORCvtFormRegR64<R8C>;
Scott Michel8c67fa42009-01-21 04:58:48 +00001541
1542 // bitconvert patterns:
1543 def r32_f32: ORCvtFormR32Reg<R32FP,
1544 [(set R32FP:$rT, (bitconvert R32C:$rA))]>;
1545 def f32_r32: ORCvtFormRegR32<R32FP,
1546 [(set R32C:$rT, (bitconvert R32FP:$rA))]>;
1547
1548 def r64_f64: ORCvtFormR64Reg<R64FP,
1549 [(set R64FP:$rT, (bitconvert R64C:$rA))]>;
1550 def f64_r64: ORCvtFormRegR64<R64FP,
1551 [(set R64C:$rT, (bitconvert R64FP:$rA))]>;
Scott Michel97872d32008-02-23 18:41:37 +00001552}
Scott Michel438be252007-12-17 22:32:34 +00001553
Scott Michel97872d32008-02-23 18:41:37 +00001554defm OR : BitwiseOr;
1555
Scott Michel06eabde2008-12-27 04:51:36 +00001556// scalar->vector promotion patterns (preferred slot to vector):
1557def : Pat<(v16i8 (SPUprefslot2vec R8C:$rA)),
1558 (ORv16i8_i8 R8C:$rA)>;
Scott Michel438be252007-12-17 22:32:34 +00001559
Scott Michel06eabde2008-12-27 04:51:36 +00001560def : Pat<(v8i16 (SPUprefslot2vec R16C:$rA)),
1561 (ORv8i16_i16 R16C:$rA)>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001562
Scott Michel06eabde2008-12-27 04:51:36 +00001563def : Pat<(v4i32 (SPUprefslot2vec R32C:$rA)),
1564 (ORv4i32_i32 R32C:$rA)>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001565
Scott Michel06eabde2008-12-27 04:51:36 +00001566def : Pat<(v2i64 (SPUprefslot2vec R64C:$rA)),
1567 (ORv2i64_i64 R64C:$rA)>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001568
Scott Michel06eabde2008-12-27 04:51:36 +00001569def : Pat<(v4f32 (SPUprefslot2vec R32FP:$rA)),
1570 (ORv4f32_f32 R32FP:$rA)>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001571
Scott Michel06eabde2008-12-27 04:51:36 +00001572def : Pat<(v2f64 (SPUprefslot2vec R64FP:$rA)),
1573 (ORv2f64_f64 R64FP:$rA)>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001574
Scott Michel06eabde2008-12-27 04:51:36 +00001575// ORi*_v*: Used to extract vector element 0 (the preferred slot), otherwise
1576// known as converting the vector back to its preferred slot
Scott Michel438be252007-12-17 22:32:34 +00001577
Scott Michelc630c412008-11-24 17:11:17 +00001578def : Pat<(SPUvec2prefslot (v16i8 VECREG:$rA)),
Scott Michel06eabde2008-12-27 04:51:36 +00001579 (ORi8_v16i8 VECREG:$rA)>;
Scott Michel438be252007-12-17 22:32:34 +00001580
Scott Michelc630c412008-11-24 17:11:17 +00001581def : Pat<(SPUvec2prefslot (v8i16 VECREG:$rA)),
Scott Michel06eabde2008-12-27 04:51:36 +00001582 (ORi16_v8i16 VECREG:$rA)>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001583
Scott Michelc630c412008-11-24 17:11:17 +00001584def : Pat<(SPUvec2prefslot (v4i32 VECREG:$rA)),
Scott Michel06eabde2008-12-27 04:51:36 +00001585 (ORi32_v4i32 VECREG:$rA)>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001586
Scott Michelc630c412008-11-24 17:11:17 +00001587def : Pat<(SPUvec2prefslot (v2i64 VECREG:$rA)),
Scott Michel06eabde2008-12-27 04:51:36 +00001588 (ORi64_v2i64 VECREG:$rA)>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001589
Scott Michelc630c412008-11-24 17:11:17 +00001590def : Pat<(SPUvec2prefslot (v4f32 VECREG:$rA)),
Scott Michel06eabde2008-12-27 04:51:36 +00001591 (ORf32_v4f32 VECREG:$rA)>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001592
Scott Michelc630c412008-11-24 17:11:17 +00001593def : Pat<(SPUvec2prefslot (v2f64 VECREG:$rA)),
Scott Michel06eabde2008-12-27 04:51:36 +00001594 (ORf64_v2f64 VECREG:$rA)>;
1595
1596// Load Register: This is an assembler alias for a bitwise OR of a register
1597// against itself. It's here because it brings some clarity to assembly
1598// language output.
1599
1600let hasCtrlDep = 1 in {
1601 class LRInst<dag OOL, dag IOL>
1602 : SPUInstr<OOL, IOL, "lr\t$rT, $rA", IntegerOp> {
1603 bits<7> RA;
1604 bits<7> RT;
1605
1606 let Pattern = [/*no pattern*/];
1607
1608 let Inst{0-10} = 0b10000010000; /* It's an OR operation */
1609 let Inst{11-17} = RA;
1610 let Inst{18-24} = RA;
1611 let Inst{25-31} = RT;
1612 }
1613
1614 class LRVecInst<ValueType vectype>:
1615 LRInst<(outs VECREG:$rT), (ins VECREG:$rA)>;
1616
1617 class LRRegInst<RegisterClass rclass>:
1618 LRInst<(outs rclass:$rT), (ins rclass:$rA)>;
1619
1620 multiclass LoadRegister {
1621 def v2i64: LRVecInst<v2i64>;
1622 def v2f64: LRVecInst<v2f64>;
1623 def v4i32: LRVecInst<v4i32>;
1624 def v4f32: LRVecInst<v4f32>;
1625 def v8i16: LRVecInst<v8i16>;
1626 def v16i8: LRVecInst<v16i8>;
1627
1628 def r128: LRRegInst<GPRC>;
1629 def r64: LRRegInst<R64C>;
1630 def f64: LRRegInst<R64FP>;
1631 def r32: LRRegInst<R32C>;
1632 def f32: LRRegInst<R32FP>;
1633 def r16: LRRegInst<R16C>;
1634 def r8: LRRegInst<R8C>;
1635 }
1636
1637 defm LR: LoadRegister;
1638}
Scott Michel8b6b4202007-12-04 22:35:58 +00001639
Scott Michel97872d32008-02-23 18:41:37 +00001640// ORC: Bitwise "or" with complement (c = a | ~b)
Scott Michel8b6b4202007-12-04 22:35:58 +00001641
Scott Michel97872d32008-02-23 18:41:37 +00001642class ORCInst<dag OOL, dag IOL, list<dag> pattern>:
1643 RRForm<0b10010010000, OOL, IOL, "orc\t$rT, $rA, $rB",
1644 IntegerOp, pattern>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001645
Scott Michel97872d32008-02-23 18:41:37 +00001646class ORCVecInst<ValueType vectype>:
1647 ORCInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1648 [(set (vectype VECREG:$rT), (or (vectype VECREG:$rA),
1649 (vnot (vectype VECREG:$rB))))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001650
Scott Michel97872d32008-02-23 18:41:37 +00001651class ORCRegInst<RegisterClass rclass>:
1652 ORCInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB),
1653 [(set rclass:$rT, (or rclass:$rA, (not rclass:$rB)))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001654
Scott Michel97872d32008-02-23 18:41:37 +00001655multiclass BitwiseOrComplement
1656{
1657 def v16i8: ORCVecInst<v16i8>;
1658 def v8i16: ORCVecInst<v8i16>;
1659 def v4i32: ORCVecInst<v4i32>;
1660 def v2i64: ORCVecInst<v2i64>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001661
Scott Michel34712c32009-03-16 18:47:25 +00001662 def r128: ORCRegInst<GPRC>;
Scott Michel97872d32008-02-23 18:41:37 +00001663 def r64: ORCRegInst<R64C>;
1664 def r32: ORCRegInst<R32C>;
1665 def r16: ORCRegInst<R16C>;
1666 def r8: ORCRegInst<R8C>;
1667}
1668
1669defm ORC : BitwiseOrComplement;
Scott Michel438be252007-12-17 22:32:34 +00001670
Scott Michel8b6b4202007-12-04 22:35:58 +00001671// OR byte immediate
Scott Michel97872d32008-02-23 18:41:37 +00001672class ORBIInst<dag OOL, dag IOL, list<dag> pattern>:
1673 RI10Form<0b01100000, OOL, IOL, "orbi\t$rT, $rA, $val",
1674 IntegerOp, pattern>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001675
Scott Michel97872d32008-02-23 18:41:37 +00001676class ORBIVecInst<ValueType vectype, PatLeaf immpred>:
1677 ORBIInst<(outs VECREG:$rT), (ins VECREG:$rA, u10imm:$val),
1678 [(set (v16i8 VECREG:$rT), (or (vectype VECREG:$rA),
1679 (vectype immpred:$val)))]>;
1680
1681multiclass BitwiseOrByteImm
1682{
1683 def v16i8: ORBIVecInst<v16i8, v16i8U8Imm>;
1684
1685 def r8: ORBIInst<(outs R8C:$rT), (ins R8C:$rA, u10imm_i8:$val),
1686 [(set R8C:$rT, (or R8C:$rA, immU8:$val))]>;
1687}
1688
1689defm ORBI : BitwiseOrByteImm;
Scott Michel438be252007-12-17 22:32:34 +00001690
Scott Michel8b6b4202007-12-04 22:35:58 +00001691// OR halfword immediate
Scott Michel97872d32008-02-23 18:41:37 +00001692class ORHIInst<dag OOL, dag IOL, list<dag> pattern>:
1693 RI10Form<0b10100000, OOL, IOL, "orhi\t$rT, $rA, $val",
1694 IntegerOp, pattern>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001695
Scott Michel97872d32008-02-23 18:41:37 +00001696class ORHIVecInst<ValueType vectype, PatLeaf immpred>:
1697 ORHIInst<(outs VECREG:$rT), (ins VECREG:$rA, u10imm:$val),
1698 [(set (vectype VECREG:$rT), (or (vectype VECREG:$rA),
1699 immpred:$val))]>;
Scott Michel438be252007-12-17 22:32:34 +00001700
Scott Michel97872d32008-02-23 18:41:37 +00001701multiclass BitwiseOrHalfwordImm
1702{
1703 def v8i16: ORHIVecInst<v8i16, v8i16Uns10Imm>;
1704
1705 def r16: ORHIInst<(outs R16C:$rT), (ins R16C:$rA, u10imm:$val),
1706 [(set R16C:$rT, (or R16C:$rA, i16ImmUns10:$val))]>;
1707
1708 // Specialized ORHI form used to promote 8-bit registers to 16-bit
1709 def i8i16: ORHIInst<(outs R16C:$rT), (ins R8C:$rA, s10imm:$val),
1710 [(set R16C:$rT, (or (anyext R8C:$rA),
1711 i16ImmSExt10:$val))]>;
1712}
1713
1714defm ORHI : BitwiseOrHalfwordImm;
1715
1716class ORIInst<dag OOL, dag IOL, list<dag> pattern>:
1717 RI10Form<0b00100000, OOL, IOL, "ori\t$rT, $rA, $val",
1718 IntegerOp, pattern>;
1719
1720class ORIVecInst<ValueType vectype, PatLeaf immpred>:
1721 ORIInst<(outs VECREG:$rT), (ins VECREG:$rA, u10imm:$val),
1722 [(set (vectype VECREG:$rT), (or (vectype VECREG:$rA),
1723 immpred:$val))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001724
1725// Bitwise "or" with immediate
Scott Michel97872d32008-02-23 18:41:37 +00001726multiclass BitwiseOrImm
1727{
1728 def v4i32: ORIVecInst<v4i32, v4i32Uns10Imm>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001729
Scott Michel97872d32008-02-23 18:41:37 +00001730 def r32: ORIInst<(outs R32C:$rT), (ins R32C:$rA, u10imm_i32:$val),
1731 [(set R32C:$rT, (or R32C:$rA, i32ImmUns10:$val))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001732
Scott Michel97872d32008-02-23 18:41:37 +00001733 // i16i32: hacked version of the ori instruction to extend 16-bit quantities
1734 // to 32-bit quantities. used exclusively to match "anyext" conversions (vide
1735 // infra "anyext 16->32" pattern.)
1736 def i16i32: ORIInst<(outs R32C:$rT), (ins R16C:$rA, s10imm_i32:$val),
1737 [(set R32C:$rT, (or (anyext R16C:$rA),
1738 i32ImmSExt10:$val))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001739
Scott Michel97872d32008-02-23 18:41:37 +00001740 // i8i32: Hacked version of the ORI instruction to extend 16-bit quantities
1741 // to 32-bit quantities. Used exclusively to match "anyext" conversions (vide
1742 // infra "anyext 16->32" pattern.)
1743 def i8i32: ORIInst<(outs R32C:$rT), (ins R8C:$rA, s10imm_i32:$val),
1744 [(set R32C:$rT, (or (anyext R8C:$rA),
1745 i32ImmSExt10:$val))]>;
1746}
Scott Michel8b6b4202007-12-04 22:35:58 +00001747
Scott Michel97872d32008-02-23 18:41:37 +00001748defm ORI : BitwiseOrImm;
Scott Michel438be252007-12-17 22:32:34 +00001749
Scott Michel8b6b4202007-12-04 22:35:58 +00001750// ORX: "or" across the vector: or's $rA's word slots leaving the result in
1751// $rT[0], slots 1-3 are zeroed.
1752//
Scott Michel438be252007-12-17 22:32:34 +00001753// FIXME: Needs to match an intrinsic pattern.
Scott Michel8b6b4202007-12-04 22:35:58 +00001754def ORXv4i32:
1755 RRForm<0b10010010000, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1756 "orx\t$rT, $rA, $rB", IntegerOp,
1757 []>;
1758
Scott Michel438be252007-12-17 22:32:34 +00001759// XOR:
Scott Michel8b6b4202007-12-04 22:35:58 +00001760
Scott Michel6baba072008-03-05 23:02:02 +00001761class XORInst<dag OOL, dag IOL, list<dag> pattern> :
1762 RRForm<0b10010010000, OOL, IOL, "xor\t$rT, $rA, $rB",
1763 IntegerOp, pattern>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001764
Scott Michel6baba072008-03-05 23:02:02 +00001765class XORVecInst<ValueType vectype>:
1766 XORInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1767 [(set (vectype VECREG:$rT), (xor (vectype VECREG:$rA),
1768 (vectype VECREG:$rB)))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001769
Scott Michel6baba072008-03-05 23:02:02 +00001770class XORRegInst<RegisterClass rclass>:
1771 XORInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB),
1772 [(set rclass:$rT, (xor rclass:$rA, rclass:$rB))]>;
1773
1774multiclass BitwiseExclusiveOr
1775{
1776 def v16i8: XORVecInst<v16i8>;
1777 def v8i16: XORVecInst<v8i16>;
1778 def v4i32: XORVecInst<v4i32>;
1779 def v2i64: XORVecInst<v2i64>;
1780
1781 def r128: XORRegInst<GPRC>;
1782 def r64: XORRegInst<R64C>;
1783 def r32: XORRegInst<R32C>;
1784 def r16: XORRegInst<R16C>;
1785 def r8: XORRegInst<R8C>;
1786
1787 // Special forms for floating point instructions.
1788 // fneg and fabs require bitwise logical ops to manipulate the sign bit.
1789
1790 def fneg32: XORInst<(outs R32FP:$rT), (ins R32FP:$rA, R32C:$rB),
1791 [/* no pattern */]>;
1792
1793 def fneg64: XORInst<(outs R64FP:$rT), (ins R64FP:$rA, VECREG:$rB),
1794 [/* no pattern */]>;
1795
1796 def fnegvec: XORInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1797 [/* no pattern, see fneg{32,64} */]>;
1798}
1799
1800defm XOR : BitwiseExclusiveOr;
Scott Michel8b6b4202007-12-04 22:35:58 +00001801
1802//==----------------------------------------------------------
Scott Michel438be252007-12-17 22:32:34 +00001803
Scott Michel97872d32008-02-23 18:41:37 +00001804class XORBIInst<dag OOL, dag IOL, list<dag> pattern>:
1805 RI10Form<0b01100000, OOL, IOL, "xorbi\t$rT, $rA, $val",
1806 IntegerOp, pattern>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001807
Scott Michel97872d32008-02-23 18:41:37 +00001808multiclass XorByteImm
1809{
1810 def v16i8:
1811 XORBIInst<(outs VECREG:$rT), (ins VECREG:$rA, u10imm:$val),
1812 [(set (v16i8 VECREG:$rT), (xor (v16i8 VECREG:$rA), v16i8U8Imm:$val))]>;
1813
1814 def r8:
1815 XORBIInst<(outs R8C:$rT), (ins R8C:$rA, u10imm_i8:$val),
1816 [(set R8C:$rT, (xor R8C:$rA, immU8:$val))]>;
1817}
1818
1819defm XORBI : XorByteImm;
Scott Michel438be252007-12-17 22:32:34 +00001820
Scott Michel8b6b4202007-12-04 22:35:58 +00001821def XORHIv8i16:
Scott Michel97872d32008-02-23 18:41:37 +00001822 RI10Form<0b10100000, (outs VECREG:$rT), (ins VECREG:$rA, u10imm:$val),
Scott Michel8b6b4202007-12-04 22:35:58 +00001823 "xorhi\t$rT, $rA, $val", IntegerOp,
1824 [(set (v8i16 VECREG:$rT), (xor (v8i16 VECREG:$rA),
1825 v8i16SExt10Imm:$val))]>;
1826
1827def XORHIr16:
1828 RI10Form<0b10100000, (outs R16C:$rT), (ins R16C:$rA, s10imm:$val),
1829 "xorhi\t$rT, $rA, $val", IntegerOp,
1830 [(set R16C:$rT, (xor R16C:$rA, i16ImmSExt10:$val))]>;
1831
1832def XORIv4i32:
Scott Michel53ab7792008-03-10 16:58:52 +00001833 RI10Form<0b00100000, (outs VECREG:$rT), (ins VECREG:$rA, s10imm_i32:$val),
Scott Michel8b6b4202007-12-04 22:35:58 +00001834 "xori\t$rT, $rA, $val", IntegerOp,
1835 [(set (v4i32 VECREG:$rT), (xor (v4i32 VECREG:$rA),
1836 v4i32SExt10Imm:$val))]>;
1837
1838def XORIr32:
1839 RI10Form<0b00100000, (outs R32C:$rT), (ins R32C:$rA, s10imm_i32:$val),
1840 "xori\t$rT, $rA, $val", IntegerOp,
1841 [(set R32C:$rT, (xor R32C:$rA, i32ImmSExt10:$val))]>;
1842
1843// NAND:
Scott Michel8b6b4202007-12-04 22:35:58 +00001844
Scott Michel34712c32009-03-16 18:47:25 +00001845class NANDInst<dag OOL, dag IOL, list<dag> pattern>:
1846 RRForm<0b10010011000, OOL, IOL, "nand\t$rT, $rA, $rB",
1847 IntegerOp, pattern>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001848
Scott Michel34712c32009-03-16 18:47:25 +00001849class NANDVecInst<ValueType vectype>:
1850 NANDInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1851 [(set (vectype VECREG:$rT), (vnot (and (vectype VECREG:$rA),
1852 (vectype VECREG:$rB))))]>;
1853class NANDRegInst<RegisterClass rclass>:
1854 NANDInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB),
1855 [(set rclass:$rT, (not (and rclass:$rA, rclass:$rB)))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001856
Scott Michel34712c32009-03-16 18:47:25 +00001857multiclass BitwiseNand
1858{
1859 def v16i8: NANDVecInst<v16i8>;
1860 def v8i16: NANDVecInst<v8i16>;
1861 def v4i32: NANDVecInst<v4i32>;
1862 def v2i64: NANDVecInst<v2i64>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001863
Scott Michel34712c32009-03-16 18:47:25 +00001864 def r128: NANDRegInst<GPRC>;
1865 def r64: NANDRegInst<R64C>;
1866 def r32: NANDRegInst<R32C>;
1867 def r16: NANDRegInst<R16C>;
1868 def r8: NANDRegInst<R8C>;
1869}
Scott Michel8b6b4202007-12-04 22:35:58 +00001870
Scott Michel34712c32009-03-16 18:47:25 +00001871defm NAND : BitwiseNand;
Scott Michel438be252007-12-17 22:32:34 +00001872
Scott Michel8b6b4202007-12-04 22:35:58 +00001873// NOR:
Scott Michel8b6b4202007-12-04 22:35:58 +00001874
Scott Michel34712c32009-03-16 18:47:25 +00001875class NORInst<dag OOL, dag IOL, list<dag> pattern>:
1876 RRForm<0b10010010000, OOL, IOL, "nor\t$rT, $rA, $rB",
1877 IntegerOp, pattern>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001878
Scott Michel34712c32009-03-16 18:47:25 +00001879class NORVecInst<ValueType vectype>:
1880 NORInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1881 [(set (vectype VECREG:$rT), (vnot (or (vectype VECREG:$rA),
1882 (vectype VECREG:$rB))))]>;
1883class NORRegInst<RegisterClass rclass>:
1884 NORInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB),
1885 [(set rclass:$rT, (not (or rclass:$rA, rclass:$rB)))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001886
Scott Michel34712c32009-03-16 18:47:25 +00001887multiclass BitwiseNor
1888{
1889 def v16i8: NORVecInst<v16i8>;
1890 def v8i16: NORVecInst<v8i16>;
1891 def v4i32: NORVecInst<v4i32>;
1892 def v2i64: NORVecInst<v2i64>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001893
Scott Michel34712c32009-03-16 18:47:25 +00001894 def r128: NORRegInst<GPRC>;
1895 def r64: NORRegInst<R64C>;
1896 def r32: NORRegInst<R32C>;
1897 def r16: NORRegInst<R16C>;
1898 def r8: NORRegInst<R8C>;
1899}
Scott Michel8b6b4202007-12-04 22:35:58 +00001900
Scott Michel34712c32009-03-16 18:47:25 +00001901defm NOR : BitwiseNor;
Scott Michel438be252007-12-17 22:32:34 +00001902
Scott Michel8b6b4202007-12-04 22:35:58 +00001903// Select bits:
Scott Michel6baba072008-03-05 23:02:02 +00001904class SELBInst<dag OOL, dag IOL, list<dag> pattern>:
1905 RRRForm<0b1000, OOL, IOL, "selb\t$rT, $rA, $rB, $rC",
1906 IntegerOp, pattern>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001907
pingbak2f387e82009-01-26 03:31:40 +00001908class SELBVecInst<ValueType vectype, PatFrag vnot_frag = vnot>:
Scott Michel6baba072008-03-05 23:02:02 +00001909 SELBInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB, VECREG:$rC),
1910 [(set (vectype VECREG:$rT),
1911 (or (and (vectype VECREG:$rC), (vectype VECREG:$rB)),
pingbak2f387e82009-01-26 03:31:40 +00001912 (and (vnot_frag (vectype VECREG:$rC)),
Scott Michel6baba072008-03-05 23:02:02 +00001913 (vectype VECREG:$rA))))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001914
Scott Michel4d07fb72008-12-30 23:28:25 +00001915class SELBVecVCondInst<ValueType vectype>:
1916 SELBInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB, VECREG:$rC),
1917 [(set (vectype VECREG:$rT),
1918 (select (vectype VECREG:$rC),
1919 (vectype VECREG:$rB),
1920 (vectype VECREG:$rA)))]>;
1921
Scott Michel06eabde2008-12-27 04:51:36 +00001922class SELBVecCondInst<ValueType vectype>:
1923 SELBInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB, R32C:$rC),
1924 [(set (vectype VECREG:$rT),
1925 (select R32C:$rC,
1926 (vectype VECREG:$rB),
1927 (vectype VECREG:$rA)))]>;
1928
Scott Michel6baba072008-03-05 23:02:02 +00001929class SELBRegInst<RegisterClass rclass>:
1930 SELBInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB, rclass:$rC),
1931 [(set rclass:$rT,
Scott Michelae5cbf52008-12-29 03:23:36 +00001932 (or (and rclass:$rB, rclass:$rC),
1933 (and rclass:$rA, (not rclass:$rC))))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001934
Scott Michel06eabde2008-12-27 04:51:36 +00001935class SELBRegCondInst<RegisterClass rcond, RegisterClass rclass>:
1936 SELBInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB, rcond:$rC),
1937 [(set rclass:$rT,
1938 (select rcond:$rC, rclass:$rB, rclass:$rA))]>;
1939
Scott Michel6baba072008-03-05 23:02:02 +00001940multiclass SelectBits
1941{
1942 def v16i8: SELBVecInst<v16i8>;
1943 def v8i16: SELBVecInst<v8i16>;
1944 def v4i32: SELBVecInst<v4i32>;
pingbak2f387e82009-01-26 03:31:40 +00001945 def v2i64: SELBVecInst<v2i64, vnot_conv>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001946
Scott Michel6baba072008-03-05 23:02:02 +00001947 def r128: SELBRegInst<GPRC>;
1948 def r64: SELBRegInst<R64C>;
1949 def r32: SELBRegInst<R32C>;
1950 def r16: SELBRegInst<R16C>;
1951 def r8: SELBRegInst<R8C>;
Scott Michel06eabde2008-12-27 04:51:36 +00001952
1953 def v16i8_cond: SELBVecCondInst<v16i8>;
1954 def v8i16_cond: SELBVecCondInst<v8i16>;
1955 def v4i32_cond: SELBVecCondInst<v4i32>;
1956 def v2i64_cond: SELBVecCondInst<v2i64>;
1957
Scott Michel4d07fb72008-12-30 23:28:25 +00001958 def v16i8_vcond: SELBVecCondInst<v16i8>;
1959 def v8i16_vcond: SELBVecCondInst<v8i16>;
1960 def v4i32_vcond: SELBVecCondInst<v4i32>;
1961 def v2i64_vcond: SELBVecCondInst<v2i64>;
1962
1963 def v4f32_cond:
pingbakb8913342009-01-26 03:37:41 +00001964 SELBInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB, VECREG:$rC),
1965 [(set (v4f32 VECREG:$rT),
1966 (select (v4i32 VECREG:$rC),
1967 (v4f32 VECREG:$rB),
1968 (v4f32 VECREG:$rA)))]>;
Scott Michel4d07fb72008-12-30 23:28:25 +00001969
Scott Michel8c67fa42009-01-21 04:58:48 +00001970 // SELBr64_cond is defined in SPU64InstrInfo.td
Scott Michel06eabde2008-12-27 04:51:36 +00001971 def r32_cond: SELBRegCondInst<R32C, R32C>;
Scott Michel4d07fb72008-12-30 23:28:25 +00001972 def f32_cond: SELBRegCondInst<R32C, R32FP>;
Scott Michel06eabde2008-12-27 04:51:36 +00001973 def r16_cond: SELBRegCondInst<R16C, R16C>;
1974 def r8_cond: SELBRegCondInst<R8C, R8C>;
Scott Michel6baba072008-03-05 23:02:02 +00001975}
Scott Michel8b6b4202007-12-04 22:35:58 +00001976
Scott Michel6baba072008-03-05 23:02:02 +00001977defm SELB : SelectBits;
Scott Michel8b6b4202007-12-04 22:35:58 +00001978
Scott Michel56a125e2008-11-22 23:50:42 +00001979class SPUselbPatVec<ValueType vectype, SPUInstr inst>:
Scott Michel6baba072008-03-05 23:02:02 +00001980 Pat<(SPUselb (vectype VECREG:$rA), (vectype VECREG:$rB), (vectype VECREG:$rC)),
1981 (inst VECREG:$rA, VECREG:$rB, VECREG:$rC)>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001982
Scott Michel56a125e2008-11-22 23:50:42 +00001983def : SPUselbPatVec<v16i8, SELBv16i8>;
1984def : SPUselbPatVec<v8i16, SELBv8i16>;
1985def : SPUselbPatVec<v4i32, SELBv4i32>;
1986def : SPUselbPatVec<v2i64, SELBv2i64>;
1987
1988class SPUselbPatReg<RegisterClass rclass, SPUInstr inst>:
1989 Pat<(SPUselb rclass:$rA, rclass:$rB, rclass:$rC),
1990 (inst rclass:$rA, rclass:$rB, rclass:$rC)>;
1991
1992def : SPUselbPatReg<R8C, SELBr8>;
1993def : SPUselbPatReg<R16C, SELBr16>;
1994def : SPUselbPatReg<R32C, SELBr32>;
1995def : SPUselbPatReg<R64C, SELBr64>;
Scott Michel8b6b4202007-12-04 22:35:58 +00001996
Scott Michel6baba072008-03-05 23:02:02 +00001997// EQV: Equivalence (1 for each same bit, otherwise 0)
1998//
1999// Note: There are a lot of ways to match this bit operator and these patterns
2000// attempt to be as exhaustive as possible.
Scott Michel8b6b4202007-12-04 22:35:58 +00002001
Scott Michel6baba072008-03-05 23:02:02 +00002002class EQVInst<dag OOL, dag IOL, list<dag> pattern>:
2003 RRForm<0b10010010000, OOL, IOL, "eqv\t$rT, $rA, $rB",
2004 IntegerOp, pattern>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002005
Scott Michel6baba072008-03-05 23:02:02 +00002006class EQVVecInst<ValueType vectype>:
2007 EQVInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
2008 [(set (vectype VECREG:$rT),
2009 (or (and (vectype VECREG:$rA), (vectype VECREG:$rB)),
2010 (and (vnot (vectype VECREG:$rA)),
2011 (vnot (vectype VECREG:$rB)))))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002012
Scott Michel6baba072008-03-05 23:02:02 +00002013class EQVRegInst<RegisterClass rclass>:
2014 EQVInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB),
2015 [(set rclass:$rT, (or (and rclass:$rA, rclass:$rB),
2016 (and (not rclass:$rA), (not rclass:$rB))))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002017
Scott Michel6baba072008-03-05 23:02:02 +00002018class EQVVecPattern1<ValueType vectype>:
2019 EQVInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
2020 [(set (vectype VECREG:$rT),
2021 (xor (vectype VECREG:$rA), (vnot (vectype VECREG:$rB))))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002022
Scott Michel6baba072008-03-05 23:02:02 +00002023class EQVRegPattern1<RegisterClass rclass>:
2024 EQVInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB),
2025 [(set rclass:$rT, (xor rclass:$rA, (not rclass:$rB)))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002026
Scott Michel6baba072008-03-05 23:02:02 +00002027class EQVVecPattern2<ValueType vectype>:
2028 EQVInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
2029 [(set (vectype VECREG:$rT),
2030 (or (and (vectype VECREG:$rA), (vectype VECREG:$rB)),
2031 (vnot (or (vectype VECREG:$rA), (vectype VECREG:$rB)))))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002032
Scott Michel6baba072008-03-05 23:02:02 +00002033class EQVRegPattern2<RegisterClass rclass>:
2034 EQVInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB),
2035 [(set rclass:$rT,
2036 (or (and rclass:$rA, rclass:$rB),
2037 (not (or rclass:$rA, rclass:$rB))))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002038
Scott Michel6baba072008-03-05 23:02:02 +00002039class EQVVecPattern3<ValueType vectype>:
2040 EQVInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
2041 [(set (vectype VECREG:$rT),
2042 (not (xor (vectype VECREG:$rA), (vectype VECREG:$rB))))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002043
Scott Michel6baba072008-03-05 23:02:02 +00002044class EQVRegPattern3<RegisterClass rclass>:
2045 EQVInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB),
2046 [(set rclass:$rT, (not (xor rclass:$rA, rclass:$rB)))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002047
Scott Michel6baba072008-03-05 23:02:02 +00002048multiclass BitEquivalence
2049{
2050 def v16i8: EQVVecInst<v16i8>;
2051 def v8i16: EQVVecInst<v8i16>;
2052 def v4i32: EQVVecInst<v4i32>;
2053 def v2i64: EQVVecInst<v2i64>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002054
Scott Michel6baba072008-03-05 23:02:02 +00002055 def v16i8_1: EQVVecPattern1<v16i8>;
2056 def v8i16_1: EQVVecPattern1<v8i16>;
2057 def v4i32_1: EQVVecPattern1<v4i32>;
2058 def v2i64_1: EQVVecPattern1<v2i64>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002059
Scott Michel6baba072008-03-05 23:02:02 +00002060 def v16i8_2: EQVVecPattern2<v16i8>;
2061 def v8i16_2: EQVVecPattern2<v8i16>;
2062 def v4i32_2: EQVVecPattern2<v4i32>;
2063 def v2i64_2: EQVVecPattern2<v2i64>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002064
Scott Michel6baba072008-03-05 23:02:02 +00002065 def v16i8_3: EQVVecPattern3<v16i8>;
2066 def v8i16_3: EQVVecPattern3<v8i16>;
2067 def v4i32_3: EQVVecPattern3<v4i32>;
2068 def v2i64_3: EQVVecPattern3<v2i64>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002069
Scott Michel6baba072008-03-05 23:02:02 +00002070 def r128: EQVRegInst<GPRC>;
2071 def r64: EQVRegInst<R64C>;
2072 def r32: EQVRegInst<R32C>;
2073 def r16: EQVRegInst<R16C>;
2074 def r8: EQVRegInst<R8C>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002075
Scott Michel6baba072008-03-05 23:02:02 +00002076 def r128_1: EQVRegPattern1<GPRC>;
2077 def r64_1: EQVRegPattern1<R64C>;
2078 def r32_1: EQVRegPattern1<R32C>;
2079 def r16_1: EQVRegPattern1<R16C>;
2080 def r8_1: EQVRegPattern1<R8C>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002081
Scott Michel6baba072008-03-05 23:02:02 +00002082 def r128_2: EQVRegPattern2<GPRC>;
2083 def r64_2: EQVRegPattern2<R64C>;
2084 def r32_2: EQVRegPattern2<R32C>;
2085 def r16_2: EQVRegPattern2<R16C>;
2086 def r8_2: EQVRegPattern2<R8C>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002087
Scott Michel6baba072008-03-05 23:02:02 +00002088 def r128_3: EQVRegPattern3<GPRC>;
2089 def r64_3: EQVRegPattern3<R64C>;
2090 def r32_3: EQVRegPattern3<R32C>;
2091 def r16_3: EQVRegPattern3<R16C>;
2092 def r8_3: EQVRegPattern3<R8C>;
2093}
Scott Michel438be252007-12-17 22:32:34 +00002094
Scott Michel6baba072008-03-05 23:02:02 +00002095defm EQV: BitEquivalence;
Scott Michel8b6b4202007-12-04 22:35:58 +00002096
2097//===----------------------------------------------------------------------===//
2098// Vector shuffle...
2099//===----------------------------------------------------------------------===//
Scott Michel8b6b4202007-12-04 22:35:58 +00002100// SPUshuffle is generated in LowerVECTOR_SHUFFLE and gets replaced with SHUFB.
2101// See the SPUshuffle SDNode operand above, which sets up the DAG pattern
2102// matcher to emit something when the LowerVECTOR_SHUFFLE generates a node with
2103// the SPUISD::SHUFB opcode.
Scott Michel97872d32008-02-23 18:41:37 +00002104//===----------------------------------------------------------------------===//
Scott Michel8b6b4202007-12-04 22:35:58 +00002105
Scott Michel97872d32008-02-23 18:41:37 +00002106class SHUFBInst<dag OOL, dag IOL, list<dag> pattern>:
2107 RRRForm<0b1000, OOL, IOL, "shufb\t$rT, $rA, $rB, $rC",
2108 IntegerOp, pattern>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002109
Scott Michel0718cd82008-12-01 17:56:02 +00002110class SHUFBVecInst<ValueType resultvec, ValueType maskvec>:
Scott Michel97872d32008-02-23 18:41:37 +00002111 SHUFBInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB, VECREG:$rC),
Scott Michel0718cd82008-12-01 17:56:02 +00002112 [(set (resultvec VECREG:$rT),
2113 (SPUshuffle (resultvec VECREG:$rA),
2114 (resultvec VECREG:$rB),
2115 (maskvec VECREG:$rC)))]>;
Scott Michel754d8662007-12-20 00:44:13 +00002116
Scott Michel06eabde2008-12-27 04:51:36 +00002117class SHUFBGPRCInst:
2118 SHUFBInst<(outs VECREG:$rT), (ins GPRC:$rA, GPRC:$rB, VECREG:$rC),
2119 [/* no pattern */]>;
2120
Scott Michel97872d32008-02-23 18:41:37 +00002121multiclass ShuffleBytes
2122{
Scott Michel0718cd82008-12-01 17:56:02 +00002123 def v16i8 : SHUFBVecInst<v16i8, v16i8>;
2124 def v16i8_m32 : SHUFBVecInst<v16i8, v4i32>;
2125 def v8i16 : SHUFBVecInst<v8i16, v16i8>;
2126 def v8i16_m32 : SHUFBVecInst<v8i16, v4i32>;
2127 def v4i32 : SHUFBVecInst<v4i32, v16i8>;
2128 def v4i32_m32 : SHUFBVecInst<v4i32, v4i32>;
2129 def v2i64 : SHUFBVecInst<v2i64, v16i8>;
2130 def v2i64_m32 : SHUFBVecInst<v2i64, v4i32>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002131
Scott Michel0718cd82008-12-01 17:56:02 +00002132 def v4f32 : SHUFBVecInst<v4f32, v16i8>;
2133 def v4f32_m32 : SHUFBVecInst<v4f32, v4i32>;
2134
2135 def v2f64 : SHUFBVecInst<v2f64, v16i8>;
2136 def v2f64_m32 : SHUFBVecInst<v2f64, v4i32>;
Scott Michel06eabde2008-12-27 04:51:36 +00002137
2138 def gprc : SHUFBGPRCInst;
Scott Michel97872d32008-02-23 18:41:37 +00002139}
2140
2141defm SHUFB : ShuffleBytes;
2142
Scott Michel8b6b4202007-12-04 22:35:58 +00002143//===----------------------------------------------------------------------===//
2144// Shift and rotate group:
2145//===----------------------------------------------------------------------===//
2146
Scott Michel97872d32008-02-23 18:41:37 +00002147class SHLHInst<dag OOL, dag IOL, list<dag> pattern>:
2148 RRForm<0b11111010000, OOL, IOL, "shlh\t$rT, $rA, $rB",
2149 RotateShift, pattern>;
2150
2151class SHLHVecInst<ValueType vectype>:
2152 SHLHInst<(outs VECREG:$rT), (ins VECREG:$rA, R16C:$rB),
2153 [(set (vectype VECREG:$rT),
2154 (SPUvec_shl (vectype VECREG:$rA), R16C:$rB))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002155
Scott Michel97872d32008-02-23 18:41:37 +00002156multiclass ShiftLeftHalfword
2157{
2158 def v8i16: SHLHVecInst<v8i16>;
2159 def r16: SHLHInst<(outs R16C:$rT), (ins R16C:$rA, R16C:$rB),
2160 [(set R16C:$rT, (shl R16C:$rA, R16C:$rB))]>;
2161 def r16_r32: SHLHInst<(outs R16C:$rT), (ins R16C:$rA, R32C:$rB),
2162 [(set R16C:$rT, (shl R16C:$rA, R32C:$rB))]>;
2163}
Scott Michel8b6b4202007-12-04 22:35:58 +00002164
Scott Michel97872d32008-02-23 18:41:37 +00002165defm SHLH : ShiftLeftHalfword;
Scott Michel8b6b4202007-12-04 22:35:58 +00002166
Scott Michel97872d32008-02-23 18:41:37 +00002167//===----------------------------------------------------------------------===//
Scott Michel438be252007-12-17 22:32:34 +00002168
Scott Michel97872d32008-02-23 18:41:37 +00002169class SHLHIInst<dag OOL, dag IOL, list<dag> pattern>:
2170 RI7Form<0b11111010000, OOL, IOL, "shlhi\t$rT, $rA, $val",
2171 RotateShift, pattern>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002172
Scott Michel97872d32008-02-23 18:41:37 +00002173class SHLHIVecInst<ValueType vectype>:
2174 SHLHIInst<(outs VECREG:$rT), (ins VECREG:$rA, u7imm:$val),
2175 [(set (vectype VECREG:$rT),
2176 (SPUvec_shl (vectype VECREG:$rA), (i16 uimm7:$val)))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002177
Scott Michel97872d32008-02-23 18:41:37 +00002178multiclass ShiftLeftHalfwordImm
2179{
2180 def v8i16: SHLHIVecInst<v8i16>;
2181 def r16: SHLHIInst<(outs R16C:$rT), (ins R16C:$rA, u7imm:$val),
2182 [(set R16C:$rT, (shl R16C:$rA, (i16 uimm7:$val)))]>;
2183}
2184
2185defm SHLHI : ShiftLeftHalfwordImm;
2186
2187def : Pat<(SPUvec_shl (v8i16 VECREG:$rA), (i32 uimm7:$val)),
2188 (SHLHIv8i16 VECREG:$rA, uimm7:$val)>;
2189
2190def : Pat<(shl R16C:$rA, (i32 uimm7:$val)),
Scott Michel438be252007-12-17 22:32:34 +00002191 (SHLHIr16 R16C:$rA, uimm7:$val)>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002192
Scott Michel97872d32008-02-23 18:41:37 +00002193//===----------------------------------------------------------------------===//
Scott Michel8b6b4202007-12-04 22:35:58 +00002194
Scott Michel97872d32008-02-23 18:41:37 +00002195class SHLInst<dag OOL, dag IOL, list<dag> pattern>:
2196 RRForm<0b11111010000, OOL, IOL, "shl\t$rT, $rA, $rB",
2197 RotateShift, pattern>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002198
Scott Michel97872d32008-02-23 18:41:37 +00002199multiclass ShiftLeftWord
2200{
2201 def v4i32:
2202 SHLInst<(outs VECREG:$rT), (ins VECREG:$rA, R16C:$rB),
2203 [(set (v4i32 VECREG:$rT),
2204 (SPUvec_shl (v4i32 VECREG:$rA), R16C:$rB))]>;
2205 def r32:
2206 SHLInst<(outs R32C:$rT), (ins R32C:$rA, R32C:$rB),
2207 [(set R32C:$rT, (shl R32C:$rA, R32C:$rB))]>;
2208}
Scott Michel8b6b4202007-12-04 22:35:58 +00002209
Scott Michel97872d32008-02-23 18:41:37 +00002210defm SHL: ShiftLeftWord;
Scott Michel438be252007-12-17 22:32:34 +00002211
Scott Michel97872d32008-02-23 18:41:37 +00002212//===----------------------------------------------------------------------===//
Scott Michel8b6b4202007-12-04 22:35:58 +00002213
Scott Michel97872d32008-02-23 18:41:37 +00002214class SHLIInst<dag OOL, dag IOL, list<dag> pattern>:
2215 RI7Form<0b11111010000, OOL, IOL, "shli\t$rT, $rA, $val",
2216 RotateShift, pattern>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002217
Scott Michel97872d32008-02-23 18:41:37 +00002218multiclass ShiftLeftWordImm
2219{
2220 def v4i32:
2221 SHLIInst<(outs VECREG:$rT), (ins VECREG:$rA, u7imm_i32:$val),
2222 [(set (v4i32 VECREG:$rT),
2223 (SPUvec_shl (v4i32 VECREG:$rA), (i32 uimm7:$val)))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002224
Scott Michel97872d32008-02-23 18:41:37 +00002225 def r32:
2226 SHLIInst<(outs R32C:$rT), (ins R32C:$rA, u7imm_i32:$val),
2227 [(set R32C:$rT, (shl R32C:$rA, (i32 uimm7:$val)))]>;
2228}
Scott Michel8b6b4202007-12-04 22:35:58 +00002229
Scott Michel97872d32008-02-23 18:41:37 +00002230defm SHLI : ShiftLeftWordImm;
Scott Michel438be252007-12-17 22:32:34 +00002231
Scott Michel97872d32008-02-23 18:41:37 +00002232//===----------------------------------------------------------------------===//
Scott Michel8b6b4202007-12-04 22:35:58 +00002233// SHLQBI vec form: Note that this will shift the entire vector (the 128-bit
2234// register) to the left. Vector form is here to ensure type correctness.
Scott Michel97872d32008-02-23 18:41:37 +00002235//
2236// The shift count is in the lowest 3 bits (29-31) of $rB, so only a bit shift
2237// of 7 bits is actually possible.
2238//
2239// Note also that SHLQBI/SHLQBII are used in conjunction with SHLQBY/SHLQBYI
2240// to shift i64 and i128. SHLQBI is the residual left over after shifting by
2241// bytes with SHLQBY.
Scott Michel8b6b4202007-12-04 22:35:58 +00002242
Scott Michel97872d32008-02-23 18:41:37 +00002243class SHLQBIInst<dag OOL, dag IOL, list<dag> pattern>:
2244 RRForm<0b11011011100, OOL, IOL, "shlqbi\t$rT, $rA, $rB",
2245 RotateShift, pattern>;
2246
2247class SHLQBIVecInst<ValueType vectype>:
2248 SHLQBIInst<(outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB),
2249 [(set (vectype VECREG:$rT),
2250 (SPUshlquad_l_bits (vectype VECREG:$rA), R32C:$rB))]>;
2251
Scott Michel8c67fa42009-01-21 04:58:48 +00002252class SHLQBIRegInst<RegisterClass rclass>:
2253 SHLQBIInst<(outs rclass:$rT), (ins rclass:$rA, R32C:$rB),
2254 [/* no pattern */]>;
2255
Scott Michel97872d32008-02-23 18:41:37 +00002256multiclass ShiftLeftQuadByBits
2257{
2258 def v16i8: SHLQBIVecInst<v16i8>;
2259 def v8i16: SHLQBIVecInst<v8i16>;
2260 def v4i32: SHLQBIVecInst<v4i32>;
Scott Michel56a125e2008-11-22 23:50:42 +00002261 def v4f32: SHLQBIVecInst<v4f32>;
Scott Michel97872d32008-02-23 18:41:37 +00002262 def v2i64: SHLQBIVecInst<v2i64>;
Scott Michel56a125e2008-11-22 23:50:42 +00002263 def v2f64: SHLQBIVecInst<v2f64>;
Scott Michel8c67fa42009-01-21 04:58:48 +00002264
2265 def r128: SHLQBIRegInst<GPRC>;
Scott Michel97872d32008-02-23 18:41:37 +00002266}
2267
2268defm SHLQBI : ShiftLeftQuadByBits;
2269
2270// See note above on SHLQBI. In this case, the predicate actually does then
2271// enforcement, whereas with SHLQBI, we have to "take it on faith."
2272class SHLQBIIInst<dag OOL, dag IOL, list<dag> pattern>:
2273 RI7Form<0b11011111100, OOL, IOL, "shlqbii\t$rT, $rA, $val",
2274 RotateShift, pattern>;
2275
2276class SHLQBIIVecInst<ValueType vectype>:
2277 SHLQBIIInst<(outs VECREG:$rT), (ins VECREG:$rA, u7imm_i32:$val),
2278 [(set (vectype VECREG:$rT),
2279 (SPUshlquad_l_bits (vectype VECREG:$rA), (i32 bitshift:$val)))]>;
2280
2281multiclass ShiftLeftQuadByBitsImm
2282{
2283 def v16i8 : SHLQBIIVecInst<v16i8>;
2284 def v8i16 : SHLQBIIVecInst<v8i16>;
2285 def v4i32 : SHLQBIIVecInst<v4i32>;
Scott Michel56a125e2008-11-22 23:50:42 +00002286 def v4f32 : SHLQBIIVecInst<v4f32>;
Scott Michel97872d32008-02-23 18:41:37 +00002287 def v2i64 : SHLQBIIVecInst<v2i64>;
Scott Michel56a125e2008-11-22 23:50:42 +00002288 def v2f64 : SHLQBIIVecInst<v2f64>;
Scott Michel97872d32008-02-23 18:41:37 +00002289}
2290
2291defm SHLQBII : ShiftLeftQuadByBitsImm;
Scott Michel8b6b4202007-12-04 22:35:58 +00002292
2293// SHLQBY, SHLQBYI vector forms: Shift the entire vector to the left by bytes,
Scott Michel97872d32008-02-23 18:41:37 +00002294// not by bits. See notes above on SHLQBI.
Scott Michel8b6b4202007-12-04 22:35:58 +00002295
Scott Michel97872d32008-02-23 18:41:37 +00002296class SHLQBYInst<dag OOL, dag IOL, list<dag> pattern>:
Scott Michelfa888632008-11-25 00:23:16 +00002297 RI7Form<0b11111011100, OOL, IOL, "shlqby\t$rT, $rA, $rB",
Scott Michel97872d32008-02-23 18:41:37 +00002298 RotateShift, pattern>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002299
Scott Michel97872d32008-02-23 18:41:37 +00002300class SHLQBYVecInst<ValueType vectype>:
2301 SHLQBYInst<(outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB),
2302 [(set (vectype VECREG:$rT),
2303 (SPUshlquad_l_bytes (vectype VECREG:$rA), R32C:$rB))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002304
Scott Michel97872d32008-02-23 18:41:37 +00002305multiclass ShiftLeftQuadBytes
2306{
2307 def v16i8: SHLQBYVecInst<v16i8>;
2308 def v8i16: SHLQBYVecInst<v8i16>;
2309 def v4i32: SHLQBYVecInst<v4i32>;
Scott Michel56a125e2008-11-22 23:50:42 +00002310 def v4f32: SHLQBYVecInst<v4f32>;
Scott Michel97872d32008-02-23 18:41:37 +00002311 def v2i64: SHLQBYVecInst<v2i64>;
Scott Michel56a125e2008-11-22 23:50:42 +00002312 def v2f64: SHLQBYVecInst<v2f64>;
Scott Michel97872d32008-02-23 18:41:37 +00002313 def r128: SHLQBYInst<(outs GPRC:$rT), (ins GPRC:$rA, R32C:$rB),
2314 [(set GPRC:$rT, (SPUshlquad_l_bytes GPRC:$rA, R32C:$rB))]>;
2315}
Scott Michel8b6b4202007-12-04 22:35:58 +00002316
Scott Michel97872d32008-02-23 18:41:37 +00002317defm SHLQBY: ShiftLeftQuadBytes;
Scott Michel8b6b4202007-12-04 22:35:58 +00002318
Scott Michel97872d32008-02-23 18:41:37 +00002319class SHLQBYIInst<dag OOL, dag IOL, list<dag> pattern>:
2320 RI7Form<0b11111111100, OOL, IOL, "shlqbyi\t$rT, $rA, $val",
2321 RotateShift, pattern>;
Scott Michel438be252007-12-17 22:32:34 +00002322
Scott Michel97872d32008-02-23 18:41:37 +00002323class SHLQBYIVecInst<ValueType vectype>:
2324 SHLQBYIInst<(outs VECREG:$rT), (ins VECREG:$rA, u7imm_i32:$val),
2325 [(set (vectype VECREG:$rT),
2326 (SPUshlquad_l_bytes (vectype VECREG:$rA), (i32 uimm7:$val)))]>;
Scott Michel438be252007-12-17 22:32:34 +00002327
Scott Michel97872d32008-02-23 18:41:37 +00002328multiclass ShiftLeftQuadBytesImm
2329{
2330 def v16i8: SHLQBYIVecInst<v16i8>;
2331 def v8i16: SHLQBYIVecInst<v8i16>;
2332 def v4i32: SHLQBYIVecInst<v4i32>;
Scott Michel56a125e2008-11-22 23:50:42 +00002333 def v4f32: SHLQBYIVecInst<v4f32>;
Scott Michel97872d32008-02-23 18:41:37 +00002334 def v2i64: SHLQBYIVecInst<v2i64>;
Scott Michel56a125e2008-11-22 23:50:42 +00002335 def v2f64: SHLQBYIVecInst<v2f64>;
Scott Michel97872d32008-02-23 18:41:37 +00002336 def r128: SHLQBYIInst<(outs GPRC:$rT), (ins GPRC:$rA, u7imm_i32:$val),
2337 [(set GPRC:$rT,
2338 (SPUshlquad_l_bytes GPRC:$rA, (i32 uimm7:$val)))]>;
2339}
Scott Michel438be252007-12-17 22:32:34 +00002340
Scott Michel97872d32008-02-23 18:41:37 +00002341defm SHLQBYI : ShiftLeftQuadBytesImm;
Scott Michel438be252007-12-17 22:32:34 +00002342
Scott Michel8c67fa42009-01-21 04:58:48 +00002343class SHLQBYBIInst<dag OOL, dag IOL, list<dag> pattern>:
2344 RRForm<0b00111001111, OOL, IOL, "shlqbybi\t$rT, $rA, $rB",
2345 RotateShift, pattern>;
2346
2347class SHLQBYBIVecInst<ValueType vectype>:
2348 SHLQBYBIInst<(outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB),
2349 [/* no pattern */]>;
2350
2351class SHLQBYBIRegInst<RegisterClass rclass>:
2352 SHLQBYBIInst<(outs rclass:$rT), (ins rclass:$rA, R32C:$rB),
2353 [/* no pattern */]>;
2354
2355multiclass ShiftLeftQuadBytesBitCount
2356{
2357 def v16i8: SHLQBYBIVecInst<v16i8>;
2358 def v8i16: SHLQBYBIVecInst<v8i16>;
2359 def v4i32: SHLQBYBIVecInst<v4i32>;
2360 def v4f32: SHLQBYBIVecInst<v4f32>;
2361 def v2i64: SHLQBYBIVecInst<v2i64>;
2362 def v2f64: SHLQBYBIVecInst<v2f64>;
2363
2364 def r128: SHLQBYBIRegInst<GPRC>;
2365}
2366
2367defm SHLQBYBI : ShiftLeftQuadBytesBitCount;
2368
Scott Michel97872d32008-02-23 18:41:37 +00002369//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2370// Rotate halfword:
2371//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2372class ROTHInst<dag OOL, dag IOL, list<dag> pattern>:
2373 RRForm<0b00111010000, OOL, IOL, "roth\t$rT, $rA, $rB",
2374 RotateShift, pattern>;
2375
2376class ROTHVecInst<ValueType vectype>:
2377 ROTHInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
2378 [(set (vectype VECREG:$rT),
2379 (SPUvec_rotl VECREG:$rA, VECREG:$rB))]>;
2380
2381class ROTHRegInst<RegisterClass rclass>:
2382 ROTHInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB),
2383 [(set rclass:$rT, (rotl rclass:$rA, rclass:$rB))]>;
2384
2385multiclass RotateLeftHalfword
2386{
2387 def v8i16: ROTHVecInst<v8i16>;
2388 def r16: ROTHRegInst<R16C>;
2389}
2390
2391defm ROTH: RotateLeftHalfword;
2392
2393def ROTHr16_r32: ROTHInst<(outs R16C:$rT), (ins R16C:$rA, R32C:$rB),
2394 [(set R16C:$rT, (rotl R16C:$rA, R32C:$rB))]>;
2395
2396//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2397// Rotate halfword, immediate:
2398//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2399class ROTHIInst<dag OOL, dag IOL, list<dag> pattern>:
2400 RI7Form<0b00111110000, OOL, IOL, "rothi\t$rT, $rA, $val",
2401 RotateShift, pattern>;
2402
2403class ROTHIVecInst<ValueType vectype>:
2404 ROTHIInst<(outs VECREG:$rT), (ins VECREG:$rA, u7imm:$val),
2405 [(set (vectype VECREG:$rT),
2406 (SPUvec_rotl VECREG:$rA, (i16 uimm7:$val)))]>;
2407
2408multiclass RotateLeftHalfwordImm
2409{
2410 def v8i16: ROTHIVecInst<v8i16>;
2411 def r16: ROTHIInst<(outs R16C:$rT), (ins R16C:$rA, u7imm:$val),
2412 [(set R16C:$rT, (rotl R16C:$rA, (i16 uimm7:$val)))]>;
2413 def r16_r32: ROTHIInst<(outs R16C:$rT), (ins R16C:$rA, u7imm_i32:$val),
2414 [(set R16C:$rT, (rotl R16C:$rA, (i32 uimm7:$val)))]>;
2415}
2416
2417defm ROTHI: RotateLeftHalfwordImm;
2418
2419def : Pat<(SPUvec_rotl VECREG:$rA, (i32 uimm7:$val)),
Scott Michel8b6b4202007-12-04 22:35:58 +00002420 (ROTHIv8i16 VECREG:$rA, imm:$val)>;
Scott Michel06eabde2008-12-27 04:51:36 +00002421
Scott Michel97872d32008-02-23 18:41:37 +00002422//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2423// Rotate word:
2424//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
Scott Michel8b6b4202007-12-04 22:35:58 +00002425
Scott Michel97872d32008-02-23 18:41:37 +00002426class ROTInst<dag OOL, dag IOL, list<dag> pattern>:
2427 RRForm<0b00011010000, OOL, IOL, "rot\t$rT, $rA, $rB",
2428 RotateShift, pattern>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002429
Scott Michel97872d32008-02-23 18:41:37 +00002430class ROTVecInst<ValueType vectype>:
2431 ROTInst<(outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB),
2432 [(set (vectype VECREG:$rT),
2433 (SPUvec_rotl (vectype VECREG:$rA), R32C:$rB))]>;
Scott Michel438be252007-12-17 22:32:34 +00002434
Scott Michel97872d32008-02-23 18:41:37 +00002435class ROTRegInst<RegisterClass rclass>:
2436 ROTInst<(outs rclass:$rT), (ins rclass:$rA, R32C:$rB),
2437 [(set rclass:$rT,
2438 (rotl rclass:$rA, R32C:$rB))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002439
Scott Michel97872d32008-02-23 18:41:37 +00002440multiclass RotateLeftWord
2441{
2442 def v4i32: ROTVecInst<v4i32>;
2443 def r32: ROTRegInst<R32C>;
2444}
2445
2446defm ROT: RotateLeftWord;
Scott Michel8b6b4202007-12-04 22:35:58 +00002447
Scott Michel438be252007-12-17 22:32:34 +00002448// The rotate amount is in the same bits whether we've got an 8-bit, 16-bit or
2449// 32-bit register
2450def ROTr32_r16_anyext:
Scott Michel97872d32008-02-23 18:41:37 +00002451 ROTInst<(outs R32C:$rT), (ins R32C:$rA, R16C:$rB),
2452 [(set R32C:$rT, (rotl R32C:$rA, (i32 (anyext R16C:$rB))))]>;
Scott Michel438be252007-12-17 22:32:34 +00002453
2454def : Pat<(rotl R32C:$rA, (i32 (zext R16C:$rB))),
2455 (ROTr32_r16_anyext R32C:$rA, R16C:$rB)>;
2456
2457def : Pat<(rotl R32C:$rA, (i32 (sext R16C:$rB))),
2458 (ROTr32_r16_anyext R32C:$rA, R16C:$rB)>;
2459
2460def ROTr32_r8_anyext:
Scott Michel97872d32008-02-23 18:41:37 +00002461 ROTInst<(outs R32C:$rT), (ins R32C:$rA, R8C:$rB),
2462 [(set R32C:$rT, (rotl R32C:$rA, (i32 (anyext R8C:$rB))))]>;
Scott Michel438be252007-12-17 22:32:34 +00002463
2464def : Pat<(rotl R32C:$rA, (i32 (zext R8C:$rB))),
2465 (ROTr32_r8_anyext R32C:$rA, R8C:$rB)>;
2466
2467def : Pat<(rotl R32C:$rA, (i32 (sext R8C:$rB))),
2468 (ROTr32_r8_anyext R32C:$rA, R8C:$rB)>;
2469
Scott Michel97872d32008-02-23 18:41:37 +00002470//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2471// Rotate word, immediate
2472//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
Scott Michel8b6b4202007-12-04 22:35:58 +00002473
Scott Michel97872d32008-02-23 18:41:37 +00002474class ROTIInst<dag OOL, dag IOL, list<dag> pattern>:
2475 RI7Form<0b00011110000, OOL, IOL, "roti\t$rT, $rA, $val",
2476 RotateShift, pattern>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002477
Scott Michel97872d32008-02-23 18:41:37 +00002478class ROTIVecInst<ValueType vectype, Operand optype, ValueType inttype, PatLeaf pred>:
2479 ROTIInst<(outs VECREG:$rT), (ins VECREG:$rA, optype:$val),
2480 [(set (vectype VECREG:$rT),
2481 (SPUvec_rotl (vectype VECREG:$rA), (inttype pred:$val)))]>;
Scott Michel438be252007-12-17 22:32:34 +00002482
Scott Michel97872d32008-02-23 18:41:37 +00002483class ROTIRegInst<RegisterClass rclass, Operand optype, ValueType inttype, PatLeaf pred>:
2484 ROTIInst<(outs rclass:$rT), (ins rclass:$rA, optype:$val),
2485 [(set rclass:$rT, (rotl rclass:$rA, (inttype pred:$val)))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002486
Scott Michel97872d32008-02-23 18:41:37 +00002487multiclass RotateLeftWordImm
2488{
2489 def v4i32: ROTIVecInst<v4i32, u7imm_i32, i32, uimm7>;
2490 def v4i32_i16: ROTIVecInst<v4i32, u7imm, i16, uimm7>;
2491 def v4i32_i8: ROTIVecInst<v4i32, u7imm_i8, i8, uimm7>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002492
Scott Michel97872d32008-02-23 18:41:37 +00002493 def r32: ROTIRegInst<R32C, u7imm_i32, i32, uimm7>;
2494 def r32_i16: ROTIRegInst<R32C, u7imm, i16, uimm7>;
2495 def r32_i8: ROTIRegInst<R32C, u7imm_i8, i8, uimm7>;
2496}
Scott Michel438be252007-12-17 22:32:34 +00002497
Scott Michel97872d32008-02-23 18:41:37 +00002498defm ROTI : RotateLeftWordImm;
2499
2500//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2501// Rotate quad by byte (count)
2502//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2503
2504class ROTQBYInst<dag OOL, dag IOL, list<dag> pattern>:
2505 RRForm<0b00111011100, OOL, IOL, "rotqby\t$rT, $rA, $rB",
2506 RotateShift, pattern>;
2507
2508class ROTQBYVecInst<ValueType vectype>:
2509 ROTQBYInst<(outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB),
2510 [(set (vectype VECREG:$rT),
2511 (SPUrotbytes_left (vectype VECREG:$rA), R32C:$rB))]>;
2512
2513multiclass RotateQuadLeftByBytes
2514{
2515 def v16i8: ROTQBYVecInst<v16i8>;
2516 def v8i16: ROTQBYVecInst<v8i16>;
2517 def v4i32: ROTQBYVecInst<v4i32>;
Scott Michele2641a12008-12-04 21:01:44 +00002518 def v4f32: ROTQBYVecInst<v4f32>;
Scott Michel97872d32008-02-23 18:41:37 +00002519 def v2i64: ROTQBYVecInst<v2i64>;
Scott Michele2641a12008-12-04 21:01:44 +00002520 def v2f64: ROTQBYVecInst<v2f64>;
Scott Michel97872d32008-02-23 18:41:37 +00002521}
2522
2523defm ROTQBY: RotateQuadLeftByBytes;
Scott Michel8b6b4202007-12-04 22:35:58 +00002524
Scott Michel97872d32008-02-23 18:41:37 +00002525//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2526// Rotate quad by byte (count), immediate
2527//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2528
2529class ROTQBYIInst<dag OOL, dag IOL, list<dag> pattern>:
2530 RI7Form<0b00111111100, OOL, IOL, "rotqbyi\t$rT, $rA, $val",
2531 RotateShift, pattern>;
2532
2533class ROTQBYIVecInst<ValueType vectype>:
2534 ROTQBYIInst<(outs VECREG:$rT), (ins VECREG:$rA, u7imm:$val),
2535 [(set (vectype VECREG:$rT),
2536 (SPUrotbytes_left (vectype VECREG:$rA), (i16 uimm7:$val)))]>;
2537
2538multiclass RotateQuadByBytesImm
2539{
2540 def v16i8: ROTQBYIVecInst<v16i8>;
2541 def v8i16: ROTQBYIVecInst<v8i16>;
2542 def v4i32: ROTQBYIVecInst<v4i32>;
Scott Michele2641a12008-12-04 21:01:44 +00002543 def v4f32: ROTQBYIVecInst<v4f32>;
Scott Michel97872d32008-02-23 18:41:37 +00002544 def v2i64: ROTQBYIVecInst<v2i64>;
Scott Michele2641a12008-12-04 21:01:44 +00002545 def vfi64: ROTQBYIVecInst<v2f64>;
Scott Michel97872d32008-02-23 18:41:37 +00002546}
2547
2548defm ROTQBYI: RotateQuadByBytesImm;
Scott Michel8b6b4202007-12-04 22:35:58 +00002549
Scott Michel8b6b4202007-12-04 22:35:58 +00002550// See ROTQBY note above.
Scott Michel67224b22008-06-02 22:18:03 +00002551class ROTQBYBIInst<dag OOL, dag IOL, list<dag> pattern>:
2552 RI7Form<0b00110011100, OOL, IOL,
2553 "rotqbybi\t$rT, $rA, $shift",
2554 RotateShift, pattern>;
2555
2556class ROTQBYBIVecInst<ValueType vectype, RegisterClass rclass>:
2557 ROTQBYBIInst<(outs VECREG:$rT), (ins VECREG:$rA, rclass:$shift),
2558 [(set (vectype VECREG:$rT),
2559 (SPUrotbytes_left_bits (vectype VECREG:$rA), rclass:$shift))]>;
2560
2561multiclass RotateQuadByBytesByBitshift {
2562 def v16i8_r32: ROTQBYBIVecInst<v16i8, R32C>;
2563 def v8i16_r32: ROTQBYBIVecInst<v8i16, R32C>;
2564 def v4i32_r32: ROTQBYBIVecInst<v4i32, R32C>;
2565 def v2i64_r32: ROTQBYBIVecInst<v2i64, R32C>;
2566}
2567
2568defm ROTQBYBI : RotateQuadByBytesByBitshift;
Scott Michel8b6b4202007-12-04 22:35:58 +00002569
Scott Michel97872d32008-02-23 18:41:37 +00002570//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
Scott Michel8b6b4202007-12-04 22:35:58 +00002571// See ROTQBY note above.
2572//
2573// Assume that the user of this instruction knows to shift the rotate count
2574// into bit 29
Scott Michel97872d32008-02-23 18:41:37 +00002575//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
Scott Michel8b6b4202007-12-04 22:35:58 +00002576
Scott Michel97872d32008-02-23 18:41:37 +00002577class ROTQBIInst<dag OOL, dag IOL, list<dag> pattern>:
2578 RRForm<0b00011011100, OOL, IOL, "rotqbi\t$rT, $rA, $rB",
2579 RotateShift, pattern>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002580
Scott Michel97872d32008-02-23 18:41:37 +00002581class ROTQBIVecInst<ValueType vectype>:
Scott Michel4d07fb72008-12-30 23:28:25 +00002582 ROTQBIInst<(outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB),
Scott Michel97872d32008-02-23 18:41:37 +00002583 [/* no pattern yet */]>;
2584
2585class ROTQBIRegInst<RegisterClass rclass>:
Scott Michel4d07fb72008-12-30 23:28:25 +00002586 ROTQBIInst<(outs rclass:$rT), (ins rclass:$rA, R32C:$rB),
Scott Michel97872d32008-02-23 18:41:37 +00002587 [/* no pattern yet */]>;
2588
2589multiclass RotateQuadByBitCount
2590{
2591 def v16i8: ROTQBIVecInst<v16i8>;
2592 def v8i16: ROTQBIVecInst<v8i16>;
2593 def v4i32: ROTQBIVecInst<v4i32>;
2594 def v2i64: ROTQBIVecInst<v2i64>;
2595
2596 def r128: ROTQBIRegInst<GPRC>;
2597 def r64: ROTQBIRegInst<R64C>;
2598}
2599
2600defm ROTQBI: RotateQuadByBitCount;
Scott Michel06eabde2008-12-27 04:51:36 +00002601
Scott Michel97872d32008-02-23 18:41:37 +00002602class ROTQBIIInst<dag OOL, dag IOL, list<dag> pattern>:
2603 RI7Form<0b00011111100, OOL, IOL, "rotqbii\t$rT, $rA, $val",
2604 RotateShift, pattern>;
2605
2606class ROTQBIIVecInst<ValueType vectype, Operand optype, ValueType inttype,
2607 PatLeaf pred>:
2608 ROTQBIIInst<(outs VECREG:$rT), (ins VECREG:$rA, optype:$val),
2609 [/* no pattern yet */]>;
2610
2611class ROTQBIIRegInst<RegisterClass rclass, Operand optype, ValueType inttype,
2612 PatLeaf pred>:
2613 ROTQBIIInst<(outs rclass:$rT), (ins rclass:$rA, optype:$val),
2614 [/* no pattern yet */]>;
2615
2616multiclass RotateQuadByBitCountImm
2617{
2618 def v16i8: ROTQBIIVecInst<v16i8, u7imm_i32, i32, uimm7>;
2619 def v8i16: ROTQBIIVecInst<v8i16, u7imm_i32, i32, uimm7>;
2620 def v4i32: ROTQBIIVecInst<v4i32, u7imm_i32, i32, uimm7>;
2621 def v2i64: ROTQBIIVecInst<v2i64, u7imm_i32, i32, uimm7>;
2622
2623 def r128: ROTQBIIRegInst<GPRC, u7imm_i32, i32, uimm7>;
2624 def r64: ROTQBIIRegInst<R64C, u7imm_i32, i32, uimm7>;
2625}
2626
2627defm ROTQBII : RotateQuadByBitCountImm;
2628
2629//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
Scott Michel8b6b4202007-12-04 22:35:58 +00002630// ROTHM v8i16 form:
2631// NOTE(1): No vector rotate is generated by the C/C++ frontend (today),
2632// so this only matches a synthetically generated/lowered code
2633// fragment.
2634// NOTE(2): $rB must be negated before the right rotate!
Scott Michel97872d32008-02-23 18:41:37 +00002635//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
Scott Michel8b6b4202007-12-04 22:35:58 +00002636
Scott Michel97872d32008-02-23 18:41:37 +00002637class ROTHMInst<dag OOL, dag IOL, list<dag> pattern>:
2638 RRForm<0b10111010000, OOL, IOL, "rothm\t$rT, $rA, $rB",
2639 RotateShift, pattern>;
2640
2641def ROTHMv8i16:
2642 ROTHMInst<(outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB),
2643 [/* see patterns below - $rB must be negated */]>;
2644
2645def : Pat<(SPUvec_srl (v8i16 VECREG:$rA), R32C:$rB),
Scott Michel8b6b4202007-12-04 22:35:58 +00002646 (ROTHMv8i16 VECREG:$rA, (SFIr32 R32C:$rB, 0))>;
2647
Scott Michel97872d32008-02-23 18:41:37 +00002648def : Pat<(SPUvec_srl (v8i16 VECREG:$rA), R16C:$rB),
Scott Michel8b6b4202007-12-04 22:35:58 +00002649 (ROTHMv8i16 VECREG:$rA,
2650 (SFIr32 (XSHWr16 R16C:$rB), 0))>;
2651
Scott Michel97872d32008-02-23 18:41:37 +00002652def : Pat<(SPUvec_srl (v8i16 VECREG:$rA), R8C:$rB),
Scott Michel8b6b4202007-12-04 22:35:58 +00002653 (ROTHMv8i16 VECREG:$rA,
Scott Michel438be252007-12-17 22:32:34 +00002654 (SFIr32 (XSHWr16 (XSBHr8 R8C:$rB) ), 0))>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002655
2656// ROTHM r16 form: Rotate 16-bit quantity to right, zero fill at the left
2657// Note: This instruction doesn't match a pattern because rB must be negated
2658// for the instruction to work. Thus, the pattern below the instruction!
Scott Michel97872d32008-02-23 18:41:37 +00002659
Scott Michel8b6b4202007-12-04 22:35:58 +00002660def ROTHMr16:
Scott Michel97872d32008-02-23 18:41:37 +00002661 ROTHMInst<(outs R16C:$rT), (ins R16C:$rA, R32C:$rB),
2662 [/* see patterns below - $rB must be negated! */]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002663
2664def : Pat<(srl R16C:$rA, R32C:$rB),
2665 (ROTHMr16 R16C:$rA, (SFIr32 R32C:$rB, 0))>;
2666
2667def : Pat<(srl R16C:$rA, R16C:$rB),
2668 (ROTHMr16 R16C:$rA,
2669 (SFIr32 (XSHWr16 R16C:$rB), 0))>;
2670
Scott Michel438be252007-12-17 22:32:34 +00002671def : Pat<(srl R16C:$rA, R8C:$rB),
Scott Michel8b6b4202007-12-04 22:35:58 +00002672 (ROTHMr16 R16C:$rA,
Scott Michel438be252007-12-17 22:32:34 +00002673 (SFIr32 (XSHWr16 (XSBHr8 R8C:$rB) ), 0))>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002674
2675// ROTHMI v8i16 form: See the comment for ROTHM v8i16. The difference here is
2676// that the immediate can be complemented, so that the user doesn't have to
2677// worry about it.
Scott Michel8b6b4202007-12-04 22:35:58 +00002678
Scott Michel97872d32008-02-23 18:41:37 +00002679class ROTHMIInst<dag OOL, dag IOL, list<dag> pattern>:
2680 RI7Form<0b10111110000, OOL, IOL, "rothmi\t$rT, $rA, $val",
2681 RotateShift, pattern>;
2682
2683def ROTHMIv8i16:
2684 ROTHMIInst<(outs VECREG:$rT), (ins VECREG:$rA, rothNeg7imm:$val),
2685 [/* no pattern */]>;
2686
2687def : Pat<(SPUvec_srl (v8i16 VECREG:$rA), (i32 imm:$val)),
2688 (ROTHMIv8i16 VECREG:$rA, imm:$val)>;
2689
2690def: Pat<(SPUvec_srl (v8i16 VECREG:$rA), (i16 imm:$val)),
Scott Michel8b6b4202007-12-04 22:35:58 +00002691 (ROTHMIv8i16 VECREG:$rA, imm:$val)>;
Scott Michel06eabde2008-12-27 04:51:36 +00002692
Scott Michel97872d32008-02-23 18:41:37 +00002693def: Pat<(SPUvec_srl (v8i16 VECREG:$rA), (i8 imm:$val)),
Scott Michel5a6f17b2008-01-30 02:55:46 +00002694 (ROTHMIv8i16 VECREG:$rA, imm:$val)>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002695
2696def ROTHMIr16:
Scott Michel97872d32008-02-23 18:41:37 +00002697 ROTHMIInst<(outs R16C:$rT), (ins R16C:$rA, rothNeg7imm:$val),
2698 [/* no pattern */]>;
2699
2700def: Pat<(srl R16C:$rA, (i32 uimm7:$val)),
2701 (ROTHMIr16 R16C:$rA, uimm7:$val)>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002702
2703def: Pat<(srl R16C:$rA, (i16 uimm7:$val)),
2704 (ROTHMIr16 R16C:$rA, uimm7:$val)>;
2705
Scott Michel438be252007-12-17 22:32:34 +00002706def: Pat<(srl R16C:$rA, (i8 uimm7:$val)),
2707 (ROTHMIr16 R16C:$rA, uimm7:$val)>;
2708
Scott Michel8b6b4202007-12-04 22:35:58 +00002709// ROTM v4i32 form: See the ROTHM v8i16 comments.
Scott Michel97872d32008-02-23 18:41:37 +00002710class ROTMInst<dag OOL, dag IOL, list<dag> pattern>:
2711 RRForm<0b10011010000, OOL, IOL, "rotm\t$rT, $rA, $rB",
2712 RotateShift, pattern>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002713
Scott Michel97872d32008-02-23 18:41:37 +00002714def ROTMv4i32:
2715 ROTMInst<(outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB),
2716 [/* see patterns below - $rB must be negated */]>;
2717
2718def : Pat<(SPUvec_srl VECREG:$rA, R32C:$rB),
Scott Michel8b6b4202007-12-04 22:35:58 +00002719 (ROTMv4i32 VECREG:$rA, (SFIr32 R32C:$rB, 0))>;
2720
Scott Michel97872d32008-02-23 18:41:37 +00002721def : Pat<(SPUvec_srl VECREG:$rA, R16C:$rB),
Scott Michel8b6b4202007-12-04 22:35:58 +00002722 (ROTMv4i32 VECREG:$rA,
2723 (SFIr32 (XSHWr16 R16C:$rB), 0))>;
2724
Scott Michel97872d32008-02-23 18:41:37 +00002725def : Pat<(SPUvec_srl VECREG:$rA, R8C:$rB),
Scott Michel8b6b4202007-12-04 22:35:58 +00002726 (ROTMv4i32 VECREG:$rA,
Scott Michel97872d32008-02-23 18:41:37 +00002727 (SFIr32 (XSHWr16 (XSBHr8 R8C:$rB)), 0))>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002728
2729def ROTMr32:
Scott Michel97872d32008-02-23 18:41:37 +00002730 ROTMInst<(outs R32C:$rT), (ins R32C:$rA, R32C:$rB),
2731 [/* see patterns below - $rB must be negated */]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002732
2733def : Pat<(srl R32C:$rA, R32C:$rB),
2734 (ROTMr32 R32C:$rA, (SFIr32 R32C:$rB, 0))>;
2735
2736def : Pat<(srl R32C:$rA, R16C:$rB),
2737 (ROTMr32 R32C:$rA,
2738 (SFIr32 (XSHWr16 R16C:$rB), 0))>;
2739
Scott Michel438be252007-12-17 22:32:34 +00002740def : Pat<(srl R32C:$rA, R8C:$rB),
2741 (ROTMr32 R32C:$rA,
2742 (SFIr32 (XSHWr16 (XSBHr8 R8C:$rB)), 0))>;
2743
Scott Michel8b6b4202007-12-04 22:35:58 +00002744// ROTMI v4i32 form: See the comment for ROTHM v8i16.
2745def ROTMIv4i32:
2746 RI7Form<0b10011110000, (outs VECREG:$rT), (ins VECREG:$rA, rotNeg7imm:$val),
2747 "rotmi\t$rT, $rA, $val", RotateShift,
2748 [(set (v4i32 VECREG:$rT),
Scott Michel97872d32008-02-23 18:41:37 +00002749 (SPUvec_srl VECREG:$rA, (i32 uimm7:$val)))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002750
Scott Michel97872d32008-02-23 18:41:37 +00002751def : Pat<(SPUvec_srl VECREG:$rA, (i16 uimm7:$val)),
Scott Michel8b6b4202007-12-04 22:35:58 +00002752 (ROTMIv4i32 VECREG:$rA, uimm7:$val)>;
Scott Michel06eabde2008-12-27 04:51:36 +00002753
Scott Michel97872d32008-02-23 18:41:37 +00002754def : Pat<(SPUvec_srl VECREG:$rA, (i8 uimm7:$val)),
Scott Michel438be252007-12-17 22:32:34 +00002755 (ROTMIv4i32 VECREG:$rA, uimm7:$val)>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002756
2757// ROTMI r32 form: know how to complement the immediate value.
2758def ROTMIr32:
2759 RI7Form<0b10011110000, (outs R32C:$rT), (ins R32C:$rA, rotNeg7imm:$val),
2760 "rotmi\t$rT, $rA, $val", RotateShift,
2761 [(set R32C:$rT, (srl R32C:$rA, (i32 uimm7:$val)))]>;
2762
2763def : Pat<(srl R32C:$rA, (i16 imm:$val)),
2764 (ROTMIr32 R32C:$rA, uimm7:$val)>;
2765
Scott Michel438be252007-12-17 22:32:34 +00002766def : Pat<(srl R32C:$rA, (i8 imm:$val)),
2767 (ROTMIr32 R32C:$rA, uimm7:$val)>;
2768
Scott Michel97872d32008-02-23 18:41:37 +00002769//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
Scott Michel2ef773a2009-01-06 03:36:14 +00002770// ROTQMBY: This is a vector form merely so that when used in an
Scott Michel8b6b4202007-12-04 22:35:58 +00002771// instruction pattern, type checking will succeed. This instruction assumes
Scott Michel97872d32008-02-23 18:41:37 +00002772// that the user knew to negate $rB.
Scott Michel97872d32008-02-23 18:41:37 +00002773//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
Scott Michel8b6b4202007-12-04 22:35:58 +00002774
Scott Michel97872d32008-02-23 18:41:37 +00002775class ROTQMBYInst<dag OOL, dag IOL, list<dag> pattern>:
2776 RRForm<0b10111011100, OOL, IOL, "rotqmby\t$rT, $rA, $rB",
2777 RotateShift, pattern>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002778
Scott Michel97872d32008-02-23 18:41:37 +00002779class ROTQMBYVecInst<ValueType vectype>:
2780 ROTQMBYInst<(outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB),
2781 [/* no pattern, $rB must be negated */]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002782
Scott Michel97872d32008-02-23 18:41:37 +00002783class ROTQMBYRegInst<RegisterClass rclass>:
2784 ROTQMBYInst<(outs rclass:$rT), (ins rclass:$rA, R32C:$rB),
Scott Michel4d07fb72008-12-30 23:28:25 +00002785 [/* no pattern */]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002786
Scott Michel97872d32008-02-23 18:41:37 +00002787multiclass RotateQuadBytes
2788{
2789 def v16i8: ROTQMBYVecInst<v16i8>;
2790 def v8i16: ROTQMBYVecInst<v8i16>;
2791 def v4i32: ROTQMBYVecInst<v4i32>;
2792 def v2i64: ROTQMBYVecInst<v2i64>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002793
Scott Michel97872d32008-02-23 18:41:37 +00002794 def r128: ROTQMBYRegInst<GPRC>;
2795 def r64: ROTQMBYRegInst<R64C>;
2796}
2797
2798defm ROTQMBY : RotateQuadBytes;
2799
Scott Michel97872d32008-02-23 18:41:37 +00002800class ROTQMBYIInst<dag OOL, dag IOL, list<dag> pattern>:
2801 RI7Form<0b10111111100, OOL, IOL, "rotqmbyi\t$rT, $rA, $val",
2802 RotateShift, pattern>;
2803
2804class ROTQMBYIVecInst<ValueType vectype>:
2805 ROTQMBYIInst<(outs VECREG:$rT), (ins VECREG:$rA, rotNeg7imm:$val),
Scott Michel4d07fb72008-12-30 23:28:25 +00002806 [/* no pattern */]>;
Scott Michel97872d32008-02-23 18:41:37 +00002807
Scott Michel2ef773a2009-01-06 03:36:14 +00002808class ROTQMBYIRegInst<RegisterClass rclass, Operand optype, ValueType inttype,
2809 PatLeaf pred>:
Scott Michel97872d32008-02-23 18:41:37 +00002810 ROTQMBYIInst<(outs rclass:$rT), (ins rclass:$rA, optype:$val),
Scott Michel4d07fb72008-12-30 23:28:25 +00002811 [/* no pattern */]>;
Scott Michel97872d32008-02-23 18:41:37 +00002812
Scott Michel2ef773a2009-01-06 03:36:14 +00002813// 128-bit zero extension form:
2814class ROTQMBYIZExtInst<RegisterClass rclass, Operand optype, PatLeaf pred>:
2815 ROTQMBYIInst<(outs GPRC:$rT), (ins rclass:$rA, optype:$val),
2816 [/* no pattern */]>;
2817
Scott Michel97872d32008-02-23 18:41:37 +00002818multiclass RotateQuadBytesImm
2819{
2820 def v16i8: ROTQMBYIVecInst<v16i8>;
2821 def v8i16: ROTQMBYIVecInst<v8i16>;
2822 def v4i32: ROTQMBYIVecInst<v4i32>;
2823 def v2i64: ROTQMBYIVecInst<v2i64>;
2824
2825 def r128: ROTQMBYIRegInst<GPRC, rotNeg7imm, i32, uimm7>;
2826 def r64: ROTQMBYIRegInst<R64C, rotNeg7imm, i32, uimm7>;
Scott Michel2ef773a2009-01-06 03:36:14 +00002827
2828 def r128_zext_r8: ROTQMBYIZExtInst<R8C, rotNeg7imm, uimm7>;
2829 def r128_zext_r16: ROTQMBYIZExtInst<R16C, rotNeg7imm, uimm7>;
2830 def r128_zext_r32: ROTQMBYIZExtInst<R32C, rotNeg7imm, uimm7>;
2831 def r128_zext_r64: ROTQMBYIZExtInst<R64C, rotNeg7imm, uimm7>;
Scott Michel97872d32008-02-23 18:41:37 +00002832}
2833
2834defm ROTQMBYI : RotateQuadBytesImm;
2835
Scott Michel97872d32008-02-23 18:41:37 +00002836//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2837// Rotate right and mask by bit count
2838//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2839
2840class ROTQMBYBIInst<dag OOL, dag IOL, list<dag> pattern>:
2841 RRForm<0b10110011100, OOL, IOL, "rotqmbybi\t$rT, $rA, $rB",
2842 RotateShift, pattern>;
2843
2844class ROTQMBYBIVecInst<ValueType vectype>:
Scott Michel4d07fb72008-12-30 23:28:25 +00002845 ROTQMBYBIInst<(outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB),
2846 [/* no pattern, */]>;
Scott Michel97872d32008-02-23 18:41:37 +00002847
2848multiclass RotateMaskQuadByBitCount
2849{
2850 def v16i8: ROTQMBYBIVecInst<v16i8>;
2851 def v8i16: ROTQMBYBIVecInst<v8i16>;
2852 def v4i32: ROTQMBYBIVecInst<v4i32>;
2853 def v2i64: ROTQMBYBIVecInst<v2i64>;
2854}
2855
2856defm ROTQMBYBI: RotateMaskQuadByBitCount;
2857
2858//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2859// Rotate quad and mask by bits
2860// Note that the rotate amount has to be negated
2861//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2862
2863class ROTQMBIInst<dag OOL, dag IOL, list<dag> pattern>:
2864 RRForm<0b10011011100, OOL, IOL, "rotqmbi\t$rT, $rA, $rB",
2865 RotateShift, pattern>;
2866
2867class ROTQMBIVecInst<ValueType vectype>:
2868 ROTQMBIInst<(outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB),
2869 [/* no pattern */]>;
2870
2871class ROTQMBIRegInst<RegisterClass rclass>:
2872 ROTQMBIInst<(outs rclass:$rT), (ins rclass:$rA, R32C:$rB),
2873 [/* no pattern */]>;
2874
2875multiclass RotateMaskQuadByBits
2876{
2877 def v16i8: ROTQMBIVecInst<v16i8>;
2878 def v8i16: ROTQMBIVecInst<v8i16>;
2879 def v4i32: ROTQMBIVecInst<v4i32>;
2880 def v2i64: ROTQMBIVecInst<v2i64>;
2881
2882 def r128: ROTQMBIRegInst<GPRC>;
2883 def r64: ROTQMBIRegInst<R64C>;
2884}
2885
2886defm ROTQMBI: RotateMaskQuadByBits;
2887
Scott Michel97872d32008-02-23 18:41:37 +00002888//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2889// Rotate quad and mask by bits, immediate
2890//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2891
2892class ROTQMBIIInst<dag OOL, dag IOL, list<dag> pattern>:
2893 RI7Form<0b10011111100, OOL, IOL, "rotqmbii\t$rT, $rA, $val",
2894 RotateShift, pattern>;
2895
2896class ROTQMBIIVecInst<ValueType vectype>:
2897 ROTQMBIIInst<(outs VECREG:$rT), (ins VECREG:$rA, rotNeg7imm:$val),
Scott Michel4d07fb72008-12-30 23:28:25 +00002898 [/* no pattern */]>;
Scott Michel97872d32008-02-23 18:41:37 +00002899
2900class ROTQMBIIRegInst<RegisterClass rclass>:
2901 ROTQMBIIInst<(outs rclass:$rT), (ins rclass:$rA, rotNeg7imm:$val),
Scott Michel4d07fb72008-12-30 23:28:25 +00002902 [/* no pattern */]>;
Scott Michel97872d32008-02-23 18:41:37 +00002903
2904multiclass RotateMaskQuadByBitsImm
2905{
2906 def v16i8: ROTQMBIIVecInst<v16i8>;
2907 def v8i16: ROTQMBIIVecInst<v8i16>;
2908 def v4i32: ROTQMBIIVecInst<v4i32>;
2909 def v2i64: ROTQMBIIVecInst<v2i64>;
2910
2911 def r128: ROTQMBIIRegInst<GPRC>;
2912 def r64: ROTQMBIIRegInst<R64C>;
2913}
2914
2915defm ROTQMBII: RotateMaskQuadByBitsImm;
2916
2917//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2918//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
Scott Michel8b6b4202007-12-04 22:35:58 +00002919
2920def ROTMAHv8i16:
2921 RRForm<0b01111010000, (outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB),
2922 "rotmah\t$rT, $rA, $rB", RotateShift,
2923 [/* see patterns below - $rB must be negated */]>;
2924
Scott Michel97872d32008-02-23 18:41:37 +00002925def : Pat<(SPUvec_sra VECREG:$rA, R32C:$rB),
Scott Michel8b6b4202007-12-04 22:35:58 +00002926 (ROTMAHv8i16 VECREG:$rA, (SFIr32 R32C:$rB, 0))>;
2927
Scott Michel97872d32008-02-23 18:41:37 +00002928def : Pat<(SPUvec_sra VECREG:$rA, R16C:$rB),
Scott Michel8b6b4202007-12-04 22:35:58 +00002929 (ROTMAHv8i16 VECREG:$rA,
2930 (SFIr32 (XSHWr16 R16C:$rB), 0))>;
2931
Scott Michel97872d32008-02-23 18:41:37 +00002932def : Pat<(SPUvec_sra VECREG:$rA, R8C:$rB),
Scott Michel438be252007-12-17 22:32:34 +00002933 (ROTMAHv8i16 VECREG:$rA,
2934 (SFIr32 (XSHWr16 (XSBHr8 R8C:$rB)), 0))>;
2935
Scott Michel8b6b4202007-12-04 22:35:58 +00002936def ROTMAHr16:
2937 RRForm<0b01111010000, (outs R16C:$rT), (ins R16C:$rA, R32C:$rB),
2938 "rotmah\t$rT, $rA, $rB", RotateShift,
2939 [/* see patterns below - $rB must be negated */]>;
2940
2941def : Pat<(sra R16C:$rA, R32C:$rB),
2942 (ROTMAHr16 R16C:$rA, (SFIr32 R32C:$rB, 0))>;
2943
2944def : Pat<(sra R16C:$rA, R16C:$rB),
2945 (ROTMAHr16 R16C:$rA,
2946 (SFIr32 (XSHWr16 R16C:$rB), 0))>;
2947
Scott Michel438be252007-12-17 22:32:34 +00002948def : Pat<(sra R16C:$rA, R8C:$rB),
2949 (ROTMAHr16 R16C:$rA,
2950 (SFIr32 (XSHWr16 (XSBHr8 R8C:$rB)), 0))>;
2951
Scott Michel8b6b4202007-12-04 22:35:58 +00002952def ROTMAHIv8i16:
2953 RRForm<0b01111110000, (outs VECREG:$rT), (ins VECREG:$rA, rothNeg7imm:$val),
2954 "rotmahi\t$rT, $rA, $val", RotateShift,
2955 [(set (v8i16 VECREG:$rT),
Scott Michel97872d32008-02-23 18:41:37 +00002956 (SPUvec_sra (v8i16 VECREG:$rA), (i32 uimm7:$val)))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00002957
Scott Michel97872d32008-02-23 18:41:37 +00002958def : Pat<(SPUvec_sra (v8i16 VECREG:$rA), (i16 uimm7:$val)),
Scott Michel8b6b4202007-12-04 22:35:58 +00002959 (ROTMAHIv8i16 (v8i16 VECREG:$rA), (i32 uimm7:$val))>;
2960
Scott Michel97872d32008-02-23 18:41:37 +00002961def : Pat<(SPUvec_sra (v8i16 VECREG:$rA), (i8 uimm7:$val)),
Scott Michel438be252007-12-17 22:32:34 +00002962 (ROTMAHIv8i16 (v8i16 VECREG:$rA), (i32 uimm7:$val))>;
2963
Scott Michel8b6b4202007-12-04 22:35:58 +00002964def ROTMAHIr16:
2965 RRForm<0b01111110000, (outs R16C:$rT), (ins R16C:$rA, rothNeg7imm_i16:$val),
2966 "rotmahi\t$rT, $rA, $val", RotateShift,
2967 [(set R16C:$rT, (sra R16C:$rA, (i16 uimm7:$val)))]>;
2968
2969def : Pat<(sra R16C:$rA, (i32 imm:$val)),
2970 (ROTMAHIr16 R16C:$rA, uimm7:$val)>;
2971
Scott Michel438be252007-12-17 22:32:34 +00002972def : Pat<(sra R16C:$rA, (i8 imm:$val)),
2973 (ROTMAHIr16 R16C:$rA, uimm7:$val)>;
2974
Scott Michel8b6b4202007-12-04 22:35:58 +00002975def ROTMAv4i32:
2976 RRForm<0b01011010000, (outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB),
2977 "rotma\t$rT, $rA, $rB", RotateShift,
2978 [/* see patterns below - $rB must be negated */]>;
2979
Scott Michel97872d32008-02-23 18:41:37 +00002980def : Pat<(SPUvec_sra VECREG:$rA, R32C:$rB),
Scott Michel8b6b4202007-12-04 22:35:58 +00002981 (ROTMAv4i32 (v4i32 VECREG:$rA), (SFIr32 R32C:$rB, 0))>;
2982
Scott Michel97872d32008-02-23 18:41:37 +00002983def : Pat<(SPUvec_sra VECREG:$rA, R16C:$rB),
Scott Michel8b6b4202007-12-04 22:35:58 +00002984 (ROTMAv4i32 (v4i32 VECREG:$rA),
2985 (SFIr32 (XSHWr16 R16C:$rB), 0))>;
2986
Scott Michel97872d32008-02-23 18:41:37 +00002987def : Pat<(SPUvec_sra VECREG:$rA, R8C:$rB),
Scott Michel438be252007-12-17 22:32:34 +00002988 (ROTMAv4i32 (v4i32 VECREG:$rA),
2989 (SFIr32 (XSHWr16 (XSBHr8 R8C:$rB)), 0))>;
2990
Scott Michel8b6b4202007-12-04 22:35:58 +00002991def ROTMAr32:
2992 RRForm<0b01011010000, (outs R32C:$rT), (ins R32C:$rA, R32C:$rB),
2993 "rotma\t$rT, $rA, $rB", RotateShift,
2994 [/* see patterns below - $rB must be negated */]>;
2995
2996def : Pat<(sra R32C:$rA, R32C:$rB),
2997 (ROTMAr32 R32C:$rA, (SFIr32 R32C:$rB, 0))>;
2998
2999def : Pat<(sra R32C:$rA, R16C:$rB),
3000 (ROTMAr32 R32C:$rA,
3001 (SFIr32 (XSHWr16 R16C:$rB), 0))>;
3002
Scott Michel438be252007-12-17 22:32:34 +00003003def : Pat<(sra R32C:$rA, R8C:$rB),
3004 (ROTMAr32 R32C:$rA,
3005 (SFIr32 (XSHWr16 (XSBHr8 R8C:$rB)), 0))>;
3006
Scott Michel67224b22008-06-02 22:18:03 +00003007class ROTMAIInst<dag OOL, dag IOL, list<dag> pattern>:
3008 RRForm<0b01011110000, OOL, IOL,
3009 "rotmai\t$rT, $rA, $val",
3010 RotateShift, pattern>;
Scott Michel8b6b4202007-12-04 22:35:58 +00003011
Scott Michel67224b22008-06-02 22:18:03 +00003012class ROTMAIVecInst<ValueType vectype, Operand intop, ValueType inttype>:
3013 ROTMAIInst<(outs VECREG:$rT), (ins VECREG:$rA, intop:$val),
3014 [(set (vectype VECREG:$rT),
3015 (SPUvec_sra VECREG:$rA, (inttype uimm7:$val)))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00003016
Scott Michel67224b22008-06-02 22:18:03 +00003017class ROTMAIRegInst<RegisterClass rclass, Operand intop, ValueType inttype>:
3018 ROTMAIInst<(outs rclass:$rT), (ins rclass:$rA, intop:$val),
3019 [(set rclass:$rT, (sra rclass:$rA, (inttype uimm7:$val)))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00003020
Scott Michel67224b22008-06-02 22:18:03 +00003021multiclass RotateMaskAlgebraicImm {
3022 def v2i64_i32 : ROTMAIVecInst<v2i64, rotNeg7imm, i32>;
3023 def v4i32_i32 : ROTMAIVecInst<v4i32, rotNeg7imm, i32>;
3024 def r64_i32 : ROTMAIRegInst<R64C, rotNeg7imm, i32>;
3025 def r32_i32 : ROTMAIRegInst<R32C, rotNeg7imm, i32>;
3026}
Scott Michel8b6b4202007-12-04 22:35:58 +00003027
Scott Michel67224b22008-06-02 22:18:03 +00003028defm ROTMAI : RotateMaskAlgebraicImm;
Scott Michel438be252007-12-17 22:32:34 +00003029
Scott Michel8b6b4202007-12-04 22:35:58 +00003030//===----------------------------------------------------------------------===//
3031// Branch and conditionals:
3032//===----------------------------------------------------------------------===//
3033
3034let isTerminator = 1, isBarrier = 1 in {
3035 // Halt If Equal (r32 preferred slot only, no vector form)
3036 def HEQr32:
3037 RRForm_3<0b00011011110, (outs), (ins R32C:$rA, R32C:$rB),
3038 "heq\t$rA, $rB", BranchResolv,
3039 [/* no pattern to match */]>;
3040
3041 def HEQIr32 :
3042 RI10Form_2<0b11111110, (outs), (ins R32C:$rA, s10imm:$val),
3043 "heqi\t$rA, $val", BranchResolv,
3044 [/* no pattern to match */]>;
3045
3046 // HGT/HGTI: These instructions use signed arithmetic for the comparison,
3047 // contrasting with HLGT/HLGTI, which use unsigned comparison:
3048 def HGTr32:
3049 RRForm_3<0b00011010010, (outs), (ins R32C:$rA, R32C:$rB),
3050 "hgt\t$rA, $rB", BranchResolv,
3051 [/* no pattern to match */]>;
3052
Scott Michel06eabde2008-12-27 04:51:36 +00003053 def HGTIr32:
Scott Michel8b6b4202007-12-04 22:35:58 +00003054 RI10Form_2<0b11110010, (outs), (ins R32C:$rA, s10imm:$val),
3055 "hgti\t$rA, $val", BranchResolv,
3056 [/* no pattern to match */]>;
3057
3058 def HLGTr32:
3059 RRForm_3<0b00011011010, (outs), (ins R32C:$rA, R32C:$rB),
3060 "hlgt\t$rA, $rB", BranchResolv,
3061 [/* no pattern to match */]>;
3062
3063 def HLGTIr32:
3064 RI10Form_2<0b11111010, (outs), (ins R32C:$rA, s10imm:$val),
3065 "hlgti\t$rA, $val", BranchResolv,
3066 [/* no pattern to match */]>;
3067}
3068
Scott Michel06eabde2008-12-27 04:51:36 +00003069//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
3070// Comparison operators for i8, i16 and i32:
3071//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
Scott Michel8b6b4202007-12-04 22:35:58 +00003072
Scott Michel97872d32008-02-23 18:41:37 +00003073class CEQBInst<dag OOL, dag IOL, list<dag> pattern> :
3074 RRForm<0b00001011110, OOL, IOL, "ceqb\t$rT, $rA, $rB",
3075 ByteOp, pattern>;
Scott Michel8b6b4202007-12-04 22:35:58 +00003076
Scott Michel97872d32008-02-23 18:41:37 +00003077multiclass CmpEqualByte
3078{
3079 def v16i8 :
3080 CEQBInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
3081 [(set (v16i8 VECREG:$rT), (seteq (v8i16 VECREG:$rA),
3082 (v8i16 VECREG:$rB)))]>;
Scott Michel438be252007-12-17 22:32:34 +00003083
Scott Michel97872d32008-02-23 18:41:37 +00003084 def r8 :
3085 CEQBInst<(outs R8C:$rT), (ins R8C:$rA, R8C:$rB),
3086 [(set R8C:$rT, (seteq R8C:$rA, R8C:$rB))]>;
3087}
Scott Michel8b6b4202007-12-04 22:35:58 +00003088
Scott Michel97872d32008-02-23 18:41:37 +00003089class CEQBIInst<dag OOL, dag IOL, list<dag> pattern> :
3090 RI10Form<0b01111110, OOL, IOL, "ceqbi\t$rT, $rA, $val",
3091 ByteOp, pattern>;
Scott Michel8b6b4202007-12-04 22:35:58 +00003092
Scott Michel97872d32008-02-23 18:41:37 +00003093multiclass CmpEqualByteImm
3094{
3095 def v16i8 :
3096 CEQBIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm_i8:$val),
3097 [(set (v16i8 VECREG:$rT), (seteq (v16i8 VECREG:$rA),
3098 v16i8SExt8Imm:$val))]>;
3099 def r8:
3100 CEQBIInst<(outs R8C:$rT), (ins R8C:$rA, s10imm_i8:$val),
3101 [(set R8C:$rT, (seteq R8C:$rA, immSExt8:$val))]>;
3102}
Scott Michel8b6b4202007-12-04 22:35:58 +00003103
Scott Michel97872d32008-02-23 18:41:37 +00003104class CEQHInst<dag OOL, dag IOL, list<dag> pattern> :
3105 RRForm<0b00010011110, OOL, IOL, "ceqh\t$rT, $rA, $rB",
3106 ByteOp, pattern>;
Scott Michel8b6b4202007-12-04 22:35:58 +00003107
Scott Michel97872d32008-02-23 18:41:37 +00003108multiclass CmpEqualHalfword
3109{
3110 def v8i16 : CEQHInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
3111 [(set (v8i16 VECREG:$rT), (seteq (v8i16 VECREG:$rA),
3112 (v8i16 VECREG:$rB)))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00003113
Scott Michel97872d32008-02-23 18:41:37 +00003114 def r16 : CEQHInst<(outs R16C:$rT), (ins R16C:$rA, R16C:$rB),
3115 [(set R16C:$rT, (seteq R16C:$rA, R16C:$rB))]>;
3116}
Scott Michel8b6b4202007-12-04 22:35:58 +00003117
Scott Michel97872d32008-02-23 18:41:37 +00003118class CEQHIInst<dag OOL, dag IOL, list<dag> pattern> :
3119 RI10Form<0b10111110, OOL, IOL, "ceqhi\t$rT, $rA, $val",
3120 ByteOp, pattern>;
Scott Michel8b6b4202007-12-04 22:35:58 +00003121
Scott Michel97872d32008-02-23 18:41:37 +00003122multiclass CmpEqualHalfwordImm
3123{
3124 def v8i16 : CEQHIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
3125 [(set (v8i16 VECREG:$rT),
3126 (seteq (v8i16 VECREG:$rA),
3127 (v8i16 v8i16SExt10Imm:$val)))]>;
3128 def r16 : CEQHIInst<(outs R16C:$rT), (ins R16C:$rA, s10imm:$val),
3129 [(set R16C:$rT, (seteq R16C:$rA, i16ImmSExt10:$val))]>;
3130}
Scott Michel8b6b4202007-12-04 22:35:58 +00003131
Scott Michel97872d32008-02-23 18:41:37 +00003132class CEQInst<dag OOL, dag IOL, list<dag> pattern> :
3133 RRForm<0b00000011110, OOL, IOL, "ceq\t$rT, $rA, $rB",
3134 ByteOp, pattern>;
3135
3136multiclass CmpEqualWord
3137{
3138 def v4i32 : CEQInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
3139 [(set (v4i32 VECREG:$rT),
3140 (seteq (v4i32 VECREG:$rA), (v4i32 VECREG:$rB)))]>;
3141
3142 def r32 : CEQInst<(outs R32C:$rT), (ins R32C:$rA, R32C:$rB),
3143 [(set R32C:$rT, (seteq R32C:$rA, R32C:$rB))]>;
3144}
3145
3146class CEQIInst<dag OOL, dag IOL, list<dag> pattern> :
3147 RI10Form<0b00111110, OOL, IOL, "ceqi\t$rT, $rA, $val",
3148 ByteOp, pattern>;
3149
3150multiclass CmpEqualWordImm
3151{
3152 def v4i32 : CEQIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
3153 [(set (v4i32 VECREG:$rT),
3154 (seteq (v4i32 VECREG:$rA),
3155 (v4i32 v4i32SExt16Imm:$val)))]>;
3156
3157 def r32: CEQIInst<(outs R32C:$rT), (ins R32C:$rA, s10imm_i32:$val),
3158 [(set R32C:$rT, (seteq R32C:$rA, i32ImmSExt10:$val))]>;
3159}
3160
3161class CGTBInst<dag OOL, dag IOL, list<dag> pattern> :
3162 RRForm<0b00001010010, OOL, IOL, "cgtb\t$rT, $rA, $rB",
3163 ByteOp, pattern>;
3164
3165multiclass CmpGtrByte
3166{
3167 def v16i8 :
3168 CGTBInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
3169 [(set (v16i8 VECREG:$rT), (setgt (v8i16 VECREG:$rA),
3170 (v8i16 VECREG:$rB)))]>;
3171
3172 def r8 :
3173 CGTBInst<(outs R8C:$rT), (ins R8C:$rA, R8C:$rB),
3174 [(set R8C:$rT, (setgt R8C:$rA, R8C:$rB))]>;
3175}
3176
3177class CGTBIInst<dag OOL, dag IOL, list<dag> pattern> :
3178 RI10Form<0b01110010, OOL, IOL, "cgtbi\t$rT, $rA, $val",
3179 ByteOp, pattern>;
3180
3181multiclass CmpGtrByteImm
3182{
3183 def v16i8 :
3184 CGTBIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm_i8:$val),
3185 [(set (v16i8 VECREG:$rT), (setgt (v16i8 VECREG:$rA),
3186 v16i8SExt8Imm:$val))]>;
3187 def r8:
3188 CGTBIInst<(outs R8C:$rT), (ins R8C:$rA, s10imm_i8:$val),
Scott Michel7833d472008-03-20 00:51:36 +00003189 [(set R8C:$rT, (setgt R8C:$rA, immSExt8:$val))]>;
Scott Michel97872d32008-02-23 18:41:37 +00003190}
3191
3192class CGTHInst<dag OOL, dag IOL, list<dag> pattern> :
3193 RRForm<0b00010010010, OOL, IOL, "cgth\t$rT, $rA, $rB",
3194 ByteOp, pattern>;
3195
3196multiclass CmpGtrHalfword
3197{
3198 def v8i16 : CGTHInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
3199 [(set (v8i16 VECREG:$rT), (setgt (v8i16 VECREG:$rA),
3200 (v8i16 VECREG:$rB)))]>;
3201
3202 def r16 : CGTHInst<(outs R16C:$rT), (ins R16C:$rA, R16C:$rB),
3203 [(set R16C:$rT, (setgt R16C:$rA, R16C:$rB))]>;
3204}
3205
3206class CGTHIInst<dag OOL, dag IOL, list<dag> pattern> :
3207 RI10Form<0b10110010, OOL, IOL, "cgthi\t$rT, $rA, $val",
3208 ByteOp, pattern>;
3209
3210multiclass CmpGtrHalfwordImm
3211{
3212 def v8i16 : CGTHIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
3213 [(set (v8i16 VECREG:$rT),
3214 (setgt (v8i16 VECREG:$rA),
3215 (v8i16 v8i16SExt10Imm:$val)))]>;
3216 def r16 : CGTHIInst<(outs R16C:$rT), (ins R16C:$rA, s10imm:$val),
3217 [(set R16C:$rT, (setgt R16C:$rA, i16ImmSExt10:$val))]>;
3218}
3219
3220class CGTInst<dag OOL, dag IOL, list<dag> pattern> :
3221 RRForm<0b00000010010, OOL, IOL, "cgt\t$rT, $rA, $rB",
3222 ByteOp, pattern>;
3223
3224multiclass CmpGtrWord
3225{
3226 def v4i32 : CGTInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
3227 [(set (v4i32 VECREG:$rT),
3228 (setgt (v4i32 VECREG:$rA), (v4i32 VECREG:$rB)))]>;
3229
3230 def r32 : CGTInst<(outs R32C:$rT), (ins R32C:$rA, R32C:$rB),
3231 [(set R32C:$rT, (setgt R32C:$rA, R32C:$rB))]>;
3232}
3233
3234class CGTIInst<dag OOL, dag IOL, list<dag> pattern> :
3235 RI10Form<0b00110010, OOL, IOL, "cgti\t$rT, $rA, $val",
3236 ByteOp, pattern>;
3237
3238multiclass CmpGtrWordImm
3239{
3240 def v4i32 : CGTIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
3241 [(set (v4i32 VECREG:$rT),
3242 (setgt (v4i32 VECREG:$rA),
3243 (v4i32 v4i32SExt16Imm:$val)))]>;
3244
3245 def r32: CGTIInst<(outs R32C:$rT), (ins R32C:$rA, s10imm_i32:$val),
3246 [(set R32C:$rT, (setgt R32C:$rA, i32ImmSExt10:$val))]>;
Scott Michel4d07fb72008-12-30 23:28:25 +00003247
3248 // CGTIv4f32, CGTIf32: These are used in the f32 fdiv instruction sequence:
3249 def v4f32: CGTIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
3250 [(set (v4i32 VECREG:$rT),
3251 (setgt (v4i32 (bitconvert (v4f32 VECREG:$rA))),
3252 (v4i32 v4i32SExt16Imm:$val)))]>;
3253
3254 def f32: CGTIInst<(outs R32C:$rT), (ins R32FP:$rA, s10imm_i32:$val),
pingbakb8913342009-01-26 03:37:41 +00003255 [/* no pattern */]>;
Scott Michel97872d32008-02-23 18:41:37 +00003256}
3257
3258class CLGTBInst<dag OOL, dag IOL, list<dag> pattern> :
Scott Michel6baba072008-03-05 23:02:02 +00003259 RRForm<0b00001011010, OOL, IOL, "clgtb\t$rT, $rA, $rB",
Scott Michel97872d32008-02-23 18:41:37 +00003260 ByteOp, pattern>;
3261
3262multiclass CmpLGtrByte
3263{
3264 def v16i8 :
3265 CLGTBInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
3266 [(set (v16i8 VECREG:$rT), (setugt (v8i16 VECREG:$rA),
3267 (v8i16 VECREG:$rB)))]>;
3268
3269 def r8 :
3270 CLGTBInst<(outs R8C:$rT), (ins R8C:$rA, R8C:$rB),
3271 [(set R8C:$rT, (setugt R8C:$rA, R8C:$rB))]>;
3272}
3273
3274class CLGTBIInst<dag OOL, dag IOL, list<dag> pattern> :
Scott Michel6baba072008-03-05 23:02:02 +00003275 RI10Form<0b01111010, OOL, IOL, "clgtbi\t$rT, $rA, $val",
Scott Michel97872d32008-02-23 18:41:37 +00003276 ByteOp, pattern>;
3277
3278multiclass CmpLGtrByteImm
3279{
3280 def v16i8 :
3281 CLGTBIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm_i8:$val),
3282 [(set (v16i8 VECREG:$rT), (setugt (v16i8 VECREG:$rA),
3283 v16i8SExt8Imm:$val))]>;
3284 def r8:
3285 CLGTBIInst<(outs R8C:$rT), (ins R8C:$rA, s10imm_i8:$val),
3286 [(set R8C:$rT, (setugt R8C:$rA, immSExt8:$val))]>;
3287}
3288
3289class CLGTHInst<dag OOL, dag IOL, list<dag> pattern> :
Scott Michel6baba072008-03-05 23:02:02 +00003290 RRForm<0b00010011010, OOL, IOL, "clgth\t$rT, $rA, $rB",
Scott Michel97872d32008-02-23 18:41:37 +00003291 ByteOp, pattern>;
3292
3293multiclass CmpLGtrHalfword
3294{
3295 def v8i16 : CLGTHInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
3296 [(set (v8i16 VECREG:$rT), (setugt (v8i16 VECREG:$rA),
3297 (v8i16 VECREG:$rB)))]>;
3298
3299 def r16 : CLGTHInst<(outs R16C:$rT), (ins R16C:$rA, R16C:$rB),
3300 [(set R16C:$rT, (setugt R16C:$rA, R16C:$rB))]>;
3301}
3302
3303class CLGTHIInst<dag OOL, dag IOL, list<dag> pattern> :
Scott Michel6baba072008-03-05 23:02:02 +00003304 RI10Form<0b10111010, OOL, IOL, "clgthi\t$rT, $rA, $val",
Scott Michel97872d32008-02-23 18:41:37 +00003305 ByteOp, pattern>;
3306
3307multiclass CmpLGtrHalfwordImm
3308{
3309 def v8i16 : CLGTHIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
3310 [(set (v8i16 VECREG:$rT),
3311 (setugt (v8i16 VECREG:$rA),
3312 (v8i16 v8i16SExt10Imm:$val)))]>;
3313 def r16 : CLGTHIInst<(outs R16C:$rT), (ins R16C:$rA, s10imm:$val),
3314 [(set R16C:$rT, (setugt R16C:$rA, i16ImmSExt10:$val))]>;
3315}
3316
3317class CLGTInst<dag OOL, dag IOL, list<dag> pattern> :
Scott Michel6baba072008-03-05 23:02:02 +00003318 RRForm<0b00000011010, OOL, IOL, "clgt\t$rT, $rA, $rB",
Scott Michel97872d32008-02-23 18:41:37 +00003319 ByteOp, pattern>;
3320
3321multiclass CmpLGtrWord
3322{
3323 def v4i32 : CLGTInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
3324 [(set (v4i32 VECREG:$rT),
3325 (setugt (v4i32 VECREG:$rA), (v4i32 VECREG:$rB)))]>;
3326
3327 def r32 : CLGTInst<(outs R32C:$rT), (ins R32C:$rA, R32C:$rB),
3328 [(set R32C:$rT, (setugt R32C:$rA, R32C:$rB))]>;
3329}
3330
3331class CLGTIInst<dag OOL, dag IOL, list<dag> pattern> :
Scott Michel6baba072008-03-05 23:02:02 +00003332 RI10Form<0b00111010, OOL, IOL, "clgti\t$rT, $rA, $val",
Scott Michel97872d32008-02-23 18:41:37 +00003333 ByteOp, pattern>;
3334
3335multiclass CmpLGtrWordImm
3336{
3337 def v4i32 : CLGTIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
3338 [(set (v4i32 VECREG:$rT),
3339 (setugt (v4i32 VECREG:$rA),
3340 (v4i32 v4i32SExt16Imm:$val)))]>;
3341
3342 def r32: CLGTIInst<(outs R32C:$rT), (ins R32C:$rA, s10imm_i32:$val),
Scott Michel6baba072008-03-05 23:02:02 +00003343 [(set R32C:$rT, (setugt R32C:$rA, i32ImmSExt10:$val))]>;
Scott Michel97872d32008-02-23 18:41:37 +00003344}
3345
3346defm CEQB : CmpEqualByte;
3347defm CEQBI : CmpEqualByteImm;
3348defm CEQH : CmpEqualHalfword;
3349defm CEQHI : CmpEqualHalfwordImm;
3350defm CEQ : CmpEqualWord;
3351defm CEQI : CmpEqualWordImm;
3352defm CGTB : CmpGtrByte;
3353defm CGTBI : CmpGtrByteImm;
3354defm CGTH : CmpGtrHalfword;
3355defm CGTHI : CmpGtrHalfwordImm;
3356defm CGT : CmpGtrWord;
3357defm CGTI : CmpGtrWordImm;
3358defm CLGTB : CmpLGtrByte;
3359defm CLGTBI : CmpLGtrByteImm;
3360defm CLGTH : CmpLGtrHalfword;
3361defm CLGTHI : CmpLGtrHalfwordImm;
3362defm CLGT : CmpLGtrWord;
3363defm CLGTI : CmpLGtrWordImm;
3364
Scott Michel53ab7792008-03-10 16:58:52 +00003365//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
Scott Michel97872d32008-02-23 18:41:37 +00003366// For SETCC primitives not supported above (setlt, setle, setge, etc.)
3367// define a pattern to generate the right code, as a binary operator
3368// (in a manner of speaking.)
Scott Michel53ab7792008-03-10 16:58:52 +00003369//
Scott Michel06eabde2008-12-27 04:51:36 +00003370// Notes:
3371// 1. This only matches the setcc set of conditionals. Special pattern
3372// matching is used for select conditionals.
3373//
3374// 2. The "DAG" versions of these classes is almost exclusively used for
3375// i64 comparisons. See the tblgen fundamentals documentation for what
3376// ".ResultInstrs[0]" means; see TargetSelectionDAG.td and the Pattern
3377// class for where ResultInstrs originates.
Scott Michel53ab7792008-03-10 16:58:52 +00003378//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
Scott Michel97872d32008-02-23 18:41:37 +00003379
Scott Michel53ab7792008-03-10 16:58:52 +00003380class SETCCNegCondReg<PatFrag cond, RegisterClass rclass, ValueType inttype,
3381 SPUInstr xorinst, SPUInstr cmpare>:
3382 Pat<(cond rclass:$rA, rclass:$rB),
3383 (xorinst (cmpare rclass:$rA, rclass:$rB), (inttype -1))>;
3384
3385class SETCCNegCondImm<PatFrag cond, RegisterClass rclass, ValueType inttype,
3386 PatLeaf immpred, SPUInstr xorinst, SPUInstr cmpare>:
3387 Pat<(cond rclass:$rA, (inttype immpred:$imm)),
3388 (xorinst (cmpare rclass:$rA, (inttype immpred:$imm)), (inttype -1))>;
3389
Scott Michel06eabde2008-12-27 04:51:36 +00003390def : SETCCNegCondReg<setne, R8C, i8, XORBIr8, CEQBr8>;
Scott Michel53ab7792008-03-10 16:58:52 +00003391def : SETCCNegCondImm<setne, R8C, i8, immSExt8, XORBIr8, CEQBIr8>;
3392
Scott Michel06eabde2008-12-27 04:51:36 +00003393def : SETCCNegCondReg<setne, R16C, i16, XORHIr16, CEQHr16>;
Scott Michel53ab7792008-03-10 16:58:52 +00003394def : SETCCNegCondImm<setne, R16C, i16, i16ImmSExt10, XORHIr16, CEQHIr16>;
3395
3396def : SETCCNegCondReg<setne, R32C, i32, XORIr32, CEQr32>;
3397def : SETCCNegCondImm<setne, R32C, i32, i32ImmSExt10, XORIr32, CEQIr32>;
Scott Michel97872d32008-02-23 18:41:37 +00003398
3399class SETCCBinOpReg<PatFrag cond, RegisterClass rclass,
3400 SPUInstr binop, SPUInstr cmpOp1, SPUInstr cmpOp2>:
3401 Pat<(cond rclass:$rA, rclass:$rB),
3402 (binop (cmpOp1 rclass:$rA, rclass:$rB),
3403 (cmpOp2 rclass:$rA, rclass:$rB))>;
3404
3405class SETCCBinOpImm<PatFrag cond, RegisterClass rclass, PatLeaf immpred,
3406 ValueType immtype,
3407 SPUInstr binop, SPUInstr cmpOp1, SPUInstr cmpOp2>:
3408 Pat<(cond rclass:$rA, (immtype immpred:$imm)),
3409 (binop (cmpOp1 rclass:$rA, (immtype immpred:$imm)),
3410 (cmpOp2 rclass:$rA, (immtype immpred:$imm)))>;
3411
Scott Michel53ab7792008-03-10 16:58:52 +00003412def : SETCCBinOpReg<setge, R8C, ORr8, CGTBr8, CEQBr8>;
3413def : SETCCBinOpImm<setge, R8C, immSExt8, i8, ORr8, CGTBIr8, CEQBIr8>;
3414def : SETCCBinOpReg<setlt, R8C, NORr8, CGTBr8, CEQBr8>;
3415def : SETCCBinOpImm<setlt, R8C, immSExt8, i8, NORr8, CGTBIr8, CEQBIr8>;
3416def : Pat<(setle R8C:$rA, R8C:$rB),
3417 (XORBIr8 (CGTBr8 R8C:$rA, R8C:$rB), 0xff)>;
3418def : Pat<(setle R8C:$rA, immU8:$imm),
3419 (XORBIr8 (CGTBIr8 R8C:$rA, immU8:$imm), 0xff)>;
Scott Michel97872d32008-02-23 18:41:37 +00003420
Scott Michel53ab7792008-03-10 16:58:52 +00003421def : SETCCBinOpReg<setge, R16C, ORr16, CGTHr16, CEQHr16>;
3422def : SETCCBinOpImm<setge, R16C, i16ImmSExt10, i16,
3423 ORr16, CGTHIr16, CEQHIr16>;
3424def : SETCCBinOpReg<setlt, R16C, NORr16, CGTHr16, CEQHr16>;
3425def : SETCCBinOpImm<setlt, R16C, i16ImmSExt10, i16, NORr16, CGTHIr16, CEQHIr16>;
3426def : Pat<(setle R16C:$rA, R16C:$rB),
3427 (XORHIr16 (CGTHr16 R16C:$rA, R16C:$rB), 0xffff)>;
3428def : Pat<(setle R16C:$rA, i16ImmSExt10:$imm),
3429 (XORHIr16 (CGTHIr16 R16C:$rA, i16ImmSExt10:$imm), 0xffff)>;
Scott Michel97872d32008-02-23 18:41:37 +00003430
Scott Michel53ab7792008-03-10 16:58:52 +00003431def : SETCCBinOpReg<setge, R32C, ORr32, CGTr32, CEQr32>;
3432def : SETCCBinOpImm<setge, R32C, i32ImmSExt10, i32,
3433 ORr32, CGTIr32, CEQIr32>;
3434def : SETCCBinOpReg<setlt, R32C, NORr32, CGTr32, CEQr32>;
3435def : SETCCBinOpImm<setlt, R32C, i32ImmSExt10, i32, NORr32, CGTIr32, CEQIr32>;
3436def : Pat<(setle R32C:$rA, R32C:$rB),
3437 (XORIr32 (CGTr32 R32C:$rA, R32C:$rB), 0xffffffff)>;
3438def : Pat<(setle R32C:$rA, i32ImmSExt10:$imm),
3439 (XORIr32 (CGTIr32 R32C:$rA, i32ImmSExt10:$imm), 0xffffffff)>;
Scott Michel97872d32008-02-23 18:41:37 +00003440
Scott Michel53ab7792008-03-10 16:58:52 +00003441def : SETCCBinOpReg<setuge, R8C, ORr8, CLGTBr8, CEQBr8>;
3442def : SETCCBinOpImm<setuge, R8C, immSExt8, i8, ORr8, CLGTBIr8, CEQBIr8>;
3443def : SETCCBinOpReg<setult, R8C, NORr8, CLGTBr8, CEQBr8>;
3444def : SETCCBinOpImm<setult, R8C, immSExt8, i8, NORr8, CLGTBIr8, CEQBIr8>;
3445def : Pat<(setule R8C:$rA, R8C:$rB),
3446 (XORBIr8 (CLGTBr8 R8C:$rA, R8C:$rB), 0xff)>;
3447def : Pat<(setule R8C:$rA, immU8:$imm),
3448 (XORBIr8 (CLGTBIr8 R8C:$rA, immU8:$imm), 0xff)>;
Scott Michel97872d32008-02-23 18:41:37 +00003449
Scott Michel53ab7792008-03-10 16:58:52 +00003450def : SETCCBinOpReg<setuge, R16C, ORr16, CLGTHr16, CEQHr16>;
3451def : SETCCBinOpImm<setuge, R16C, i16ImmSExt10, i16,
3452 ORr16, CLGTHIr16, CEQHIr16>;
3453def : SETCCBinOpReg<setult, R16C, NORr16, CLGTHr16, CEQHr16>;
3454def : SETCCBinOpImm<setult, R16C, i16ImmSExt10, i16, NORr16,
3455 CLGTHIr16, CEQHIr16>;
3456def : Pat<(setule R16C:$rA, R16C:$rB),
3457 (XORHIr16 (CLGTHr16 R16C:$rA, R16C:$rB), 0xffff)>;
Scott Michel7833d472008-03-20 00:51:36 +00003458def : Pat<(setule R16C:$rA, i16ImmSExt10:$imm),
Scott Michel53ab7792008-03-10 16:58:52 +00003459 (XORHIr16 (CLGTHIr16 R16C:$rA, i16ImmSExt10:$imm), 0xffff)>;
Scott Michel97872d32008-02-23 18:41:37 +00003460
Scott Michel53ab7792008-03-10 16:58:52 +00003461def : SETCCBinOpReg<setuge, R32C, ORr32, CLGTr32, CEQr32>;
Scott Michel7833d472008-03-20 00:51:36 +00003462def : SETCCBinOpImm<setuge, R32C, i32ImmSExt10, i32,
Scott Michel53ab7792008-03-10 16:58:52 +00003463 ORr32, CLGTIr32, CEQIr32>;
3464def : SETCCBinOpReg<setult, R32C, NORr32, CLGTr32, CEQr32>;
Scott Michel7833d472008-03-20 00:51:36 +00003465def : SETCCBinOpImm<setult, R32C, i32ImmSExt10, i32, NORr32, CLGTIr32, CEQIr32>;
Scott Michel53ab7792008-03-10 16:58:52 +00003466def : Pat<(setule R32C:$rA, R32C:$rB),
3467 (XORIr32 (CLGTr32 R32C:$rA, R32C:$rB), 0xffffffff)>;
3468def : Pat<(setule R32C:$rA, i32ImmSExt10:$imm),
3469 (XORIr32 (CLGTIr32 R32C:$rA, i32ImmSExt10:$imm), 0xffffffff)>;
Scott Michel97872d32008-02-23 18:41:37 +00003470
Scott Michel53ab7792008-03-10 16:58:52 +00003471//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
3472// select conditional patterns:
3473//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
3474
3475class SELECTNegCondReg<PatFrag cond, RegisterClass rclass, ValueType inttype,
3476 SPUInstr selinstr, SPUInstr cmpare>:
3477 Pat<(select (inttype (cond rclass:$rA, rclass:$rB)),
3478 rclass:$rTrue, rclass:$rFalse),
3479 (selinstr rclass:$rTrue, rclass:$rFalse,
Bill Wendling8f6608b2008-07-22 08:50:44 +00003480 (cmpare rclass:$rA, rclass:$rB))>;
Scott Michel53ab7792008-03-10 16:58:52 +00003481
3482class SELECTNegCondImm<PatFrag cond, RegisterClass rclass, ValueType inttype,
3483 PatLeaf immpred, SPUInstr selinstr, SPUInstr cmpare>:
3484 Pat<(select (inttype (cond rclass:$rA, immpred:$imm)),
Bill Wendling8f6608b2008-07-22 08:50:44 +00003485 rclass:$rTrue, rclass:$rFalse),
Scott Michel53ab7792008-03-10 16:58:52 +00003486 (selinstr rclass:$rTrue, rclass:$rFalse,
3487 (cmpare rclass:$rA, immpred:$imm))>;
3488
3489def : SELECTNegCondReg<setne, R8C, i8, SELBr8, CEQBr8>;
3490def : SELECTNegCondImm<setne, R8C, i8, immSExt8, SELBr8, CEQBIr8>;
3491def : SELECTNegCondReg<setle, R8C, i8, SELBr8, CGTBr8>;
3492def : SELECTNegCondImm<setle, R8C, i8, immSExt8, SELBr8, CGTBr8>;
3493def : SELECTNegCondReg<setule, R8C, i8, SELBr8, CLGTBr8>;
3494def : SELECTNegCondImm<setule, R8C, i8, immU8, SELBr8, CLGTBIr8>;
3495
3496def : SELECTNegCondReg<setne, R16C, i16, SELBr16, CEQHr16>;
3497def : SELECTNegCondImm<setne, R16C, i16, i16ImmSExt10, SELBr16, CEQHIr16>;
3498def : SELECTNegCondReg<setle, R16C, i16, SELBr16, CGTHr16>;
3499def : SELECTNegCondImm<setle, R16C, i16, i16ImmSExt10, SELBr16, CGTHIr16>;
3500def : SELECTNegCondReg<setule, R16C, i16, SELBr16, CLGTHr16>;
3501def : SELECTNegCondImm<setule, R16C, i16, i16ImmSExt10, SELBr16, CLGTHIr16>;
3502
3503def : SELECTNegCondReg<setne, R32C, i32, SELBr32, CEQr32>;
3504def : SELECTNegCondImm<setne, R32C, i32, i32ImmSExt10, SELBr32, CEQIr32>;
3505def : SELECTNegCondReg<setle, R32C, i32, SELBr32, CGTr32>;
3506def : SELECTNegCondImm<setle, R32C, i32, i32ImmSExt10, SELBr32, CGTIr32>;
3507def : SELECTNegCondReg<setule, R32C, i32, SELBr32, CLGTr32>;
3508def : SELECTNegCondImm<setule, R32C, i32, i32ImmSExt10, SELBr32, CLGTIr32>;
3509
3510class SELECTBinOpReg<PatFrag cond, RegisterClass rclass, ValueType inttype,
3511 SPUInstr selinstr, SPUInstr binop, SPUInstr cmpOp1,
3512 SPUInstr cmpOp2>:
3513 Pat<(select (inttype (cond rclass:$rA, rclass:$rB)),
Scott Michel06eabde2008-12-27 04:51:36 +00003514 rclass:$rTrue, rclass:$rFalse),
3515 (selinstr rclass:$rFalse, rclass:$rTrue,
Scott Michel53ab7792008-03-10 16:58:52 +00003516 (binop (cmpOp1 rclass:$rA, rclass:$rB),
3517 (cmpOp2 rclass:$rA, rclass:$rB)))>;
3518
3519class SELECTBinOpImm<PatFrag cond, RegisterClass rclass, PatLeaf immpred,
3520 ValueType inttype,
3521 SPUInstr selinstr, SPUInstr binop, SPUInstr cmpOp1,
3522 SPUInstr cmpOp2>:
3523 Pat<(select (inttype (cond rclass:$rA, (inttype immpred:$imm))),
Bill Wendling8f6608b2008-07-22 08:50:44 +00003524 rclass:$rTrue, rclass:$rFalse),
Scott Michel53ab7792008-03-10 16:58:52 +00003525 (selinstr rclass:$rFalse, rclass:$rTrue,
3526 (binop (cmpOp1 rclass:$rA, (inttype immpred:$imm)),
3527 (cmpOp2 rclass:$rA, (inttype immpred:$imm))))>;
3528
3529def : SELECTBinOpReg<setge, R8C, i8, SELBr8, ORr8, CGTBr8, CEQBr8>;
3530def : SELECTBinOpImm<setge, R8C, immSExt8, i8,
3531 SELBr8, ORr8, CGTBIr8, CEQBIr8>;
3532
3533def : SELECTBinOpReg<setge, R16C, i16, SELBr16, ORr16, CGTHr16, CEQHr16>;
3534def : SELECTBinOpImm<setge, R16C, i16ImmSExt10, i16,
3535 SELBr16, ORr16, CGTHIr16, CEQHIr16>;
3536
3537def : SELECTBinOpReg<setge, R32C, i32, SELBr32, ORr32, CGTr32, CEQr32>;
3538def : SELECTBinOpImm<setge, R32C, i32ImmSExt10, i32,
3539 SELBr32, ORr32, CGTIr32, CEQIr32>;
3540
3541def : SELECTBinOpReg<setuge, R8C, i8, SELBr8, ORr8, CLGTBr8, CEQBr8>;
3542def : SELECTBinOpImm<setuge, R8C, immSExt8, i8,
3543 SELBr8, ORr8, CLGTBIr8, CEQBIr8>;
3544
3545def : SELECTBinOpReg<setuge, R16C, i16, SELBr16, ORr16, CLGTHr16, CEQHr16>;
3546def : SELECTBinOpImm<setuge, R16C, i16ImmUns10, i16,
3547 SELBr16, ORr16, CLGTHIr16, CEQHIr16>;
3548
3549def : SELECTBinOpReg<setuge, R32C, i32, SELBr32, ORr32, CLGTr32, CEQr32>;
3550def : SELECTBinOpImm<setuge, R32C, i32ImmUns10, i32,
3551 SELBr32, ORr32, CLGTIr32, CEQIr32>;
Scott Michel97872d32008-02-23 18:41:37 +00003552
3553//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
Scott Michel8b6b4202007-12-04 22:35:58 +00003554
3555let isCall = 1,
3556 // All calls clobber the non-callee-saved registers:
3557 Defs = [R0, R1, R2, R3, R4, R5, R6, R7, R8, R9,
3558 R10,R11,R12,R13,R14,R15,R16,R17,R18,R19,
3559 R20,R21,R22,R23,R24,R25,R26,R27,R28,R29,
3560 R30,R31,R32,R33,R34,R35,R36,R37,R38,R39,
3561 R40,R41,R42,R43,R44,R45,R46,R47,R48,R49,
3562 R50,R51,R52,R53,R54,R55,R56,R57,R58,R59,
3563 R60,R61,R62,R63,R64,R65,R66,R67,R68,R69,
3564 R70,R71,R72,R73,R74,R75,R76,R77,R78,R79],
3565 // All of these instructions use $lr (aka $0)
3566 Uses = [R0] in {
3567 // Branch relative and set link: Used if we actually know that the target
3568 // is within [-32768, 32767] bytes of the target
3569 def BRSL:
3570 BranchSetLink<0b011001100, (outs), (ins relcalltarget:$func, variable_ops),
3571 "brsl\t$$lr, $func",
3572 [(SPUcall (SPUpcrel tglobaladdr:$func, 0))]>;
3573
3574 // Branch absolute and set link: Used if we actually know that the target
3575 // is an absolute address
3576 def BRASL:
3577 BranchSetLink<0b011001100, (outs), (ins calltarget:$func, variable_ops),
3578 "brasl\t$$lr, $func",
Scott Micheldbac4cf2008-01-11 02:53:15 +00003579 [(SPUcall (SPUaform tglobaladdr:$func, 0))]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00003580
3581 // Branch indirect and set link if external data. These instructions are not
3582 // actually generated, matched by an intrinsic:
3583 def BISLED_00: BISLEDForm<0b11, "bisled\t$$lr, $func", [/* empty pattern */]>;
3584 def BISLED_E0: BISLEDForm<0b10, "bisled\t$$lr, $func", [/* empty pattern */]>;
3585 def BISLED_0D: BISLEDForm<0b01, "bisled\t$$lr, $func", [/* empty pattern */]>;
3586 def BISLED_ED: BISLEDForm<0b00, "bisled\t$$lr, $func", [/* empty pattern */]>;
3587
3588 // Branch indirect and set link. This is the "X-form" address version of a
3589 // function call
3590 def BISL:
3591 BIForm<0b10010101100, "bisl\t$$lr, $func", [(SPUcall R32C:$func)]>;
3592}
3593
Scott Michelae5cbf52008-12-29 03:23:36 +00003594// Support calls to external symbols:
3595def : Pat<(SPUcall (SPUpcrel texternalsym:$func, 0)),
3596 (BRSL texternalsym:$func)>;
3597
3598def : Pat<(SPUcall (SPUaform texternalsym:$func, 0)),
3599 (BRASL texternalsym:$func)>;
3600
Scott Michel8b6b4202007-12-04 22:35:58 +00003601// Unconditional branches:
3602let isBranch = 1, isTerminator = 1, hasCtrlDep = 1, isBarrier = 1 in {
3603 def BR :
3604 UncondBranch<0b001001100, (outs), (ins brtarget:$dest),
3605 "br\t$dest",
3606 [(br bb:$dest)]>;
3607
3608 // Unconditional, absolute address branch
3609 def BRA:
3610 UncondBranch<0b001100000, (outs), (ins brtarget:$dest),
3611 "bra\t$dest",
3612 [/* no pattern */]>;
3613
3614 // Indirect branch
3615 def BI:
3616 BIForm<0b00010101100, "bi\t$func", [(brind R32C:$func)]>;
3617
Scott Michele0168c12009-01-05 01:34:35 +00003618 // Conditional branches:
Scott Michel06eabde2008-12-27 04:51:36 +00003619 class BRNZInst<dag IOL, list<dag> pattern>:
3620 RI16Form<0b010000100, (outs), IOL, "brnz\t$rCond,$dest",
3621 BranchResolv, pattern>;
Scott Michel8b6b4202007-12-04 22:35:58 +00003622
Scott Michel06eabde2008-12-27 04:51:36 +00003623 class BRNZRegInst<RegisterClass rclass>:
3624 BRNZInst<(ins rclass:$rCond, brtarget:$dest),
3625 [(brcond rclass:$rCond, bb:$dest)]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00003626
Scott Michel06eabde2008-12-27 04:51:36 +00003627 class BRNZVecInst<ValueType vectype>:
3628 BRNZInst<(ins VECREG:$rCond, brtarget:$dest),
3629 [(brcond (vectype VECREG:$rCond), bb:$dest)]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00003630
Scott Michel06eabde2008-12-27 04:51:36 +00003631 multiclass BranchNotZero {
3632 def v4i32 : BRNZVecInst<v4i32>;
3633 def r32 : BRNZRegInst<R32C>;
3634 }
Scott Michel8b6b4202007-12-04 22:35:58 +00003635
Scott Michel06eabde2008-12-27 04:51:36 +00003636 defm BRNZ : BranchNotZero;
3637
3638 class BRZInst<dag IOL, list<dag> pattern>:
3639 RI16Form<0b000000100, (outs), IOL, "brz\t$rT,$dest",
3640 BranchResolv, pattern>;
3641
3642 class BRZRegInst<RegisterClass rclass>:
3643 BRZInst<(ins rclass:$rT, brtarget:$dest), [/* no pattern */]>;
3644
3645 class BRZVecInst<ValueType vectype>:
3646 BRZInst<(ins VECREG:$rT, brtarget:$dest), [/* no pattern */]>;
3647
3648 multiclass BranchZero {
3649 def v4i32: BRZVecInst<v4i32>;
3650 def r32: BRZRegInst<R32C>;
3651 }
3652
3653 defm BRZ: BranchZero;
3654
3655 // Note: LLVM doesn't do branch conditional, indirect. Otherwise these would
3656 // be useful:
3657 /*
3658 class BINZInst<dag IOL, list<dag> pattern>:
3659 BICondForm<0b10010100100, (outs), IOL, "binz\t$rA, $dest", pattern>;
3660
3661 class BINZRegInst<RegisterClass rclass>:
3662 BINZInst<(ins rclass:$rA, brtarget:$dest),
3663 [(brcond rclass:$rA, R32C:$dest)]>;
3664
3665 class BINZVecInst<ValueType vectype>:
3666 BINZInst<(ins VECREG:$rA, R32C:$dest),
3667 [(brcond (vectype VECREG:$rA), R32C:$dest)]>;
3668
3669 multiclass BranchNotZeroIndirect {
3670 def v4i32: BINZVecInst<v4i32>;
3671 def r32: BINZRegInst<R32C>;
3672 }
3673
3674 defm BINZ: BranchNotZeroIndirect;
3675
3676 class BIZInst<dag IOL, list<dag> pattern>:
3677 BICondForm<0b00010100100, (outs), IOL, "biz\t$rA, $func", pattern>;
3678
3679 class BIZRegInst<RegisterClass rclass>:
3680 BIZInst<(ins rclass:$rA, R32C:$func), [/* no pattern */]>;
3681
3682 class BIZVecInst<ValueType vectype>:
3683 BIZInst<(ins VECREG:$rA, R32C:$func), [/* no pattern */]>;
3684
3685 multiclass BranchZeroIndirect {
3686 def v4i32: BIZVecInst<v4i32>;
3687 def r32: BIZRegInst<R32C>;
3688 }
3689
3690 defm BIZ: BranchZeroIndirect;
3691 */
3692
3693 class BRHNZInst<dag IOL, list<dag> pattern>:
3694 RI16Form<0b011000100, (outs), IOL, "brhnz\t$rCond,$dest", BranchResolv,
3695 pattern>;
3696
3697 class BRHNZRegInst<RegisterClass rclass>:
3698 BRHNZInst<(ins rclass:$rCond, brtarget:$dest),
3699 [(brcond rclass:$rCond, bb:$dest)]>;
3700
3701 class BRHNZVecInst<ValueType vectype>:
3702 BRHNZInst<(ins VECREG:$rCond, brtarget:$dest), [/* no pattern */]>;
3703
3704 multiclass BranchNotZeroHalfword {
3705 def v8i16: BRHNZVecInst<v8i16>;
3706 def r16: BRHNZRegInst<R16C>;
3707 }
3708
3709 defm BRHNZ: BranchNotZeroHalfword;
3710
3711 class BRHZInst<dag IOL, list<dag> pattern>:
3712 RI16Form<0b001000100, (outs), IOL, "brhz\t$rT,$dest", BranchResolv,
3713 pattern>;
3714
3715 class BRHZRegInst<RegisterClass rclass>:
3716 BRHZInst<(ins rclass:$rT, brtarget:$dest), [/* no pattern */]>;
3717
3718 class BRHZVecInst<ValueType vectype>:
3719 BRHZInst<(ins VECREG:$rT, brtarget:$dest), [/* no pattern */]>;
3720
3721 multiclass BranchZeroHalfword {
3722 def v8i16: BRHZVecInst<v8i16>;
3723 def r16: BRHZRegInst<R16C>;
3724 }
3725
3726 defm BRHZ: BranchZeroHalfword;
Scott Michel8b6b4202007-12-04 22:35:58 +00003727}
3728
Scott Michel394e26d2008-01-17 20:38:41 +00003729//===----------------------------------------------------------------------===//
Scott Michelf9f42e62008-01-29 02:16:57 +00003730// setcc and brcond patterns:
Scott Michel394e26d2008-01-17 20:38:41 +00003731//===----------------------------------------------------------------------===//
Scott Michelf9f42e62008-01-29 02:16:57 +00003732
Scott Michel06eabde2008-12-27 04:51:36 +00003733def : Pat<(brcond (i16 (seteq R16C:$rA, 0)), bb:$dest),
3734 (BRHZr16 R16C:$rA, bb:$dest)>;
3735def : Pat<(brcond (i16 (setne R16C:$rA, 0)), bb:$dest),
3736 (BRHNZr16 R16C:$rA, bb:$dest)>;
Scott Michel97872d32008-02-23 18:41:37 +00003737
Scott Michel06eabde2008-12-27 04:51:36 +00003738def : Pat<(brcond (i32 (seteq R32C:$rA, 0)), bb:$dest),
3739 (BRZr32 R32C:$rA, bb:$dest)>;
3740def : Pat<(brcond (i32 (setne R32C:$rA, 0)), bb:$dest),
3741 (BRNZr32 R32C:$rA, bb:$dest)>;
Scott Michel8b6b4202007-12-04 22:35:58 +00003742
Scott Michel97872d32008-02-23 18:41:37 +00003743multiclass BranchCondEQ<PatFrag cond, SPUInstr brinst16, SPUInstr brinst32>
3744{
3745 def r16imm: Pat<(brcond (i16 (cond R16C:$rA, i16ImmSExt10:$val)), bb:$dest),
3746 (brinst16 (CEQHIr16 R16C:$rA, i16ImmSExt10:$val), bb:$dest)>;
Scott Michelf9f42e62008-01-29 02:16:57 +00003747
Scott Michel97872d32008-02-23 18:41:37 +00003748 def r16 : Pat<(brcond (i16 (cond R16C:$rA, R16C:$rB)), bb:$dest),
3749 (brinst16 (CEQHr16 R16C:$rA, R16:$rB), bb:$dest)>;
3750
3751 def r32imm : Pat<(brcond (i32 (cond R32C:$rA, i32ImmSExt10:$val)), bb:$dest),
3752 (brinst32 (CEQIr32 R32C:$rA, i32ImmSExt10:$val), bb:$dest)>;
3753
3754 def r32 : Pat<(brcond (i32 (cond R32C:$rA, R32C:$rB)), bb:$dest),
3755 (brinst32 (CEQr32 R32C:$rA, R32C:$rB), bb:$dest)>;
3756}
3757
Scott Michele0168c12009-01-05 01:34:35 +00003758defm BRCONDeq : BranchCondEQ<seteq, BRHNZr16, BRNZr32>;
3759defm BRCONDne : BranchCondEQ<setne, BRHZr16, BRZr32>;
Scott Michel97872d32008-02-23 18:41:37 +00003760
3761multiclass BranchCondLGT<PatFrag cond, SPUInstr brinst16, SPUInstr brinst32>
3762{
3763 def r16imm : Pat<(brcond (i16 (cond R16C:$rA, i16ImmSExt10:$val)), bb:$dest),
3764 (brinst16 (CLGTHIr16 R16C:$rA, i16ImmSExt10:$val), bb:$dest)>;
3765
3766 def r16 : Pat<(brcond (i16 (cond R16C:$rA, R16C:$rB)), bb:$dest),
3767 (brinst16 (CLGTHr16 R16C:$rA, R16:$rB), bb:$dest)>;
3768
3769 def r32imm : Pat<(brcond (i32 (cond R32C:$rA, i32ImmSExt10:$val)), bb:$dest),
3770 (brinst32 (CLGTIr32 R32C:$rA, i32ImmSExt10:$val), bb:$dest)>;
3771
3772 def r32 : Pat<(brcond (i32 (cond R32C:$rA, R32C:$rB)), bb:$dest),
3773 (brinst32 (CLGTr32 R32C:$rA, R32C:$rB), bb:$dest)>;
3774}
3775
Scott Michel06eabde2008-12-27 04:51:36 +00003776defm BRCONDugt : BranchCondLGT<setugt, BRHNZr16, BRNZr32>;
3777defm BRCONDule : BranchCondLGT<setule, BRHZr16, BRZr32>;
Scott Michel97872d32008-02-23 18:41:37 +00003778
3779multiclass BranchCondLGTEQ<PatFrag cond, SPUInstr orinst16, SPUInstr brinst16,
3780 SPUInstr orinst32, SPUInstr brinst32>
3781{
3782 def r16imm: Pat<(brcond (i16 (cond R16C:$rA, i16ImmSExt10:$val)), bb:$dest),
3783 (brinst16 (orinst16 (CLGTHIr16 R16C:$rA, i16ImmSExt10:$val),
3784 (CEQHIr16 R16C:$rA, i16ImmSExt10:$val)),
3785 bb:$dest)>;
3786
3787 def r16: Pat<(brcond (i16 (cond R16C:$rA, R16C:$rB)), bb:$dest),
3788 (brinst16 (orinst16 (CLGTHr16 R16C:$rA, R16:$rB),
3789 (CEQHr16 R16C:$rA, R16:$rB)),
3790 bb:$dest)>;
3791
3792 def r32imm : Pat<(brcond (i32 (cond R32C:$rA, i32ImmSExt10:$val)), bb:$dest),
3793 (brinst32 (orinst32 (CLGTIr32 R32C:$rA, i32ImmSExt10:$val),
3794 (CEQIr32 R32C:$rA, i32ImmSExt10:$val)),
3795 bb:$dest)>;
3796
3797 def r32 : Pat<(brcond (i32 (cond R32C:$rA, R32C:$rB)), bb:$dest),
3798 (brinst32 (orinst32 (CLGTr32 R32C:$rA, R32C:$rB),
3799 (CEQr32 R32C:$rA, R32C:$rB)),
3800 bb:$dest)>;
3801}
3802
Scott Michel06eabde2008-12-27 04:51:36 +00003803defm BRCONDuge : BranchCondLGTEQ<setuge, ORr16, BRHNZr16, ORr32, BRNZr32>;
3804defm BRCONDult : BranchCondLGTEQ<setult, ORr16, BRHZr16, ORr32, BRZr32>;
Scott Michel97872d32008-02-23 18:41:37 +00003805
3806multiclass BranchCondGT<PatFrag cond, SPUInstr brinst16, SPUInstr brinst32>
3807{
3808 def r16imm : Pat<(brcond (i16 (cond R16C:$rA, i16ImmSExt10:$val)), bb:$dest),
3809 (brinst16 (CGTHIr16 R16C:$rA, i16ImmSExt10:$val), bb:$dest)>;
3810
3811 def r16 : Pat<(brcond (i16 (cond R16C:$rA, R16C:$rB)), bb:$dest),
3812 (brinst16 (CGTHr16 R16C:$rA, R16:$rB), bb:$dest)>;
3813
3814 def r32imm : Pat<(brcond (i32 (cond R32C:$rA, i32ImmSExt10:$val)), bb:$dest),
3815 (brinst32 (CGTIr32 R32C:$rA, i32ImmSExt10:$val), bb:$dest)>;
3816
3817 def r32 : Pat<(brcond (i32 (cond R32C:$rA, R32C:$rB)), bb:$dest),
3818 (brinst32 (CGTr32 R32C:$rA, R32C:$rB), bb:$dest)>;
3819}
3820
Scott Michel06eabde2008-12-27 04:51:36 +00003821defm BRCONDgt : BranchCondGT<setgt, BRHNZr16, BRNZr32>;
3822defm BRCONDle : BranchCondGT<setle, BRHZr16, BRZr32>;
Scott Michel97872d32008-02-23 18:41:37 +00003823
3824multiclass BranchCondGTEQ<PatFrag cond, SPUInstr orinst16, SPUInstr brinst16,
3825 SPUInstr orinst32, SPUInstr brinst32>
3826{
3827 def r16imm: Pat<(brcond (i16 (cond R16C:$rA, i16ImmSExt10:$val)), bb:$dest),
3828 (brinst16 (orinst16 (CGTHIr16 R16C:$rA, i16ImmSExt10:$val),
3829 (CEQHIr16 R16C:$rA, i16ImmSExt10:$val)),
3830 bb:$dest)>;
3831
3832 def r16: Pat<(brcond (i16 (cond R16C:$rA, R16C:$rB)), bb:$dest),
3833 (brinst16 (orinst16 (CGTHr16 R16C:$rA, R16:$rB),
3834 (CEQHr16 R16C:$rA, R16:$rB)),
3835 bb:$dest)>;
3836
3837 def r32imm : Pat<(brcond (i32 (cond R32C:$rA, i32ImmSExt10:$val)), bb:$dest),
3838 (brinst32 (orinst32 (CGTIr32 R32C:$rA, i32ImmSExt10:$val),
3839 (CEQIr32 R32C:$rA, i32ImmSExt10:$val)),
3840 bb:$dest)>;
3841
3842 def r32 : Pat<(brcond (i32 (cond R32C:$rA, R32C:$rB)), bb:$dest),
3843 (brinst32 (orinst32 (CGTr32 R32C:$rA, R32C:$rB),
3844 (CEQr32 R32C:$rA, R32C:$rB)),
3845 bb:$dest)>;
3846}
3847
Scott Michel06eabde2008-12-27 04:51:36 +00003848defm BRCONDge : BranchCondGTEQ<setge, ORr16, BRHNZr16, ORr32, BRNZr32>;
3849defm BRCONDlt : BranchCondGTEQ<setlt, ORr16, BRHZr16, ORr32, BRZr32>;
Scott Michelf9f42e62008-01-29 02:16:57 +00003850
Scott Michel8b6b4202007-12-04 22:35:58 +00003851let isTerminator = 1, isBarrier = 1 in {
3852 let isReturn = 1 in {
3853 def RET:
3854 RETForm<"bi\t$$lr", [(retflag)]>;
3855 }
3856}
3857
3858//===----------------------------------------------------------------------===//
Scott Michel8b6b4202007-12-04 22:35:58 +00003859// Single precision floating point instructions
3860//===----------------------------------------------------------------------===//
3861
Scott Michel61895fe2008-12-10 00:15:19 +00003862class FAInst<dag OOL, dag IOL, list<dag> pattern>:
3863 RRForm<0b01011000100, OOL, IOL, "fa\t$rT, $rA, $rB",
Scott Michel4d07fb72008-12-30 23:28:25 +00003864 SPrecFP, pattern>;
Scott Michel06eabde2008-12-27 04:51:36 +00003865
Scott Michel61895fe2008-12-10 00:15:19 +00003866class FAVecInst<ValueType vectype>:
3867 FAInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
3868 [(set (vectype VECREG:$rT),
Scott Michel4d07fb72008-12-30 23:28:25 +00003869 (fadd (vectype VECREG:$rA), (vectype VECREG:$rB)))]>;
Scott Michel06eabde2008-12-27 04:51:36 +00003870
Scott Michel61895fe2008-12-10 00:15:19 +00003871multiclass SFPAdd
3872{
3873 def v4f32: FAVecInst<v4f32>;
Scott Michel4d07fb72008-12-30 23:28:25 +00003874 def f32: FAInst<(outs R32FP:$rT), (ins R32FP:$rA, R32FP:$rB),
3875 [(set R32FP:$rT, (fadd R32FP:$rA, R32FP:$rB))]>;
Scott Michel61895fe2008-12-10 00:15:19 +00003876}
Scott Michel8b6b4202007-12-04 22:35:58 +00003877
Scott Michel61895fe2008-12-10 00:15:19 +00003878defm FA : SFPAdd;
Scott Michel8b6b4202007-12-04 22:35:58 +00003879
Scott Michel61895fe2008-12-10 00:15:19 +00003880class FSInst<dag OOL, dag IOL, list<dag> pattern>:
3881 RRForm<0b01011000100, OOL, IOL, "fs\t$rT, $rA, $rB",
Scott Michel4d07fb72008-12-30 23:28:25 +00003882 SPrecFP, pattern>;
Scott Michel8b6b4202007-12-04 22:35:58 +00003883
Scott Michel61895fe2008-12-10 00:15:19 +00003884class FSVecInst<ValueType vectype>:
3885 FSInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
Scott Michel4d07fb72008-12-30 23:28:25 +00003886 [(set (vectype VECREG:$rT),
3887 (fsub (vectype VECREG:$rA), (vectype VECREG:$rB)))]>;
Scott Michel61895fe2008-12-10 00:15:19 +00003888
3889multiclass SFPSub
3890{
3891 def v4f32: FSVecInst<v4f32>;
Scott Michel4d07fb72008-12-30 23:28:25 +00003892 def f32: FSInst<(outs R32FP:$rT), (ins R32FP:$rA, R32FP:$rB),
3893 [(set R32FP:$rT, (fsub R32FP:$rA, R32FP:$rB))]>;
Scott Michel61895fe2008-12-10 00:15:19 +00003894}
3895
3896defm FS : SFPSub;
Scott Michel8b6b4202007-12-04 22:35:58 +00003897
3898// Floating point reciprocal estimate
Scott Michel8b6b4202007-12-04 22:35:58 +00003899
Scott Michel4d07fb72008-12-30 23:28:25 +00003900class FRESTInst<dag OOL, dag IOL>:
3901 RRForm_1<0b00110111000, OOL, IOL,
3902 "frest\t$rT, $rA", SPrecFP,
3903 [/* no pattern */]>;
3904
3905def FRESTv4f32 :
3906 FRESTInst<(outs VECREG:$rT), (ins VECREG:$rA)>;
3907
3908def FRESTf32 :
3909 FRESTInst<(outs R32FP:$rT), (ins R32FP:$rA)>;
Scott Michel8b6b4202007-12-04 22:35:58 +00003910
3911// Floating point interpolate (used in conjunction with reciprocal estimate)
3912def FIv4f32 :
3913 RRForm<0b00101011110, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
3914 "fi\t$rT, $rA, $rB", SPrecFP,
Scott Michel4d07fb72008-12-30 23:28:25 +00003915 [/* no pattern */]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00003916
3917def FIf32 :
3918 RRForm<0b00101011110, (outs R32FP:$rT), (ins R32FP:$rA, R32FP:$rB),
3919 "fi\t$rT, $rA, $rB", SPrecFP,
Scott Michel4d07fb72008-12-30 23:28:25 +00003920 [/* no pattern */]>;
Scott Michel8b6b4202007-12-04 22:35:58 +00003921
Scott Michel33d73eb2008-11-21 02:56:16 +00003922//--------------------------------------------------------------------------
3923// Basic single precision floating point comparisons:
3924//
3925// Note: There is no support on SPU for single precision NaN. Consequently,
3926// ordered and unordered comparisons are the same.
3927//--------------------------------------------------------------------------
3928
Scott Michel8b6b4202007-12-04 22:35:58 +00003929def FCEQf32 :
3930 RRForm<0b01000011110, (outs R32C:$rT), (ins R32FP:$rA, R32FP:$rB),
3931 "fceq\t$rT, $rA, $rB", SPrecFP,
Scott Michel33d73eb2008-11-21 02:56:16 +00003932 [(set R32C:$rT, (setueq R32FP:$rA, R32FP:$rB))]>;
3933
3934def : Pat<(setoeq R32FP:$rA, R32FP:$rB),
3935 (FCEQf32 R32FP:$rA, R32FP:$rB)>;
Scott Michel8b6b4202007-12-04 22:35:58 +00003936
3937def FCMEQf32 :
3938 RRForm<0b01010011110, (outs R32C:$rT), (ins R32FP:$rA, R32FP:$rB),
3939 "fcmeq\t$rT, $rA, $rB", SPrecFP,
Scott Michel33d73eb2008-11-21 02:56:16 +00003940 [(set R32C:$rT, (setueq (fabs R32FP:$rA), (fabs R32FP:$rB)))]>;
3941
3942def : Pat<(setoeq (fabs R32FP:$rA), (fabs R32FP:$rB)),
3943 (FCMEQf32 R32FP:$rA, R32FP:$rB)>;
Scott Michel8b6b4202007-12-04 22:35:58 +00003944
3945def FCGTf32 :
3946 RRForm<0b01000011010, (outs R32C:$rT), (ins R32FP:$rA, R32FP:$rB),
3947 "fcgt\t$rT, $rA, $rB", SPrecFP,
Scott Michel33d73eb2008-11-21 02:56:16 +00003948 [(set R32C:$rT, (setugt R32FP:$rA, R32FP:$rB))]>;
3949
3950def : Pat<(setugt R32FP:$rA, R32FP:$rB),
3951 (FCGTf32 R32FP:$rA, R32FP:$rB)>;
Scott Michel8b6b4202007-12-04 22:35:58 +00003952
3953def FCMGTf32 :
3954 RRForm<0b01010011010, (outs R32C:$rT), (ins R32FP:$rA, R32FP:$rB),
3955 "fcmgt\t$rT, $rA, $rB", SPrecFP,
Scott Michel33d73eb2008-11-21 02:56:16 +00003956 [(set R32C:$rT, (setugt (fabs R32FP:$rA), (fabs R32FP:$rB)))]>;
3957
3958def : Pat<(setugt (fabs R32FP:$rA), (fabs R32FP:$rB)),
3959 (FCMGTf32 R32FP:$rA, R32FP:$rB)>;
3960
3961//--------------------------------------------------------------------------
3962// Single precision floating point comparisons and SETCC equivalents:
3963//--------------------------------------------------------------------------
3964
3965def : SETCCNegCondReg<setune, R32FP, i32, XORIr32, FCEQf32>;
3966def : SETCCNegCondReg<setone, R32FP, i32, XORIr32, FCEQf32>;
3967
3968def : SETCCBinOpReg<setuge, R32FP, ORr32, FCGTf32, FCEQf32>;
3969def : SETCCBinOpReg<setoge, R32FP, ORr32, FCGTf32, FCEQf32>;
3970
3971def : SETCCBinOpReg<setult, R32FP, NORr32, FCGTf32, FCEQf32>;
3972def : SETCCBinOpReg<setolt, R32FP, NORr32, FCGTf32, FCEQf32>;
3973
3974def : Pat<(setule R32FP:$rA, R32FP:$rB),
3975 (XORIr32 (FCGTf32 R32FP:$rA, R32FP:$rB), 0xffffffff)>;
3976def : Pat<(setole R32FP:$rA, R32FP:$rB),
3977 (XORIr32 (FCGTf32 R32FP:$rA, R32FP:$rB), 0xffffffff)>;
Scott Michel8b6b4202007-12-04 22:35:58 +00003978
3979// FP Status and Control Register Write
3980// Why isn't rT a don't care in the ISA?
3981// Should we create a special RRForm_3 for this guy and zero out the rT?
3982def FSCRWf32 :
3983 RRForm_1<0b01011101110, (outs R32FP:$rT), (ins R32FP:$rA),
3984 "fscrwr\t$rA", SPrecFP,
3985 [/* This instruction requires an intrinsic. Note: rT is unused. */]>;
3986
3987// FP Status and Control Register Read
3988def FSCRRf32 :
3989 RRForm_2<0b01011101110, (outs R32FP:$rT), (ins),
3990 "fscrrd\t$rT", SPrecFP,
3991 [/* This instruction requires an intrinsic */]>;
3992
3993// llvm instruction space
3994// How do these map onto cell instructions?
3995// fdiv rA rB
3996// frest rC rB # c = 1/b (both lines)
3997// fi rC rB rC
3998// fm rD rA rC # d = a * 1/b
3999// fnms rB rD rB rA # b = - (d * b - a) --should == 0 in a perfect world
4000// fma rB rB rC rD # b = b * c + d
4001// = -(d *b -a) * c + d
4002// = a * c - c ( a *b *c - a)
4003
4004// fcopysign (???)
4005
4006// Library calls:
4007// These llvm instructions will actually map to library calls.
4008// All that's needed, then, is to check that the appropriate library is
4009// imported and do a brsl to the proper function name.
4010// frem # fmod(x, y): x - (x/y) * y
4011// (Note: fmod(double, double), fmodf(float,float)
4012// fsqrt?
4013// fsin?
4014// fcos?
4015// Unimplemented SPU instruction space
4016// floating reciprocal absolute square root estimate (frsqest)
4017
4018// The following are probably just intrinsics
Scott Michel06eabde2008-12-27 04:51:36 +00004019// status and control register write
Scott Michel8b6b4202007-12-04 22:35:58 +00004020// status and control register read
4021
4022//--------------------------------------
4023// Floating point multiply instructions
4024//--------------------------------------
4025
4026def FMv4f32:
4027 RRForm<0b00100011010, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
4028 "fm\t$rT, $rA, $rB", SPrecFP,
4029 [(set (v4f32 VECREG:$rT), (fmul (v4f32 VECREG:$rA),
4030 (v4f32 VECREG:$rB)))]>;
4031
4032def FMf32 :
4033 RRForm<0b01100011010, (outs R32FP:$rT), (ins R32FP:$rA, R32FP:$rB),
4034 "fm\t$rT, $rA, $rB", SPrecFP,
4035 [(set R32FP:$rT, (fmul R32FP:$rA, R32FP:$rB))]>;
4036
4037// Floating point multiply and add
4038// e.g. d = c + (a * b)
4039def FMAv4f32:
4040 RRRForm<0b0111, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB, VECREG:$rC),
4041 "fma\t$rT, $rA, $rB, $rC", SPrecFP,
4042 [(set (v4f32 VECREG:$rT),
4043 (fadd (v4f32 VECREG:$rC),
4044 (fmul (v4f32 VECREG:$rA), (v4f32 VECREG:$rB))))]>;
4045
4046def FMAf32:
4047 RRRForm<0b0111, (outs R32FP:$rT), (ins R32FP:$rA, R32FP:$rB, R32FP:$rC),
4048 "fma\t$rT, $rA, $rB, $rC", SPrecFP,
4049 [(set R32FP:$rT, (fadd R32FP:$rC, (fmul R32FP:$rA, R32FP:$rB)))]>;
4050
4051// FP multiply and subtract
4052// Subtracts value in rC from product
4053// res = a * b - c
4054def FMSv4f32 :
4055 RRRForm<0b0111, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB, VECREG:$rC),
4056 "fms\t$rT, $rA, $rB, $rC", SPrecFP,
4057 [(set (v4f32 VECREG:$rT),
4058 (fsub (fmul (v4f32 VECREG:$rA), (v4f32 VECREG:$rB)),
4059 (v4f32 VECREG:$rC)))]>;
4060
4061def FMSf32 :
4062 RRRForm<0b0111, (outs R32FP:$rT), (ins R32FP:$rA, R32FP:$rB, R32FP:$rC),
4063 "fms\t$rT, $rA, $rB, $rC", SPrecFP,
4064 [(set R32FP:$rT,
4065 (fsub (fmul R32FP:$rA, R32FP:$rB), R32FP:$rC))]>;
4066
4067// Floating Negative Mulitply and Subtract
4068// Subtracts product from value in rC
4069// res = fneg(fms a b c)
4070// = - (a * b - c)
4071// = c - a * b
4072// NOTE: subtraction order
4073// fsub a b = a - b
Scott Michel06eabde2008-12-27 04:51:36 +00004074// fs a b = b - a?
Scott Michel8b6b4202007-12-04 22:35:58 +00004075def FNMSf32 :
4076 RRRForm<0b1101, (outs R32FP:$rT), (ins R32FP:$rA, R32FP:$rB, R32FP:$rC),
4077 "fnms\t$rT, $rA, $rB, $rC", SPrecFP,
4078 [(set R32FP:$rT, (fsub R32FP:$rC, (fmul R32FP:$rA, R32FP:$rB)))]>;
4079
4080def FNMSv4f32 :
4081 RRRForm<0b1101, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB, VECREG:$rC),
4082 "fnms\t$rT, $rA, $rB, $rC", SPrecFP,
Scott Michel06eabde2008-12-27 04:51:36 +00004083 [(set (v4f32 VECREG:$rT),
4084 (fsub (v4f32 VECREG:$rC),
4085 (fmul (v4f32 VECREG:$rA),
Scott Michel8b6b4202007-12-04 22:35:58 +00004086 (v4f32 VECREG:$rB))))]>;
4087
4088//--------------------------------------
4089// Floating Point Conversions
4090// Signed conversions:
4091def CSiFv4f32:
4092 CVTIntFPForm<0b0101101110, (outs VECREG:$rT), (ins VECREG:$rA),
4093 "csflt\t$rT, $rA, 0", SPrecFP,
4094 [(set (v4f32 VECREG:$rT), (sint_to_fp (v4i32 VECREG:$rA)))]>;
4095
Scott Michel06eabde2008-12-27 04:51:36 +00004096// Convert signed integer to floating point
Scott Michel8b6b4202007-12-04 22:35:58 +00004097def CSiFf32 :
4098 CVTIntFPForm<0b0101101110, (outs R32FP:$rT), (ins R32C:$rA),
4099 "csflt\t$rT, $rA, 0", SPrecFP,
4100 [(set R32FP:$rT, (sint_to_fp R32C:$rA))]>;
4101
4102// Convert unsigned into to float
4103def CUiFv4f32 :
4104 CVTIntFPForm<0b1101101110, (outs VECREG:$rT), (ins VECREG:$rA),
4105 "cuflt\t$rT, $rA, 0", SPrecFP,
4106 [(set (v4f32 VECREG:$rT), (uint_to_fp (v4i32 VECREG:$rA)))]>;
4107
4108def CUiFf32 :
4109 CVTIntFPForm<0b1101101110, (outs R32FP:$rT), (ins R32C:$rA),
4110 "cuflt\t$rT, $rA, 0", SPrecFP,
4111 [(set R32FP:$rT, (uint_to_fp R32C:$rA))]>;
4112
Scott Michel06eabde2008-12-27 04:51:36 +00004113// Convert float to unsigned int
Scott Michel8b6b4202007-12-04 22:35:58 +00004114// Assume that scale = 0
4115
4116def CFUiv4f32 :
4117 CVTIntFPForm<0b1101101110, (outs VECREG:$rT), (ins VECREG:$rA),
4118 "cfltu\t$rT, $rA, 0", SPrecFP,
4119 [(set (v4i32 VECREG:$rT), (fp_to_uint (v4f32 VECREG:$rA)))]>;
4120
4121def CFUif32 :
4122 CVTIntFPForm<0b1101101110, (outs R32C:$rT), (ins R32FP:$rA),
4123 "cfltu\t$rT, $rA, 0", SPrecFP,
4124 [(set R32C:$rT, (fp_to_uint R32FP:$rA))]>;
4125
Scott Michel06eabde2008-12-27 04:51:36 +00004126// Convert float to signed int
Scott Michel8b6b4202007-12-04 22:35:58 +00004127// Assume that scale = 0
4128
4129def CFSiv4f32 :
4130 CVTIntFPForm<0b1101101110, (outs VECREG:$rT), (ins VECREG:$rA),
4131 "cflts\t$rT, $rA, 0", SPrecFP,
4132 [(set (v4i32 VECREG:$rT), (fp_to_sint (v4f32 VECREG:$rA)))]>;
4133
4134def CFSif32 :
4135 CVTIntFPForm<0b1101101110, (outs R32C:$rT), (ins R32FP:$rA),
4136 "cflts\t$rT, $rA, 0", SPrecFP,
4137 [(set R32C:$rT, (fp_to_sint R32FP:$rA))]>;
4138
4139//===----------------------------------------------------------------------==//
4140// Single<->Double precision conversions
4141//===----------------------------------------------------------------------==//
4142
4143// NOTE: We use "vec" name suffix here to avoid confusion (e.g. input is a
4144// v4f32, output is v2f64--which goes in the name?)
4145
4146// Floating point extend single to double
4147// NOTE: Not sure if passing in v4f32 to FESDvec is correct since it
4148// operates on two double-word slots (i.e. 1st and 3rd fp numbers
4149// are ignored).
4150def FESDvec :
4151 RRForm_1<0b00011101110, (outs VECREG:$rT), (ins VECREG:$rA),
4152 "fesd\t$rT, $rA", SPrecFP,
4153 [(set (v2f64 VECREG:$rT), (fextend (v4f32 VECREG:$rA)))]>;
4154
4155def FESDf32 :
4156 RRForm_1<0b00011101110, (outs R64FP:$rT), (ins R32FP:$rA),
4157 "fesd\t$rT, $rA", SPrecFP,
4158 [(set R64FP:$rT, (fextend R32FP:$rA))]>;
4159
4160// Floating point round double to single
4161//def FRDSvec :
4162// RRForm_1<0b10011101110, (outs VECREG:$rT), (ins VECREG:$rA),
4163// "frds\t$rT, $rA,", SPrecFP,
4164// [(set (v4f32 R32FP:$rT), (fround (v2f64 R64FP:$rA)))]>;
4165
4166def FRDSf64 :
4167 RRForm_1<0b10011101110, (outs R32FP:$rT), (ins R64FP:$rA),
4168 "frds\t$rT, $rA", SPrecFP,
4169 [(set R32FP:$rT, (fround R64FP:$rA))]>;
4170
4171//ToDo include anyextend?
4172
4173//===----------------------------------------------------------------------==//
4174// Double precision floating point instructions
4175//===----------------------------------------------------------------------==//
4176def FAf64 :
4177 RRForm<0b00110011010, (outs R64FP:$rT), (ins R64FP:$rA, R64FP:$rB),
4178 "dfa\t$rT, $rA, $rB", DPrecFP,
4179 [(set R64FP:$rT, (fadd R64FP:$rA, R64FP:$rB))]>;
4180
4181def FAv2f64 :
4182 RRForm<0b00110011010, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
4183 "dfa\t$rT, $rA, $rB", DPrecFP,
4184 [(set (v2f64 VECREG:$rT), (fadd (v2f64 VECREG:$rA), (v2f64 VECREG:$rB)))]>;
4185
4186def FSf64 :
4187 RRForm<0b10100011010, (outs R64FP:$rT), (ins R64FP:$rA, R64FP:$rB),
4188 "dfs\t$rT, $rA, $rB", DPrecFP,
4189 [(set R64FP:$rT, (fsub R64FP:$rA, R64FP:$rB))]>;
4190
4191def FSv2f64 :
4192 RRForm<0b10100011010, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
4193 "dfs\t$rT, $rA, $rB", DPrecFP,
4194 [(set (v2f64 VECREG:$rT),
4195 (fsub (v2f64 VECREG:$rA), (v2f64 VECREG:$rB)))]>;
4196
4197def FMf64 :
4198 RRForm<0b01100011010, (outs R64FP:$rT), (ins R64FP:$rA, R64FP:$rB),
4199 "dfm\t$rT, $rA, $rB", DPrecFP,
4200 [(set R64FP:$rT, (fmul R64FP:$rA, R64FP:$rB))]>;
4201
4202def FMv2f64:
4203 RRForm<0b00100011010, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
4204 "dfm\t$rT, $rA, $rB", DPrecFP,
4205 [(set (v2f64 VECREG:$rT),
4206 (fmul (v2f64 VECREG:$rA), (v2f64 VECREG:$rB)))]>;
4207
4208def FMAf64:
4209 RRForm<0b00111010110, (outs R64FP:$rT),
4210 (ins R64FP:$rA, R64FP:$rB, R64FP:$rC),
4211 "dfma\t$rT, $rA, $rB", DPrecFP,
4212 [(set R64FP:$rT, (fadd R64FP:$rC, (fmul R64FP:$rA, R64FP:$rB)))]>,
4213 RegConstraint<"$rC = $rT">,
4214 NoEncode<"$rC">;
4215
4216def FMAv2f64:
4217 RRForm<0b00111010110, (outs VECREG:$rT),
4218 (ins VECREG:$rA, VECREG:$rB, VECREG:$rC),
4219 "dfma\t$rT, $rA, $rB", DPrecFP,
4220 [(set (v2f64 VECREG:$rT),
4221 (fadd (v2f64 VECREG:$rC),
4222 (fmul (v2f64 VECREG:$rA), (v2f64 VECREG:$rB))))]>,
4223 RegConstraint<"$rC = $rT">,
4224 NoEncode<"$rC">;
4225
4226def FMSf64 :
4227 RRForm<0b10111010110, (outs R64FP:$rT),
4228 (ins R64FP:$rA, R64FP:$rB, R64FP:$rC),
4229 "dfms\t$rT, $rA, $rB", DPrecFP,
4230 [(set R64FP:$rT, (fsub (fmul R64FP:$rA, R64FP:$rB), R64FP:$rC))]>,
4231 RegConstraint<"$rC = $rT">,
4232 NoEncode<"$rC">;
4233
4234def FMSv2f64 :
4235 RRForm<0b10111010110, (outs VECREG:$rT),
4236 (ins VECREG:$rA, VECREG:$rB, VECREG:$rC),
4237 "dfms\t$rT, $rA, $rB", DPrecFP,
4238 [(set (v2f64 VECREG:$rT),
4239 (fsub (fmul (v2f64 VECREG:$rA), (v2f64 VECREG:$rB)),
4240 (v2f64 VECREG:$rC)))]>;
4241
4242// FNMS: - (a * b - c)
4243// - (a * b) + c => c - (a * b)
4244def FNMSf64 :
4245 RRForm<0b01111010110, (outs R64FP:$rT),
4246 (ins R64FP:$rA, R64FP:$rB, R64FP:$rC),
4247 "dfnms\t$rT, $rA, $rB", DPrecFP,
4248 [(set R64FP:$rT, (fsub R64FP:$rC, (fmul R64FP:$rA, R64FP:$rB)))]>,
4249 RegConstraint<"$rC = $rT">,
4250 NoEncode<"$rC">;
4251
4252def : Pat<(fneg (fsub (fmul R64FP:$rA, R64FP:$rB), R64FP:$rC)),
4253 (FNMSf64 R64FP:$rA, R64FP:$rB, R64FP:$rC)>;
4254
4255def FNMSv2f64 :
4256 RRForm<0b01111010110, (outs VECREG:$rT),
4257 (ins VECREG:$rA, VECREG:$rB, VECREG:$rC),
4258 "dfnms\t$rT, $rA, $rB", DPrecFP,
Scott Michel06eabde2008-12-27 04:51:36 +00004259 [(set (v2f64 VECREG:$rT),
4260 (fsub (v2f64 VECREG:$rC),
4261 (fmul (v2f64 VECREG:$rA),
Scott Michel8b6b4202007-12-04 22:35:58 +00004262 (v2f64 VECREG:$rB))))]>,
4263 RegConstraint<"$rC = $rT">,
4264 NoEncode<"$rC">;
4265
4266def : Pat<(fneg (fsub (fmul (v2f64 VECREG:$rA), (v2f64 VECREG:$rB)),
4267 (v2f64 VECREG:$rC))),
4268 (FNMSv2f64 VECREG:$rA, VECREG:$rB, VECREG:$rC)>;
4269
4270// - (a * b + c)
4271// - (a * b) - c
4272def FNMAf64 :
4273 RRForm<0b11111010110, (outs R64FP:$rT),
4274 (ins R64FP:$rA, R64FP:$rB, R64FP:$rC),
4275 "dfnma\t$rT, $rA, $rB", DPrecFP,
4276 [(set R64FP:$rT, (fneg (fadd R64FP:$rC, (fmul R64FP:$rA, R64FP:$rB))))]>,
4277 RegConstraint<"$rC = $rT">,
4278 NoEncode<"$rC">;
4279
4280def FNMAv2f64 :
4281 RRForm<0b11111010110, (outs VECREG:$rT),
4282 (ins VECREG:$rA, VECREG:$rB, VECREG:$rC),
4283 "dfnma\t$rT, $rA, $rB", DPrecFP,
Scott Michel06eabde2008-12-27 04:51:36 +00004284 [(set (v2f64 VECREG:$rT),
4285 (fneg (fadd (v2f64 VECREG:$rC),
4286 (fmul (v2f64 VECREG:$rA),
Scott Michel8b6b4202007-12-04 22:35:58 +00004287 (v2f64 VECREG:$rB)))))]>,
4288 RegConstraint<"$rC = $rT">,
4289 NoEncode<"$rC">;
4290
4291//===----------------------------------------------------------------------==//
4292// Floating point negation and absolute value
4293//===----------------------------------------------------------------------==//
4294
4295def : Pat<(fneg (v4f32 VECREG:$rA)),
Scott Michel06eabde2008-12-27 04:51:36 +00004296 (XORfnegvec (v4f32 VECREG:$rA),
Scott Michel8b6b4202007-12-04 22:35:58 +00004297 (v4f32 (ILHUv4i32 0x8000)))>;
4298
4299def : Pat<(fneg R32FP:$rA),
4300 (XORfneg32 R32FP:$rA, (ILHUr32 0x8000))>;
4301
4302def : Pat<(fneg (v2f64 VECREG:$rA)),
4303 (XORfnegvec (v2f64 VECREG:$rA),
4304 (v2f64 (ANDBIv16i8 (FSMBIv16i8 0x8080), 0x80)))>;
4305
4306def : Pat<(fneg R64FP:$rA),
4307 (XORfneg64 R64FP:$rA,
4308 (ANDBIv16i8 (FSMBIv16i8 0x8080), 0x80))>;
4309
4310// Floating point absolute value
4311
4312def : Pat<(fabs R32FP:$rA),
4313 (ANDfabs32 R32FP:$rA, (IOHLr32 (ILHUr32 0x7fff), 0xffff))>;
4314
4315def : Pat<(fabs (v4f32 VECREG:$rA)),
4316 (ANDfabsvec (v4f32 VECREG:$rA),
4317 (v4f32 (ANDBIv16i8 (FSMBIv16i8 0xffff), 0x7f)))>;
4318
pingbak2f387e82009-01-26 03:31:40 +00004319def : Pat<(fabs R64FP:$rA),
4320 (ANDfabs64 R64FP:$rA, (ANDBIv16i8 (FSMBIv16i8 0xffff), 0x7f))>;
4321
4322def : Pat<(fabs (v2f64 VECREG:$rA)),
4323 (ANDfabsvec (v2f64 VECREG:$rA),
4324 (v2f64 (ANDBIv16i8 (FSMBIv16i8 0xffff), 0x7f)))>;
4325
Scott Michel8b6b4202007-12-04 22:35:58 +00004326//===----------------------------------------------------------------------===//
Scott Michel61895fe2008-12-10 00:15:19 +00004327// Hint for branch instructions:
4328//===----------------------------------------------------------------------===//
4329
4330/* def HBR : SPUInstr<(outs), (ins), "hbr\t" */
4331
4332//===----------------------------------------------------------------------===//
Scott Michel8b6b4202007-12-04 22:35:58 +00004333// Execution, Load NOP (execute NOPs belong in even pipeline, load NOPs belong
4334// in the odd pipeline)
4335//===----------------------------------------------------------------------===//
4336
Scott Michel97872d32008-02-23 18:41:37 +00004337def ENOP : SPUInstr<(outs), (ins), "enop", ExecNOP> {
Scott Michel8b6b4202007-12-04 22:35:58 +00004338 let Pattern = [];
4339
4340 let Inst{0-10} = 0b10000000010;
4341 let Inst{11-17} = 0;
4342 let Inst{18-24} = 0;
4343 let Inst{25-31} = 0;
4344}
4345
Scott Michel97872d32008-02-23 18:41:37 +00004346def LNOP : SPUInstr<(outs), (ins), "lnop", LoadNOP> {
Scott Michel8b6b4202007-12-04 22:35:58 +00004347 let Pattern = [];
4348
4349 let Inst{0-10} = 0b10000000000;
4350 let Inst{11-17} = 0;
4351 let Inst{18-24} = 0;
4352 let Inst{25-31} = 0;
4353}
4354
4355//===----------------------------------------------------------------------===//
4356// Bit conversions (type conversions between vector/packed types)
Scott Michel34712c32009-03-16 18:47:25 +00004357// NOTE: Promotions are handled using the XS* instructions.
Scott Michel8b6b4202007-12-04 22:35:58 +00004358//===----------------------------------------------------------------------===//
4359def : Pat<(v16i8 (bitconvert (v8i16 VECREG:$src))), (v16i8 VECREG:$src)>;
4360def : Pat<(v16i8 (bitconvert (v4i32 VECREG:$src))), (v16i8 VECREG:$src)>;
4361def : Pat<(v16i8 (bitconvert (v2i64 VECREG:$src))), (v16i8 VECREG:$src)>;
4362def : Pat<(v16i8 (bitconvert (v4f32 VECREG:$src))), (v16i8 VECREG:$src)>;
4363def : Pat<(v16i8 (bitconvert (v2f64 VECREG:$src))), (v16i8 VECREG:$src)>;
4364
4365def : Pat<(v8i16 (bitconvert (v16i8 VECREG:$src))), (v8i16 VECREG:$src)>;
4366def : Pat<(v8i16 (bitconvert (v4i32 VECREG:$src))), (v8i16 VECREG:$src)>;
4367def : Pat<(v8i16 (bitconvert (v2i64 VECREG:$src))), (v8i16 VECREG:$src)>;
4368def : Pat<(v8i16 (bitconvert (v4f32 VECREG:$src))), (v8i16 VECREG:$src)>;
4369def : Pat<(v8i16 (bitconvert (v2f64 VECREG:$src))), (v8i16 VECREG:$src)>;
4370
4371def : Pat<(v4i32 (bitconvert (v16i8 VECREG:$src))), (v4i32 VECREG:$src)>;
4372def : Pat<(v4i32 (bitconvert (v8i16 VECREG:$src))), (v4i32 VECREG:$src)>;
4373def : Pat<(v4i32 (bitconvert (v2i64 VECREG:$src))), (v4i32 VECREG:$src)>;
4374def : Pat<(v4i32 (bitconvert (v4f32 VECREG:$src))), (v4i32 VECREG:$src)>;
4375def : Pat<(v4i32 (bitconvert (v2f64 VECREG:$src))), (v4i32 VECREG:$src)>;
4376
4377def : Pat<(v2i64 (bitconvert (v16i8 VECREG:$src))), (v2i64 VECREG:$src)>;
4378def : Pat<(v2i64 (bitconvert (v8i16 VECREG:$src))), (v2i64 VECREG:$src)>;
4379def : Pat<(v2i64 (bitconvert (v4i32 VECREG:$src))), (v2i64 VECREG:$src)>;
4380def : Pat<(v2i64 (bitconvert (v4f32 VECREG:$src))), (v2i64 VECREG:$src)>;
4381def : Pat<(v2i64 (bitconvert (v2f64 VECREG:$src))), (v2i64 VECREG:$src)>;
4382
4383def : Pat<(v4f32 (bitconvert (v16i8 VECREG:$src))), (v4f32 VECREG:$src)>;
4384def : Pat<(v4f32 (bitconvert (v8i16 VECREG:$src))), (v4f32 VECREG:$src)>;
4385def : Pat<(v4f32 (bitconvert (v2i64 VECREG:$src))), (v4f32 VECREG:$src)>;
4386def : Pat<(v4f32 (bitconvert (v4i32 VECREG:$src))), (v4f32 VECREG:$src)>;
4387def : Pat<(v4f32 (bitconvert (v2f64 VECREG:$src))), (v4f32 VECREG:$src)>;
4388
4389def : Pat<(v2f64 (bitconvert (v16i8 VECREG:$src))), (v2f64 VECREG:$src)>;
4390def : Pat<(v2f64 (bitconvert (v8i16 VECREG:$src))), (v2f64 VECREG:$src)>;
4391def : Pat<(v2f64 (bitconvert (v4i32 VECREG:$src))), (v2f64 VECREG:$src)>;
4392def : Pat<(v2f64 (bitconvert (v2i64 VECREG:$src))), (v2f64 VECREG:$src)>;
4393def : Pat<(v2f64 (bitconvert (v2f64 VECREG:$src))), (v2f64 VECREG:$src)>;
4394
Scott Michel34712c32009-03-16 18:47:25 +00004395def : Pat<(i128 (bitconvert (v16i8 VECREG:$src))),
4396 (ORi128_vec VECREG:$src)>;
4397def : Pat<(i128 (bitconvert (v8i16 VECREG:$src))),
4398 (ORi128_vec VECREG:$src)>;
4399def : Pat<(i128 (bitconvert (v4i32 VECREG:$src))),
4400 (ORi128_vec VECREG:$src)>;
4401def : Pat<(i128 (bitconvert (v2i64 VECREG:$src))),
4402 (ORi128_vec VECREG:$src)>;
4403def : Pat<(i128 (bitconvert (v4f32 VECREG:$src))),
4404 (ORi128_vec VECREG:$src)>;
4405def : Pat<(i128 (bitconvert (v2f64 VECREG:$src))),
4406 (ORi128_vec VECREG:$src)>;
4407
4408def : Pat<(v16i8 (bitconvert (i128 GPRC:$src))),
4409 (v16i8 (ORvec_i128 GPRC:$src))>;
4410def : Pat<(v8i16 (bitconvert (i128 GPRC:$src))),
4411 (v8i16 (ORvec_i128 GPRC:$src))>;
4412def : Pat<(v4i32 (bitconvert (i128 GPRC:$src))),
4413 (v4i32 (ORvec_i128 GPRC:$src))>;
4414def : Pat<(v2i64 (bitconvert (i128 GPRC:$src))),
4415 (v2i64 (ORvec_i128 GPRC:$src))>;
4416def : Pat<(v4f32 (bitconvert (i128 GPRC:$src))),
4417 (v4f32 (ORvec_i128 GPRC:$src))>;
4418def : Pat<(v2f64 (bitconvert (i128 GPRC:$src))),
4419 (v2f64 (ORvec_i128 GPRC:$src))>;
Scott Michel8b6b4202007-12-04 22:35:58 +00004420
4421//===----------------------------------------------------------------------===//
4422// Instruction patterns:
4423//===----------------------------------------------------------------------===//
4424
4425// General 32-bit constants:
4426def : Pat<(i32 imm:$imm),
4427 (IOHLr32 (ILHUr32 (HI16 imm:$imm)), (LO16 imm:$imm))>;
4428
4429// Single precision float constants:
Nate Begeman78125042008-02-14 18:43:04 +00004430def : Pat<(f32 fpimm:$imm),
Scott Michel8b6b4202007-12-04 22:35:58 +00004431 (IOHLf32 (ILHUf32 (HI16_f32 fpimm:$imm)), (LO16_f32 fpimm:$imm))>;
4432
4433// General constant 32-bit vectors
4434def : Pat<(v4i32 v4i32Imm:$imm),
Scott Michel6baba072008-03-05 23:02:02 +00004435 (IOHLv4i32 (v4i32 (ILHUv4i32 (HI16_vec v4i32Imm:$imm))),
4436 (LO16_vec v4i32Imm:$imm))>;
Scott Michel06eabde2008-12-27 04:51:36 +00004437
Scott Michel438be252007-12-17 22:32:34 +00004438// 8-bit constants
4439def : Pat<(i8 imm:$imm),
4440 (ILHr8 imm:$imm)>;
Scott Michel8b6b4202007-12-04 22:35:58 +00004441
4442//===----------------------------------------------------------------------===//
4443// Call instruction patterns:
4444//===----------------------------------------------------------------------===//
4445// Return void
4446def : Pat<(ret),
4447 (RET)>;
4448
4449//===----------------------------------------------------------------------===//
4450// Zero/Any/Sign extensions
4451//===----------------------------------------------------------------------===//
4452
Scott Michel8b6b4202007-12-04 22:35:58 +00004453// sext 8->32: Sign extend bytes to words
4454def : Pat<(sext_inreg R32C:$rSrc, i8),
4455 (XSHWr32 (XSBHr32 R32C:$rSrc))>;
4456
Scott Michel438be252007-12-17 22:32:34 +00004457def : Pat<(i32 (sext R8C:$rSrc)),
4458 (XSHWr16 (XSBHr8 R8C:$rSrc))>;
4459
Scott Michel2ef773a2009-01-06 03:36:14 +00004460// sext 8->64: Sign extend bytes to double word
4461def : Pat<(sext_inreg R64C:$rSrc, i8),
4462 (XSWDr64_inreg (XSHWr64 (XSBHr64 R64C:$rSrc)))>;
4463
4464def : Pat<(i64 (sext R8C:$rSrc)),
4465 (XSWDr64 (XSHWr16 (XSBHr8 R8C:$rSrc)))>;
4466
Scott Michel438be252007-12-17 22:32:34 +00004467// zext 8->16: Zero extend bytes to halfwords
4468def : Pat<(i16 (zext R8C:$rSrc)),
Scott Michel97872d32008-02-23 18:41:37 +00004469 (ANDHIi8i16 R8C:$rSrc, 0xff)>;
Scott Michel438be252007-12-17 22:32:34 +00004470
Scott Michel438be252007-12-17 22:32:34 +00004471// zext 8->32: Zero extend bytes to words
4472def : Pat<(i32 (zext R8C:$rSrc)),
Scott Michel97872d32008-02-23 18:41:37 +00004473 (ANDIi8i32 R8C:$rSrc, 0xff)>;
Scott Michel438be252007-12-17 22:32:34 +00004474
Scott Michel2ef773a2009-01-06 03:36:14 +00004475// zext 8->64: Zero extend bytes to double words
4476def : Pat<(i64 (zext R8C:$rSrc)),
4477 (ORi64_v2i64 (SELBv4i32 (ROTQMBYv4i32
4478 (ORv4i32_i32 (ANDIi8i32 R8C:$rSrc, 0xff)),
4479 0x4),
4480 (ILv4i32 0x0),
4481 (FSMBIv4i32 0x0f0f)))>;
4482
4483// anyext 8->16: Extend 8->16 bits, irrespective of sign, preserves high bits
Scott Michel438be252007-12-17 22:32:34 +00004484def : Pat<(i16 (anyext R8C:$rSrc)),
Scott Michel97872d32008-02-23 18:41:37 +00004485 (ORHIi8i16 R8C:$rSrc, 0)>;
Scott Michel438be252007-12-17 22:32:34 +00004486
Scott Michel2ef773a2009-01-06 03:36:14 +00004487// anyext 8->32: Extend 8->32 bits, irrespective of sign, preserves high bits
Scott Michel438be252007-12-17 22:32:34 +00004488def : Pat<(i32 (anyext R8C:$rSrc)),
Scott Michel97872d32008-02-23 18:41:37 +00004489 (ORIi8i32 R8C:$rSrc, 0)>;
Scott Michel438be252007-12-17 22:32:34 +00004490
Scott Michel2ef773a2009-01-06 03:36:14 +00004491// sext 16->64: Sign extend halfword to double word
4492def : Pat<(sext_inreg R64C:$rSrc, i16),
4493 (XSWDr64_inreg (XSHWr64 R64C:$rSrc))>;
4494
4495def : Pat<(sext R16C:$rSrc),
4496 (XSWDr64 (XSHWr16 R16C:$rSrc))>;
4497
Scott Michel97872d32008-02-23 18:41:37 +00004498// zext 16->32: Zero extend halfwords to words
Scott Michel8b6b4202007-12-04 22:35:58 +00004499def : Pat<(i32 (zext R16C:$rSrc)),
Scott Michel97872d32008-02-23 18:41:37 +00004500 (ANDi16i32 R16C:$rSrc, (ILAr32 0xffff))>;
Scott Michel8b6b4202007-12-04 22:35:58 +00004501
4502def : Pat<(i32 (zext (and R16C:$rSrc, 0xf))),
Scott Michel97872d32008-02-23 18:41:37 +00004503 (ANDIi16i32 R16C:$rSrc, 0xf)>;
Scott Michel8b6b4202007-12-04 22:35:58 +00004504
4505def : Pat<(i32 (zext (and R16C:$rSrc, 0xff))),
Scott Michel97872d32008-02-23 18:41:37 +00004506 (ANDIi16i32 R16C:$rSrc, 0xff)>;
Scott Michel8b6b4202007-12-04 22:35:58 +00004507
4508def : Pat<(i32 (zext (and R16C:$rSrc, 0xfff))),
Scott Michel97872d32008-02-23 18:41:37 +00004509 (ANDIi16i32 R16C:$rSrc, 0xfff)>;
Scott Michel8b6b4202007-12-04 22:35:58 +00004510
4511// anyext 16->32: Extend 16->32 bits, irrespective of sign
4512def : Pat<(i32 (anyext R16C:$rSrc)),
Scott Michel97872d32008-02-23 18:41:37 +00004513 (ORIi16i32 R16C:$rSrc, 0)>;
Scott Michel8b6b4202007-12-04 22:35:58 +00004514
4515//===----------------------------------------------------------------------===//
Scott Michel06eabde2008-12-27 04:51:36 +00004516// Truncates:
4517// These truncates are for the SPU's supported types (i8, i16, i32). i64 and
4518// above are custom lowered.
4519//===----------------------------------------------------------------------===//
4520
4521def : Pat<(i8 (trunc GPRC:$src)),
4522 (ORi8_v16i8
4523 (SHUFBgprc GPRC:$src, GPRC:$src,
4524 (IOHLv4i32 (ILHUv4i32 0x0f0f), 0x0f0f)))>;
4525
4526def : Pat<(i8 (trunc R64C:$src)),
4527 (ORi8_v16i8
4528 (SHUFBv2i64_m32
4529 (ORv2i64_i64 R64C:$src),
4530 (ORv2i64_i64 R64C:$src),
4531 (IOHLv4i32 (ILHUv4i32 0x0707), 0x0707)))>;
4532
4533def : Pat<(i8 (trunc R32C:$src)),
4534 (ORi8_v16i8
4535 (SHUFBv4i32_m32
4536 (ORv4i32_i32 R32C:$src),
4537 (ORv4i32_i32 R32C:$src),
4538 (IOHLv4i32 (ILHUv4i32 0x0303), 0x0303)))>;
4539
4540def : Pat<(i8 (trunc R16C:$src)),
4541 (ORi8_v16i8
4542 (SHUFBv4i32_m32
4543 (ORv8i16_i16 R16C:$src),
4544 (ORv8i16_i16 R16C:$src),
4545 (IOHLv4i32 (ILHUv4i32 0x0303), 0x0303)))>;
4546
4547def : Pat<(i16 (trunc GPRC:$src)),
4548 (ORi16_v8i16
4549 (SHUFBgprc GPRC:$src, GPRC:$src,
4550 (IOHLv4i32 (ILHUv4i32 0x0e0f), 0x0e0f)))>;
4551
4552def : Pat<(i16 (trunc R64C:$src)),
4553 (ORi16_v8i16
4554 (SHUFBv2i64_m32
4555 (ORv2i64_i64 R64C:$src),
4556 (ORv2i64_i64 R64C:$src),
4557 (IOHLv4i32 (ILHUv4i32 0x0607), 0x0607)))>;
4558
4559def : Pat<(i16 (trunc R32C:$src)),
4560 (ORi16_v8i16
4561 (SHUFBv4i32_m32
4562 (ORv4i32_i32 R32C:$src),
4563 (ORv4i32_i32 R32C:$src),
4564 (IOHLv4i32 (ILHUv4i32 0x0203), 0x0203)))>;
4565
4566def : Pat<(i32 (trunc GPRC:$src)),
4567 (ORi32_v4i32
4568 (SHUFBgprc GPRC:$src, GPRC:$src,
4569 (IOHLv4i32 (ILHUv4i32 0x0c0d), 0x0e0f)))>;
4570
4571def : Pat<(i32 (trunc R64C:$src)),
4572 (ORi32_v4i32
4573 (SHUFBv2i64_m32
4574 (ORv2i64_i64 R64C:$src),
4575 (ORv2i64_i64 R64C:$src),
4576 (IOHLv4i32 (ILHUv4i32 0x0405), 0x0607)))>;
4577
4578//===----------------------------------------------------------------------===//
Scott Michelf9f42e62008-01-29 02:16:57 +00004579// Address generation: SPU, like PPC, has to split addresses into high and
Scott Michel8b6b4202007-12-04 22:35:58 +00004580// low parts in order to load them into a register.
4581//===----------------------------------------------------------------------===//
4582
Scott Michelf9f42e62008-01-29 02:16:57 +00004583def : Pat<(SPUaform tglobaladdr:$in, 0), (ILAlsa tglobaladdr:$in)>;
4584def : Pat<(SPUaform texternalsym:$in, 0), (ILAlsa texternalsym:$in)>;
4585def : Pat<(SPUaform tjumptable:$in, 0), (ILAlsa tjumptable:$in)>;
4586def : Pat<(SPUaform tconstpool:$in, 0), (ILAlsa tconstpool:$in)>;
4587
4588def : Pat<(SPUindirect (SPUhi tglobaladdr:$in, 0),
4589 (SPUlo tglobaladdr:$in, 0)),
Scott Micheldbac4cf2008-01-11 02:53:15 +00004590 (IOHLlo (ILHUhi tglobaladdr:$in), tglobaladdr:$in)>;
Scott Michel394e26d2008-01-17 20:38:41 +00004591
Scott Michelf9f42e62008-01-29 02:16:57 +00004592def : Pat<(SPUindirect (SPUhi texternalsym:$in, 0),
4593 (SPUlo texternalsym:$in, 0)),
4594 (IOHLlo (ILHUhi texternalsym:$in), texternalsym:$in)>;
4595
4596def : Pat<(SPUindirect (SPUhi tjumptable:$in, 0),
4597 (SPUlo tjumptable:$in, 0)),
Scott Micheldbac4cf2008-01-11 02:53:15 +00004598 (IOHLlo (ILHUhi tjumptable:$in), tjumptable:$in)>;
Scott Michel394e26d2008-01-17 20:38:41 +00004599
Scott Michelf9f42e62008-01-29 02:16:57 +00004600def : Pat<(SPUindirect (SPUhi tconstpool:$in, 0),
4601 (SPUlo tconstpool:$in, 0)),
4602 (IOHLlo (ILHUhi tconstpool:$in), tconstpool:$in)>;
4603
4604def : Pat<(add (SPUhi tglobaladdr:$in, 0), (SPUlo tglobaladdr:$in, 0)),
4605 (IOHLlo (ILHUhi tglobaladdr:$in), tglobaladdr:$in)>;
4606
4607def : Pat<(add (SPUhi texternalsym:$in, 0), (SPUlo texternalsym:$in, 0)),
4608 (IOHLlo (ILHUhi texternalsym:$in), texternalsym:$in)>;
4609
4610def : Pat<(add (SPUhi tjumptable:$in, 0), (SPUlo tjumptable:$in, 0)),
4611 (IOHLlo (ILHUhi tjumptable:$in), tjumptable:$in)>;
4612
4613def : Pat<(add (SPUhi tconstpool:$in, 0), (SPUlo tconstpool:$in, 0)),
4614 (IOHLlo (ILHUhi tconstpool:$in), tconstpool:$in)>;
Scott Michel8b6b4202007-12-04 22:35:58 +00004615
Scott Michel34712c32009-03-16 18:47:25 +00004616// Intrinsics:
Scott Michel8b6b4202007-12-04 22:35:58 +00004617include "CellSDKIntrinsics.td"
Scott Michel4d07fb72008-12-30 23:28:25 +00004618// Various math operator instruction sequences
4619include "SPUMathInstr.td"
Scott Michel06eabde2008-12-27 04:51:36 +00004620// 64-bit "instructions"/support
4621include "SPU64InstrInfo.td"
Scott Michel2ef773a2009-01-06 03:36:14 +00004622// 128-bit "instructions"/support
4623include "SPU128InstrInfo.td"