Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 1 | //==- SPUInstrInfo.td - Describe the Cell SPU Instructions -*- tablegen -*-==// |
Scott Michel | 06eabde | 2008-12-27 04:51:36 +0000 | [diff] [blame^] | 2 | // |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Chris Lattner | 081ce94 | 2007-12-29 20:36:04 +0000 | [diff] [blame] | 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
Scott Michel | 06eabde | 2008-12-27 04:51:36 +0000 | [diff] [blame^] | 7 | // |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 8 | //===----------------------------------------------------------------------===// |
| 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 | |
| 24 | let hasCtrlDep = 1, Defs = [R1], Uses = [R1] in { |
Scott Michel | bc5fbc1 | 2008-04-30 00:30:08 +0000 | [diff] [blame] | 25 | def ADJCALLSTACKDOWN : Pseudo<(outs), (ins u16imm_i32:$amt), |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 26 | "${:comment} ADJCALLSTACKDOWN", |
Chris Lattner | fe5d402 | 2008-10-11 22:08:30 +0000 | [diff] [blame] | 27 | [(callseq_start timm:$amt)]>; |
Scott Michel | bc5fbc1 | 2008-04-30 00:30:08 +0000 | [diff] [blame] | 28 | def ADJCALLSTACKUP : Pseudo<(outs), (ins u16imm_i32:$amt), |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 29 | "${:comment} ADJCALLSTACKUP", |
Chris Lattner | fe5d402 | 2008-10-11 22:08:30 +0000 | [diff] [blame] | 30 | [(callseq_end timm:$amt)]>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 31 | } |
| 32 | |
| 33 | //===----------------------------------------------------------------------===// |
| 34 | // DWARF debugging Pseudo Instructions |
| 35 | //===----------------------------------------------------------------------===// |
| 36 | |
| 37 | def DWARF_LOC : Pseudo<(outs), (ins i32imm:$line, i32imm:$col, i32imm:$file), |
| 38 | "${:comment} .loc $file, $line, $col", |
| 39 | [(dwarf_loc (i32 imm:$line), (i32 imm:$col), |
| 40 | (i32 imm:$file))]>; |
| 41 | |
| 42 | //===----------------------------------------------------------------------===// |
| 43 | // Loads: |
| 44 | // NB: The ordering is actually important, since the instruction selection |
| 45 | // will try each of the instructions in sequence, i.e., the D-form first with |
| 46 | // the 10-bit displacement, then the A-form with the 16 bit displacement, and |
| 47 | // finally the X-form with the register-register. |
| 48 | //===----------------------------------------------------------------------===// |
| 49 | |
Dan Gohman | 5574cc7 | 2008-12-03 18:15:48 +0000 | [diff] [blame] | 50 | let canFoldAsLoad = 1 in { |
Scott Michel | f9f42e6 | 2008-01-29 02:16:57 +0000 | [diff] [blame] | 51 | class LoadDFormVec<ValueType vectype> |
Scott Michel | 06eabde | 2008-12-27 04:51:36 +0000 | [diff] [blame^] | 52 | : RI10Form<0b00101100, (outs VECREG:$rT), (ins dformaddr:$src), |
Scott Michel | f9f42e6 | 2008-01-29 02:16:57 +0000 | [diff] [blame] | 53 | "lqd\t$rT, $src", |
| 54 | LoadStore, |
| 55 | [(set (vectype VECREG:$rT), (load dform_addr:$src))]> |
| 56 | { } |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 57 | |
Scott Michel | f9f42e6 | 2008-01-29 02:16:57 +0000 | [diff] [blame] | 58 | class LoadDForm<RegisterClass rclass> |
Scott Michel | 06eabde | 2008-12-27 04:51:36 +0000 | [diff] [blame^] | 59 | : RI10Form<0b00101100, (outs rclass:$rT), (ins dformaddr:$src), |
Scott Michel | f9f42e6 | 2008-01-29 02:16:57 +0000 | [diff] [blame] | 60 | "lqd\t$rT, $src", |
| 61 | LoadStore, |
| 62 | [(set rclass:$rT, (load dform_addr:$src))]> |
| 63 | { } |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 64 | |
Scott Michel | f9f42e6 | 2008-01-29 02:16:57 +0000 | [diff] [blame] | 65 | multiclass LoadDForms |
| 66 | { |
| 67 | def v16i8: LoadDFormVec<v16i8>; |
| 68 | def v8i16: LoadDFormVec<v8i16>; |
| 69 | def v4i32: LoadDFormVec<v4i32>; |
| 70 | def v2i64: LoadDFormVec<v2i64>; |
| 71 | def v4f32: LoadDFormVec<v4f32>; |
| 72 | def v2f64: LoadDFormVec<v2f64>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 73 | |
Scott Michel | f9f42e6 | 2008-01-29 02:16:57 +0000 | [diff] [blame] | 74 | def r128: LoadDForm<GPRC>; |
| 75 | def r64: LoadDForm<R64C>; |
| 76 | def r32: LoadDForm<R32C>; |
| 77 | def f32: LoadDForm<R32FP>; |
| 78 | def f64: LoadDForm<R64FP>; |
| 79 | def r16: LoadDForm<R16C>; |
| 80 | def r8: LoadDForm<R8C>; |
| 81 | } |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 82 | |
Scott Michel | f9f42e6 | 2008-01-29 02:16:57 +0000 | [diff] [blame] | 83 | class LoadAFormVec<ValueType vectype> |
| 84 | : RI16Form<0b100001100, (outs VECREG:$rT), (ins addr256k:$src), |
| 85 | "lqa\t$rT, $src", |
| 86 | LoadStore, |
| 87 | [(set (vectype VECREG:$rT), (load aform_addr:$src))]> |
| 88 | { } |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 89 | |
Scott Michel | f9f42e6 | 2008-01-29 02:16:57 +0000 | [diff] [blame] | 90 | class LoadAForm<RegisterClass rclass> |
| 91 | : RI16Form<0b100001100, (outs rclass:$rT), (ins addr256k:$src), |
| 92 | "lqa\t$rT, $src", |
| 93 | LoadStore, |
| 94 | [(set rclass:$rT, (load aform_addr:$src))]> |
| 95 | { } |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 96 | |
Scott Michel | f9f42e6 | 2008-01-29 02:16:57 +0000 | [diff] [blame] | 97 | multiclass LoadAForms |
| 98 | { |
| 99 | def v16i8: LoadAFormVec<v16i8>; |
| 100 | def v8i16: LoadAFormVec<v8i16>; |
| 101 | def v4i32: LoadAFormVec<v4i32>; |
| 102 | def v2i64: LoadAFormVec<v2i64>; |
| 103 | def v4f32: LoadAFormVec<v4f32>; |
| 104 | def v2f64: LoadAFormVec<v2f64>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 105 | |
Scott Michel | f9f42e6 | 2008-01-29 02:16:57 +0000 | [diff] [blame] | 106 | def r128: LoadAForm<GPRC>; |
| 107 | def r64: LoadAForm<R64C>; |
| 108 | def r32: LoadAForm<R32C>; |
| 109 | def f32: LoadAForm<R32FP>; |
| 110 | def f64: LoadAForm<R64FP>; |
| 111 | def r16: LoadAForm<R16C>; |
| 112 | def r8: LoadAForm<R8C>; |
| 113 | } |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 114 | |
Scott Michel | f9f42e6 | 2008-01-29 02:16:57 +0000 | [diff] [blame] | 115 | class LoadXFormVec<ValueType vectype> |
| 116 | : RRForm<0b00100011100, (outs VECREG:$rT), (ins memrr:$src), |
| 117 | "lqx\t$rT, $src", |
| 118 | LoadStore, |
| 119 | [(set (vectype VECREG:$rT), (load xform_addr:$src))]> |
| 120 | { } |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 121 | |
Scott Michel | f9f42e6 | 2008-01-29 02:16:57 +0000 | [diff] [blame] | 122 | class LoadXForm<RegisterClass rclass> |
| 123 | : RRForm<0b00100011100, (outs rclass:$rT), (ins memrr:$src), |
| 124 | "lqx\t$rT, $src", |
| 125 | LoadStore, |
| 126 | [(set rclass:$rT, (load xform_addr:$src))]> |
| 127 | { } |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 128 | |
Scott Michel | f9f42e6 | 2008-01-29 02:16:57 +0000 | [diff] [blame] | 129 | multiclass LoadXForms |
| 130 | { |
| 131 | def v16i8: LoadXFormVec<v16i8>; |
| 132 | def v8i16: LoadXFormVec<v8i16>; |
| 133 | def v4i32: LoadXFormVec<v4i32>; |
| 134 | def v2i64: LoadXFormVec<v2i64>; |
| 135 | def v4f32: LoadXFormVec<v4f32>; |
| 136 | def v2f64: LoadXFormVec<v2f64>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 137 | |
Scott Michel | f9f42e6 | 2008-01-29 02:16:57 +0000 | [diff] [blame] | 138 | def r128: LoadXForm<GPRC>; |
| 139 | def r64: LoadXForm<R64C>; |
| 140 | def r32: LoadXForm<R32C>; |
| 141 | def f32: LoadXForm<R32FP>; |
| 142 | def f64: LoadXForm<R64FP>; |
| 143 | def r16: LoadXForm<R16C>; |
| 144 | def r8: LoadXForm<R8C>; |
| 145 | } |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 146 | |
Scott Michel | f9f42e6 | 2008-01-29 02:16:57 +0000 | [diff] [blame] | 147 | defm LQA : LoadAForms; |
| 148 | defm LQD : LoadDForms; |
| 149 | defm LQX : LoadXForms; |
Scott Michel | 438be25 | 2007-12-17 22:32:34 +0000 | [diff] [blame] | 150 | |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 151 | /* Load quadword, PC relative: Not much use at this point in time. |
Scott Michel | f9f42e6 | 2008-01-29 02:16:57 +0000 | [diff] [blame] | 152 | Might be of use later for relocatable code. It's effectively the |
| 153 | same as LQA, but uses PC-relative addressing. |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 154 | def LQR : RI16Form<0b111001100, (outs VECREG:$rT), (ins s16imm:$disp), |
| 155 | "lqr\t$rT, $disp", LoadStore, |
| 156 | [(set VECREG:$rT, (load iaddr:$disp))]>; |
| 157 | */ |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 158 | } |
| 159 | |
| 160 | //===----------------------------------------------------------------------===// |
| 161 | // Stores: |
| 162 | //===----------------------------------------------------------------------===// |
Scott Michel | f9f42e6 | 2008-01-29 02:16:57 +0000 | [diff] [blame] | 163 | class StoreDFormVec<ValueType vectype> |
Scott Michel | 06eabde | 2008-12-27 04:51:36 +0000 | [diff] [blame^] | 164 | : RI10Form<0b00100100, (outs), (ins VECREG:$rT, dformaddr:$src), |
Scott Michel | f9f42e6 | 2008-01-29 02:16:57 +0000 | [diff] [blame] | 165 | "stqd\t$rT, $src", |
| 166 | LoadStore, |
| 167 | [(store (vectype VECREG:$rT), dform_addr:$src)]> |
| 168 | { } |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 169 | |
Scott Michel | f9f42e6 | 2008-01-29 02:16:57 +0000 | [diff] [blame] | 170 | class StoreDForm<RegisterClass rclass> |
Scott Michel | 06eabde | 2008-12-27 04:51:36 +0000 | [diff] [blame^] | 171 | : RI10Form<0b00100100, (outs), (ins rclass:$rT, dformaddr:$src), |
Scott Michel | f9f42e6 | 2008-01-29 02:16:57 +0000 | [diff] [blame] | 172 | "stqd\t$rT, $src", |
| 173 | LoadStore, |
| 174 | [(store rclass:$rT, dform_addr:$src)]> |
| 175 | { } |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 176 | |
Scott Michel | f9f42e6 | 2008-01-29 02:16:57 +0000 | [diff] [blame] | 177 | multiclass StoreDForms |
| 178 | { |
| 179 | def v16i8: StoreDFormVec<v16i8>; |
| 180 | def v8i16: StoreDFormVec<v8i16>; |
| 181 | def v4i32: StoreDFormVec<v4i32>; |
| 182 | def v2i64: StoreDFormVec<v2i64>; |
| 183 | def v4f32: StoreDFormVec<v4f32>; |
| 184 | def v2f64: StoreDFormVec<v2f64>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 185 | |
Scott Michel | f9f42e6 | 2008-01-29 02:16:57 +0000 | [diff] [blame] | 186 | def r128: StoreDForm<GPRC>; |
| 187 | def r64: StoreDForm<R64C>; |
| 188 | def r32: StoreDForm<R32C>; |
| 189 | def f32: StoreDForm<R32FP>; |
| 190 | def f64: StoreDForm<R64FP>; |
| 191 | def r16: StoreDForm<R16C>; |
| 192 | def r8: StoreDForm<R8C>; |
| 193 | } |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 194 | |
Scott Michel | f9f42e6 | 2008-01-29 02:16:57 +0000 | [diff] [blame] | 195 | class StoreAFormVec<ValueType vectype> |
| 196 | : RI16Form<0b0010010, (outs), (ins VECREG:$rT, addr256k:$src), |
Scott Michel | 5a6f17b | 2008-01-30 02:55:46 +0000 | [diff] [blame] | 197 | "stqa\t$rT, $src", |
| 198 | LoadStore, |
Scott Michel | 6baba07 | 2008-03-05 23:02:02 +0000 | [diff] [blame] | 199 | [(store (vectype VECREG:$rT), aform_addr:$src)]>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 200 | |
Scott Michel | f9f42e6 | 2008-01-29 02:16:57 +0000 | [diff] [blame] | 201 | class StoreAForm<RegisterClass rclass> |
| 202 | : RI16Form<0b001001, (outs), (ins rclass:$rT, addr256k:$src), |
Scott Michel | 5a6f17b | 2008-01-30 02:55:46 +0000 | [diff] [blame] | 203 | "stqa\t$rT, $src", |
| 204 | LoadStore, |
Scott Michel | 6baba07 | 2008-03-05 23:02:02 +0000 | [diff] [blame] | 205 | [(store rclass:$rT, aform_addr:$src)]>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 206 | |
Scott Michel | f9f42e6 | 2008-01-29 02:16:57 +0000 | [diff] [blame] | 207 | multiclass StoreAForms |
| 208 | { |
| 209 | def v16i8: StoreAFormVec<v16i8>; |
| 210 | def v8i16: StoreAFormVec<v8i16>; |
| 211 | def v4i32: StoreAFormVec<v4i32>; |
| 212 | def v2i64: StoreAFormVec<v2i64>; |
| 213 | def v4f32: StoreAFormVec<v4f32>; |
| 214 | def v2f64: StoreAFormVec<v2f64>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 215 | |
Scott Michel | f9f42e6 | 2008-01-29 02:16:57 +0000 | [diff] [blame] | 216 | def r128: StoreAForm<GPRC>; |
| 217 | def r64: StoreAForm<R64C>; |
| 218 | def r32: StoreAForm<R32C>; |
| 219 | def f32: StoreAForm<R32FP>; |
| 220 | def f64: StoreAForm<R64FP>; |
| 221 | def r16: StoreAForm<R16C>; |
| 222 | def r8: StoreAForm<R8C>; |
| 223 | } |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 224 | |
Scott Michel | f9f42e6 | 2008-01-29 02:16:57 +0000 | [diff] [blame] | 225 | class StoreXFormVec<ValueType vectype> |
| 226 | : RRForm<0b00100100, (outs), (ins VECREG:$rT, memrr:$src), |
Scott Michel | 5a6f17b | 2008-01-30 02:55:46 +0000 | [diff] [blame] | 227 | "stqx\t$rT, $src", |
| 228 | LoadStore, |
| 229 | [(store (vectype VECREG:$rT), xform_addr:$src)]> |
Scott Michel | f9f42e6 | 2008-01-29 02:16:57 +0000 | [diff] [blame] | 230 | { } |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 231 | |
Scott Michel | f9f42e6 | 2008-01-29 02:16:57 +0000 | [diff] [blame] | 232 | class StoreXForm<RegisterClass rclass> |
| 233 | : RRForm<0b00100100, (outs), (ins rclass:$rT, memrr:$src), |
Scott Michel | 5a6f17b | 2008-01-30 02:55:46 +0000 | [diff] [blame] | 234 | "stqx\t$rT, $src", |
| 235 | LoadStore, |
| 236 | [(store rclass:$rT, xform_addr:$src)]> |
Scott Michel | f9f42e6 | 2008-01-29 02:16:57 +0000 | [diff] [blame] | 237 | { } |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 238 | |
Scott Michel | f9f42e6 | 2008-01-29 02:16:57 +0000 | [diff] [blame] | 239 | multiclass StoreXForms |
| 240 | { |
| 241 | def v16i8: StoreXFormVec<v16i8>; |
| 242 | def v8i16: StoreXFormVec<v8i16>; |
| 243 | def v4i32: StoreXFormVec<v4i32>; |
| 244 | def v2i64: StoreXFormVec<v2i64>; |
| 245 | def v4f32: StoreXFormVec<v4f32>; |
| 246 | def v2f64: StoreXFormVec<v2f64>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 247 | |
Scott Michel | f9f42e6 | 2008-01-29 02:16:57 +0000 | [diff] [blame] | 248 | def r128: StoreXForm<GPRC>; |
| 249 | def r64: StoreXForm<R64C>; |
| 250 | def r32: StoreXForm<R32C>; |
| 251 | def f32: StoreXForm<R32FP>; |
| 252 | def f64: StoreXForm<R64FP>; |
| 253 | def r16: StoreXForm<R16C>; |
| 254 | def r8: StoreXForm<R8C>; |
| 255 | } |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 256 | |
Scott Michel | f9f42e6 | 2008-01-29 02:16:57 +0000 | [diff] [blame] | 257 | defm STQD : StoreDForms; |
| 258 | defm STQA : StoreAForms; |
| 259 | defm STQX : StoreXForms; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 260 | |
| 261 | /* Store quadword, PC relative: Not much use at this point in time. Might |
Scott Michel | f9f42e6 | 2008-01-29 02:16:57 +0000 | [diff] [blame] | 262 | be useful for relocatable code. |
Chris Lattner | ef8d608 | 2008-01-06 06:44:58 +0000 | [diff] [blame] | 263 | def STQR : RI16Form<0b111000100, (outs), (ins VECREG:$rT, s16imm:$disp), |
| 264 | "stqr\t$rT, $disp", LoadStore, |
| 265 | [(store VECREG:$rT, iaddr:$disp)]>; |
| 266 | */ |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 267 | |
| 268 | //===----------------------------------------------------------------------===// |
| 269 | // Generate Controls for Insertion: |
| 270 | //===----------------------------------------------------------------------===// |
| 271 | |
Scott Michel | 06eabde | 2008-12-27 04:51:36 +0000 | [diff] [blame^] | 272 | def CBD: RI7Form<0b10101111100, (outs VECREG:$rT), (ins shufaddr:$src), |
Scott Michel | 0718cd8 | 2008-12-01 17:56:02 +0000 | [diff] [blame] | 273 | "cbd\t$rT, $src", ShuffleOp, |
| 274 | [(set (v16i8 VECREG:$rT), (SPUshufmask dform2_addr:$src))]>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 275 | |
Scott Michel | 0718cd8 | 2008-12-01 17:56:02 +0000 | [diff] [blame] | 276 | def CBX: RRForm<0b00101011100, (outs VECREG:$rT), (ins memrr:$src), |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 277 | "cbx\t$rT, $src", ShuffleOp, |
Scott Michel | 56a125e | 2008-11-22 23:50:42 +0000 | [diff] [blame] | 278 | [(set (v16i8 VECREG:$rT), (SPUshufmask xform_addr:$src))]>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 279 | |
Scott Michel | 06eabde | 2008-12-27 04:51:36 +0000 | [diff] [blame^] | 280 | def CHD: RI7Form<0b10101111100, (outs VECREG:$rT), (ins shufaddr:$src), |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 281 | "chd\t$rT, $src", ShuffleOp, |
Scott Michel | 56a125e | 2008-11-22 23:50:42 +0000 | [diff] [blame] | 282 | [(set (v8i16 VECREG:$rT), (SPUshufmask dform2_addr:$src))]>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 283 | |
Scott Michel | 0718cd8 | 2008-12-01 17:56:02 +0000 | [diff] [blame] | 284 | def CHX: RRForm<0b10101011100, (outs VECREG:$rT), (ins memrr:$src), |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 285 | "chx\t$rT, $src", ShuffleOp, |
Scott Michel | 56a125e | 2008-11-22 23:50:42 +0000 | [diff] [blame] | 286 | [(set (v8i16 VECREG:$rT), (SPUshufmask xform_addr:$src))]>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 287 | |
Scott Michel | 06eabde | 2008-12-27 04:51:36 +0000 | [diff] [blame^] | 288 | def CWD: RI7Form<0b01101111100, (outs VECREG:$rT), (ins shufaddr:$src), |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 289 | "cwd\t$rT, $src", ShuffleOp, |
Scott Michel | 56a125e | 2008-11-22 23:50:42 +0000 | [diff] [blame] | 290 | [(set (v4i32 VECREG:$rT), (SPUshufmask dform2_addr:$src))]>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 291 | |
Scott Michel | 0718cd8 | 2008-12-01 17:56:02 +0000 | [diff] [blame] | 292 | def CWX: RRForm<0b01101011100, (outs VECREG:$rT), (ins memrr:$src), |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 293 | "cwx\t$rT, $src", ShuffleOp, |
Scott Michel | 56a125e | 2008-11-22 23:50:42 +0000 | [diff] [blame] | 294 | [(set (v4i32 VECREG:$rT), (SPUshufmask xform_addr:$src))]>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 295 | |
Scott Michel | 06eabde | 2008-12-27 04:51:36 +0000 | [diff] [blame^] | 296 | def CWDf32: RI7Form<0b01101111100, (outs VECREG:$rT), (ins shufaddr:$src), |
Scott Michel | 0718cd8 | 2008-12-01 17:56:02 +0000 | [diff] [blame] | 297 | "cwd\t$rT, $src", ShuffleOp, |
| 298 | [(set (v4f32 VECREG:$rT), (SPUshufmask dform2_addr:$src))]>; |
| 299 | |
| 300 | def CWXf32: RRForm<0b01101011100, (outs VECREG:$rT), (ins memrr:$src), |
Scott Michel | bc5fbc1 | 2008-04-30 00:30:08 +0000 | [diff] [blame] | 301 | "cwx\t$rT, $src", ShuffleOp, |
Scott Michel | 56a125e | 2008-11-22 23:50:42 +0000 | [diff] [blame] | 302 | [(set (v4f32 VECREG:$rT), (SPUshufmask xform_addr:$src))]>; |
Scott Michel | bc5fbc1 | 2008-04-30 00:30:08 +0000 | [diff] [blame] | 303 | |
Scott Michel | 06eabde | 2008-12-27 04:51:36 +0000 | [diff] [blame^] | 304 | def CDD: RI7Form<0b11101111100, (outs VECREG:$rT), (ins shufaddr:$src), |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 305 | "cdd\t$rT, $src", ShuffleOp, |
Scott Michel | 56a125e | 2008-11-22 23:50:42 +0000 | [diff] [blame] | 306 | [(set (v2i64 VECREG:$rT), (SPUshufmask dform2_addr:$src))]>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 307 | |
Scott Michel | 0718cd8 | 2008-12-01 17:56:02 +0000 | [diff] [blame] | 308 | def CDX: RRForm<0b11101011100, (outs VECREG:$rT), (ins memrr:$src), |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 309 | "cdx\t$rT, $src", ShuffleOp, |
Scott Michel | 56a125e | 2008-11-22 23:50:42 +0000 | [diff] [blame] | 310 | [(set (v2i64 VECREG:$rT), (SPUshufmask xform_addr:$src))]>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 311 | |
Scott Michel | 06eabde | 2008-12-27 04:51:36 +0000 | [diff] [blame^] | 312 | def CDDf64: RI7Form<0b11101111100, (outs VECREG:$rT), (ins shufaddr:$src), |
Scott Michel | 0718cd8 | 2008-12-01 17:56:02 +0000 | [diff] [blame] | 313 | "cdd\t$rT, $src", ShuffleOp, |
| 314 | [(set (v2f64 VECREG:$rT), (SPUshufmask dform2_addr:$src))]>; |
| 315 | |
| 316 | def CDXf64: RRForm<0b11101011100, (outs VECREG:$rT), (ins memrr:$src), |
Scott Michel | bc5fbc1 | 2008-04-30 00:30:08 +0000 | [diff] [blame] | 317 | "cdx\t$rT, $src", ShuffleOp, |
Scott Michel | 56a125e | 2008-11-22 23:50:42 +0000 | [diff] [blame] | 318 | [(set (v2f64 VECREG:$rT), (SPUshufmask xform_addr:$src))]>; |
Scott Michel | bc5fbc1 | 2008-04-30 00:30:08 +0000 | [diff] [blame] | 319 | |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 320 | //===----------------------------------------------------------------------===// |
| 321 | // Constant formation: |
| 322 | //===----------------------------------------------------------------------===// |
| 323 | |
| 324 | def ILHv8i16: |
| 325 | RI16Form<0b110000010, (outs VECREG:$rT), (ins s16imm:$val), |
| 326 | "ilh\t$rT, $val", ImmLoad, |
| 327 | [(set (v8i16 VECREG:$rT), (v8i16 v8i16SExt16Imm:$val))]>; |
| 328 | |
| 329 | def ILHr16: |
| 330 | RI16Form<0b110000010, (outs R16C:$rT), (ins s16imm:$val), |
| 331 | "ilh\t$rT, $val", ImmLoad, |
| 332 | [(set R16C:$rT, immSExt16:$val)]>; |
| 333 | |
Scott Michel | 438be25 | 2007-12-17 22:32:34 +0000 | [diff] [blame] | 334 | // Cell SPU doesn't have a native 8-bit immediate load, but ILH works ("with |
| 335 | // the right constant") |
| 336 | def ILHr8: |
| 337 | RI16Form<0b110000010, (outs R8C:$rT), (ins s16imm_i8:$val), |
| 338 | "ilh\t$rT, $val", ImmLoad, |
| 339 | [(set R8C:$rT, immSExt8:$val)]>; |
| 340 | |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 341 | // IL does sign extension! |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 342 | |
Scott Michel | 6baba07 | 2008-03-05 23:02:02 +0000 | [diff] [blame] | 343 | class ILInst<dag OOL, dag IOL, list<dag> pattern>: |
| 344 | RI16Form<0b100000010, OOL, IOL, "il\t$rT, $val", |
| 345 | ImmLoad, pattern>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 346 | |
Scott Michel | 6baba07 | 2008-03-05 23:02:02 +0000 | [diff] [blame] | 347 | class ILVecInst<ValueType vectype, Operand immtype, PatLeaf xform>: |
| 348 | ILInst<(outs VECREG:$rT), (ins immtype:$val), |
| 349 | [(set (vectype VECREG:$rT), (vectype xform:$val))]>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 350 | |
Scott Michel | 6baba07 | 2008-03-05 23:02:02 +0000 | [diff] [blame] | 351 | class ILRegInst<RegisterClass rclass, Operand immtype, PatLeaf xform>: |
| 352 | ILInst<(outs rclass:$rT), (ins immtype:$val), |
| 353 | [(set rclass:$rT, xform:$val)]>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 354 | |
Scott Michel | 6baba07 | 2008-03-05 23:02:02 +0000 | [diff] [blame] | 355 | multiclass ImmediateLoad |
| 356 | { |
| 357 | def v2i64: ILVecInst<v2i64, s16imm_i64, v2i64SExt16Imm>; |
| 358 | def v4i32: ILVecInst<v4i32, s16imm_i32, v4i32SExt16Imm>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 359 | |
Scott Michel | 6baba07 | 2008-03-05 23:02:02 +0000 | [diff] [blame] | 360 | // TODO: Need v2f64, v4f32 |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 361 | |
Scott Michel | 6baba07 | 2008-03-05 23:02:02 +0000 | [diff] [blame] | 362 | def r64: ILRegInst<R64C, s16imm_i64, immSExt16>; |
| 363 | def r32: ILRegInst<R32C, s16imm_i32, immSExt16>; |
| 364 | def f32: ILRegInst<R32FP, s16imm_f32, fpimmSExt16>; |
| 365 | def f64: ILRegInst<R64FP, s16imm_f64, fpimmSExt16>; |
| 366 | } |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 367 | |
Scott Michel | 6baba07 | 2008-03-05 23:02:02 +0000 | [diff] [blame] | 368 | defm IL : ImmediateLoad; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 369 | |
Scott Michel | 6baba07 | 2008-03-05 23:02:02 +0000 | [diff] [blame] | 370 | class ILHUInst<dag OOL, dag IOL, list<dag> pattern>: |
| 371 | RI16Form<0b010000010, OOL, IOL, "ilhu\t$rT, $val", |
| 372 | ImmLoad, pattern>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 373 | |
Scott Michel | 6baba07 | 2008-03-05 23:02:02 +0000 | [diff] [blame] | 374 | class ILHUVecInst<ValueType vectype, Operand immtype, PatLeaf xform>: |
| 375 | ILHUInst<(outs VECREG:$rT), (ins immtype:$val), |
| 376 | [(set (vectype VECREG:$rT), (vectype xform:$val))]>; |
| 377 | |
| 378 | class ILHURegInst<RegisterClass rclass, Operand immtype, PatLeaf xform>: |
| 379 | ILHUInst<(outs rclass:$rT), (ins immtype:$val), |
| 380 | [(set rclass:$rT, xform:$val)]>; |
| 381 | |
| 382 | multiclass ImmLoadHalfwordUpper |
| 383 | { |
| 384 | def v2i64: ILHUVecInst<v2i64, u16imm_i64, immILHUvec_i64>; |
Scott Michel | bc5fbc1 | 2008-04-30 00:30:08 +0000 | [diff] [blame] | 385 | def v4i32: ILHUVecInst<v4i32, u16imm_i32, immILHUvec>; |
Scott Michel | 6baba07 | 2008-03-05 23:02:02 +0000 | [diff] [blame] | 386 | |
| 387 | def r64: ILHURegInst<R64C, u16imm_i64, hi16>; |
Scott Michel | bc5fbc1 | 2008-04-30 00:30:08 +0000 | [diff] [blame] | 388 | def r32: ILHURegInst<R32C, u16imm_i32, hi16>; |
Scott Michel | 6baba07 | 2008-03-05 23:02:02 +0000 | [diff] [blame] | 389 | |
| 390 | // Loads the high portion of an address |
| 391 | def hi: ILHURegInst<R32C, symbolHi, hi16>; |
| 392 | |
| 393 | // Used in custom lowering constant SFP loads: |
| 394 | def f32: ILHURegInst<R32FP, f16imm, hi16_f32>; |
| 395 | } |
| 396 | |
| 397 | defm ILHU : ImmLoadHalfwordUpper; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 398 | |
| 399 | // Immediate load address (can also be used to load 18-bit unsigned constants, |
| 400 | // see the zext 16->32 pattern) |
Scott Michel | 6baba07 | 2008-03-05 23:02:02 +0000 | [diff] [blame] | 401 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 402 | class ILAInst<dag OOL, dag IOL, list<dag> pattern>: |
| 403 | RI18Form<0b1000010, OOL, IOL, "ila\t$rT, $val", |
| 404 | LoadNOP, pattern>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 405 | |
Scott Michel | 6baba07 | 2008-03-05 23:02:02 +0000 | [diff] [blame] | 406 | class ILAVecInst<ValueType vectype, Operand immtype, PatLeaf xform>: |
| 407 | ILAInst<(outs VECREG:$rT), (ins immtype:$val), |
| 408 | [(set (vectype VECREG:$rT), (vectype xform:$val))]>; |
| 409 | |
| 410 | class ILARegInst<RegisterClass rclass, Operand immtype, PatLeaf xform>: |
| 411 | ILAInst<(outs rclass:$rT), (ins immtype:$val), |
| 412 | [(set rclass:$rT, xform:$val)]>; |
| 413 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 414 | multiclass ImmLoadAddress |
| 415 | { |
Scott Michel | 6baba07 | 2008-03-05 23:02:02 +0000 | [diff] [blame] | 416 | def v2i64: ILAVecInst<v2i64, u18imm, v2i64Uns18Imm>; |
| 417 | def v4i32: ILAVecInst<v4i32, u18imm, v4i32Uns18Imm>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 418 | |
Scott Michel | 6baba07 | 2008-03-05 23:02:02 +0000 | [diff] [blame] | 419 | def r64: ILARegInst<R64C, u18imm_i64, imm18>; |
| 420 | def r32: ILARegInst<R32C, u18imm, imm18>; |
| 421 | def f32: ILARegInst<R32FP, f18imm, fpimm18>; |
| 422 | def f64: ILARegInst<R64FP, f18imm_f64, fpimm18>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 423 | |
Scott Michel | 06eabde | 2008-12-27 04:51:36 +0000 | [diff] [blame^] | 424 | def hi: ILARegInst<R32C, symbolHi, imm18>; |
Scott Michel | 6baba07 | 2008-03-05 23:02:02 +0000 | [diff] [blame] | 425 | def lo: ILARegInst<R32C, symbolLo, imm18>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 426 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 427 | def lsa: ILAInst<(outs R32C:$rT), (ins symbolLSA:$val), |
| 428 | [/* no pattern */]>; |
| 429 | } |
| 430 | |
| 431 | defm ILA : ImmLoadAddress; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 432 | |
| 433 | // Immediate OR, Halfword Lower: The "other" part of loading large constants |
| 434 | // into 32-bit registers. See the anonymous pattern Pat<(i32 imm:$imm), ...> |
| 435 | // Note that these are really two operand instructions, but they're encoded |
| 436 | // as three operands with the first two arguments tied-to each other. |
| 437 | |
Scott Michel | 6baba07 | 2008-03-05 23:02:02 +0000 | [diff] [blame] | 438 | class IOHLInst<dag OOL, dag IOL, list<dag> pattern>: |
| 439 | RI16Form<0b100000110, OOL, IOL, "iohl\t$rT, $val", |
| 440 | ImmLoad, pattern>, |
| 441 | RegConstraint<"$rS = $rT">, |
| 442 | NoEncode<"$rS">; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 443 | |
Scott Michel | 6baba07 | 2008-03-05 23:02:02 +0000 | [diff] [blame] | 444 | class IOHLVecInst<ValueType vectype, Operand immtype /* , PatLeaf xform */>: |
| 445 | IOHLInst<(outs VECREG:$rT), (ins VECREG:$rS, immtype:$val), |
| 446 | [/* no pattern */]>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 447 | |
Scott Michel | 6baba07 | 2008-03-05 23:02:02 +0000 | [diff] [blame] | 448 | class IOHLRegInst<RegisterClass rclass, Operand immtype /* , PatLeaf xform */>: |
| 449 | IOHLInst<(outs rclass:$rT), (ins rclass:$rS, immtype:$val), |
| 450 | [/* no pattern */]>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 451 | |
Scott Michel | 6baba07 | 2008-03-05 23:02:02 +0000 | [diff] [blame] | 452 | multiclass ImmOrHalfwordLower |
| 453 | { |
| 454 | def v2i64: IOHLVecInst<v2i64, u16imm_i64>; |
Scott Michel | bc5fbc1 | 2008-04-30 00:30:08 +0000 | [diff] [blame] | 455 | def v4i32: IOHLVecInst<v4i32, u16imm_i32>; |
Scott Michel | 6baba07 | 2008-03-05 23:02:02 +0000 | [diff] [blame] | 456 | |
| 457 | def r32: IOHLRegInst<R32C, i32imm>; |
| 458 | def f32: IOHLRegInst<R32FP, f32imm>; |
| 459 | |
| 460 | def lo: IOHLRegInst<R32C, symbolLo>; |
| 461 | } |
| 462 | |
| 463 | defm IOHL: ImmOrHalfwordLower; |
Scott Michel | dbac4cf | 2008-01-11 02:53:15 +0000 | [diff] [blame] | 464 | |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 465 | // Form select mask for bytes using immediate, used in conjunction with the |
| 466 | // SELB instruction: |
| 467 | |
Scott Michel | 6baba07 | 2008-03-05 23:02:02 +0000 | [diff] [blame] | 468 | class FSMBIVec<ValueType vectype>: |
| 469 | RI16Form<0b101001100, (outs VECREG:$rT), (ins u16imm:$val), |
| 470 | "fsmbi\t$rT, $val", |
| 471 | SelectOp, |
Scott Michel | 67224b2 | 2008-06-02 22:18:03 +0000 | [diff] [blame] | 472 | [(set (vectype VECREG:$rT), (SPUselmask (i16 immU16:$val)))]>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 473 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 474 | multiclass FormSelectMaskBytesImm |
Scott Michel | f9f42e6 | 2008-01-29 02:16:57 +0000 | [diff] [blame] | 475 | { |
| 476 | def v16i8: FSMBIVec<v16i8>; |
| 477 | def v8i16: FSMBIVec<v8i16>; |
| 478 | def v4i32: FSMBIVec<v4i32>; |
| 479 | def v2i64: FSMBIVec<v2i64>; |
| 480 | } |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 481 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 482 | defm FSMBI : FormSelectMaskBytesImm; |
| 483 | |
| 484 | // fsmb: Form select mask for bytes. N.B. Input operand, $rA, is 16-bits |
Scott Michel | 06eabde | 2008-12-27 04:51:36 +0000 | [diff] [blame^] | 485 | class FSMBInst<dag OOL, dag IOL, list<dag> pattern>: |
| 486 | RRForm_1<0b01101101100, OOL, IOL, "fsmb\t$rT, $rA", SelectOp, |
| 487 | pattern>; |
| 488 | |
| 489 | class FSMBRegInst<RegisterClass rclass, ValueType vectype>: |
| 490 | FSMBInst<(outs VECREG:$rT), (ins rclass:$rA), |
| 491 | [(set (vectype VECREG:$rT), (SPUselmask rclass:$rA))]>; |
| 492 | |
| 493 | class FSMBVecInst<ValueType vectype>: |
| 494 | FSMBInst<(outs VECREG:$rT), (ins VECREG:$rA), |
| 495 | [(set (vectype VECREG:$rT), |
| 496 | (SPUselmask (vectype VECREG:$rA)))]>; |
| 497 | |
| 498 | multiclass FormSelectMaskBits { |
| 499 | def v16i8_r16: FSMBRegInst<R16C, v16i8>; |
| 500 | def v16i8: FSMBVecInst<v16i8>; |
| 501 | } |
| 502 | |
| 503 | defm FSMB: FormSelectMaskBits; |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 504 | |
| 505 | // fsmh: Form select mask for halfwords. N.B., Input operand, $rA, is |
| 506 | // only 8-bits wide (even though it's input as 16-bits here) |
Scott Michel | 06eabde | 2008-12-27 04:51:36 +0000 | [diff] [blame^] | 507 | |
| 508 | class FSMHInst<dag OOL, dag IOL, list<dag> pattern>: |
| 509 | RRForm_1<0b10101101100, OOL, IOL, "fsmh\t$rT, $rA", SelectOp, |
| 510 | pattern>; |
| 511 | |
| 512 | class FSMHRegInst<RegisterClass rclass, ValueType vectype>: |
| 513 | FSMHInst<(outs VECREG:$rT), (ins rclass:$rA), |
| 514 | [(set (vectype VECREG:$rT), (SPUselmask rclass:$rA))]>; |
| 515 | |
| 516 | class FSMHVecInst<ValueType vectype>: |
| 517 | FSMHInst<(outs VECREG:$rT), (ins VECREG:$rA), |
| 518 | [(set (vectype VECREG:$rT), |
| 519 | (SPUselmask (vectype VECREG:$rA)))]>; |
| 520 | |
| 521 | multiclass FormSelectMaskHalfword { |
| 522 | def v8i16_r16: FSMHRegInst<R16C, v8i16>; |
| 523 | def v8i16: FSMHVecInst<v8i16>; |
| 524 | } |
| 525 | |
| 526 | defm FSMH: FormSelectMaskHalfword; |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 527 | |
| 528 | // fsm: Form select mask for words. Like the other fsm* instructions, |
| 529 | // only the lower 4 bits of $rA are significant. |
Scott Michel | 06eabde | 2008-12-27 04:51:36 +0000 | [diff] [blame^] | 530 | |
| 531 | class FSMInst<dag OOL, dag IOL, list<dag> pattern>: |
| 532 | RRForm_1<0b00101101100, OOL, IOL, "fsm\t$rT, $rA", SelectOp, |
| 533 | pattern>; |
| 534 | |
| 535 | class FSMRegInst<ValueType vectype, RegisterClass rclass>: |
| 536 | FSMInst<(outs VECREG:$rT), (ins rclass:$rA), |
| 537 | [(set (vectype VECREG:$rT), (SPUselmask rclass:$rA))]>; |
| 538 | |
| 539 | class FSMVecInst<ValueType vectype>: |
| 540 | FSMInst<(outs VECREG:$rT), (ins VECREG:$rA), |
| 541 | [(set (vectype VECREG:$rT), (SPUselmask (vectype VECREG:$rA)))]>; |
Scott Michel | 67224b2 | 2008-06-02 22:18:03 +0000 | [diff] [blame] | 542 | |
| 543 | multiclass FormSelectMaskWord { |
Scott Michel | 06eabde | 2008-12-27 04:51:36 +0000 | [diff] [blame^] | 544 | def v4i32: FSMVecInst<v4i32>; |
| 545 | |
| 546 | def r32 : FSMRegInst<v4i32, R32C>; |
| 547 | def r16 : FSMRegInst<v4i32, R16C>; |
Scott Michel | 67224b2 | 2008-06-02 22:18:03 +0000 | [diff] [blame] | 548 | } |
| 549 | |
| 550 | defm FSM : FormSelectMaskWord; |
| 551 | |
| 552 | // Special case when used for i64 math operations |
| 553 | multiclass FormSelectMaskWord64 { |
Scott Michel | 06eabde | 2008-12-27 04:51:36 +0000 | [diff] [blame^] | 554 | def r32 : FSMRegInst<v2i64, R32C>; |
| 555 | def r16 : FSMRegInst<v2i64, R16C>; |
Scott Michel | 67224b2 | 2008-06-02 22:18:03 +0000 | [diff] [blame] | 556 | } |
| 557 | |
| 558 | defm FSM64 : FormSelectMaskWord64; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 559 | |
| 560 | //===----------------------------------------------------------------------===// |
| 561 | // Integer and Logical Operations: |
| 562 | //===----------------------------------------------------------------------===// |
| 563 | |
| 564 | def AHv8i16: |
| 565 | RRForm<0b00010011000, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB), |
| 566 | "ah\t$rT, $rA, $rB", IntegerOp, |
| 567 | [(set (v8i16 VECREG:$rT), (int_spu_si_ah VECREG:$rA, VECREG:$rB))]>; |
| 568 | |
| 569 | def : Pat<(add (v8i16 VECREG:$rA), (v8i16 VECREG:$rB)), |
| 570 | (AHv8i16 VECREG:$rA, VECREG:$rB)>; |
| 571 | |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 572 | def AHr16: |
| 573 | RRForm<0b00010011000, (outs R16C:$rT), (ins R16C:$rA, R16C:$rB), |
| 574 | "ah\t$rT, $rA, $rB", IntegerOp, |
| 575 | [(set R16C:$rT, (add R16C:$rA, R16C:$rB))]>; |
| 576 | |
| 577 | def AHIvec: |
| 578 | RI10Form<0b10111000, (outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val), |
| 579 | "ahi\t$rT, $rA, $val", IntegerOp, |
| 580 | [(set (v8i16 VECREG:$rT), (add (v8i16 VECREG:$rA), |
| 581 | v8i16SExt10Imm:$val))]>; |
| 582 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 583 | def AHIr16: |
| 584 | RI10Form<0b10111000, (outs R16C:$rT), (ins R16C:$rA, s10imm:$val), |
| 585 | "ahi\t$rT, $rA, $val", IntegerOp, |
| 586 | [(set R16C:$rT, (add R16C:$rA, v8i16SExt10Imm:$val))]>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 587 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 588 | def Avec: |
| 589 | RRForm<0b00000011000, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB), |
| 590 | "a\t$rT, $rA, $rB", IntegerOp, |
| 591 | [(set (v4i32 VECREG:$rT), (add (v4i32 VECREG:$rA), (v4i32 VECREG:$rB)))]>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 592 | |
| 593 | def : Pat<(add (v16i8 VECREG:$rA), (v16i8 VECREG:$rB)), |
| 594 | (Avec VECREG:$rA, VECREG:$rB)>; |
| 595 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 596 | def Ar32: |
| 597 | RRForm<0b00000011000, (outs R32C:$rT), (ins R32C:$rA, R32C:$rB), |
| 598 | "a\t$rT, $rA, $rB", IntegerOp, |
| 599 | [(set R32C:$rT, (add R32C:$rA, R32C:$rB))]>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 600 | |
Scott Michel | 438be25 | 2007-12-17 22:32:34 +0000 | [diff] [blame] | 601 | def Ar8: |
| 602 | RRForm<0b00000011000, (outs R8C:$rT), (ins R8C:$rA, R8C:$rB), |
| 603 | "a\t$rT, $rA, $rB", IntegerOp, |
Scott Michel | 67224b2 | 2008-06-02 22:18:03 +0000 | [diff] [blame] | 604 | [/* no pattern */]>; |
Scott Michel | 438be25 | 2007-12-17 22:32:34 +0000 | [diff] [blame] | 605 | |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 606 | def AIvec: |
| 607 | RI10Form<0b00111000, (outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val), |
| 608 | "ai\t$rT, $rA, $val", IntegerOp, |
| 609 | [(set (v4i32 VECREG:$rT), (add (v4i32 VECREG:$rA), |
| 610 | v4i32SExt10Imm:$val))]>; |
| 611 | |
Scott Michel | 438be25 | 2007-12-17 22:32:34 +0000 | [diff] [blame] | 612 | def AIr32: |
| 613 | RI10Form<0b00111000, (outs R32C:$rT), (ins R32C:$rA, s10imm_i32:$val), |
| 614 | "ai\t$rT, $rA, $val", IntegerOp, |
| 615 | [(set R32C:$rT, (add R32C:$rA, i32ImmSExt10:$val))]>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 616 | |
Scott Michel | 438be25 | 2007-12-17 22:32:34 +0000 | [diff] [blame] | 617 | def SFHvec: |
| 618 | RRForm<0b00010010000, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB), |
| 619 | "sfh\t$rT, $rA, $rB", IntegerOp, |
| 620 | [(set (v8i16 VECREG:$rT), (sub (v8i16 VECREG:$rA), |
| 621 | (v8i16 VECREG:$rB)))]>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 622 | |
Scott Michel | 438be25 | 2007-12-17 22:32:34 +0000 | [diff] [blame] | 623 | def SFHr16: |
| 624 | RRForm<0b00010010000, (outs R16C:$rT), (ins R16C:$rA, R16C:$rB), |
| 625 | "sfh\t$rT, $rA, $rB", IntegerOp, |
| 626 | [(set R16C:$rT, (sub R16C:$rA, R16C:$rB))]>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 627 | |
| 628 | def SFHIvec: |
| 629 | RI10Form<0b10110000, (outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val), |
| 630 | "sfhi\t$rT, $rA, $val", IntegerOp, |
| 631 | [(set (v8i16 VECREG:$rT), (sub v8i16SExt10Imm:$val, |
| 632 | (v8i16 VECREG:$rA)))]>; |
| 633 | |
| 634 | def SFHIr16 : RI10Form<0b10110000, (outs R16C:$rT), (ins R16C:$rA, s10imm:$val), |
| 635 | "sfhi\t$rT, $rA, $val", IntegerOp, |
| 636 | [(set R16C:$rT, (sub i16ImmSExt10:$val, R16C:$rA))]>; |
| 637 | |
| 638 | def SFvec : RRForm<0b00000010000, (outs VECREG:$rT), |
| 639 | (ins VECREG:$rA, VECREG:$rB), |
| 640 | "sf\t$rT, $rA, $rB", IntegerOp, |
| 641 | [(set (v4i32 VECREG:$rT), (sub (v4i32 VECREG:$rA), (v4i32 VECREG:$rB)))]>; |
| 642 | |
| 643 | def SFr32 : RRForm<0b00000010000, (outs R32C:$rT), (ins R32C:$rA, R32C:$rB), |
| 644 | "sf\t$rT, $rA, $rB", IntegerOp, |
| 645 | [(set R32C:$rT, (sub R32C:$rA, R32C:$rB))]>; |
| 646 | |
| 647 | def SFIvec: |
| 648 | RI10Form<0b00110000, (outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val), |
| 649 | "sfi\t$rT, $rA, $val", IntegerOp, |
| 650 | [(set (v4i32 VECREG:$rT), (sub v4i32SExt10Imm:$val, |
| 651 | (v4i32 VECREG:$rA)))]>; |
| 652 | |
| 653 | def SFIr32 : RI10Form<0b00110000, (outs R32C:$rT), |
| 654 | (ins R32C:$rA, s10imm_i32:$val), |
| 655 | "sfi\t$rT, $rA, $val", IntegerOp, |
| 656 | [(set R32C:$rT, (sub i32ImmSExt10:$val, R32C:$rA))]>; |
| 657 | |
| 658 | // ADDX: only available in vector form, doesn't match a pattern. |
Scott Michel | 67224b2 | 2008-06-02 22:18:03 +0000 | [diff] [blame] | 659 | class ADDXInst<dag OOL, dag IOL, list<dag> pattern>: |
| 660 | RRForm<0b00000010110, OOL, IOL, |
| 661 | "addx\t$rT, $rA, $rB", |
| 662 | IntegerOp, pattern>; |
| 663 | |
| 664 | class ADDXVecInst<ValueType vectype>: |
| 665 | ADDXInst<(outs VECREG:$rT), |
| 666 | (ins VECREG:$rA, VECREG:$rB, VECREG:$rCarry), |
| 667 | [(set (vectype VECREG:$rT), |
| 668 | (SPUaddx (vectype VECREG:$rA), (vectype VECREG:$rB), |
| 669 | (vectype VECREG:$rCarry)))]>, |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 670 | RegConstraint<"$rCarry = $rT">, |
| 671 | NoEncode<"$rCarry">; |
| 672 | |
Scott Michel | 67224b2 | 2008-06-02 22:18:03 +0000 | [diff] [blame] | 673 | class ADDXRegInst<RegisterClass rclass>: |
| 674 | ADDXInst<(outs rclass:$rT), |
| 675 | (ins rclass:$rA, rclass:$rB, rclass:$rCarry), |
| 676 | [(set rclass:$rT, |
| 677 | (SPUaddx rclass:$rA, rclass:$rB, rclass:$rCarry))]>, |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 678 | RegConstraint<"$rCarry = $rT">, |
| 679 | NoEncode<"$rCarry">; |
| 680 | |
Scott Michel | 67224b2 | 2008-06-02 22:18:03 +0000 | [diff] [blame] | 681 | multiclass AddExtended { |
| 682 | def v2i64 : ADDXVecInst<v2i64>; |
| 683 | def v4i32 : ADDXVecInst<v4i32>; |
| 684 | def r64 : ADDXRegInst<R64C>; |
| 685 | def r32 : ADDXRegInst<R32C>; |
| 686 | } |
| 687 | |
| 688 | defm ADDX : AddExtended; |
| 689 | |
| 690 | // CG: Generate carry for add |
| 691 | class CGInst<dag OOL, dag IOL, list<dag> pattern>: |
| 692 | RRForm<0b01000011000, OOL, IOL, |
| 693 | "cg\t$rT, $rA, $rB", |
| 694 | IntegerOp, pattern>; |
| 695 | |
| 696 | class CGVecInst<ValueType vectype>: |
| 697 | CGInst<(outs VECREG:$rT), |
| 698 | (ins VECREG:$rA, VECREG:$rB), |
| 699 | [(set (vectype VECREG:$rT), |
| 700 | (SPUcarry_gen (vectype VECREG:$rA), (vectype VECREG:$rB)))]>; |
| 701 | |
| 702 | class CGRegInst<RegisterClass rclass>: |
| 703 | CGInst<(outs rclass:$rT), |
| 704 | (ins rclass:$rA, rclass:$rB), |
| 705 | [(set rclass:$rT, |
| 706 | (SPUcarry_gen rclass:$rA, rclass:$rB))]>; |
| 707 | |
| 708 | multiclass CarryGenerate { |
| 709 | def v2i64 : CGVecInst<v2i64>; |
| 710 | def v4i32 : CGVecInst<v4i32>; |
| 711 | def r64 : CGRegInst<R64C>; |
| 712 | def r32 : CGRegInst<R32C>; |
| 713 | } |
| 714 | |
| 715 | defm CG : CarryGenerate; |
| 716 | |
| 717 | // SFX: Subract from, extended. This is used in conjunction with BG to subtract |
| 718 | // with carry (borrow, in this case) |
| 719 | class SFXInst<dag OOL, dag IOL, list<dag> pattern>: |
| 720 | RRForm<0b10000010110, OOL, IOL, |
| 721 | "sfx\t$rT, $rA, $rB", |
| 722 | IntegerOp, pattern>; |
| 723 | |
| 724 | class SFXVecInst<ValueType vectype>: |
| 725 | SFXInst<(outs VECREG:$rT), |
| 726 | (ins VECREG:$rA, VECREG:$rB, VECREG:$rCarry), |
| 727 | [(set (vectype VECREG:$rT), |
| 728 | (SPUsubx (vectype VECREG:$rA), (vectype VECREG:$rB), |
| 729 | (vectype VECREG:$rCarry)))]>, |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 730 | RegConstraint<"$rCarry = $rT">, |
| 731 | NoEncode<"$rCarry">; |
| 732 | |
Scott Michel | 67224b2 | 2008-06-02 22:18:03 +0000 | [diff] [blame] | 733 | class SFXRegInst<RegisterClass rclass>: |
| 734 | SFXInst<(outs rclass:$rT), |
| 735 | (ins rclass:$rA, rclass:$rB, rclass:$rCarry), |
| 736 | [(set rclass:$rT, |
| 737 | (SPUsubx rclass:$rA, rclass:$rB, rclass:$rCarry))]>, |
| 738 | RegConstraint<"$rCarry = $rT">, |
| 739 | NoEncode<"$rCarry">; |
| 740 | |
| 741 | multiclass SubtractExtended { |
| 742 | def v2i64 : SFXVecInst<v2i64>; |
| 743 | def v4i32 : SFXVecInst<v4i32>; |
| 744 | def r64 : SFXRegInst<R64C>; |
| 745 | def r32 : SFXRegInst<R32C>; |
| 746 | } |
| 747 | |
| 748 | defm SFX : SubtractExtended; |
| 749 | |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 750 | // BG: only available in vector form, doesn't match a pattern. |
Scott Michel | 67224b2 | 2008-06-02 22:18:03 +0000 | [diff] [blame] | 751 | class BGInst<dag OOL, dag IOL, list<dag> pattern>: |
| 752 | RRForm<0b01000010000, OOL, IOL, |
| 753 | "bg\t$rT, $rA, $rB", |
| 754 | IntegerOp, pattern>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 755 | |
Scott Michel | 67224b2 | 2008-06-02 22:18:03 +0000 | [diff] [blame] | 756 | class BGVecInst<ValueType vectype>: |
| 757 | BGInst<(outs VECREG:$rT), |
| 758 | (ins VECREG:$rA, VECREG:$rB), |
| 759 | [(set (vectype VECREG:$rT), |
| 760 | (SPUborrow_gen (vectype VECREG:$rA), (vectype VECREG:$rB)))]>; |
| 761 | |
| 762 | class BGRegInst<RegisterClass rclass>: |
| 763 | BGInst<(outs rclass:$rT), |
| 764 | (ins rclass:$rA, rclass:$rB), |
| 765 | [(set rclass:$rT, |
| 766 | (SPUborrow_gen rclass:$rA, rclass:$rB))]>; |
| 767 | |
| 768 | multiclass BorrowGenerate { |
| 769 | def v4i32 : BGVecInst<v4i32>; |
| 770 | def v2i64 : BGVecInst<v2i64>; |
| 771 | def r64 : BGRegInst<R64C>; |
| 772 | def r32 : BGRegInst<R32C>; |
| 773 | } |
| 774 | |
| 775 | defm BG : BorrowGenerate; |
| 776 | |
| 777 | // BGX: Borrow generate, extended. |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 778 | def BGXvec: |
| 779 | RRForm<0b11000010110, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB, |
Scott Michel | 06eabde | 2008-12-27 04:51:36 +0000 | [diff] [blame^] | 780 | VECREG:$rCarry), |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 781 | "bgx\t$rT, $rA, $rB", IntegerOp, |
| 782 | []>, |
| 783 | RegConstraint<"$rCarry = $rT">, |
| 784 | NoEncode<"$rCarry">; |
| 785 | |
| 786 | // Halfword multiply variants: |
| 787 | // N.B: These can be used to build up larger quantities (16x16 -> 32) |
| 788 | |
| 789 | def MPYv8i16: |
| 790 | RRForm<0b00100011110, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB), |
| 791 | "mpy\t$rT, $rA, $rB", IntegerMulDiv, |
| 792 | [(set (v8i16 VECREG:$rT), (SPUmpy_v8i16 (v8i16 VECREG:$rA), |
| 793 | (v8i16 VECREG:$rB)))]>; |
| 794 | |
| 795 | def MPYr16: |
| 796 | RRForm<0b00100011110, (outs R16C:$rT), (ins R16C:$rA, R16C:$rB), |
| 797 | "mpy\t$rT, $rA, $rB", IntegerMulDiv, |
| 798 | [(set R16C:$rT, (mul R16C:$rA, R16C:$rB))]>; |
| 799 | |
| 800 | def MPYUv4i32: |
| 801 | RRForm<0b00110011110, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB), |
| 802 | "mpyu\t$rT, $rA, $rB", IntegerMulDiv, |
| 803 | [(set (v4i32 VECREG:$rT), |
| 804 | (SPUmpyu_v4i32 (v4i32 VECREG:$rA), (v4i32 VECREG:$rB)))]>; |
| 805 | |
| 806 | def MPYUr16: |
| 807 | RRForm<0b00110011110, (outs R32C:$rT), (ins R16C:$rA, R16C:$rB), |
| 808 | "mpyu\t$rT, $rA, $rB", IntegerMulDiv, |
| 809 | [(set R32C:$rT, (mul (zext R16C:$rA), |
| 810 | (zext R16C:$rB)))]>; |
| 811 | |
| 812 | def MPYUr32: |
| 813 | RRForm<0b00110011110, (outs R32C:$rT), (ins R32C:$rA, R32C:$rB), |
| 814 | "mpyu\t$rT, $rA, $rB", IntegerMulDiv, |
| 815 | [(set R32C:$rT, (SPUmpyu_i32 R32C:$rA, R32C:$rB))]>; |
| 816 | |
| 817 | // mpyi: multiply 16 x s10imm -> 32 result (custom lowering for 32 bit result, |
| 818 | // this only produces the lower 16 bits) |
| 819 | def MPYIvec: |
| 820 | RI10Form<0b00101110, (outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val), |
| 821 | "mpyi\t$rT, $rA, $val", IntegerMulDiv, |
| 822 | [(set (v8i16 VECREG:$rT), (mul (v8i16 VECREG:$rA), v8i16SExt10Imm:$val))]>; |
| 823 | |
| 824 | def MPYIr16: |
| 825 | RI10Form<0b00101110, (outs R16C:$rT), (ins R16C:$rA, s10imm:$val), |
| 826 | "mpyi\t$rT, $rA, $val", IntegerMulDiv, |
| 827 | [(set R16C:$rT, (mul R16C:$rA, i16ImmSExt10:$val))]>; |
| 828 | |
| 829 | // mpyui: same issues as other multiplies, plus, this doesn't match a |
| 830 | // pattern... but may be used during target DAG selection or lowering |
| 831 | def MPYUIvec: |
| 832 | RI10Form<0b10101110, (outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val), |
| 833 | "mpyui\t$rT, $rA, $val", IntegerMulDiv, |
| 834 | []>; |
| 835 | |
| 836 | def MPYUIr16: |
| 837 | RI10Form<0b10101110, (outs R16C:$rT), (ins R16C:$rA, s10imm:$val), |
| 838 | "mpyui\t$rT, $rA, $val", IntegerMulDiv, |
| 839 | []>; |
| 840 | |
| 841 | // mpya: 16 x 16 + 16 -> 32 bit result |
| 842 | def MPYAvec: |
| 843 | RRRForm<0b0011, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB, VECREG:$rC), |
| 844 | "mpya\t$rT, $rA, $rB, $rC", IntegerMulDiv, |
| 845 | [(set (v4i32 VECREG:$rT), (add (v4i32 (bitconvert (mul (v8i16 VECREG:$rA), |
| 846 | (v8i16 VECREG:$rB)))), |
| 847 | (v4i32 VECREG:$rC)))]>; |
| 848 | |
| 849 | def MPYAr32: |
| 850 | RRRForm<0b0011, (outs R32C:$rT), (ins R16C:$rA, R16C:$rB, R32C:$rC), |
| 851 | "mpya\t$rT, $rA, $rB, $rC", IntegerMulDiv, |
| 852 | [(set R32C:$rT, (add (sext (mul R16C:$rA, R16C:$rB)), |
| 853 | R32C:$rC))]>; |
| 854 | |
| 855 | def : Pat<(add (mul (sext R16C:$rA), (sext R16C:$rB)), R32C:$rC), |
| 856 | (MPYAr32 R16C:$rA, R16C:$rB, R32C:$rC)>; |
| 857 | |
| 858 | def MPYAr32_sextinreg: |
| 859 | RRRForm<0b0011, (outs R32C:$rT), (ins R32C:$rA, R32C:$rB, R32C:$rC), |
| 860 | "mpya\t$rT, $rA, $rB, $rC", IntegerMulDiv, |
| 861 | [(set R32C:$rT, (add (mul (sext_inreg R32C:$rA, i16), |
| 862 | (sext_inreg R32C:$rB, i16)), |
| 863 | R32C:$rC))]>; |
| 864 | |
| 865 | //def MPYAr32: |
| 866 | // RRRForm<0b0011, (outs R32C:$rT), (ins R16C:$rA, R16C:$rB, R32C:$rC), |
| 867 | // "mpya\t$rT, $rA, $rB, $rC", IntegerMulDiv, |
| 868 | // [(set R32C:$rT, (add (sext (mul R16C:$rA, R16C:$rB)), |
| 869 | // R32C:$rC))]>; |
| 870 | |
| 871 | // mpyh: multiply high, used to synthesize 32-bit multiplies |
| 872 | def MPYHv4i32: |
| 873 | RRForm<0b10100011110, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB), |
| 874 | "mpyh\t$rT, $rA, $rB", IntegerMulDiv, |
| 875 | [(set (v4i32 VECREG:$rT), |
| 876 | (SPUmpyh_v4i32 (v4i32 VECREG:$rA), (v4i32 VECREG:$rB)))]>; |
| 877 | |
| 878 | def MPYHr32: |
| 879 | RRForm<0b10100011110, (outs R32C:$rT), (ins R32C:$rA, R32C:$rB), |
| 880 | "mpyh\t$rT, $rA, $rB", IntegerMulDiv, |
| 881 | [(set R32C:$rT, (SPUmpyh_i32 R32C:$rA, R32C:$rB))]>; |
| 882 | |
| 883 | // mpys: multiply high and shift right (returns the top half of |
| 884 | // a 16-bit multiply, sign extended to 32 bits.) |
| 885 | def MPYSvec: |
| 886 | RRForm<0b11100011110, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB), |
| 887 | "mpys\t$rT, $rA, $rB", IntegerMulDiv, |
| 888 | []>; |
| 889 | |
| 890 | def MPYSr16: |
| 891 | RRForm<0b11100011110, (outs R32C:$rT), (ins R16C:$rA, R16C:$rB), |
| 892 | "mpys\t$rT, $rA, $rB", IntegerMulDiv, |
| 893 | []>; |
| 894 | |
| 895 | // mpyhh: multiply high-high (returns the 32-bit result from multiplying |
| 896 | // the top 16 bits of the $rA, $rB) |
| 897 | def MPYHHv8i16: |
| 898 | RRForm<0b01100011110, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB), |
| 899 | "mpyhh\t$rT, $rA, $rB", IntegerMulDiv, |
| 900 | [(set (v8i16 VECREG:$rT), |
| 901 | (SPUmpyhh_v8i16 (v8i16 VECREG:$rA), (v8i16 VECREG:$rB)))]>; |
| 902 | |
| 903 | def MPYHHr32: |
| 904 | RRForm<0b01100011110, (outs R32C:$rT), (ins R32C:$rA, R32C:$rB), |
| 905 | "mpyhh\t$rT, $rA, $rB", IntegerMulDiv, |
| 906 | []>; |
| 907 | |
| 908 | // mpyhha: Multiply high-high, add to $rT: |
| 909 | def MPYHHAvec: |
| 910 | RRForm<0b01100010110, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB), |
| 911 | "mpyhha\t$rT, $rA, $rB", IntegerMulDiv, |
| 912 | []>; |
| 913 | |
| 914 | def MPYHHAr32: |
| 915 | RRForm<0b01100010110, (outs R32C:$rT), (ins R32C:$rA, R32C:$rB), |
| 916 | "mpyhha\t$rT, $rA, $rB", IntegerMulDiv, |
| 917 | []>; |
| 918 | |
| 919 | // mpyhhu: Multiply high-high, unsigned |
| 920 | def MPYHHUvec: |
| 921 | RRForm<0b01110011110, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB), |
| 922 | "mpyhhu\t$rT, $rA, $rB", IntegerMulDiv, |
| 923 | []>; |
| 924 | |
| 925 | def MPYHHUr32: |
| 926 | RRForm<0b01110011110, (outs R32C:$rT), (ins R32C:$rA, R32C:$rB), |
| 927 | "mpyhhu\t$rT, $rA, $rB", IntegerMulDiv, |
| 928 | []>; |
| 929 | |
| 930 | // mpyhhau: Multiply high-high, unsigned |
| 931 | def MPYHHAUvec: |
| 932 | RRForm<0b01110010110, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB), |
| 933 | "mpyhhau\t$rT, $rA, $rB", IntegerMulDiv, |
| 934 | []>; |
| 935 | |
| 936 | def MPYHHAUr32: |
| 937 | RRForm<0b01110010110, (outs R32C:$rT), (ins R32C:$rA, R32C:$rB), |
| 938 | "mpyhhau\t$rT, $rA, $rB", IntegerMulDiv, |
| 939 | []>; |
| 940 | |
| 941 | // clz: Count leading zeroes |
Scott Michel | 06eabde | 2008-12-27 04:51:36 +0000 | [diff] [blame^] | 942 | class CLZInst<dag OOL, dag IOL, list<dag> pattern>: |
| 943 | RRForm_1<0b10100101010, OOL, IOL, "clz\t$rT, $rA", |
| 944 | IntegerOp, pattern>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 945 | |
Scott Michel | 06eabde | 2008-12-27 04:51:36 +0000 | [diff] [blame^] | 946 | class CLZRegInst<RegisterClass rclass>: |
| 947 | CLZInst<(outs rclass:$rT), (ins rclass:$rA), |
| 948 | [(set rclass:$rT, (ctlz rclass:$rA))]>; |
| 949 | |
| 950 | class CLZVecInst<ValueType vectype>: |
| 951 | CLZInst<(outs VECREG:$rT), (ins VECREG:$rA), |
| 952 | [(set (vectype VECREG:$rT), (ctlz (vectype VECREG:$rA)))]>; |
| 953 | |
| 954 | multiclass CountLeadingZeroes { |
| 955 | def v4i32 : CLZVecInst<v4i32>; |
| 956 | def r32 : CLZRegInst<R32C>; |
| 957 | } |
| 958 | |
| 959 | defm CLZ : CountLeadingZeroes; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 960 | |
| 961 | // cntb: Count ones in bytes (aka "population count") |
Scott Michel | 06eabde | 2008-12-27 04:51:36 +0000 | [diff] [blame^] | 962 | // |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 963 | // NOTE: This instruction is really a vector instruction, but the custom |
| 964 | // lowering code uses it in unorthodox ways to support CTPOP for other |
| 965 | // data types! |
Scott Michel | 06eabde | 2008-12-27 04:51:36 +0000 | [diff] [blame^] | 966 | |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 967 | def CNTBv16i8: |
| 968 | RRForm_1<0b00101101010, (outs VECREG:$rT), (ins VECREG:$rA), |
| 969 | "cntb\t$rT, $rA", IntegerOp, |
Scott Michel | 67224b2 | 2008-06-02 22:18:03 +0000 | [diff] [blame] | 970 | [(set (v16i8 VECREG:$rT), (SPUcntb (v16i8 VECREG:$rA)))]>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 971 | |
| 972 | def CNTBv8i16 : |
| 973 | RRForm_1<0b00101101010, (outs VECREG:$rT), (ins VECREG:$rA), |
| 974 | "cntb\t$rT, $rA", IntegerOp, |
Scott Michel | 67224b2 | 2008-06-02 22:18:03 +0000 | [diff] [blame] | 975 | [(set (v8i16 VECREG:$rT), (SPUcntb (v8i16 VECREG:$rA)))]>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 976 | |
| 977 | def CNTBv4i32 : |
| 978 | RRForm_1<0b00101101010, (outs VECREG:$rT), (ins VECREG:$rA), |
| 979 | "cntb\t$rT, $rA", IntegerOp, |
Scott Michel | 67224b2 | 2008-06-02 22:18:03 +0000 | [diff] [blame] | 980 | [(set (v4i32 VECREG:$rT), (SPUcntb (v4i32 VECREG:$rA)))]>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 981 | |
Scott Michel | 06eabde | 2008-12-27 04:51:36 +0000 | [diff] [blame^] | 982 | // gbb: Gather the low order bits from each byte in $rA into a single 16-bit |
| 983 | // quantity stored into $rT's slot 0, upper 16 bits are zeroed, as are |
| 984 | // slots 1-3. |
| 985 | // |
| 986 | // Note: This instruction "pairs" with the fsmb instruction for all of the |
| 987 | // various types defined here. |
| 988 | // |
| 989 | // Note 2: The "VecInst" and "RegInst" forms refer to the result being either |
| 990 | // a vector or register. |
| 991 | |
| 992 | class GBBInst<dag OOL, dag IOL, list<dag> pattern>: |
| 993 | RRForm_1<0b01001101100, OOL, IOL, "gbb\t$rT, $rA", GatherOp, pattern>; |
| 994 | |
| 995 | class GBBRegInst<RegisterClass rclass, ValueType vectype>: |
| 996 | GBBInst<(outs rclass:$rT), (ins VECREG:$rA), |
| 997 | [(set rclass:$rT, (SPUgatherbits (vectype VECREG:$rA)))]>; |
| 998 | |
| 999 | class GBBVecInst<ValueType vectype>: |
| 1000 | GBBInst<(outs VECREG:$rT), (ins VECREG:$rA), |
| 1001 | [(set (vectype VECREG:$rT), (SPUgatherbits (vectype VECREG:$rA)))]>; |
| 1002 | |
| 1003 | multiclass GatherBitsFromBytes { |
| 1004 | def v16i8_r32: GBBRegInst<R32C, v16i8>; |
| 1005 | def v16i8_r16: GBBRegInst<R16C, v16i8>; |
| 1006 | def v16i8: GBBVecInst<v16i8>; |
| 1007 | } |
| 1008 | |
| 1009 | defm GBB: GatherBitsFromBytes; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 1010 | |
| 1011 | // gbh: Gather all low order bits from each halfword in $rA into a single |
Scott Michel | 06eabde | 2008-12-27 04:51:36 +0000 | [diff] [blame^] | 1012 | // 8-bit quantity stored in $rT's slot 0, with the upper bits of $rT set to 0 |
| 1013 | // and slots 1-3 also set to 0. |
| 1014 | // |
| 1015 | // See notes for GBBInst, above. |
| 1016 | |
| 1017 | class GBHInst<dag OOL, dag IOL, list<dag> pattern>: |
| 1018 | RRForm_1<0b10001101100, OOL, IOL, "gbh\t$rT, $rA", GatherOp, |
| 1019 | pattern>; |
| 1020 | |
| 1021 | class GBHRegInst<RegisterClass rclass, ValueType vectype>: |
| 1022 | GBHInst<(outs rclass:$rT), (ins VECREG:$rA), |
| 1023 | [(set rclass:$rT, (SPUgatherbits (vectype VECREG:$rA)))]>; |
| 1024 | |
| 1025 | class GBHVecInst<ValueType vectype>: |
| 1026 | GBHInst<(outs VECREG:$rT), (ins VECREG:$rA), |
| 1027 | [(set (vectype VECREG:$rT), |
| 1028 | (SPUgatherbits (vectype VECREG:$rA)))]>; |
| 1029 | |
| 1030 | multiclass GatherBitsHalfword { |
| 1031 | def v8i16_r32: GBHRegInst<R32C, v8i16>; |
| 1032 | def v8i16_r16: GBHRegInst<R16C, v8i16>; |
| 1033 | def v8i16: GBHVecInst<v8i16>; |
| 1034 | } |
| 1035 | |
| 1036 | defm GBH: GatherBitsHalfword; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 1037 | |
| 1038 | // gb: Gather all low order bits from each word in $rA into a single |
Scott Michel | 06eabde | 2008-12-27 04:51:36 +0000 | [diff] [blame^] | 1039 | // 4-bit quantity stored in $rT's slot 0, upper bits in $rT set to 0, |
| 1040 | // as well as slots 1-3. |
| 1041 | // |
| 1042 | // See notes for gbb, above. |
| 1043 | |
| 1044 | class GBInst<dag OOL, dag IOL, list<dag> pattern>: |
| 1045 | RRForm_1<0b00001101100, OOL, IOL, "gb\t$rT, $rA", GatherOp, |
| 1046 | pattern>; |
| 1047 | |
| 1048 | class GBRegInst<RegisterClass rclass, ValueType vectype>: |
| 1049 | GBInst<(outs rclass:$rT), (ins VECREG:$rA), |
| 1050 | [(set rclass:$rT, (SPUgatherbits (vectype VECREG:$rA)))]>; |
| 1051 | |
| 1052 | class GBVecInst<ValueType vectype>: |
| 1053 | GBInst<(outs VECREG:$rT), (ins VECREG:$rA), |
| 1054 | [(set (vectype VECREG:$rT), |
| 1055 | (SPUgatherbits (vectype VECREG:$rA)))]>; |
| 1056 | |
| 1057 | multiclass GatherBitsWord { |
| 1058 | def v4i32_r32: GBRegInst<R32C, v4i32>; |
| 1059 | def v4i32_r16: GBRegInst<R16C, v4i32>; |
| 1060 | def v4i32: GBVecInst<v4i32>; |
| 1061 | } |
| 1062 | |
| 1063 | defm GB: GatherBitsWord; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 1064 | |
| 1065 | // avgb: average bytes |
| 1066 | def AVGB: |
| 1067 | RRForm<0b11001011000, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB), |
| 1068 | "avgb\t$rT, $rA, $rB", ByteOp, |
| 1069 | []>; |
| 1070 | |
| 1071 | // absdb: absolute difference of bytes |
| 1072 | def ABSDB: |
| 1073 | RRForm<0b11001010000, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB), |
| 1074 | "absdb\t$rT, $rA, $rB", ByteOp, |
| 1075 | []>; |
| 1076 | |
| 1077 | // sumb: sum bytes into halfwords |
| 1078 | def SUMB: |
| 1079 | RRForm<0b11001010010, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB), |
| 1080 | "sumb\t$rT, $rA, $rB", ByteOp, |
| 1081 | []>; |
| 1082 | |
| 1083 | // Sign extension operations: |
Scott Michel | 67224b2 | 2008-06-02 22:18:03 +0000 | [diff] [blame] | 1084 | class XSBHInst<dag OOL, dag IOL, list<dag> pattern>: |
| 1085 | RRForm_1<0b01101101010, OOL, IOL, |
| 1086 | "xsbh\t$rDst, $rSrc", |
| 1087 | IntegerOp, pattern>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 1088 | |
Scott Michel | 67224b2 | 2008-06-02 22:18:03 +0000 | [diff] [blame] | 1089 | class XSBHVecInst<ValueType vectype>: |
| 1090 | XSBHInst<(outs VECREG:$rDst), (ins VECREG:$rSrc), |
| 1091 | [(set (v8i16 VECREG:$rDst), (sext (vectype VECREG:$rSrc)))]>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 1092 | |
Scott Michel | 06eabde | 2008-12-27 04:51:36 +0000 | [diff] [blame^] | 1093 | class XSBHInRegInst<RegisterClass rclass>: |
Scott Michel | 67224b2 | 2008-06-02 22:18:03 +0000 | [diff] [blame] | 1094 | XSBHInst<(outs rclass:$rDst), (ins rclass:$rSrc), |
| 1095 | [(set rclass:$rDst, (sext_inreg rclass:$rSrc, i8))]>; |
| 1096 | |
| 1097 | multiclass ExtendByteHalfword { |
| 1098 | def v16i8: XSBHVecInst<v8i16>; |
Scott Michel | 06eabde | 2008-12-27 04:51:36 +0000 | [diff] [blame^] | 1099 | def r16: XSBHInRegInst<R16C>; |
| 1100 | def r8: XSBHInst<(outs R16C:$rDst), (ins R8C:$rSrc), |
| 1101 | [(set R16C:$rDst, (sext R8C:$rSrc))]>; |
Scott Michel | 67224b2 | 2008-06-02 22:18:03 +0000 | [diff] [blame] | 1102 | |
| 1103 | // 32-bit form for XSBH: used to sign extend 8-bit quantities to 16-bit |
| 1104 | // quantities to 32-bit quantities via a 32-bit register (see the sext 8->32 |
| 1105 | // pattern below). Intentionally doesn't match a pattern because we want the |
| 1106 | // sext 8->32 pattern to do the work for us, namely because we need the extra |
| 1107 | // XSHWr32. |
Scott Michel | 06eabde | 2008-12-27 04:51:36 +0000 | [diff] [blame^] | 1108 | def r32: XSBHInRegInst<R32C>; |
Scott Michel | 67224b2 | 2008-06-02 22:18:03 +0000 | [diff] [blame] | 1109 | } |
| 1110 | |
| 1111 | defm XSBH : ExtendByteHalfword; |
| 1112 | |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 1113 | // Sign extend halfwords to words: |
| 1114 | def XSHWvec: |
| 1115 | RRForm_1<0b01101101010, (outs VECREG:$rDest), (ins VECREG:$rSrc), |
| 1116 | "xshw\t$rDest, $rSrc", IntegerOp, |
| 1117 | [(set (v4i32 VECREG:$rDest), (sext (v8i16 VECREG:$rSrc)))]>; |
| 1118 | |
| 1119 | def XSHWr32: |
| 1120 | RRForm_1<0b01101101010, (outs R32C:$rDst), (ins R32C:$rSrc), |
| 1121 | "xshw\t$rDst, $rSrc", IntegerOp, |
| 1122 | [(set R32C:$rDst, (sext_inreg R32C:$rSrc, i16))]>; |
| 1123 | |
| 1124 | def XSHWr16: |
| 1125 | RRForm_1<0b01101101010, (outs R32C:$rDst), (ins R16C:$rSrc), |
| 1126 | "xshw\t$rDst, $rSrc", IntegerOp, |
| 1127 | [(set R32C:$rDst, (sext R16C:$rSrc))]>; |
| 1128 | |
| 1129 | def XSWDvec: |
| 1130 | RRForm_1<0b01100101010, (outs VECREG:$rDst), (ins VECREG:$rSrc), |
| 1131 | "xswd\t$rDst, $rSrc", IntegerOp, |
| 1132 | [(set (v2i64 VECREG:$rDst), (sext (v4i32 VECREG:$rSrc)))]>; |
| 1133 | |
| 1134 | def XSWDr64: |
| 1135 | RRForm_1<0b01100101010, (outs R64C:$rDst), (ins R64C:$rSrc), |
| 1136 | "xswd\t$rDst, $rSrc", IntegerOp, |
| 1137 | [(set R64C:$rDst, (sext_inreg R64C:$rSrc, i32))]>; |
| 1138 | |
| 1139 | def XSWDr32: |
| 1140 | RRForm_1<0b01100101010, (outs R64C:$rDst), (ins R32C:$rSrc), |
| 1141 | "xswd\t$rDst, $rSrc", IntegerOp, |
| 1142 | [(set R64C:$rDst, (SPUsext32_to_64 R32C:$rSrc))]>; |
| 1143 | |
| 1144 | def : Pat<(sext R32C:$inp), |
| 1145 | (XSWDr32 R32C:$inp)>; |
| 1146 | |
| 1147 | // AND operations |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 1148 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 1149 | class ANDInst<dag OOL, dag IOL, list<dag> pattern> : |
| 1150 | RRForm<0b10000011000, OOL, IOL, "and\t$rT, $rA, $rB", |
| 1151 | IntegerOp, pattern>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 1152 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 1153 | class ANDVecInst<ValueType vectype>: |
| 1154 | ANDInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB), |
| 1155 | [(set (vectype VECREG:$rT), (and (vectype VECREG:$rA), |
| 1156 | (vectype VECREG:$rB)))]>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 1157 | |
Scott Michel | 6baba07 | 2008-03-05 23:02:02 +0000 | [diff] [blame] | 1158 | class ANDRegInst<RegisterClass rclass>: |
| 1159 | ANDInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB), |
| 1160 | [(set rclass:$rT, (and rclass:$rA, rclass:$rB))]>; |
| 1161 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 1162 | multiclass BitwiseAnd |
| 1163 | { |
| 1164 | def v16i8: ANDVecInst<v16i8>; |
| 1165 | def v8i16: ANDVecInst<v8i16>; |
| 1166 | def v4i32: ANDVecInst<v4i32>; |
| 1167 | def v2i64: ANDVecInst<v2i64>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 1168 | |
Scott Michel | 6baba07 | 2008-03-05 23:02:02 +0000 | [diff] [blame] | 1169 | def r128: ANDRegInst<GPRC>; |
| 1170 | def r64: ANDRegInst<R64C>; |
| 1171 | def r32: ANDRegInst<R32C>; |
| 1172 | def r16: ANDRegInst<R16C>; |
| 1173 | def r8: ANDRegInst<R8C>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 1174 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 1175 | //===--------------------------------------------- |
| 1176 | // Special instructions to perform the fabs instruction |
| 1177 | def fabs32: ANDInst<(outs R32FP:$rT), (ins R32FP:$rA, R32C:$rB), |
| 1178 | [/* Intentionally does not match a pattern */]>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 1179 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 1180 | def fabs64: ANDInst<(outs R64FP:$rT), (ins R64FP:$rA, VECREG:$rB), |
| 1181 | [/* Intentionally does not match a pattern */]>; |
Scott Michel | 438be25 | 2007-12-17 22:32:34 +0000 | [diff] [blame] | 1182 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 1183 | // Could use v4i32, but won't for clarity |
| 1184 | def fabsvec: ANDInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB), |
| 1185 | [/* Intentionally does not match a pattern */]>; |
| 1186 | |
| 1187 | //===--------------------------------------------- |
| 1188 | |
| 1189 | // Hacked form of AND to zero-extend 16-bit quantities to 32-bit |
| 1190 | // quantities -- see 16->32 zext pattern. |
| 1191 | // |
| 1192 | // This pattern is somewhat artificial, since it might match some |
| 1193 | // compiler generated pattern but it is unlikely to do so. |
| 1194 | |
| 1195 | def i16i32: ANDInst<(outs R32C:$rT), (ins R16C:$rA, R32C:$rB), |
| 1196 | [(set R32C:$rT, (and (zext R16C:$rA), R32C:$rB))]>; |
| 1197 | } |
| 1198 | |
| 1199 | defm AND : BitwiseAnd; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 1200 | |
| 1201 | // N.B.: vnot_conv is one of those special target selection pattern fragments, |
| 1202 | // in which we expect there to be a bit_convert on the constant. Bear in mind |
| 1203 | // that llvm translates "not <reg>" to "xor <reg>, -1" (or in this case, a |
| 1204 | // constant -1 vector.) |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 1205 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 1206 | class ANDCInst<dag OOL, dag IOL, list<dag> pattern>: |
| 1207 | RRForm<0b10000011010, OOL, IOL, "andc\t$rT, $rA, $rB", |
| 1208 | IntegerOp, pattern>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 1209 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 1210 | class ANDCVecInst<ValueType vectype>: |
| 1211 | ANDCInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB), |
| 1212 | [(set (vectype VECREG:$rT), (and (vectype VECREG:$rA), |
| 1213 | (vnot (vectype VECREG:$rB))))]>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 1214 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 1215 | class ANDCRegInst<RegisterClass rclass>: |
| 1216 | ANDCInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB), |
| 1217 | [(set rclass:$rT, (and rclass:$rA, (not rclass:$rB)))]>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 1218 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 1219 | multiclass AndComplement |
| 1220 | { |
| 1221 | def v16i8: ANDCVecInst<v16i8>; |
| 1222 | def v8i16: ANDCVecInst<v8i16>; |
| 1223 | def v4i32: ANDCVecInst<v4i32>; |
| 1224 | def v2i64: ANDCVecInst<v2i64>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 1225 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 1226 | def r128: ANDCRegInst<GPRC>; |
| 1227 | def r64: ANDCRegInst<R64C>; |
| 1228 | def r32: ANDCRegInst<R32C>; |
| 1229 | def r16: ANDCRegInst<R16C>; |
| 1230 | def r8: ANDCRegInst<R8C>; |
| 1231 | } |
Scott Michel | 438be25 | 2007-12-17 22:32:34 +0000 | [diff] [blame] | 1232 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 1233 | defm ANDC : AndComplement; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 1234 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 1235 | class ANDBIInst<dag OOL, dag IOL, list<dag> pattern>: |
| 1236 | RI10Form<0b01101000, OOL, IOL, "andbi\t$rT, $rA, $val", |
Scott Michel | 61895fe | 2008-12-10 00:15:19 +0000 | [diff] [blame] | 1237 | ByteOp, pattern>; |
Scott Michel | 438be25 | 2007-12-17 22:32:34 +0000 | [diff] [blame] | 1238 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 1239 | multiclass AndByteImm |
| 1240 | { |
| 1241 | def v16i8: ANDBIInst<(outs VECREG:$rT), (ins VECREG:$rA, u10imm:$val), |
| 1242 | [(set (v16i8 VECREG:$rT), |
| 1243 | (and (v16i8 VECREG:$rA), |
| 1244 | (v16i8 v16i8U8Imm:$val)))]>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 1245 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 1246 | def r8: ANDBIInst<(outs R8C:$rT), (ins R8C:$rA, u10imm_i8:$val), |
| 1247 | [(set R8C:$rT, (and R8C:$rA, immU8:$val))]>; |
| 1248 | } |
Scott Michel | 438be25 | 2007-12-17 22:32:34 +0000 | [diff] [blame] | 1249 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 1250 | defm ANDBI : AndByteImm; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 1251 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 1252 | class ANDHIInst<dag OOL, dag IOL, list<dag> pattern> : |
| 1253 | RI10Form<0b10101000, OOL, IOL, "andhi\t$rT, $rA, $val", |
Scott Michel | 61895fe | 2008-12-10 00:15:19 +0000 | [diff] [blame] | 1254 | ByteOp, pattern>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 1255 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 1256 | multiclass AndHalfwordImm |
| 1257 | { |
| 1258 | def v8i16: ANDHIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val), |
| 1259 | [(set (v8i16 VECREG:$rT), |
| 1260 | (and (v8i16 VECREG:$rA), v8i16SExt10Imm:$val))]>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 1261 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 1262 | def r16: ANDHIInst<(outs R16C:$rT), (ins R16C:$rA, u10imm:$val), |
| 1263 | [(set R16C:$rT, (and R16C:$rA, i16ImmUns10:$val))]>; |
Scott Michel | 438be25 | 2007-12-17 22:32:34 +0000 | [diff] [blame] | 1264 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 1265 | // Zero-extend i8 to i16: |
| 1266 | def i8i16: ANDHIInst<(outs R16C:$rT), (ins R8C:$rA, u10imm:$val), |
| 1267 | [(set R16C:$rT, (and (zext R8C:$rA), i16ImmUns10:$val))]>; |
| 1268 | } |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 1269 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 1270 | defm ANDHI : AndHalfwordImm; |
| 1271 | |
| 1272 | class ANDIInst<dag OOL, dag IOL, list<dag> pattern> : |
| 1273 | RI10Form<0b00101000, OOL, IOL, "andi\t$rT, $rA, $val", |
| 1274 | IntegerOp, pattern>; |
| 1275 | |
| 1276 | multiclass AndWordImm |
| 1277 | { |
| 1278 | def v4i32: ANDIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val), |
| 1279 | [(set (v4i32 VECREG:$rT), |
| 1280 | (and (v4i32 VECREG:$rA), v4i32SExt10Imm:$val))]>; |
| 1281 | |
| 1282 | def r32: ANDIInst<(outs R32C:$rT), (ins R32C:$rA, s10imm_i32:$val), |
| 1283 | [(set R32C:$rT, (and R32C:$rA, i32ImmSExt10:$val))]>; |
| 1284 | |
| 1285 | // Hacked form of ANDI to zero-extend i8 quantities to i32. See the zext 8->32 |
| 1286 | // pattern below. |
| 1287 | def i8i32: ANDIInst<(outs R32C:$rT), (ins R8C:$rA, s10imm_i32:$val), |
| 1288 | [(set R32C:$rT, |
| 1289 | (and (zext R8C:$rA), i32ImmSExt10:$val))]>; |
| 1290 | |
| 1291 | // Hacked form of ANDI to zero-extend i16 quantities to i32. See the |
| 1292 | // zext 16->32 pattern below. |
| 1293 | // |
| 1294 | // Note that this pattern is somewhat artificial, since it might match |
| 1295 | // something the compiler generates but is unlikely to occur in practice. |
| 1296 | def i16i32: ANDIInst<(outs R32C:$rT), (ins R16C:$rA, s10imm_i32:$val), |
| 1297 | [(set R32C:$rT, |
| 1298 | (and (zext R16C:$rA), i32ImmSExt10:$val))]>; |
| 1299 | } |
| 1300 | |
| 1301 | defm ANDI : AndWordImm; |
| 1302 | |
| 1303 | //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 1304 | // Bitwise OR group: |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 1305 | //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ |
| 1306 | |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 1307 | // Bitwise "or" (N.B.: These are also register-register copy instructions...) |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 1308 | class ORInst<dag OOL, dag IOL, list<dag> pattern>: |
| 1309 | RRForm<0b10000010000, OOL, IOL, "or\t$rT, $rA, $rB", |
| 1310 | IntegerOp, pattern>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 1311 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 1312 | class ORVecInst<ValueType vectype>: |
| 1313 | ORInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB), |
| 1314 | [(set (vectype VECREG:$rT), (or (vectype VECREG:$rA), |
| 1315 | (vectype VECREG:$rB)))]>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 1316 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 1317 | class ORRegInst<RegisterClass rclass>: |
| 1318 | ORInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB), |
| 1319 | [(set rclass:$rT, (or rclass:$rA, rclass:$rB))]>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 1320 | |
Scott Michel | 06eabde | 2008-12-27 04:51:36 +0000 | [diff] [blame^] | 1321 | // ORCvtForm: OR conversion form |
| 1322 | // |
| 1323 | // This is used to "convert" the preferred slot to its vector equivalent, as |
| 1324 | // well as convert a vector back to its preferred slot. |
| 1325 | // |
| 1326 | // These are effectively no-ops, but need to exist for proper type conversion |
| 1327 | // and type coercion. |
| 1328 | |
| 1329 | class ORCvtForm<dag OOL, dag IOL> |
| 1330 | : SPUInstr<OOL, IOL, "or\t$rT, $rA, $rA", IntegerOp> { |
| 1331 | bits<7> RA; |
| 1332 | bits<7> RT; |
| 1333 | |
| 1334 | let Pattern = [/* no pattern */]; |
| 1335 | |
| 1336 | let Inst{0-10} = 0b10000010000; |
| 1337 | let Inst{11-17} = RA; |
| 1338 | let Inst{18-24} = RA; |
| 1339 | let Inst{25-31} = RT; |
| 1340 | } |
| 1341 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 1342 | class ORPromoteScalar<RegisterClass rclass>: |
Scott Michel | 06eabde | 2008-12-27 04:51:36 +0000 | [diff] [blame^] | 1343 | ORCvtForm<(outs VECREG:$rT), (ins rclass:$rA)>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 1344 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 1345 | class ORExtractElt<RegisterClass rclass>: |
Scott Michel | 06eabde | 2008-12-27 04:51:36 +0000 | [diff] [blame^] | 1346 | ORCvtForm<(outs rclass:$rT), (ins VECREG:$rA)>; |
| 1347 | |
| 1348 | class ORCvtRegGPRC<RegisterClass rclass>: |
| 1349 | ORCvtForm<(outs GPRC:$rT), (ins rclass:$rA)>; |
| 1350 | |
| 1351 | class ORCvtVecGPRC: |
| 1352 | ORCvtForm<(outs GPRC:$rT), (ins VECREG:$rA)>; |
| 1353 | |
| 1354 | class ORCvtGPRCReg<RegisterClass rclass>: |
| 1355 | ORCvtForm<(outs rclass:$rT), (ins GPRC:$rA)>; |
| 1356 | |
| 1357 | class ORCvtGPRCVec: |
| 1358 | ORCvtForm<(outs VECREG:$rT), (ins GPRC:$rA)>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 1359 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 1360 | multiclass BitwiseOr |
| 1361 | { |
| 1362 | def v16i8: ORVecInst<v16i8>; |
| 1363 | def v8i16: ORVecInst<v8i16>; |
| 1364 | def v4i32: ORVecInst<v4i32>; |
| 1365 | def v2i64: ORVecInst<v2i64>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 1366 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 1367 | def v4f32: ORInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB), |
| 1368 | [(set (v4f32 VECREG:$rT), |
| 1369 | (v4f32 (bitconvert (or (v4i32 VECREG:$rA), |
| 1370 | (v4i32 VECREG:$rB)))))]>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 1371 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 1372 | def v2f64: ORInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB), |
Scott Michel | 06eabde | 2008-12-27 04:51:36 +0000 | [diff] [blame^] | 1373 | [(set (v2f64 VECREG:$rT), |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 1374 | (v2f64 (bitconvert (or (v2i64 VECREG:$rA), |
| 1375 | (v2i64 VECREG:$rB)))))]>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 1376 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 1377 | def r64: ORRegInst<R64C>; |
| 1378 | def r32: ORRegInst<R32C>; |
| 1379 | def r16: ORRegInst<R16C>; |
| 1380 | def r8: ORRegInst<R8C>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 1381 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 1382 | // OR instructions used to copy f32 and f64 registers. |
| 1383 | def f32: ORInst<(outs R32FP:$rT), (ins R32FP:$rA, R32FP:$rB), |
| 1384 | [/* no pattern */]>; |
Scott Michel | 438be25 | 2007-12-17 22:32:34 +0000 | [diff] [blame] | 1385 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 1386 | def f64: ORInst<(outs R64FP:$rT), (ins R64FP:$rA, R64FP:$rB), |
| 1387 | [/* no pattern */]>; |
Scott Michel | 754d866 | 2007-12-20 00:44:13 +0000 | [diff] [blame] | 1388 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 1389 | // scalar->vector promotion: |
| 1390 | def v16i8_i8: ORPromoteScalar<R8C>; |
| 1391 | def v8i16_i16: ORPromoteScalar<R16C>; |
| 1392 | def v4i32_i32: ORPromoteScalar<R32C>; |
| 1393 | def v2i64_i64: ORPromoteScalar<R64C>; |
| 1394 | def v4f32_f32: ORPromoteScalar<R32FP>; |
| 1395 | def v2f64_f64: ORPromoteScalar<R64FP>; |
Scott Michel | 754d866 | 2007-12-20 00:44:13 +0000 | [diff] [blame] | 1396 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 1397 | // extract element 0: |
| 1398 | def i8_v16i8: ORExtractElt<R8C>; |
| 1399 | def i16_v8i16: ORExtractElt<R16C>; |
| 1400 | def i32_v4i32: ORExtractElt<R32C>; |
| 1401 | def i64_v2i64: ORExtractElt<R64C>; |
| 1402 | def f32_v4f32: ORExtractElt<R32FP>; |
| 1403 | def f64_v2f64: ORExtractElt<R64FP>; |
Scott Michel | 06eabde | 2008-12-27 04:51:36 +0000 | [diff] [blame^] | 1404 | |
| 1405 | // Conversion from GPRC to register |
| 1406 | def i128_r64: ORCvtRegGPRC<R64C>; |
| 1407 | def i128_f64: ORCvtRegGPRC<R64FP>; |
| 1408 | def i128_r32: ORCvtRegGPRC<R32C>; |
| 1409 | def i128_f32: ORCvtRegGPRC<R32FP>; |
| 1410 | def i128_r16: ORCvtRegGPRC<R16C>; |
| 1411 | def i128_r8: ORCvtRegGPRC<R8C>; |
| 1412 | |
| 1413 | // Conversion from GPRC to vector |
| 1414 | def i128_vec: ORCvtVecGPRC; |
| 1415 | |
| 1416 | // Conversion from register to GPRC |
| 1417 | def r64_i128: ORCvtGPRCReg<R64C>; |
| 1418 | def f64_i128: ORCvtGPRCReg<R64FP>; |
| 1419 | def r32_i128: ORCvtGPRCReg<R32C>; |
| 1420 | def f32_i128: ORCvtGPRCReg<R32FP>; |
| 1421 | def r16_i128: ORCvtGPRCReg<R16C>; |
| 1422 | def r8_i128: ORCvtGPRCReg<R8C>; |
| 1423 | |
| 1424 | // Conversion from vector to GPRC |
| 1425 | def vec_i128: ORCvtGPRCVec; |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 1426 | } |
Scott Michel | 438be25 | 2007-12-17 22:32:34 +0000 | [diff] [blame] | 1427 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 1428 | defm OR : BitwiseOr; |
| 1429 | |
Scott Michel | 06eabde | 2008-12-27 04:51:36 +0000 | [diff] [blame^] | 1430 | // scalar->vector promotion patterns (preferred slot to vector): |
| 1431 | def : Pat<(v16i8 (SPUprefslot2vec R8C:$rA)), |
| 1432 | (ORv16i8_i8 R8C:$rA)>; |
Scott Michel | 438be25 | 2007-12-17 22:32:34 +0000 | [diff] [blame] | 1433 | |
Scott Michel | 06eabde | 2008-12-27 04:51:36 +0000 | [diff] [blame^] | 1434 | def : Pat<(v8i16 (SPUprefslot2vec R16C:$rA)), |
| 1435 | (ORv8i16_i16 R16C:$rA)>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 1436 | |
Scott Michel | 06eabde | 2008-12-27 04:51:36 +0000 | [diff] [blame^] | 1437 | def : Pat<(v4i32 (SPUprefslot2vec R32C:$rA)), |
| 1438 | (ORv4i32_i32 R32C:$rA)>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 1439 | |
Scott Michel | 06eabde | 2008-12-27 04:51:36 +0000 | [diff] [blame^] | 1440 | def : Pat<(v2i64 (SPUprefslot2vec R64C:$rA)), |
| 1441 | (ORv2i64_i64 R64C:$rA)>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 1442 | |
Scott Michel | 06eabde | 2008-12-27 04:51:36 +0000 | [diff] [blame^] | 1443 | def : Pat<(v4f32 (SPUprefslot2vec R32FP:$rA)), |
| 1444 | (ORv4f32_f32 R32FP:$rA)>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 1445 | |
Scott Michel | 06eabde | 2008-12-27 04:51:36 +0000 | [diff] [blame^] | 1446 | def : Pat<(v2f64 (SPUprefslot2vec R64FP:$rA)), |
| 1447 | (ORv2f64_f64 R64FP:$rA)>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 1448 | |
Scott Michel | 06eabde | 2008-12-27 04:51:36 +0000 | [diff] [blame^] | 1449 | // ORi*_v*: Used to extract vector element 0 (the preferred slot), otherwise |
| 1450 | // known as converting the vector back to its preferred slot |
Scott Michel | 438be25 | 2007-12-17 22:32:34 +0000 | [diff] [blame] | 1451 | |
Scott Michel | c630c41 | 2008-11-24 17:11:17 +0000 | [diff] [blame] | 1452 | def : Pat<(SPUvec2prefslot (v16i8 VECREG:$rA)), |
Scott Michel | 06eabde | 2008-12-27 04:51:36 +0000 | [diff] [blame^] | 1453 | (ORi8_v16i8 VECREG:$rA)>; |
Scott Michel | 438be25 | 2007-12-17 22:32:34 +0000 | [diff] [blame] | 1454 | |
Scott Michel | c630c41 | 2008-11-24 17:11:17 +0000 | [diff] [blame] | 1455 | def : Pat<(SPUvec2prefslot (v8i16 VECREG:$rA)), |
Scott Michel | 06eabde | 2008-12-27 04:51:36 +0000 | [diff] [blame^] | 1456 | (ORi16_v8i16 VECREG:$rA)>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 1457 | |
Scott Michel | c630c41 | 2008-11-24 17:11:17 +0000 | [diff] [blame] | 1458 | def : Pat<(SPUvec2prefslot (v4i32 VECREG:$rA)), |
Scott Michel | 06eabde | 2008-12-27 04:51:36 +0000 | [diff] [blame^] | 1459 | (ORi32_v4i32 VECREG:$rA)>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 1460 | |
Scott Michel | c630c41 | 2008-11-24 17:11:17 +0000 | [diff] [blame] | 1461 | def : Pat<(SPUvec2prefslot (v2i64 VECREG:$rA)), |
Scott Michel | 06eabde | 2008-12-27 04:51:36 +0000 | [diff] [blame^] | 1462 | (ORi64_v2i64 VECREG:$rA)>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 1463 | |
Scott Michel | c630c41 | 2008-11-24 17:11:17 +0000 | [diff] [blame] | 1464 | def : Pat<(SPUvec2prefslot (v4f32 VECREG:$rA)), |
Scott Michel | 06eabde | 2008-12-27 04:51:36 +0000 | [diff] [blame^] | 1465 | (ORf32_v4f32 VECREG:$rA)>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 1466 | |
Scott Michel | c630c41 | 2008-11-24 17:11:17 +0000 | [diff] [blame] | 1467 | def : Pat<(SPUvec2prefslot (v2f64 VECREG:$rA)), |
Scott Michel | 06eabde | 2008-12-27 04:51:36 +0000 | [diff] [blame^] | 1468 | (ORf64_v2f64 VECREG:$rA)>; |
| 1469 | |
| 1470 | // Load Register: This is an assembler alias for a bitwise OR of a register |
| 1471 | // against itself. It's here because it brings some clarity to assembly |
| 1472 | // language output. |
| 1473 | |
| 1474 | let hasCtrlDep = 1 in { |
| 1475 | class LRInst<dag OOL, dag IOL> |
| 1476 | : SPUInstr<OOL, IOL, "lr\t$rT, $rA", IntegerOp> { |
| 1477 | bits<7> RA; |
| 1478 | bits<7> RT; |
| 1479 | |
| 1480 | let Pattern = [/*no pattern*/]; |
| 1481 | |
| 1482 | let Inst{0-10} = 0b10000010000; /* It's an OR operation */ |
| 1483 | let Inst{11-17} = RA; |
| 1484 | let Inst{18-24} = RA; |
| 1485 | let Inst{25-31} = RT; |
| 1486 | } |
| 1487 | |
| 1488 | class LRVecInst<ValueType vectype>: |
| 1489 | LRInst<(outs VECREG:$rT), (ins VECREG:$rA)>; |
| 1490 | |
| 1491 | class LRRegInst<RegisterClass rclass>: |
| 1492 | LRInst<(outs rclass:$rT), (ins rclass:$rA)>; |
| 1493 | |
| 1494 | multiclass LoadRegister { |
| 1495 | def v2i64: LRVecInst<v2i64>; |
| 1496 | def v2f64: LRVecInst<v2f64>; |
| 1497 | def v4i32: LRVecInst<v4i32>; |
| 1498 | def v4f32: LRVecInst<v4f32>; |
| 1499 | def v8i16: LRVecInst<v8i16>; |
| 1500 | def v16i8: LRVecInst<v16i8>; |
| 1501 | |
| 1502 | def r128: LRRegInst<GPRC>; |
| 1503 | def r64: LRRegInst<R64C>; |
| 1504 | def f64: LRRegInst<R64FP>; |
| 1505 | def r32: LRRegInst<R32C>; |
| 1506 | def f32: LRRegInst<R32FP>; |
| 1507 | def r16: LRRegInst<R16C>; |
| 1508 | def r8: LRRegInst<R8C>; |
| 1509 | } |
| 1510 | |
| 1511 | defm LR: LoadRegister; |
| 1512 | } |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 1513 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 1514 | // ORC: Bitwise "or" with complement (c = a | ~b) |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 1515 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 1516 | class ORCInst<dag OOL, dag IOL, list<dag> pattern>: |
| 1517 | RRForm<0b10010010000, OOL, IOL, "orc\t$rT, $rA, $rB", |
| 1518 | IntegerOp, pattern>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 1519 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 1520 | class ORCVecInst<ValueType vectype>: |
| 1521 | ORCInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB), |
| 1522 | [(set (vectype VECREG:$rT), (or (vectype VECREG:$rA), |
| 1523 | (vnot (vectype VECREG:$rB))))]>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 1524 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 1525 | class ORCRegInst<RegisterClass rclass>: |
| 1526 | ORCInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB), |
| 1527 | [(set rclass:$rT, (or rclass:$rA, (not rclass:$rB)))]>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 1528 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 1529 | multiclass BitwiseOrComplement |
| 1530 | { |
| 1531 | def v16i8: ORCVecInst<v16i8>; |
| 1532 | def v8i16: ORCVecInst<v8i16>; |
| 1533 | def v4i32: ORCVecInst<v4i32>; |
| 1534 | def v2i64: ORCVecInst<v2i64>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 1535 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 1536 | def r64: ORCRegInst<R64C>; |
| 1537 | def r32: ORCRegInst<R32C>; |
| 1538 | def r16: ORCRegInst<R16C>; |
| 1539 | def r8: ORCRegInst<R8C>; |
| 1540 | } |
| 1541 | |
| 1542 | defm ORC : BitwiseOrComplement; |
Scott Michel | 438be25 | 2007-12-17 22:32:34 +0000 | [diff] [blame] | 1543 | |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 1544 | // OR byte immediate |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 1545 | class ORBIInst<dag OOL, dag IOL, list<dag> pattern>: |
| 1546 | RI10Form<0b01100000, OOL, IOL, "orbi\t$rT, $rA, $val", |
| 1547 | IntegerOp, pattern>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 1548 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 1549 | class ORBIVecInst<ValueType vectype, PatLeaf immpred>: |
| 1550 | ORBIInst<(outs VECREG:$rT), (ins VECREG:$rA, u10imm:$val), |
| 1551 | [(set (v16i8 VECREG:$rT), (or (vectype VECREG:$rA), |
| 1552 | (vectype immpred:$val)))]>; |
| 1553 | |
| 1554 | multiclass BitwiseOrByteImm |
| 1555 | { |
| 1556 | def v16i8: ORBIVecInst<v16i8, v16i8U8Imm>; |
| 1557 | |
| 1558 | def r8: ORBIInst<(outs R8C:$rT), (ins R8C:$rA, u10imm_i8:$val), |
| 1559 | [(set R8C:$rT, (or R8C:$rA, immU8:$val))]>; |
| 1560 | } |
| 1561 | |
| 1562 | defm ORBI : BitwiseOrByteImm; |
Scott Michel | 438be25 | 2007-12-17 22:32:34 +0000 | [diff] [blame] | 1563 | |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 1564 | // OR halfword immediate |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 1565 | class ORHIInst<dag OOL, dag IOL, list<dag> pattern>: |
| 1566 | RI10Form<0b10100000, OOL, IOL, "orhi\t$rT, $rA, $val", |
| 1567 | IntegerOp, pattern>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 1568 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 1569 | class ORHIVecInst<ValueType vectype, PatLeaf immpred>: |
| 1570 | ORHIInst<(outs VECREG:$rT), (ins VECREG:$rA, u10imm:$val), |
| 1571 | [(set (vectype VECREG:$rT), (or (vectype VECREG:$rA), |
| 1572 | immpred:$val))]>; |
Scott Michel | 438be25 | 2007-12-17 22:32:34 +0000 | [diff] [blame] | 1573 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 1574 | multiclass BitwiseOrHalfwordImm |
| 1575 | { |
| 1576 | def v8i16: ORHIVecInst<v8i16, v8i16Uns10Imm>; |
| 1577 | |
| 1578 | def r16: ORHIInst<(outs R16C:$rT), (ins R16C:$rA, u10imm:$val), |
| 1579 | [(set R16C:$rT, (or R16C:$rA, i16ImmUns10:$val))]>; |
| 1580 | |
| 1581 | // Specialized ORHI form used to promote 8-bit registers to 16-bit |
| 1582 | def i8i16: ORHIInst<(outs R16C:$rT), (ins R8C:$rA, s10imm:$val), |
| 1583 | [(set R16C:$rT, (or (anyext R8C:$rA), |
| 1584 | i16ImmSExt10:$val))]>; |
| 1585 | } |
| 1586 | |
| 1587 | defm ORHI : BitwiseOrHalfwordImm; |
| 1588 | |
| 1589 | class ORIInst<dag OOL, dag IOL, list<dag> pattern>: |
| 1590 | RI10Form<0b00100000, OOL, IOL, "ori\t$rT, $rA, $val", |
| 1591 | IntegerOp, pattern>; |
| 1592 | |
| 1593 | class ORIVecInst<ValueType vectype, PatLeaf immpred>: |
| 1594 | ORIInst<(outs VECREG:$rT), (ins VECREG:$rA, u10imm:$val), |
| 1595 | [(set (vectype VECREG:$rT), (or (vectype VECREG:$rA), |
| 1596 | immpred:$val))]>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 1597 | |
| 1598 | // Bitwise "or" with immediate |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 1599 | multiclass BitwiseOrImm |
| 1600 | { |
| 1601 | def v4i32: ORIVecInst<v4i32, v4i32Uns10Imm>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 1602 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 1603 | def r32: ORIInst<(outs R32C:$rT), (ins R32C:$rA, u10imm_i32:$val), |
| 1604 | [(set R32C:$rT, (or R32C:$rA, i32ImmUns10:$val))]>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 1605 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 1606 | // i16i32: hacked version of the ori instruction to extend 16-bit quantities |
| 1607 | // to 32-bit quantities. used exclusively to match "anyext" conversions (vide |
| 1608 | // infra "anyext 16->32" pattern.) |
| 1609 | def i16i32: ORIInst<(outs R32C:$rT), (ins R16C:$rA, s10imm_i32:$val), |
| 1610 | [(set R32C:$rT, (or (anyext R16C:$rA), |
| 1611 | i32ImmSExt10:$val))]>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 1612 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 1613 | // i8i32: Hacked version of the ORI instruction to extend 16-bit quantities |
| 1614 | // to 32-bit quantities. Used exclusively to match "anyext" conversions (vide |
| 1615 | // infra "anyext 16->32" pattern.) |
| 1616 | def i8i32: ORIInst<(outs R32C:$rT), (ins R8C:$rA, s10imm_i32:$val), |
| 1617 | [(set R32C:$rT, (or (anyext R8C:$rA), |
| 1618 | i32ImmSExt10:$val))]>; |
| 1619 | } |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 1620 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 1621 | defm ORI : BitwiseOrImm; |
Scott Michel | 438be25 | 2007-12-17 22:32:34 +0000 | [diff] [blame] | 1622 | |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 1623 | // ORX: "or" across the vector: or's $rA's word slots leaving the result in |
| 1624 | // $rT[0], slots 1-3 are zeroed. |
| 1625 | // |
Scott Michel | 438be25 | 2007-12-17 22:32:34 +0000 | [diff] [blame] | 1626 | // FIXME: Needs to match an intrinsic pattern. |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 1627 | def ORXv4i32: |
| 1628 | RRForm<0b10010010000, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB), |
| 1629 | "orx\t$rT, $rA, $rB", IntegerOp, |
| 1630 | []>; |
| 1631 | |
Scott Michel | 438be25 | 2007-12-17 22:32:34 +0000 | [diff] [blame] | 1632 | // XOR: |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 1633 | |
Scott Michel | 6baba07 | 2008-03-05 23:02:02 +0000 | [diff] [blame] | 1634 | class XORInst<dag OOL, dag IOL, list<dag> pattern> : |
| 1635 | RRForm<0b10010010000, OOL, IOL, "xor\t$rT, $rA, $rB", |
| 1636 | IntegerOp, pattern>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 1637 | |
Scott Michel | 6baba07 | 2008-03-05 23:02:02 +0000 | [diff] [blame] | 1638 | class XORVecInst<ValueType vectype>: |
| 1639 | XORInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB), |
| 1640 | [(set (vectype VECREG:$rT), (xor (vectype VECREG:$rA), |
| 1641 | (vectype VECREG:$rB)))]>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 1642 | |
Scott Michel | 6baba07 | 2008-03-05 23:02:02 +0000 | [diff] [blame] | 1643 | class XORRegInst<RegisterClass rclass>: |
| 1644 | XORInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB), |
| 1645 | [(set rclass:$rT, (xor rclass:$rA, rclass:$rB))]>; |
| 1646 | |
| 1647 | multiclass BitwiseExclusiveOr |
| 1648 | { |
| 1649 | def v16i8: XORVecInst<v16i8>; |
| 1650 | def v8i16: XORVecInst<v8i16>; |
| 1651 | def v4i32: XORVecInst<v4i32>; |
| 1652 | def v2i64: XORVecInst<v2i64>; |
| 1653 | |
| 1654 | def r128: XORRegInst<GPRC>; |
| 1655 | def r64: XORRegInst<R64C>; |
| 1656 | def r32: XORRegInst<R32C>; |
| 1657 | def r16: XORRegInst<R16C>; |
| 1658 | def r8: XORRegInst<R8C>; |
| 1659 | |
| 1660 | // Special forms for floating point instructions. |
| 1661 | // fneg and fabs require bitwise logical ops to manipulate the sign bit. |
| 1662 | |
| 1663 | def fneg32: XORInst<(outs R32FP:$rT), (ins R32FP:$rA, R32C:$rB), |
| 1664 | [/* no pattern */]>; |
| 1665 | |
| 1666 | def fneg64: XORInst<(outs R64FP:$rT), (ins R64FP:$rA, VECREG:$rB), |
| 1667 | [/* no pattern */]>; |
| 1668 | |
| 1669 | def fnegvec: XORInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB), |
| 1670 | [/* no pattern, see fneg{32,64} */]>; |
| 1671 | } |
| 1672 | |
| 1673 | defm XOR : BitwiseExclusiveOr; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 1674 | |
| 1675 | //==---------------------------------------------------------- |
Scott Michel | 438be25 | 2007-12-17 22:32:34 +0000 | [diff] [blame] | 1676 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 1677 | class XORBIInst<dag OOL, dag IOL, list<dag> pattern>: |
| 1678 | RI10Form<0b01100000, OOL, IOL, "xorbi\t$rT, $rA, $val", |
| 1679 | IntegerOp, pattern>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 1680 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 1681 | multiclass XorByteImm |
| 1682 | { |
| 1683 | def v16i8: |
| 1684 | XORBIInst<(outs VECREG:$rT), (ins VECREG:$rA, u10imm:$val), |
| 1685 | [(set (v16i8 VECREG:$rT), (xor (v16i8 VECREG:$rA), v16i8U8Imm:$val))]>; |
| 1686 | |
| 1687 | def r8: |
| 1688 | XORBIInst<(outs R8C:$rT), (ins R8C:$rA, u10imm_i8:$val), |
| 1689 | [(set R8C:$rT, (xor R8C:$rA, immU8:$val))]>; |
| 1690 | } |
| 1691 | |
| 1692 | defm XORBI : XorByteImm; |
Scott Michel | 438be25 | 2007-12-17 22:32:34 +0000 | [diff] [blame] | 1693 | |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 1694 | def XORHIv8i16: |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 1695 | RI10Form<0b10100000, (outs VECREG:$rT), (ins VECREG:$rA, u10imm:$val), |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 1696 | "xorhi\t$rT, $rA, $val", IntegerOp, |
| 1697 | [(set (v8i16 VECREG:$rT), (xor (v8i16 VECREG:$rA), |
| 1698 | v8i16SExt10Imm:$val))]>; |
| 1699 | |
| 1700 | def XORHIr16: |
| 1701 | RI10Form<0b10100000, (outs R16C:$rT), (ins R16C:$rA, s10imm:$val), |
| 1702 | "xorhi\t$rT, $rA, $val", IntegerOp, |
| 1703 | [(set R16C:$rT, (xor R16C:$rA, i16ImmSExt10:$val))]>; |
| 1704 | |
| 1705 | def XORIv4i32: |
Scott Michel | 53ab779 | 2008-03-10 16:58:52 +0000 | [diff] [blame] | 1706 | RI10Form<0b00100000, (outs VECREG:$rT), (ins VECREG:$rA, s10imm_i32:$val), |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 1707 | "xori\t$rT, $rA, $val", IntegerOp, |
| 1708 | [(set (v4i32 VECREG:$rT), (xor (v4i32 VECREG:$rA), |
| 1709 | v4i32SExt10Imm:$val))]>; |
| 1710 | |
| 1711 | def XORIr32: |
| 1712 | RI10Form<0b00100000, (outs R32C:$rT), (ins R32C:$rA, s10imm_i32:$val), |
| 1713 | "xori\t$rT, $rA, $val", IntegerOp, |
| 1714 | [(set R32C:$rT, (xor R32C:$rA, i32ImmSExt10:$val))]>; |
| 1715 | |
| 1716 | // NAND: |
| 1717 | def NANDv16i8: |
| 1718 | RRForm<0b10010010000, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB), |
| 1719 | "nand\t$rT, $rA, $rB", IntegerOp, |
| 1720 | [(set (v16i8 VECREG:$rT), (vnot (and (v16i8 VECREG:$rA), |
| 1721 | (v16i8 VECREG:$rB))))]>; |
| 1722 | |
| 1723 | def NANDv8i16: |
| 1724 | RRForm<0b10010010000, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB), |
| 1725 | "nand\t$rT, $rA, $rB", IntegerOp, |
| 1726 | [(set (v8i16 VECREG:$rT), (vnot (and (v8i16 VECREG:$rA), |
| 1727 | (v8i16 VECREG:$rB))))]>; |
| 1728 | |
| 1729 | def NANDv4i32: |
| 1730 | RRForm<0b10010010000, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB), |
| 1731 | "nand\t$rT, $rA, $rB", IntegerOp, |
| 1732 | [(set (v4i32 VECREG:$rT), (vnot (and (v4i32 VECREG:$rA), |
| 1733 | (v4i32 VECREG:$rB))))]>; |
| 1734 | |
| 1735 | def NANDr32: |
| 1736 | RRForm<0b10010010000, (outs R32C:$rT), (ins R32C:$rA, R32C:$rB), |
| 1737 | "nand\t$rT, $rA, $rB", IntegerOp, |
| 1738 | [(set R32C:$rT, (not (and R32C:$rA, R32C:$rB)))]>; |
| 1739 | |
| 1740 | def NANDr16: |
| 1741 | RRForm<0b10010010000, (outs R16C:$rT), (ins R16C:$rA, R16C:$rB), |
| 1742 | "nand\t$rT, $rA, $rB", IntegerOp, |
| 1743 | [(set R16C:$rT, (not (and R16C:$rA, R16C:$rB)))]>; |
| 1744 | |
Scott Michel | 438be25 | 2007-12-17 22:32:34 +0000 | [diff] [blame] | 1745 | def NANDr8: |
| 1746 | RRForm<0b10010010000, (outs R8C:$rT), (ins R8C:$rA, R8C:$rB), |
| 1747 | "nand\t$rT, $rA, $rB", IntegerOp, |
| 1748 | [(set R8C:$rT, (not (and R8C:$rA, R8C:$rB)))]>; |
| 1749 | |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 1750 | // NOR: |
| 1751 | def NORv16i8: |
| 1752 | RRForm<0b10010010000, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB), |
| 1753 | "nor\t$rT, $rA, $rB", IntegerOp, |
| 1754 | [(set (v16i8 VECREG:$rT), (vnot (or (v16i8 VECREG:$rA), |
| 1755 | (v16i8 VECREG:$rB))))]>; |
| 1756 | |
| 1757 | def NORv8i16: |
| 1758 | RRForm<0b10010010000, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB), |
| 1759 | "nor\t$rT, $rA, $rB", IntegerOp, |
| 1760 | [(set (v8i16 VECREG:$rT), (vnot (or (v8i16 VECREG:$rA), |
| 1761 | (v8i16 VECREG:$rB))))]>; |
| 1762 | |
| 1763 | def NORv4i32: |
| 1764 | RRForm<0b10010010000, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB), |
| 1765 | "nor\t$rT, $rA, $rB", IntegerOp, |
| 1766 | [(set (v4i32 VECREG:$rT), (vnot (or (v4i32 VECREG:$rA), |
| 1767 | (v4i32 VECREG:$rB))))]>; |
| 1768 | |
| 1769 | def NORr32: |
| 1770 | RRForm<0b10010010000, (outs R32C:$rT), (ins R32C:$rA, R32C:$rB), |
| 1771 | "nor\t$rT, $rA, $rB", IntegerOp, |
| 1772 | [(set R32C:$rT, (not (or R32C:$rA, R32C:$rB)))]>; |
| 1773 | |
| 1774 | def NORr16: |
| 1775 | RRForm<0b10010010000, (outs R16C:$rT), (ins R16C:$rA, R16C:$rB), |
| 1776 | "nor\t$rT, $rA, $rB", IntegerOp, |
| 1777 | [(set R16C:$rT, (not (or R16C:$rA, R16C:$rB)))]>; |
| 1778 | |
Scott Michel | 438be25 | 2007-12-17 22:32:34 +0000 | [diff] [blame] | 1779 | def NORr8: |
| 1780 | RRForm<0b10010010000, (outs R8C:$rT), (ins R8C:$rA, R8C:$rB), |
| 1781 | "nor\t$rT, $rA, $rB", IntegerOp, |
| 1782 | [(set R8C:$rT, (not (or R8C:$rA, R8C:$rB)))]>; |
| 1783 | |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 1784 | // Select bits: |
Scott Michel | 6baba07 | 2008-03-05 23:02:02 +0000 | [diff] [blame] | 1785 | class SELBInst<dag OOL, dag IOL, list<dag> pattern>: |
| 1786 | RRRForm<0b1000, OOL, IOL, "selb\t$rT, $rA, $rB, $rC", |
| 1787 | IntegerOp, pattern>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 1788 | |
Scott Michel | 6baba07 | 2008-03-05 23:02:02 +0000 | [diff] [blame] | 1789 | class SELBVecInst<ValueType vectype>: |
| 1790 | SELBInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB, VECREG:$rC), |
| 1791 | [(set (vectype VECREG:$rT), |
| 1792 | (or (and (vectype VECREG:$rC), (vectype VECREG:$rB)), |
| 1793 | (and (vnot (vectype VECREG:$rC)), |
| 1794 | (vectype VECREG:$rA))))]>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 1795 | |
Scott Michel | 06eabde | 2008-12-27 04:51:36 +0000 | [diff] [blame^] | 1796 | class SELBVecCondInst<ValueType vectype>: |
| 1797 | SELBInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB, R32C:$rC), |
| 1798 | [(set (vectype VECREG:$rT), |
| 1799 | (select R32C:$rC, |
| 1800 | (vectype VECREG:$rB), |
| 1801 | (vectype VECREG:$rA)))]>; |
| 1802 | |
Scott Michel | 6baba07 | 2008-03-05 23:02:02 +0000 | [diff] [blame] | 1803 | class SELBRegInst<RegisterClass rclass>: |
| 1804 | SELBInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB, rclass:$rC), |
| 1805 | [(set rclass:$rT, |
| 1806 | (or (and rclass:$rA, rclass:$rC), |
| 1807 | (and rclass:$rB, (not rclass:$rC))))]>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 1808 | |
Scott Michel | 06eabde | 2008-12-27 04:51:36 +0000 | [diff] [blame^] | 1809 | class SELBRegCondInst<RegisterClass rcond, RegisterClass rclass>: |
| 1810 | SELBInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB, rcond:$rC), |
| 1811 | [(set rclass:$rT, |
| 1812 | (select rcond:$rC, rclass:$rB, rclass:$rA))]>; |
| 1813 | |
Scott Michel | 6baba07 | 2008-03-05 23:02:02 +0000 | [diff] [blame] | 1814 | multiclass SelectBits |
| 1815 | { |
| 1816 | def v16i8: SELBVecInst<v16i8>; |
| 1817 | def v8i16: SELBVecInst<v8i16>; |
| 1818 | def v4i32: SELBVecInst<v4i32>; |
| 1819 | def v2i64: SELBVecInst<v2i64>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 1820 | |
Scott Michel | 6baba07 | 2008-03-05 23:02:02 +0000 | [diff] [blame] | 1821 | def r128: SELBRegInst<GPRC>; |
| 1822 | def r64: SELBRegInst<R64C>; |
| 1823 | def r32: SELBRegInst<R32C>; |
| 1824 | def r16: SELBRegInst<R16C>; |
| 1825 | def r8: SELBRegInst<R8C>; |
Scott Michel | 06eabde | 2008-12-27 04:51:36 +0000 | [diff] [blame^] | 1826 | |
| 1827 | def v16i8_cond: SELBVecCondInst<v16i8>; |
| 1828 | def v8i16_cond: SELBVecCondInst<v8i16>; |
| 1829 | def v4i32_cond: SELBVecCondInst<v4i32>; |
| 1830 | def v2i64_cond: SELBVecCondInst<v2i64>; |
| 1831 | |
| 1832 | // SELBr64_cond is defined further down, look for i64 comparisons |
| 1833 | def r32_cond: SELBRegCondInst<R32C, R32C>; |
| 1834 | def r16_cond: SELBRegCondInst<R16C, R16C>; |
| 1835 | def r8_cond: SELBRegCondInst<R8C, R8C>; |
Scott Michel | 6baba07 | 2008-03-05 23:02:02 +0000 | [diff] [blame] | 1836 | } |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 1837 | |
Scott Michel | 6baba07 | 2008-03-05 23:02:02 +0000 | [diff] [blame] | 1838 | defm SELB : SelectBits; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 1839 | |
Scott Michel | 56a125e | 2008-11-22 23:50:42 +0000 | [diff] [blame] | 1840 | class SPUselbPatVec<ValueType vectype, SPUInstr inst>: |
Scott Michel | 6baba07 | 2008-03-05 23:02:02 +0000 | [diff] [blame] | 1841 | Pat<(SPUselb (vectype VECREG:$rA), (vectype VECREG:$rB), (vectype VECREG:$rC)), |
| 1842 | (inst VECREG:$rA, VECREG:$rB, VECREG:$rC)>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 1843 | |
Scott Michel | 56a125e | 2008-11-22 23:50:42 +0000 | [diff] [blame] | 1844 | def : SPUselbPatVec<v16i8, SELBv16i8>; |
| 1845 | def : SPUselbPatVec<v8i16, SELBv8i16>; |
| 1846 | def : SPUselbPatVec<v4i32, SELBv4i32>; |
| 1847 | def : SPUselbPatVec<v2i64, SELBv2i64>; |
| 1848 | |
| 1849 | class SPUselbPatReg<RegisterClass rclass, SPUInstr inst>: |
| 1850 | Pat<(SPUselb rclass:$rA, rclass:$rB, rclass:$rC), |
| 1851 | (inst rclass:$rA, rclass:$rB, rclass:$rC)>; |
| 1852 | |
| 1853 | def : SPUselbPatReg<R8C, SELBr8>; |
| 1854 | def : SPUselbPatReg<R16C, SELBr16>; |
| 1855 | def : SPUselbPatReg<R32C, SELBr32>; |
| 1856 | def : SPUselbPatReg<R64C, SELBr64>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 1857 | |
Scott Michel | 6baba07 | 2008-03-05 23:02:02 +0000 | [diff] [blame] | 1858 | // EQV: Equivalence (1 for each same bit, otherwise 0) |
| 1859 | // |
| 1860 | // Note: There are a lot of ways to match this bit operator and these patterns |
| 1861 | // attempt to be as exhaustive as possible. |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 1862 | |
Scott Michel | 6baba07 | 2008-03-05 23:02:02 +0000 | [diff] [blame] | 1863 | class EQVInst<dag OOL, dag IOL, list<dag> pattern>: |
| 1864 | RRForm<0b10010010000, OOL, IOL, "eqv\t$rT, $rA, $rB", |
| 1865 | IntegerOp, pattern>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 1866 | |
Scott Michel | 6baba07 | 2008-03-05 23:02:02 +0000 | [diff] [blame] | 1867 | class EQVVecInst<ValueType vectype>: |
| 1868 | EQVInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB), |
| 1869 | [(set (vectype VECREG:$rT), |
| 1870 | (or (and (vectype VECREG:$rA), (vectype VECREG:$rB)), |
| 1871 | (and (vnot (vectype VECREG:$rA)), |
| 1872 | (vnot (vectype VECREG:$rB)))))]>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 1873 | |
Scott Michel | 6baba07 | 2008-03-05 23:02:02 +0000 | [diff] [blame] | 1874 | class EQVRegInst<RegisterClass rclass>: |
| 1875 | EQVInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB), |
| 1876 | [(set rclass:$rT, (or (and rclass:$rA, rclass:$rB), |
| 1877 | (and (not rclass:$rA), (not rclass:$rB))))]>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 1878 | |
Scott Michel | 6baba07 | 2008-03-05 23:02:02 +0000 | [diff] [blame] | 1879 | class EQVVecPattern1<ValueType vectype>: |
| 1880 | EQVInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB), |
| 1881 | [(set (vectype VECREG:$rT), |
| 1882 | (xor (vectype VECREG:$rA), (vnot (vectype VECREG:$rB))))]>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 1883 | |
Scott Michel | 6baba07 | 2008-03-05 23:02:02 +0000 | [diff] [blame] | 1884 | class EQVRegPattern1<RegisterClass rclass>: |
| 1885 | EQVInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB), |
| 1886 | [(set rclass:$rT, (xor rclass:$rA, (not rclass:$rB)))]>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 1887 | |
Scott Michel | 6baba07 | 2008-03-05 23:02:02 +0000 | [diff] [blame] | 1888 | class EQVVecPattern2<ValueType vectype>: |
| 1889 | EQVInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB), |
| 1890 | [(set (vectype VECREG:$rT), |
| 1891 | (or (and (vectype VECREG:$rA), (vectype VECREG:$rB)), |
| 1892 | (vnot (or (vectype VECREG:$rA), (vectype VECREG:$rB)))))]>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 1893 | |
Scott Michel | 6baba07 | 2008-03-05 23:02:02 +0000 | [diff] [blame] | 1894 | class EQVRegPattern2<RegisterClass rclass>: |
| 1895 | EQVInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB), |
| 1896 | [(set rclass:$rT, |
| 1897 | (or (and rclass:$rA, rclass:$rB), |
| 1898 | (not (or rclass:$rA, rclass:$rB))))]>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 1899 | |
Scott Michel | 6baba07 | 2008-03-05 23:02:02 +0000 | [diff] [blame] | 1900 | class EQVVecPattern3<ValueType vectype>: |
| 1901 | EQVInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB), |
| 1902 | [(set (vectype VECREG:$rT), |
| 1903 | (not (xor (vectype VECREG:$rA), (vectype VECREG:$rB))))]>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 1904 | |
Scott Michel | 6baba07 | 2008-03-05 23:02:02 +0000 | [diff] [blame] | 1905 | class EQVRegPattern3<RegisterClass rclass>: |
| 1906 | EQVInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB), |
| 1907 | [(set rclass:$rT, (not (xor rclass:$rA, rclass:$rB)))]>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 1908 | |
Scott Michel | 6baba07 | 2008-03-05 23:02:02 +0000 | [diff] [blame] | 1909 | multiclass BitEquivalence |
| 1910 | { |
| 1911 | def v16i8: EQVVecInst<v16i8>; |
| 1912 | def v8i16: EQVVecInst<v8i16>; |
| 1913 | def v4i32: EQVVecInst<v4i32>; |
| 1914 | def v2i64: EQVVecInst<v2i64>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 1915 | |
Scott Michel | 6baba07 | 2008-03-05 23:02:02 +0000 | [diff] [blame] | 1916 | def v16i8_1: EQVVecPattern1<v16i8>; |
| 1917 | def v8i16_1: EQVVecPattern1<v8i16>; |
| 1918 | def v4i32_1: EQVVecPattern1<v4i32>; |
| 1919 | def v2i64_1: EQVVecPattern1<v2i64>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 1920 | |
Scott Michel | 6baba07 | 2008-03-05 23:02:02 +0000 | [diff] [blame] | 1921 | def v16i8_2: EQVVecPattern2<v16i8>; |
| 1922 | def v8i16_2: EQVVecPattern2<v8i16>; |
| 1923 | def v4i32_2: EQVVecPattern2<v4i32>; |
| 1924 | def v2i64_2: EQVVecPattern2<v2i64>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 1925 | |
Scott Michel | 6baba07 | 2008-03-05 23:02:02 +0000 | [diff] [blame] | 1926 | def v16i8_3: EQVVecPattern3<v16i8>; |
| 1927 | def v8i16_3: EQVVecPattern3<v8i16>; |
| 1928 | def v4i32_3: EQVVecPattern3<v4i32>; |
| 1929 | def v2i64_3: EQVVecPattern3<v2i64>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 1930 | |
Scott Michel | 6baba07 | 2008-03-05 23:02:02 +0000 | [diff] [blame] | 1931 | def r128: EQVRegInst<GPRC>; |
| 1932 | def r64: EQVRegInst<R64C>; |
| 1933 | def r32: EQVRegInst<R32C>; |
| 1934 | def r16: EQVRegInst<R16C>; |
| 1935 | def r8: EQVRegInst<R8C>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 1936 | |
Scott Michel | 6baba07 | 2008-03-05 23:02:02 +0000 | [diff] [blame] | 1937 | def r128_1: EQVRegPattern1<GPRC>; |
| 1938 | def r64_1: EQVRegPattern1<R64C>; |
| 1939 | def r32_1: EQVRegPattern1<R32C>; |
| 1940 | def r16_1: EQVRegPattern1<R16C>; |
| 1941 | def r8_1: EQVRegPattern1<R8C>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 1942 | |
Scott Michel | 6baba07 | 2008-03-05 23:02:02 +0000 | [diff] [blame] | 1943 | def r128_2: EQVRegPattern2<GPRC>; |
| 1944 | def r64_2: EQVRegPattern2<R64C>; |
| 1945 | def r32_2: EQVRegPattern2<R32C>; |
| 1946 | def r16_2: EQVRegPattern2<R16C>; |
| 1947 | def r8_2: EQVRegPattern2<R8C>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 1948 | |
Scott Michel | 6baba07 | 2008-03-05 23:02:02 +0000 | [diff] [blame] | 1949 | def r128_3: EQVRegPattern3<GPRC>; |
| 1950 | def r64_3: EQVRegPattern3<R64C>; |
| 1951 | def r32_3: EQVRegPattern3<R32C>; |
| 1952 | def r16_3: EQVRegPattern3<R16C>; |
| 1953 | def r8_3: EQVRegPattern3<R8C>; |
| 1954 | } |
Scott Michel | 438be25 | 2007-12-17 22:32:34 +0000 | [diff] [blame] | 1955 | |
Scott Michel | 6baba07 | 2008-03-05 23:02:02 +0000 | [diff] [blame] | 1956 | defm EQV: BitEquivalence; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 1957 | |
| 1958 | //===----------------------------------------------------------------------===// |
| 1959 | // Vector shuffle... |
| 1960 | //===----------------------------------------------------------------------===// |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 1961 | // SPUshuffle is generated in LowerVECTOR_SHUFFLE and gets replaced with SHUFB. |
| 1962 | // See the SPUshuffle SDNode operand above, which sets up the DAG pattern |
| 1963 | // matcher to emit something when the LowerVECTOR_SHUFFLE generates a node with |
| 1964 | // the SPUISD::SHUFB opcode. |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 1965 | //===----------------------------------------------------------------------===// |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 1966 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 1967 | class SHUFBInst<dag OOL, dag IOL, list<dag> pattern>: |
| 1968 | RRRForm<0b1000, OOL, IOL, "shufb\t$rT, $rA, $rB, $rC", |
| 1969 | IntegerOp, pattern>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 1970 | |
Scott Michel | 0718cd8 | 2008-12-01 17:56:02 +0000 | [diff] [blame] | 1971 | class SHUFBVecInst<ValueType resultvec, ValueType maskvec>: |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 1972 | SHUFBInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB, VECREG:$rC), |
Scott Michel | 0718cd8 | 2008-12-01 17:56:02 +0000 | [diff] [blame] | 1973 | [(set (resultvec VECREG:$rT), |
| 1974 | (SPUshuffle (resultvec VECREG:$rA), |
| 1975 | (resultvec VECREG:$rB), |
| 1976 | (maskvec VECREG:$rC)))]>; |
Scott Michel | 754d866 | 2007-12-20 00:44:13 +0000 | [diff] [blame] | 1977 | |
Scott Michel | 06eabde | 2008-12-27 04:51:36 +0000 | [diff] [blame^] | 1978 | class SHUFBGPRCInst: |
| 1979 | SHUFBInst<(outs VECREG:$rT), (ins GPRC:$rA, GPRC:$rB, VECREG:$rC), |
| 1980 | [/* no pattern */]>; |
| 1981 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 1982 | multiclass ShuffleBytes |
| 1983 | { |
Scott Michel | 0718cd8 | 2008-12-01 17:56:02 +0000 | [diff] [blame] | 1984 | def v16i8 : SHUFBVecInst<v16i8, v16i8>; |
| 1985 | def v16i8_m32 : SHUFBVecInst<v16i8, v4i32>; |
| 1986 | def v8i16 : SHUFBVecInst<v8i16, v16i8>; |
| 1987 | def v8i16_m32 : SHUFBVecInst<v8i16, v4i32>; |
| 1988 | def v4i32 : SHUFBVecInst<v4i32, v16i8>; |
| 1989 | def v4i32_m32 : SHUFBVecInst<v4i32, v4i32>; |
| 1990 | def v2i64 : SHUFBVecInst<v2i64, v16i8>; |
| 1991 | def v2i64_m32 : SHUFBVecInst<v2i64, v4i32>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 1992 | |
Scott Michel | 0718cd8 | 2008-12-01 17:56:02 +0000 | [diff] [blame] | 1993 | def v4f32 : SHUFBVecInst<v4f32, v16i8>; |
| 1994 | def v4f32_m32 : SHUFBVecInst<v4f32, v4i32>; |
| 1995 | |
| 1996 | def v2f64 : SHUFBVecInst<v2f64, v16i8>; |
| 1997 | def v2f64_m32 : SHUFBVecInst<v2f64, v4i32>; |
Scott Michel | 06eabde | 2008-12-27 04:51:36 +0000 | [diff] [blame^] | 1998 | |
| 1999 | def gprc : SHUFBGPRCInst; |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 2000 | } |
| 2001 | |
| 2002 | defm SHUFB : ShuffleBytes; |
| 2003 | |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 2004 | //===----------------------------------------------------------------------===// |
| 2005 | // Shift and rotate group: |
| 2006 | //===----------------------------------------------------------------------===// |
| 2007 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 2008 | class SHLHInst<dag OOL, dag IOL, list<dag> pattern>: |
| 2009 | RRForm<0b11111010000, OOL, IOL, "shlh\t$rT, $rA, $rB", |
| 2010 | RotateShift, pattern>; |
| 2011 | |
| 2012 | class SHLHVecInst<ValueType vectype>: |
| 2013 | SHLHInst<(outs VECREG:$rT), (ins VECREG:$rA, R16C:$rB), |
| 2014 | [(set (vectype VECREG:$rT), |
| 2015 | (SPUvec_shl (vectype VECREG:$rA), R16C:$rB))]>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 2016 | |
| 2017 | // $rB gets promoted to 32-bit register type when confronted with |
| 2018 | // this llvm assembly code: |
| 2019 | // |
| 2020 | // define i16 @shlh_i16_1(i16 %arg1, i16 %arg2) { |
| 2021 | // %A = shl i16 %arg1, %arg2 |
| 2022 | // ret i16 %A |
| 2023 | // } |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 2024 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 2025 | multiclass ShiftLeftHalfword |
| 2026 | { |
| 2027 | def v8i16: SHLHVecInst<v8i16>; |
| 2028 | def r16: SHLHInst<(outs R16C:$rT), (ins R16C:$rA, R16C:$rB), |
| 2029 | [(set R16C:$rT, (shl R16C:$rA, R16C:$rB))]>; |
| 2030 | def r16_r32: SHLHInst<(outs R16C:$rT), (ins R16C:$rA, R32C:$rB), |
| 2031 | [(set R16C:$rT, (shl R16C:$rA, R32C:$rB))]>; |
| 2032 | } |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 2033 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 2034 | defm SHLH : ShiftLeftHalfword; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 2035 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 2036 | //===----------------------------------------------------------------------===// |
Scott Michel | 438be25 | 2007-12-17 22:32:34 +0000 | [diff] [blame] | 2037 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 2038 | class SHLHIInst<dag OOL, dag IOL, list<dag> pattern>: |
| 2039 | RI7Form<0b11111010000, OOL, IOL, "shlhi\t$rT, $rA, $val", |
| 2040 | RotateShift, pattern>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 2041 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 2042 | class SHLHIVecInst<ValueType vectype>: |
| 2043 | SHLHIInst<(outs VECREG:$rT), (ins VECREG:$rA, u7imm:$val), |
| 2044 | [(set (vectype VECREG:$rT), |
| 2045 | (SPUvec_shl (vectype VECREG:$rA), (i16 uimm7:$val)))]>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 2046 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 2047 | multiclass ShiftLeftHalfwordImm |
| 2048 | { |
| 2049 | def v8i16: SHLHIVecInst<v8i16>; |
| 2050 | def r16: SHLHIInst<(outs R16C:$rT), (ins R16C:$rA, u7imm:$val), |
| 2051 | [(set R16C:$rT, (shl R16C:$rA, (i16 uimm7:$val)))]>; |
| 2052 | } |
| 2053 | |
| 2054 | defm SHLHI : ShiftLeftHalfwordImm; |
| 2055 | |
| 2056 | def : Pat<(SPUvec_shl (v8i16 VECREG:$rA), (i32 uimm7:$val)), |
| 2057 | (SHLHIv8i16 VECREG:$rA, uimm7:$val)>; |
| 2058 | |
| 2059 | def : Pat<(shl R16C:$rA, (i32 uimm7:$val)), |
Scott Michel | 438be25 | 2007-12-17 22:32:34 +0000 | [diff] [blame] | 2060 | (SHLHIr16 R16C:$rA, uimm7:$val)>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 2061 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 2062 | //===----------------------------------------------------------------------===// |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 2063 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 2064 | class SHLInst<dag OOL, dag IOL, list<dag> pattern>: |
| 2065 | RRForm<0b11111010000, OOL, IOL, "shl\t$rT, $rA, $rB", |
| 2066 | RotateShift, pattern>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 2067 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 2068 | multiclass ShiftLeftWord |
| 2069 | { |
| 2070 | def v4i32: |
| 2071 | SHLInst<(outs VECREG:$rT), (ins VECREG:$rA, R16C:$rB), |
| 2072 | [(set (v4i32 VECREG:$rT), |
| 2073 | (SPUvec_shl (v4i32 VECREG:$rA), R16C:$rB))]>; |
| 2074 | def r32: |
| 2075 | SHLInst<(outs R32C:$rT), (ins R32C:$rA, R32C:$rB), |
| 2076 | [(set R32C:$rT, (shl R32C:$rA, R32C:$rB))]>; |
| 2077 | } |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 2078 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 2079 | defm SHL: ShiftLeftWord; |
Scott Michel | 438be25 | 2007-12-17 22:32:34 +0000 | [diff] [blame] | 2080 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 2081 | //===----------------------------------------------------------------------===// |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 2082 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 2083 | class SHLIInst<dag OOL, dag IOL, list<dag> pattern>: |
| 2084 | RI7Form<0b11111010000, OOL, IOL, "shli\t$rT, $rA, $val", |
| 2085 | RotateShift, pattern>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 2086 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 2087 | multiclass ShiftLeftWordImm |
| 2088 | { |
| 2089 | def v4i32: |
| 2090 | SHLIInst<(outs VECREG:$rT), (ins VECREG:$rA, u7imm_i32:$val), |
| 2091 | [(set (v4i32 VECREG:$rT), |
| 2092 | (SPUvec_shl (v4i32 VECREG:$rA), (i32 uimm7:$val)))]>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 2093 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 2094 | def r32: |
| 2095 | SHLIInst<(outs R32C:$rT), (ins R32C:$rA, u7imm_i32:$val), |
| 2096 | [(set R32C:$rT, (shl R32C:$rA, (i32 uimm7:$val)))]>; |
| 2097 | } |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 2098 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 2099 | defm SHLI : ShiftLeftWordImm; |
Scott Michel | 438be25 | 2007-12-17 22:32:34 +0000 | [diff] [blame] | 2100 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 2101 | //===----------------------------------------------------------------------===// |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 2102 | // SHLQBI vec form: Note that this will shift the entire vector (the 128-bit |
| 2103 | // register) to the left. Vector form is here to ensure type correctness. |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 2104 | // |
| 2105 | // The shift count is in the lowest 3 bits (29-31) of $rB, so only a bit shift |
| 2106 | // of 7 bits is actually possible. |
| 2107 | // |
| 2108 | // Note also that SHLQBI/SHLQBII are used in conjunction with SHLQBY/SHLQBYI |
| 2109 | // to shift i64 and i128. SHLQBI is the residual left over after shifting by |
| 2110 | // bytes with SHLQBY. |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 2111 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 2112 | class SHLQBIInst<dag OOL, dag IOL, list<dag> pattern>: |
| 2113 | RRForm<0b11011011100, OOL, IOL, "shlqbi\t$rT, $rA, $rB", |
| 2114 | RotateShift, pattern>; |
| 2115 | |
| 2116 | class SHLQBIVecInst<ValueType vectype>: |
| 2117 | SHLQBIInst<(outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB), |
| 2118 | [(set (vectype VECREG:$rT), |
| 2119 | (SPUshlquad_l_bits (vectype VECREG:$rA), R32C:$rB))]>; |
| 2120 | |
| 2121 | multiclass ShiftLeftQuadByBits |
| 2122 | { |
| 2123 | def v16i8: SHLQBIVecInst<v16i8>; |
| 2124 | def v8i16: SHLQBIVecInst<v8i16>; |
| 2125 | def v4i32: SHLQBIVecInst<v4i32>; |
Scott Michel | 56a125e | 2008-11-22 23:50:42 +0000 | [diff] [blame] | 2126 | def v4f32: SHLQBIVecInst<v4f32>; |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 2127 | def v2i64: SHLQBIVecInst<v2i64>; |
Scott Michel | 56a125e | 2008-11-22 23:50:42 +0000 | [diff] [blame] | 2128 | def v2f64: SHLQBIVecInst<v2f64>; |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 2129 | } |
| 2130 | |
| 2131 | defm SHLQBI : ShiftLeftQuadByBits; |
| 2132 | |
| 2133 | // See note above on SHLQBI. In this case, the predicate actually does then |
| 2134 | // enforcement, whereas with SHLQBI, we have to "take it on faith." |
| 2135 | class SHLQBIIInst<dag OOL, dag IOL, list<dag> pattern>: |
| 2136 | RI7Form<0b11011111100, OOL, IOL, "shlqbii\t$rT, $rA, $val", |
| 2137 | RotateShift, pattern>; |
| 2138 | |
| 2139 | class SHLQBIIVecInst<ValueType vectype>: |
| 2140 | SHLQBIIInst<(outs VECREG:$rT), (ins VECREG:$rA, u7imm_i32:$val), |
| 2141 | [(set (vectype VECREG:$rT), |
| 2142 | (SPUshlquad_l_bits (vectype VECREG:$rA), (i32 bitshift:$val)))]>; |
| 2143 | |
| 2144 | multiclass ShiftLeftQuadByBitsImm |
| 2145 | { |
| 2146 | def v16i8 : SHLQBIIVecInst<v16i8>; |
| 2147 | def v8i16 : SHLQBIIVecInst<v8i16>; |
| 2148 | def v4i32 : SHLQBIIVecInst<v4i32>; |
Scott Michel | 56a125e | 2008-11-22 23:50:42 +0000 | [diff] [blame] | 2149 | def v4f32 : SHLQBIIVecInst<v4f32>; |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 2150 | def v2i64 : SHLQBIIVecInst<v2i64>; |
Scott Michel | 56a125e | 2008-11-22 23:50:42 +0000 | [diff] [blame] | 2151 | def v2f64 : SHLQBIIVecInst<v2f64>; |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 2152 | } |
| 2153 | |
| 2154 | defm SHLQBII : ShiftLeftQuadByBitsImm; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 2155 | |
| 2156 | // SHLQBY, SHLQBYI vector forms: Shift the entire vector to the left by bytes, |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 2157 | // not by bits. See notes above on SHLQBI. |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 2158 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 2159 | class SHLQBYInst<dag OOL, dag IOL, list<dag> pattern>: |
Scott Michel | fa88863 | 2008-11-25 00:23:16 +0000 | [diff] [blame] | 2160 | RI7Form<0b11111011100, OOL, IOL, "shlqby\t$rT, $rA, $rB", |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 2161 | RotateShift, pattern>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 2162 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 2163 | class SHLQBYVecInst<ValueType vectype>: |
| 2164 | SHLQBYInst<(outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB), |
| 2165 | [(set (vectype VECREG:$rT), |
| 2166 | (SPUshlquad_l_bytes (vectype VECREG:$rA), R32C:$rB))]>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 2167 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 2168 | multiclass ShiftLeftQuadBytes |
| 2169 | { |
| 2170 | def v16i8: SHLQBYVecInst<v16i8>; |
| 2171 | def v8i16: SHLQBYVecInst<v8i16>; |
| 2172 | def v4i32: SHLQBYVecInst<v4i32>; |
Scott Michel | 56a125e | 2008-11-22 23:50:42 +0000 | [diff] [blame] | 2173 | def v4f32: SHLQBYVecInst<v4f32>; |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 2174 | def v2i64: SHLQBYVecInst<v2i64>; |
Scott Michel | 56a125e | 2008-11-22 23:50:42 +0000 | [diff] [blame] | 2175 | def v2f64: SHLQBYVecInst<v2f64>; |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 2176 | def r128: SHLQBYInst<(outs GPRC:$rT), (ins GPRC:$rA, R32C:$rB), |
| 2177 | [(set GPRC:$rT, (SPUshlquad_l_bytes GPRC:$rA, R32C:$rB))]>; |
| 2178 | } |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 2179 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 2180 | defm SHLQBY: ShiftLeftQuadBytes; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 2181 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 2182 | class SHLQBYIInst<dag OOL, dag IOL, list<dag> pattern>: |
| 2183 | RI7Form<0b11111111100, OOL, IOL, "shlqbyi\t$rT, $rA, $val", |
| 2184 | RotateShift, pattern>; |
Scott Michel | 438be25 | 2007-12-17 22:32:34 +0000 | [diff] [blame] | 2185 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 2186 | class SHLQBYIVecInst<ValueType vectype>: |
| 2187 | SHLQBYIInst<(outs VECREG:$rT), (ins VECREG:$rA, u7imm_i32:$val), |
| 2188 | [(set (vectype VECREG:$rT), |
| 2189 | (SPUshlquad_l_bytes (vectype VECREG:$rA), (i32 uimm7:$val)))]>; |
Scott Michel | 438be25 | 2007-12-17 22:32:34 +0000 | [diff] [blame] | 2190 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 2191 | multiclass ShiftLeftQuadBytesImm |
| 2192 | { |
| 2193 | def v16i8: SHLQBYIVecInst<v16i8>; |
| 2194 | def v8i16: SHLQBYIVecInst<v8i16>; |
| 2195 | def v4i32: SHLQBYIVecInst<v4i32>; |
Scott Michel | 56a125e | 2008-11-22 23:50:42 +0000 | [diff] [blame] | 2196 | def v4f32: SHLQBYIVecInst<v4f32>; |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 2197 | def v2i64: SHLQBYIVecInst<v2i64>; |
Scott Michel | 56a125e | 2008-11-22 23:50:42 +0000 | [diff] [blame] | 2198 | def v2f64: SHLQBYIVecInst<v2f64>; |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 2199 | def r128: SHLQBYIInst<(outs GPRC:$rT), (ins GPRC:$rA, u7imm_i32:$val), |
| 2200 | [(set GPRC:$rT, |
| 2201 | (SPUshlquad_l_bytes GPRC:$rA, (i32 uimm7:$val)))]>; |
| 2202 | } |
Scott Michel | 438be25 | 2007-12-17 22:32:34 +0000 | [diff] [blame] | 2203 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 2204 | defm SHLQBYI : ShiftLeftQuadBytesImm; |
Scott Michel | 438be25 | 2007-12-17 22:32:34 +0000 | [diff] [blame] | 2205 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 2206 | //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ |
| 2207 | // Rotate halfword: |
| 2208 | //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ |
| 2209 | class ROTHInst<dag OOL, dag IOL, list<dag> pattern>: |
| 2210 | RRForm<0b00111010000, OOL, IOL, "roth\t$rT, $rA, $rB", |
| 2211 | RotateShift, pattern>; |
| 2212 | |
| 2213 | class ROTHVecInst<ValueType vectype>: |
| 2214 | ROTHInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB), |
| 2215 | [(set (vectype VECREG:$rT), |
| 2216 | (SPUvec_rotl VECREG:$rA, VECREG:$rB))]>; |
| 2217 | |
| 2218 | class ROTHRegInst<RegisterClass rclass>: |
| 2219 | ROTHInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB), |
| 2220 | [(set rclass:$rT, (rotl rclass:$rA, rclass:$rB))]>; |
| 2221 | |
| 2222 | multiclass RotateLeftHalfword |
| 2223 | { |
| 2224 | def v8i16: ROTHVecInst<v8i16>; |
| 2225 | def r16: ROTHRegInst<R16C>; |
| 2226 | } |
| 2227 | |
| 2228 | defm ROTH: RotateLeftHalfword; |
| 2229 | |
| 2230 | def ROTHr16_r32: ROTHInst<(outs R16C:$rT), (ins R16C:$rA, R32C:$rB), |
| 2231 | [(set R16C:$rT, (rotl R16C:$rA, R32C:$rB))]>; |
| 2232 | |
| 2233 | //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ |
| 2234 | // Rotate halfword, immediate: |
| 2235 | //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ |
| 2236 | class ROTHIInst<dag OOL, dag IOL, list<dag> pattern>: |
| 2237 | RI7Form<0b00111110000, OOL, IOL, "rothi\t$rT, $rA, $val", |
| 2238 | RotateShift, pattern>; |
| 2239 | |
| 2240 | class ROTHIVecInst<ValueType vectype>: |
| 2241 | ROTHIInst<(outs VECREG:$rT), (ins VECREG:$rA, u7imm:$val), |
| 2242 | [(set (vectype VECREG:$rT), |
| 2243 | (SPUvec_rotl VECREG:$rA, (i16 uimm7:$val)))]>; |
| 2244 | |
| 2245 | multiclass RotateLeftHalfwordImm |
| 2246 | { |
| 2247 | def v8i16: ROTHIVecInst<v8i16>; |
| 2248 | def r16: ROTHIInst<(outs R16C:$rT), (ins R16C:$rA, u7imm:$val), |
| 2249 | [(set R16C:$rT, (rotl R16C:$rA, (i16 uimm7:$val)))]>; |
| 2250 | def r16_r32: ROTHIInst<(outs R16C:$rT), (ins R16C:$rA, u7imm_i32:$val), |
| 2251 | [(set R16C:$rT, (rotl R16C:$rA, (i32 uimm7:$val)))]>; |
| 2252 | } |
| 2253 | |
| 2254 | defm ROTHI: RotateLeftHalfwordImm; |
| 2255 | |
| 2256 | def : Pat<(SPUvec_rotl VECREG:$rA, (i32 uimm7:$val)), |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 2257 | (ROTHIv8i16 VECREG:$rA, imm:$val)>; |
Scott Michel | 06eabde | 2008-12-27 04:51:36 +0000 | [diff] [blame^] | 2258 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 2259 | //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ |
| 2260 | // Rotate word: |
| 2261 | //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 2262 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 2263 | class ROTInst<dag OOL, dag IOL, list<dag> pattern>: |
| 2264 | RRForm<0b00011010000, OOL, IOL, "rot\t$rT, $rA, $rB", |
| 2265 | RotateShift, pattern>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 2266 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 2267 | class ROTVecInst<ValueType vectype>: |
| 2268 | ROTInst<(outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB), |
| 2269 | [(set (vectype VECREG:$rT), |
| 2270 | (SPUvec_rotl (vectype VECREG:$rA), R32C:$rB))]>; |
Scott Michel | 438be25 | 2007-12-17 22:32:34 +0000 | [diff] [blame] | 2271 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 2272 | class ROTRegInst<RegisterClass rclass>: |
| 2273 | ROTInst<(outs rclass:$rT), (ins rclass:$rA, R32C:$rB), |
| 2274 | [(set rclass:$rT, |
| 2275 | (rotl rclass:$rA, R32C:$rB))]>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 2276 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 2277 | multiclass RotateLeftWord |
| 2278 | { |
| 2279 | def v4i32: ROTVecInst<v4i32>; |
| 2280 | def r32: ROTRegInst<R32C>; |
| 2281 | } |
| 2282 | |
| 2283 | defm ROT: RotateLeftWord; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 2284 | |
Scott Michel | 438be25 | 2007-12-17 22:32:34 +0000 | [diff] [blame] | 2285 | // The rotate amount is in the same bits whether we've got an 8-bit, 16-bit or |
| 2286 | // 32-bit register |
| 2287 | def ROTr32_r16_anyext: |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 2288 | ROTInst<(outs R32C:$rT), (ins R32C:$rA, R16C:$rB), |
| 2289 | [(set R32C:$rT, (rotl R32C:$rA, (i32 (anyext R16C:$rB))))]>; |
Scott Michel | 438be25 | 2007-12-17 22:32:34 +0000 | [diff] [blame] | 2290 | |
| 2291 | def : Pat<(rotl R32C:$rA, (i32 (zext R16C:$rB))), |
| 2292 | (ROTr32_r16_anyext R32C:$rA, R16C:$rB)>; |
| 2293 | |
| 2294 | def : Pat<(rotl R32C:$rA, (i32 (sext R16C:$rB))), |
| 2295 | (ROTr32_r16_anyext R32C:$rA, R16C:$rB)>; |
| 2296 | |
| 2297 | def ROTr32_r8_anyext: |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 2298 | ROTInst<(outs R32C:$rT), (ins R32C:$rA, R8C:$rB), |
| 2299 | [(set R32C:$rT, (rotl R32C:$rA, (i32 (anyext R8C:$rB))))]>; |
Scott Michel | 438be25 | 2007-12-17 22:32:34 +0000 | [diff] [blame] | 2300 | |
| 2301 | def : Pat<(rotl R32C:$rA, (i32 (zext R8C:$rB))), |
| 2302 | (ROTr32_r8_anyext R32C:$rA, R8C:$rB)>; |
| 2303 | |
| 2304 | def : Pat<(rotl R32C:$rA, (i32 (sext R8C:$rB))), |
| 2305 | (ROTr32_r8_anyext R32C:$rA, R8C:$rB)>; |
| 2306 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 2307 | //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ |
| 2308 | // Rotate word, immediate |
| 2309 | //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 2310 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 2311 | class ROTIInst<dag OOL, dag IOL, list<dag> pattern>: |
| 2312 | RI7Form<0b00011110000, OOL, IOL, "roti\t$rT, $rA, $val", |
| 2313 | RotateShift, pattern>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 2314 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 2315 | class ROTIVecInst<ValueType vectype, Operand optype, ValueType inttype, PatLeaf pred>: |
| 2316 | ROTIInst<(outs VECREG:$rT), (ins VECREG:$rA, optype:$val), |
| 2317 | [(set (vectype VECREG:$rT), |
| 2318 | (SPUvec_rotl (vectype VECREG:$rA), (inttype pred:$val)))]>; |
Scott Michel | 438be25 | 2007-12-17 22:32:34 +0000 | [diff] [blame] | 2319 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 2320 | class ROTIRegInst<RegisterClass rclass, Operand optype, ValueType inttype, PatLeaf pred>: |
| 2321 | ROTIInst<(outs rclass:$rT), (ins rclass:$rA, optype:$val), |
| 2322 | [(set rclass:$rT, (rotl rclass:$rA, (inttype pred:$val)))]>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 2323 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 2324 | multiclass RotateLeftWordImm |
| 2325 | { |
| 2326 | def v4i32: ROTIVecInst<v4i32, u7imm_i32, i32, uimm7>; |
| 2327 | def v4i32_i16: ROTIVecInst<v4i32, u7imm, i16, uimm7>; |
| 2328 | def v4i32_i8: ROTIVecInst<v4i32, u7imm_i8, i8, uimm7>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 2329 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 2330 | def r32: ROTIRegInst<R32C, u7imm_i32, i32, uimm7>; |
| 2331 | def r32_i16: ROTIRegInst<R32C, u7imm, i16, uimm7>; |
| 2332 | def r32_i8: ROTIRegInst<R32C, u7imm_i8, i8, uimm7>; |
| 2333 | } |
Scott Michel | 438be25 | 2007-12-17 22:32:34 +0000 | [diff] [blame] | 2334 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 2335 | defm ROTI : RotateLeftWordImm; |
| 2336 | |
| 2337 | //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ |
| 2338 | // Rotate quad by byte (count) |
| 2339 | //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ |
| 2340 | |
| 2341 | class ROTQBYInst<dag OOL, dag IOL, list<dag> pattern>: |
| 2342 | RRForm<0b00111011100, OOL, IOL, "rotqby\t$rT, $rA, $rB", |
| 2343 | RotateShift, pattern>; |
| 2344 | |
| 2345 | class ROTQBYVecInst<ValueType vectype>: |
| 2346 | ROTQBYInst<(outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB), |
| 2347 | [(set (vectype VECREG:$rT), |
| 2348 | (SPUrotbytes_left (vectype VECREG:$rA), R32C:$rB))]>; |
| 2349 | |
| 2350 | multiclass RotateQuadLeftByBytes |
| 2351 | { |
| 2352 | def v16i8: ROTQBYVecInst<v16i8>; |
| 2353 | def v8i16: ROTQBYVecInst<v8i16>; |
| 2354 | def v4i32: ROTQBYVecInst<v4i32>; |
Scott Michel | e2641a1 | 2008-12-04 21:01:44 +0000 | [diff] [blame] | 2355 | def v4f32: ROTQBYVecInst<v4f32>; |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 2356 | def v2i64: ROTQBYVecInst<v2i64>; |
Scott Michel | e2641a1 | 2008-12-04 21:01:44 +0000 | [diff] [blame] | 2357 | def v2f64: ROTQBYVecInst<v2f64>; |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 2358 | } |
| 2359 | |
| 2360 | defm ROTQBY: RotateQuadLeftByBytes; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 2361 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 2362 | //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ |
| 2363 | // Rotate quad by byte (count), immediate |
| 2364 | //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ |
| 2365 | |
| 2366 | class ROTQBYIInst<dag OOL, dag IOL, list<dag> pattern>: |
| 2367 | RI7Form<0b00111111100, OOL, IOL, "rotqbyi\t$rT, $rA, $val", |
| 2368 | RotateShift, pattern>; |
| 2369 | |
| 2370 | class ROTQBYIVecInst<ValueType vectype>: |
| 2371 | ROTQBYIInst<(outs VECREG:$rT), (ins VECREG:$rA, u7imm:$val), |
| 2372 | [(set (vectype VECREG:$rT), |
| 2373 | (SPUrotbytes_left (vectype VECREG:$rA), (i16 uimm7:$val)))]>; |
| 2374 | |
| 2375 | multiclass RotateQuadByBytesImm |
| 2376 | { |
| 2377 | def v16i8: ROTQBYIVecInst<v16i8>; |
| 2378 | def v8i16: ROTQBYIVecInst<v8i16>; |
| 2379 | def v4i32: ROTQBYIVecInst<v4i32>; |
Scott Michel | e2641a1 | 2008-12-04 21:01:44 +0000 | [diff] [blame] | 2380 | def v4f32: ROTQBYIVecInst<v4f32>; |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 2381 | def v2i64: ROTQBYIVecInst<v2i64>; |
Scott Michel | e2641a1 | 2008-12-04 21:01:44 +0000 | [diff] [blame] | 2382 | def vfi64: ROTQBYIVecInst<v2f64>; |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 2383 | } |
| 2384 | |
| 2385 | defm ROTQBYI: RotateQuadByBytesImm; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 2386 | |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 2387 | // See ROTQBY note above. |
Scott Michel | 67224b2 | 2008-06-02 22:18:03 +0000 | [diff] [blame] | 2388 | class ROTQBYBIInst<dag OOL, dag IOL, list<dag> pattern>: |
| 2389 | RI7Form<0b00110011100, OOL, IOL, |
| 2390 | "rotqbybi\t$rT, $rA, $shift", |
| 2391 | RotateShift, pattern>; |
| 2392 | |
| 2393 | class ROTQBYBIVecInst<ValueType vectype, RegisterClass rclass>: |
| 2394 | ROTQBYBIInst<(outs VECREG:$rT), (ins VECREG:$rA, rclass:$shift), |
| 2395 | [(set (vectype VECREG:$rT), |
| 2396 | (SPUrotbytes_left_bits (vectype VECREG:$rA), rclass:$shift))]>; |
| 2397 | |
| 2398 | multiclass RotateQuadByBytesByBitshift { |
| 2399 | def v16i8_r32: ROTQBYBIVecInst<v16i8, R32C>; |
| 2400 | def v8i16_r32: ROTQBYBIVecInst<v8i16, R32C>; |
| 2401 | def v4i32_r32: ROTQBYBIVecInst<v4i32, R32C>; |
| 2402 | def v2i64_r32: ROTQBYBIVecInst<v2i64, R32C>; |
| 2403 | } |
| 2404 | |
| 2405 | defm ROTQBYBI : RotateQuadByBytesByBitshift; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 2406 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 2407 | //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 2408 | // See ROTQBY note above. |
| 2409 | // |
| 2410 | // Assume that the user of this instruction knows to shift the rotate count |
| 2411 | // into bit 29 |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 2412 | //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 2413 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 2414 | class ROTQBIInst<dag OOL, dag IOL, list<dag> pattern>: |
| 2415 | RRForm<0b00011011100, OOL, IOL, "rotqbi\t$rT, $rA, $rB", |
| 2416 | RotateShift, pattern>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 2417 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 2418 | class ROTQBIVecInst<ValueType vectype>: |
| 2419 | ROTQBIInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB), |
| 2420 | [/* no pattern yet */]>; |
| 2421 | |
| 2422 | class ROTQBIRegInst<RegisterClass rclass>: |
| 2423 | ROTQBIInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB), |
| 2424 | [/* no pattern yet */]>; |
| 2425 | |
| 2426 | multiclass RotateQuadByBitCount |
| 2427 | { |
| 2428 | def v16i8: ROTQBIVecInst<v16i8>; |
| 2429 | def v8i16: ROTQBIVecInst<v8i16>; |
| 2430 | def v4i32: ROTQBIVecInst<v4i32>; |
| 2431 | def v2i64: ROTQBIVecInst<v2i64>; |
| 2432 | |
| 2433 | def r128: ROTQBIRegInst<GPRC>; |
| 2434 | def r64: ROTQBIRegInst<R64C>; |
| 2435 | } |
| 2436 | |
| 2437 | defm ROTQBI: RotateQuadByBitCount; |
Scott Michel | 06eabde | 2008-12-27 04:51:36 +0000 | [diff] [blame^] | 2438 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 2439 | class ROTQBIIInst<dag OOL, dag IOL, list<dag> pattern>: |
| 2440 | RI7Form<0b00011111100, OOL, IOL, "rotqbii\t$rT, $rA, $val", |
| 2441 | RotateShift, pattern>; |
| 2442 | |
| 2443 | class ROTQBIIVecInst<ValueType vectype, Operand optype, ValueType inttype, |
| 2444 | PatLeaf pred>: |
| 2445 | ROTQBIIInst<(outs VECREG:$rT), (ins VECREG:$rA, optype:$val), |
| 2446 | [/* no pattern yet */]>; |
| 2447 | |
| 2448 | class ROTQBIIRegInst<RegisterClass rclass, Operand optype, ValueType inttype, |
| 2449 | PatLeaf pred>: |
| 2450 | ROTQBIIInst<(outs rclass:$rT), (ins rclass:$rA, optype:$val), |
| 2451 | [/* no pattern yet */]>; |
| 2452 | |
| 2453 | multiclass RotateQuadByBitCountImm |
| 2454 | { |
| 2455 | def v16i8: ROTQBIIVecInst<v16i8, u7imm_i32, i32, uimm7>; |
| 2456 | def v8i16: ROTQBIIVecInst<v8i16, u7imm_i32, i32, uimm7>; |
| 2457 | def v4i32: ROTQBIIVecInst<v4i32, u7imm_i32, i32, uimm7>; |
| 2458 | def v2i64: ROTQBIIVecInst<v2i64, u7imm_i32, i32, uimm7>; |
| 2459 | |
| 2460 | def r128: ROTQBIIRegInst<GPRC, u7imm_i32, i32, uimm7>; |
| 2461 | def r64: ROTQBIIRegInst<R64C, u7imm_i32, i32, uimm7>; |
| 2462 | } |
| 2463 | |
| 2464 | defm ROTQBII : RotateQuadByBitCountImm; |
| 2465 | |
| 2466 | //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 2467 | // ROTHM v8i16 form: |
| 2468 | // NOTE(1): No vector rotate is generated by the C/C++ frontend (today), |
| 2469 | // so this only matches a synthetically generated/lowered code |
| 2470 | // fragment. |
| 2471 | // NOTE(2): $rB must be negated before the right rotate! |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 2472 | //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 2473 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 2474 | class ROTHMInst<dag OOL, dag IOL, list<dag> pattern>: |
| 2475 | RRForm<0b10111010000, OOL, IOL, "rothm\t$rT, $rA, $rB", |
| 2476 | RotateShift, pattern>; |
| 2477 | |
| 2478 | def ROTHMv8i16: |
| 2479 | ROTHMInst<(outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB), |
| 2480 | [/* see patterns below - $rB must be negated */]>; |
| 2481 | |
| 2482 | def : Pat<(SPUvec_srl (v8i16 VECREG:$rA), R32C:$rB), |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 2483 | (ROTHMv8i16 VECREG:$rA, (SFIr32 R32C:$rB, 0))>; |
| 2484 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 2485 | def : Pat<(SPUvec_srl (v8i16 VECREG:$rA), R16C:$rB), |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 2486 | (ROTHMv8i16 VECREG:$rA, |
| 2487 | (SFIr32 (XSHWr16 R16C:$rB), 0))>; |
| 2488 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 2489 | def : Pat<(SPUvec_srl (v8i16 VECREG:$rA), R8C:$rB), |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 2490 | (ROTHMv8i16 VECREG:$rA, |
Scott Michel | 438be25 | 2007-12-17 22:32:34 +0000 | [diff] [blame] | 2491 | (SFIr32 (XSHWr16 (XSBHr8 R8C:$rB) ), 0))>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 2492 | |
| 2493 | // ROTHM r16 form: Rotate 16-bit quantity to right, zero fill at the left |
| 2494 | // Note: This instruction doesn't match a pattern because rB must be negated |
| 2495 | // for the instruction to work. Thus, the pattern below the instruction! |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 2496 | |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 2497 | def ROTHMr16: |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 2498 | ROTHMInst<(outs R16C:$rT), (ins R16C:$rA, R32C:$rB), |
| 2499 | [/* see patterns below - $rB must be negated! */]>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 2500 | |
| 2501 | def : Pat<(srl R16C:$rA, R32C:$rB), |
| 2502 | (ROTHMr16 R16C:$rA, (SFIr32 R32C:$rB, 0))>; |
| 2503 | |
| 2504 | def : Pat<(srl R16C:$rA, R16C:$rB), |
| 2505 | (ROTHMr16 R16C:$rA, |
| 2506 | (SFIr32 (XSHWr16 R16C:$rB), 0))>; |
| 2507 | |
Scott Michel | 438be25 | 2007-12-17 22:32:34 +0000 | [diff] [blame] | 2508 | def : Pat<(srl R16C:$rA, R8C:$rB), |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 2509 | (ROTHMr16 R16C:$rA, |
Scott Michel | 438be25 | 2007-12-17 22:32:34 +0000 | [diff] [blame] | 2510 | (SFIr32 (XSHWr16 (XSBHr8 R8C:$rB) ), 0))>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 2511 | |
| 2512 | // ROTHMI v8i16 form: See the comment for ROTHM v8i16. The difference here is |
| 2513 | // that the immediate can be complemented, so that the user doesn't have to |
| 2514 | // worry about it. |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 2515 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 2516 | class ROTHMIInst<dag OOL, dag IOL, list<dag> pattern>: |
| 2517 | RI7Form<0b10111110000, OOL, IOL, "rothmi\t$rT, $rA, $val", |
| 2518 | RotateShift, pattern>; |
| 2519 | |
| 2520 | def ROTHMIv8i16: |
| 2521 | ROTHMIInst<(outs VECREG:$rT), (ins VECREG:$rA, rothNeg7imm:$val), |
| 2522 | [/* no pattern */]>; |
| 2523 | |
| 2524 | def : Pat<(SPUvec_srl (v8i16 VECREG:$rA), (i32 imm:$val)), |
| 2525 | (ROTHMIv8i16 VECREG:$rA, imm:$val)>; |
| 2526 | |
| 2527 | def: Pat<(SPUvec_srl (v8i16 VECREG:$rA), (i16 imm:$val)), |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 2528 | (ROTHMIv8i16 VECREG:$rA, imm:$val)>; |
Scott Michel | 06eabde | 2008-12-27 04:51:36 +0000 | [diff] [blame^] | 2529 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 2530 | def: Pat<(SPUvec_srl (v8i16 VECREG:$rA), (i8 imm:$val)), |
Scott Michel | 5a6f17b | 2008-01-30 02:55:46 +0000 | [diff] [blame] | 2531 | (ROTHMIv8i16 VECREG:$rA, imm:$val)>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 2532 | |
| 2533 | def ROTHMIr16: |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 2534 | ROTHMIInst<(outs R16C:$rT), (ins R16C:$rA, rothNeg7imm:$val), |
| 2535 | [/* no pattern */]>; |
| 2536 | |
| 2537 | def: Pat<(srl R16C:$rA, (i32 uimm7:$val)), |
| 2538 | (ROTHMIr16 R16C:$rA, uimm7:$val)>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 2539 | |
| 2540 | def: Pat<(srl R16C:$rA, (i16 uimm7:$val)), |
| 2541 | (ROTHMIr16 R16C:$rA, uimm7:$val)>; |
| 2542 | |
Scott Michel | 438be25 | 2007-12-17 22:32:34 +0000 | [diff] [blame] | 2543 | def: Pat<(srl R16C:$rA, (i8 uimm7:$val)), |
| 2544 | (ROTHMIr16 R16C:$rA, uimm7:$val)>; |
| 2545 | |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 2546 | // ROTM v4i32 form: See the ROTHM v8i16 comments. |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 2547 | class ROTMInst<dag OOL, dag IOL, list<dag> pattern>: |
| 2548 | RRForm<0b10011010000, OOL, IOL, "rotm\t$rT, $rA, $rB", |
| 2549 | RotateShift, pattern>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 2550 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 2551 | def ROTMv4i32: |
| 2552 | ROTMInst<(outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB), |
| 2553 | [/* see patterns below - $rB must be negated */]>; |
| 2554 | |
| 2555 | def : Pat<(SPUvec_srl VECREG:$rA, R32C:$rB), |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 2556 | (ROTMv4i32 VECREG:$rA, (SFIr32 R32C:$rB, 0))>; |
| 2557 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 2558 | def : Pat<(SPUvec_srl VECREG:$rA, R16C:$rB), |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 2559 | (ROTMv4i32 VECREG:$rA, |
| 2560 | (SFIr32 (XSHWr16 R16C:$rB), 0))>; |
| 2561 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 2562 | def : Pat<(SPUvec_srl VECREG:$rA, R8C:$rB), |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 2563 | (ROTMv4i32 VECREG:$rA, |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 2564 | (SFIr32 (XSHWr16 (XSBHr8 R8C:$rB)), 0))>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 2565 | |
| 2566 | def ROTMr32: |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 2567 | ROTMInst<(outs R32C:$rT), (ins R32C:$rA, R32C:$rB), |
| 2568 | [/* see patterns below - $rB must be negated */]>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 2569 | |
| 2570 | def : Pat<(srl R32C:$rA, R32C:$rB), |
| 2571 | (ROTMr32 R32C:$rA, (SFIr32 R32C:$rB, 0))>; |
| 2572 | |
| 2573 | def : Pat<(srl R32C:$rA, R16C:$rB), |
| 2574 | (ROTMr32 R32C:$rA, |
| 2575 | (SFIr32 (XSHWr16 R16C:$rB), 0))>; |
| 2576 | |
Scott Michel | 438be25 | 2007-12-17 22:32:34 +0000 | [diff] [blame] | 2577 | def : Pat<(srl R32C:$rA, R8C:$rB), |
| 2578 | (ROTMr32 R32C:$rA, |
| 2579 | (SFIr32 (XSHWr16 (XSBHr8 R8C:$rB)), 0))>; |
| 2580 | |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 2581 | // ROTMI v4i32 form: See the comment for ROTHM v8i16. |
| 2582 | def ROTMIv4i32: |
| 2583 | RI7Form<0b10011110000, (outs VECREG:$rT), (ins VECREG:$rA, rotNeg7imm:$val), |
| 2584 | "rotmi\t$rT, $rA, $val", RotateShift, |
| 2585 | [(set (v4i32 VECREG:$rT), |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 2586 | (SPUvec_srl VECREG:$rA, (i32 uimm7:$val)))]>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 2587 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 2588 | def : Pat<(SPUvec_srl VECREG:$rA, (i16 uimm7:$val)), |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 2589 | (ROTMIv4i32 VECREG:$rA, uimm7:$val)>; |
Scott Michel | 06eabde | 2008-12-27 04:51:36 +0000 | [diff] [blame^] | 2590 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 2591 | def : Pat<(SPUvec_srl VECREG:$rA, (i8 uimm7:$val)), |
Scott Michel | 438be25 | 2007-12-17 22:32:34 +0000 | [diff] [blame] | 2592 | (ROTMIv4i32 VECREG:$rA, uimm7:$val)>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 2593 | |
| 2594 | // ROTMI r32 form: know how to complement the immediate value. |
| 2595 | def ROTMIr32: |
| 2596 | RI7Form<0b10011110000, (outs R32C:$rT), (ins R32C:$rA, rotNeg7imm:$val), |
| 2597 | "rotmi\t$rT, $rA, $val", RotateShift, |
| 2598 | [(set R32C:$rT, (srl R32C:$rA, (i32 uimm7:$val)))]>; |
| 2599 | |
| 2600 | def : Pat<(srl R32C:$rA, (i16 imm:$val)), |
| 2601 | (ROTMIr32 R32C:$rA, uimm7:$val)>; |
| 2602 | |
Scott Michel | 438be25 | 2007-12-17 22:32:34 +0000 | [diff] [blame] | 2603 | def : Pat<(srl R32C:$rA, (i8 imm:$val)), |
| 2604 | (ROTMIr32 R32C:$rA, uimm7:$val)>; |
| 2605 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 2606 | //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 2607 | // ROTQMBYvec: This is a vector form merely so that when used in an |
| 2608 | // instruction pattern, type checking will succeed. This instruction assumes |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 2609 | // that the user knew to negate $rB. |
| 2610 | // |
| 2611 | // Using the SPUrotquad_rz_bytes target-specific DAG node, the patterns |
| 2612 | // ensure that $rB is negated. |
| 2613 | //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 2614 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 2615 | class ROTQMBYInst<dag OOL, dag IOL, list<dag> pattern>: |
| 2616 | RRForm<0b10111011100, OOL, IOL, "rotqmby\t$rT, $rA, $rB", |
| 2617 | RotateShift, pattern>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 2618 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 2619 | class ROTQMBYVecInst<ValueType vectype>: |
| 2620 | ROTQMBYInst<(outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB), |
| 2621 | [/* no pattern, $rB must be negated */]>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 2622 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 2623 | class ROTQMBYRegInst<RegisterClass rclass>: |
| 2624 | ROTQMBYInst<(outs rclass:$rT), (ins rclass:$rA, R32C:$rB), |
| 2625 | [(set rclass:$rT, |
| 2626 | (SPUrotquad_rz_bytes rclass:$rA, R32C:$rB))]>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 2627 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 2628 | multiclass RotateQuadBytes |
| 2629 | { |
| 2630 | def v16i8: ROTQMBYVecInst<v16i8>; |
| 2631 | def v8i16: ROTQMBYVecInst<v8i16>; |
| 2632 | def v4i32: ROTQMBYVecInst<v4i32>; |
| 2633 | def v2i64: ROTQMBYVecInst<v2i64>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 2634 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 2635 | def r128: ROTQMBYRegInst<GPRC>; |
| 2636 | def r64: ROTQMBYRegInst<R64C>; |
| 2637 | } |
| 2638 | |
| 2639 | defm ROTQMBY : RotateQuadBytes; |
| 2640 | |
| 2641 | def : Pat<(SPUrotquad_rz_bytes (v16i8 VECREG:$rA), R32C:$rB), |
| 2642 | (ROTQMBYv16i8 VECREG:$rA, (SFIr32 R32C:$rB, 0))>; |
| 2643 | def : Pat<(SPUrotquad_rz_bytes (v8i16 VECREG:$rA), R32C:$rB), |
| 2644 | (ROTQMBYv8i16 VECREG:$rA, (SFIr32 R32C:$rB, 0))>; |
| 2645 | def : Pat<(SPUrotquad_rz_bytes (v4i32 VECREG:$rA), R32C:$rB), |
| 2646 | (ROTQMBYv4i32 VECREG:$rA, (SFIr32 R32C:$rB, 0))>; |
| 2647 | def : Pat<(SPUrotquad_rz_bytes (v2i64 VECREG:$rA), R32C:$rB), |
| 2648 | (ROTQMBYv2i64 VECREG:$rA, (SFIr32 R32C:$rB, 0))>; |
| 2649 | def : Pat<(SPUrotquad_rz_bytes GPRC:$rA, R32C:$rB), |
| 2650 | (ROTQMBYr128 GPRC:$rA, (SFIr32 R32C:$rB, 0))>; |
| 2651 | def : Pat<(SPUrotquad_rz_bytes R64C:$rA, R32C:$rB), |
| 2652 | (ROTQMBYr64 R64C:$rA, (SFIr32 R32C:$rB, 0))>; |
| 2653 | |
| 2654 | class ROTQMBYIInst<dag OOL, dag IOL, list<dag> pattern>: |
| 2655 | RI7Form<0b10111111100, OOL, IOL, "rotqmbyi\t$rT, $rA, $val", |
| 2656 | RotateShift, pattern>; |
| 2657 | |
| 2658 | class ROTQMBYIVecInst<ValueType vectype>: |
| 2659 | ROTQMBYIInst<(outs VECREG:$rT), (ins VECREG:$rA, rotNeg7imm:$val), |
| 2660 | [(set (vectype VECREG:$rT), |
| 2661 | (SPUrotquad_rz_bytes (vectype VECREG:$rA), (i32 uimm7:$val)))]>; |
| 2662 | |
| 2663 | class ROTQMBYIRegInst<RegisterClass rclass, Operand optype, ValueType inttype, PatLeaf pred>: |
| 2664 | ROTQMBYIInst<(outs rclass:$rT), (ins rclass:$rA, optype:$val), |
| 2665 | [(set rclass:$rT, |
| 2666 | (SPUrotquad_rz_bytes rclass:$rA, (inttype pred:$val)))]>; |
| 2667 | |
| 2668 | multiclass RotateQuadBytesImm |
| 2669 | { |
| 2670 | def v16i8: ROTQMBYIVecInst<v16i8>; |
| 2671 | def v8i16: ROTQMBYIVecInst<v8i16>; |
| 2672 | def v4i32: ROTQMBYIVecInst<v4i32>; |
| 2673 | def v2i64: ROTQMBYIVecInst<v2i64>; |
| 2674 | |
| 2675 | def r128: ROTQMBYIRegInst<GPRC, rotNeg7imm, i32, uimm7>; |
| 2676 | def r64: ROTQMBYIRegInst<R64C, rotNeg7imm, i32, uimm7>; |
| 2677 | } |
| 2678 | |
| 2679 | defm ROTQMBYI : RotateQuadBytesImm; |
| 2680 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 2681 | //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ |
| 2682 | // Rotate right and mask by bit count |
| 2683 | //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ |
| 2684 | |
| 2685 | class ROTQMBYBIInst<dag OOL, dag IOL, list<dag> pattern>: |
| 2686 | RRForm<0b10110011100, OOL, IOL, "rotqmbybi\t$rT, $rA, $rB", |
| 2687 | RotateShift, pattern>; |
| 2688 | |
| 2689 | class ROTQMBYBIVecInst<ValueType vectype>: |
| 2690 | ROTQMBYBIInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB), |
| 2691 | [/* no pattern, intrinsic? */]>; |
| 2692 | |
| 2693 | multiclass RotateMaskQuadByBitCount |
| 2694 | { |
| 2695 | def v16i8: ROTQMBYBIVecInst<v16i8>; |
| 2696 | def v8i16: ROTQMBYBIVecInst<v8i16>; |
| 2697 | def v4i32: ROTQMBYBIVecInst<v4i32>; |
| 2698 | def v2i64: ROTQMBYBIVecInst<v2i64>; |
| 2699 | } |
| 2700 | |
| 2701 | defm ROTQMBYBI: RotateMaskQuadByBitCount; |
| 2702 | |
| 2703 | //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ |
| 2704 | // Rotate quad and mask by bits |
| 2705 | // Note that the rotate amount has to be negated |
| 2706 | //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ |
| 2707 | |
| 2708 | class ROTQMBIInst<dag OOL, dag IOL, list<dag> pattern>: |
| 2709 | RRForm<0b10011011100, OOL, IOL, "rotqmbi\t$rT, $rA, $rB", |
| 2710 | RotateShift, pattern>; |
| 2711 | |
| 2712 | class ROTQMBIVecInst<ValueType vectype>: |
| 2713 | ROTQMBIInst<(outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB), |
| 2714 | [/* no pattern */]>; |
| 2715 | |
| 2716 | class ROTQMBIRegInst<RegisterClass rclass>: |
| 2717 | ROTQMBIInst<(outs rclass:$rT), (ins rclass:$rA, R32C:$rB), |
| 2718 | [/* no pattern */]>; |
| 2719 | |
| 2720 | multiclass RotateMaskQuadByBits |
| 2721 | { |
| 2722 | def v16i8: ROTQMBIVecInst<v16i8>; |
| 2723 | def v8i16: ROTQMBIVecInst<v8i16>; |
| 2724 | def v4i32: ROTQMBIVecInst<v4i32>; |
| 2725 | def v2i64: ROTQMBIVecInst<v2i64>; |
| 2726 | |
| 2727 | def r128: ROTQMBIRegInst<GPRC>; |
| 2728 | def r64: ROTQMBIRegInst<R64C>; |
| 2729 | } |
| 2730 | |
| 2731 | defm ROTQMBI: RotateMaskQuadByBits; |
| 2732 | |
| 2733 | def : Pat<(SPUrotquad_rz_bits (v16i8 VECREG:$rA), R32C:$rB), |
| 2734 | (ROTQMBIv16i8 VECREG:$rA, (SFIr32 R32C:$rB, 0))>; |
| 2735 | def : Pat<(SPUrotquad_rz_bits (v8i16 VECREG:$rA), R32C:$rB), |
| 2736 | (ROTQMBIv8i16 VECREG:$rA, (SFIr32 R32C:$rB, 0))>; |
| 2737 | def : Pat<(SPUrotquad_rz_bits (v4i32 VECREG:$rA), R32C:$rB), |
| 2738 | (ROTQMBIv4i32 VECREG:$rA, (SFIr32 R32C:$rB, 0))>; |
| 2739 | def : Pat<(SPUrotquad_rz_bits (v2i64 VECREG:$rA), R32C:$rB), |
| 2740 | (ROTQMBIv2i64 VECREG:$rA, (SFIr32 R32C:$rB, 0))>; |
| 2741 | def : Pat<(SPUrotquad_rz_bits GPRC:$rA, R32C:$rB), |
| 2742 | (ROTQMBIr128 GPRC:$rA, (SFIr32 R32C:$rB, 0))>; |
| 2743 | def : Pat<(SPUrotquad_rz_bits R64C:$rA, R32C:$rB), |
| 2744 | (ROTQMBIr64 R64C:$rA, (SFIr32 R32C:$rB, 0))>; |
| 2745 | |
| 2746 | //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ |
| 2747 | // Rotate quad and mask by bits, immediate |
| 2748 | //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ |
| 2749 | |
| 2750 | class ROTQMBIIInst<dag OOL, dag IOL, list<dag> pattern>: |
| 2751 | RI7Form<0b10011111100, OOL, IOL, "rotqmbii\t$rT, $rA, $val", |
| 2752 | RotateShift, pattern>; |
| 2753 | |
| 2754 | class ROTQMBIIVecInst<ValueType vectype>: |
| 2755 | ROTQMBIIInst<(outs VECREG:$rT), (ins VECREG:$rA, rotNeg7imm:$val), |
| 2756 | [(set (vectype VECREG:$rT), |
| 2757 | (SPUrotquad_rz_bits (vectype VECREG:$rA), (i32 uimm7:$val)))]>; |
| 2758 | |
| 2759 | class ROTQMBIIRegInst<RegisterClass rclass>: |
| 2760 | ROTQMBIIInst<(outs rclass:$rT), (ins rclass:$rA, rotNeg7imm:$val), |
| 2761 | [(set rclass:$rT, |
| 2762 | (SPUrotquad_rz_bits rclass:$rA, (i32 uimm7:$val)))]>; |
| 2763 | |
| 2764 | multiclass RotateMaskQuadByBitsImm |
| 2765 | { |
| 2766 | def v16i8: ROTQMBIIVecInst<v16i8>; |
| 2767 | def v8i16: ROTQMBIIVecInst<v8i16>; |
| 2768 | def v4i32: ROTQMBIIVecInst<v4i32>; |
| 2769 | def v2i64: ROTQMBIIVecInst<v2i64>; |
| 2770 | |
| 2771 | def r128: ROTQMBIIRegInst<GPRC>; |
| 2772 | def r64: ROTQMBIIRegInst<R64C>; |
| 2773 | } |
| 2774 | |
| 2775 | defm ROTQMBII: RotateMaskQuadByBitsImm; |
| 2776 | |
| 2777 | //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ |
| 2778 | //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 2779 | |
| 2780 | def ROTMAHv8i16: |
| 2781 | RRForm<0b01111010000, (outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB), |
| 2782 | "rotmah\t$rT, $rA, $rB", RotateShift, |
| 2783 | [/* see patterns below - $rB must be negated */]>; |
| 2784 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 2785 | def : Pat<(SPUvec_sra VECREG:$rA, R32C:$rB), |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 2786 | (ROTMAHv8i16 VECREG:$rA, (SFIr32 R32C:$rB, 0))>; |
| 2787 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 2788 | def : Pat<(SPUvec_sra VECREG:$rA, R16C:$rB), |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 2789 | (ROTMAHv8i16 VECREG:$rA, |
| 2790 | (SFIr32 (XSHWr16 R16C:$rB), 0))>; |
| 2791 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 2792 | def : Pat<(SPUvec_sra VECREG:$rA, R8C:$rB), |
Scott Michel | 438be25 | 2007-12-17 22:32:34 +0000 | [diff] [blame] | 2793 | (ROTMAHv8i16 VECREG:$rA, |
| 2794 | (SFIr32 (XSHWr16 (XSBHr8 R8C:$rB)), 0))>; |
| 2795 | |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 2796 | def ROTMAHr16: |
| 2797 | RRForm<0b01111010000, (outs R16C:$rT), (ins R16C:$rA, R32C:$rB), |
| 2798 | "rotmah\t$rT, $rA, $rB", RotateShift, |
| 2799 | [/* see patterns below - $rB must be negated */]>; |
| 2800 | |
| 2801 | def : Pat<(sra R16C:$rA, R32C:$rB), |
| 2802 | (ROTMAHr16 R16C:$rA, (SFIr32 R32C:$rB, 0))>; |
| 2803 | |
| 2804 | def : Pat<(sra R16C:$rA, R16C:$rB), |
| 2805 | (ROTMAHr16 R16C:$rA, |
| 2806 | (SFIr32 (XSHWr16 R16C:$rB), 0))>; |
| 2807 | |
Scott Michel | 438be25 | 2007-12-17 22:32:34 +0000 | [diff] [blame] | 2808 | def : Pat<(sra R16C:$rA, R8C:$rB), |
| 2809 | (ROTMAHr16 R16C:$rA, |
| 2810 | (SFIr32 (XSHWr16 (XSBHr8 R8C:$rB)), 0))>; |
| 2811 | |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 2812 | def ROTMAHIv8i16: |
| 2813 | RRForm<0b01111110000, (outs VECREG:$rT), (ins VECREG:$rA, rothNeg7imm:$val), |
| 2814 | "rotmahi\t$rT, $rA, $val", RotateShift, |
| 2815 | [(set (v8i16 VECREG:$rT), |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 2816 | (SPUvec_sra (v8i16 VECREG:$rA), (i32 uimm7:$val)))]>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 2817 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 2818 | def : Pat<(SPUvec_sra (v8i16 VECREG:$rA), (i16 uimm7:$val)), |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 2819 | (ROTMAHIv8i16 (v8i16 VECREG:$rA), (i32 uimm7:$val))>; |
| 2820 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 2821 | def : Pat<(SPUvec_sra (v8i16 VECREG:$rA), (i8 uimm7:$val)), |
Scott Michel | 438be25 | 2007-12-17 22:32:34 +0000 | [diff] [blame] | 2822 | (ROTMAHIv8i16 (v8i16 VECREG:$rA), (i32 uimm7:$val))>; |
| 2823 | |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 2824 | def ROTMAHIr16: |
| 2825 | RRForm<0b01111110000, (outs R16C:$rT), (ins R16C:$rA, rothNeg7imm_i16:$val), |
| 2826 | "rotmahi\t$rT, $rA, $val", RotateShift, |
| 2827 | [(set R16C:$rT, (sra R16C:$rA, (i16 uimm7:$val)))]>; |
| 2828 | |
| 2829 | def : Pat<(sra R16C:$rA, (i32 imm:$val)), |
| 2830 | (ROTMAHIr16 R16C:$rA, uimm7:$val)>; |
| 2831 | |
Scott Michel | 438be25 | 2007-12-17 22:32:34 +0000 | [diff] [blame] | 2832 | def : Pat<(sra R16C:$rA, (i8 imm:$val)), |
| 2833 | (ROTMAHIr16 R16C:$rA, uimm7:$val)>; |
| 2834 | |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 2835 | def ROTMAv4i32: |
| 2836 | RRForm<0b01011010000, (outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB), |
| 2837 | "rotma\t$rT, $rA, $rB", RotateShift, |
| 2838 | [/* see patterns below - $rB must be negated */]>; |
| 2839 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 2840 | def : Pat<(SPUvec_sra VECREG:$rA, R32C:$rB), |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 2841 | (ROTMAv4i32 (v4i32 VECREG:$rA), (SFIr32 R32C:$rB, 0))>; |
| 2842 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 2843 | def : Pat<(SPUvec_sra VECREG:$rA, R16C:$rB), |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 2844 | (ROTMAv4i32 (v4i32 VECREG:$rA), |
| 2845 | (SFIr32 (XSHWr16 R16C:$rB), 0))>; |
| 2846 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 2847 | def : Pat<(SPUvec_sra VECREG:$rA, R8C:$rB), |
Scott Michel | 438be25 | 2007-12-17 22:32:34 +0000 | [diff] [blame] | 2848 | (ROTMAv4i32 (v4i32 VECREG:$rA), |
| 2849 | (SFIr32 (XSHWr16 (XSBHr8 R8C:$rB)), 0))>; |
| 2850 | |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 2851 | def ROTMAr32: |
| 2852 | RRForm<0b01011010000, (outs R32C:$rT), (ins R32C:$rA, R32C:$rB), |
| 2853 | "rotma\t$rT, $rA, $rB", RotateShift, |
| 2854 | [/* see patterns below - $rB must be negated */]>; |
| 2855 | |
| 2856 | def : Pat<(sra R32C:$rA, R32C:$rB), |
| 2857 | (ROTMAr32 R32C:$rA, (SFIr32 R32C:$rB, 0))>; |
| 2858 | |
| 2859 | def : Pat<(sra R32C:$rA, R16C:$rB), |
| 2860 | (ROTMAr32 R32C:$rA, |
| 2861 | (SFIr32 (XSHWr16 R16C:$rB), 0))>; |
| 2862 | |
Scott Michel | 438be25 | 2007-12-17 22:32:34 +0000 | [diff] [blame] | 2863 | def : Pat<(sra R32C:$rA, R8C:$rB), |
| 2864 | (ROTMAr32 R32C:$rA, |
| 2865 | (SFIr32 (XSHWr16 (XSBHr8 R8C:$rB)), 0))>; |
| 2866 | |
Scott Michel | 67224b2 | 2008-06-02 22:18:03 +0000 | [diff] [blame] | 2867 | class ROTMAIInst<dag OOL, dag IOL, list<dag> pattern>: |
| 2868 | RRForm<0b01011110000, OOL, IOL, |
| 2869 | "rotmai\t$rT, $rA, $val", |
| 2870 | RotateShift, pattern>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 2871 | |
Scott Michel | 67224b2 | 2008-06-02 22:18:03 +0000 | [diff] [blame] | 2872 | class ROTMAIVecInst<ValueType vectype, Operand intop, ValueType inttype>: |
| 2873 | ROTMAIInst<(outs VECREG:$rT), (ins VECREG:$rA, intop:$val), |
| 2874 | [(set (vectype VECREG:$rT), |
| 2875 | (SPUvec_sra VECREG:$rA, (inttype uimm7:$val)))]>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 2876 | |
Scott Michel | 67224b2 | 2008-06-02 22:18:03 +0000 | [diff] [blame] | 2877 | class ROTMAIRegInst<RegisterClass rclass, Operand intop, ValueType inttype>: |
| 2878 | ROTMAIInst<(outs rclass:$rT), (ins rclass:$rA, intop:$val), |
| 2879 | [(set rclass:$rT, (sra rclass:$rA, (inttype uimm7:$val)))]>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 2880 | |
Scott Michel | 67224b2 | 2008-06-02 22:18:03 +0000 | [diff] [blame] | 2881 | multiclass RotateMaskAlgebraicImm { |
| 2882 | def v2i64_i32 : ROTMAIVecInst<v2i64, rotNeg7imm, i32>; |
| 2883 | def v4i32_i32 : ROTMAIVecInst<v4i32, rotNeg7imm, i32>; |
| 2884 | def r64_i32 : ROTMAIRegInst<R64C, rotNeg7imm, i32>; |
| 2885 | def r32_i32 : ROTMAIRegInst<R32C, rotNeg7imm, i32>; |
| 2886 | } |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 2887 | |
Scott Michel | 67224b2 | 2008-06-02 22:18:03 +0000 | [diff] [blame] | 2888 | defm ROTMAI : RotateMaskAlgebraicImm; |
Scott Michel | 438be25 | 2007-12-17 22:32:34 +0000 | [diff] [blame] | 2889 | |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 2890 | //===----------------------------------------------------------------------===// |
| 2891 | // Branch and conditionals: |
| 2892 | //===----------------------------------------------------------------------===// |
| 2893 | |
| 2894 | let isTerminator = 1, isBarrier = 1 in { |
| 2895 | // Halt If Equal (r32 preferred slot only, no vector form) |
| 2896 | def HEQr32: |
| 2897 | RRForm_3<0b00011011110, (outs), (ins R32C:$rA, R32C:$rB), |
| 2898 | "heq\t$rA, $rB", BranchResolv, |
| 2899 | [/* no pattern to match */]>; |
| 2900 | |
| 2901 | def HEQIr32 : |
| 2902 | RI10Form_2<0b11111110, (outs), (ins R32C:$rA, s10imm:$val), |
| 2903 | "heqi\t$rA, $val", BranchResolv, |
| 2904 | [/* no pattern to match */]>; |
| 2905 | |
| 2906 | // HGT/HGTI: These instructions use signed arithmetic for the comparison, |
| 2907 | // contrasting with HLGT/HLGTI, which use unsigned comparison: |
| 2908 | def HGTr32: |
| 2909 | RRForm_3<0b00011010010, (outs), (ins R32C:$rA, R32C:$rB), |
| 2910 | "hgt\t$rA, $rB", BranchResolv, |
| 2911 | [/* no pattern to match */]>; |
| 2912 | |
Scott Michel | 06eabde | 2008-12-27 04:51:36 +0000 | [diff] [blame^] | 2913 | def HGTIr32: |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 2914 | RI10Form_2<0b11110010, (outs), (ins R32C:$rA, s10imm:$val), |
| 2915 | "hgti\t$rA, $val", BranchResolv, |
| 2916 | [/* no pattern to match */]>; |
| 2917 | |
| 2918 | def HLGTr32: |
| 2919 | RRForm_3<0b00011011010, (outs), (ins R32C:$rA, R32C:$rB), |
| 2920 | "hlgt\t$rA, $rB", BranchResolv, |
| 2921 | [/* no pattern to match */]>; |
| 2922 | |
| 2923 | def HLGTIr32: |
| 2924 | RI10Form_2<0b11111010, (outs), (ins R32C:$rA, s10imm:$val), |
| 2925 | "hlgti\t$rA, $val", BranchResolv, |
| 2926 | [/* no pattern to match */]>; |
| 2927 | } |
| 2928 | |
Scott Michel | 06eabde | 2008-12-27 04:51:36 +0000 | [diff] [blame^] | 2929 | //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ |
| 2930 | // Comparison operators for i8, i16 and i32: |
| 2931 | //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 2932 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 2933 | class CEQBInst<dag OOL, dag IOL, list<dag> pattern> : |
| 2934 | RRForm<0b00001011110, OOL, IOL, "ceqb\t$rT, $rA, $rB", |
| 2935 | ByteOp, pattern>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 2936 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 2937 | multiclass CmpEqualByte |
| 2938 | { |
| 2939 | def v16i8 : |
| 2940 | CEQBInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB), |
| 2941 | [(set (v16i8 VECREG:$rT), (seteq (v8i16 VECREG:$rA), |
| 2942 | (v8i16 VECREG:$rB)))]>; |
Scott Michel | 438be25 | 2007-12-17 22:32:34 +0000 | [diff] [blame] | 2943 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 2944 | def r8 : |
| 2945 | CEQBInst<(outs R8C:$rT), (ins R8C:$rA, R8C:$rB), |
| 2946 | [(set R8C:$rT, (seteq R8C:$rA, R8C:$rB))]>; |
| 2947 | } |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 2948 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 2949 | class CEQBIInst<dag OOL, dag IOL, list<dag> pattern> : |
| 2950 | RI10Form<0b01111110, OOL, IOL, "ceqbi\t$rT, $rA, $val", |
| 2951 | ByteOp, pattern>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 2952 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 2953 | multiclass CmpEqualByteImm |
| 2954 | { |
| 2955 | def v16i8 : |
| 2956 | CEQBIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm_i8:$val), |
| 2957 | [(set (v16i8 VECREG:$rT), (seteq (v16i8 VECREG:$rA), |
| 2958 | v16i8SExt8Imm:$val))]>; |
| 2959 | def r8: |
| 2960 | CEQBIInst<(outs R8C:$rT), (ins R8C:$rA, s10imm_i8:$val), |
| 2961 | [(set R8C:$rT, (seteq R8C:$rA, immSExt8:$val))]>; |
| 2962 | } |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 2963 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 2964 | class CEQHInst<dag OOL, dag IOL, list<dag> pattern> : |
| 2965 | RRForm<0b00010011110, OOL, IOL, "ceqh\t$rT, $rA, $rB", |
| 2966 | ByteOp, pattern>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 2967 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 2968 | multiclass CmpEqualHalfword |
| 2969 | { |
| 2970 | def v8i16 : CEQHInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB), |
| 2971 | [(set (v8i16 VECREG:$rT), (seteq (v8i16 VECREG:$rA), |
| 2972 | (v8i16 VECREG:$rB)))]>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 2973 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 2974 | def r16 : CEQHInst<(outs R16C:$rT), (ins R16C:$rA, R16C:$rB), |
| 2975 | [(set R16C:$rT, (seteq R16C:$rA, R16C:$rB))]>; |
| 2976 | } |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 2977 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 2978 | class CEQHIInst<dag OOL, dag IOL, list<dag> pattern> : |
| 2979 | RI10Form<0b10111110, OOL, IOL, "ceqhi\t$rT, $rA, $val", |
| 2980 | ByteOp, pattern>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 2981 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 2982 | multiclass CmpEqualHalfwordImm |
| 2983 | { |
| 2984 | def v8i16 : CEQHIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val), |
| 2985 | [(set (v8i16 VECREG:$rT), |
| 2986 | (seteq (v8i16 VECREG:$rA), |
| 2987 | (v8i16 v8i16SExt10Imm:$val)))]>; |
| 2988 | def r16 : CEQHIInst<(outs R16C:$rT), (ins R16C:$rA, s10imm:$val), |
| 2989 | [(set R16C:$rT, (seteq R16C:$rA, i16ImmSExt10:$val))]>; |
| 2990 | } |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 2991 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 2992 | class CEQInst<dag OOL, dag IOL, list<dag> pattern> : |
| 2993 | RRForm<0b00000011110, OOL, IOL, "ceq\t$rT, $rA, $rB", |
| 2994 | ByteOp, pattern>; |
| 2995 | |
| 2996 | multiclass CmpEqualWord |
| 2997 | { |
| 2998 | def v4i32 : CEQInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB), |
| 2999 | [(set (v4i32 VECREG:$rT), |
| 3000 | (seteq (v4i32 VECREG:$rA), (v4i32 VECREG:$rB)))]>; |
| 3001 | |
| 3002 | def r32 : CEQInst<(outs R32C:$rT), (ins R32C:$rA, R32C:$rB), |
| 3003 | [(set R32C:$rT, (seteq R32C:$rA, R32C:$rB))]>; |
| 3004 | } |
| 3005 | |
| 3006 | class CEQIInst<dag OOL, dag IOL, list<dag> pattern> : |
| 3007 | RI10Form<0b00111110, OOL, IOL, "ceqi\t$rT, $rA, $val", |
| 3008 | ByteOp, pattern>; |
| 3009 | |
| 3010 | multiclass CmpEqualWordImm |
| 3011 | { |
| 3012 | def v4i32 : CEQIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val), |
| 3013 | [(set (v4i32 VECREG:$rT), |
| 3014 | (seteq (v4i32 VECREG:$rA), |
| 3015 | (v4i32 v4i32SExt16Imm:$val)))]>; |
| 3016 | |
| 3017 | def r32: CEQIInst<(outs R32C:$rT), (ins R32C:$rA, s10imm_i32:$val), |
| 3018 | [(set R32C:$rT, (seteq R32C:$rA, i32ImmSExt10:$val))]>; |
| 3019 | } |
| 3020 | |
| 3021 | class CGTBInst<dag OOL, dag IOL, list<dag> pattern> : |
| 3022 | RRForm<0b00001010010, OOL, IOL, "cgtb\t$rT, $rA, $rB", |
| 3023 | ByteOp, pattern>; |
| 3024 | |
| 3025 | multiclass CmpGtrByte |
| 3026 | { |
| 3027 | def v16i8 : |
| 3028 | CGTBInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB), |
| 3029 | [(set (v16i8 VECREG:$rT), (setgt (v8i16 VECREG:$rA), |
| 3030 | (v8i16 VECREG:$rB)))]>; |
| 3031 | |
| 3032 | def r8 : |
| 3033 | CGTBInst<(outs R8C:$rT), (ins R8C:$rA, R8C:$rB), |
| 3034 | [(set R8C:$rT, (setgt R8C:$rA, R8C:$rB))]>; |
| 3035 | } |
| 3036 | |
| 3037 | class CGTBIInst<dag OOL, dag IOL, list<dag> pattern> : |
| 3038 | RI10Form<0b01110010, OOL, IOL, "cgtbi\t$rT, $rA, $val", |
| 3039 | ByteOp, pattern>; |
| 3040 | |
| 3041 | multiclass CmpGtrByteImm |
| 3042 | { |
| 3043 | def v16i8 : |
| 3044 | CGTBIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm_i8:$val), |
| 3045 | [(set (v16i8 VECREG:$rT), (setgt (v16i8 VECREG:$rA), |
| 3046 | v16i8SExt8Imm:$val))]>; |
| 3047 | def r8: |
| 3048 | CGTBIInst<(outs R8C:$rT), (ins R8C:$rA, s10imm_i8:$val), |
Scott Michel | 7833d47 | 2008-03-20 00:51:36 +0000 | [diff] [blame] | 3049 | [(set R8C:$rT, (setgt R8C:$rA, immSExt8:$val))]>; |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 3050 | } |
| 3051 | |
| 3052 | class CGTHInst<dag OOL, dag IOL, list<dag> pattern> : |
| 3053 | RRForm<0b00010010010, OOL, IOL, "cgth\t$rT, $rA, $rB", |
| 3054 | ByteOp, pattern>; |
| 3055 | |
| 3056 | multiclass CmpGtrHalfword |
| 3057 | { |
| 3058 | def v8i16 : CGTHInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB), |
| 3059 | [(set (v8i16 VECREG:$rT), (setgt (v8i16 VECREG:$rA), |
| 3060 | (v8i16 VECREG:$rB)))]>; |
| 3061 | |
| 3062 | def r16 : CGTHInst<(outs R16C:$rT), (ins R16C:$rA, R16C:$rB), |
| 3063 | [(set R16C:$rT, (setgt R16C:$rA, R16C:$rB))]>; |
| 3064 | } |
| 3065 | |
| 3066 | class CGTHIInst<dag OOL, dag IOL, list<dag> pattern> : |
| 3067 | RI10Form<0b10110010, OOL, IOL, "cgthi\t$rT, $rA, $val", |
| 3068 | ByteOp, pattern>; |
| 3069 | |
| 3070 | multiclass CmpGtrHalfwordImm |
| 3071 | { |
| 3072 | def v8i16 : CGTHIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val), |
| 3073 | [(set (v8i16 VECREG:$rT), |
| 3074 | (setgt (v8i16 VECREG:$rA), |
| 3075 | (v8i16 v8i16SExt10Imm:$val)))]>; |
| 3076 | def r16 : CGTHIInst<(outs R16C:$rT), (ins R16C:$rA, s10imm:$val), |
| 3077 | [(set R16C:$rT, (setgt R16C:$rA, i16ImmSExt10:$val))]>; |
| 3078 | } |
| 3079 | |
| 3080 | class CGTInst<dag OOL, dag IOL, list<dag> pattern> : |
| 3081 | RRForm<0b00000010010, OOL, IOL, "cgt\t$rT, $rA, $rB", |
| 3082 | ByteOp, pattern>; |
| 3083 | |
| 3084 | multiclass CmpGtrWord |
| 3085 | { |
| 3086 | def v4i32 : CGTInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB), |
| 3087 | [(set (v4i32 VECREG:$rT), |
| 3088 | (setgt (v4i32 VECREG:$rA), (v4i32 VECREG:$rB)))]>; |
| 3089 | |
| 3090 | def r32 : CGTInst<(outs R32C:$rT), (ins R32C:$rA, R32C:$rB), |
| 3091 | [(set R32C:$rT, (setgt R32C:$rA, R32C:$rB))]>; |
| 3092 | } |
| 3093 | |
| 3094 | class CGTIInst<dag OOL, dag IOL, list<dag> pattern> : |
| 3095 | RI10Form<0b00110010, OOL, IOL, "cgti\t$rT, $rA, $val", |
| 3096 | ByteOp, pattern>; |
| 3097 | |
| 3098 | multiclass CmpGtrWordImm |
| 3099 | { |
| 3100 | def v4i32 : CGTIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val), |
| 3101 | [(set (v4i32 VECREG:$rT), |
| 3102 | (setgt (v4i32 VECREG:$rA), |
| 3103 | (v4i32 v4i32SExt16Imm:$val)))]>; |
| 3104 | |
| 3105 | def r32: CGTIInst<(outs R32C:$rT), (ins R32C:$rA, s10imm_i32:$val), |
| 3106 | [(set R32C:$rT, (setgt R32C:$rA, i32ImmSExt10:$val))]>; |
| 3107 | } |
| 3108 | |
| 3109 | class CLGTBInst<dag OOL, dag IOL, list<dag> pattern> : |
Scott Michel | 6baba07 | 2008-03-05 23:02:02 +0000 | [diff] [blame] | 3110 | RRForm<0b00001011010, OOL, IOL, "clgtb\t$rT, $rA, $rB", |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 3111 | ByteOp, pattern>; |
| 3112 | |
| 3113 | multiclass CmpLGtrByte |
| 3114 | { |
| 3115 | def v16i8 : |
| 3116 | CLGTBInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB), |
| 3117 | [(set (v16i8 VECREG:$rT), (setugt (v8i16 VECREG:$rA), |
| 3118 | (v8i16 VECREG:$rB)))]>; |
| 3119 | |
| 3120 | def r8 : |
| 3121 | CLGTBInst<(outs R8C:$rT), (ins R8C:$rA, R8C:$rB), |
| 3122 | [(set R8C:$rT, (setugt R8C:$rA, R8C:$rB))]>; |
| 3123 | } |
| 3124 | |
| 3125 | class CLGTBIInst<dag OOL, dag IOL, list<dag> pattern> : |
Scott Michel | 6baba07 | 2008-03-05 23:02:02 +0000 | [diff] [blame] | 3126 | RI10Form<0b01111010, OOL, IOL, "clgtbi\t$rT, $rA, $val", |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 3127 | ByteOp, pattern>; |
| 3128 | |
| 3129 | multiclass CmpLGtrByteImm |
| 3130 | { |
| 3131 | def v16i8 : |
| 3132 | CLGTBIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm_i8:$val), |
| 3133 | [(set (v16i8 VECREG:$rT), (setugt (v16i8 VECREG:$rA), |
| 3134 | v16i8SExt8Imm:$val))]>; |
| 3135 | def r8: |
| 3136 | CLGTBIInst<(outs R8C:$rT), (ins R8C:$rA, s10imm_i8:$val), |
| 3137 | [(set R8C:$rT, (setugt R8C:$rA, immSExt8:$val))]>; |
| 3138 | } |
| 3139 | |
| 3140 | class CLGTHInst<dag OOL, dag IOL, list<dag> pattern> : |
Scott Michel | 6baba07 | 2008-03-05 23:02:02 +0000 | [diff] [blame] | 3141 | RRForm<0b00010011010, OOL, IOL, "clgth\t$rT, $rA, $rB", |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 3142 | ByteOp, pattern>; |
| 3143 | |
| 3144 | multiclass CmpLGtrHalfword |
| 3145 | { |
| 3146 | def v8i16 : CLGTHInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB), |
| 3147 | [(set (v8i16 VECREG:$rT), (setugt (v8i16 VECREG:$rA), |
| 3148 | (v8i16 VECREG:$rB)))]>; |
| 3149 | |
| 3150 | def r16 : CLGTHInst<(outs R16C:$rT), (ins R16C:$rA, R16C:$rB), |
| 3151 | [(set R16C:$rT, (setugt R16C:$rA, R16C:$rB))]>; |
| 3152 | } |
| 3153 | |
| 3154 | class CLGTHIInst<dag OOL, dag IOL, list<dag> pattern> : |
Scott Michel | 6baba07 | 2008-03-05 23:02:02 +0000 | [diff] [blame] | 3155 | RI10Form<0b10111010, OOL, IOL, "clgthi\t$rT, $rA, $val", |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 3156 | ByteOp, pattern>; |
| 3157 | |
| 3158 | multiclass CmpLGtrHalfwordImm |
| 3159 | { |
| 3160 | def v8i16 : CLGTHIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val), |
| 3161 | [(set (v8i16 VECREG:$rT), |
| 3162 | (setugt (v8i16 VECREG:$rA), |
| 3163 | (v8i16 v8i16SExt10Imm:$val)))]>; |
| 3164 | def r16 : CLGTHIInst<(outs R16C:$rT), (ins R16C:$rA, s10imm:$val), |
| 3165 | [(set R16C:$rT, (setugt R16C:$rA, i16ImmSExt10:$val))]>; |
| 3166 | } |
| 3167 | |
| 3168 | class CLGTInst<dag OOL, dag IOL, list<dag> pattern> : |
Scott Michel | 6baba07 | 2008-03-05 23:02:02 +0000 | [diff] [blame] | 3169 | RRForm<0b00000011010, OOL, IOL, "clgt\t$rT, $rA, $rB", |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 3170 | ByteOp, pattern>; |
| 3171 | |
| 3172 | multiclass CmpLGtrWord |
| 3173 | { |
| 3174 | def v4i32 : CLGTInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB), |
| 3175 | [(set (v4i32 VECREG:$rT), |
| 3176 | (setugt (v4i32 VECREG:$rA), (v4i32 VECREG:$rB)))]>; |
| 3177 | |
| 3178 | def r32 : CLGTInst<(outs R32C:$rT), (ins R32C:$rA, R32C:$rB), |
| 3179 | [(set R32C:$rT, (setugt R32C:$rA, R32C:$rB))]>; |
| 3180 | } |
| 3181 | |
| 3182 | class CLGTIInst<dag OOL, dag IOL, list<dag> pattern> : |
Scott Michel | 6baba07 | 2008-03-05 23:02:02 +0000 | [diff] [blame] | 3183 | RI10Form<0b00111010, OOL, IOL, "clgti\t$rT, $rA, $val", |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 3184 | ByteOp, pattern>; |
| 3185 | |
| 3186 | multiclass CmpLGtrWordImm |
| 3187 | { |
| 3188 | def v4i32 : CLGTIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val), |
| 3189 | [(set (v4i32 VECREG:$rT), |
| 3190 | (setugt (v4i32 VECREG:$rA), |
| 3191 | (v4i32 v4i32SExt16Imm:$val)))]>; |
| 3192 | |
| 3193 | def r32: CLGTIInst<(outs R32C:$rT), (ins R32C:$rA, s10imm_i32:$val), |
Scott Michel | 6baba07 | 2008-03-05 23:02:02 +0000 | [diff] [blame] | 3194 | [(set R32C:$rT, (setugt R32C:$rA, i32ImmSExt10:$val))]>; |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 3195 | } |
| 3196 | |
| 3197 | defm CEQB : CmpEqualByte; |
| 3198 | defm CEQBI : CmpEqualByteImm; |
| 3199 | defm CEQH : CmpEqualHalfword; |
| 3200 | defm CEQHI : CmpEqualHalfwordImm; |
| 3201 | defm CEQ : CmpEqualWord; |
| 3202 | defm CEQI : CmpEqualWordImm; |
| 3203 | defm CGTB : CmpGtrByte; |
| 3204 | defm CGTBI : CmpGtrByteImm; |
| 3205 | defm CGTH : CmpGtrHalfword; |
| 3206 | defm CGTHI : CmpGtrHalfwordImm; |
| 3207 | defm CGT : CmpGtrWord; |
| 3208 | defm CGTI : CmpGtrWordImm; |
| 3209 | defm CLGTB : CmpLGtrByte; |
| 3210 | defm CLGTBI : CmpLGtrByteImm; |
| 3211 | defm CLGTH : CmpLGtrHalfword; |
| 3212 | defm CLGTHI : CmpLGtrHalfwordImm; |
| 3213 | defm CLGT : CmpLGtrWord; |
| 3214 | defm CLGTI : CmpLGtrWordImm; |
| 3215 | |
Scott Michel | 53ab779 | 2008-03-10 16:58:52 +0000 | [diff] [blame] | 3216 | //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 3217 | // For SETCC primitives not supported above (setlt, setle, setge, etc.) |
| 3218 | // define a pattern to generate the right code, as a binary operator |
| 3219 | // (in a manner of speaking.) |
Scott Michel | 53ab779 | 2008-03-10 16:58:52 +0000 | [diff] [blame] | 3220 | // |
Scott Michel | 06eabde | 2008-12-27 04:51:36 +0000 | [diff] [blame^] | 3221 | // Notes: |
| 3222 | // 1. This only matches the setcc set of conditionals. Special pattern |
| 3223 | // matching is used for select conditionals. |
| 3224 | // |
| 3225 | // 2. The "DAG" versions of these classes is almost exclusively used for |
| 3226 | // i64 comparisons. See the tblgen fundamentals documentation for what |
| 3227 | // ".ResultInstrs[0]" means; see TargetSelectionDAG.td and the Pattern |
| 3228 | // class for where ResultInstrs originates. |
Scott Michel | 53ab779 | 2008-03-10 16:58:52 +0000 | [diff] [blame] | 3229 | //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 3230 | |
Scott Michel | 53ab779 | 2008-03-10 16:58:52 +0000 | [diff] [blame] | 3231 | class SETCCNegCondReg<PatFrag cond, RegisterClass rclass, ValueType inttype, |
| 3232 | SPUInstr xorinst, SPUInstr cmpare>: |
| 3233 | Pat<(cond rclass:$rA, rclass:$rB), |
| 3234 | (xorinst (cmpare rclass:$rA, rclass:$rB), (inttype -1))>; |
| 3235 | |
| 3236 | class SETCCNegCondImm<PatFrag cond, RegisterClass rclass, ValueType inttype, |
| 3237 | PatLeaf immpred, SPUInstr xorinst, SPUInstr cmpare>: |
| 3238 | Pat<(cond rclass:$rA, (inttype immpred:$imm)), |
| 3239 | (xorinst (cmpare rclass:$rA, (inttype immpred:$imm)), (inttype -1))>; |
| 3240 | |
Scott Michel | 06eabde | 2008-12-27 04:51:36 +0000 | [diff] [blame^] | 3241 | def : SETCCNegCondReg<setne, R8C, i8, XORBIr8, CEQBr8>; |
Scott Michel | 53ab779 | 2008-03-10 16:58:52 +0000 | [diff] [blame] | 3242 | def : SETCCNegCondImm<setne, R8C, i8, immSExt8, XORBIr8, CEQBIr8>; |
| 3243 | |
Scott Michel | 06eabde | 2008-12-27 04:51:36 +0000 | [diff] [blame^] | 3244 | def : SETCCNegCondReg<setne, R16C, i16, XORHIr16, CEQHr16>; |
Scott Michel | 53ab779 | 2008-03-10 16:58:52 +0000 | [diff] [blame] | 3245 | def : SETCCNegCondImm<setne, R16C, i16, i16ImmSExt10, XORHIr16, CEQHIr16>; |
| 3246 | |
| 3247 | def : SETCCNegCondReg<setne, R32C, i32, XORIr32, CEQr32>; |
| 3248 | def : SETCCNegCondImm<setne, R32C, i32, i32ImmSExt10, XORIr32, CEQIr32>; |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 3249 | |
| 3250 | class SETCCBinOpReg<PatFrag cond, RegisterClass rclass, |
| 3251 | SPUInstr binop, SPUInstr cmpOp1, SPUInstr cmpOp2>: |
| 3252 | Pat<(cond rclass:$rA, rclass:$rB), |
| 3253 | (binop (cmpOp1 rclass:$rA, rclass:$rB), |
| 3254 | (cmpOp2 rclass:$rA, rclass:$rB))>; |
| 3255 | |
| 3256 | class SETCCBinOpImm<PatFrag cond, RegisterClass rclass, PatLeaf immpred, |
| 3257 | ValueType immtype, |
| 3258 | SPUInstr binop, SPUInstr cmpOp1, SPUInstr cmpOp2>: |
| 3259 | Pat<(cond rclass:$rA, (immtype immpred:$imm)), |
| 3260 | (binop (cmpOp1 rclass:$rA, (immtype immpred:$imm)), |
| 3261 | (cmpOp2 rclass:$rA, (immtype immpred:$imm)))>; |
| 3262 | |
Scott Michel | 53ab779 | 2008-03-10 16:58:52 +0000 | [diff] [blame] | 3263 | def : SETCCBinOpReg<setge, R8C, ORr8, CGTBr8, CEQBr8>; |
| 3264 | def : SETCCBinOpImm<setge, R8C, immSExt8, i8, ORr8, CGTBIr8, CEQBIr8>; |
| 3265 | def : SETCCBinOpReg<setlt, R8C, NORr8, CGTBr8, CEQBr8>; |
| 3266 | def : SETCCBinOpImm<setlt, R8C, immSExt8, i8, NORr8, CGTBIr8, CEQBIr8>; |
| 3267 | def : Pat<(setle R8C:$rA, R8C:$rB), |
| 3268 | (XORBIr8 (CGTBr8 R8C:$rA, R8C:$rB), 0xff)>; |
| 3269 | def : Pat<(setle R8C:$rA, immU8:$imm), |
| 3270 | (XORBIr8 (CGTBIr8 R8C:$rA, immU8:$imm), 0xff)>; |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 3271 | |
Scott Michel | 53ab779 | 2008-03-10 16:58:52 +0000 | [diff] [blame] | 3272 | def : SETCCBinOpReg<setge, R16C, ORr16, CGTHr16, CEQHr16>; |
| 3273 | def : SETCCBinOpImm<setge, R16C, i16ImmSExt10, i16, |
| 3274 | ORr16, CGTHIr16, CEQHIr16>; |
| 3275 | def : SETCCBinOpReg<setlt, R16C, NORr16, CGTHr16, CEQHr16>; |
| 3276 | def : SETCCBinOpImm<setlt, R16C, i16ImmSExt10, i16, NORr16, CGTHIr16, CEQHIr16>; |
| 3277 | def : Pat<(setle R16C:$rA, R16C:$rB), |
| 3278 | (XORHIr16 (CGTHr16 R16C:$rA, R16C:$rB), 0xffff)>; |
| 3279 | def : Pat<(setle R16C:$rA, i16ImmSExt10:$imm), |
| 3280 | (XORHIr16 (CGTHIr16 R16C:$rA, i16ImmSExt10:$imm), 0xffff)>; |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 3281 | |
Scott Michel | 53ab779 | 2008-03-10 16:58:52 +0000 | [diff] [blame] | 3282 | def : SETCCBinOpReg<setge, R32C, ORr32, CGTr32, CEQr32>; |
| 3283 | def : SETCCBinOpImm<setge, R32C, i32ImmSExt10, i32, |
| 3284 | ORr32, CGTIr32, CEQIr32>; |
| 3285 | def : SETCCBinOpReg<setlt, R32C, NORr32, CGTr32, CEQr32>; |
| 3286 | def : SETCCBinOpImm<setlt, R32C, i32ImmSExt10, i32, NORr32, CGTIr32, CEQIr32>; |
| 3287 | def : Pat<(setle R32C:$rA, R32C:$rB), |
| 3288 | (XORIr32 (CGTr32 R32C:$rA, R32C:$rB), 0xffffffff)>; |
| 3289 | def : Pat<(setle R32C:$rA, i32ImmSExt10:$imm), |
| 3290 | (XORIr32 (CGTIr32 R32C:$rA, i32ImmSExt10:$imm), 0xffffffff)>; |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 3291 | |
Scott Michel | 53ab779 | 2008-03-10 16:58:52 +0000 | [diff] [blame] | 3292 | def : SETCCBinOpReg<setuge, R8C, ORr8, CLGTBr8, CEQBr8>; |
| 3293 | def : SETCCBinOpImm<setuge, R8C, immSExt8, i8, ORr8, CLGTBIr8, CEQBIr8>; |
| 3294 | def : SETCCBinOpReg<setult, R8C, NORr8, CLGTBr8, CEQBr8>; |
| 3295 | def : SETCCBinOpImm<setult, R8C, immSExt8, i8, NORr8, CLGTBIr8, CEQBIr8>; |
| 3296 | def : Pat<(setule R8C:$rA, R8C:$rB), |
| 3297 | (XORBIr8 (CLGTBr8 R8C:$rA, R8C:$rB), 0xff)>; |
| 3298 | def : Pat<(setule R8C:$rA, immU8:$imm), |
| 3299 | (XORBIr8 (CLGTBIr8 R8C:$rA, immU8:$imm), 0xff)>; |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 3300 | |
Scott Michel | 53ab779 | 2008-03-10 16:58:52 +0000 | [diff] [blame] | 3301 | def : SETCCBinOpReg<setuge, R16C, ORr16, CLGTHr16, CEQHr16>; |
| 3302 | def : SETCCBinOpImm<setuge, R16C, i16ImmSExt10, i16, |
| 3303 | ORr16, CLGTHIr16, CEQHIr16>; |
| 3304 | def : SETCCBinOpReg<setult, R16C, NORr16, CLGTHr16, CEQHr16>; |
| 3305 | def : SETCCBinOpImm<setult, R16C, i16ImmSExt10, i16, NORr16, |
| 3306 | CLGTHIr16, CEQHIr16>; |
| 3307 | def : Pat<(setule R16C:$rA, R16C:$rB), |
| 3308 | (XORHIr16 (CLGTHr16 R16C:$rA, R16C:$rB), 0xffff)>; |
Scott Michel | 7833d47 | 2008-03-20 00:51:36 +0000 | [diff] [blame] | 3309 | def : Pat<(setule R16C:$rA, i16ImmSExt10:$imm), |
Scott Michel | 53ab779 | 2008-03-10 16:58:52 +0000 | [diff] [blame] | 3310 | (XORHIr16 (CLGTHIr16 R16C:$rA, i16ImmSExt10:$imm), 0xffff)>; |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 3311 | |
Scott Michel | 53ab779 | 2008-03-10 16:58:52 +0000 | [diff] [blame] | 3312 | def : SETCCBinOpReg<setuge, R32C, ORr32, CLGTr32, CEQr32>; |
Scott Michel | 7833d47 | 2008-03-20 00:51:36 +0000 | [diff] [blame] | 3313 | def : SETCCBinOpImm<setuge, R32C, i32ImmSExt10, i32, |
Scott Michel | 53ab779 | 2008-03-10 16:58:52 +0000 | [diff] [blame] | 3314 | ORr32, CLGTIr32, CEQIr32>; |
| 3315 | def : SETCCBinOpReg<setult, R32C, NORr32, CLGTr32, CEQr32>; |
Scott Michel | 7833d47 | 2008-03-20 00:51:36 +0000 | [diff] [blame] | 3316 | def : SETCCBinOpImm<setult, R32C, i32ImmSExt10, i32, NORr32, CLGTIr32, CEQIr32>; |
Scott Michel | 53ab779 | 2008-03-10 16:58:52 +0000 | [diff] [blame] | 3317 | def : Pat<(setule R32C:$rA, R32C:$rB), |
| 3318 | (XORIr32 (CLGTr32 R32C:$rA, R32C:$rB), 0xffffffff)>; |
| 3319 | def : Pat<(setule R32C:$rA, i32ImmSExt10:$imm), |
| 3320 | (XORIr32 (CLGTIr32 R32C:$rA, i32ImmSExt10:$imm), 0xffffffff)>; |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 3321 | |
Scott Michel | 53ab779 | 2008-03-10 16:58:52 +0000 | [diff] [blame] | 3322 | //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ |
| 3323 | // select conditional patterns: |
| 3324 | //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ |
| 3325 | |
| 3326 | class SELECTNegCondReg<PatFrag cond, RegisterClass rclass, ValueType inttype, |
| 3327 | SPUInstr selinstr, SPUInstr cmpare>: |
| 3328 | Pat<(select (inttype (cond rclass:$rA, rclass:$rB)), |
| 3329 | rclass:$rTrue, rclass:$rFalse), |
| 3330 | (selinstr rclass:$rTrue, rclass:$rFalse, |
Bill Wendling | 8f6608b | 2008-07-22 08:50:44 +0000 | [diff] [blame] | 3331 | (cmpare rclass:$rA, rclass:$rB))>; |
Scott Michel | 53ab779 | 2008-03-10 16:58:52 +0000 | [diff] [blame] | 3332 | |
| 3333 | class SELECTNegCondImm<PatFrag cond, RegisterClass rclass, ValueType inttype, |
| 3334 | PatLeaf immpred, SPUInstr selinstr, SPUInstr cmpare>: |
| 3335 | Pat<(select (inttype (cond rclass:$rA, immpred:$imm)), |
Bill Wendling | 8f6608b | 2008-07-22 08:50:44 +0000 | [diff] [blame] | 3336 | rclass:$rTrue, rclass:$rFalse), |
Scott Michel | 53ab779 | 2008-03-10 16:58:52 +0000 | [diff] [blame] | 3337 | (selinstr rclass:$rTrue, rclass:$rFalse, |
| 3338 | (cmpare rclass:$rA, immpred:$imm))>; |
| 3339 | |
| 3340 | def : SELECTNegCondReg<setne, R8C, i8, SELBr8, CEQBr8>; |
| 3341 | def : SELECTNegCondImm<setne, R8C, i8, immSExt8, SELBr8, CEQBIr8>; |
| 3342 | def : SELECTNegCondReg<setle, R8C, i8, SELBr8, CGTBr8>; |
| 3343 | def : SELECTNegCondImm<setle, R8C, i8, immSExt8, SELBr8, CGTBr8>; |
| 3344 | def : SELECTNegCondReg<setule, R8C, i8, SELBr8, CLGTBr8>; |
| 3345 | def : SELECTNegCondImm<setule, R8C, i8, immU8, SELBr8, CLGTBIr8>; |
| 3346 | |
| 3347 | def : SELECTNegCondReg<setne, R16C, i16, SELBr16, CEQHr16>; |
| 3348 | def : SELECTNegCondImm<setne, R16C, i16, i16ImmSExt10, SELBr16, CEQHIr16>; |
| 3349 | def : SELECTNegCondReg<setle, R16C, i16, SELBr16, CGTHr16>; |
| 3350 | def : SELECTNegCondImm<setle, R16C, i16, i16ImmSExt10, SELBr16, CGTHIr16>; |
| 3351 | def : SELECTNegCondReg<setule, R16C, i16, SELBr16, CLGTHr16>; |
| 3352 | def : SELECTNegCondImm<setule, R16C, i16, i16ImmSExt10, SELBr16, CLGTHIr16>; |
| 3353 | |
| 3354 | def : SELECTNegCondReg<setne, R32C, i32, SELBr32, CEQr32>; |
| 3355 | def : SELECTNegCondImm<setne, R32C, i32, i32ImmSExt10, SELBr32, CEQIr32>; |
| 3356 | def : SELECTNegCondReg<setle, R32C, i32, SELBr32, CGTr32>; |
| 3357 | def : SELECTNegCondImm<setle, R32C, i32, i32ImmSExt10, SELBr32, CGTIr32>; |
| 3358 | def : SELECTNegCondReg<setule, R32C, i32, SELBr32, CLGTr32>; |
| 3359 | def : SELECTNegCondImm<setule, R32C, i32, i32ImmSExt10, SELBr32, CLGTIr32>; |
| 3360 | |
| 3361 | class SELECTBinOpReg<PatFrag cond, RegisterClass rclass, ValueType inttype, |
| 3362 | SPUInstr selinstr, SPUInstr binop, SPUInstr cmpOp1, |
| 3363 | SPUInstr cmpOp2>: |
| 3364 | Pat<(select (inttype (cond rclass:$rA, rclass:$rB)), |
Scott Michel | 06eabde | 2008-12-27 04:51:36 +0000 | [diff] [blame^] | 3365 | rclass:$rTrue, rclass:$rFalse), |
| 3366 | (selinstr rclass:$rFalse, rclass:$rTrue, |
Scott Michel | 53ab779 | 2008-03-10 16:58:52 +0000 | [diff] [blame] | 3367 | (binop (cmpOp1 rclass:$rA, rclass:$rB), |
| 3368 | (cmpOp2 rclass:$rA, rclass:$rB)))>; |
| 3369 | |
| 3370 | class SELECTBinOpImm<PatFrag cond, RegisterClass rclass, PatLeaf immpred, |
| 3371 | ValueType inttype, |
| 3372 | SPUInstr selinstr, SPUInstr binop, SPUInstr cmpOp1, |
| 3373 | SPUInstr cmpOp2>: |
| 3374 | Pat<(select (inttype (cond rclass:$rA, (inttype immpred:$imm))), |
Bill Wendling | 8f6608b | 2008-07-22 08:50:44 +0000 | [diff] [blame] | 3375 | rclass:$rTrue, rclass:$rFalse), |
Scott Michel | 53ab779 | 2008-03-10 16:58:52 +0000 | [diff] [blame] | 3376 | (selinstr rclass:$rFalse, rclass:$rTrue, |
| 3377 | (binop (cmpOp1 rclass:$rA, (inttype immpred:$imm)), |
| 3378 | (cmpOp2 rclass:$rA, (inttype immpred:$imm))))>; |
| 3379 | |
| 3380 | def : SELECTBinOpReg<setge, R8C, i8, SELBr8, ORr8, CGTBr8, CEQBr8>; |
| 3381 | def : SELECTBinOpImm<setge, R8C, immSExt8, i8, |
| 3382 | SELBr8, ORr8, CGTBIr8, CEQBIr8>; |
| 3383 | |
| 3384 | def : SELECTBinOpReg<setge, R16C, i16, SELBr16, ORr16, CGTHr16, CEQHr16>; |
| 3385 | def : SELECTBinOpImm<setge, R16C, i16ImmSExt10, i16, |
| 3386 | SELBr16, ORr16, CGTHIr16, CEQHIr16>; |
| 3387 | |
| 3388 | def : SELECTBinOpReg<setge, R32C, i32, SELBr32, ORr32, CGTr32, CEQr32>; |
| 3389 | def : SELECTBinOpImm<setge, R32C, i32ImmSExt10, i32, |
| 3390 | SELBr32, ORr32, CGTIr32, CEQIr32>; |
| 3391 | |
| 3392 | def : SELECTBinOpReg<setuge, R8C, i8, SELBr8, ORr8, CLGTBr8, CEQBr8>; |
| 3393 | def : SELECTBinOpImm<setuge, R8C, immSExt8, i8, |
| 3394 | SELBr8, ORr8, CLGTBIr8, CEQBIr8>; |
| 3395 | |
| 3396 | def : SELECTBinOpReg<setuge, R16C, i16, SELBr16, ORr16, CLGTHr16, CEQHr16>; |
| 3397 | def : SELECTBinOpImm<setuge, R16C, i16ImmUns10, i16, |
| 3398 | SELBr16, ORr16, CLGTHIr16, CEQHIr16>; |
| 3399 | |
| 3400 | def : SELECTBinOpReg<setuge, R32C, i32, SELBr32, ORr32, CLGTr32, CEQr32>; |
| 3401 | def : SELECTBinOpImm<setuge, R32C, i32ImmUns10, i32, |
| 3402 | SELBr32, ORr32, CLGTIr32, CEQIr32>; |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 3403 | |
| 3404 | //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 3405 | |
| 3406 | let isCall = 1, |
| 3407 | // All calls clobber the non-callee-saved registers: |
| 3408 | Defs = [R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, |
| 3409 | R10,R11,R12,R13,R14,R15,R16,R17,R18,R19, |
| 3410 | R20,R21,R22,R23,R24,R25,R26,R27,R28,R29, |
| 3411 | R30,R31,R32,R33,R34,R35,R36,R37,R38,R39, |
| 3412 | R40,R41,R42,R43,R44,R45,R46,R47,R48,R49, |
| 3413 | R50,R51,R52,R53,R54,R55,R56,R57,R58,R59, |
| 3414 | R60,R61,R62,R63,R64,R65,R66,R67,R68,R69, |
| 3415 | R70,R71,R72,R73,R74,R75,R76,R77,R78,R79], |
| 3416 | // All of these instructions use $lr (aka $0) |
| 3417 | Uses = [R0] in { |
| 3418 | // Branch relative and set link: Used if we actually know that the target |
| 3419 | // is within [-32768, 32767] bytes of the target |
| 3420 | def BRSL: |
| 3421 | BranchSetLink<0b011001100, (outs), (ins relcalltarget:$func, variable_ops), |
| 3422 | "brsl\t$$lr, $func", |
| 3423 | [(SPUcall (SPUpcrel tglobaladdr:$func, 0))]>; |
| 3424 | |
| 3425 | // Branch absolute and set link: Used if we actually know that the target |
| 3426 | // is an absolute address |
| 3427 | def BRASL: |
| 3428 | BranchSetLink<0b011001100, (outs), (ins calltarget:$func, variable_ops), |
| 3429 | "brasl\t$$lr, $func", |
Scott Michel | dbac4cf | 2008-01-11 02:53:15 +0000 | [diff] [blame] | 3430 | [(SPUcall (SPUaform tglobaladdr:$func, 0))]>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 3431 | |
| 3432 | // Branch indirect and set link if external data. These instructions are not |
| 3433 | // actually generated, matched by an intrinsic: |
| 3434 | def BISLED_00: BISLEDForm<0b11, "bisled\t$$lr, $func", [/* empty pattern */]>; |
| 3435 | def BISLED_E0: BISLEDForm<0b10, "bisled\t$$lr, $func", [/* empty pattern */]>; |
| 3436 | def BISLED_0D: BISLEDForm<0b01, "bisled\t$$lr, $func", [/* empty pattern */]>; |
| 3437 | def BISLED_ED: BISLEDForm<0b00, "bisled\t$$lr, $func", [/* empty pattern */]>; |
| 3438 | |
| 3439 | // Branch indirect and set link. This is the "X-form" address version of a |
| 3440 | // function call |
| 3441 | def BISL: |
| 3442 | BIForm<0b10010101100, "bisl\t$$lr, $func", [(SPUcall R32C:$func)]>; |
| 3443 | } |
| 3444 | |
| 3445 | // Unconditional branches: |
| 3446 | let isBranch = 1, isTerminator = 1, hasCtrlDep = 1, isBarrier = 1 in { |
| 3447 | def BR : |
| 3448 | UncondBranch<0b001001100, (outs), (ins brtarget:$dest), |
| 3449 | "br\t$dest", |
| 3450 | [(br bb:$dest)]>; |
| 3451 | |
| 3452 | // Unconditional, absolute address branch |
| 3453 | def BRA: |
| 3454 | UncondBranch<0b001100000, (outs), (ins brtarget:$dest), |
| 3455 | "bra\t$dest", |
| 3456 | [/* no pattern */]>; |
| 3457 | |
| 3458 | // Indirect branch |
| 3459 | def BI: |
| 3460 | BIForm<0b00010101100, "bi\t$func", [(brind R32C:$func)]>; |
| 3461 | |
| 3462 | // Various branches: |
Scott Michel | 06eabde | 2008-12-27 04:51:36 +0000 | [diff] [blame^] | 3463 | class BRNZInst<dag IOL, list<dag> pattern>: |
| 3464 | RI16Form<0b010000100, (outs), IOL, "brnz\t$rCond,$dest", |
| 3465 | BranchResolv, pattern>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 3466 | |
Scott Michel | 06eabde | 2008-12-27 04:51:36 +0000 | [diff] [blame^] | 3467 | class BRNZRegInst<RegisterClass rclass>: |
| 3468 | BRNZInst<(ins rclass:$rCond, brtarget:$dest), |
| 3469 | [(brcond rclass:$rCond, bb:$dest)]>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 3470 | |
Scott Michel | 06eabde | 2008-12-27 04:51:36 +0000 | [diff] [blame^] | 3471 | class BRNZVecInst<ValueType vectype>: |
| 3472 | BRNZInst<(ins VECREG:$rCond, brtarget:$dest), |
| 3473 | [(brcond (vectype VECREG:$rCond), bb:$dest)]>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 3474 | |
Scott Michel | 06eabde | 2008-12-27 04:51:36 +0000 | [diff] [blame^] | 3475 | multiclass BranchNotZero { |
| 3476 | def v4i32 : BRNZVecInst<v4i32>; |
| 3477 | def r32 : BRNZRegInst<R32C>; |
| 3478 | } |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 3479 | |
Scott Michel | 06eabde | 2008-12-27 04:51:36 +0000 | [diff] [blame^] | 3480 | defm BRNZ : BranchNotZero; |
| 3481 | |
| 3482 | class BRZInst<dag IOL, list<dag> pattern>: |
| 3483 | RI16Form<0b000000100, (outs), IOL, "brz\t$rT,$dest", |
| 3484 | BranchResolv, pattern>; |
| 3485 | |
| 3486 | class BRZRegInst<RegisterClass rclass>: |
| 3487 | BRZInst<(ins rclass:$rT, brtarget:$dest), [/* no pattern */]>; |
| 3488 | |
| 3489 | class BRZVecInst<ValueType vectype>: |
| 3490 | BRZInst<(ins VECREG:$rT, brtarget:$dest), [/* no pattern */]>; |
| 3491 | |
| 3492 | multiclass BranchZero { |
| 3493 | def v4i32: BRZVecInst<v4i32>; |
| 3494 | def r32: BRZRegInst<R32C>; |
| 3495 | } |
| 3496 | |
| 3497 | defm BRZ: BranchZero; |
| 3498 | |
| 3499 | // Note: LLVM doesn't do branch conditional, indirect. Otherwise these would |
| 3500 | // be useful: |
| 3501 | /* |
| 3502 | class BINZInst<dag IOL, list<dag> pattern>: |
| 3503 | BICondForm<0b10010100100, (outs), IOL, "binz\t$rA, $dest", pattern>; |
| 3504 | |
| 3505 | class BINZRegInst<RegisterClass rclass>: |
| 3506 | BINZInst<(ins rclass:$rA, brtarget:$dest), |
| 3507 | [(brcond rclass:$rA, R32C:$dest)]>; |
| 3508 | |
| 3509 | class BINZVecInst<ValueType vectype>: |
| 3510 | BINZInst<(ins VECREG:$rA, R32C:$dest), |
| 3511 | [(brcond (vectype VECREG:$rA), R32C:$dest)]>; |
| 3512 | |
| 3513 | multiclass BranchNotZeroIndirect { |
| 3514 | def v4i32: BINZVecInst<v4i32>; |
| 3515 | def r32: BINZRegInst<R32C>; |
| 3516 | } |
| 3517 | |
| 3518 | defm BINZ: BranchNotZeroIndirect; |
| 3519 | |
| 3520 | class BIZInst<dag IOL, list<dag> pattern>: |
| 3521 | BICondForm<0b00010100100, (outs), IOL, "biz\t$rA, $func", pattern>; |
| 3522 | |
| 3523 | class BIZRegInst<RegisterClass rclass>: |
| 3524 | BIZInst<(ins rclass:$rA, R32C:$func), [/* no pattern */]>; |
| 3525 | |
| 3526 | class BIZVecInst<ValueType vectype>: |
| 3527 | BIZInst<(ins VECREG:$rA, R32C:$func), [/* no pattern */]>; |
| 3528 | |
| 3529 | multiclass BranchZeroIndirect { |
| 3530 | def v4i32: BIZVecInst<v4i32>; |
| 3531 | def r32: BIZRegInst<R32C>; |
| 3532 | } |
| 3533 | |
| 3534 | defm BIZ: BranchZeroIndirect; |
| 3535 | */ |
| 3536 | |
| 3537 | class BRHNZInst<dag IOL, list<dag> pattern>: |
| 3538 | RI16Form<0b011000100, (outs), IOL, "brhnz\t$rCond,$dest", BranchResolv, |
| 3539 | pattern>; |
| 3540 | |
| 3541 | class BRHNZRegInst<RegisterClass rclass>: |
| 3542 | BRHNZInst<(ins rclass:$rCond, brtarget:$dest), |
| 3543 | [(brcond rclass:$rCond, bb:$dest)]>; |
| 3544 | |
| 3545 | class BRHNZVecInst<ValueType vectype>: |
| 3546 | BRHNZInst<(ins VECREG:$rCond, brtarget:$dest), [/* no pattern */]>; |
| 3547 | |
| 3548 | multiclass BranchNotZeroHalfword { |
| 3549 | def v8i16: BRHNZVecInst<v8i16>; |
| 3550 | def r16: BRHNZRegInst<R16C>; |
| 3551 | } |
| 3552 | |
| 3553 | defm BRHNZ: BranchNotZeroHalfword; |
| 3554 | |
| 3555 | class BRHZInst<dag IOL, list<dag> pattern>: |
| 3556 | RI16Form<0b001000100, (outs), IOL, "brhz\t$rT,$dest", BranchResolv, |
| 3557 | pattern>; |
| 3558 | |
| 3559 | class BRHZRegInst<RegisterClass rclass>: |
| 3560 | BRHZInst<(ins rclass:$rT, brtarget:$dest), [/* no pattern */]>; |
| 3561 | |
| 3562 | class BRHZVecInst<ValueType vectype>: |
| 3563 | BRHZInst<(ins VECREG:$rT, brtarget:$dest), [/* no pattern */]>; |
| 3564 | |
| 3565 | multiclass BranchZeroHalfword { |
| 3566 | def v8i16: BRHZVecInst<v8i16>; |
| 3567 | def r16: BRHZRegInst<R16C>; |
| 3568 | } |
| 3569 | |
| 3570 | defm BRHZ: BranchZeroHalfword; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 3571 | } |
| 3572 | |
Scott Michel | 394e26d | 2008-01-17 20:38:41 +0000 | [diff] [blame] | 3573 | //===----------------------------------------------------------------------===// |
Scott Michel | f9f42e6 | 2008-01-29 02:16:57 +0000 | [diff] [blame] | 3574 | // setcc and brcond patterns: |
Scott Michel | 394e26d | 2008-01-17 20:38:41 +0000 | [diff] [blame] | 3575 | //===----------------------------------------------------------------------===// |
Scott Michel | f9f42e6 | 2008-01-29 02:16:57 +0000 | [diff] [blame] | 3576 | |
Scott Michel | 06eabde | 2008-12-27 04:51:36 +0000 | [diff] [blame^] | 3577 | def : Pat<(brcond (i16 (seteq R16C:$rA, 0)), bb:$dest), |
| 3578 | (BRHZr16 R16C:$rA, bb:$dest)>; |
| 3579 | def : Pat<(brcond (i16 (setne R16C:$rA, 0)), bb:$dest), |
| 3580 | (BRHNZr16 R16C:$rA, bb:$dest)>; |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 3581 | |
Scott Michel | 06eabde | 2008-12-27 04:51:36 +0000 | [diff] [blame^] | 3582 | def : Pat<(brcond (i32 (seteq R32C:$rA, 0)), bb:$dest), |
| 3583 | (BRZr32 R32C:$rA, bb:$dest)>; |
| 3584 | def : Pat<(brcond (i32 (setne R32C:$rA, 0)), bb:$dest), |
| 3585 | (BRNZr32 R32C:$rA, bb:$dest)>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 3586 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 3587 | multiclass BranchCondEQ<PatFrag cond, SPUInstr brinst16, SPUInstr brinst32> |
| 3588 | { |
| 3589 | def r16imm: Pat<(brcond (i16 (cond R16C:$rA, i16ImmSExt10:$val)), bb:$dest), |
| 3590 | (brinst16 (CEQHIr16 R16C:$rA, i16ImmSExt10:$val), bb:$dest)>; |
Scott Michel | f9f42e6 | 2008-01-29 02:16:57 +0000 | [diff] [blame] | 3591 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 3592 | def r16 : Pat<(brcond (i16 (cond R16C:$rA, R16C:$rB)), bb:$dest), |
| 3593 | (brinst16 (CEQHr16 R16C:$rA, R16:$rB), bb:$dest)>; |
| 3594 | |
| 3595 | def r32imm : Pat<(brcond (i32 (cond R32C:$rA, i32ImmSExt10:$val)), bb:$dest), |
| 3596 | (brinst32 (CEQIr32 R32C:$rA, i32ImmSExt10:$val), bb:$dest)>; |
| 3597 | |
| 3598 | def r32 : Pat<(brcond (i32 (cond R32C:$rA, R32C:$rB)), bb:$dest), |
| 3599 | (brinst32 (CEQr32 R32C:$rA, R32C:$rB), bb:$dest)>; |
| 3600 | } |
| 3601 | |
Scott Michel | 06eabde | 2008-12-27 04:51:36 +0000 | [diff] [blame^] | 3602 | defm BRCONDeq : BranchCondEQ<seteq, BRHZr16, BRZr32>; |
| 3603 | defm BRCONDne : BranchCondEQ<setne, BRHNZr16, BRNZr32>; |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 3604 | |
| 3605 | multiclass BranchCondLGT<PatFrag cond, SPUInstr brinst16, SPUInstr brinst32> |
| 3606 | { |
| 3607 | def r16imm : Pat<(brcond (i16 (cond R16C:$rA, i16ImmSExt10:$val)), bb:$dest), |
| 3608 | (brinst16 (CLGTHIr16 R16C:$rA, i16ImmSExt10:$val), bb:$dest)>; |
| 3609 | |
| 3610 | def r16 : Pat<(brcond (i16 (cond R16C:$rA, R16C:$rB)), bb:$dest), |
| 3611 | (brinst16 (CLGTHr16 R16C:$rA, R16:$rB), bb:$dest)>; |
| 3612 | |
| 3613 | def r32imm : Pat<(brcond (i32 (cond R32C:$rA, i32ImmSExt10:$val)), bb:$dest), |
| 3614 | (brinst32 (CLGTIr32 R32C:$rA, i32ImmSExt10:$val), bb:$dest)>; |
| 3615 | |
| 3616 | def r32 : Pat<(brcond (i32 (cond R32C:$rA, R32C:$rB)), bb:$dest), |
| 3617 | (brinst32 (CLGTr32 R32C:$rA, R32C:$rB), bb:$dest)>; |
| 3618 | } |
| 3619 | |
Scott Michel | 06eabde | 2008-12-27 04:51:36 +0000 | [diff] [blame^] | 3620 | defm BRCONDugt : BranchCondLGT<setugt, BRHNZr16, BRNZr32>; |
| 3621 | defm BRCONDule : BranchCondLGT<setule, BRHZr16, BRZr32>; |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 3622 | |
| 3623 | multiclass BranchCondLGTEQ<PatFrag cond, SPUInstr orinst16, SPUInstr brinst16, |
| 3624 | SPUInstr orinst32, SPUInstr brinst32> |
| 3625 | { |
| 3626 | def r16imm: Pat<(brcond (i16 (cond R16C:$rA, i16ImmSExt10:$val)), bb:$dest), |
| 3627 | (brinst16 (orinst16 (CLGTHIr16 R16C:$rA, i16ImmSExt10:$val), |
| 3628 | (CEQHIr16 R16C:$rA, i16ImmSExt10:$val)), |
| 3629 | bb:$dest)>; |
| 3630 | |
| 3631 | def r16: Pat<(brcond (i16 (cond R16C:$rA, R16C:$rB)), bb:$dest), |
| 3632 | (brinst16 (orinst16 (CLGTHr16 R16C:$rA, R16:$rB), |
| 3633 | (CEQHr16 R16C:$rA, R16:$rB)), |
| 3634 | bb:$dest)>; |
| 3635 | |
| 3636 | def r32imm : Pat<(brcond (i32 (cond R32C:$rA, i32ImmSExt10:$val)), bb:$dest), |
| 3637 | (brinst32 (orinst32 (CLGTIr32 R32C:$rA, i32ImmSExt10:$val), |
| 3638 | (CEQIr32 R32C:$rA, i32ImmSExt10:$val)), |
| 3639 | bb:$dest)>; |
| 3640 | |
| 3641 | def r32 : Pat<(brcond (i32 (cond R32C:$rA, R32C:$rB)), bb:$dest), |
| 3642 | (brinst32 (orinst32 (CLGTr32 R32C:$rA, R32C:$rB), |
| 3643 | (CEQr32 R32C:$rA, R32C:$rB)), |
| 3644 | bb:$dest)>; |
| 3645 | } |
| 3646 | |
Scott Michel | 06eabde | 2008-12-27 04:51:36 +0000 | [diff] [blame^] | 3647 | defm BRCONDuge : BranchCondLGTEQ<setuge, ORr16, BRHNZr16, ORr32, BRNZr32>; |
| 3648 | defm BRCONDult : BranchCondLGTEQ<setult, ORr16, BRHZr16, ORr32, BRZr32>; |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 3649 | |
| 3650 | multiclass BranchCondGT<PatFrag cond, SPUInstr brinst16, SPUInstr brinst32> |
| 3651 | { |
| 3652 | def r16imm : Pat<(brcond (i16 (cond R16C:$rA, i16ImmSExt10:$val)), bb:$dest), |
| 3653 | (brinst16 (CGTHIr16 R16C:$rA, i16ImmSExt10:$val), bb:$dest)>; |
| 3654 | |
| 3655 | def r16 : Pat<(brcond (i16 (cond R16C:$rA, R16C:$rB)), bb:$dest), |
| 3656 | (brinst16 (CGTHr16 R16C:$rA, R16:$rB), bb:$dest)>; |
| 3657 | |
| 3658 | def r32imm : Pat<(brcond (i32 (cond R32C:$rA, i32ImmSExt10:$val)), bb:$dest), |
| 3659 | (brinst32 (CGTIr32 R32C:$rA, i32ImmSExt10:$val), bb:$dest)>; |
| 3660 | |
| 3661 | def r32 : Pat<(brcond (i32 (cond R32C:$rA, R32C:$rB)), bb:$dest), |
| 3662 | (brinst32 (CGTr32 R32C:$rA, R32C:$rB), bb:$dest)>; |
| 3663 | } |
| 3664 | |
Scott Michel | 06eabde | 2008-12-27 04:51:36 +0000 | [diff] [blame^] | 3665 | defm BRCONDgt : BranchCondGT<setgt, BRHNZr16, BRNZr32>; |
| 3666 | defm BRCONDle : BranchCondGT<setle, BRHZr16, BRZr32>; |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 3667 | |
| 3668 | multiclass BranchCondGTEQ<PatFrag cond, SPUInstr orinst16, SPUInstr brinst16, |
| 3669 | SPUInstr orinst32, SPUInstr brinst32> |
| 3670 | { |
| 3671 | def r16imm: Pat<(brcond (i16 (cond R16C:$rA, i16ImmSExt10:$val)), bb:$dest), |
| 3672 | (brinst16 (orinst16 (CGTHIr16 R16C:$rA, i16ImmSExt10:$val), |
| 3673 | (CEQHIr16 R16C:$rA, i16ImmSExt10:$val)), |
| 3674 | bb:$dest)>; |
| 3675 | |
| 3676 | def r16: Pat<(brcond (i16 (cond R16C:$rA, R16C:$rB)), bb:$dest), |
| 3677 | (brinst16 (orinst16 (CGTHr16 R16C:$rA, R16:$rB), |
| 3678 | (CEQHr16 R16C:$rA, R16:$rB)), |
| 3679 | bb:$dest)>; |
| 3680 | |
| 3681 | def r32imm : Pat<(brcond (i32 (cond R32C:$rA, i32ImmSExt10:$val)), bb:$dest), |
| 3682 | (brinst32 (orinst32 (CGTIr32 R32C:$rA, i32ImmSExt10:$val), |
| 3683 | (CEQIr32 R32C:$rA, i32ImmSExt10:$val)), |
| 3684 | bb:$dest)>; |
| 3685 | |
| 3686 | def r32 : Pat<(brcond (i32 (cond R32C:$rA, R32C:$rB)), bb:$dest), |
| 3687 | (brinst32 (orinst32 (CGTr32 R32C:$rA, R32C:$rB), |
| 3688 | (CEQr32 R32C:$rA, R32C:$rB)), |
| 3689 | bb:$dest)>; |
| 3690 | } |
| 3691 | |
Scott Michel | 06eabde | 2008-12-27 04:51:36 +0000 | [diff] [blame^] | 3692 | defm BRCONDge : BranchCondGTEQ<setge, ORr16, BRHNZr16, ORr32, BRNZr32>; |
| 3693 | defm BRCONDlt : BranchCondGTEQ<setlt, ORr16, BRHZr16, ORr32, BRZr32>; |
Scott Michel | f9f42e6 | 2008-01-29 02:16:57 +0000 | [diff] [blame] | 3694 | |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 3695 | let isTerminator = 1, isBarrier = 1 in { |
| 3696 | let isReturn = 1 in { |
| 3697 | def RET: |
| 3698 | RETForm<"bi\t$$lr", [(retflag)]>; |
| 3699 | } |
| 3700 | } |
| 3701 | |
| 3702 | //===----------------------------------------------------------------------===// |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 3703 | // Single precision floating point instructions |
| 3704 | //===----------------------------------------------------------------------===// |
| 3705 | |
Scott Michel | 61895fe | 2008-12-10 00:15:19 +0000 | [diff] [blame] | 3706 | class FAInst<dag OOL, dag IOL, list<dag> pattern>: |
| 3707 | RRForm<0b01011000100, OOL, IOL, "fa\t$rT, $rA, $rB", |
| 3708 | SPrecFP, pattern>; |
Scott Michel | 06eabde | 2008-12-27 04:51:36 +0000 | [diff] [blame^] | 3709 | |
Scott Michel | 61895fe | 2008-12-10 00:15:19 +0000 | [diff] [blame] | 3710 | class FAVecInst<ValueType vectype>: |
| 3711 | FAInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB), |
| 3712 | [(set (vectype VECREG:$rT), |
| 3713 | (fadd (vectype VECREG:$rA), (vectype VECREG:$rB)))]>; |
Scott Michel | 06eabde | 2008-12-27 04:51:36 +0000 | [diff] [blame^] | 3714 | |
Scott Michel | 61895fe | 2008-12-10 00:15:19 +0000 | [diff] [blame] | 3715 | multiclass SFPAdd |
| 3716 | { |
| 3717 | def v4f32: FAVecInst<v4f32>; |
| 3718 | def r32: FAInst<(outs R32FP:$rT), (ins R32FP:$rA, R32FP:$rB), |
| 3719 | [(set R32FP:$rT, (fadd R32FP:$rA, R32FP:$rB))]>; |
| 3720 | } |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 3721 | |
Scott Michel | 61895fe | 2008-12-10 00:15:19 +0000 | [diff] [blame] | 3722 | defm FA : SFPAdd; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 3723 | |
Scott Michel | 61895fe | 2008-12-10 00:15:19 +0000 | [diff] [blame] | 3724 | class FSInst<dag OOL, dag IOL, list<dag> pattern>: |
| 3725 | RRForm<0b01011000100, OOL, IOL, "fs\t$rT, $rA, $rB", |
| 3726 | SPrecFP, pattern>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 3727 | |
Scott Michel | 61895fe | 2008-12-10 00:15:19 +0000 | [diff] [blame] | 3728 | class FSVecInst<ValueType vectype>: |
| 3729 | FSInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB), |
| 3730 | [(set (vectype VECREG:$rT), |
| 3731 | (fsub (vectype VECREG:$rA), (vectype VECREG:$rB)))]>; |
| 3732 | |
| 3733 | multiclass SFPSub |
| 3734 | { |
| 3735 | def v4f32: FSVecInst<v4f32>; |
| 3736 | def r32: FSInst<(outs R32FP:$rT), (ins R32FP:$rA, R32FP:$rB), |
| 3737 | [(set R32FP:$rT, (fsub R32FP:$rA, R32FP:$rB))]>; |
| 3738 | } |
| 3739 | |
| 3740 | defm FS : SFPSub; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 3741 | |
| 3742 | // Floating point reciprocal estimate |
| 3743 | def FREv4f32 : |
| 3744 | RRForm_1<0b00011101100, (outs VECREG:$rT), (ins VECREG:$rA), |
| 3745 | "frest\t$rT, $rA", SPrecFP, |
| 3746 | [(set (v4f32 VECREG:$rT), (SPUreciprocalEst (v4f32 VECREG:$rA)))]>; |
| 3747 | |
| 3748 | def FREf32 : |
| 3749 | RRForm_1<0b00011101100, (outs R32FP:$rT), (ins R32FP:$rA), |
| 3750 | "frest\t$rT, $rA", SPrecFP, |
| 3751 | [(set R32FP:$rT, (SPUreciprocalEst R32FP:$rA))]>; |
| 3752 | |
| 3753 | // Floating point interpolate (used in conjunction with reciprocal estimate) |
| 3754 | def FIv4f32 : |
| 3755 | RRForm<0b00101011110, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB), |
| 3756 | "fi\t$rT, $rA, $rB", SPrecFP, |
| 3757 | [(set (v4f32 VECREG:$rT), (SPUinterpolate (v4f32 VECREG:$rA), |
| 3758 | (v4f32 VECREG:$rB)))]>; |
| 3759 | |
| 3760 | def FIf32 : |
| 3761 | RRForm<0b00101011110, (outs R32FP:$rT), (ins R32FP:$rA, R32FP:$rB), |
| 3762 | "fi\t$rT, $rA, $rB", SPrecFP, |
| 3763 | [(set R32FP:$rT, (SPUinterpolate R32FP:$rA, R32FP:$rB))]>; |
| 3764 | |
Scott Michel | 33d73eb | 2008-11-21 02:56:16 +0000 | [diff] [blame] | 3765 | //-------------------------------------------------------------------------- |
| 3766 | // Basic single precision floating point comparisons: |
| 3767 | // |
| 3768 | // Note: There is no support on SPU for single precision NaN. Consequently, |
| 3769 | // ordered and unordered comparisons are the same. |
| 3770 | //-------------------------------------------------------------------------- |
| 3771 | |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 3772 | def FCEQf32 : |
| 3773 | RRForm<0b01000011110, (outs R32C:$rT), (ins R32FP:$rA, R32FP:$rB), |
| 3774 | "fceq\t$rT, $rA, $rB", SPrecFP, |
Scott Michel | 33d73eb | 2008-11-21 02:56:16 +0000 | [diff] [blame] | 3775 | [(set R32C:$rT, (setueq R32FP:$rA, R32FP:$rB))]>; |
| 3776 | |
| 3777 | def : Pat<(setoeq R32FP:$rA, R32FP:$rB), |
| 3778 | (FCEQf32 R32FP:$rA, R32FP:$rB)>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 3779 | |
| 3780 | def FCMEQf32 : |
| 3781 | RRForm<0b01010011110, (outs R32C:$rT), (ins R32FP:$rA, R32FP:$rB), |
| 3782 | "fcmeq\t$rT, $rA, $rB", SPrecFP, |
Scott Michel | 33d73eb | 2008-11-21 02:56:16 +0000 | [diff] [blame] | 3783 | [(set R32C:$rT, (setueq (fabs R32FP:$rA), (fabs R32FP:$rB)))]>; |
| 3784 | |
| 3785 | def : Pat<(setoeq (fabs R32FP:$rA), (fabs R32FP:$rB)), |
| 3786 | (FCMEQf32 R32FP:$rA, R32FP:$rB)>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 3787 | |
| 3788 | def FCGTf32 : |
| 3789 | RRForm<0b01000011010, (outs R32C:$rT), (ins R32FP:$rA, R32FP:$rB), |
| 3790 | "fcgt\t$rT, $rA, $rB", SPrecFP, |
Scott Michel | 33d73eb | 2008-11-21 02:56:16 +0000 | [diff] [blame] | 3791 | [(set R32C:$rT, (setugt R32FP:$rA, R32FP:$rB))]>; |
| 3792 | |
| 3793 | def : Pat<(setugt R32FP:$rA, R32FP:$rB), |
| 3794 | (FCGTf32 R32FP:$rA, R32FP:$rB)>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 3795 | |
| 3796 | def FCMGTf32 : |
| 3797 | RRForm<0b01010011010, (outs R32C:$rT), (ins R32FP:$rA, R32FP:$rB), |
| 3798 | "fcmgt\t$rT, $rA, $rB", SPrecFP, |
Scott Michel | 33d73eb | 2008-11-21 02:56:16 +0000 | [diff] [blame] | 3799 | [(set R32C:$rT, (setugt (fabs R32FP:$rA), (fabs R32FP:$rB)))]>; |
| 3800 | |
| 3801 | def : Pat<(setugt (fabs R32FP:$rA), (fabs R32FP:$rB)), |
| 3802 | (FCMGTf32 R32FP:$rA, R32FP:$rB)>; |
| 3803 | |
| 3804 | //-------------------------------------------------------------------------- |
| 3805 | // Single precision floating point comparisons and SETCC equivalents: |
| 3806 | //-------------------------------------------------------------------------- |
| 3807 | |
| 3808 | def : SETCCNegCondReg<setune, R32FP, i32, XORIr32, FCEQf32>; |
| 3809 | def : SETCCNegCondReg<setone, R32FP, i32, XORIr32, FCEQf32>; |
| 3810 | |
| 3811 | def : SETCCBinOpReg<setuge, R32FP, ORr32, FCGTf32, FCEQf32>; |
| 3812 | def : SETCCBinOpReg<setoge, R32FP, ORr32, FCGTf32, FCEQf32>; |
| 3813 | |
| 3814 | def : SETCCBinOpReg<setult, R32FP, NORr32, FCGTf32, FCEQf32>; |
| 3815 | def : SETCCBinOpReg<setolt, R32FP, NORr32, FCGTf32, FCEQf32>; |
| 3816 | |
| 3817 | def : Pat<(setule R32FP:$rA, R32FP:$rB), |
| 3818 | (XORIr32 (FCGTf32 R32FP:$rA, R32FP:$rB), 0xffffffff)>; |
| 3819 | def : Pat<(setole R32FP:$rA, R32FP:$rB), |
| 3820 | (XORIr32 (FCGTf32 R32FP:$rA, R32FP:$rB), 0xffffffff)>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 3821 | |
| 3822 | // FP Status and Control Register Write |
| 3823 | // Why isn't rT a don't care in the ISA? |
| 3824 | // Should we create a special RRForm_3 for this guy and zero out the rT? |
| 3825 | def FSCRWf32 : |
| 3826 | RRForm_1<0b01011101110, (outs R32FP:$rT), (ins R32FP:$rA), |
| 3827 | "fscrwr\t$rA", SPrecFP, |
| 3828 | [/* This instruction requires an intrinsic. Note: rT is unused. */]>; |
| 3829 | |
| 3830 | // FP Status and Control Register Read |
| 3831 | def FSCRRf32 : |
| 3832 | RRForm_2<0b01011101110, (outs R32FP:$rT), (ins), |
| 3833 | "fscrrd\t$rT", SPrecFP, |
| 3834 | [/* This instruction requires an intrinsic */]>; |
| 3835 | |
| 3836 | // llvm instruction space |
| 3837 | // How do these map onto cell instructions? |
| 3838 | // fdiv rA rB |
| 3839 | // frest rC rB # c = 1/b (both lines) |
| 3840 | // fi rC rB rC |
| 3841 | // fm rD rA rC # d = a * 1/b |
| 3842 | // fnms rB rD rB rA # b = - (d * b - a) --should == 0 in a perfect world |
| 3843 | // fma rB rB rC rD # b = b * c + d |
| 3844 | // = -(d *b -a) * c + d |
| 3845 | // = a * c - c ( a *b *c - a) |
| 3846 | |
| 3847 | // fcopysign (???) |
| 3848 | |
| 3849 | // Library calls: |
| 3850 | // These llvm instructions will actually map to library calls. |
| 3851 | // All that's needed, then, is to check that the appropriate library is |
| 3852 | // imported and do a brsl to the proper function name. |
| 3853 | // frem # fmod(x, y): x - (x/y) * y |
| 3854 | // (Note: fmod(double, double), fmodf(float,float) |
| 3855 | // fsqrt? |
| 3856 | // fsin? |
| 3857 | // fcos? |
| 3858 | // Unimplemented SPU instruction space |
| 3859 | // floating reciprocal absolute square root estimate (frsqest) |
| 3860 | |
| 3861 | // The following are probably just intrinsics |
Scott Michel | 06eabde | 2008-12-27 04:51:36 +0000 | [diff] [blame^] | 3862 | // status and control register write |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 3863 | // status and control register read |
| 3864 | |
| 3865 | //-------------------------------------- |
| 3866 | // Floating point multiply instructions |
| 3867 | //-------------------------------------- |
| 3868 | |
| 3869 | def FMv4f32: |
| 3870 | RRForm<0b00100011010, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB), |
| 3871 | "fm\t$rT, $rA, $rB", SPrecFP, |
| 3872 | [(set (v4f32 VECREG:$rT), (fmul (v4f32 VECREG:$rA), |
| 3873 | (v4f32 VECREG:$rB)))]>; |
| 3874 | |
| 3875 | def FMf32 : |
| 3876 | RRForm<0b01100011010, (outs R32FP:$rT), (ins R32FP:$rA, R32FP:$rB), |
| 3877 | "fm\t$rT, $rA, $rB", SPrecFP, |
| 3878 | [(set R32FP:$rT, (fmul R32FP:$rA, R32FP:$rB))]>; |
| 3879 | |
| 3880 | // Floating point multiply and add |
| 3881 | // e.g. d = c + (a * b) |
| 3882 | def FMAv4f32: |
| 3883 | RRRForm<0b0111, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB, VECREG:$rC), |
| 3884 | "fma\t$rT, $rA, $rB, $rC", SPrecFP, |
| 3885 | [(set (v4f32 VECREG:$rT), |
| 3886 | (fadd (v4f32 VECREG:$rC), |
| 3887 | (fmul (v4f32 VECREG:$rA), (v4f32 VECREG:$rB))))]>; |
| 3888 | |
| 3889 | def FMAf32: |
| 3890 | RRRForm<0b0111, (outs R32FP:$rT), (ins R32FP:$rA, R32FP:$rB, R32FP:$rC), |
| 3891 | "fma\t$rT, $rA, $rB, $rC", SPrecFP, |
| 3892 | [(set R32FP:$rT, (fadd R32FP:$rC, (fmul R32FP:$rA, R32FP:$rB)))]>; |
| 3893 | |
| 3894 | // FP multiply and subtract |
| 3895 | // Subtracts value in rC from product |
| 3896 | // res = a * b - c |
| 3897 | def FMSv4f32 : |
| 3898 | RRRForm<0b0111, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB, VECREG:$rC), |
| 3899 | "fms\t$rT, $rA, $rB, $rC", SPrecFP, |
| 3900 | [(set (v4f32 VECREG:$rT), |
| 3901 | (fsub (fmul (v4f32 VECREG:$rA), (v4f32 VECREG:$rB)), |
| 3902 | (v4f32 VECREG:$rC)))]>; |
| 3903 | |
| 3904 | def FMSf32 : |
| 3905 | RRRForm<0b0111, (outs R32FP:$rT), (ins R32FP:$rA, R32FP:$rB, R32FP:$rC), |
| 3906 | "fms\t$rT, $rA, $rB, $rC", SPrecFP, |
| 3907 | [(set R32FP:$rT, |
| 3908 | (fsub (fmul R32FP:$rA, R32FP:$rB), R32FP:$rC))]>; |
| 3909 | |
| 3910 | // Floating Negative Mulitply and Subtract |
| 3911 | // Subtracts product from value in rC |
| 3912 | // res = fneg(fms a b c) |
| 3913 | // = - (a * b - c) |
| 3914 | // = c - a * b |
| 3915 | // NOTE: subtraction order |
| 3916 | // fsub a b = a - b |
Scott Michel | 06eabde | 2008-12-27 04:51:36 +0000 | [diff] [blame^] | 3917 | // fs a b = b - a? |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 3918 | def FNMSf32 : |
| 3919 | RRRForm<0b1101, (outs R32FP:$rT), (ins R32FP:$rA, R32FP:$rB, R32FP:$rC), |
| 3920 | "fnms\t$rT, $rA, $rB, $rC", SPrecFP, |
| 3921 | [(set R32FP:$rT, (fsub R32FP:$rC, (fmul R32FP:$rA, R32FP:$rB)))]>; |
| 3922 | |
| 3923 | def FNMSv4f32 : |
| 3924 | RRRForm<0b1101, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB, VECREG:$rC), |
| 3925 | "fnms\t$rT, $rA, $rB, $rC", SPrecFP, |
Scott Michel | 06eabde | 2008-12-27 04:51:36 +0000 | [diff] [blame^] | 3926 | [(set (v4f32 VECREG:$rT), |
| 3927 | (fsub (v4f32 VECREG:$rC), |
| 3928 | (fmul (v4f32 VECREG:$rA), |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 3929 | (v4f32 VECREG:$rB))))]>; |
| 3930 | |
| 3931 | //-------------------------------------- |
| 3932 | // Floating Point Conversions |
| 3933 | // Signed conversions: |
| 3934 | def CSiFv4f32: |
| 3935 | CVTIntFPForm<0b0101101110, (outs VECREG:$rT), (ins VECREG:$rA), |
| 3936 | "csflt\t$rT, $rA, 0", SPrecFP, |
| 3937 | [(set (v4f32 VECREG:$rT), (sint_to_fp (v4i32 VECREG:$rA)))]>; |
| 3938 | |
Scott Michel | 06eabde | 2008-12-27 04:51:36 +0000 | [diff] [blame^] | 3939 | // Convert signed integer to floating point |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 3940 | def CSiFf32 : |
| 3941 | CVTIntFPForm<0b0101101110, (outs R32FP:$rT), (ins R32C:$rA), |
| 3942 | "csflt\t$rT, $rA, 0", SPrecFP, |
| 3943 | [(set R32FP:$rT, (sint_to_fp R32C:$rA))]>; |
| 3944 | |
| 3945 | // Convert unsigned into to float |
| 3946 | def CUiFv4f32 : |
| 3947 | CVTIntFPForm<0b1101101110, (outs VECREG:$rT), (ins VECREG:$rA), |
| 3948 | "cuflt\t$rT, $rA, 0", SPrecFP, |
| 3949 | [(set (v4f32 VECREG:$rT), (uint_to_fp (v4i32 VECREG:$rA)))]>; |
| 3950 | |
| 3951 | def CUiFf32 : |
| 3952 | CVTIntFPForm<0b1101101110, (outs R32FP:$rT), (ins R32C:$rA), |
| 3953 | "cuflt\t$rT, $rA, 0", SPrecFP, |
| 3954 | [(set R32FP:$rT, (uint_to_fp R32C:$rA))]>; |
| 3955 | |
Scott Michel | 06eabde | 2008-12-27 04:51:36 +0000 | [diff] [blame^] | 3956 | // Convert float to unsigned int |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 3957 | // Assume that scale = 0 |
| 3958 | |
| 3959 | def CFUiv4f32 : |
| 3960 | CVTIntFPForm<0b1101101110, (outs VECREG:$rT), (ins VECREG:$rA), |
| 3961 | "cfltu\t$rT, $rA, 0", SPrecFP, |
| 3962 | [(set (v4i32 VECREG:$rT), (fp_to_uint (v4f32 VECREG:$rA)))]>; |
| 3963 | |
| 3964 | def CFUif32 : |
| 3965 | CVTIntFPForm<0b1101101110, (outs R32C:$rT), (ins R32FP:$rA), |
| 3966 | "cfltu\t$rT, $rA, 0", SPrecFP, |
| 3967 | [(set R32C:$rT, (fp_to_uint R32FP:$rA))]>; |
| 3968 | |
Scott Michel | 06eabde | 2008-12-27 04:51:36 +0000 | [diff] [blame^] | 3969 | // Convert float to signed int |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 3970 | // Assume that scale = 0 |
| 3971 | |
| 3972 | def CFSiv4f32 : |
| 3973 | CVTIntFPForm<0b1101101110, (outs VECREG:$rT), (ins VECREG:$rA), |
| 3974 | "cflts\t$rT, $rA, 0", SPrecFP, |
| 3975 | [(set (v4i32 VECREG:$rT), (fp_to_sint (v4f32 VECREG:$rA)))]>; |
| 3976 | |
| 3977 | def CFSif32 : |
| 3978 | CVTIntFPForm<0b1101101110, (outs R32C:$rT), (ins R32FP:$rA), |
| 3979 | "cflts\t$rT, $rA, 0", SPrecFP, |
| 3980 | [(set R32C:$rT, (fp_to_sint R32FP:$rA))]>; |
| 3981 | |
| 3982 | //===----------------------------------------------------------------------==// |
| 3983 | // Single<->Double precision conversions |
| 3984 | //===----------------------------------------------------------------------==// |
| 3985 | |
| 3986 | // NOTE: We use "vec" name suffix here to avoid confusion (e.g. input is a |
| 3987 | // v4f32, output is v2f64--which goes in the name?) |
| 3988 | |
| 3989 | // Floating point extend single to double |
| 3990 | // NOTE: Not sure if passing in v4f32 to FESDvec is correct since it |
| 3991 | // operates on two double-word slots (i.e. 1st and 3rd fp numbers |
| 3992 | // are ignored). |
| 3993 | def FESDvec : |
| 3994 | RRForm_1<0b00011101110, (outs VECREG:$rT), (ins VECREG:$rA), |
| 3995 | "fesd\t$rT, $rA", SPrecFP, |
| 3996 | [(set (v2f64 VECREG:$rT), (fextend (v4f32 VECREG:$rA)))]>; |
| 3997 | |
| 3998 | def FESDf32 : |
| 3999 | RRForm_1<0b00011101110, (outs R64FP:$rT), (ins R32FP:$rA), |
| 4000 | "fesd\t$rT, $rA", SPrecFP, |
| 4001 | [(set R64FP:$rT, (fextend R32FP:$rA))]>; |
| 4002 | |
| 4003 | // Floating point round double to single |
| 4004 | //def FRDSvec : |
| 4005 | // RRForm_1<0b10011101110, (outs VECREG:$rT), (ins VECREG:$rA), |
| 4006 | // "frds\t$rT, $rA,", SPrecFP, |
| 4007 | // [(set (v4f32 R32FP:$rT), (fround (v2f64 R64FP:$rA)))]>; |
| 4008 | |
| 4009 | def FRDSf64 : |
| 4010 | RRForm_1<0b10011101110, (outs R32FP:$rT), (ins R64FP:$rA), |
| 4011 | "frds\t$rT, $rA", SPrecFP, |
| 4012 | [(set R32FP:$rT, (fround R64FP:$rA))]>; |
| 4013 | |
| 4014 | //ToDo include anyextend? |
| 4015 | |
| 4016 | //===----------------------------------------------------------------------==// |
| 4017 | // Double precision floating point instructions |
| 4018 | //===----------------------------------------------------------------------==// |
| 4019 | def FAf64 : |
| 4020 | RRForm<0b00110011010, (outs R64FP:$rT), (ins R64FP:$rA, R64FP:$rB), |
| 4021 | "dfa\t$rT, $rA, $rB", DPrecFP, |
| 4022 | [(set R64FP:$rT, (fadd R64FP:$rA, R64FP:$rB))]>; |
| 4023 | |
| 4024 | def FAv2f64 : |
| 4025 | RRForm<0b00110011010, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB), |
| 4026 | "dfa\t$rT, $rA, $rB", DPrecFP, |
| 4027 | [(set (v2f64 VECREG:$rT), (fadd (v2f64 VECREG:$rA), (v2f64 VECREG:$rB)))]>; |
| 4028 | |
| 4029 | def FSf64 : |
| 4030 | RRForm<0b10100011010, (outs R64FP:$rT), (ins R64FP:$rA, R64FP:$rB), |
| 4031 | "dfs\t$rT, $rA, $rB", DPrecFP, |
| 4032 | [(set R64FP:$rT, (fsub R64FP:$rA, R64FP:$rB))]>; |
| 4033 | |
| 4034 | def FSv2f64 : |
| 4035 | RRForm<0b10100011010, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB), |
| 4036 | "dfs\t$rT, $rA, $rB", DPrecFP, |
| 4037 | [(set (v2f64 VECREG:$rT), |
| 4038 | (fsub (v2f64 VECREG:$rA), (v2f64 VECREG:$rB)))]>; |
| 4039 | |
| 4040 | def FMf64 : |
| 4041 | RRForm<0b01100011010, (outs R64FP:$rT), (ins R64FP:$rA, R64FP:$rB), |
| 4042 | "dfm\t$rT, $rA, $rB", DPrecFP, |
| 4043 | [(set R64FP:$rT, (fmul R64FP:$rA, R64FP:$rB))]>; |
| 4044 | |
| 4045 | def FMv2f64: |
| 4046 | RRForm<0b00100011010, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB), |
| 4047 | "dfm\t$rT, $rA, $rB", DPrecFP, |
| 4048 | [(set (v2f64 VECREG:$rT), |
| 4049 | (fmul (v2f64 VECREG:$rA), (v2f64 VECREG:$rB)))]>; |
| 4050 | |
| 4051 | def FMAf64: |
| 4052 | RRForm<0b00111010110, (outs R64FP:$rT), |
| 4053 | (ins R64FP:$rA, R64FP:$rB, R64FP:$rC), |
| 4054 | "dfma\t$rT, $rA, $rB", DPrecFP, |
| 4055 | [(set R64FP:$rT, (fadd R64FP:$rC, (fmul R64FP:$rA, R64FP:$rB)))]>, |
| 4056 | RegConstraint<"$rC = $rT">, |
| 4057 | NoEncode<"$rC">; |
| 4058 | |
| 4059 | def FMAv2f64: |
| 4060 | RRForm<0b00111010110, (outs VECREG:$rT), |
| 4061 | (ins VECREG:$rA, VECREG:$rB, VECREG:$rC), |
| 4062 | "dfma\t$rT, $rA, $rB", DPrecFP, |
| 4063 | [(set (v2f64 VECREG:$rT), |
| 4064 | (fadd (v2f64 VECREG:$rC), |
| 4065 | (fmul (v2f64 VECREG:$rA), (v2f64 VECREG:$rB))))]>, |
| 4066 | RegConstraint<"$rC = $rT">, |
| 4067 | NoEncode<"$rC">; |
| 4068 | |
| 4069 | def FMSf64 : |
| 4070 | RRForm<0b10111010110, (outs R64FP:$rT), |
| 4071 | (ins R64FP:$rA, R64FP:$rB, R64FP:$rC), |
| 4072 | "dfms\t$rT, $rA, $rB", DPrecFP, |
| 4073 | [(set R64FP:$rT, (fsub (fmul R64FP:$rA, R64FP:$rB), R64FP:$rC))]>, |
| 4074 | RegConstraint<"$rC = $rT">, |
| 4075 | NoEncode<"$rC">; |
| 4076 | |
| 4077 | def FMSv2f64 : |
| 4078 | RRForm<0b10111010110, (outs VECREG:$rT), |
| 4079 | (ins VECREG:$rA, VECREG:$rB, VECREG:$rC), |
| 4080 | "dfms\t$rT, $rA, $rB", DPrecFP, |
| 4081 | [(set (v2f64 VECREG:$rT), |
| 4082 | (fsub (fmul (v2f64 VECREG:$rA), (v2f64 VECREG:$rB)), |
| 4083 | (v2f64 VECREG:$rC)))]>; |
| 4084 | |
| 4085 | // FNMS: - (a * b - c) |
| 4086 | // - (a * b) + c => c - (a * b) |
| 4087 | def FNMSf64 : |
| 4088 | RRForm<0b01111010110, (outs R64FP:$rT), |
| 4089 | (ins R64FP:$rA, R64FP:$rB, R64FP:$rC), |
| 4090 | "dfnms\t$rT, $rA, $rB", DPrecFP, |
| 4091 | [(set R64FP:$rT, (fsub R64FP:$rC, (fmul R64FP:$rA, R64FP:$rB)))]>, |
| 4092 | RegConstraint<"$rC = $rT">, |
| 4093 | NoEncode<"$rC">; |
| 4094 | |
| 4095 | def : Pat<(fneg (fsub (fmul R64FP:$rA, R64FP:$rB), R64FP:$rC)), |
| 4096 | (FNMSf64 R64FP:$rA, R64FP:$rB, R64FP:$rC)>; |
| 4097 | |
| 4098 | def FNMSv2f64 : |
| 4099 | RRForm<0b01111010110, (outs VECREG:$rT), |
| 4100 | (ins VECREG:$rA, VECREG:$rB, VECREG:$rC), |
| 4101 | "dfnms\t$rT, $rA, $rB", DPrecFP, |
Scott Michel | 06eabde | 2008-12-27 04:51:36 +0000 | [diff] [blame^] | 4102 | [(set (v2f64 VECREG:$rT), |
| 4103 | (fsub (v2f64 VECREG:$rC), |
| 4104 | (fmul (v2f64 VECREG:$rA), |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 4105 | (v2f64 VECREG:$rB))))]>, |
| 4106 | RegConstraint<"$rC = $rT">, |
| 4107 | NoEncode<"$rC">; |
| 4108 | |
| 4109 | def : Pat<(fneg (fsub (fmul (v2f64 VECREG:$rA), (v2f64 VECREG:$rB)), |
| 4110 | (v2f64 VECREG:$rC))), |
| 4111 | (FNMSv2f64 VECREG:$rA, VECREG:$rB, VECREG:$rC)>; |
| 4112 | |
| 4113 | // - (a * b + c) |
| 4114 | // - (a * b) - c |
| 4115 | def FNMAf64 : |
| 4116 | RRForm<0b11111010110, (outs R64FP:$rT), |
| 4117 | (ins R64FP:$rA, R64FP:$rB, R64FP:$rC), |
| 4118 | "dfnma\t$rT, $rA, $rB", DPrecFP, |
| 4119 | [(set R64FP:$rT, (fneg (fadd R64FP:$rC, (fmul R64FP:$rA, R64FP:$rB))))]>, |
| 4120 | RegConstraint<"$rC = $rT">, |
| 4121 | NoEncode<"$rC">; |
| 4122 | |
| 4123 | def FNMAv2f64 : |
| 4124 | RRForm<0b11111010110, (outs VECREG:$rT), |
| 4125 | (ins VECREG:$rA, VECREG:$rB, VECREG:$rC), |
| 4126 | "dfnma\t$rT, $rA, $rB", DPrecFP, |
Scott Michel | 06eabde | 2008-12-27 04:51:36 +0000 | [diff] [blame^] | 4127 | [(set (v2f64 VECREG:$rT), |
| 4128 | (fneg (fadd (v2f64 VECREG:$rC), |
| 4129 | (fmul (v2f64 VECREG:$rA), |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 4130 | (v2f64 VECREG:$rB)))))]>, |
| 4131 | RegConstraint<"$rC = $rT">, |
| 4132 | NoEncode<"$rC">; |
| 4133 | |
| 4134 | //===----------------------------------------------------------------------==// |
| 4135 | // Floating point negation and absolute value |
| 4136 | //===----------------------------------------------------------------------==// |
| 4137 | |
| 4138 | def : Pat<(fneg (v4f32 VECREG:$rA)), |
Scott Michel | 06eabde | 2008-12-27 04:51:36 +0000 | [diff] [blame^] | 4139 | (XORfnegvec (v4f32 VECREG:$rA), |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 4140 | (v4f32 (ILHUv4i32 0x8000)))>; |
| 4141 | |
| 4142 | def : Pat<(fneg R32FP:$rA), |
| 4143 | (XORfneg32 R32FP:$rA, (ILHUr32 0x8000))>; |
| 4144 | |
| 4145 | def : Pat<(fneg (v2f64 VECREG:$rA)), |
| 4146 | (XORfnegvec (v2f64 VECREG:$rA), |
| 4147 | (v2f64 (ANDBIv16i8 (FSMBIv16i8 0x8080), 0x80)))>; |
| 4148 | |
| 4149 | def : Pat<(fneg R64FP:$rA), |
| 4150 | (XORfneg64 R64FP:$rA, |
| 4151 | (ANDBIv16i8 (FSMBIv16i8 0x8080), 0x80))>; |
| 4152 | |
| 4153 | // Floating point absolute value |
| 4154 | |
| 4155 | def : Pat<(fabs R32FP:$rA), |
| 4156 | (ANDfabs32 R32FP:$rA, (IOHLr32 (ILHUr32 0x7fff), 0xffff))>; |
| 4157 | |
| 4158 | def : Pat<(fabs (v4f32 VECREG:$rA)), |
| 4159 | (ANDfabsvec (v4f32 VECREG:$rA), |
| 4160 | (v4f32 (ANDBIv16i8 (FSMBIv16i8 0xffff), 0x7f)))>; |
| 4161 | |
| 4162 | def : Pat<(fabs R64FP:$rA), |
| 4163 | (ANDfabs64 R64FP:$rA, (ANDBIv16i8 (FSMBIv16i8 0xffff), 0x7f))>; |
| 4164 | |
| 4165 | def : Pat<(fabs (v2f64 VECREG:$rA)), |
| 4166 | (ANDfabsvec (v2f64 VECREG:$rA), |
| 4167 | (v2f64 (ANDBIv16i8 (FSMBIv16i8 0xffff), 0x7f)))>; |
| 4168 | |
| 4169 | //===----------------------------------------------------------------------===// |
Scott Michel | 61895fe | 2008-12-10 00:15:19 +0000 | [diff] [blame] | 4170 | // Hint for branch instructions: |
| 4171 | //===----------------------------------------------------------------------===// |
| 4172 | |
| 4173 | /* def HBR : SPUInstr<(outs), (ins), "hbr\t" */ |
| 4174 | |
| 4175 | //===----------------------------------------------------------------------===// |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 4176 | // Execution, Load NOP (execute NOPs belong in even pipeline, load NOPs belong |
| 4177 | // in the odd pipeline) |
| 4178 | //===----------------------------------------------------------------------===// |
| 4179 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 4180 | def ENOP : SPUInstr<(outs), (ins), "enop", ExecNOP> { |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 4181 | let Pattern = []; |
| 4182 | |
| 4183 | let Inst{0-10} = 0b10000000010; |
| 4184 | let Inst{11-17} = 0; |
| 4185 | let Inst{18-24} = 0; |
| 4186 | let Inst{25-31} = 0; |
| 4187 | } |
| 4188 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 4189 | def LNOP : SPUInstr<(outs), (ins), "lnop", LoadNOP> { |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 4190 | let Pattern = []; |
| 4191 | |
| 4192 | let Inst{0-10} = 0b10000000000; |
| 4193 | let Inst{11-17} = 0; |
| 4194 | let Inst{18-24} = 0; |
| 4195 | let Inst{25-31} = 0; |
| 4196 | } |
| 4197 | |
| 4198 | //===----------------------------------------------------------------------===// |
| 4199 | // Bit conversions (type conversions between vector/packed types) |
| 4200 | // NOTE: Promotions are handled using the XS* instructions. Truncation |
| 4201 | // is not handled. |
| 4202 | //===----------------------------------------------------------------------===// |
| 4203 | def : Pat<(v16i8 (bitconvert (v8i16 VECREG:$src))), (v16i8 VECREG:$src)>; |
| 4204 | def : Pat<(v16i8 (bitconvert (v4i32 VECREG:$src))), (v16i8 VECREG:$src)>; |
| 4205 | def : Pat<(v16i8 (bitconvert (v2i64 VECREG:$src))), (v16i8 VECREG:$src)>; |
| 4206 | def : Pat<(v16i8 (bitconvert (v4f32 VECREG:$src))), (v16i8 VECREG:$src)>; |
| 4207 | def : Pat<(v16i8 (bitconvert (v2f64 VECREG:$src))), (v16i8 VECREG:$src)>; |
| 4208 | |
| 4209 | def : Pat<(v8i16 (bitconvert (v16i8 VECREG:$src))), (v8i16 VECREG:$src)>; |
| 4210 | def : Pat<(v8i16 (bitconvert (v4i32 VECREG:$src))), (v8i16 VECREG:$src)>; |
| 4211 | def : Pat<(v8i16 (bitconvert (v2i64 VECREG:$src))), (v8i16 VECREG:$src)>; |
| 4212 | def : Pat<(v8i16 (bitconvert (v4f32 VECREG:$src))), (v8i16 VECREG:$src)>; |
| 4213 | def : Pat<(v8i16 (bitconvert (v2f64 VECREG:$src))), (v8i16 VECREG:$src)>; |
| 4214 | |
| 4215 | def : Pat<(v4i32 (bitconvert (v16i8 VECREG:$src))), (v4i32 VECREG:$src)>; |
| 4216 | def : Pat<(v4i32 (bitconvert (v8i16 VECREG:$src))), (v4i32 VECREG:$src)>; |
| 4217 | def : Pat<(v4i32 (bitconvert (v2i64 VECREG:$src))), (v4i32 VECREG:$src)>; |
| 4218 | def : Pat<(v4i32 (bitconvert (v4f32 VECREG:$src))), (v4i32 VECREG:$src)>; |
| 4219 | def : Pat<(v4i32 (bitconvert (v2f64 VECREG:$src))), (v4i32 VECREG:$src)>; |
| 4220 | |
| 4221 | def : Pat<(v2i64 (bitconvert (v16i8 VECREG:$src))), (v2i64 VECREG:$src)>; |
| 4222 | def : Pat<(v2i64 (bitconvert (v8i16 VECREG:$src))), (v2i64 VECREG:$src)>; |
| 4223 | def : Pat<(v2i64 (bitconvert (v4i32 VECREG:$src))), (v2i64 VECREG:$src)>; |
| 4224 | def : Pat<(v2i64 (bitconvert (v4f32 VECREG:$src))), (v2i64 VECREG:$src)>; |
| 4225 | def : Pat<(v2i64 (bitconvert (v2f64 VECREG:$src))), (v2i64 VECREG:$src)>; |
| 4226 | |
| 4227 | def : Pat<(v4f32 (bitconvert (v16i8 VECREG:$src))), (v4f32 VECREG:$src)>; |
| 4228 | def : Pat<(v4f32 (bitconvert (v8i16 VECREG:$src))), (v4f32 VECREG:$src)>; |
| 4229 | def : Pat<(v4f32 (bitconvert (v2i64 VECREG:$src))), (v4f32 VECREG:$src)>; |
| 4230 | def : Pat<(v4f32 (bitconvert (v4i32 VECREG:$src))), (v4f32 VECREG:$src)>; |
| 4231 | def : Pat<(v4f32 (bitconvert (v2f64 VECREG:$src))), (v4f32 VECREG:$src)>; |
| 4232 | |
| 4233 | def : Pat<(v2f64 (bitconvert (v16i8 VECREG:$src))), (v2f64 VECREG:$src)>; |
| 4234 | def : Pat<(v2f64 (bitconvert (v8i16 VECREG:$src))), (v2f64 VECREG:$src)>; |
| 4235 | def : Pat<(v2f64 (bitconvert (v4i32 VECREG:$src))), (v2f64 VECREG:$src)>; |
| 4236 | def : Pat<(v2f64 (bitconvert (v2i64 VECREG:$src))), (v2f64 VECREG:$src)>; |
| 4237 | def : Pat<(v2f64 (bitconvert (v2f64 VECREG:$src))), (v2f64 VECREG:$src)>; |
| 4238 | |
| 4239 | def : Pat<(f32 (bitconvert (i32 R32C:$src))), (f32 R32FP:$src)>; |
Scott Michel | 754d866 | 2007-12-20 00:44:13 +0000 | [diff] [blame] | 4240 | def : Pat<(f64 (bitconvert (i64 R64C:$src))), (f64 R64FP:$src)>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 4241 | |
| 4242 | //===----------------------------------------------------------------------===// |
| 4243 | // Instruction patterns: |
| 4244 | //===----------------------------------------------------------------------===// |
| 4245 | |
| 4246 | // General 32-bit constants: |
| 4247 | def : Pat<(i32 imm:$imm), |
| 4248 | (IOHLr32 (ILHUr32 (HI16 imm:$imm)), (LO16 imm:$imm))>; |
| 4249 | |
| 4250 | // Single precision float constants: |
Nate Begeman | 7812504 | 2008-02-14 18:43:04 +0000 | [diff] [blame] | 4251 | def : Pat<(f32 fpimm:$imm), |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 4252 | (IOHLf32 (ILHUf32 (HI16_f32 fpimm:$imm)), (LO16_f32 fpimm:$imm))>; |
| 4253 | |
| 4254 | // General constant 32-bit vectors |
| 4255 | def : Pat<(v4i32 v4i32Imm:$imm), |
Scott Michel | 6baba07 | 2008-03-05 23:02:02 +0000 | [diff] [blame] | 4256 | (IOHLv4i32 (v4i32 (ILHUv4i32 (HI16_vec v4i32Imm:$imm))), |
| 4257 | (LO16_vec v4i32Imm:$imm))>; |
Scott Michel | 06eabde | 2008-12-27 04:51:36 +0000 | [diff] [blame^] | 4258 | |
Scott Michel | 438be25 | 2007-12-17 22:32:34 +0000 | [diff] [blame] | 4259 | // 8-bit constants |
| 4260 | def : Pat<(i8 imm:$imm), |
| 4261 | (ILHr8 imm:$imm)>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 4262 | |
| 4263 | //===----------------------------------------------------------------------===// |
| 4264 | // Call instruction patterns: |
| 4265 | //===----------------------------------------------------------------------===// |
| 4266 | // Return void |
| 4267 | def : Pat<(ret), |
| 4268 | (RET)>; |
| 4269 | |
| 4270 | //===----------------------------------------------------------------------===// |
| 4271 | // Zero/Any/Sign extensions |
| 4272 | //===----------------------------------------------------------------------===// |
| 4273 | |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 4274 | // sext 8->32: Sign extend bytes to words |
| 4275 | def : Pat<(sext_inreg R32C:$rSrc, i8), |
| 4276 | (XSHWr32 (XSBHr32 R32C:$rSrc))>; |
| 4277 | |
Scott Michel | 438be25 | 2007-12-17 22:32:34 +0000 | [diff] [blame] | 4278 | def : Pat<(i32 (sext R8C:$rSrc)), |
| 4279 | (XSHWr16 (XSBHr8 R8C:$rSrc))>; |
| 4280 | |
Scott Michel | 438be25 | 2007-12-17 22:32:34 +0000 | [diff] [blame] | 4281 | // zext 8->16: Zero extend bytes to halfwords |
| 4282 | def : Pat<(i16 (zext R8C:$rSrc)), |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 4283 | (ANDHIi8i16 R8C:$rSrc, 0xff)>; |
Scott Michel | 438be25 | 2007-12-17 22:32:34 +0000 | [diff] [blame] | 4284 | |
Scott Michel | 438be25 | 2007-12-17 22:32:34 +0000 | [diff] [blame] | 4285 | // zext 8->32: Zero extend bytes to words |
| 4286 | def : Pat<(i32 (zext R8C:$rSrc)), |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 4287 | (ANDIi8i32 R8C:$rSrc, 0xff)>; |
Scott Michel | 438be25 | 2007-12-17 22:32:34 +0000 | [diff] [blame] | 4288 | |
| 4289 | // anyext 8->16: Extend 8->16 bits, irrespective of sign |
| 4290 | def : Pat<(i16 (anyext R8C:$rSrc)), |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 4291 | (ORHIi8i16 R8C:$rSrc, 0)>; |
Scott Michel | 438be25 | 2007-12-17 22:32:34 +0000 | [diff] [blame] | 4292 | |
| 4293 | // anyext 8->32: Extend 8->32 bits, irrespective of sign |
| 4294 | def : Pat<(i32 (anyext R8C:$rSrc)), |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 4295 | (ORIi8i32 R8C:$rSrc, 0)>; |
Scott Michel | 438be25 | 2007-12-17 22:32:34 +0000 | [diff] [blame] | 4296 | |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 4297 | // zext 16->32: Zero extend halfwords to words |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 4298 | def : Pat<(i32 (zext R16C:$rSrc)), |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 4299 | (ANDi16i32 R16C:$rSrc, (ILAr32 0xffff))>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 4300 | |
| 4301 | def : Pat<(i32 (zext (and R16C:$rSrc, 0xf))), |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 4302 | (ANDIi16i32 R16C:$rSrc, 0xf)>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 4303 | |
| 4304 | def : Pat<(i32 (zext (and R16C:$rSrc, 0xff))), |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 4305 | (ANDIi16i32 R16C:$rSrc, 0xff)>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 4306 | |
| 4307 | def : Pat<(i32 (zext (and R16C:$rSrc, 0xfff))), |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 4308 | (ANDIi16i32 R16C:$rSrc, 0xfff)>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 4309 | |
| 4310 | // anyext 16->32: Extend 16->32 bits, irrespective of sign |
| 4311 | def : Pat<(i32 (anyext R16C:$rSrc)), |
Scott Michel | 97872d3 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 4312 | (ORIi16i32 R16C:$rSrc, 0)>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 4313 | |
| 4314 | //===----------------------------------------------------------------------===// |
Scott Michel | 06eabde | 2008-12-27 04:51:36 +0000 | [diff] [blame^] | 4315 | // Truncates: |
| 4316 | // These truncates are for the SPU's supported types (i8, i16, i32). i64 and |
| 4317 | // above are custom lowered. |
| 4318 | //===----------------------------------------------------------------------===// |
| 4319 | |
| 4320 | def : Pat<(i8 (trunc GPRC:$src)), |
| 4321 | (ORi8_v16i8 |
| 4322 | (SHUFBgprc GPRC:$src, GPRC:$src, |
| 4323 | (IOHLv4i32 (ILHUv4i32 0x0f0f), 0x0f0f)))>; |
| 4324 | |
| 4325 | def : Pat<(i8 (trunc R64C:$src)), |
| 4326 | (ORi8_v16i8 |
| 4327 | (SHUFBv2i64_m32 |
| 4328 | (ORv2i64_i64 R64C:$src), |
| 4329 | (ORv2i64_i64 R64C:$src), |
| 4330 | (IOHLv4i32 (ILHUv4i32 0x0707), 0x0707)))>; |
| 4331 | |
| 4332 | def : Pat<(i8 (trunc R32C:$src)), |
| 4333 | (ORi8_v16i8 |
| 4334 | (SHUFBv4i32_m32 |
| 4335 | (ORv4i32_i32 R32C:$src), |
| 4336 | (ORv4i32_i32 R32C:$src), |
| 4337 | (IOHLv4i32 (ILHUv4i32 0x0303), 0x0303)))>; |
| 4338 | |
| 4339 | def : Pat<(i8 (trunc R16C:$src)), |
| 4340 | (ORi8_v16i8 |
| 4341 | (SHUFBv4i32_m32 |
| 4342 | (ORv8i16_i16 R16C:$src), |
| 4343 | (ORv8i16_i16 R16C:$src), |
| 4344 | (IOHLv4i32 (ILHUv4i32 0x0303), 0x0303)))>; |
| 4345 | |
| 4346 | def : Pat<(i16 (trunc GPRC:$src)), |
| 4347 | (ORi16_v8i16 |
| 4348 | (SHUFBgprc GPRC:$src, GPRC:$src, |
| 4349 | (IOHLv4i32 (ILHUv4i32 0x0e0f), 0x0e0f)))>; |
| 4350 | |
| 4351 | def : Pat<(i16 (trunc R64C:$src)), |
| 4352 | (ORi16_v8i16 |
| 4353 | (SHUFBv2i64_m32 |
| 4354 | (ORv2i64_i64 R64C:$src), |
| 4355 | (ORv2i64_i64 R64C:$src), |
| 4356 | (IOHLv4i32 (ILHUv4i32 0x0607), 0x0607)))>; |
| 4357 | |
| 4358 | def : Pat<(i16 (trunc R32C:$src)), |
| 4359 | (ORi16_v8i16 |
| 4360 | (SHUFBv4i32_m32 |
| 4361 | (ORv4i32_i32 R32C:$src), |
| 4362 | (ORv4i32_i32 R32C:$src), |
| 4363 | (IOHLv4i32 (ILHUv4i32 0x0203), 0x0203)))>; |
| 4364 | |
| 4365 | def : Pat<(i32 (trunc GPRC:$src)), |
| 4366 | (ORi32_v4i32 |
| 4367 | (SHUFBgprc GPRC:$src, GPRC:$src, |
| 4368 | (IOHLv4i32 (ILHUv4i32 0x0c0d), 0x0e0f)))>; |
| 4369 | |
| 4370 | def : Pat<(i32 (trunc R64C:$src)), |
| 4371 | (ORi32_v4i32 |
| 4372 | (SHUFBv2i64_m32 |
| 4373 | (ORv2i64_i64 R64C:$src), |
| 4374 | (ORv2i64_i64 R64C:$src), |
| 4375 | (IOHLv4i32 (ILHUv4i32 0x0405), 0x0607)))>; |
| 4376 | |
| 4377 | //===----------------------------------------------------------------------===// |
Scott Michel | f9f42e6 | 2008-01-29 02:16:57 +0000 | [diff] [blame] | 4378 | // Address generation: SPU, like PPC, has to split addresses into high and |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 4379 | // low parts in order to load them into a register. |
| 4380 | //===----------------------------------------------------------------------===// |
| 4381 | |
Scott Michel | f9f42e6 | 2008-01-29 02:16:57 +0000 | [diff] [blame] | 4382 | def : Pat<(SPUaform tglobaladdr:$in, 0), (ILAlsa tglobaladdr:$in)>; |
| 4383 | def : Pat<(SPUaform texternalsym:$in, 0), (ILAlsa texternalsym:$in)>; |
| 4384 | def : Pat<(SPUaform tjumptable:$in, 0), (ILAlsa tjumptable:$in)>; |
| 4385 | def : Pat<(SPUaform tconstpool:$in, 0), (ILAlsa tconstpool:$in)>; |
| 4386 | |
| 4387 | def : Pat<(SPUindirect (SPUhi tglobaladdr:$in, 0), |
| 4388 | (SPUlo tglobaladdr:$in, 0)), |
Scott Michel | dbac4cf | 2008-01-11 02:53:15 +0000 | [diff] [blame] | 4389 | (IOHLlo (ILHUhi tglobaladdr:$in), tglobaladdr:$in)>; |
Scott Michel | 394e26d | 2008-01-17 20:38:41 +0000 | [diff] [blame] | 4390 | |
Scott Michel | f9f42e6 | 2008-01-29 02:16:57 +0000 | [diff] [blame] | 4391 | def : Pat<(SPUindirect (SPUhi texternalsym:$in, 0), |
| 4392 | (SPUlo texternalsym:$in, 0)), |
| 4393 | (IOHLlo (ILHUhi texternalsym:$in), texternalsym:$in)>; |
| 4394 | |
| 4395 | def : Pat<(SPUindirect (SPUhi tjumptable:$in, 0), |
| 4396 | (SPUlo tjumptable:$in, 0)), |
Scott Michel | dbac4cf | 2008-01-11 02:53:15 +0000 | [diff] [blame] | 4397 | (IOHLlo (ILHUhi tjumptable:$in), tjumptable:$in)>; |
Scott Michel | 394e26d | 2008-01-17 20:38:41 +0000 | [diff] [blame] | 4398 | |
Scott Michel | f9f42e6 | 2008-01-29 02:16:57 +0000 | [diff] [blame] | 4399 | def : Pat<(SPUindirect (SPUhi tconstpool:$in, 0), |
| 4400 | (SPUlo tconstpool:$in, 0)), |
| 4401 | (IOHLlo (ILHUhi tconstpool:$in), tconstpool:$in)>; |
| 4402 | |
Scott Michel | bc5fbc1 | 2008-04-30 00:30:08 +0000 | [diff] [blame] | 4403 | def : Pat<(SPUindirect R32C:$sp, i32ImmSExt10:$imm), |
| 4404 | (AIr32 R32C:$sp, i32ImmSExt10:$imm)>; |
| 4405 | |
| 4406 | def : Pat<(SPUindirect R32C:$sp, imm:$imm), |
| 4407 | (Ar32 R32C:$sp, |
| 4408 | (IOHLr32 (ILHUr32 (HI16 imm:$imm)), (LO16 imm:$imm)))>; |
| 4409 | |
Scott Michel | f9f42e6 | 2008-01-29 02:16:57 +0000 | [diff] [blame] | 4410 | def : Pat<(add (SPUhi tglobaladdr:$in, 0), (SPUlo tglobaladdr:$in, 0)), |
| 4411 | (IOHLlo (ILHUhi tglobaladdr:$in), tglobaladdr:$in)>; |
| 4412 | |
| 4413 | def : Pat<(add (SPUhi texternalsym:$in, 0), (SPUlo texternalsym:$in, 0)), |
| 4414 | (IOHLlo (ILHUhi texternalsym:$in), texternalsym:$in)>; |
| 4415 | |
| 4416 | def : Pat<(add (SPUhi tjumptable:$in, 0), (SPUlo tjumptable:$in, 0)), |
| 4417 | (IOHLlo (ILHUhi tjumptable:$in), tjumptable:$in)>; |
| 4418 | |
| 4419 | def : Pat<(add (SPUhi tconstpool:$in, 0), (SPUlo tconstpool:$in, 0)), |
| 4420 | (IOHLlo (ILHUhi tconstpool:$in), tconstpool:$in)>; |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 4421 | |
Scott Michel | 8b6b420 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 4422 | // Instrinsics: |
| 4423 | include "CellSDKIntrinsics.td" |
Scott Michel | 06eabde | 2008-12-27 04:51:36 +0000 | [diff] [blame^] | 4424 | // 64-bit "instructions"/support |
| 4425 | include "SPU64InstrInfo.td" |