Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Implement 64-bit-only hardware intrinsic #21264

Merged
merged 6 commits into from
Dec 3, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,9 @@ public static int CountDigits(uint value)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static int CountHexDigits(ulong value)
{
if (Lzcnt.IsSupported && IntPtr.Size == 8)
if (Lzcnt.X64.IsSupported)
{
int right = 64 - (int)Lzcnt.LeadingZeroCount(value | 1);
int right = 64 - (int)Lzcnt.X64.LeadingZeroCount(value | 1);
return (right + 3) >> 2;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,75 +78,41 @@ internal X64() { }
/// ANDN r32a, r32b, reg/m32
/// </summary>
public static uint AndNot(uint left, uint right) { throw new PlatformNotSupportedException(); }
/// <summary>
/// unsigned __int64 _andn_u64 (unsigned __int64 a, unsigned __int64 b)
/// ANDN r64a, r64b, reg/m64
/// </summary>
public static ulong AndNot(ulong left, ulong right) { throw new PlatformNotSupportedException(); }

/// <summary>
/// unsigned int _bextr_u32 (unsigned int a, unsigned int start, unsigned int len)
/// BEXTR r32a, reg/m32, r32b
/// </summary>
public static uint BitFieldExtract(uint value, byte start, byte length) { throw new PlatformNotSupportedException(); }
/// <summary>
/// unsigned __int64 _bextr_u64 (unsigned __int64 a, unsigned int start, unsigned int len)
/// BEXTR r64a, reg/m64, r64b
/// </summary>
public static ulong BitFieldExtract(ulong value, byte start, byte length) { throw new PlatformNotSupportedException(); }

/// <summary>
/// unsigned int _bextr2_u32 (unsigned int a, unsigned int control)
/// BEXTR r32a, reg/m32, r32b
/// </summary>
public static uint BitFieldExtract(uint value, ushort control) { throw new PlatformNotSupportedException(); }
/// <summary>
/// unsigned __int64 _bextr2_u64 (unsigned __int64 a, unsigned __int64 control)
/// BEXTR r64a, reg/m64, r64b
/// </summary>
public static ulong BitFieldExtract(ulong value, ushort control) { throw new PlatformNotSupportedException(); }

/// <summary>
/// unsigned int _blsi_u32 (unsigned int a)
/// BLSI reg, reg/m32
/// </summary>
public static uint ExtractLowestSetBit(uint value) { throw new PlatformNotSupportedException(); }
/// <summary>
/// unsigned __int64 _blsi_u64 (unsigned __int64 a)
/// BLSI reg, reg/m64
/// </summary>
public static ulong ExtractLowestSetBit(ulong value) { throw new PlatformNotSupportedException(); }

/// <summary>
/// unsigned int _blsmsk_u32 (unsigned int a)
/// BLSMSK reg, reg/m32
/// </summary>
public static uint GetMaskUpToLowestSetBit(uint value) { throw new PlatformNotSupportedException(); }
/// <summary>
/// unsigned __int64 _blsmsk_u64 (unsigned __int64 a)
/// BLSMSK reg, reg/m64
/// </summary>
public static ulong GetMaskUpToLowestSetBit(ulong value) { throw new PlatformNotSupportedException(); }

/// <summary>
/// unsigned int _blsr_u32 (unsigned int a)
/// BLSR reg, reg/m32
/// </summary>
public static uint ResetLowestSetBit(uint value) { throw new PlatformNotSupportedException(); }
/// <summary>
/// unsigned __int64 _blsr_u64 (unsigned __int64 a)
/// BLSR reg, reg/m64
/// </summary>
public static ulong ResetLowestSetBit(ulong value) { throw new PlatformNotSupportedException(); }

/// <summary>
/// int _mm_tzcnt_32 (unsigned int a)
/// TZCNT reg, reg/m32
/// </summary>
public static uint TrailingZeroCount(uint value) { throw new PlatformNotSupportedException(); }
/// <summary>
/// __int64 _mm_tzcnt_64 (unsigned __int64 a)
/// TZCNT reg, reg/m64
/// </summary>
public static ulong TrailingZeroCount(ulong value) { throw new PlatformNotSupportedException(); }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,75 +78,41 @@ internal X64() { }
/// ANDN r32a, r32b, reg/m32
/// </summary>
public static uint AndNot(uint left, uint right) => AndNot(left, right);
/// <summary>
/// unsigned __int64 _andn_u64 (unsigned __int64 a, unsigned __int64 b)
/// ANDN r64a, r64b, reg/m64
/// </summary>
public static ulong AndNot(ulong left, ulong right) => AndNot(left, right);

/// <summary>
/// unsigned int _bextr_u32 (unsigned int a, unsigned int start, unsigned int len)
/// BEXTR r32a, reg/m32, r32b
/// </summary>
public static uint BitFieldExtract(uint value, byte start, byte length) => BitFieldExtract(value, start, length);
/// <summary>
/// unsigned __int64 _bextr_u64 (unsigned __int64 a, unsigned int start, unsigned int len)
/// BEXTR r64a, reg/m64, r64b
/// </summary>
public static ulong BitFieldExtract(ulong value, byte start, byte length) => BitFieldExtract(value, start, length);

/// <summary>
/// unsigned int _bextr2_u32 (unsigned int a, unsigned int control)
/// BEXTR r32a, reg/m32, r32b
/// </summary>
public static uint BitFieldExtract(uint value, ushort control) => BitFieldExtract(value, control);
/// <summary>
/// unsigned __int64 _bextr2_u64 (unsigned __int64 a, unsigned __int64 control)
/// BEXTR r64a, reg/m64, r64b
/// </summary>
public static ulong BitFieldExtract(ulong value, ushort control) => BitFieldExtract(value, control);

/// <summary>
/// unsigned int _blsi_u32 (unsigned int a)
/// BLSI reg, reg/m32
/// </summary>
public static uint ExtractLowestSetBit(uint value) => ExtractLowestSetBit(value);
/// <summary>
/// unsigned __int64 _blsi_u64 (unsigned __int64 a)
/// BLSI reg, reg/m64
/// </summary>
public static ulong ExtractLowestSetBit(ulong value) => ExtractLowestSetBit(value);

/// <summary>
/// unsigned int _blsmsk_u32 (unsigned int a)
/// BLSMSK reg, reg/m32
/// </summary>
public static uint GetMaskUpToLowestSetBit(uint value) => GetMaskUpToLowestSetBit(value);
/// <summary>
/// unsigned __int64 _blsmsk_u64 (unsigned __int64 a)
/// BLSMSK reg, reg/m64
/// </summary>
public static ulong GetMaskUpToLowestSetBit(ulong value) => GetMaskUpToLowestSetBit(value);

/// <summary>
/// unsigned int _blsr_u32 (unsigned int a)
/// BLSR reg, reg/m32
/// </summary>
public static uint ResetLowestSetBit(uint value) => ResetLowestSetBit(value);
/// <summary>
/// unsigned __int64 _blsr_u64 (unsigned __int64 a)
/// BLSR reg, reg/m64
/// </summary>
public static ulong ResetLowestSetBit(ulong value) => ResetLowestSetBit(value);

/// <summary>
/// int _mm_tzcnt_32 (unsigned int a)
/// TZCNT reg, reg/m32
/// </summary>
public static uint TrailingZeroCount(uint value) => TrailingZeroCount(value);
/// <summary>
/// __int64 _mm_tzcnt_64 (unsigned __int64 a)
/// TZCNT reg, reg/m64
/// </summary>
public static ulong TrailingZeroCount(ulong value) => TrailingZeroCount(value);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,43 +57,23 @@ internal X64() { }
/// BZHI r32a, reg/m32, r32b
/// </summary>
public static uint ZeroHighBits(uint value, uint index) { throw new PlatformNotSupportedException(); }
/// <summary>
/// unsigned __int64 _bzhi_u64 (unsigned __int64 a, unsigned int index)
/// BZHI r64a, reg/m32, r64b
/// </summary>
public static ulong ZeroHighBits(ulong value, ulong index) { throw new PlatformNotSupportedException(); }

/// <summary>
/// unsigned int _mulx_u32 (unsigned int a, unsigned int b, unsigned int* hi)
/// MULX r32a, r32b, reg/m32
/// </summary>
public static unsafe uint MultiplyNoFlags(uint left, uint right, uint* high) { throw new PlatformNotSupportedException(); }
/// <summary>
/// unsigned __int64 _mulx_u64 (unsigned __int64 a, unsigned __int64 b, unsigned __int64* hi)
/// MULX r64a, r64b, reg/m64
/// </summary>
public static unsafe ulong MultiplyNoFlags(ulong left, ulong right, ulong* high) { throw new PlatformNotSupportedException(); }

/// <summary>
/// unsigned int _pdep_u32 (unsigned int a, unsigned int mask)
/// PDEP r32a, r32b, reg/m32
/// </summary>
public static uint ParallelBitDeposit(uint value, uint mask) { throw new PlatformNotSupportedException(); }
/// <summary>
/// unsigned __int64 _pdep_u64 (unsigned __int64 a, unsigned __int64 mask)
/// PDEP r64a, r64b, reg/m64
/// </summary>
public static ulong ParallelBitDeposit(ulong value, ulong mask) { throw new PlatformNotSupportedException(); }

/// <summary>
/// unsigned int _pext_u32 (unsigned int a, unsigned int mask)
/// PEXT r32a, r32b, reg/m32
/// </summary>
public static uint ParallelBitExtract(uint value, uint mask) { throw new PlatformNotSupportedException(); }
/// <summary>
/// unsigned __int64 _pext_u64 (unsigned __int64 a, unsigned __int64 mask)
/// PEXT r64a, r64b, reg/m64
/// </summary>
public static ulong ParallelBitExtract(ulong value, ulong mask) { throw new PlatformNotSupportedException(); }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,43 +57,23 @@ internal X64() { }
/// BZHI r32a, reg/m32, r32b
/// </summary>
public static uint ZeroHighBits(uint value, uint index) => ZeroHighBits(value, index);
/// <summary>
/// unsigned __int64 _bzhi_u64 (unsigned __int64 a, unsigned int index)
/// BZHI r64a, reg/m32, r64b
/// </summary>
public static ulong ZeroHighBits(ulong value, ulong index) => ZeroHighBits(value, index);

/// <summary>
/// unsigned int _mulx_u32 (unsigned int a, unsigned int b, unsigned int* hi)
/// MULX r32a, r32b, reg/m32
/// </summary>
public static unsafe uint MultiplyNoFlags(uint left, uint right, uint* high) => MultiplyNoFlags(left, right, high);
/// <summary>
/// unsigned __int64 _mulx_u64 (unsigned __int64 a, unsigned __int64 b, unsigned __int64* hi)
/// MULX r64a, r64b, reg/m64
/// </summary>
public static unsafe ulong MultiplyNoFlags(ulong left, ulong right, ulong* high) => MultiplyNoFlags(left, right, high);

/// <summary>
/// unsigned int _pdep_u32 (unsigned int a, unsigned int mask)
/// PDEP r32a, r32b, reg/m32
/// </summary>
public static uint ParallelBitDeposit(uint value, uint mask) => ParallelBitDeposit(value, mask);
/// <summary>
/// unsigned __int64 _pdep_u64 (unsigned __int64 a, unsigned __int64 mask)
/// PDEP r64a, r64b, reg/m64
/// </summary>
public static ulong ParallelBitDeposit(ulong value, ulong mask) => ParallelBitDeposit(value, mask);

/// <summary>
/// unsigned int _pext_u32 (unsigned int a, unsigned int mask)
/// PEXT r32a, r32b, reg/m32
/// </summary>
public static uint ParallelBitExtract(uint value, uint mask) => ParallelBitExtract(value, mask);
/// <summary>
/// unsigned __int64 _pext_u64 (unsigned __int64 a, unsigned __int64 mask)
/// PEXT r64a, r64b, reg/m64
/// </summary>
public static ulong ParallelBitExtract(ulong value, ulong mask) => ParallelBitExtract(value, mask);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,5 @@ internal X64() { }
/// LZCNT reg, reg/m32
/// </summary>
public static uint LeadingZeroCount(uint value) { throw new PlatformNotSupportedException(); }
/// <summary>
/// unsigned __int64 _lzcnt_u64 (unsigned __int64 a)
/// LZCNT reg, reg/m64
/// </summary>
public static ulong LeadingZeroCount(ulong value) { throw new PlatformNotSupportedException(); }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,5 @@ internal X64() { }
/// LZCNT reg, reg/m32
/// </summary>
public static uint LeadingZeroCount(uint value) => LeadingZeroCount(value);
/// <summary>
/// unsigned __int64 _lzcnt_u64 (unsigned __int64 a)
/// LZCNT reg, reg/m64
/// </summary>
public static ulong LeadingZeroCount(ulong value) => LeadingZeroCount(value);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,19 @@ internal Popcnt() { }
public new abstract class X64 : Sse41.X64
{
internal X64() { }
public new static bool IsSupported { get => IsSupported; }
public new static bool IsSupported { get { return false; } }
/// <summary>
/// __int64 _mm_popcnt_u64 (unsigned __int64 a)
/// POPCNT reg64, reg/m64
/// This intrinisc is only available on 64-bit processes
/// </summary>
public static ulong PopCount(ulong value) => PopCount(value);
public static ulong PopCount(ulong value) { throw new PlatformNotSupportedException(); }
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed a mistake from previous PRs.

}

/// <summary>
/// int _mm_popcnt_u32 (unsigned int a)
/// POPCNT reg, reg/m32
/// </summary>
public static uint PopCount(uint value) { throw new PlatformNotSupportedException(); }
/// <summary>
/// __int64 _mm_popcnt_u64 (unsigned __int64 a)
/// POPCNT reg64, reg/m64
/// </summary>
public static ulong PopCount(ulong value) { throw new PlatformNotSupportedException(); }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,5 @@ internal X64() { }
/// POPCNT reg, reg/m32
/// </summary>
public static uint PopCount(uint value) => PopCount(value);
/// <summary>
/// __int64 _mm_popcnt_u64 (unsigned __int64 a)
/// POPCNT reg, reg/m64
/// </summary>
public static ulong PopCount(ulong value) => PopCount(value);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -290,33 +290,18 @@ internal X64() { }
/// CVTSS2SI r32, xmm/m32
/// </summary>
public static int ConvertToInt32(Vector128<float> value) { throw new PlatformNotSupportedException(); }
/// <summary>
/// __int64 _mm_cvtss_si64 (__m128 a)
/// CVTSS2SI r64, xmm/m32
/// </summary>
public static long ConvertToInt64(Vector128<float> value) { throw new PlatformNotSupportedException(); }

/// <summary>
/// __m128 _mm_cvtsi32_ss (__m128 a, int b)
/// CVTSI2SS xmm, reg/m32
/// </summary>
public static Vector128<float> ConvertScalarToVector128Single(Vector128<float> upper, int value) { throw new PlatformNotSupportedException(); }
/// <summary>
/// __m128 _mm_cvtsi64_ss (__m128 a, __int64 b)
/// CVTSI2SS xmm, reg/m64
/// </summary>
public static Vector128<float> ConvertScalarToVector128Single(Vector128<float> upper, long value) { throw new PlatformNotSupportedException(); }

/// <summary>
/// int _mm_cvttss_si32 (__m128 a)
/// CVTTSS2SI r32, xmm/m32
/// </summary>
public static int ConvertToInt32WithTruncation(Vector128<float> value) { throw new PlatformNotSupportedException(); }
/// <summary>
/// __int64 _mm_cvttss_si64 (__m128 a)
/// CVTTSS2SI r64, xmm/m32
/// </summary>
public static long ConvertToInt64WithTruncation(Vector128<float> value) { throw new PlatformNotSupportedException(); }

/// <summary>
/// __m128 _mm_div_ps (__m128 a, __m128 b)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,33 +291,18 @@ internal X64() { }
/// CVTSS2SI r32, xmm/m32
/// </summary>
public static int ConvertToInt32(Vector128<float> value) => ConvertToInt32(value);
/// <summary>
/// __int64 _mm_cvtss_si64 (__m128 a)
/// CVTSS2SI r64, xmm/m32
/// </summary>
public static long ConvertToInt64(Vector128<float> value) => ConvertToInt64(value);

/// <summary>
/// __m128 _mm_cvtsi32_ss (__m128 a, int b)
/// CVTSI2SS xmm, reg/m32
/// </summary>
public static Vector128<float> ConvertScalarToVector128Single(Vector128<float> upper, int value) => ConvertScalarToVector128Single(upper, value);
/// <summary>
/// __m128 _mm_cvtsi64_ss (__m128 a, __int64 b)
/// CVTSI2SS xmm, reg/m64
/// </summary>
public static Vector128<float> ConvertScalarToVector128Single(Vector128<float> upper, long value) => ConvertScalarToVector128Single(upper, value);

/// <summary>
/// int _mm_cvttss_si32 (__m128 a)
/// CVTTSS2SI r32, xmm/m32
/// </summary>
public static int ConvertToInt32WithTruncation(Vector128<float> value) => ConvertToInt32WithTruncation(value);
/// <summary>
/// __int64 _mm_cvttss_si64 (__m128 a)
/// CVTTSS2SI r64, xmm/m32
/// </summary>
public static long ConvertToInt64WithTruncation(Vector128<float> value) => ConvertToInt64WithTruncation(value);

/// <summary>
/// __m128 _mm_div_ps (__m128 a, __m128 b)
Expand Down
Loading