WasmMath.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. //-------------------------------------------------------------------------------------------------------
  2. // Copyright (C) Microsoft Corporation and contributors. All rights reserved.
  3. // Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
  4. //-------------------------------------------------------------------------------------------------------
  5. #pragma once
  6. namespace Wasm
  7. {
  8. class WasmMath
  9. {
  10. public:
  11. template<typename T> static int Eqz(T value);
  12. template<typename T> static T Shl( T aLeft, T aRight );
  13. template<typename T> static T Shr( T aLeft, T aRight );
  14. template<typename T> static T ShrU( T aLeft, T aRight );
  15. template<typename T> static T VECTORCALL Copysign(T aLeft, T aRight);
  16. template<typename T> static T Trunc(T aLeft);
  17. template<typename T> static T Nearest(T aLeft);
  18. template<typename T> static T PopCnt(T value);
  19. template<typename T> static T Ctz(T value);
  20. template<typename T> static T Clz(T value);
  21. template<typename T> static T Rol(T aLeft, T aRight);
  22. template<typename T> static T Ror(T aLeft, T aRight);
  23. template <typename T> bool static LessThan(T aLeft, T aRight);
  24. template <typename T> bool static LessOrEqual(T aLeft, T aRight);
  25. template <typename T> using CmpPtr = bool(*)(T a, T b);
  26. template <
  27. typename SourceType,
  28. typename DstType,
  29. typename ReinterpretType,
  30. ReinterpretType Max,
  31. ReinterpretType NegZero,
  32. ReinterpretType NegOne,
  33. CmpPtr<ReinterpretType> MaxCmp,
  34. CmpPtr<ReinterpretType> NegOneCmp,
  35. bool Saturate,
  36. DstType MinResult,
  37. DstType MaxResult>
  38. static DstType ConvertFloatToInt(SourceType srcVal, _In_ Js::ScriptContext* scriptContext);
  39. template <typename STYPE> static bool IsNaN(STYPE src);
  40. template<typename To, typename From> static To SignExtend(To value);
  41. template <bool Saturate>
  42. static int64 F32ToI64(float src, _In_ Js::ScriptContext* scriptContext);
  43. template <bool Saturate>
  44. static uint64 F32ToU64(float src, _In_ Js::ScriptContext* scriptContext);
  45. template <bool Saturate>
  46. static int64 F64ToI64(double src, _In_ Js::ScriptContext* scriptContext);
  47. template <bool Saturate>
  48. static uint64 F64ToU64(double src, _In_ Js::ScriptContext* scriptContext);
  49. template <bool Saturate>
  50. static int32 F32ToI32(float src, _In_ Js::ScriptContext* scriptContext);
  51. template <bool Saturate>
  52. static uint32 F32ToU32(float src, _In_ Js::ScriptContext* scriptContext);
  53. template <bool Saturate>
  54. static int32 F64ToI32(double src, _In_ Js::ScriptContext* scriptContext);
  55. template <bool Saturate>
  56. static uint32 F64ToU32(double src, _In_ Js::ScriptContext* scriptContext);
  57. };
  58. } //namespace Wasm
  59. #include "WasmMath.inl"