[RISC-V] Initial commit for libraries directory (#90203)
authort-mustafin <66252296+t-mustafin@users.noreply.github.com>
Wed, 13 Sep 2023 18:57:49 +0000 (21:57 +0300)
committerGleb Balykov <g.balykov@samsung.com>
Fri, 15 Dec 2023 12:28:32 +0000 (15:28 +0300)
* [RISC-V] Initial commit for libraries directory

* Update src/libraries/System.Reflection.Metadata/tests/PortableExecutable/PEHeadersTests.cs

Co-authored-by: Jan Kotas <jkotas@microsoft.com>
---------

Co-authored-by: Jan Kotas <jkotas@microsoft.com>
src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs
src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Architecture.cs
src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/RuntimeInformation.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

index c0bbcaa..431bc77 100644 (file)
@@ -66,6 +66,7 @@ namespace System
         public static bool IsS390xProcess => (int)RuntimeInformation.ProcessArchitecture == 5; // Architecture.S390x
         public static bool IsArmv6Process => (int)RuntimeInformation.ProcessArchitecture == 7; // Architecture.Armv6
         public static bool IsPpc64leProcess => (int)RuntimeInformation.ProcessArchitecture == 8; // Architecture.Ppc64le
+        public static bool IsRiscV64Process => (int)RuntimeInformation.ProcessArchitecture == 9; // Architecture.RiscV64;
         public static bool IsX64Process => RuntimeInformation.ProcessArchitecture == Architecture.X64;
         public static bool IsX86Process => RuntimeInformation.ProcessArchitecture == Architecture.X86;
         public static bool IsNotX86Process => !IsX86Process;
index ec9641f..2e1c3c5 100644 (file)
@@ -50,5 +50,12 @@ namespace System.Runtime.InteropServices
         /// A PowerPC 64-bit (little-endian) processor architecture.
         /// </summary>
         Ppc64le,
+        /// <summary>
+        /// A RiscV 64-bit processor architecture.
+        /// </summary>
+        /// <remarks>
+        /// This value indicates RV64GC set of extensions.
+        /// </remarks>
+        RiscV64,
     }
 }
index 281b00f..1bb3db3 100644 (file)
@@ -71,7 +71,7 @@ namespace System.Runtime.InteropServices
 #elif TARGET_POWERPC64
             => Architecture.Ppc64le
 #elif TARGET_RISCV64
-            => (Architecture)9 // TODO-RISCV64: go though API review for RiscV64
+            => Architecture.RiscV64
 #else
 #error Unknown Architecture
 #endif
index 61314bf..d656738 100644 (file)
@@ -3293,6 +3293,9 @@ namespace System.Reflection.PortableExecutable
         Arm64 = (ushort)43620,
         LoongArch32 = (ushort)25138,
         LoongArch64 = (ushort)25188,
+        RiscV32 = (ushort)20530,
+        RiscV64 = (ushort)20580,
+        RiscV128 = (ushort)20776,
     }
     public partial class ManagedPEBuilder : System.Reflection.PortableExecutable.PEBuilder
     {
index c4d3e33..a5bbe07 100644 (file)
@@ -139,5 +139,20 @@ namespace System.Reflection.PortableExecutable
         /// LOONGARCH64
         /// </summary>
         LoongArch64 = 0x6264,
+
+        /// <summary>
+        /// RISCV32
+        /// </summary>
+        RiscV32 = 0x5032,
+
+        /// <summary>
+        /// RISCV64
+        /// </summary>
+        RiscV64 = 0x5064,
+
+        /// <summary>
+        /// RISCV128
+        /// </summary>
+        RiscV128 = 0x5128,
     }
 }
index 29c91dc..74612fb 100644 (file)
@@ -60,6 +60,10 @@ namespace System.Runtime.InteropServices.RuntimeInformationTests
                     Assert.Equal(Architecture.Ppc64le, processArch);
                     break;
 
+                case Architecture.RiscV64:
+                    Assert.Equal(Architecture.RiscV64, processArch);
+                    break;
+
                 default:
                     Assert.False(true, "Unexpected Architecture.");
                     break;
index bc7e04a..3a772c1 100644 (file)
@@ -13403,6 +13403,7 @@ namespace System.Runtime.InteropServices
         LoongArch64 = 6,
         Armv6 = 7,
         Ppc64le = 8,
+        RiscV64 = 9,
     }
     public enum CharSet
     {