[LoongArch64] Port libraries directory (#62888)
authorQiao <35673267+shushanhf@users.noreply.github.com>
Fri, 7 Jan 2022 16:24:34 +0000 (00:24 +0800)
committerGitHub <noreply@github.com>
Fri, 7 Jan 2022 16:24:34 +0000 (08:24 -0800)
Co-authored-by: qiaopengcheng <qiaopengcheng-hf@loongson.cn>
Co-authored-by: Jan Kotas <jkotas@microsoft.com>
20 files changed:
src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj
src/libraries/Microsoft.NETCore.Platforms/src/runtime.compatibility.json
src/libraries/Microsoft.NETCore.Platforms/src/runtime.json
src/libraries/Microsoft.NETCore.Platforms/src/runtimeGroups.props
src/libraries/System.Private.CoreLib/src/Internal/Padding.cs
src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems
src/libraries/System.Private.CoreLib/src/System/Buffer.Unix.cs
src/libraries/System.Private.CoreLib/src/System/Buffer.cs
src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Architecture.cs
src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/RuntimeInformation.ProcessArchitecture.cs
src/libraries/System.Private.CoreLib/src/System/SpanHelpers.cs
src/libraries/System.Private.CoreLib/src/System/Threading/PortableThreadPool.WorkerThread.cs
src/libraries/System.Reflection.Metadata/ref/System.Reflection.Metadata.cs
src/libraries/System.Reflection.Metadata/src/System/Reflection/PortableExecutable/Machine.cs
src/libraries/System.Runtime.InteropServices.RuntimeInformation/tests/CheckArchitectureTests.cs
src/libraries/System.Runtime/ref/System.Runtime.cs
src/native/corehost/bundle/reader.h
src/native/corehost/hostmisc/utils.cpp
src/native/eventpipe/ep-event-source.c
src/native/libs/System.Native/pal_runtimeinformation.h

index f62c8b9..e1230d5 100644 (file)
     <PlatformTarget>AnyCPU</PlatformTarget>
     <DefineConstants>$(DefineConstants);TARGET_ARM64</DefineConstants>
   </PropertyGroup>
+  <PropertyGroup Condition="'$(Platform)' == 'loongarch64'">
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <DefineConstants>$(DefineConstants);TARGET_LOONGARCH64</DefineConstants>
+  </PropertyGroup>
 
   <!-- Configuration specific properties -->
   <PropertyGroup Condition="'$(Configuration)' == 'Debug' or '$(Configuration)' == 'Checked'">
index 8d9a538..3d7f5a5 100644 (file)
     "any",
     "base"
   ],
+  "linux-loongarch64": [
+    "linux-loongarch64",
+    "linux",
+    "unix-loongarch64",
+    "unix",
+    "any",
+    "base"
+  ],
   "linux-mips64": [
     "linux-mips64",
     "linux",
     "any",
     "base"
   ],
+  "unix-loongarch64": [
+    "unix-loongarch64",
+    "unix",
+    "any",
+    "base"
+  ],
   "unix-mips64": [
     "unix-mips64",
     "unix",
     "any",
     "base"
   ]
-}
+}
\ No newline at end of file
index 39ca7bd..76d454f 100644 (file)
         "unix-armel"
       ]
     },
+    "linux-loongarch64": {
+      "#import": [
+        "linux",
+        "unix-loongarch64"
+      ]
+    },
     "linux-mips64": {
       "#import": [
         "linux",
         "unix"
       ]
     },
+    "unix-loongarch64": {
+      "#import": [
+        "unix"
+      ]
+    },
     "unix-mips64": {
       "#import": [
         "unix"
       ]
     }
   }
-}
+}
\ No newline at end of file
index bc7832c..b834534 100644 (file)
@@ -3,11 +3,11 @@
   <ItemGroup>
     <RuntimeGroup Include="unix">
       <Parent>any</Parent>
-      <Architectures>x64;x86;arm;armel;arm64;mips64;s390x</Architectures>
+      <Architectures>x64;x86;arm;armel;arm64;loongarch64;mips64;s390x</Architectures>
     </RuntimeGroup>
     <RuntimeGroup Include="linux">
       <Parent>unix</Parent>
