Optimizations.cs 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. using System.Runtime.Intrinsics.Arm;
  2. namespace ARMeilleure
  3. {
  4. using Arm64HardwareCapabilities = ARMeilleure.CodeGen.Arm64.HardwareCapabilities;
  5. using X86HardwareCapabilities = ARMeilleure.CodeGen.X86.HardwareCapabilities;
  6. public static class Optimizations
  7. {
  8. public static bool FastFP { get; set; } = true;
  9. public static bool AllowLcqInFunctionTable { get; set; } = true;
  10. public static bool UseUnmanagedDispatchLoop { get; set; } = true;
  11. public static bool UseAdvSimdIfAvailable { get; set; } = true;
  12. public static bool UseArm64PmullIfAvailable { get; set; } = true;
  13. public static bool UseSseIfAvailable { get; set; } = true;
  14. public static bool UseSse2IfAvailable { get; set; } = true;
  15. public static bool UseSse3IfAvailable { get; set; } = true;
  16. public static bool UseSsse3IfAvailable { get; set; } = true;
  17. public static bool UseSse41IfAvailable { get; set; } = true;
  18. public static bool UseSse42IfAvailable { get; set; } = true;
  19. public static bool UsePopCntIfAvailable { get; set; } = true;
  20. public static bool UseAvxIfAvailable { get; set; } = true;
  21. public static bool UseF16cIfAvailable { get; set; } = true;
  22. public static bool UseFmaIfAvailable { get; set; } = true;
  23. public static bool UseAesniIfAvailable { get; set; } = true;
  24. public static bool UsePclmulqdqIfAvailable { get; set; } = true;
  25. public static bool UseShaIfAvailable { get; set; } = true;
  26. public static bool UseGfniIfAvailable { get; set; } = true;
  27. public static bool ForceLegacySse
  28. {
  29. get => X86HardwareCapabilities.ForceLegacySse;
  30. set => X86HardwareCapabilities.ForceLegacySse = value;
  31. }
  32. internal static bool UseAdvSimd => UseAdvSimdIfAvailable && Arm64HardwareCapabilities.SupportsAdvSimd;
  33. internal static bool UseArm64Pmull => UseArm64PmullIfAvailable && Arm64HardwareCapabilities.SupportsPmull;
  34. internal static bool UseSse => UseSseIfAvailable && X86HardwareCapabilities.SupportsSse;
  35. internal static bool UseSse2 => UseSse2IfAvailable && X86HardwareCapabilities.SupportsSse2;
  36. internal static bool UseSse3 => UseSse3IfAvailable && X86HardwareCapabilities.SupportsSse3;
  37. internal static bool UseSsse3 => UseSsse3IfAvailable && X86HardwareCapabilities.SupportsSsse3;
  38. internal static bool UseSse41 => UseSse41IfAvailable && X86HardwareCapabilities.SupportsSse41;
  39. internal static bool UseSse42 => UseSse42IfAvailable && X86HardwareCapabilities.SupportsSse42;
  40. internal static bool UsePopCnt => UsePopCntIfAvailable && X86HardwareCapabilities.SupportsPopcnt;
  41. internal static bool UseAvx => UseAvxIfAvailable && X86HardwareCapabilities.SupportsAvx && !ForceLegacySse;
  42. internal static bool UseF16c => UseF16cIfAvailable && X86HardwareCapabilities.SupportsF16c;
  43. internal static bool UseFma => UseFmaIfAvailable && X86HardwareCapabilities.SupportsFma;
  44. internal static bool UseAesni => UseAesniIfAvailable && X86HardwareCapabilities.SupportsAesni;
  45. internal static bool UsePclmulqdq => UsePclmulqdqIfAvailable && X86HardwareCapabilities.SupportsPclmulqdq;
  46. internal static bool UseSha => UseShaIfAvailable && X86HardwareCapabilities.SupportsSha;
  47. internal static bool UseGfni => UseGfniIfAvailable && X86HardwareCapabilities.SupportsGfni;
  48. }
  49. }