OpCodesSimd.h 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. //-------------------------------------------------------------------------------------------------------
  2. // Copyright (C) Microsoft. All rights reserved.
  3. // Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
  4. //-------------------------------------------------------------------------------------------------------
  5. /*
  6. SIMD.js opcodes
  7. - All opcodes are typed.
  8. - Used as bytecode for AsmJs Interpreter.
  9. - Used as IR by the backend only for both AsmJs and non-AsmJs code.
  10. */
  11. // used as both AsmJs bytecode and IR
  12. #ifndef MACRO_SIMD
  13. #define MACRO_SIMD(opcode, asmjsLayout, opCodeAttrAsmJs, OpCodeAttr, ...)
  14. #endif
  15. #ifndef MACRO_SIMD_WMS
  16. #define MACRO_SIMD_WMS(opcode, asmjsLayout, opCodeAttrAsmJs, OpCodeAttr, ...)
  17. #endif
  18. // used as AsmJs bytecode only
  19. #ifndef MACRO_SIMD_ASMJS_ONLY_WMS
  20. #define MACRO_SIMD_ASMJS_ONLY_WMS(opcode, asmjsLayout, opCodeAttrAsmJs, OpCodeAttr, ...)
  21. #endif
  22. // used as IR only
  23. #ifndef MACRO_SIMD_BACKEND_ONLY
  24. #define MACRO_SIMD_BACKEND_ONLY(opcode, asmjsLayout, opCodeAttrAsmJs, OpCodeAttr)
  25. #endif
  26. // same as above but with extended opcodes
  27. #ifndef MACRO_SIMD_EXTEND
  28. #define MACRO_SIMD_EXTEND(opcode, asmjsLayout, opCodeAttrAsmJs, OpCodeAttr, ...)
  29. #endif
  30. #ifndef MACRO_SIMD_EXTEND_WMS
  31. #define MACRO_SIMD_EXTEND_WMS(opcode, asmjsLayout, opCodeAttrAsmJs, OpCodeAttr, ...)
  32. #endif
  33. // used as AsmJs bytecode only
  34. #ifndef MACRO_SIMD_ASMJS_ONLY_EXTEND_WMS
  35. #define MACRO_SIMD_ASMJS_ONLY_EXTEND_WMS(opcode, asmjsLayout, opCodeAttrAsmJs, OpCodeAttr, ...)
  36. #endif
  37. // used as IR only
  38. #ifndef MACRO_SIMD_BACKEND_ONLY_EXTEND
  39. #define MACRO_SIMD_BACKEND_ONLY_EXTEND(opcode, asmjsLayout, opCodeAttrAsmJs, OpCodeAttr)
  40. #endif
  41. // OpCode , LayoutAsmJs , OpCodeAttrAsmJs, OpCodeAttr Addition macro args FuncInfo Ret and Args ValueTypes
  42. // | | | | | | |
  43. // v v v v v v v
  44. MACRO_SIMD ( Simd128_Start , Empty , None , None , 0) // Just a marker to indicate SIMD opcodes region
  45. // Int32x4
  46. MACRO_SIMD_WMS ( Simd128_IntsToI4 , Int32x4_1Int4 , None , OpCanCSE , 6, &Js::SIMDInt32x4Lib::EntryInfo::Int32x4, ValueType::GetSimd128(ObjectType::Simd128Int32x4), ValueType::GetInt(false), ValueType::GetInt(false), ValueType::GetInt(false), ValueType::GetInt(false))
  47. MACRO_SIMD_WMS ( Simd128_Splat_I4 , Int32x4_1Int1 , None , OpCanCSE , 0)
  48. MACRO_SIMD_WMS ( Simd128_FromFloat64x2_I4 , Int32x4_1Float64x2_1 , None , OpCanCSE , 0)
  49. MACRO_SIMD_WMS ( Simd128_FromFloat64x2Bits_I4 , Int32x4_1Float64x2_1 , None , OpCanCSE , 0)
  50. MACRO_SIMD_WMS ( Simd128_FromFloat32x4_I4 , Int32x4_1Float32x4_1 , None , OpCanCSE , 0)
  51. MACRO_SIMD_WMS ( Simd128_FromFloat32x4Bits_I4 , Int32x4_1Float32x4_1 , None , OpCanCSE , 0)
  52. MACRO_SIMD_WMS ( Simd128_Neg_I4 , Int32x4_2 , None , OpCanCSE , 0)
  53. MACRO_SIMD_WMS ( Simd128_Add_I4 , Int32x4_3 , None , OpCanCSE , 4, &Js::SIMDInt32x4Lib::EntryInfo::Add, ValueType::GetSimd128(ObjectType::Simd128Int32x4), ValueType::GetSimd128(ObjectType::Simd128Int32x4), ValueType::GetSimd128(ObjectType::Simd128Int32x4))
  54. MACRO_SIMD_WMS ( Simd128_Sub_I4 , Int32x4_3 , None , OpCanCSE , 0)
  55. MACRO_SIMD_WMS ( Simd128_Mul_I4 , Int32x4_3 , None , OpCanCSE , 0)
  56. MACRO_SIMD_WMS ( Simd128_Lt_I4 , Int32x4_3 , None , OpCanCSE , 0)
  57. MACRO_SIMD_WMS ( Simd128_Gt_I4 , Int32x4_3 , None , OpCanCSE , 0)
  58. MACRO_SIMD_WMS ( Simd128_Eq_I4 , Int32x4_3 , None , OpCanCSE , 0)
  59. MACRO_SIMD_WMS ( Simd128_Select_I4 , Int32x4_4 , None , OpCanCSE , 0)
  60. MACRO_SIMD_WMS ( Simd128_And_I4 , Int32x4_3 , None , OpCanCSE , 0)
  61. MACRO_SIMD_WMS ( Simd128_Or_I4 , Int32x4_3 , None , OpCanCSE , 0)
  62. MACRO_SIMD_WMS ( Simd128_Xor_I4 , Int32x4_3 , None , OpCanCSE , 0)
  63. MACRO_SIMD_WMS ( Simd128_Not_I4 , Int32x4_2 , None , OpCanCSE , 0)
  64. MACRO_SIMD_WMS ( Simd128_Shr_I4 , Int32x4_2Int1 , None , OpCanCSE , 0)
  65. MACRO_SIMD_WMS ( Simd128_ShrA_I4 , Int32x4_2Int1 , None , OpCanCSE , 0)
  66. MACRO_SIMD_WMS ( Simd128_Shl_I4 , Int32x4_2Int1 , None , OpCanCSE , 0)
  67. MACRO_SIMD_WMS ( Simd128_Swizzle_I4 , Int32x4_2Int4 , None , OpCanCSE , 0)
  68. MACRO_SIMD_WMS ( Simd128_Shuffle_I4 , Int32x4_3Int4 , None , OpCanCSE , 0)
  69. MACRO_SIMD_WMS ( Simd128_LdSignMask_I4 , Int1Int32x4_1 , None , OpCanCSE , 0)
  70. MACRO_SIMD_ASMJS_ONLY_WMS ( Simd128_Ld_I4 , Int32x4_2 , None , None )
  71. MACRO_SIMD_ASMJS_ONLY_WMS ( Simd128_LdSlot_I4 , ElementSlot , None , None )
  72. MACRO_SIMD_ASMJS_ONLY_WMS ( Simd128_StSlot_I4 , ElementSlot , None , None )
  73. MACRO_SIMD_ASMJS_ONLY_WMS ( Simd128_Return_I4 , Int32x4_2 , None , None )
  74. MACRO_SIMD_ASMJS_ONLY_WMS ( Simd128_I_ArgOut_I4 , Reg1Int32x4_1 , None , None )
  75. MACRO_SIMD_ASMJS_ONLY_WMS ( Simd128_I_Conv_VTI4 , Int32x4_2 , None , None )
  76. // Float32x4
  77. MACRO_SIMD_WMS ( Simd128_FloatsToF4 , Float32x4_1Float4 , None , OpCanCSE , 6, &Js::SIMDFloat32x4Lib::EntryInfo::Float32x4, ValueType::GetSimd128(ObjectType::Simd128Float32x4), ValueType::Float, ValueType::Float, ValueType::Float, ValueType::Float)
  78. MACRO_SIMD_WMS ( Simd128_Splat_F4 , Float32x4_1Float1 , None , OpCanCSE , 0)
  79. MACRO_SIMD_WMS ( Simd128_FromFloat64x2_F4 , Float32x4_1Float64x2_1 , None , OpCanCSE , 0)
  80. MACRO_SIMD_WMS ( Simd128_FromFloat64x2Bits_F4 , Float32x4_1Float64x2_1 , None , OpCanCSE , 0)
  81. MACRO_SIMD_WMS ( Simd128_FromInt32x4_F4 , Float32x4_1Int32x4_1 , None , OpCanCSE , 0)
  82. MACRO_SIMD_WMS ( Simd128_FromInt32x4Bits_F4 , Float32x4_1Int32x4_1 , None , OpCanCSE , 0)
  83. MACRO_SIMD_WMS ( Simd128_Abs_F4 , Float32x4_2 , None , OpCanCSE , 0)
  84. MACRO_SIMD_WMS ( Simd128_Neg_F4 , Float32x4_2 , None , OpCanCSE , 0)
  85. MACRO_SIMD_WMS ( Simd128_Add_F4 , Float32x4_3 , None , OpCanCSE , 4, &Js::SIMDFloat32x4Lib::EntryInfo::Add, ValueType::GetSimd128(ObjectType::Simd128Float32x4), ValueType::GetSimd128(ObjectType::Simd128Float32x4), ValueType::GetSimd128(ObjectType::Simd128Float32x4))
  86. MACRO_SIMD_WMS ( Simd128_Sub_F4 , Float32x4_3 , None , OpCanCSE , 0)
  87. MACRO_SIMD_WMS ( Simd128_Mul_F4 , Float32x4_3 , None , OpCanCSE , 0)
  88. MACRO_SIMD_WMS ( Simd128_Div_F4 , Float32x4_3 , None , OpCanCSE , 0)
  89. MACRO_SIMD_WMS ( Simd128_Clamp_F4 , Float32x4_4 , None , OpCanCSE , 0)
  90. MACRO_SIMD_WMS ( Simd128_Min_F4 , Float32x4_3 , None , OpCanCSE , 0)
  91. MACRO_SIMD_WMS ( Simd128_Max_F4 , Float32x4_3 , None , OpCanCSE , 0)
  92. MACRO_SIMD_WMS ( Simd128_Rcp_F4 , Float32x4_2 , None , OpCanCSE , 0)
  93. MACRO_SIMD_WMS ( Simd128_RcpSqrt_F4 , Float32x4_2 , None , OpCanCSE , 0)
  94. MACRO_SIMD_WMS ( Simd128_Sqrt_F4 , Float32x4_2 , None , OpCanCSE , 0)
  95. MACRO_SIMD_WMS ( Simd128_Swizzle_F4 , Float32x4_2Int4 , None , OpCanCSE , 0)
  96. MACRO_SIMD_WMS ( Simd128_Shuffle_F4 , Float32x4_3Int4 , None , OpCanCSE , 0)
  97. MACRO_SIMD_WMS ( Simd128_Lt_F4 , Float32x4_3 , None , OpCanCSE , 0)
  98. MACRO_SIMD_WMS ( Simd128_LtEq_F4 , Float32x4_3 , None , OpCanCSE , 0)
  99. MACRO_SIMD_WMS ( Simd128_Eq_F4 , Float32x4_3 , None , OpCanCSE , 0)
  100. MACRO_SIMD_WMS ( Simd128_Neq_F4 , Float32x4_3 , None , OpCanCSE , 0)
  101. MACRO_SIMD_WMS ( Simd128_Gt_F4 , Float32x4_3 , None , OpCanCSE , 0)
  102. MACRO_SIMD_WMS ( Simd128_GtEq_F4 , Float32x4_3 , None , OpCanCSE , 0)
  103. MACRO_SIMD_WMS ( Simd128_Select_F4 , Float32x4_1Int32x4_1Float32x4_2 , None , OpCanCSE , 0)
  104. MACRO_SIMD_WMS ( Simd128_And_F4 , Float32x4_3 , None , OpCanCSE , 0)
  105. MACRO_SIMD_WMS ( Simd128_Or_F4 , Float32x4_3 , None , OpCanCSE , 0)
  106. MACRO_SIMD_WMS ( Simd128_Xor_F4 , Float32x4_3 , None , OpCanCSE , 0)
  107. MACRO_SIMD_WMS ( Simd128_Not_F4 , Float32x4_2 , None , OpCanCSE , 0)
  108. MACRO_SIMD_WMS ( Simd128_LdSignMask_F4 , Int1Float32x4_1 , None , OpCanCSE , 0)
  109. MACRO_SIMD_ASMJS_ONLY_WMS ( Simd128_Ld_F4 , Float32x4_2 , None , None )
  110. MACRO_SIMD_ASMJS_ONLY_WMS ( Simd128_LdSlot_F4 , ElementSlot , None , None )
  111. MACRO_SIMD_ASMJS_ONLY_WMS ( Simd128_StSlot_F4 , ElementSlot , None , None )
  112. MACRO_SIMD_ASMJS_ONLY_WMS ( Simd128_Return_F4 , Float32x4_2 , None , None )
  113. MACRO_SIMD_ASMJS_ONLY_WMS ( Simd128_I_ArgOut_F4 , Reg1Float32x4_1 , None , None )
  114. MACRO_SIMD_ASMJS_ONLY_WMS ( Simd128_I_Conv_VTF4 , Float32x4_2 , None , None )
  115. // Float64x2 , 0
  116. MACRO_SIMD_WMS ( Simd128_DoublesToD2 , Float64x2_1Double2 , None , OpCanCSE , 0)
  117. MACRO_SIMD_WMS ( Simd128_Splat_D2 , Float64x2_1Double1 , None , OpCanCSE , 0)
  118. MACRO_SIMD_WMS ( Simd128_FromFloat32x4_D2 , Float64x2_1Float32x4_1 , None , OpCanCSE , 0)
  119. MACRO_SIMD_WMS ( Simd128_FromFloat32x4Bits_D2 , Float64x2_1Float32x4_1 , None , OpCanCSE , 0)
  120. MACRO_SIMD_WMS ( Simd128_FromInt32x4_D2 , Float64x2_1Int32x4_1 , None , OpCanCSE , 0)
  121. MACRO_SIMD_WMS ( Simd128_FromInt32x4Bits_D2 , Float64x2_1Int32x4_1 , None , OpCanCSE , 0)
  122. MACRO_SIMD_WMS ( Simd128_Abs_D2 , Float64x2_2 , None , OpCanCSE , 0)
  123. MACRO_SIMD_WMS ( Simd128_Neg_D2 , Float64x2_2 , None , OpCanCSE , 0)
  124. MACRO_SIMD_WMS ( Simd128_Add_D2 , Float64x2_3 , None , OpCanCSE , 0)
  125. MACRO_SIMD_WMS ( Simd128_Sub_D2 , Float64x2_3 , None , OpCanCSE , 0)
  126. MACRO_SIMD_WMS ( Simd128_Mul_D2 , Float64x2_3 , None , OpCanCSE , 0)
  127. MACRO_SIMD_WMS ( Simd128_Div_D2 , Float64x2_3 , None , OpCanCSE , 0)
  128. MACRO_SIMD_WMS ( Simd128_Clamp_D2 , Float64x2_4 , None , OpCanCSE , 0)
  129. MACRO_SIMD_WMS ( Simd128_Min_D2 , Float64x2_3 , None , OpCanCSE , 0)
  130. MACRO_SIMD_WMS ( Simd128_Max_D2 , Float64x2_3 , None , OpCanCSE , 0)
  131. MACRO_SIMD_WMS ( Simd128_Rcp_D2 , Float64x2_2 , None , OpCanCSE , 0)
  132. MACRO_SIMD_WMS ( Simd128_RcpSqrt_D2 , Float64x2_2 , None , OpCanCSE , 0)
  133. MACRO_SIMD_WMS ( Simd128_Sqrt_D2 , Float64x2_2 , None , OpCanCSE , 0)
  134. MACRO_SIMD_WMS ( Simd128_Lt_D2 , Float64x2_3 , None , OpCanCSE , 0)
  135. MACRO_SIMD_WMS ( Simd128_Select_D2 , Float64x2_1Int32x4_1Float64x2_2 , None , OpCanCSE , 0)
  136. MACRO_SIMD_WMS ( Simd128_LdSignMask_D2 , Int1Float64x2_1 , None , OpCanCSE , 0)
  137. MACRO_SIMD_WMS ( Simd128_LtEq_D2 , Float64x2_3 , None , OpCanCSE , 0)
  138. MACRO_SIMD_WMS ( Simd128_Eq_D2 , Float64x2_3 , None , OpCanCSE , 0)
  139. MACRO_SIMD_WMS ( Simd128_Neq_D2 , Float64x2_3 , None , OpCanCSE , 0)
  140. MACRO_SIMD_WMS ( Simd128_Gt_D2 , Float64x2_3 , None , OpCanCSE , 0)
  141. MACRO_SIMD_WMS ( Simd128_GtEq_D2 , Float64x2_3 , None , OpCanCSE , 0)
  142. MACRO_SIMD_ASMJS_ONLY_WMS ( Simd128_Return_D2 , Float64x2_2 , None , None )
  143. MACRO_SIMD_ASMJS_ONLY_WMS ( Simd128_I_ArgOut_D2 , Reg1Float64x2_1 , None , None )
  144. MACRO_SIMD_ASMJS_ONLY_WMS ( Simd128_I_Conv_VTD2 , Float64x2_2 , None , None )
  145. MACRO_SIMD_BACKEND_ONLY ( Simd128_LdC , Empty , None , OpCanCSE ) // Load Simd128 const stack slot
  146. MACRO_SIMD ( Simd128_End , Empty , None , None ) // Just a marker to indicate SIMD opcodes region
  147. // Extended opcodes. Running out of 1-byte opcode space. Add new opcodes here.
  148. MACRO_SIMD_EXTEND ( Simd128_Start_Extend , Empty , None , None , 0) // Just a marker to indicate SIMD opcodes region
  149. MACRO_SIMD_ASMJS_ONLY_EXTEND_WMS ( Simd128_Ld_D2 , Float64x2_2 , None , None )
  150. MACRO_SIMD_ASMJS_ONLY_EXTEND_WMS ( Simd128_LdSlot_D2 , ElementSlot , None , None )
  151. MACRO_SIMD_ASMJS_ONLY_EXTEND_WMS ( Simd128_StSlot_D2 , ElementSlot , None , None )
  152. MACRO_SIMD_EXTEND_WMS ( Simd128_Swizzle_D2 , Float64x2_2Int2 , None , OpCanCSE , 0)
  153. MACRO_SIMD_EXTEND_WMS ( Simd128_Shuffle_D2 , Float64x2_3Int2 , None , OpCanCSE , 0)
  154. MACRO_SIMD_EXTEND_WMS ( Simd128_LdArr_I4 , AsmSimdTypedArr , None , OpCanCSE , 0)
  155. MACRO_SIMD_EXTEND_WMS ( Simd128_LdArrConst_I4 , AsmSimdTypedArr , None , OpCanCSE , 0)
  156. MACRO_SIMD_EXTEND_WMS ( Simd128_LdArr_F4 , AsmSimdTypedArr , None , OpCanCSE , 0)
  157. MACRO_SIMD_EXTEND_WMS ( Simd128_LdArrConst_F4 , AsmSimdTypedArr , None , OpCanCSE , 0)
  158. MACRO_SIMD_EXTEND_WMS ( Simd128_LdArr_D2 , AsmSimdTypedArr , None , OpCanCSE , 0)
  159. MACRO_SIMD_EXTEND_WMS ( Simd128_LdArrConst_D2 , AsmSimdTypedArr , None , OpCanCSE , 0)
  160. MACRO_SIMD_EXTEND_WMS ( Simd128_StArr_I4 , AsmSimdTypedArr , None , OpCanCSE , 0)
  161. MACRO_SIMD_EXTEND_WMS ( Simd128_StArrConst_I4 , AsmSimdTypedArr , None , OpCanCSE , 0)
  162. MACRO_SIMD_EXTEND_WMS ( Simd128_StArr_F4 , AsmSimdTypedArr , None , OpCanCSE , 0)
  163. MACRO_SIMD_EXTEND_WMS ( Simd128_StArrConst_F4 , AsmSimdTypedArr , None , OpCanCSE , 0)
  164. MACRO_SIMD_EXTEND_WMS ( Simd128_StArr_D2 , AsmSimdTypedArr , None , OpCanCSE , 0)
  165. MACRO_SIMD_EXTEND_WMS ( Simd128_StArrConst_D2 , AsmSimdTypedArr , None , OpCanCSE , 0)
  166. MACRO_SIMD_EXTEND_WMS ( Simd128_ExtractLane_I4 , Int1Int32x4_1Int1 , None , OpCanCSE , 0)
  167. MACRO_SIMD_EXTEND_WMS ( Simd128_ReplaceLane_I4 , Int32x4_2Int2 , None , OpCanCSE , 0)
  168. MACRO_SIMD_EXTEND_WMS ( Simd128_ExtractLane_F4 , Float1Float32x4_1Int1 , None , OpCanCSE , 0)
  169. MACRO_SIMD_EXTEND_WMS ( Simd128_ReplaceLane_F4 , Float32x4_2Int1Float1 , None , OpCanCSE , 0)
  170. MACRO_SIMD_EXTEND ( Simd128_End_Extend , Empty , None , None , 0) // Just a marker to indicate SIMD opcodes region
  171. #undef MACRO_SIMD
  172. #undef MACRO_SIMD_WMS
  173. #undef MACRO_SIMD_ASMJS_ONLY_WMS
  174. #undef MACRO_SIMD_BACKEND_ONLY
  175. #undef MACRO_SIMD_EXTEND
  176. #undef MACRO_SIMD_EXTEND_WMS
  177. #undef MACRO_SIMD_ASMJS_ONLY_EXTEND_WMS
  178. #undef MACRO_SIMD_BACKEND_ONLY_EXTEND