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