Home | History | Annotate | Download | only in IR
      1 //===- IntrinsicsSystemZ.td - Defines SystemZ intrinsics ---*- tablegen -*-===//
      2 //
      3 //                     The LLVM Compiler Infrastructure
      4 //
      5 // This file is distributed under the University of Illinois Open Source
      6 // License. See LICENSE.TXT for details.
      7 //
      8 //===----------------------------------------------------------------------===//
      9 //
     10 // This file defines all of the SystemZ-specific intrinsics.
     11 //
     12 //===----------------------------------------------------------------------===//
     13 
     14 class SystemZUnaryConv<string name, LLVMType result, LLVMType arg>
     15   : GCCBuiltin<"__builtin_s390_" ## name>,
     16     Intrinsic<[result], [arg], [IntrNoMem]>;
     17 
     18 class SystemZUnary<string name, LLVMType type>
     19   : SystemZUnaryConv<name, type, type>;
     20 
     21 class SystemZUnaryConvCC<LLVMType result, LLVMType arg>
     22   : Intrinsic<[result, llvm_i32_ty], [arg], [IntrNoMem]>;
     23 
     24 class SystemZUnaryCC<LLVMType type>
     25   : SystemZUnaryConvCC<type, type>;
     26 
     27 class SystemZBinaryConv<string name, LLVMType result, LLVMType arg>
     28   : GCCBuiltin<"__builtin_s390_" ## name>,
     29     Intrinsic<[result], [arg, arg], [IntrNoMem]>;
     30 
     31 class SystemZBinary<string name, LLVMType type>
     32   : SystemZBinaryConv<name, type, type>;
     33 
     34 class SystemZBinaryInt<string name, LLVMType type>
     35   : GCCBuiltin<"__builtin_s390_" ## name>,
     36     Intrinsic<[type], [type, llvm_i32_ty], [IntrNoMem]>;
     37 
     38 class SystemZBinaryConvCC<LLVMType result, LLVMType arg>
     39   : Intrinsic<[result, llvm_i32_ty], [arg, arg], [IntrNoMem]>;
     40 
     41 class SystemZBinaryConvIntCC<LLVMType result, LLVMType arg>
     42   : Intrinsic<[result, llvm_i32_ty], [arg, llvm_i32_ty], [IntrNoMem]>;
     43 
     44 class SystemZBinaryCC<LLVMType type>
     45   : SystemZBinaryConvCC<type, type>;
     46 
     47 class SystemZTernaryConv<string name, LLVMType result, LLVMType arg>
     48   : GCCBuiltin<"__builtin_s390_" ## name>,
     49     Intrinsic<[result], [arg, arg, result], [IntrNoMem]>;
     50 
     51 class SystemZTernary<string name, LLVMType type>
     52   : SystemZTernaryConv<name, type, type>;
     53 
     54 class SystemZTernaryInt<string name, LLVMType type>
     55   : GCCBuiltin<"__builtin_s390_" ## name>,
     56     Intrinsic<[type], [type, type, llvm_i32_ty], [IntrNoMem]>;
     57 
     58 class SystemZTernaryIntCC<LLVMType type>
     59   : Intrinsic<[type, llvm_i32_ty], [type, type, llvm_i32_ty], [IntrNoMem]>;
     60 
     61 class SystemZQuaternaryInt<string name, LLVMType type>
     62   : GCCBuiltin<"__builtin_s390_" ## name>,
     63     Intrinsic<[type], [type, type, type, llvm_i32_ty], [IntrNoMem]>;
     64 
     65 class SystemZQuaternaryIntCC<LLVMType type>
     66   : Intrinsic<[type, llvm_i32_ty], [type, type, type, llvm_i32_ty],
     67               [IntrNoMem]>;
     68 
     69 multiclass SystemZUnaryExtBHF<string name> {
     70   def b : SystemZUnaryConv<name##"b", llvm_v8i16_ty, llvm_v16i8_ty>;
     71   def h : SystemZUnaryConv<name##"h", llvm_v4i32_ty, llvm_v8i16_ty>;
     72   def f : SystemZUnaryConv<name##"f", llvm_v2i64_ty, llvm_v4i32_ty>;
     73 }
     74 
     75 multiclass SystemZUnaryExtBHWF<string name> {
     76   def b  : SystemZUnaryConv<name##"b",  llvm_v8i16_ty, llvm_v16i8_ty>;
     77   def hw : SystemZUnaryConv<name##"hw", llvm_v4i32_ty, llvm_v8i16_ty>;
     78   def f  : SystemZUnaryConv<name##"f",  llvm_v2i64_ty, llvm_v4i32_ty>;
     79 }
     80 
     81 multiclass SystemZUnaryBHF<string name> {
     82   def b : SystemZUnary<name##"b", llvm_v16i8_ty>;
     83   def h : SystemZUnary<name##"h", llvm_v8i16_ty>;
     84   def f : SystemZUnary<name##"f", llvm_v4i32_ty>;
     85 }
     86 
     87 multiclass SystemZUnaryBHFG<string name> : SystemZUnaryBHF<name> {
     88   def g : SystemZUnary<name##"g", llvm_v2i64_ty>;
     89 }
     90 
     91 multiclass SystemZUnaryCCBHF {
     92   def bs : SystemZUnaryCC<llvm_v16i8_ty>;
     93   def hs : SystemZUnaryCC<llvm_v8i16_ty>;
     94   def fs : SystemZUnaryCC<llvm_v4i32_ty>;
     95 }
     96 
     97 multiclass SystemZBinaryTruncHFG<string name> {
     98   def h : SystemZBinaryConv<name##"h", llvm_v16i8_ty, llvm_v8i16_ty>;
     99   def f : SystemZBinaryConv<name##"f", llvm_v8i16_ty, llvm_v4i32_ty>;
    100   def g : SystemZBinaryConv<name##"g", llvm_v4i32_ty, llvm_v2i64_ty>;
    101 }
    102 
    103 multiclass SystemZBinaryTruncCCHFG {
    104   def hs : SystemZBinaryConvCC<llvm_v16i8_ty, llvm_v8i16_ty>;
    105   def fs : SystemZBinaryConvCC<llvm_v8i16_ty, llvm_v4i32_ty>;
    106   def gs : SystemZBinaryConvCC<llvm_v4i32_ty, llvm_v2i64_ty>;
    107 }
    108 
    109 multiclass SystemZBinaryExtBHF<string name> {
    110   def b : SystemZBinaryConv<name##"b", llvm_v8i16_ty, llvm_v16i8_ty>;
    111   def h : SystemZBinaryConv<name##"h", llvm_v4i32_ty, llvm_v8i16_ty>;
    112   def f : SystemZBinaryConv<name##"f", llvm_v2i64_ty, llvm_v4i32_ty>;
    113 }
    114 
    115 multiclass SystemZBinaryExtBHFG<string name> : SystemZBinaryExtBHF<name> {
    116   def g : SystemZBinaryConv<name##"g", llvm_v16i8_ty, llvm_v2i64_ty>;
    117 }
    118 
    119 multiclass SystemZBinaryBHF<string name> {
    120   def b : SystemZBinary<name##"b", llvm_v16i8_ty>;
    121   def h : SystemZBinary<name##"h", llvm_v8i16_ty>;
    122   def f : SystemZBinary<name##"f", llvm_v4i32_ty>;
    123 }
    124 
    125 multiclass SystemZBinaryBHFG<string name> : SystemZBinaryBHF<name> {
    126   def g : SystemZBinary<name##"g", llvm_v2i64_ty>;
    127 }
    128 
    129 multiclass SystemZBinaryIntBHFG<string name> {
    130   def b : SystemZBinaryInt<name##"b", llvm_v16i8_ty>;
    131   def h : SystemZBinaryInt<name##"h", llvm_v8i16_ty>;
    132   def f : SystemZBinaryInt<name##"f", llvm_v4i32_ty>;
    133   def g : SystemZBinaryInt<name##"g", llvm_v2i64_ty>;
    134 }
    135 
    136 multiclass SystemZBinaryCCBHF {
    137   def bs : SystemZBinaryCC<llvm_v16i8_ty>;
    138   def hs : SystemZBinaryCC<llvm_v8i16_ty>;
    139   def fs : SystemZBinaryCC<llvm_v4i32_ty>;
    140 }
    141 
    142 multiclass SystemZCompareBHFG<string name> {
    143   def bs : SystemZBinaryCC<llvm_v16i8_ty>;
    144   def hs : SystemZBinaryCC<llvm_v8i16_ty>;
    145   def fs : SystemZBinaryCC<llvm_v4i32_ty>;
    146   def gs : SystemZBinaryCC<llvm_v2i64_ty>;
    147 }
    148 
    149 multiclass SystemZTernaryExtBHF<string name> {
    150   def b : SystemZTernaryConv<name##"b", llvm_v8i16_ty, llvm_v16i8_ty>;
    151   def h : SystemZTernaryConv<name##"h", llvm_v4i32_ty, llvm_v8i16_ty>;
    152   def f : SystemZTernaryConv<name##"f", llvm_v2i64_ty, llvm_v4i32_ty>;
    153 }
    154 
    155 multiclass SystemZTernaryExtBHFG<string name> : SystemZTernaryExtBHF<name> {
    156   def g : SystemZTernaryConv<name##"g", llvm_v16i8_ty, llvm_v2i64_ty>;
    157 }
    158 
    159 multiclass SystemZTernaryBHF<string name> {
    160   def b : SystemZTernary<name##"b", llvm_v16i8_ty>;
    161   def h : SystemZTernary<name##"h", llvm_v8i16_ty>;
    162   def f : SystemZTernary<name##"f", llvm_v4i32_ty>;
    163 }
    164 
    165 multiclass SystemZTernaryIntBHF<string name> {
    166   def b : SystemZTernaryInt<name##"b", llvm_v16i8_ty>;
    167   def h : SystemZTernaryInt<name##"h", llvm_v8i16_ty>;
    168   def f : SystemZTernaryInt<name##"f", llvm_v4i32_ty>;
    169 }
    170 
    171 multiclass SystemZTernaryIntCCBHF {
    172   def bs : SystemZTernaryIntCC<llvm_v16i8_ty>;
    173   def hs : SystemZTernaryIntCC<llvm_v8i16_ty>;
    174   def fs : SystemZTernaryIntCC<llvm_v4i32_ty>;
    175 }
    176 
    177 multiclass SystemZQuaternaryIntBHF<string name> {
    178   def b : SystemZQuaternaryInt<name##"b", llvm_v16i8_ty>;
    179   def h : SystemZQuaternaryInt<name##"h", llvm_v8i16_ty>;
    180   def f : SystemZQuaternaryInt<name##"f", llvm_v4i32_ty>;
    181 }
    182 
    183 multiclass SystemZQuaternaryIntBHFG<string name> : SystemZQuaternaryIntBHF<name> {
    184   def g : SystemZQuaternaryInt<name##"g", llvm_v2i64_ty>;
    185 }
    186 
    187 multiclass SystemZQuaternaryIntCCBHF {
    188   def bs : SystemZQuaternaryIntCC<llvm_v16i8_ty>;
    189   def hs : SystemZQuaternaryIntCC<llvm_v8i16_ty>;
    190   def fs : SystemZQuaternaryIntCC<llvm_v4i32_ty>;
    191 }
    192 
    193 //===----------------------------------------------------------------------===//
    194 //
    195 // Transactional-execution intrinsics
    196 //
    197 //===----------------------------------------------------------------------===//
    198 
    199 let TargetPrefix = "s390" in {
    200   def int_s390_tbegin : Intrinsic<[llvm_i32_ty], [llvm_ptr_ty, llvm_i32_ty],
    201                                   [IntrNoDuplicate]>;
    202 
    203   def int_s390_tbegin_nofloat : Intrinsic<[llvm_i32_ty],
    204                                           [llvm_ptr_ty, llvm_i32_ty],
    205                                           [IntrNoDuplicate]>;
    206 
    207   def int_s390_tbeginc : Intrinsic<[], [llvm_ptr_ty, llvm_i32_ty],
    208                                    [IntrNoDuplicate]>;
    209 
    210   def int_s390_tabort : Intrinsic<[], [llvm_i64_ty],
    211                                   [IntrNoReturn, Throws]>;
    212 
    213   def int_s390_tend : GCCBuiltin<"__builtin_tend">,
    214                       Intrinsic<[llvm_i32_ty], []>;
    215 
    216   def int_s390_etnd : GCCBuiltin<"__builtin_tx_nesting_depth">,
    217                       Intrinsic<[llvm_i32_ty], [], [IntrNoMem]>;
    218 
    219   def int_s390_ntstg : Intrinsic<[], [llvm_i64_ty, llvm_ptr64_ty],
    220                                  [IntrArgMemOnly]>;
    221 
    222   def int_s390_ppa_txassist : GCCBuiltin<"__builtin_tx_assist">,
    223                               Intrinsic<[], [llvm_i32_ty]>;
    224 }
    225 
    226 //===----------------------------------------------------------------------===//
    227 //
    228 // Vector intrinsics
    229 //
    230 //===----------------------------------------------------------------------===//
    231 
    232 let TargetPrefix = "s390" in {
    233   def int_s390_lcbb : GCCBuiltin<"__builtin_s390_lcbb">,
    234                       Intrinsic<[llvm_i32_ty], [llvm_ptr_ty, llvm_i32_ty],
    235                                 [IntrNoMem]>;
    236 
    237   def int_s390_vlbb : GCCBuiltin<"__builtin_s390_vlbb">,
    238                       Intrinsic<[llvm_v16i8_ty], [llvm_ptr_ty, llvm_i32_ty],
    239                                 [IntrReadMem, IntrArgMemOnly]>;
    240 
    241   def int_s390_vll : GCCBuiltin<"__builtin_s390_vll">,
    242                      Intrinsic<[llvm_v16i8_ty], [llvm_i32_ty, llvm_ptr_ty],
    243                                [IntrReadMem, IntrArgMemOnly]>;
    244 
    245   def int_s390_vpdi : GCCBuiltin<"__builtin_s390_vpdi">,
    246                       Intrinsic<[llvm_v2i64_ty],
    247                                 [llvm_v2i64_ty, llvm_v2i64_ty, llvm_i32_ty],
    248                                 [IntrNoMem]>;
    249 
    250   def int_s390_vperm : GCCBuiltin<"__builtin_s390_vperm">,
    251                        Intrinsic<[llvm_v16i8_ty],
    252                                  [llvm_v16i8_ty, llvm_v16i8_ty, llvm_v16i8_ty],
    253                                  [IntrNoMem]>;
    254 
    255   defm int_s390_vpks : SystemZBinaryTruncHFG<"vpks">;
    256   defm int_s390_vpks : SystemZBinaryTruncCCHFG;
    257 
    258   defm int_s390_vpkls : SystemZBinaryTruncHFG<"vpkls">;
    259   defm int_s390_vpkls : SystemZBinaryTruncCCHFG;
    260 
    261   def int_s390_vstl : GCCBuiltin<"__builtin_s390_vstl">,
    262                       Intrinsic<[], [llvm_v16i8_ty, llvm_i32_ty, llvm_ptr_ty],
    263                                 // In fact write-only but there's no property
    264                                 // for that.
    265                                 [IntrArgMemOnly]>;
    266 
    267   defm int_s390_vupl  : SystemZUnaryExtBHWF<"vupl">;
    268   defm int_s390_vupll : SystemZUnaryExtBHF<"vupll">;
    269 
    270   defm int_s390_vuph  : SystemZUnaryExtBHF<"vuph">;
    271   defm int_s390_vuplh : SystemZUnaryExtBHF<"vuplh">;
    272 
    273   defm int_s390_vacc : SystemZBinaryBHFG<"vacc">;
    274 
    275   def int_s390_vaq    : SystemZBinary<"vaq",     llvm_v16i8_ty>;
    276   def int_s390_vacq   : SystemZTernary<"vacq",   llvm_v16i8_ty>;
    277   def int_s390_vaccq  : SystemZBinary<"vaccq",   llvm_v16i8_ty>;
    278   def int_s390_vacccq : SystemZTernary<"vacccq", llvm_v16i8_ty>;
    279 
    280   defm int_s390_vavg  : SystemZBinaryBHFG<"vavg">;
    281   defm int_s390_vavgl : SystemZBinaryBHFG<"vavgl">;
    282 
    283   def int_s390_vcksm : SystemZBinary<"vcksm", llvm_v4i32_ty>;
    284 
    285   defm int_s390_vgfm  : SystemZBinaryExtBHFG<"vgfm">;
    286   defm int_s390_vgfma : SystemZTernaryExtBHFG<"vgfma">;
    287 
    288   defm int_s390_vmah  : SystemZTernaryBHF<"vmah">;
    289   defm int_s390_vmalh : SystemZTernaryBHF<"vmalh">;
    290   defm int_s390_vmae  : SystemZTernaryExtBHF<"vmae">;
    291   defm int_s390_vmale : SystemZTernaryExtBHF<"vmale">;
    292   defm int_s390_vmao  : SystemZTernaryExtBHF<"vmao">;
    293   defm int_s390_vmalo : SystemZTernaryExtBHF<"vmalo">;
    294 
    295   defm int_s390_vmh  : SystemZBinaryBHF<"vmh">;
    296   defm int_s390_vmlh : SystemZBinaryBHF<"vmlh">;
    297   defm int_s390_vme  : SystemZBinaryExtBHF<"vme">;
    298   defm int_s390_vmle : SystemZBinaryExtBHF<"vmle">;
    299   defm int_s390_vmo  : SystemZBinaryExtBHF<"vmo">;
    300   defm int_s390_vmlo : SystemZBinaryExtBHF<"vmlo">;
    301 
    302   defm int_s390_verllv : SystemZBinaryBHFG<"verllv">;
    303   defm int_s390_verll  : SystemZBinaryIntBHFG<"verll">;
    304   defm int_s390_verim  : SystemZQuaternaryIntBHFG<"verim">;
    305 
    306   def int_s390_vsl   : SystemZBinary<"vsl",   llvm_v16i8_ty>;
    307   def int_s390_vslb  : SystemZBinary<"vslb",  llvm_v16i8_ty>;
    308   def int_s390_vsra  : SystemZBinary<"vsra",  llvm_v16i8_ty>;
    309   def int_s390_vsrab : SystemZBinary<"vsrab", llvm_v16i8_ty>;
    310   def int_s390_vsrl  : SystemZBinary<"vsrl",  llvm_v16i8_ty>;
    311   def int_s390_vsrlb : SystemZBinary<"vsrlb", llvm_v16i8_ty>;
    312 
    313   def int_s390_vsldb : GCCBuiltin<"__builtin_s390_vsldb">,
    314                        Intrinsic<[llvm_v16i8_ty],
    315                                  [llvm_v16i8_ty, llvm_v16i8_ty, llvm_i32_ty],
    316                                  [IntrNoMem]>;
    317 
    318   defm int_s390_vscbi : SystemZBinaryBHFG<"vscbi">;
    319 
    320   def int_s390_vsq     : SystemZBinary<"vsq",      llvm_v16i8_ty>;
    321   def int_s390_vsbiq   : SystemZTernary<"vsbiq",   llvm_v16i8_ty>;
    322   def int_s390_vscbiq  : SystemZBinary<"vscbiq",   llvm_v16i8_ty>;
    323   def int_s390_vsbcbiq : SystemZTernary<"vsbcbiq", llvm_v16i8_ty>;
    324 
    325   def int_s390_vsumb : SystemZBinaryConv<"vsumb", llvm_v4i32_ty, llvm_v16i8_ty>;
    326   def int_s390_vsumh : SystemZBinaryConv<"vsumh", llvm_v4i32_ty, llvm_v8i16_ty>;
    327 
    328   def int_s390_vsumgh : SystemZBinaryConv<"vsumgh", llvm_v2i64_ty,
    329                                           llvm_v8i16_ty>;
    330   def int_s390_vsumgf : SystemZBinaryConv<"vsumgf", llvm_v2i64_ty,
    331                                           llvm_v4i32_ty>;
    332 
    333   def int_s390_vsumqf : SystemZBinaryConv<"vsumqf", llvm_v16i8_ty,
    334                                           llvm_v4i32_ty>;
    335   def int_s390_vsumqg : SystemZBinaryConv<"vsumqg", llvm_v16i8_ty,
    336                                           llvm_v2i64_ty>;
    337 
    338   def int_s390_vtm : SystemZBinaryConv<"vtm", llvm_i32_ty, llvm_v16i8_ty>;
    339 
    340   defm int_s390_vceq : SystemZCompareBHFG<"vceq">;
    341   defm int_s390_vch  : SystemZCompareBHFG<"vch">;
    342   defm int_s390_vchl : SystemZCompareBHFG<"vchl">;
    343 
    344   defm int_s390_vfae  : SystemZTernaryIntBHF<"vfae">;
    345   defm int_s390_vfae  : SystemZTernaryIntCCBHF;
    346   defm int_s390_vfaez : SystemZTernaryIntBHF<"vfaez">;
    347   defm int_s390_vfaez : SystemZTernaryIntCCBHF;
    348 
    349   defm int_s390_vfee  : SystemZBinaryBHF<"vfee">;
    350   defm int_s390_vfee  : SystemZBinaryCCBHF;
    351   defm int_s390_vfeez : SystemZBinaryBHF<"vfeez">;
    352   defm int_s390_vfeez : SystemZBinaryCCBHF;
    353 
    354   defm int_s390_vfene  : SystemZBinaryBHF<"vfene">;
    355   defm int_s390_vfene  : SystemZBinaryCCBHF;
    356   defm int_s390_vfenez : SystemZBinaryBHF<"vfenez">;
    357   defm int_s390_vfenez : SystemZBinaryCCBHF;
    358 
    359   defm int_s390_vistr : SystemZUnaryBHF<"vistr">;
    360   defm int_s390_vistr : SystemZUnaryCCBHF;
    361 
    362   defm int_s390_vstrc  : SystemZQuaternaryIntBHF<"vstrc">;
    363   defm int_s390_vstrc  : SystemZQuaternaryIntCCBHF;
    364   defm int_s390_vstrcz : SystemZQuaternaryIntBHF<"vstrcz">;
    365   defm int_s390_vstrcz : SystemZQuaternaryIntCCBHF;
    366 
    367   def int_s390_vfcedbs  : SystemZBinaryConvCC<llvm_v2i64_ty, llvm_v2f64_ty>;
    368   def int_s390_vfchdbs  : SystemZBinaryConvCC<llvm_v2i64_ty, llvm_v2f64_ty>;
    369   def int_s390_vfchedbs : SystemZBinaryConvCC<llvm_v2i64_ty, llvm_v2f64_ty>;
    370 
    371   def int_s390_vftcidb : SystemZBinaryConvIntCC<llvm_v2i64_ty, llvm_v2f64_ty>;
    372 
    373   def int_s390_vfidb : Intrinsic<[llvm_v2f64_ty],
    374                                  [llvm_v2f64_ty, llvm_i32_ty, llvm_i32_ty],
    375                                  [IntrNoMem]>;
    376 }
    377 
    378 //===----------------------------------------------------------------------===//
    379 //
    380 // Misc intrinsics
    381 //
    382 //===----------------------------------------------------------------------===//
    383 
    384 let TargetPrefix = "s390" in {
    385   def int_s390_sfpc : GCCBuiltin<"__builtin_s390_sfpc">,
    386                       Intrinsic<[], [llvm_i32_ty], []>;
    387   def int_s390_efpc : GCCBuiltin<"__builtin_s390_efpc">,
    388                       Intrinsic<[llvm_i32_ty], [], []>;
    389 
    390   def int_s390_tdc : Intrinsic<[llvm_i32_ty], [llvm_anyfloat_ty, llvm_i64_ty],
    391                                [IntrNoMem]>;
    392 }
    393