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