Rafael Espindola | b90c5f1 | 2012-11-21 16:56:33 +0000 | [diff] [blame] | 1 | //===- HexagonOperands.td - Hexagon immediate processing -*- tablegen -*-===// |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illnois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
Jyotsna Verma | 3ec3a49 | 2012-11-21 19:53:42 +0000 | [diff] [blame^] | 10 | // Immediate operands. |
| 11 | |
| 12 | let PrintMethod = "printImmOperand" in { |
| 13 | // f32Ext type is used to identify constant extended floating point immediates. |
| 14 | def f32Ext : Operand<f32>; |
| 15 | def s32Imm : Operand<i32>; |
| 16 | def s26_6Imm : Operand<i32>; |
| 17 | def s16Imm : Operand<i32>; |
| 18 | def s12Imm : Operand<i32>; |
| 19 | def s11Imm : Operand<i32>; |
| 20 | def s11_0Imm : Operand<i32>; |
| 21 | def s11_1Imm : Operand<i32>; |
| 22 | def s11_2Imm : Operand<i32>; |
| 23 | def s11_3Imm : Operand<i32>; |
| 24 | def s10Imm : Operand<i32>; |
| 25 | def s9Imm : Operand<i32>; |
| 26 | def m9Imm : Operand<i32>; |
| 27 | def s8Imm : Operand<i32>; |
| 28 | def s8Imm64 : Operand<i64>; |
| 29 | def s6Imm : Operand<i32>; |
| 30 | def s4Imm : Operand<i32>; |
| 31 | def s4_0Imm : Operand<i32>; |
| 32 | def s4_1Imm : Operand<i32>; |
| 33 | def s4_2Imm : Operand<i32>; |
| 34 | def s4_3Imm : Operand<i32>; |
| 35 | def u64Imm : Operand<i64>; |
| 36 | def u32Imm : Operand<i32>; |
| 37 | def u26_6Imm : Operand<i32>; |
| 38 | def u16Imm : Operand<i32>; |
| 39 | def u16_0Imm : Operand<i32>; |
| 40 | def u16_1Imm : Operand<i32>; |
| 41 | def u16_2Imm : Operand<i32>; |
| 42 | def u11_3Imm : Operand<i32>; |
| 43 | def u10Imm : Operand<i32>; |
| 44 | def u9Imm : Operand<i32>; |
| 45 | def u8Imm : Operand<i32>; |
| 46 | def u7Imm : Operand<i32>; |
| 47 | def u6Imm : Operand<i32>; |
| 48 | def u6_0Imm : Operand<i32>; |
| 49 | def u6_1Imm : Operand<i32>; |
| 50 | def u6_2Imm : Operand<i32>; |
| 51 | def u6_3Imm : Operand<i32>; |
| 52 | def u5Imm : Operand<i32>; |
| 53 | def u4Imm : Operand<i32>; |
| 54 | def u3Imm : Operand<i32>; |
| 55 | def u2Imm : Operand<i32>; |
| 56 | def u1Imm : Operand<i32>; |
| 57 | def n8Imm : Operand<i32>; |
| 58 | def m6Imm : Operand<i32>; |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 59 | } |
| 60 | |
Jyotsna Verma | 3ec3a49 | 2012-11-21 19:53:42 +0000 | [diff] [blame^] | 61 | let PrintMethod = "printNOneImmOperand" in |
| 62 | def nOneImm : Operand<i32>; |
Sirish Pande | 30804c2 | 2012-02-15 18:52:27 +0000 | [diff] [blame] | 63 | |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 64 | // |
| 65 | // Immediate predicates |
| 66 | // |
| 67 | def s32ImmPred : PatLeaf<(i32 imm), [{ |
| 68 | // immS16 predicate - True if the immediate fits in a 16-bit sign extended |
| 69 | // field. |
| 70 | int64_t v = (int64_t)N->getSExtValue(); |
| 71 | return isInt<32>(v); |
| 72 | }]>; |
| 73 | |
| 74 | def s32_24ImmPred : PatLeaf<(i32 imm), [{ |
| 75 | // s32_24ImmPred predicate - True if the immediate fits in a 32-bit sign |
| 76 | // extended field that is a multiple of 0x1000000. |
| 77 | int64_t v = (int64_t)N->getSExtValue(); |
| 78 | return isShiftedInt<32,24>(v); |
| 79 | }]>; |
| 80 | |
| 81 | def s32_16s8ImmPred : PatLeaf<(i32 imm), [{ |
| 82 | // s32_16s8ImmPred predicate - True if the immediate fits in a 32-bit sign |
| 83 | // extended field that is a multiple of 0x10000. |
| 84 | int64_t v = (int64_t)N->getSExtValue(); |
| 85 | return isShiftedInt<24,16>(v); |
| 86 | }]>; |
| 87 | |
| 88 | def s16ImmPred : PatLeaf<(i32 imm), [{ |
| 89 | // immS16 predicate - True if the immediate fits in a 16-bit sign extended |
| 90 | // field. |
| 91 | int64_t v = (int64_t)N->getSExtValue(); |
| 92 | return isInt<16>(v); |
| 93 | }]>; |
| 94 | |
| 95 | |
| 96 | def s13ImmPred : PatLeaf<(i32 imm), [{ |
| 97 | // immS13 predicate - True if the immediate fits in a 13-bit sign extended |
| 98 | // field. |
| 99 | int64_t v = (int64_t)N->getSExtValue(); |
| 100 | return isInt<13>(v); |
| 101 | }]>; |
| 102 | |
| 103 | |
| 104 | def s12ImmPred : PatLeaf<(i32 imm), [{ |
| 105 | // immS16 predicate - True if the immediate fits in a 16-bit sign extended |
| 106 | // field. |
| 107 | int64_t v = (int64_t)N->getSExtValue(); |
| 108 | return isInt<12>(v); |
| 109 | }]>; |
| 110 | |
| 111 | def s11_0ImmPred : PatLeaf<(i32 imm), [{ |
| 112 | // immS16 predicate - True if the immediate fits in a 16-bit sign extended |
| 113 | // field. |
| 114 | int64_t v = (int64_t)N->getSExtValue(); |
| 115 | return isInt<11>(v); |
| 116 | }]>; |
| 117 | |
| 118 | |
| 119 | def s11_1ImmPred : PatLeaf<(i32 imm), [{ |
| 120 | // immS16 predicate - True if the immediate fits in a 16-bit sign extended |
| 121 | // field. |
| 122 | int64_t v = (int64_t)N->getSExtValue(); |
| 123 | return isShiftedInt<11,1>(v); |
| 124 | }]>; |
| 125 | |
| 126 | |
| 127 | def s11_2ImmPred : PatLeaf<(i32 imm), [{ |
| 128 | // immS16 predicate - True if the immediate fits in a 16-bit sign extended |
| 129 | // field. |
| 130 | int64_t v = (int64_t)N->getSExtValue(); |
| 131 | return isShiftedInt<11,2>(v); |
| 132 | }]>; |
| 133 | |
| 134 | |
| 135 | def s11_3ImmPred : PatLeaf<(i32 imm), [{ |
| 136 | // immS16 predicate - True if the immediate fits in a 16-bit sign extended |
| 137 | // field. |
| 138 | int64_t v = (int64_t)N->getSExtValue(); |
| 139 | return isShiftedInt<11,3>(v); |
| 140 | }]>; |
| 141 | |
| 142 | |
| 143 | def s10ImmPred : PatLeaf<(i32 imm), [{ |
| 144 | // s10ImmPred predicate - True if the immediate fits in a 10-bit sign extended |
| 145 | // field. |
| 146 | int64_t v = (int64_t)N->getSExtValue(); |
| 147 | return isInt<10>(v); |
| 148 | }]>; |
| 149 | |
| 150 | |
| 151 | def s9ImmPred : PatLeaf<(i32 imm), [{ |
| 152 | // s9ImmPred predicate - True if the immediate fits in a 9-bit sign extended |
| 153 | // field. |
| 154 | int64_t v = (int64_t)N->getSExtValue(); |
| 155 | return isInt<9>(v); |
| 156 | }]>; |
| 157 | |
| 158 | |
| 159 | def s8ImmPred : PatLeaf<(i32 imm), [{ |
| 160 | // s8ImmPred predicate - True if the immediate fits in a 8-bit sign extended |
| 161 | // field. |
| 162 | int64_t v = (int64_t)N->getSExtValue(); |
| 163 | return isInt<8>(v); |
| 164 | }]>; |
| 165 | |
| 166 | |
| 167 | def s8Imm64Pred : PatLeaf<(i64 imm), [{ |
| 168 | // s8ImmPred predicate - True if the immediate fits in a 8-bit sign extended |
| 169 | // field. |
| 170 | int64_t v = (int64_t)N->getSExtValue(); |
| 171 | return isInt<8>(v); |
| 172 | }]>; |
| 173 | |
| 174 | |
| 175 | def s6ImmPred : PatLeaf<(i32 imm), [{ |
| 176 | // s6ImmPred predicate - True if the immediate fits in a 6-bit sign extended |
| 177 | // field. |
| 178 | int64_t v = (int64_t)N->getSExtValue(); |
| 179 | return isInt<6>(v); |
| 180 | }]>; |
| 181 | |
| 182 | |
| 183 | def s4_0ImmPred : PatLeaf<(i32 imm), [{ |
| 184 | // s4_0ImmPred predicate - True if the immediate fits in a 4-bit sign extended |
| 185 | // field. |
| 186 | int64_t v = (int64_t)N->getSExtValue(); |
| 187 | return isInt<4>(v); |
| 188 | }]>; |
| 189 | |
| 190 | |
| 191 | def s4_1ImmPred : PatLeaf<(i32 imm), [{ |
| 192 | // s4_1ImmPred predicate - True if the immediate fits in a 4-bit sign extended |
| 193 | // field of 2. |
| 194 | int64_t v = (int64_t)N->getSExtValue(); |
| 195 | return isShiftedInt<4,1>(v); |
| 196 | }]>; |
| 197 | |
| 198 | |
| 199 | def s4_2ImmPred : PatLeaf<(i32 imm), [{ |
| 200 | // s4_2ImmPred predicate - True if the immediate fits in a 4-bit sign extended |
| 201 | // field that is a multiple of 4. |
| 202 | int64_t v = (int64_t)N->getSExtValue(); |
| 203 | return isShiftedInt<4,2>(v); |
| 204 | }]>; |
| 205 | |
| 206 | |
| 207 | def s4_3ImmPred : PatLeaf<(i32 imm), [{ |
| 208 | // s4_3ImmPred predicate - True if the immediate fits in a 4-bit sign extended |
| 209 | // field that is a multiple of 8. |
| 210 | int64_t v = (int64_t)N->getSExtValue(); |
| 211 | return isShiftedInt<4,3>(v); |
| 212 | }]>; |
| 213 | |
| 214 | |
| 215 | def u64ImmPred : PatLeaf<(i64 imm), [{ |
| 216 | // immS16 predicate - True if the immediate fits in a 16-bit sign extended |
| 217 | // field. |
Benjamin Kramer | bde9176 | 2012-06-02 10:20:22 +0000 | [diff] [blame] | 218 | // Adding "N ||" to suppress gcc unused warning. |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 219 | return (N || true); |
| 220 | }]>; |
| 221 | |
| 222 | def u32ImmPred : PatLeaf<(i32 imm), [{ |
| 223 | // immS16 predicate - True if the immediate fits in a 16-bit sign extended |
| 224 | // field. |
| 225 | int64_t v = (int64_t)N->getSExtValue(); |
| 226 | return isUInt<32>(v); |
| 227 | }]>; |
| 228 | |
| 229 | def u16ImmPred : PatLeaf<(i32 imm), [{ |
| 230 | // u16ImmPred predicate - True if the immediate fits in a 16-bit unsigned |
| 231 | // field. |
| 232 | int64_t v = (int64_t)N->getSExtValue(); |
| 233 | return isUInt<16>(v); |
| 234 | }]>; |
| 235 | |
| 236 | def u16_s8ImmPred : PatLeaf<(i32 imm), [{ |
| 237 | // u16_s8ImmPred predicate - True if the immediate fits in a 16-bit sign |
| 238 | // extended s8 field. |
| 239 | int64_t v = (int64_t)N->getSExtValue(); |
| 240 | return isShiftedUInt<16,8>(v); |
| 241 | }]>; |
| 242 | |
| 243 | def u9ImmPred : PatLeaf<(i32 imm), [{ |
| 244 | // u9ImmPred predicate - True if the immediate fits in a 9-bit unsigned |
| 245 | // field. |
| 246 | int64_t v = (int64_t)N->getSExtValue(); |
| 247 | return isUInt<9>(v); |
| 248 | }]>; |
| 249 | |
| 250 | |
| 251 | def u8ImmPred : PatLeaf<(i32 imm), [{ |
| 252 | // u8ImmPred predicate - True if the immediate fits in a 8-bit unsigned |
| 253 | // field. |
| 254 | int64_t v = (int64_t)N->getSExtValue(); |
| 255 | return isUInt<8>(v); |
| 256 | }]>; |
| 257 | |
| 258 | def u7ImmPred : PatLeaf<(i32 imm), [{ |
| 259 | // u7ImmPred predicate - True if the immediate fits in a 8-bit unsigned |
| 260 | // field. |
| 261 | int64_t v = (int64_t)N->getSExtValue(); |
| 262 | return isUInt<7>(v); |
| 263 | }]>; |
| 264 | |
| 265 | |
| 266 | def u6ImmPred : PatLeaf<(i32 imm), [{ |
| 267 | // u6ImmPred predicate - True if the immediate fits in a 6-bit unsigned |
| 268 | // field. |
| 269 | int64_t v = (int64_t)N->getSExtValue(); |
| 270 | return isUInt<6>(v); |
| 271 | }]>; |
| 272 | |
| 273 | def u6_0ImmPred : PatLeaf<(i32 imm), [{ |
| 274 | // u6_0ImmPred predicate - True if the immediate fits in a 6-bit unsigned |
| 275 | // field. Same as u6ImmPred. |
| 276 | int64_t v = (int64_t)N->getSExtValue(); |
| 277 | return isUInt<6>(v); |
| 278 | }]>; |
| 279 | |
| 280 | def u6_1ImmPred : PatLeaf<(i32 imm), [{ |
| 281 | // u6_1ImmPred predicate - True if the immediate fits in a 6-bit unsigned |
| 282 | // field that is 1 bit alinged - multiple of 2. |
| 283 | int64_t v = (int64_t)N->getSExtValue(); |
| 284 | return isShiftedUInt<6,1>(v); |
| 285 | }]>; |
| 286 | |
| 287 | def u6_2ImmPred : PatLeaf<(i32 imm), [{ |
| 288 | // u6_2ImmPred predicate - True if the immediate fits in a 6-bit unsigned |
| 289 | // field that is 2 bits alinged - multiple of 4. |
| 290 | int64_t v = (int64_t)N->getSExtValue(); |
| 291 | return isShiftedUInt<6,2>(v); |
| 292 | }]>; |
| 293 | |
| 294 | def u6_3ImmPred : PatLeaf<(i32 imm), [{ |
| 295 | // u6_3ImmPred predicate - True if the immediate fits in a 6-bit unsigned |
| 296 | // field that is 3 bits alinged - multiple of 8. |
| 297 | int64_t v = (int64_t)N->getSExtValue(); |
| 298 | return isShiftedUInt<6,3>(v); |
| 299 | }]>; |
| 300 | |
| 301 | def u5ImmPred : PatLeaf<(i32 imm), [{ |
| 302 | // u5ImmPred predicate - True if the immediate fits in a 5-bit unsigned |
| 303 | // field. |
| 304 | int64_t v = (int64_t)N->getSExtValue(); |
| 305 | return isUInt<5>(v); |
| 306 | }]>; |
| 307 | |
| 308 | |
| 309 | def u3ImmPred : PatLeaf<(i32 imm), [{ |
| 310 | // u3ImmPred predicate - True if the immediate fits in a 3-bit unsigned |
| 311 | // field. |
| 312 | int64_t v = (int64_t)N->getSExtValue(); |
| 313 | return isUInt<3>(v); |
| 314 | }]>; |
| 315 | |
| 316 | |
| 317 | def u2ImmPred : PatLeaf<(i32 imm), [{ |
| 318 | // u2ImmPred predicate - True if the immediate fits in a 2-bit unsigned |
| 319 | // field. |
| 320 | int64_t v = (int64_t)N->getSExtValue(); |
| 321 | return isUInt<2>(v); |
| 322 | }]>; |
| 323 | |
| 324 | |
| 325 | def u1ImmPred : PatLeaf<(i1 imm), [{ |
| 326 | // u1ImmPred predicate - True if the immediate fits in a 1-bit unsigned |
| 327 | // field. |
| 328 | int64_t v = (int64_t)N->getSExtValue(); |
| 329 | return isUInt<1>(v); |
| 330 | }]>; |
| 331 | |
| 332 | def m6ImmPred : PatLeaf<(i32 imm), [{ |
| 333 | // m6ImmPred predicate - True if the immediate is negative and fits in |
| 334 | // a 6-bit negative number. |
| 335 | int64_t v = (int64_t)N->getSExtValue(); |
| 336 | return isInt<6>(v); |
| 337 | }]>; |
| 338 | |
| 339 | //InN means negative integers in [-(2^N - 1), 0] |
| 340 | def n8ImmPred : PatLeaf<(i32 imm), [{ |
Evandro Menezes | 5cee621 | 2012-04-12 17:55:53 +0000 | [diff] [blame] | 341 | // n8ImmPred predicate - True if the immediate fits in a 8-bit signed |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 342 | // field. |
| 343 | int64_t v = (int64_t)N->getSExtValue(); |
| 344 | return (-255 <= v && v <= 0); |
| 345 | }]>; |
Sirish Pande | 30804c2 | 2012-02-15 18:52:27 +0000 | [diff] [blame] | 346 | |
| 347 | def nOneImmPred : PatLeaf<(i32 imm), [{ |
| 348 | // nOneImmPred predicate - True if the immediate is -1. |
| 349 | int64_t v = (int64_t)N->getSExtValue(); |
| 350 | return (-1 == v); |
| 351 | }]>; |
| 352 | |