-      <Architectures>x64;x86;arm;armel;arm64;mips64;s390x</Architectures>
+      <Architectures>x64;x86;arm;armel;arm64;loongarch64;mips64;s390x</Architectures>
     </RuntimeGroup>
     <RuntimeGroup Include="linux-musl">
       <Parent>linux</Parent>
index 17f3643..5f846ce 100644 (file)
@@ -9,7 +9,7 @@ namespace Internal
     internal static class PaddingHelpers
     {
         /// <summary>A size greater than or equal to the size of the most common CPU cache lines.</summary>
-#if TARGET_ARM64
+#if TARGET_ARM64 || TARGET_LOONGARCH64
         internal const int CACHE_LINE_SIZE = 128;
 #else
         internal const int CACHE_LINE_SIZE = 64;
index 7ee14fe..5c3b0ad 100644 (file)
@@ -17,7 +17,7 @@
     <SupportsX86Intrinsics Condition="'$(Platform)' == 'x64' or ('$(Platform)' == 'x86' and '$(TargetsUnix)' != 'true')">true</SupportsX86Intrinsics>
     <ILLinkSharedDirectory>$(MSBuildThisFileDirectory)ILLink\</ILLinkSharedDirectory>
     <IsBigEndian Condition="'$(Platform)' == 's390x'">true</IsBigEndian>
-    <Is64Bit Condition="'$(Platform)' == 'arm64' or '$(Platform)' == 'x64' or '$(Platform)' == 's390x'">true</Is64Bit>
+    <Is64Bit Condition="'$(Platform)' == 'arm64' or '$(Platform)' == 'x64' or '$(Platform)' == 's390x' or '$(Platform)' == 'loongarch64'">true</Is64Bit>
     <UseMinimalGlobalizationData Condition="'$(TargetsiOS)' == 'true' or '$(TargetstvOS)' == 'true' or '$(TargetsBrowser)' == 'true'">true</UseMinimalGlobalizationData>
   </PropertyGroup>
   <PropertyGroup>
index 4d0c18c..008bc93 100644 (file)
@@ -5,7 +5,7 @@ namespace System
 {
     public static partial class Buffer
     {
-#if TARGET_ARM64
+#if TARGET_ARM64 || TARGET_LOONGARCH64
         // Managed code is currently faster than glibc unoptimized memmove
         // TODO-ARM64-UNIX-OPT revisit when glibc optimized memmove is in Linux distros
         // https://github.com/dotnet/runtime/issues/8897
index 64bd6fc..027c138 100644 (file)
@@ -1,7 +1,7 @@
 // Licensed to the .NET Foundation under one or more agreements.
 // The .NET Foundation licenses this file to you under the MIT license.
 
-#if TARGET_AMD64 || TARGET_ARM64 || (TARGET_32BIT && !TARGET_ARM)
+#if TARGET_AMD64 || TARGET_ARM64 || (TARGET_32BIT && !TARGET_ARM) || TARGET_LOONGARCH64
 #define HAS_CUSTOM_BLOCKS
 #endif
 
index 2c52a9b..225fec2 100644 (file)
@@ -10,6 +10,7 @@ namespace System.Runtime.InteropServices
         Arm,
         Arm64,
         Wasm,
-        S390x
+        S390x,
+        LoongArch64
     }
 }
index 298d039..0da595b 100644 (file)
@@ -18,6 +18,8 @@ namespace System.Runtime.InteropServices
             => Architecture.Wasm;
 #elif TARGET_S390X
             => Architecture.S390x;
+#elif TARGET_LOONGARCH64
+            => Architecture.LoongArch64;
 #else
 #error Unknown Architecture
 #endif
index a7f99e4..9cc7516 100644 (file)
@@ -14,7 +14,7 @@ namespace System
             if (byteLength == 0)
                 return;
 
-#if TARGET_AMD64 || TARGET_ARM64
+#if TARGET_AMD64 || TARGET_ARM64 || TARGET_LOONGARCH64
             // The exact matrix on when ZeroMemory is faster than InitBlockUnaligned is very complex. The factors to consider include
             // type of hardware and memory alignment. This threshold was chosen as a good balance across different configurations.
             if (byteLength > 768)
index 796c0e5..7a79c99 100644 (file)
@@ -13,7 +13,7 @@ namespace System.Threading
         private static class WorkerThread
         {
             private const int SemaphoreSpinCountDefaultBaseline = 70;
-#if !TARGET_ARM64 && !TARGET_ARM
+#if !TARGET_ARM64 && !TARGET_ARM && !TARGET_LOONGARCH64
             private const int SemaphoreSpinCountDefault = SemaphoreSpinCountDefaultBaseline;
 #else
             // On systems with ARM processors, more spin-waiting seems to be necessary to avoid perf regressions from incurring
index fee9b78..db86c83 100644 (file)
@@ -3271,6 +3271,8 @@ namespace System.Reflection.PortableExecutable
         Amd64 = (ushort)34404,
         M32R = (ushort)36929,
         Arm64 = (ushort)43620,
+        LoongArch32 = (ushort)25138,
+        LoongArch64 = (ushort)25188,
     }
     public partial class ManagedPEBuilder : System.Reflection.PortableExecutable.PEBuilder
     {
index 2d1dc8e..c4d3e33 100644 (file)
@@ -129,5 +129,15 @@ namespace System.Reflection.PortableExecutable
         /// ARM64
         /// </summary>
         Arm64 = 0xAA64,
+
+        /// <summary>
+        /// LOONGARCH32
+        /// </summary>
+        LoongArch32 = 0x6232,
+
+        /// <summary>
+        /// LOONGARCH64
+        /// </summary>
+        LoongArch64 = 0x6264,
     }
 }
