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