| Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame^] | 1 | //=- HexagonImmediates.td - Hexagon immediate processing --*- tablegen -*-=// |
| 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 | |
| 10 | // From IA64's InstrInfo file |
| 11 | def s32Imm : Operand<i32> { |
| 12 | // For now, we use a generic print function for all operands. |
| 13 | let PrintMethod = "printHexagonImmOperand"; |
| 14 | } |
| 15 | |
| 16 | def s16Imm : Operand<i32> { |
| 17 | let PrintMethod = "printHexagonImmOperand"; |
| 18 | } |
| 19 | |
| 20 | def s12Imm : Operand<i32> { |
| 21 | // For now, we use a generic print function for all operands. |
| 22 | let PrintMethod = "printHexagonImmOperand"; |
| 23 | } |
| 24 | |
| 25 | def s11Imm : Operand<i32> { |
| 26 | // For now, we use a generic print function for all operands. |
| 27 | let PrintMethod = "printHexagonImmOperand"; |
| 28 | } |
| 29 | |
| 30 | def s11_0Imm : Operand<i32> { |
| 31 | // For now, we use a generic print function for all operands. |
| 32 | let PrintMethod = "printHexagonImmOperand"; |
| 33 | } |
| 34 | |
| 35 | def s11_1Imm : Operand<i32> { |
| 36 | // For now, we use a generic print function for all operands. |
| 37 | let PrintMethod = "printHexagonImmOperand"; |
| 38 | } |
| 39 | |
| 40 | def s11_2Imm : Operand<i32> { |
| 41 | // For now, we use a generic print function for all operands. |
| 42 | let PrintMethod = "printHexagonImmOperand"; |
| 43 | } |
| 44 | |
| 45 | def s11_3Imm : Operand<i32> { |
| 46 | // For now, we use a generic print function for all operands. |
| 47 | let PrintMethod = "printHexagonImmOperand"; |
| 48 | } |
| 49 | |
| 50 | def s10Imm : Operand<i32> { |
| 51 | // For now, we use a generic print function for all operands. |
| 52 | let PrintMethod = "printHexagonImmOperand"; |
| 53 | } |
| 54 | |
| 55 | def s8Imm : Operand<i32> { |
| 56 | // For now, we use a generic print function for all operands. |
| 57 | let PrintMethod = "printHexagonImmOperand"; |
| 58 | } |
| 59 | |
| 60 | def s9Imm : Operand<i32> { |
| 61 | // For now, we use a generic print function for all operands. |
| 62 | let PrintMethod = "printHexagonImmOperand"; |
| 63 | } |
| 64 | |
| 65 | def s8Imm64 : Operand<i64> { |
| 66 | // For now, we use a generic print function for all operands. |
| 67 | let PrintMethod = "printHexagonImmOperand"; |
| 68 | } |
| 69 | |
| 70 | def s6Imm : Operand<i32> { |
| 71 | // For now, we use a generic print function for all operands. |
| 72 | let PrintMethod = "printHexagonImmOperand"; |
| 73 | } |
| 74 | |
| 75 | def s4Imm : Operand<i32> { |
| 76 | // For now, we use a generic print function for all operands. |
| 77 | let PrintMethod = "printHexagonImmOperand"; |
| 78 | } |
| 79 | |
| 80 | def s4_0Imm : Operand<i32> { |
| 81 | // For now, we use a generic print function for all operands. |
| 82 | let PrintMethod = "printHexagonImmOperand"; |
| 83 | } |
| 84 | |
| 85 | def s4_1Imm : Operand<i32> { |
| 86 | // For now, we use a generic print function for all operands. |
| 87 | let PrintMethod = "printHexagonImmOperand"; |
| 88 | } |
| 89 | |
| 90 | def s4_2Imm : Operand<i32> { |
| 91 | // For now, we use a generic print function for all operands. |
| 92 | let PrintMethod = "printHexagonImmOperand"; |
| 93 | } |
| 94 | |
| 95 | def s4_3Imm : Operand<i32> { |
| 96 | // For now, we use a generic print function for all operands. |
| 97 | let PrintMethod = "printHexagonImmOperand"; |
| 98 | } |
| 99 | |
| 100 | def u64Imm : Operand<i64> { |
| 101 | // For now, we use a generic print function for all operands. |
| 102 | let PrintMethod = "printHexagonImmOperand"; |
| 103 | } |
| 104 | |
| 105 | def u32Imm : Operand<i32> { |
| 106 | // For now, we use a generic print function for all operands. |
| 107 | let PrintMethod = "printHexagonImmOperand"; |
| 108 | } |
| 109 | |
| 110 | def u16Imm : Operand<i32> { |
| 111 | // For now, we use a generic print function for all operands. |
| 112 | let PrintMethod = "printHexagonImmOperand"; |
| 113 | } |
| 114 | |
| 115 | def u16_0Imm : Operand<i32> { |
| 116 | // For now, we use a generic print function for all operands. |
| 117 | let PrintMethod = "printHexagonImmOperand"; |
| 118 | } |
| 119 | |
| 120 | def u16_1Imm : Operand<i32> { |
| 121 | // For now, we use a generic print function for all operands. |
| 122 | let PrintMethod = "printHexagonImmOperand"; |
| 123 | } |
| 124 | |
| 125 | def u16_2Imm : Operand<i32> { |
| 126 | // For now, we use a generic print function for all operands. |
| 127 | let PrintMethod = "printHexagonImmOperand"; |
| 128 | } |
| 129 | |
| 130 | def u11_3Imm : Operand<i32> { |
| 131 | // For now, we use a generic print function for all operands. |
| 132 | let PrintMethod = "printHexagonImmOperand"; |
| 133 | } |
| 134 | |
| 135 | def u10Imm : Operand<i32> { |
| 136 | // For now, we use a generic print function for all operands. |
| 137 | let PrintMethod = "printHexagonImmOperand"; |
| 138 | } |
| 139 | |
| 140 | def u9Imm : Operand<i32> { |
| 141 | // For now, we use a generic print function for all operands. |
| 142 | let PrintMethod = "printHexagonImmOperand"; |
| 143 | } |
| 144 | |
| 145 | def u8Imm : Operand<i32> { |
| 146 | // For now, we use a generic print function for all operands. |
| 147 | let PrintMethod = "printHexagonImmOperand"; |
| 148 | } |
| 149 | |
| 150 | def u7Imm : Operand<i32> { |
| 151 | // For now, we use a generic print function for all operands. |
| 152 | let PrintMethod = "printHexagonImmOperand"; |
| 153 | } |
| 154 | |
| 155 | def u6Imm : Operand<i32> { |
| 156 | // For now, we use a generic print function for all operands. |
| 157 | let PrintMethod = "printHexagonImmOperand"; |
| 158 | } |
| 159 | |
| 160 | def u6_0Imm : Operand<i32> { |
| 161 | // For now, we use a generic print function for all operands. |
| 162 | let PrintMethod = "printHexagonImmOperand"; |
| 163 | } |
| 164 | |
| 165 | def u6_1Imm : Operand<i32> { |
| 166 | // For now, we use a generic print function for all operands. |
| 167 | let PrintMethod = "printHexagonImmOperand"; |
| 168 | } |
| 169 | |
| 170 | def u6_2Imm : Operand<i32> { |
| 171 | // For now, we use a generic print function for all operands. |
| 172 | let PrintMethod = "printHexagonImmOperand"; |
| 173 | } |
| 174 | |
| 175 | def u6_3Imm : Operand<i32> { |
| 176 | // For now, we use a generic print function for all operands. |
| 177 | let PrintMethod = "printHexagonImmOperand"; |
| 178 | } |
| 179 | |
| 180 | def u5Imm : Operand<i32> { |
| 181 | // For now, we use a generic print function for all operands. |
| 182 | let PrintMethod = "printHexagonImmOperand"; |
| 183 | } |
| 184 | |
| 185 | def u4Imm : Operand<i32> { |
| 186 | // For now, we use a generic print function for all operands. |
| 187 | let PrintMethod = "printHexagonImmOperand"; |
| 188 | } |
| 189 | |
| 190 | def u3Imm : Operand<i32> { |
| 191 | // For now, we use a generic print function for all operands. |
| 192 | let PrintMethod = "printHexagonImmOperand"; |
| 193 | } |
| 194 | |
| 195 | def u2Imm : Operand<i32> { |
| 196 | // For now, we use a generic print function for all operands. |
| 197 | let PrintMethod = "printHexagonImmOperand"; |
| 198 | } |
| 199 | |
| 200 | def n8Imm : Operand<i32> { |
| 201 | // For now, we use a generic print function for all operands. |
| 202 | let PrintMethod = "printHexagonImmOperand"; |
| 203 | } |
| 204 | |
| 205 | def m6Imm : Operand<i32> { |
| 206 | // For now, we use a generic print function for all operands. |
| 207 | let PrintMethod = "printHexagonImmOperand"; |
| 208 | } |
| 209 | |
| 210 | // |
| 211 | // Immediate predicates |
| 212 | // |
| 213 | def s32ImmPred : PatLeaf<(i32 imm), [{ |
| 214 | // immS16 predicate - True if the immediate fits in a 16-bit sign extended |
| 215 | // field. |
| 216 | int64_t v = (int64_t)N->getSExtValue(); |
| 217 | return isInt<32>(v); |
| 218 | }]>; |
| 219 | |
| 220 | def s32_24ImmPred : PatLeaf<(i32 imm), [{ |
| 221 | // s32_24ImmPred predicate - True if the immediate fits in a 32-bit sign |
| 222 | // extended field that is a multiple of 0x1000000. |
| 223 | int64_t v = (int64_t)N->getSExtValue(); |
| 224 | return isShiftedInt<32,24>(v); |
| 225 | }]>; |
| 226 | |
| 227 | def s32_16s8ImmPred : PatLeaf<(i32 imm), [{ |
| 228 | // s32_16s8ImmPred predicate - True if the immediate fits in a 32-bit sign |
| 229 | // extended field that is a multiple of 0x10000. |
| 230 | int64_t v = (int64_t)N->getSExtValue(); |
| 231 | return isShiftedInt<24,16>(v); |
| 232 | }]>; |
| 233 | |
| 234 | def s16ImmPred : PatLeaf<(i32 imm), [{ |
| 235 | // immS16 predicate - True if the immediate fits in a 16-bit sign extended |
| 236 | // field. |
| 237 | int64_t v = (int64_t)N->getSExtValue(); |
| 238 | return isInt<16>(v); |
| 239 | }]>; |
| 240 | |
| 241 | |
| 242 | def s13ImmPred : PatLeaf<(i32 imm), [{ |
| 243 | // immS13 predicate - True if the immediate fits in a 13-bit sign extended |
| 244 | // field. |
| 245 | int64_t v = (int64_t)N->getSExtValue(); |
| 246 | return isInt<13>(v); |
| 247 | }]>; |
| 248 | |
| 249 | |
| 250 | def s12ImmPred : PatLeaf<(i32 imm), [{ |
| 251 | // immS16 predicate - True if the immediate fits in a 16-bit sign extended |
| 252 | // field. |
| 253 | int64_t v = (int64_t)N->getSExtValue(); |
| 254 | return isInt<12>(v); |
| 255 | }]>; |
| 256 | |
| 257 | def s11_0ImmPred : PatLeaf<(i32 imm), [{ |
| 258 | // immS16 predicate - True if the immediate fits in a 16-bit sign extended |
| 259 | // field. |
| 260 | int64_t v = (int64_t)N->getSExtValue(); |
| 261 | return isInt<11>(v); |
| 262 | }]>; |
| 263 | |
| 264 | |
| 265 | def s11_1ImmPred : PatLeaf<(i32 imm), [{ |
| 266 | // immS16 predicate - True if the immediate fits in a 16-bit sign extended |
| 267 | // field. |
| 268 | int64_t v = (int64_t)N->getSExtValue(); |
| 269 | return isShiftedInt<11,1>(v); |
| 270 | }]>; |
| 271 | |
| 272 | |
| 273 | def s11_2ImmPred : PatLeaf<(i32 imm), [{ |
| 274 | // immS16 predicate - True if the immediate fits in a 16-bit sign extended |
| 275 | // field. |
| 276 | int64_t v = (int64_t)N->getSExtValue(); |
| 277 | return isShiftedInt<11,2>(v); |
| 278 | }]>; |
| 279 | |
| 280 | |
| 281 | def s11_3ImmPred : PatLeaf<(i32 imm), [{ |
| 282 | // immS16 predicate - True if the immediate fits in a 16-bit sign extended |
| 283 | // field. |
| 284 | int64_t v = (int64_t)N->getSExtValue(); |
| 285 | return isShiftedInt<11,3>(v); |
| 286 | }]>; |
| 287 | |
| 288 | |
| 289 | def s10ImmPred : PatLeaf<(i32 imm), [{ |
| 290 | // s10ImmPred predicate - True if the immediate fits in a 10-bit sign extended |
| 291 | // field. |
| 292 | int64_t v = (int64_t)N->getSExtValue(); |
| 293 | return isInt<10>(v); |
| 294 | }]>; |
| 295 | |
| 296 | |
| 297 | def s9ImmPred : PatLeaf<(i32 imm), [{ |
| 298 | // s9ImmPred predicate - True if the immediate fits in a 9-bit sign extended |
| 299 | // field. |
| 300 | int64_t v = (int64_t)N->getSExtValue(); |
| 301 | return isInt<9>(v); |
| 302 | }]>; |
| 303 | |
| 304 | |
| 305 | def s8ImmPred : PatLeaf<(i32 imm), [{ |
| 306 | // s8ImmPred predicate - True if the immediate fits in a 8-bit sign extended |
| 307 | // field. |
| 308 | int64_t v = (int64_t)N->getSExtValue(); |
| 309 | return isInt<8>(v); |
| 310 | }]>; |
| 311 | |
| 312 | |
| 313 | def s8Imm64Pred : PatLeaf<(i64 imm), [{ |
| 314 | // s8ImmPred predicate - True if the immediate fits in a 8-bit sign extended |
| 315 | // field. |
| 316 | int64_t v = (int64_t)N->getSExtValue(); |
| 317 | return isInt<8>(v); |
| 318 | }]>; |
| 319 | |
| 320 | |
| 321 | def s6ImmPred : PatLeaf<(i32 imm), [{ |
| 322 | // s6ImmPred predicate - True if the immediate fits in a 6-bit sign extended |
| 323 | // field. |
| 324 | int64_t v = (int64_t)N->getSExtValue(); |
| 325 | return isInt<6>(v); |
| 326 | }]>; |
| 327 | |
| 328 | |
| 329 | def s4_0ImmPred : PatLeaf<(i32 imm), [{ |
| 330 | // s4_0ImmPred predicate - True if the immediate fits in a 4-bit sign extended |
| 331 | // field. |
| 332 | int64_t v = (int64_t)N->getSExtValue(); |
| 333 | return isInt<4>(v); |
| 334 | }]>; |
| 335 | |
| 336 | |
| 337 | def s4_1ImmPred : PatLeaf<(i32 imm), [{ |
| 338 | // s4_1ImmPred predicate - True if the immediate fits in a 4-bit sign extended |
| 339 | // field of 2. |
| 340 | int64_t v = (int64_t)N->getSExtValue(); |
| 341 | return isShiftedInt<4,1>(v); |
| 342 | }]>; |
| 343 | |
| 344 | |
| 345 | def s4_2ImmPred : PatLeaf<(i32 imm), [{ |
| 346 | // s4_2ImmPred predicate - True if the immediate fits in a 4-bit sign extended |
| 347 | // field that is a multiple of 4. |
| 348 | int64_t v = (int64_t)N->getSExtValue(); |
| 349 | return isShiftedInt<4,2>(v); |
| 350 | }]>; |
| 351 | |
| 352 | |
| 353 | def s4_3ImmPred : PatLeaf<(i32 imm), [{ |
| 354 | // s4_3ImmPred predicate - True if the immediate fits in a 4-bit sign extended |
| 355 | // field that is a multiple of 8. |
| 356 | int64_t v = (int64_t)N->getSExtValue(); |
| 357 | return isShiftedInt<4,3>(v); |
| 358 | }]>; |
| 359 | |
| 360 | |
| 361 | def u64ImmPred : PatLeaf<(i64 imm), [{ |
| 362 | // immS16 predicate - True if the immediate fits in a 16-bit sign extended |
| 363 | // field. |
| 364 | // Adding "N ||" to supress gcc unused warning. |
| 365 | return (N || true); |
| 366 | }]>; |
| 367 | |
| 368 | def u32ImmPred : PatLeaf<(i32 imm), [{ |
| 369 | // immS16 predicate - True if the immediate fits in a 16-bit sign extended |
| 370 | // field. |
| 371 | int64_t v = (int64_t)N->getSExtValue(); |
| 372 | return isUInt<32>(v); |
| 373 | }]>; |
| 374 | |
| 375 | def u16ImmPred : PatLeaf<(i32 imm), [{ |
| 376 | // u16ImmPred predicate - True if the immediate fits in a 16-bit unsigned |
| 377 | // field. |
| 378 | int64_t v = (int64_t)N->getSExtValue(); |
| 379 | return isUInt<16>(v); |
| 380 | }]>; |
| 381 | |
| 382 | def u16_s8ImmPred : PatLeaf<(i32 imm), [{ |
| 383 | // u16_s8ImmPred predicate - True if the immediate fits in a 16-bit sign |
| 384 | // extended s8 field. |
| 385 | int64_t v = (int64_t)N->getSExtValue(); |
| 386 | return isShiftedUInt<16,8>(v); |
| 387 | }]>; |
| 388 | |
| 389 | def u9ImmPred : PatLeaf<(i32 imm), [{ |
| 390 | // u9ImmPred predicate - True if the immediate fits in a 9-bit unsigned |
| 391 | // field. |
| 392 | int64_t v = (int64_t)N->getSExtValue(); |
| 393 | return isUInt<9>(v); |
| 394 | }]>; |
| 395 | |
| 396 | |
| 397 | def u8ImmPred : PatLeaf<(i32 imm), [{ |
| 398 | // u8ImmPred predicate - True if the immediate fits in a 8-bit unsigned |
| 399 | // field. |
| 400 | int64_t v = (int64_t)N->getSExtValue(); |
| 401 | return isUInt<8>(v); |
| 402 | }]>; |
| 403 | |
| 404 | def u7ImmPred : PatLeaf<(i32 imm), [{ |
| 405 | // u7ImmPred predicate - True if the immediate fits in a 8-bit unsigned |
| 406 | // field. |
| 407 | int64_t v = (int64_t)N->getSExtValue(); |
| 408 | return isUInt<7>(v); |
| 409 | }]>; |
| 410 | |
| 411 | |
| 412 | def u6ImmPred : PatLeaf<(i32 imm), [{ |
| 413 | // u6ImmPred predicate - True if the immediate fits in a 6-bit unsigned |
| 414 | // field. |
| 415 | int64_t v = (int64_t)N->getSExtValue(); |
| 416 | return isUInt<6>(v); |
| 417 | }]>; |
| 418 | |
| 419 | def u6_0ImmPred : PatLeaf<(i32 imm), [{ |
| 420 | // u6_0ImmPred predicate - True if the immediate fits in a 6-bit unsigned |
| 421 | // field. Same as u6ImmPred. |
| 422 | int64_t v = (int64_t)N->getSExtValue(); |
| 423 | return isUInt<6>(v); |
| 424 | }]>; |
| 425 | |
| 426 | def u6_1ImmPred : PatLeaf<(i32 imm), [{ |
| 427 | // u6_1ImmPred predicate - True if the immediate fits in a 6-bit unsigned |
| 428 | // field that is 1 bit alinged - multiple of 2. |
| 429 | int64_t v = (int64_t)N->getSExtValue(); |
| 430 | return isShiftedUInt<6,1>(v); |
| 431 | }]>; |
| 432 | |
| 433 | def u6_2ImmPred : PatLeaf<(i32 imm), [{ |
| 434 | // u6_2ImmPred predicate - True if the immediate fits in a 6-bit unsigned |
| 435 | // field that is 2 bits alinged - multiple of 4. |
| 436 | int64_t v = (int64_t)N->getSExtValue(); |
| 437 | return isShiftedUInt<6,2>(v); |
| 438 | }]>; |
| 439 | |
| 440 | def u6_3ImmPred : PatLeaf<(i32 imm), [{ |
| 441 | // u6_3ImmPred predicate - True if the immediate fits in a 6-bit unsigned |
| 442 | // field that is 3 bits alinged - multiple of 8. |
| 443 | int64_t v = (int64_t)N->getSExtValue(); |
| 444 | return isShiftedUInt<6,3>(v); |
| 445 | }]>; |
| 446 | |
| 447 | def u5ImmPred : PatLeaf<(i32 imm), [{ |
| 448 | // u5ImmPred predicate - True if the immediate fits in a 5-bit unsigned |
| 449 | // field. |
| 450 | int64_t v = (int64_t)N->getSExtValue(); |
| 451 | return isUInt<5>(v); |
| 452 | }]>; |
| 453 | |
| 454 | |
| 455 | def u3ImmPred : PatLeaf<(i32 imm), [{ |
| 456 | // u3ImmPred predicate - True if the immediate fits in a 3-bit unsigned |
| 457 | // field. |
| 458 | int64_t v = (int64_t)N->getSExtValue(); |
| 459 | return isUInt<3>(v); |
| 460 | }]>; |
| 461 | |
| 462 | |
| 463 | def u2ImmPred : PatLeaf<(i32 imm), [{ |
| 464 | // u2ImmPred predicate - True if the immediate fits in a 2-bit unsigned |
| 465 | // field. |
| 466 | int64_t v = (int64_t)N->getSExtValue(); |
| 467 | return isUInt<2>(v); |
| 468 | }]>; |
| 469 | |
| 470 | |
| 471 | def u1ImmPred : PatLeaf<(i1 imm), [{ |
| 472 | // u1ImmPred predicate - True if the immediate fits in a 1-bit unsigned |
| 473 | // field. |
| 474 | int64_t v = (int64_t)N->getSExtValue(); |
| 475 | return isUInt<1>(v); |
| 476 | }]>; |
| 477 | |
| 478 | def m6ImmPred : PatLeaf<(i32 imm), [{ |
| 479 | // m6ImmPred predicate - True if the immediate is negative and fits in |
| 480 | // a 6-bit negative number. |
| 481 | int64_t v = (int64_t)N->getSExtValue(); |
| 482 | return isInt<6>(v); |
| 483 | }]>; |
| 484 | |
| 485 | //InN means negative integers in [-(2^N - 1), 0] |
| 486 | def n8ImmPred : PatLeaf<(i32 imm), [{ |
| 487 | // n8ImmPred predicate - True if the immediate fits in a 8-bit unsigned |
| 488 | // field. |
| 489 | int64_t v = (int64_t)N->getSExtValue(); |
| 490 | return (-255 <= v && v <= 0); |
| 491 | }]>; |