From: t-mustafin <66252296+t-mustafin@users.noreply.github.com> Date: Wed, 13 Sep 2023 18:57:49 +0000 (+0300) Subject: [RISC-V] Initial commit for libraries directory (#90203) X-Git-Tag: accepted/tizen/unified/riscv/20231226.055536~41 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=eaea85e9fa89ca1db79f0ae7db1b9d441a795dd2;p=platform%2Fupstream%2Fdotnet%2Fruntime.git [RISC-V] Initial commit for libraries directory (#90203) * [RISC-V] Initial commit for libraries directory * Update src/libraries/System.Reflection.Metadata/tests/PortableExecutable/PEHeadersTests.cs Co-authored-by: Jan Kotas --------- Co-authored-by: Jan Kotas --- diff --git a/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs b/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs index c0bbcaa..431bc77 100644 --- a/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs +++ b/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs @@ -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; diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Architecture.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Architecture.cs index ec9641f..2e1c3c5 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Architecture.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Architecture.cs @@ -50,5 +50,12 @@ namespace System.Runtime.InteropServices /// A PowerPC 64-bit (little-endian) processor architecture. /// Ppc64le, + /// + /// A RiscV 64-bit processor architecture. + /// + /// + /// This value indicates RV64GC set of extensions. + /// + RiscV64, } } diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/RuntimeInformation.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/RuntimeInformation.cs index 281b00f..1bb3db3 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/RuntimeInformation.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/RuntimeInformation.cs @@ -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 diff --git a/src/libraries/System.Reflection.Metadata/ref/System.Reflection.Metadata.cs b/src/libraries/System.Reflection.Metadata/ref/System.Reflection.Metadata.cs index 61314bf..d656738 100644 --- a/src/libraries/System.Reflection.Metadata/ref/System.Reflection.Metadata.cs +++ b/src/libraries/System.Reflection.Metadata/ref/System.Reflection.Metadata.cs @@ -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 { diff --git a/src/libraries/System.Reflection.Metadata/src/System/Reflection/PortableExecutable/Machine.cs b/src/libraries/System.Reflection.Metadata/src/System/Reflection/PortableExecutable/Machine.cs index c4d3e33..a5bbe07 100644 --- a/src/libraries/System.Reflection.Metadata/src/System/Reflection/PortableExecutable/Machine.cs +++ b/src/libraries/System.Reflection.Metadata/src/System/Reflection/PortableExecutable/Machine.cs @@ -139,5 +139,20 @@ namespace System.Reflection.PortableExecutable /// LOONGARCH64 /// LoongArch64 = 0x6264, + + /// + /// RISCV32 + /// + RiscV32 = 0x5032, + + /// + /// RISCV64 + /// + RiscV64 = 0x5064, + + /// + /// RISCV128 + /// + RiscV128 = 0x5128, } } diff --git a/src/libraries/System.Runtime.InteropServices.RuntimeInformation/tests/CheckArchitectureTests.cs b/src/libraries/System.Runtime.InteropServices.RuntimeInformation/tests/CheckArchitectureTests.cs index 29c91dc..74612fb 100644 --- a/src/libraries/System.Runtime.InteropServices.RuntimeInformation/tests/CheckArchitectureTests.cs +++ b/src/libraries/System.Runtime.InteropServices.RuntimeInformation/tests/CheckArchitectureTests.cs @@ -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; diff --git a/src/libraries/System.Runtime/ref/System.Runtime.cs b/src/libraries/System.Runtime/ref/System.Runtime.cs index bc7e04a..3a772c1 100644 --- a/src/libraries/System.Runtime/ref/System.Runtime.cs +++ b/src/libraries/System.Runtime/ref/System.Runtime.cs @@ -13403,6 +13403,7 @@ namespace System.Runtime.InteropServices LoongArch64 = 6, Armv6 = 7, Ppc64le = 8, + RiscV64 = 9, } public enum CharSet {