Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ WidenAsciiToUtf16_Intrinsified()

static unsafe nuint System.Text.ASCIIUtility.WidenAsciiToUtf16_Intrinsified ( byte * pAsciiBuffer,
char * pUtf16Buffer,
nuint elementCount )
inlinestaticprivate

Definition at line 877 of file ASCIIUtility.cs.

878 {
879 uint num = (uint)Unsafe.SizeOf<Vector128<byte>>();
880 nuint num2 = num - 1;
881 if (Sse2.IsSupported)
882 {
883 Vector128<byte> vector = Sse2.LoadVector128(pAsciiBuffer);
884 if (Sse2.MoveMask(vector) != 0)
885 {
886 return 0u;
887 }
889 if (Sse2.IsSupported)
890 {
891 Vector128<byte> source = Sse2.UnpackLow(vector, zero);
892 Sse2.Store((byte*)pUtf16Buffer, source);
893 nuint num3 = (num >> 1) - (((nuint)pUtf16Buffer >> 1) & (num2 >> 1));
894 nuint num4 = elementCount - num;
895 char* ptr = pUtf16Buffer + num3;
896 while (true)
897 {
898 if (Sse2.IsSupported)
899 {
900 vector = Sse2.LoadVector128(pAsciiBuffer + num3);
901 bool flag = Sse2.MoveMask(vector) != 0;
902 if (!flag)
903 {
904 if (!Sse2.IsSupported)
905 {
907 {
908 }
909 throw new PlatformNotSupportedException();
910 }
911 Vector128<byte> source2 = Sse2.UnpackLow(vector, zero);
912 Sse2.StoreAligned((byte*)ptr, source2);
913 Vector128<byte> source3 = Sse2.UnpackHigh(vector, zero);
914 Sse2.StoreAligned((byte*)ptr + num, source3);
915 num3 += num;
916 ptr += num;
917 if (num3 <= num4)
918 {
919 continue;
920 }
921 }
922 else if (!flag)
923 {
924 if (!Sse2.IsSupported)
925 {
926 break;
927 }
928 source = Sse2.UnpackLow(vector, zero);
929 Sse2.StoreAligned((byte*)(pUtf16Buffer + num3), source);
930 num3 += num / 2;
931 }
932 return num3;
933 }
935 {
936 }
937 throw new PlatformNotSupportedException();
938 }
940 {
941 }
942 throw new PlatformNotSupportedException();
943 }
945 {
946 }
947 throw new PlatformNotSupportedException();
948 }
950 {
951 }
952 throw new PlatformNotSupportedException();
953 }
static unsafe Vector128< sbyte > LoadVector128(sbyte *address)
Definition Sse2.cs:582
static int MoveMask(Vector128< sbyte > value)
Definition Sse2.cs:772
static unsafe void Store(sbyte *address, Vector128< sbyte > source)
Definition Sse2.cs:1287
static unsafe void StoreAligned(sbyte *address, Vector128< sbyte > source)
Definition Sse2.cs:1197
static Vector128< byte > UnpackLow(Vector128< byte > left, Vector128< byte > right)
Definition Sse2.cs:1467
static new bool IsSupported
Definition Sse2.cs:60
static Vector128< byte > UnpackHigh(Vector128< byte > left, Vector128< byte > right)
Definition Sse2.cs:1422

References System.Runtime.Intrinsics.Arm.AdvSimd.Arm64.IsSupported, System.Runtime.Intrinsics.Arm.AdvSimd.IsSupported, System.Runtime.Intrinsics.X86.Sse2.IsSupported, System.Runtime.Intrinsics.X86.Sse2.LoadVector128(), System.Runtime.Intrinsics.X86.Sse2.MoveMask(), System.source, System.Runtime.Intrinsics.X86.Sse2.Store(), System.Runtime.Intrinsics.X86.Sse2.StoreAligned(), System.Runtime.Intrinsics.X86.Sse2.UnpackHigh(), System.Runtime.Intrinsics.X86.Sse2.UnpackLow(), and System.Runtime.Intrinsics.Vector128< T >.Zero.

Referenced by System.Text.ASCIIUtility.WidenAsciiToUtf16().