index 50c52fa..6f1b289 100644 (file)
@@ -40,6 +40,10 @@ namespace System.Runtime.InteropServices.RuntimeInformationTests
                     Assert.Equal(Architecture.S390x, processArch);
                     break;
 
+                case Architecture.LoongArch64:
+                    Assert.Equal(Architecture.LoongArch64, processArch);
+                    break;
+
                 default:
                     Assert.False(true, "Unexpected Architecture.");
                     break;
index 840ecbd..41c562f 100644 (file)
@@ -13431,6 +13431,7 @@ namespace System.Runtime.InteropServices
         Arm64 = 3,
         Wasm = 4,
         S390x = 5,
+        LoongArch64 = 6,
     }
     public enum CharSet
     {
index a4c1e07..cc905a1 100644 (file)
@@ -17,6 +17,8 @@
 
 #if defined(TARGET_ARM64)
 #define TARGET_CPU_TYPE CPU_TYPE_ARM64
+#elif defined(TARGET_LOONGARCH64)
+#define TARGET_CPU_TYPE CPU_TYPE_LOONGARCH64
 #else
 #define TARGET_CPU_TYPE CPU_TYPE_X86_64
 #endif
index 21cc7e9..7f5fdbc 100644 (file)
@@ -195,6 +195,8 @@ const pal::char_t* get_arch()
     return _X("arm");
 #elif defined(TARGET_ARM64)
     return _X("arm64");
+#elif defined(TARGET_LOONGARCH64)
+    return _X("loongarch64");
 #elif defined(TARGET_S390X)
     return _X("s390x");
 #else
index 36eac2d..78d1c48 100644 (file)
@@ -40,6 +40,8 @@ const ep_char8_t* _ep_arch_info = "arm32";
 const ep_char8_t* _ep_arch_info = "arm64";
 #elif defined(TARGET_S390X)
 const ep_char8_t* _ep_arch_info = "s390x";
+#elif defined(TARGET_LOONGARCH64)
+const ep_char8_t* _ep_arch_info = "loongarch64";
 #else
 const ep_char8_t* _ep_arch_info = "Unknown";
 #endif
index 6b13077..adae223 100644 (file)
@@ -22,5 +22,6 @@ enum
     ARCH_ARM,
     ARCH_ARM64,
     ARCH_WASM,
-    ARCH_S390X
+    ARCH_S390X,
+    ARCH_LOONGARCH64
 };