Optimizations.cs 3.2 KB

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