暫無描述
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Common.cs 1.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. using System;
  2. namespace Unity.Burst.Intrinsics
  3. {
  4. /// <summary>
  5. /// Static methods and properties for X86 instruction intrinsics.
  6. /// </summary>
  7. public unsafe static partial class X86
  8. {
  9. private static v128 GenericCSharpLoad(void* ptr)
  10. {
  11. return *(v128*)ptr;
  12. }
  13. private static void GenericCSharpStore(void* ptr, v128 val)
  14. {
  15. *(v128*)ptr = val;
  16. }
  17. private static sbyte Saturate_To_Int8(int val)
  18. {
  19. if (val > sbyte.MaxValue)
  20. return sbyte.MaxValue;
  21. else if (val < sbyte.MinValue)
  22. return sbyte.MinValue;
  23. return (sbyte)val;
  24. }
  25. private static byte Saturate_To_UnsignedInt8(int val)
  26. {
  27. if (val > byte.MaxValue)
  28. return byte.MaxValue;
  29. else if (val < byte.MinValue)
  30. return byte.MinValue;
  31. return (byte)val;
  32. }
  33. private static short Saturate_To_Int16(int val)
  34. {
  35. if (val > short.MaxValue)
  36. return short.MaxValue;
  37. else if (val < short.MinValue)
  38. return short.MinValue;
  39. return (short)val;
  40. }
  41. private static ushort Saturate_To_UnsignedInt16(int val)
  42. {
  43. if (val > ushort.MaxValue)
  44. return ushort.MaxValue;
  45. else if (val < ushort.MinValue)
  46. return ushort.MinValue;
  47. return (ushort)val;
  48. }
  49. private static bool IsNaN(uint v)
  50. {
  51. return (v & 0x7fffffffu) > 0x7f800000;
  52. }
  53. private static bool IsNaN(ulong v)
  54. {
  55. return (v & 0x7ffffffffffffffful) > 0x7ff0000000000000ul;
  56. }
  57. }
  58. }